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

Conversation

mydea
Copy link
Member

@mydea mydea commented Jul 3, 2025

This adds docs explaining how captureException handles different kinds of objects.

Closes https://linear.app/getsentry/issue/FE-507/improve-js-sdk-based-on-user-feedback

@mydea mydea requested review from BYK, AbhiPrasad and andreiborza July 3, 2025 13:58
@mydea mydea self-assigned this Jul 3, 2025
Copy link

vercel bot commented Jul 3, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
sentry-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 3, 2025 2:11pm
1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
develop-docs ⬜️ Ignored (Inspect) Jul 3, 2025 2:11pm

Copy link

codecov bot commented Jul 3, 2025

Bundle Report

Changes will increase total bundle size by 180 bytes (0.0%) ⬆️. This is within the configured threshold ✅

Detailed changes
Bundle name Size Change
sentry-docs-server-cjs 11.8MB 186 bytes (0.0%) ⬆️
sentry-docs-client-array-push 9.8MB -6 bytes (-0.0%) ⬇️

Affected Assets, Files, and Routes:

view changes for bundle: sentry-docs-client-array-push

Assets Changed:

Asset Name Size Change Total Size Change (%)
static/chunks/pages/_app-*.js -3 bytes 873.24kB -0.0%
static/chunks/7750-*.js -3 bytes 415.85kB -0.0%
server/middleware-*.js 5.55kB 6.55kB 555.3% ⚠️
server/middleware-*.js -5.55kB 1.0kB -84.74%
static/Y423AMCSnpLXkQiW4j3lw/_buildManifest.js (New) 684 bytes 684 bytes 100.0% 🚀
static/Y423AMCSnpLXkQiW4j3lw/_ssgManifest.js (New) 77 bytes 77 bytes 100.0% 🚀
static/eIe1YqfXlnwRYGw2MaR38/_buildManifest.js (Deleted) -684 bytes 0 bytes -100.0% 🗑️
static/eIe1YqfXlnwRYGw2MaR38/_ssgManifest.js (Deleted) -77 bytes 0 bytes -100.0% 🗑️
view changes for bundle: sentry-docs-server-cjs

Assets Changed:

Asset Name Size Change Total Size Change (%)
1729.js -3 bytes 1.64MB -0.0%
../instrumentation.js -3 bytes 973.36kB -0.0%
9523.js -3 bytes 949.31kB -0.0%
../app/[[...path]]/page.js.nft.json 65 bytes 693.4kB 0.01%
../app/platform-redirect/page.js.nft.json 65 bytes 693.32kB 0.01%
../app/sitemap.xml/route.js.nft.json 65 bytes 691.29kB 0.01%

// --> "Object captured as 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 😅

@@ -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"

Copy link
Contributor

@coolguyzone coolguyzone left a comment

Choose a reason for hiding this comment

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

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants