Skip to content

feat(js-loader): Support Trusted Types when loading the SDK - #132184

Merged
msonnb merged 2 commits into
masterfrom
ms/loader-trusted-types
Nov 27, 2026
Merged

msonnb merged 2 commits into
masterfrom
ms/loader-trusted-types

Conversation

@msonnb

@msonnb msonnb commented Nov 23, 2026

Copy link
Copy Markdown
Member

Pages enforcing Trusted Types (require-trusted-types-for 'script') block the Loader from setting the src of the SDK script. The Loader now creates a sentry-loader policy that only ever returns the bundle URL rendered by the backend.

It's separate from the SDK's sentry-sdk policy (getsentry/sentry-javascript#26764) because it has to exist before the SDK loads, and sharing a name would require 'allow-duplicates'. Pages with a trusted-types directive need to add sentry-loader. If it isn't allowed, the Loader falls back to the plain URL, as before.

The object literal changes in js-sdk-loader.js.tmpl come from regenerating the template after #131758.

Refs getsentry/sentry-javascript#24744

@github-actions github-actions Bot added Scope: Frontend Automatically applied to PRs that change frontend components Scope: Backend Automatically applied to PRs that change backend components labels Nov 23, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🚨 Warning: This pull request contains Frontend and Backend changes!

It's discouraged to make changes to Sentry's Frontend and Backend in a single pull request. The Frontend and Backend are not atomically deployed. If the changes are interdependent of each other, they must be separated into two pull requests and be made forward or backwards compatible, such that the Backend or Frontend can be safely deployed independently.

Have questions? Please ask in the #discuss-dev-infra channel.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@msonnb
msonnb force-pushed the ms/loader-trusted-types branch from 8cce894 to bbf662d Compare November 24, 2026 14:26
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@msonnb
msonnb marked this pull request as ready for review November 25, 2026 09:01
@msonnb
msonnb requested a review from a team as a code owner November 25, 2026 09:01
@msonnb
msonnb requested review from Lms24 and logaretm November 26, 2026 09:28

@Lms24 Lms24 left a comment

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.

Nice! I think the backend/frontend mix warning is a false positive because of the TS template files. should be good to merge :)

@msonnb
msonnb merged commit 904db3b into master Nov 27, 2026
80 checks passed
@msonnb
msonnb deleted the ms/loader-trusted-types branch November 27, 2026 09:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Backend Automatically applied to PRs that change backend components Scope: Frontend Automatically applied to PRs that change frontend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants