-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
feat(core): Deprecate session APIs on hub and add global replacements #10054
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 all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
76fbf9d
feat(core): Deprecate session APIs on hub and add global replacements
Lms24 9302f38
s/getCurrentScope/getIsolationScope
Lms24 103cd17
fix node 8 test
Lms24 70b2cec
fix passing session to ANR worker
Lms24 29ffcef
bring back currentScope.(get|set)Session
Lms24 e9de0d1
add migration entry
Lms24 5ce536a
add integration test for deprecated API
Lms24 5a83b95
add unit tests for deprecated API
Lms24 566016d
fix anr getCurrentScope
Lms24 86fb99c
lint lint lint
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
14 changes: 14 additions & 0 deletions
14
dev-packages/browser-integration-tests/suites/sessions/v7-hub-start-session/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,14 @@ | ||
import * as Sentry from '@sentry/browser'; | ||
|
||
window.Sentry = Sentry; | ||
|
||
Sentry.init({ | ||
dsn: 'https://[email protected]/1337', | ||
release: '0.1', | ||
// intentionally disabling this, we want to leverage the deprecated hub API | ||
autoSessionTracking: false, | ||
}); | ||
|
||
// simulate old startSessionTracking behavior | ||
Sentry.getCurrentHub().startSession({ ignoreDuration: true }); | ||
Sentry.getCurrentHub().captureSession(); |
9 changes: 9 additions & 0 deletions
9
dev-packages/browser-integration-tests/suites/sessions/v7-hub-start-session/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> | ||
<a id='navigate' href="foo">Navigate</button> | ||
</body> | ||
</html> |
39 changes: 39 additions & 0 deletions
39
dev-packages/browser-integration-tests/suites/sessions/v7-hub-start-session/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,39 @@ | ||
import type { Route } from '@playwright/test'; | ||
import { expect } from '@playwright/test'; | ||
import type { SessionContext } from '@sentry/types'; | ||
|
||
import { sentryTest } from '../../../utils/fixtures'; | ||
import { getFirstSentryEnvelopeRequest } from '../../../utils/helpers'; | ||
|
||
sentryTest('should start a new session on pageload.', async ({ getLocalTestPath, page }) => { | ||
const url = await getLocalTestPath({ testDir: __dirname }); | ||
const session = await getFirstSentryEnvelopeRequest<SessionContext>(page, url); | ||
|
||
expect(session).toBeDefined(); | ||
expect(session.init).toBe(true); | ||
expect(session.errors).toBe(0); | ||
expect(session.status).toBe('ok'); | ||
}); | ||
|
||
sentryTest('should start a new session with navigation.', async ({ getLocalTestPath, page, browserName }) => { | ||
// Navigations get CORS error on Firefox and WebKit as we're using `file://` protocol. | ||
if (browserName !== 'chromium') { | ||
sentryTest.skip(); | ||
} | ||
|
||
const url = await getLocalTestPath({ testDir: __dirname }); | ||
await page.route('**/foo', (route: Route) => route.fulfill({ path: `${__dirname}/dist/index.html` })); | ||
|
||
const initSession = await getFirstSentryEnvelopeRequest<SessionContext>(page, url); | ||
|
||
await page.click('#navigate'); | ||
|
||
const newSession = await getFirstSentryEnvelopeRequest<SessionContext>(page, url); | ||
|
||
expect(newSession).toBeDefined(); | ||
expect(newSession.init).toBe(true); | ||
expect(newSession.errors).toBe(0); | ||
expect(newSession.status).toBe('ok'); | ||
expect(newSession.sid).toBeDefined(); | ||
expect(initSession.sid).not.toBe(newSession.sid); | ||
}); |
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
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.
l: should we maybe just bail out if no client is found? Doesn't matter probably, but for clarity...
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.
Hmm thinking about this, if we do so, we have to return
undefined
which I'm not sure we want to do. Also this means the signature of the replacement would slightly differ from the deprecated hub method. Since we're only taking env and release from the client I think it's okay to continue. Obviously, nosession will be sent but to me this aligns more with the concept of no-op spans for example.
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.
ok, sounds good to me!