feat(replay): Allow to treeshake & configure compression worker URL#9409
Merged
feat(replay): Allow to treeshake & configure compression worker URL#9409
Conversation
mydea
commented
Oct 30, 2023
| expect(replayEvent0).toEqual(getExpectedReplayEvent()); | ||
|
|
||
| const snapshots = getFullRecordingSnapshots(await reqPromise0); | ||
| expect(replayEnvelopeIsCompressed(req0)).toEqual(true); |
Member
Author
There was a problem hiding this comment.
I also added a check to actually test that we are sending a compressed payload 😅
62dccc4 to
61feab0
Compare
Contributor
size-limit report 📦
|
Member
Author
|
Follow up: In e.g. next.js, we could do this automatically, which would reduce bundle size etc. |
billyvg
approved these changes
Oct 30, 2023
Co-authored-by: Billy Vong <billyvg@users.noreply.github.com>
de39290 to
f5afdb0
Compare
mydea
commented
Oct 31, 2023
| @@ -0,0 +1,2 @@ | |||
| /*! Sentry Replay Worker 7.76.0 (de39290bc) | https://github.com/getsentry/sentry-javascript */ | |||
Member
Author
There was a problem hiding this comment.
I added a banner here with the version etc. for clarity!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This PR does two things:
workerUrlin replay config, which is expected to be an URL of a self-hosted worker script.a. Added an example worker script, which is a built version of the pako-based compression worker
a. Users can basically host this file themselves and point to it in
workerUrl, as long as it is on the same origin as the website itself.a. We can eventually document this in docs
__SENTRY_EXCLUDE_REPLAY_WORKER__in your build to strip the default included web worker. You can configure this if you're disabling compression anyhow, or if you want to configure a custom web worker as in the above step.Fixes #6739, and allows to reduce bundle size further. Once merged/released we can also add this to the bundler plugins
bundleSizeOptimizationsoptions.Note that we do not recommend to disable the web worker completely. We only recommend to tree shake the worker code if you provide a custom worker URL - else, replay payloads will not be compressed, resulting in much larger payloads sent over the network, which is bad for your applications performance.
Also note that when providing a custom worker, it is your own responsibility to keep it up to date - we try to keep the worker interface stable, and the worker is generally not updated often, but you should still check regularly when updating the SDK if the example worker has changed.