-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
fix: Use correct types for event context data #2910
Conversation
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.
45f14a0
to
933f399
Compare
933f399
to
150f7f2
Compare
size-limit report
|
d17146a
to
86042df
Compare
86042df
to
9fc9d6d
Compare
82cd860
to
56e2c62
Compare
@@ -853,7 +853,7 @@ export class Tracing implements Integration { | |||
Tracing._log(`[Tracing] Transaction: ${SpanStatus.Cancelled} since it maxed out maxTransactionDuration`); | |||
if (event.contexts && event.contexts.trace) { | |||
event.contexts.trace = { | |||
...event.contexts.trace, | |||
...(typeof event.contexts.trace === 'object' && event.contexts.trace), |
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.
Why do we now do a type check here?
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.
Because unknown
is more restrictive than any
, and requires type check before it can be spread. On the other hand, it doesnt require unnecessary no-explcit-any
linting rule.
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.
event.contexts.trace
has type Context
, it must be an object, mustn't it?
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.
Fixed
Co-authored-by: Rodolfo Carvalho <[email protected]>
public setContext(key: string, context: Context | null): this { | ||
if (context === null) { | ||
// eslint-disable-next-line @typescript-eslint/no-dynamic-delete | ||
delete this._contexts[key]; |
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.
Hmm this is more than changing the types, would the previous code delete keys?! Was this a bug?
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.
From https://develop.sentry.dev/sdk/unified-api/
So now setting a context to null deletes it. Let's document this in the changelog.
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.
Was a bug, fixed.
per #2905 (comment)