feat(with-sentry): update with-sentry examples to align with shared environments #70
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I went through a lot of variations when upgrading/using Sentry in extensions.
While Sentry does provide guidance when it comes to shared environments, recommending v8, this guidance really only applies to code executed in the content scripts. This is because content scripts are the only thing executed in the same window as the website currently in the browser.
But, what I found out the hard way is that even using Sentry's default way of initialising in the popup script can cause issues, specifically, rejections from the stores.
With this code snippet being the one in question.
After a deep-dive, this code is included when using the
Sentry.init
function. This is because of how the import works (e.g.import * as Sentry from '@sentry/browser
[or from the react version]), as it actually imports all things, which includes the lazy loading integration [this integration isn't needed when you're bundling code, but hey ho).I've modified the example to show how to set up Sentry for usage in a content script, which shouldn't have this problem, but I've left the popup initialisation as standard with a comment. Open for discussion!