-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
fix(replay): Start replay in afterAllSetup
instead of next tick
#12709
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
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 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 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
1 change: 1 addition & 0 deletions
1
dev-packages/browser-integration-tests/loader-suites/loader/noOnLoad/replayError/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 @@ | ||
window.doSomethingWrong(); |
35 changes: 35 additions & 0 deletions
35
dev-packages/browser-integration-tests/loader-suites/loader/noOnLoad/replayError/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,35 @@ | ||
import { expect } from '@playwright/test'; | ||
|
||
import { sentryTest } from '../../../../utils/fixtures'; | ||
import { envelopeRequestParser, waitForErrorRequestOnUrl } from '../../../../utils/helpers'; | ||
import { getReplayEvent, shouldSkipReplayTest, waitForReplayRequest } from '../../../../utils/replayHelpers'; | ||
|
||
sentryTest('should capture a replay & attach an error', async ({ getLocalTestUrl, page }) => { | ||
if (shouldSkipReplayTest()) { | ||
sentryTest.skip(); | ||
} | ||
|
||
await page.route('https://dsn.ingest.sentry.io/**/*', route => { | ||
return route.fulfill({ | ||
status: 200, | ||
contentType: 'application/json', | ||
body: JSON.stringify({ id: 'test-id' }), | ||
}); | ||
}); | ||
|
||
const req = waitForReplayRequest(page); | ||
|
||
const url = await getLocalTestUrl({ testDir: __dirname }); | ||
const reqError = await waitForErrorRequestOnUrl(page, url); | ||
|
||
const errorEventData = envelopeRequestParser(reqError); | ||
expect(errorEventData.exception?.values?.length).toBe(1); | ||
expect(errorEventData.exception?.values?.[0]?.value).toContain('window.doSomethingWrong is not a function'); | ||
|
||
const eventData = getReplayEvent(await req); | ||
|
||
expect(eventData).toBeDefined(); | ||
expect(eventData.segment_id).toBe(0); | ||
|
||
expect(errorEventData.tags?.replayId).toEqual(eventData.replay_id); | ||
}); |
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 |
---|---|---|
|
@@ -6,5 +6,7 @@ Sentry.onLoad(function () { | |
useCompression: false, | ||
}), | ||
], | ||
|
||
replaysSessionSampleRate: 1, | ||
}); | ||
}); |
4 changes: 3 additions & 1 deletion
4
dev-packages/browser-integration-tests/loader-suites/loader/onLoad/replay/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 |
---|---|---|
@@ -1,3 +1,5 @@ | ||
Sentry.onLoad(function () { | ||
Sentry.init({}); | ||
Sentry.init({ | ||
replaysSessionSampleRate: 1, | ||
}); | ||
}); |
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions
1
dev-packages/browser-integration-tests/suites/replay/errors/immediateError/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 @@ | ||
window.doSomethingWrong(); |
38 changes: 38 additions & 0 deletions
38
dev-packages/browser-integration-tests/suites/replay/errors/immediateError/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,38 @@ | ||
import { expect } from '@playwright/test'; | ||
|
||
import { sentryTest } from '../../../../utils/fixtures'; | ||
import { envelopeRequestParser, waitForErrorRequestOnUrl } from '../../../../utils/helpers'; | ||
import { getReplayEvent, shouldSkipReplayTest, waitForReplayRequest } from '../../../../utils/replayHelpers'; | ||
|
||
sentryTest( | ||
'[error-mode] should capture error that happens immediately after init', | ||
async ({ getLocalTestUrl, page }) => { | ||
if (shouldSkipReplayTest()) { | ||
sentryTest.skip(); | ||
} | ||
|
||
await page.route('https://dsn.ingest.sentry.io/**/*', route => { | ||
return route.fulfill({ | ||
status: 200, | ||
contentType: 'application/json', | ||
body: JSON.stringify({ id: 'test-id' }), | ||
}); | ||
}); | ||
|
||
const req = waitForReplayRequest(page); | ||
|
||
const url = await getLocalTestUrl({ testDir: __dirname }); | ||
const reqError = await waitForErrorRequestOnUrl(page, url); | ||
|
||
const errorEventData = envelopeRequestParser(reqError); | ||
expect(errorEventData.exception?.values?.length).toBe(1); | ||
expect(errorEventData.exception?.values?.[0]?.value).toContain('window.doSomethingWrong is not a function'); | ||
|
||
const eventData = getReplayEvent(await req); | ||
|
||
expect(eventData).toBeDefined(); | ||
expect(eventData.segment_id).toBe(0); | ||
|
||
expect(errorEventData.tags?.replayId).toEqual(eventData.replay_id); | ||
}, | ||
); |
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
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
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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
import { getClient } from '@sentry/core'; | ||
import type { Event } from '@sentry/types'; | ||
|
||
import { REPLAY_EVENT_NAME, SESSION_IDLE_EXPIRE_DURATION } from '../../../src/constants'; | ||
|
@@ -133,8 +134,8 @@ describe('Integration | coreHandlers | handleGlobalEvent', () => { | |
|
||
it('tags errors and transactions with replay id for session samples', async () => { | ||
const { replay, integration } = await resetSdkMock({}); | ||
// @ts-expect-error protected but ok to use for testing | ||
integration._initialize(); | ||
integration['_initialize'](getClient()!); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. omg this syntax 😅 Not wrong at all, just JS/TS 🙄 😆 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yeah, it is definitely weird, but I prefer this over having to do |
||
|
||
const transaction = Transaction(); | ||
const error = Error(); | ||
expect(handleGlobalEventListener(replay)(transaction, {})).toEqual( | ||
|
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
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
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
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
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.
Could we remove this now?