-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(bundle): Ensure CDN bundles do not overwrite
window.Sentry
- Loading branch information
Showing
5 changed files
with
45 additions
and
0 deletions.
There are no files selected for viewing
5 changes: 5 additions & 0 deletions
5
dev-packages/browser-integration-tests/loader-suites/loader/onLoad/keepSentryGlobal/init.js
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
window.sentryOnLoad = function () { | ||
Sentry.init({}); | ||
|
||
window.__sentryLoaded = true; | ||
} |
3 changes: 3 additions & 0 deletions
3
...ackages/browser-integration-tests/loader-suites/loader/onLoad/keepSentryGlobal/subject.js
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
Sentry.forceLoad(); | ||
|
||
Sentry.captureException('Test exception'); |
10 changes: 10 additions & 0 deletions
10
...ages/browser-integration-tests/loader-suites/loader/onLoad/keepSentryGlobal/template.html
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<script> | ||
window.Sentry = {_customThingOnSentry: 'customThingOnSentry' }; | ||
</script> | ||
</head> | ||
<body></body> | ||
</html> |
24 changes: 24 additions & 0 deletions
24
dev-packages/browser-integration-tests/loader-suites/loader/onLoad/keepSentryGlobal/test.ts
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { expect } from '@playwright/test'; | ||
|
||
import { sentryTest } from '../../../../utils/fixtures'; | ||
import { envelopeRequestParser, waitForErrorRequestOnUrl } from '../../../../utils/helpers'; | ||
|
||
sentryTest('keeps data on window.Sentry intact', async ({ getLocalTestUrl, page }) => { | ||
await page.route('https://dsn.ingest.sentry.io/**/*', route => { | ||
return route.fulfill({ | ||
status: 200, | ||
contentType: 'application/json', | ||
body: JSON.stringify({ id: 'test-id' }), | ||
}); | ||
}); | ||
|
||
const url = await getLocalTestUrl({ testDir: __dirname }); | ||
const req = await waitForErrorRequestOnUrl(page, url); | ||
|
||
const eventData = envelopeRequestParser(req); | ||
|
||
expect(eventData.message).toBe('Test exception'); | ||
|
||
const customThingy = await page.evaluate('window.Sentry._customThingOnSentry'); | ||
expect(customThingy).toBe('customThingOnSentry'); | ||
}); |
This file contains 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