feat(csr): ship standalone worker file and expose workerUrl option - #412
Open
nicklasl wants to merge 5 commits into
Open
feat(csr): ship standalone worker file and expose workerUrl option#412nicklasl wants to merge 5 commits into
nicklasl wants to merge 5 commits into
Conversation
- Add `workerUrl` to `InitSessionRecorderOptions`, plumbed to `createUploader`. - Export `workerScript` from `@spotify-confidence/session-recording/worker` so customers can serve it at a same-origin route. - Emit `dist/confidence-worker.js` as a standalone file in the npm package that can be copied directly to static assets. - Add CSP section to README with required directives, three hosting options (copy, build-tool, serve-from-route), and troubleshooting. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
nicklasl
force-pushed
the
nicklasl/csr-ship-worker-js
branch
from
July 16, 2026 07:31
04ad1dd to
651317a
Compare
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
csr-common now emits dist/confidence-worker.js as a first-class build artifact. session-recording copies it instead of extracting the worker string from source. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
nicklasl
force-pushed
the
nicklasl/csr-ship-worker-js
branch
from
July 17, 2026 08:40
732ded9 to
0f8148b
Compare
nicklasl
commented
Jul 17, 2026
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
8 tasks
nicklasl
marked this pull request as ready for review
July 17, 2026 12:34
nicklasl
requested review from
AHB,
Billlynch,
andreas-karlsson,
fabriziodemaria,
mfranberg,
sam-cook and
vahidlazio
as code owners
July 17, 2026 12:34
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.
Summary
dist/confidence-worker.jsas a standalone file customers can copy to their static assetsworkerUrloninitSessionRecorderfor customers whose CSP blocksdata:andblob:inworker-srcworkerScriptfrom@spotify-confidence/session-recording/workerfor server-route integrationBuild restructure
The standalone worker file is now a first-class build artifact of
csr-common. During csr-common's build,emit-worker-file.mjsextracts the bundledworkerScriptstring from the compiled output and writes it asdist/confidence-worker.js. session-recording simply copies the file from csr-common's dist — no regex parsing, no second rolldown invocation.Build order:
build-worker.mjsbundles worker source into string constant + generatescsr-version.tsemit-worker-file.mjswritesdist/confidence-worker.jscsr-common/dist/confidence-worker.jsFollow-up (separate PR)
sdkVersionin hello, worker reportsworkerVersionin welcome, mismatch logs a warning viadebugLogger./workerhelper export usingnew URLpattern for automatic bundler asset handling (needs Next.js validation)Test plan
yarn build:csrproduces identicalconfidence-worker.jsin both csr-common and session-recording distworkerUrlforwarded frominitSessionRecordertocreateUploader(unit-tested)@spotify-confidence/session-recording/workerexportsworkerScript🤖 Generated with Claude Code