-
-
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(replay): Start replay immediately, not in next tick
This should hopefully fix some race conditions...
- Loading branch information
Showing
15 changed files
with
93 additions
and
14 deletions.
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).toBe('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).toBe('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