Skip to content

feat(js): Add docs about serialization of captureException objects #14256

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion docs/platforms/javascript/common/apis.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,16 @@ more information on how to use integrations.
only `Error` objects, but also other objects as `exception` - in that case,
the SDK will attempt to serialize the object for you, and the stack trace will
be generated by the SDK and may be less accurate.

Please note that the serialization of objects may not be perfect, as it works based on simple heuristics. Objects that are not `Error` objects will be generally be serialized as follows:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Please note that the serialization of objects may not be perfect, as it works based on simple heuristics. Objects that are not `Error` objects will be generally be serialized as follows:
Please note that the serialization of objects may not be perfect, as it's based on simple heuristics. Objects that are not `Error` objects will be generally be serialized as follows:


```javascript
Sentry.captureException({ prop1: "value1", prop2: "value2" });
// --> "Object captured as exception with keys: prop1, prop2"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// --> "Object captured as exception with keys: prop1, prop2"
// --> "Object captured as an exception with keys: prop1, prop2"

```

Note that built-in objects may be serialized differently. If you want to capture objects in a specific way, you can use the `captureContext` parameter to attach additional data to the event.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe provide an example for the HTTP Response objects for demonstration? Would also help LLMs as a 1-shot prompt 😅


</SdkApi>

<SdkApi
Expand Down Expand Up @@ -1138,7 +1148,7 @@ export const load = wrapServerLoadWithSentry(({ fetch }) => {

</SdkApi>

## Instrumenting Server Routes
## Instrumenting Server Routes

<SdkApi
name="wrapServerRouteWithSentry"
Expand Down