Skip to content

feat(replay-canvas): Support Trusted Types for the canvas worker - #26893

Open
msonnb wants to merge 1 commit into
ms/trusted-types-policyfrom
ms/replay-canvas-trusted-types
Open

msonnb wants to merge 1 commit into
ms/trusted-types-policyfrom
ms/replay-canvas-trusted-types

Conversation

@msonnb

@msonnb msonnb commented Nov 25, 2026 •

Copy link
Copy Markdown
Member

What

Canvas Replay now works on pages that enforce Trusted Types, if the page allows the SDK's policy with trusted-types sentry-sdk.

Why

rrweb creates the canvas worker from a plain blob: URL string, which enforcement blocks. Passing our policy through rrweb's new getTrustedScriptURL option (getsentry/rrweb#367) means users don't have to allow a second policy name. This adds @sentry/browser-utils as a dependency of replay-canvas.

closes #24744

@msonnb
msonnb added this pull request to stack #26894 November 25, 2026 16:05
@msonnb
msonnb force-pushed the ms/replay-canvas-trusted-types branch from de8d4a6 to 30a6312 Compare November 25, 2026 16:08
@github-actions

github-actions Bot commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

size-limit report 📦

Compared: 8404e45 (PR test merge using develop at 2162c51)

Against: cf84d81 (develop) · base run #68198

⚠️ Baseline mismatch: 6 develop commit(s) in the PR build are missing from the baseline. Their size changes also affect this comparison. Compare commits. Re-run once develop's baseline build for 2162c51 finishes.

Path Size % Change Change
@sentry/browser 30.57 kB +0.06% +18 B 🔺
@sentry/browser - with treeshaking flags 28.77 kB +0.1% +27 B 🔺
@sentry/browser - with treeshaking flags tracing without tracing 28.64 kB +0.1% +28 B 🔺
@sentry/browser (incl. Tracing) 53.66 kB -0.03% -16 B 🔽
@sentry/browser (incl. Tracing Core) 40.59 kB -0.01% -4 B 🔽
@sentry/browser (incl. Tracing + Span Streaming) 53.67 kB -0.03% -16 B 🔽
@sentry/browser (incl. Tracing, Profiling) 56.57 kB -0.01% -5 B 🔽
@sentry/browser (incl. Tracing, Replay) 94.19 kB +0.63% +586 B 🔺
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 82.44 kB +0.05% +41 B 🔺
@sentry/browser (incl. Tracing, Replay with Canvas) 99.03 kB +0.59% +574 B 🔺
@sentry/browser (incl. Tracing, Replay, Feedback) 111.96 kB +0.5% +555 B 🔺
@sentry/browser (incl. Feedback) 48.42 kB +0.04% +15 B 🔺
@sentry/browser (incl. sendFeedback) 31.14 kB +0.06% +18 B 🔺
@sentry/browser (incl. FeedbackAsync) 36.66 kB +1.35% +486 B 🔺
@sentry/browser (incl. Metrics) 31.89 kB +0.06% +19 B 🔺
@sentry/browser (incl. Logs) 32.16 kB +0.06% +19 B 🔺
@sentry/browser (incl. Metrics & Logs) 32.82 kB +0.03% +7 B 🔺
@sentry/react 32.97 kB +1.2% +390 B 🔺
@sentry/react (incl. Tracing) 56.84 kB +0.76% +424 B 🔺
@sentry/vue 38.75 kB -0.03% -8 B 🔽
@sentry/vue (incl. Tracing) 56.7 kB +0.02% +10 B 🔺
@sentry/svelte 30.59 kB +0.04% +11 B 🔺
@sentry/effect (client) 42.23 kB +0.01% +4 B 🔺
@sentry/effect (client, incl. Tracing) 54.97 kB -0.01% -5 B 🔽
@sentry/effect (client, incl. Tracing, Logs, Metrics) 66.32 kB - -
@sentry/remix (Remix 3 client bundle) 59.41 kB - -
CDN Bundle 32.61 kB +0.67% +215 B 🔺
CDN Bundle (incl. Tracing) 54.29 kB +0.45% +238 B 🔺
CDN Bundle (incl. Logs, Metrics) 35.33 kB +0.53% +185 B 🔺
CDN Bundle (incl. Tracing, Logs, Metrics) 56.73 kB +0.38% +212 B 🔺
CDN Bundle (incl. Replay, Logs, Metrics) 76.29 kB +0.26% +191 B 🔺
CDN Bundle (incl. Tracing, Replay) 92.11 kB +0.29% +261 B 🔺
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) 94.61 kB +0.24% +222 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback) 97.52 kB +0.21% +196 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 100.02 kB +0.23% +229 B 🔺
CDN Bundle - uncompressed 95.27 kB +0.73% +684 B 🔺
CDN Bundle (incl. Tracing) - uncompressed 160.55 kB +0.43% +684 B 🔺
CDN Bundle (incl. Logs, Metrics) - uncompressed 103.61 kB +0.67% +684 B 🔺
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 168.18 kB +0.41% +684 B 🔺
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 234 kB +0.3% +688 B 🔺
CDN Bundle (incl. Tracing, Replay) - uncompressed 280.99 kB +0.25% +688 B 🔺
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 288.62 kB +0.24% +688 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 292.92 kB +0.24% +688 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 300.54 kB +0.23% +688 B 🔺
@sentry/nextjs (client) 60.08 kB -0.02% -12 B 🔽
@sentry/sveltekit (client) 55.02 kB -0.03% -14 B 🔽
@sentry/core/server 45.84 kB - -
@sentry/core/browser 14.48 kB - -
@sentry/node 157.6 kB -0.01% -2 B 🔽
@sentry/node/import (ESM hook with diagnostics-channel injection) 83.45 kB - -
@sentry/node - without tracing 89.84 kB - -
@sentry/node - without channel injection 146.57 kB - -
@sentry/aws-serverless 100.5 kB -0.01% -2 B 🔽
@sentry/cloudflare (withSentry) - minified 211.97 kB - -
@sentry/cloudflare (withSentry) 491.78 kB - -
@sentry/cloudflare (withSentry, instrumented CommonJS package) - minified 214.92 kB - -
@sentry/nextjs/cloudflare (withSentry) - minified 237.22 kB - -

View base workflow run

@github-actions

Copy link
Copy Markdown
Contributor

One or more gzipped bundles increased by more than 500 bytes. If this increase is intentional, add the Accept Bundlesize Increase label to this PR to rerun and accept the check.

@github-actions

github-actions Bot commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Optional E2E tests

All optional checks were successful. 65 successful. See the run.

Successful checks
Check Status
✅ CI: Optional E2E Tests / E2E astro-7 Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E hono-5 (cloudflare) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E hapi-21 (deno) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E hono-5 Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E cloudflare-flue-send-to-sentry Test (optional) Successful in 3m Details
✅ CI: Optional E2E Tests / E2E nextjs-16 (vinext, bun) Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E debug-id-sourcemaps Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E node-eve (content off) Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E cloudflare-pi-durable (latest) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E deno (latest) Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E nextjs-16-tunnel (cloudflare) Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E cloudflare-think (ai v6) Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E cloudflare-workers-without-tracing-send-to-sentry Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E nextjs-16 (vinext) Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E nuxt-5 (cloudflare) Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E nextjs-14-supabase Test (optional) Successful in 3m Details
✅ CI: Optional E2E Tests / E2E gen-ai-libraries (latest) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E hono-5 (deno) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E hono-5 (bun) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E astro-7 (static trace lifecycle) Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E nuxt-5 (development) Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E nextjs-15 (turbo) Test (optional) Successful in 3m Details
✅ CI: Optional E2E Tests / E2E hapi-21 (bun) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E cloudflare-agent Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E node-mastra (latest) Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E node-express-send-to-sentry (static trace lifecycle) Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E node-eve (0.x) Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E nuxt-5 Test (optional) Successful in 3m Details
✅ CI: Optional E2E Tests / E2E nuxt-5-sourcemaps (static / nuxt generate) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E cloudflare-workers-send-to-sentry Test (optional) Successful in 3m Details
✅ CI: Optional E2E Tests / E2E node-eve (orchestrion) Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E node-express-send-to-sentry Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E node-flue (latest) Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E tanstackstart-react-sourcemaps (delete all) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E solidstart-2 Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E tanstackstart-react-cloudflare Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E nuxt-5 (kv-cache) Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E solidstart-2-tunnel Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E nuxt-5 (bun) Test (optional) Successful in 3m Details
✅ CI: Optional E2E Tests / E2E nextjs-15 (latest) Test (optional) Successful in 3m Details
✅ CI: Optional E2E Tests / E2E tanstackstart-react-sourcemaps Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E react-send-to-sentry Test (optional) Successful in 3m Details
✅ CI: Optional E2E Tests / E2E nuxt-5-sourcemaps Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E react-router-7-framework-instrumentation Test (optional) Successful in 3m Details
✅ CI: Optional E2E Tests / E2E nuxt-5-sourcemaps (client source maps enabled by Sentry) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E nuxt-4-sourcemaps (Vite server) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E node-express-mcp-v2 (MCP SDK OpenTelemetry) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E node-openai-decisions (latest) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E node-fastify-6 Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E node-express-mcp-v2 Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E nuxt-5 (deno) Test (optional) Successful in 3m Details
✅ CI: Optional E2E Tests / E2E solidstart-2 (no upload) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E nuxt-5-sourcemaps (client source maps kept) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E tanstackstart-react-sourcemaps (manual upload) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E solidstart-2 (manual upload) Test (optional) Successful in 3m Details
✅ CI: Optional E2E Tests / E2E solidstart-2 (delete all) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E node-pi-durable (latest) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E node-express-mcp-v1 Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E nuxt-5-tunnel (cloudflare) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E tanstackstart-react-sourcemaps (no upload) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E nuxt-5-sourcemaps (no upload) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E vinext-cf-workers (workers cache) Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E tanstackstart-react (latest) Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E nuxt-5-tunnel Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E vue-3 (no Options API) Test (optional) Successful in 1m Details

@msonnb
msonnb marked this pull request as ready for review November 26, 2026 10:12

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 30a6312. Configure here.

sentryTest('records canvas on pages that enforce Trusted Types', async ({ getLocalTestUrl, page }) => {
if (shouldSkipReplayTest() || (process.env.PW_BUNDLE || '').startsWith('bundle')) {
sentryTest.skip();
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Trusted Types canvas test runs on WebKit

Low Severity

This test waits until a CanvasMutation snapshot arrives, but unlike the existing records and manualSnapshot canvas tests it doesn't skip webkit. If WebKit never emits canvas mutation snapshots (likely the reason those tests skip it), collectReplayRequests will hang until timeout and the test will fail or flake in the WebKit project.

Additional Locations (1)
Fix in Cursor Fix in Web

Triggered by project rule: PR Review Guidelines for Cursor Bot

Reviewed by Cursor Bugbot for commit 30a6312. Configure here.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It passes on WebKit locally and in CI it only runs in Chromium because the WebKit job uses a CDN bundle and the test skips bundles

Comment thread packages/replay-canvas/package.json Outdated
Comment on lines 60 to 62
"@sentry/browser-utils": "11.17.0",
"@sentry/replay": "11.17.0",
"@sentry/core": "11.17.0"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: makes me think it belongs in core but then again this is not usable on server, so 🤷‍♂️

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i mean we do have core/browser, but iirc the idea was to move as much as possible into browser-utils (and core/server into server-utils), so I guess this is fine here.

@msonnb
msonnb force-pushed the ms/replay-canvas-trusted-types branch from 30a6312 to 810983f Compare November 27, 2026 08:52
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@msonnb
msonnb force-pushed the ms/replay-canvas-trusted-types branch from 810983f to f0a680a Compare November 27, 2026 08:59

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support Trusted Types (require-trusted-types-for 'script')

3 participants