Skip to content

Commit 75a3e47

Browse files
committed
Update docs
1 parent 66d8a8e commit 75a3e47

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

guides/Getting Started.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,8 @@ The `ErrorTracker.set_context/1` function stores the given context in the curren
106106
ErrorTracker.set_context(%{user_id: conn.assigns.current_user.id})
107107
```
108108

109+
There are some requirements on the type of data that can be included in the context, so we recommend taking a look at `set_context/1` documentation
110+
109111
## Manual error tracking
110112

111113
If you want to report custom errors that fall outside the default integration scope, you may use `ErrorTracker.report/2`. This allows you to report an exception yourself:

lib/error_tracker.ex

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ defmodule ErrorTracker do
4141
can gather, but aside from that, you can also add your own information. You can
4242
do this in a per-process basis or in a per-call basis (or both).
4343
44+
There are some requirements on the type of data that can be included in the
45+
context, so we recommend taking a look at `set_context/1` documentation.
46+
4447
**Per process**
4548
4649
This allows you to set a general context for the current process such as a Phoenix
@@ -152,6 +155,17 @@ defmodule ErrorTracker do
152155
153156
That means that any existing data on deep levels for he current context will
154157
be replaced if the first level key is received on the new contents.
158+
159+
## Content serialization
160+
161+
The content stored on the context should be serializable using the JSON library
162+
used by the application (usually `Jason`), so it is rather recommended to use
163+
primitive types (strings, numbers, booleans...).
164+
165+
If you still need to pass more complex data types to your context, please test
166+
that they can be encoded to JSON or storing the errors will fail. In the case
167+
of `Jason` that may require defining an Encoder for that data type if not
168+
included by default.
155169
"""
156170
@spec set_context(context()) :: context()
157171
def set_context(params) when is_map(params) do

0 commit comments

Comments
 (0)