-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
ref(core): Use versioned carrier on global object #12206
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
size-limit report 📦
|
8a2dce8
to
8a45505
Compare
Hmm seems like TS 3.8 isn't happy with the Problem is, I can't use |
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 is only a temporary modification. Besides formatting the minified code, I added logic to access the versioned carrier in the loader script. We have to make this modification in the actual loader script that we ship to users.
@timfish @krystofwoldrich do you see potential problems with this in Electron or RN? |
No! |
packages/core/src/sdk.ts
Outdated
* Sentry carrier object. This is because certain scripts (e.g. our loader script) obtain | ||
* the client via `window.__SENTRY__.hub.getClient()`. | ||
* the client via `window.__SENTRY__[version].stack.getClient()`. |
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.
Is this actually true going forward? I think in loader for v8 we can do this:
const sentry = window.__SENTRY__[version].stack.getClient()
So we'll have a different code path anyhow...? 🤔 do we need this for spotlight or something else?
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.
ah wait, I see now - this just sets this on the stack 🤔 I guess that's ok for now...
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.
I mean we could also just set a flag, something like window.__SENTRY__[version].sdkInitialized = true
instead, right? At least for the loader that's enough I think, since we only check if the client exists or not 🤔
Spotlight currently accesses window.__SENTRY__.acs
which I still need to change to window.__SENTRY__[version].acs
once this PR lands. So I don't think this is necessary for spotlight at all.
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.
could we just check if window.__SENTRY__[version]
exists, actually? This will only be set if the SDK was initialized I guess..? 😅
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.
I guess our integration tests should tell us. Let me check :)
8f8c99d
to
9d14585
Compare
Co-authored-by: Francesco Novy <[email protected]>
Nope, I don't see problems with this in RN. |
055398f
to
0c08418
Compare
2cfc81a
to
26f7d02
Compare
This PR implements a versioned Sentry carrier as described in #12188. The idea is that SDKs can from now on access their global Sentry instance and thereby no longer overwrite or interfere with potentially other SDKs (e.g. 3rd party libraries, scripts, etc).
Internally, SDKs can access their carrier via the
window.__SENTRY__[SDK_VERSION]
. Externally (spotlight, loader script) viawindow.__SENTRY__[window.__SENTRY__.version]
.As we can see in this example, the main SDK sets its properties on the
8.4.0
key, while another, presumably older SDK sets itshub
directly onto the__SENTRY__
object.There are some caveats to consider with this approach as documented in #12188. For now though, I'd argue that the benefits (i.e. get rid of a lot of errors our users can't do much about) outweigh the potential problems.
closes #12188
also:
fixes #12155
fixes #12054
Once this is merged, we have to make updates to: