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
feat: Add source map debug ids #7068
Conversation
size-limit report 📦
|
const INJECTOR_CODE = | ||
'\n!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=(new Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="__DEBUG_ID__")}catch(e){}}()'; | ||
|
||
const DEBUG_COMMENT_CODE = '\n//# sentryDebugId=__DEBUG_ID__'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's call this __SENTRY_DEBUG_ID__
to stay on the safe side.
const DEBUG_COMMENT_CODE = '\n//# sentryDebugId=__DEBUG_ID__'; | |
const DEBUG_COMMENT_CODE = '\n//# sentryDebugId=__DEBUG_ID__'; |
packages/browser/src/eventbuilder.ts
Outdated
exception.stacktrace?.frames?.forEach(eventFrame => { | ||
let debugId: string | undefined; | ||
Object.keys(GLOBAL_OBJ._sentryDebugIds!).forEach(sentryDebugIdStack => { | ||
const stackFrames = stackParser(sentryDebugIdStack); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's cache this result.
packages/browser/package.json
Outdated
"yargs": "^17.6.2", | ||
"uuid": "^9.0.0" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's try and avoid adding these deps if we can!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
uuid
we can just generate ourselves, we don't need strict uuid4
(copy paste the implementation in Sentry you have to)
yargs
is more painful, but just parse the args ourselves. We don't have a super complicated CLI atm, so no need to worry about ordering concerns or similar for now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As discussed: Since this is only a poc I removed the CLI
let debugIdCache = debugIdParserCache.get(parser); | ||
if (!debugIdCache) { | ||
debugIdCache = new Map(); | ||
debugIdParserCache.set(parser, debugIdCache); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
m: This is unbounded, which is not a problem for browser js, but it is for node. We may have re-think this as a result, or add some crude eviction mechanism.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As discussed: The upper bound is the number of modules that have been injected with the debug id times the amount of stack trace parsers. I am gonna go ahead and say this is safely cachable.
Ref: getsentry/team-webplatform-meta#17
Most importantly this PR adds adding debug ids to individual stack frames that have previously been injected into the bundle.
Additionally, this PR adds a small lil' script to inject debug IDs into JS bundles.