-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
ref(core): Use versioned carrier on global object #12206
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 12 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
e373820
wip
Lms24 b07a98f
add basic implementation for populating and retrieving versioned carrier
Lms24 73458c3
ref(core): Use versioned carrier on global object
Lms24 ee49730
tmp-fix loader tests
Lms24 c696ab8
add another sdk interop test
Lms24 9d14585
make version.ts in utils the one source of truth for sdk version
Lms24 4575321
Update packages/core/src/sdk.ts
Lms24 71fe56a
try/catch instead of definedness guarding
Lms24 efe3229
cleanup types, reduce bundle size a bit
Lms24 b74ee3f
InternalGlobal .version optional
Lms24 0c08418
rm `registerClientOnGlobalHub`
Lms24 26f7d02
remove VersionString type -> fix TS3.8
Lms24 58791ab
fix tests
Lms24 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
19 changes: 19 additions & 0 deletions
19
dev-packages/browser-integration-tests/suites/old-sdk-interop/acs/getCurrentScope/init.js
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| import * as Sentry from '@sentry/browser'; | ||
|
|
||
| /** | ||
| * This simulates an relatively new v7 SDK setting acs on the __SENTRY__ carrier. | ||
| * see: https://github.com/getsentry/sentry-javascript/issues/12054 | ||
| */ | ||
| window.__SENTRY__ = { | ||
| acs: { | ||
| getCurrentScope: () => { | ||
| return 'scope'; | ||
| }, | ||
| }, | ||
| }; | ||
|
|
||
| window.Sentry = Sentry; | ||
|
|
||
| Sentry.init({ | ||
| dsn: 'https://[email protected]/1337', | ||
| }); |
10 changes: 10 additions & 0 deletions
10
dev-packages/browser-integration-tests/suites/old-sdk-interop/acs/getCurrentScope/subject.js
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| const sentryCarrier = window && window.__SENTRY__; | ||
|
|
||
| /** | ||
| * Simulate an old pre v8 SDK obtaining the hub from the global sentry carrier | ||
| * and checking for the hub version. | ||
| */ | ||
| const res = sentryCarrier.acs && sentryCarrier.acs.getCurrentScope(); | ||
|
|
||
| // Write back result into the document | ||
| document.getElementById('currentScope').innerText = res && 'scope'; |
9 changes: 9 additions & 0 deletions
9
...ckages/browser-integration-tests/suites/old-sdk-interop/acs/getCurrentScope/template.html
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| <!DOCTYPE html> | ||
| <html> | ||
| <head> | ||
| <meta charset="utf-8" /> | ||
| </head> | ||
| <body> | ||
| <p id="currentScope"></p> | ||
| </body> | ||
| </html> |
13 changes: 13 additions & 0 deletions
13
dev-packages/browser-integration-tests/suites/old-sdk-interop/acs/getCurrentScope/test.ts
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| import { expect } from '@playwright/test'; | ||
|
|
||
| import { sentryTest } from '../../../../utils/fixtures'; | ||
|
|
||
| sentryTest( | ||
| "doesn't crash if older SDKs access `acs.getCurrentScope` on the global object", | ||
| async ({ getLocalTestUrl, page }) => { | ||
| const url = await getLocalTestUrl({ testDir: __dirname }); | ||
| await page.goto(url); | ||
|
|
||
| await expect(page.locator('#currentScope')).toHaveText('scope'); | ||
| }, | ||
| ); |
19 changes: 19 additions & 0 deletions
19
dev-packages/browser-integration-tests/suites/old-sdk-interop/hub/isOlderThan/init.js
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| import * as Sentry from '@sentry/browser'; | ||
|
|
||
| /** | ||
| * This simulates an old, pre-v8 SDK setting itself up on the global __SENTRY__ carrier. | ||
| * see: https://github.com/getsentry/sentry-javascript/issues/12155 | ||
| */ | ||
| window.__SENTRY__ = { | ||
| hub: { | ||
| isOlderThan: version => { | ||
| return version < 7; | ||
| }, | ||
| }, | ||
| }; | ||
|
|
||
| window.Sentry = Sentry; | ||
|
|
||
| Sentry.init({ | ||
| dsn: 'https://[email protected]/1337', | ||
| }); |
10 changes: 10 additions & 0 deletions
10
dev-packages/browser-integration-tests/suites/old-sdk-interop/hub/isOlderThan/subject.js
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| const sentryCarrier = window && window.__SENTRY__; | ||
|
|
||
| /** | ||
| * Simulate an old pre v8 SDK obtaining the hub from the global sentry carrier | ||
| * and checking for the hub version. | ||
| */ | ||
| const res = sentryCarrier.hub && sentryCarrier.hub.isOlderThan(7); | ||
|
|
||
| // Write back result into the document | ||
| document.getElementById('olderThan').innerText = res; |
9 changes: 9 additions & 0 deletions
9
dev-packages/browser-integration-tests/suites/old-sdk-interop/hub/isOlderThan/template.html
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| <!DOCTYPE html> | ||
| <html> | ||
| <head> | ||
| <meta charset="utf-8" /> | ||
| </head> | ||
| <body> | ||
| <p id="olderThan"></p> | ||
| </body> | ||
| </html> |
13 changes: 13 additions & 0 deletions
13
dev-packages/browser-integration-tests/suites/old-sdk-interop/hub/isOlderThan/test.ts
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| import { expect } from '@playwright/test'; | ||
|
|
||
| import { sentryTest } from '../../../../utils/fixtures'; | ||
|
|
||
| sentryTest( | ||
| "doesn't crash if older SDKs access `hub.isOlderThan` on the global object", | ||
| async ({ getLocalTestUrl, page }) => { | ||
| const url = await getLocalTestUrl({ testDir: __dirname }); | ||
| await page.goto(url); | ||
|
|
||
| await expect(page.locator('#olderThan')).toHaveText('false'); | ||
| }, | ||
| ); |
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
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
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
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is only a temporary modification. Besides formatting the minified code, I added logic to access the versioned carrier in the loader script. We have to make this modification in the actual loader script that we ship to users.