Description
Is 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?
@sentry/angular
SDK Version
7.6.0
Framework Version
14.0.0
Link to Sentry event
No response
Steps to Reproduce
Hello,
We are facing some issues with the latest browser/angular SDK version (7.6.0) because the context data (tags, extra, etc), which we just set before capture the event by Sentry SDK, don't appear in the Sentry dashboard along with the error. This problem just shows up when the error happens in an async context like:
setTimeout(() => {
const c = null;
const v = c.pop;
}, 1000)
However, if the error happens in a sync context, the error context data does appear in the Sentry dashboard as expected.
In order to set a specific context for an error we have unsuccessfully tried all ways that the documentation says here: https://docs.sentry.io/platforms/javascript/enriching-events/context/#passing-context-directly
For example like that:
Sentry.withScope(scope => {
scope.setTag('customTag', 'error');
scope.setExtra('test', 'this is a test');
scope.setContext('test', { value: 'test context' });
Sentry.captureException(extractedError);
});
Or like that:
Sentry.captureException(error, {
tags: {
section: "articles",
},
});
For our surprise, this just happens in SDK version higher than 7.0, since we have also tried to do the same with the latest 6x SDK version and it is working property over it (all data is shown up in the Sentry dashboard as expected).
Please, is there some official workaround to deal with this issue?
Thanks in advance,
Expected Result
Sentry SDK should record tags, extra and context we set for the error captured by Sentry SDK and they also should be shown up in the Sentry dashboard.
Actual Result
Sentry SDK doesn't record properly the error tags and context data when the error happens in an async context. It seems that all data set in the error scope is lost.