-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
feat(core): Set default scope for BaseClient methods #11775
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(core): Set default scope for BaseClient methods #11775
Conversation
This comment was marked as off-topic.
This comment was marked as off-topic.
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.
This feels right to me - thoughts but I want to make sure @mydea is fine with it.
It feels OK, but I guess the main downside is that it can be confusing when working with multi clients 🤔 You'll easily get leakage in this scenario: const client = new BrowserClient();
const client2 = new BrowserClient();
setCurrentClient(client);
client2.captureException(); // <-- will have scope from `client` applied Not sure how much we care about this, though... Generally, what's the use case to call this directly on the client? |
Working with multiple clients is probably the only use case. The client is passed to integrations though so users might use it there if they don't know it's limitations. Some jsdocs that say It just felt like a bit of a footgun that |
I think my main concern with this is that it does not play well with this scenario: const scope1 = new Scope();
const scope2 = new Scope();
const client1 = new Client();
const client2 = new Client();
scope1.setClient(client1);
scope2.setClient(client2);
client1.captureException(...); // <-- gets some other scope applied, not scope1 obviously this is also not great today, but I'd argue that it's better to not apply any scope here than to apply the incorrect one...? Overall I'd tend to improve this through documentation/jsdoc. E.g. it makes sense to add to the |
Ah yes, agreed!
Ok, I'll change this PR to do that. |
Ah sorry, one more thought...
If you have to pass a scope, should we make the Unfortunately, we'd need to change the order of the parameters to do this... |
I think this is too much friction for now, but we should evaluate this for later on |
client.captureException/captureMessage/captureEvent
do not include current scope in events by default. This is in contrast tocaptureException/captureMessage/captureEvent
exported from every SDK which include the current scope by default.This PR changes the parameter names (
scope
>currentScope
) and adds jsdocs to make this more clear. It also changes the parameters to use the scope interface instead of the scope class.