How can I keep /packages/replay-worker/examples/worker.min.js
up-to-date in my codebase when it seems like it comes from an internal package?
#9572
-
#9409 looks very interesting! I'm trying to set it up on our codebase but not sure where to get the example worker from? I can see it on Github at https://github.com/getsentry/sentry-javascript/blob/develop/packages/replay-worker/examples/worker.min.js but not sure how to install I'd like to write a npm postinstall hook that copies I had a quick look in |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 6 replies
-
Yeah, currently this is not published anywhere -- @mydea should we consider publishing this package to npm? |
Beta Was this translation helpful? Give feedback.
-
I'm on Next.js so don't mind waiting if there is a plan for the Next SDK to do this sort of thing automatically :) But I can imagine some people might want to automate this recommendation from the PR and we'll need access to the file locally do to that:
Another slight issue for @mydea I think – I noticed the example file has the SDK version number in a header – will that make it less cacheable as the cache will be busted each time the SDK version is updated, even if the worker file contents didn't actually change? Maybe there's something else you could put in that script header instead of the SDK version? |
Beta Was this translation helpful? Give feedback.
-
Hey there! You cannot use the file from the package, you have to copy the file and host it yourself. This is documented here: The version is included in the file, but we only update the version when we actually update the worker script. So this will not change for each version, but you can easily see if the script has changed by comparing the version you have with the version in the repo :) Hope that helps! (FWIW imho the process with a postinstall hook sounds decent to me! 👍 ) |
Beta Was this translation helpful? Give feedback.
-
Here's what I am doing to automate keeping the worker up to date, for anyone else interested. This assumes that you are keeping all your other Sentry dependencies up-to-date and that it's okay to always be using the example worker from Sentry's In {
"scripts": {
"download-sentry-session-recorder-worker": "[ \"$CI\" = \"true\" ] || curl -s https://raw.githubusercontent.com/getsentry/sentry-javascript/develop/packages/replay-worker/examples/worker.min.js -o ./public/sentry-relay-recorder-worker.js",
"postinstall": "patch-package && npm run download-sentry-session-recorder-worker"
}
} The |
Beta Was this translation helpful? Give feedback.
Hey there! You cannot use the file from the package, you have to copy the file and host it yourself. This is documented here:
https://docs.sentry.io/platforms/javascript/session-replay/configuration/#using-a-custom-compression-worker
The version is included in the file, but we only update the version when we actually update the worker script. So this will not change for each version, but you can easily see if the script has changed by comparing the version you have with the version in the repo :) Hope that helps!
(FWIW imho the process with a postinstall hook sounds decent to me! 👍 )