Context not being reliably set in withScope. Potential v7 regression.
See original GitHub issueIs there an existing issue for this?
- I have checked for existing issues https://github.com/getsentry/sentry-javascript/issues
- I have reviewed the documentation https://docs.sentry.io/
- I am using the latest SDK release https://github.com/getsentry/sentry-javascript/releases
How do you use Sentry?
Sentry Saas (sentry.io)
Which package are you using?
SDK Version
7.1.1
Framework Version
7.1.1
Link to Sentry event
Steps to Reproduce
I have a small class that wraps sentry for capturing messages and exceptions. As shown below, for some reason, context does not get reliably sent.
public reportMessage(
message: string,
options?: { context?: Context; tags?: Tags }
) {
Sentry.withScope((scope) => {
if (options?.context) {
scope.setContext("context", this._stringifyContext(options.context))
}
if (options?.tags) {
scope.setTags(options.tags);
}
Sentry.captureMessage(message);
});
}
Below are two examples where it works every time. And I do not understand why.
If I do anything extra like this console log:
Sentry.withScope((scope) => {
if (options?.context) {
console.log("literally anything")
scope.setContext("context", this._stringifyContext(options.context));
}
if (options?.tags) {
scope.setTags(options.tags);
}
Sentry.captureMessage(message);
});
Or even just setting context to a new variable first like this:
Sentry.withScope((scope) => {
if (options?.context) {
const context = this._stringifyContext(options.context);
scope.setContext("context", context);
}
if (options?.tags) {
scope.setTags(options.tags);
}
Sentry.captureMessage(message);
});
Is this a bug with 7.0? This didn’t happen before I upgraded.
Expected Result
Custom context should show up on issue in Sentry.io console
Actual Result
Custom context does not show up in Sentry.io console
Issue Analytics
- State:
- Created a year ago
- Reactions:1
- Comments:9 (4 by maintainers)
Top Results From Across the Web
sentry-javascript/CHANGELOG.md at master
JS SDK works in older browsers that do not support ES6 or ES6+ (e.g. object spread) features. feat(react): Use state context for Redux...
Read more >Multicollinearity in Regression Analysis: Problems, ...
Multicollinearity is when independent variables in a regression model are correlated. I explore its problems, testing your model for it, and solutions.
Read more >Contexts and Dependency Injection for the Java EE platform
Getting Start with Weld, the CDI Reference Implementation . ... Prior to Java EE 6, there was no clear definition of the term...
Read more >Scopes and Hubs for JavaScript
When an event is captured and sent to Sentry, SDKs will merge that event data with extra information from the current scope.
Read more >Fix list for IBM WebSphere Application Server V8.5
IBM WebSphere Application Server provides periodic fixes for the base and Network Deployment editions of release V8.5. The following is a complete listing ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This should be fixed by
7.2.0
: https://github.com/getsentry/sentry-javascript/releases/tag/7.2.0Good catch! We’ll be fixing this ASAP and cutting a release very soon.