-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
feat: Explicit Scope for captureException and captureMessage #2627
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
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.
While I really appreciate the PR description maybe let's add a few sentences about the motivation and link issues. Also, let's link the notion doc that will soon move to develop.sentry.dev
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.
Good PR, before merging, let's discuss in which version we want to release this.
@HazAT @kamilogorek How does it differ from |
When will be this one be released? |
@diegopamio already shipped in |
@kamilogorek @HazAT Could you please clarify the difference between withScope and this additional argument? Thanks! |
@3zzy there's effectively none for most of the cases. The only difference is that |
@kamilogorek Thanks, but it doesn't seem to work when using a custom hub, for example:
The error is tracked in Sentry but no tag or user ID is visible. |
@3zzy hub has a different function definition, that's why it doesn't work like that. Explicit scopes are meant to make "common usecases" easier to execute. Compare https://github.com/getsentry/sentry-javascript/blob/master/packages/minimal/src/index.ts#L24 to https://github.com/getsentry/sentry-javascript/blob/master/packages/hub/src/hub.ts#L157 If you want to use them in custom hubs, you need to tell the hub that what you pass to it is a var client1 = new Sentry.BrowserClient({ ... });
var hub1 = new Sentry.Hub(client1)
hub1.captureException(new Error("wat"), {
captureContext: {
user: {
id: 1337
},
tags: {
wat: "ok",
}
}
}); |
This PR introduces a second, optional argument to
captureException
andcaptureMessage
methods, that allows to provide some custom data directly to the scope.Provided data will be merged with what's already on the scope, unless explicitly cleared using a callback method.
It works in three variations:
Scope
instance that'll extract the attributes fromList of allowed keys:
Example usages:
Ref: #1607
Notion: https://www.notion.so/sentry/Explicit-Scope-797e8b674010494d8854001281cf8769#8be8a9f0b4064842904d3e649bfac407
Asana: https://app.asana.com/0/1169125731075107/1175779896688409