-
-
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
feat(core): Add getGlobalScope()
method
#9920
Conversation
size-limit report 📦
|
packages/core/src/scope.ts
Outdated
@@ -469,7 +472,7 @@ export class Scope implements ScopeInterface { | |||
} | |||
|
|||
/** @inheritDoc */ | |||
public getScopeData(): ScopeData { | |||
public getPerScopeData(): ScopeData { |
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.
Does getPerScopeData
have to be public API?
I also am not the biggest fan of the scope class being aware of a separate global scope. I'd rather it be the consumers of the scope that decide to use the global scope.
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, I see your point. I'll see if we can do this another way!
0ed9262
to
b17d167
Compare
// of `@sentry/core` that does not have the `getAttachments` method. | ||
// See: https://github.com/getsentry/sentry-javascript/issues/5229 | ||
// Merge scope data together | ||
const data = getGlobalScope().getScopeData(); |
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.
@AbhiPrasad I refactored this so that the global scope is merged/applied in prepareEvent
.
const data = getGlobalScope().getPerScopeData(); | ||
const isolationScopeData = this._getIsolationScope().getPerScopeData(); | ||
const scopeData = this.getPerScopeData(); | ||
const globalScope = getGlobalScope(); |
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.
When we introduce the isolation scope in a follow up PR, we can clean this up here and drastically simplify this! But for now I think this is "OK".
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.
Thanks for making the change!
packages/core/src/globals.ts
Outdated
import type { Scope } from '@sentry/types'; | ||
|
||
interface GlobalData { | ||
globalScope?: Scope; |
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.
m: we need to be careful for global{s}.ts
because of #5969
Let's rename this file to globalscope.ts
? Also why do we have the indirection to GLOBAL_DATA.globalScope
, can't we point to globalScope
directly? If we refactor to need more GLOBAL_DATA
, items, we can add it back.
This scope lives in module scope and is applied to _all_ events.
b17d167
to
94ae54c
Compare
This scope lives in module scope and is applied to all events.
Please review this carefully, as it is important that data is correctly applied etc. There should be a decent amount of tests covering all of this, but just to make sure. This was mostly ported/extracted from node-experimental.