-
Notifications
You must be signed in to change notification settings - Fork 389
CHECKOUT-6524: Fix Sentry client initialization to avoid conflict #1610
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
}); | ||
}; | ||
|
||
this.hub = createHub(clientOptions as BrowserClientOptions); |
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.
Can we use a typeguard here and avoid the as
keyword please?
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.
Yes good spot, I made some tweaks to the type so I no longer need to use as
. 🙂
5d50dcd
to
19fb467
Compare
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 the reference to the documentation 👍
…rors if some of the frames in the stack trace are thrown from the app code
19fb467
to
3aa8749
Compare
stackParser: defaultStackParser, | ||
}; | ||
|
||
this.hub = createHub(clientOptions); |
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.
Hi @bigcommerce/team-checkout , I'm going to revert this PR because this line is not working in production and stopping Sentry from logging any issue.
An example of a production error message:
Refused to create a worker from 'blob:https://checkout.solostove.com/5837bd07-3018-47d1-8af1-50e16ed86d04' because it violates the following Content Security Policy directive: "script-src 'none'". Note that 'worker-src' was not explicitly set, so 'script-src' is used as a fallback.

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.
After more thorough testing and research, I found out that the proposed solution won’t work. Although Sentry SDK allows multiple client instances for different accounts, many of its features (a.k.a. integrations) only works with the primary client. For example, only the primary client includes breadcrumbs in its error logs, and reports uncaught exceptions. It also won’t work if other client instances are constructed using a different SDK version. This is because all of the client instances actually share the same underlying __SENTRY__
global variable. Several issues have been reported regarding the limitation of running multiple client instances (e.g.: getsentry/sentry-javascript#3271, getsentry/sentry-javascript#3268, getsentry/sentry-javascript#2732 etc…). Until Sentry SDK has a better support for multiple client instances, I think the only way around this problem is to recommend merchants to not to initialise their own client instance on the checkout page if they are using the default OOPC.
What?
BrowserClient
andHub
to avoid conflicting with the globalBrowserClient
andHub
provided by Sentry Browser SDK.Why?
Testing / Proof
@bigcommerce/team-checkout