Skip to content

Commit 348ee80

Browse files
sergicalclaude
andauthored
feat(loader): Use region-aware CDN host for Loader Script (#17476)
## DESCRIBE YOUR PR The Loader Script snippet in the JavaScript install docs was hardcoded to `https://js.sentry-cdn.com/...`, which is wrong for organizations hosted in the EU (they need `js-de.sentry-cdn.com`). This PR makes the host dynamic for signed-in users and adds a short alert for unauthenticated readers. - Add a new `JS_SDK_LOADER_HOST` code keyword on `ProjectCodeKeywords`, derived from the project's DSN host (`.ingest.de.` → `js-de.sentry-cdn.com`, else `js.sentry-cdn.com`). - Swap the 5 loader `<script>` URLs in `docs/platforms/javascript/common/install/loader.mdx` to use `___JS_SDK_LOADER_HOST___`. - Register `SignedInCheck` as an MDX component and wrap a small `<Alert>` above the loader snippets telling unauthenticated readers to swap to `js-de.sentry-cdn.com` if their org is in the EU. Refs #17471 ## IS YOUR CHANGE URGENT? Help us prioritize incoming PRs by letting us know when the change needs to go live. - [ ] Urgent deadline (GA date, etc.): <!-- ENTER DATE HERE --> - [ ] Other deadline: <!-- ENTER DATE HERE --> - [x] None: Not urgent, can wait up to 1 week+ ## SLA - Teamwork makes the dream work, so please add a reviewer to your PRs. - Please give the docs team up to 1 week to review your PR unless you've added an urgent due date to it. Thanks in advance for your help! ## PRE-MERGE CHECKLIST *Make sure you've checked the following before merging your changes:* - [ ] Checked Vercel preview for correctness, including links - [ ] PR was reviewed and approved by any necessary SMEs (subject matter experts) - [ ] PR was reviewed and approved by a member of the [Sentry docs team](https://github.com/orgs/getsentry/teams/docs) --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent ba05566 commit 348ee80

2 files changed

Lines changed: 12 additions & 5 deletions

File tree

docs/platforms/javascript/common/install/loader.mdx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ To use the loader, go in the Sentry UI to **Settings > Projects > (select projec
4747

4848
```html
4949
<script
50-
src="https://js.sentry-cdn.com/___PUBLIC_KEY___.min.js"
50+
src="https://___JS_SDK_LOADER_HOST___/___PUBLIC_KEY___.min.js"
5151
crossorigin="anonymous"
5252
></script>
5353
```
@@ -91,7 +91,7 @@ Alternatively, you can set the loader to request the full SDK earlier: still as
9191

9292
```html
9393
<script
94-
src="https://js.sentry-cdn.com/___PUBLIC_KEY___.min.js"
94+
src="https://___JS_SDK_LOADER_HOST___/___PUBLIC_KEY___.min.js"
9595
crossorigin="anonymous"
9696
data-lazy="no"
9797
></script>
@@ -140,7 +140,7 @@ The loader script always includes a call to `Sentry.init` with a default configu
140140
</script>
141141

142142
<script
143-
src="https://js.sentry-cdn.com/___PUBLIC_KEY___.min.js"
143+
src="https://___JS_SDK_LOADER_HOST___/___PUBLIC_KEY___.min.js"
144144
crossorigin="anonymous"
145145
></script>
146146
```
@@ -183,7 +183,7 @@ If you want to call any other method when using the Loader, you have to guard it
183183
};
184184
</script>
185185

186-
<script src="https://js.sentry-cdn.com/___PUBLIC_KEY___.min.js" crossorigin="anonymous"></script>
186+
<script src="https://___JS_SDK_LOADER_HOST___/___PUBLIC_KEY___.min.js" crossorigin="anonymous"></script>
187187

188188
<script>
189189
// Guard against window.Sentry not being available, e.g. due to Ad-blockers
@@ -220,7 +220,7 @@ If this is a critical issue for you, you have two options to ensure that all you
220220
};
221221
</script>
222222

223-
<script src="https://js.sentry-cdn.com/___PUBLIC_KEY___.min.js" crossorigin="anonymous"></script>
223+
<script src="https://___JS_SDK_LOADER_HOST___/___PUBLIC_KEY___.min.js" crossorigin="anonymous"></script>
224224

225225
<script>
226226
Sentry.onLoad(function () {

src/components/codeContext.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {OnboardingOptionType} from './onboarding';
99
type ProjectCodeKeywords = {
1010
API_URL: string;
1111
DSN: string;
12+
JS_SDK_LOADER_HOST: string;
1213
MINIDUMP_URL: string;
1314
ORG_ID: number;
1415
ORG_INGEST_DOMAIN: string;
@@ -86,6 +87,7 @@ export const DEFAULTS: CodeKeywords = {
8687
ORG_ID: 0,
8788
ORG_SLUG: 'example-org',
8889
ORG_INGEST_DOMAIN: 'o0.ingest.sentry.io',
90+
JS_SDK_LOADER_HOST: 'js.sentry-cdn.com',
8991
MINIDUMP_URL:
9092
'https://o0.ingest.sentry.io/api/0/minidump/?sentry_key=examplePublicKey',
9193
UNREAL_URL: 'https://o0.ingest.sentry.io/api/0/unreal/examplePublicKey/',
@@ -171,6 +173,10 @@ const formatApiUrl = ({scheme, host}: Dsn) => {
171173
return `${scheme}${apiHost}/api`;
172174
};
173175

176+
const getJsSdkLoaderHost = ({host}: Dsn) => {
177+
return host.includes('.ingest.de.') ? 'js-de.sentry-cdn.com' : 'js.sentry-cdn.com';
178+
};
179+
174180
function getHost(): string {
175181
if (process.env.NODE_ENV === 'development') {
176182
return 'http://dev.getsentry.net:8000';
@@ -254,6 +260,7 @@ export async function fetchCodeKeywords(): Promise<CodeKeywords> {
254260
ORG_SLUG: project.organizationSlug,
255261
ORG_INGEST_DOMAIN:
256262
parsedDsn.host ?? `o${project.organizationId}.ingest.sentry.io`,
263+
JS_SDK_LOADER_HOST: getJsSdkLoaderHost(parsedDsn),
257264
MINIDUMP_URL: formatMinidumpURL(parsedDsn),
258265
UNREAL_URL: formatUnrealEngineURL(parsedDsn),
259266
OTLP_URL: formatOtlpUrl(parsedDsn),

0 commit comments

Comments
 (0)