-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
feat(core): Ensure replay envelopes are sent in order when offline #11413
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
23 commits
Select commit
Hold shift + click to select a range
345b6fd
feat(core): Ensure replay envelopes are sent in order when offline
timfish ccbcb22
add browser test
timfish 1b783aa
correct comment
timfish 1d0e187
Revert "add browser test"
timfish 697ba8a
Add browser integration test
timfish 79cad04
Try increasing the timeouts
timfish 68b6245
delays are not reliable
timfish 500d8d0
Use route options so only the first request is aborted
timfish 7f95226
I'll try anything
timfish 20f0609
another try
timfish 3bcbd28
delay between
timfish 50c368a
Merge remote-tracking branch 'upstream/develop' into timfish/feat-ord…
timfish 72443b5
remove abort to see if it fixes test
timfish 783cbc5
Is this caused by offline?
timfish 2362062
Revert the changes and capture traces!
timfish 7f50dcd
actually collect traces
timfish 0b20619
makeBrowserOfflineTransport is not included in any CDN bundles
timfish 41040fd
Use JavaScript fn names (pop > shift)
timfish db3c26e
couple more improvements
timfish 1011f04
Update sent_at in header
timfish afbefe2
Merge branch 'develop' into timfish/feat-ordered-offline-queue
timfish e99274f
Merge branch 'develop' into timfish/feat-ordered-offline-queue
timfish c776be9
Merge branch 'develop' into timfish/feat-ordered-offline-queue
timfish 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
17 changes: 17 additions & 0 deletions
17
dev-packages/browser-integration-tests/suites/replay/captureReplayOffline/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,17 @@ | ||
import * as Sentry from '@sentry/browser'; | ||
|
||
window.Sentry = Sentry; | ||
window.Replay = Sentry.replayIntegration({ | ||
flushMinDelay: 200, | ||
flushMaxDelay: 200, | ||
minReplayDuration: 0, | ||
}); | ||
|
||
Sentry.init({ | ||
dsn: 'https://[email protected]/1337', | ||
sampleRate: 0, | ||
replaysSessionSampleRate: 1.0, | ||
replaysOnErrorSampleRate: 0.0, | ||
transport: Sentry.makeBrowserOfflineTransport(), | ||
integrations: [window.Replay], | ||
}); |
9 changes: 9 additions & 0 deletions
9
dev-packages/browser-integration-tests/suites/replay/captureReplayOffline/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> | ||
<button onclick="console.log('Test log')">Click me</button> | ||
</body> | ||
</html> |
45 changes: 45 additions & 0 deletions
45
dev-packages/browser-integration-tests/suites/replay/captureReplayOffline/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,45 @@ | ||
import { expect } from '@playwright/test'; | ||
|
||
import { sentryTest } from '../../../utils/fixtures'; | ||
import { getReplayEvent, shouldSkipReplayTest, waitForReplayRequest } from '../../../utils/replayHelpers'; | ||
|
||
sentryTest('should capture replays offline', async ({ getLocalTestPath, page }) => { | ||
// makeBrowserOfflineTransport is not included in any CDN bundles | ||
if (shouldSkipReplayTest() || (process.env.PW_BUNDLE && process.env.PW_BUNDLE.startsWith('bundle'))) { | ||
sentryTest.skip(); | ||
} | ||
|
||
const reqPromise0 = waitForReplayRequest(page, 0); | ||
const reqPromise1 = waitForReplayRequest(page, 1); | ||
|
||
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 getLocalTestPath({ testDir: __dirname }); | ||
|
||
// This would be the obvious way to test offline support but it doesn't appear to work! | ||
// await context.setOffline(true); | ||
|
||
// Abort the first envelope request so the event gets queued | ||
await page.route(/ingest\.sentry\.io/, route => route.abort('internetdisconnected'), { times: 1 }); | ||
|
||
await page.goto(url); | ||
|
||
await new Promise(resolve => setTimeout(resolve, 2_000)); | ||
|
||
// Now send a second event which should be queued after the the first one and force flushing the queue | ||
await page.locator('button').click(); | ||
|
||
const replayEvent0 = getReplayEvent(await reqPromise0); | ||
const replayEvent1 = getReplayEvent(await reqPromise1); | ||
|
||
// Check that we received the envelopes in the correct order | ||
expect(replayEvent0.timestamp).toBeGreaterThan(0); | ||
expect(replayEvent1.timestamp).toBeGreaterThan(0); | ||
expect(replayEvent0.timestamp).toBeLessThan(replayEvent1.timestamp || 0); | ||
}); |
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 |
---|---|---|
|
@@ -4,5 +4,5 @@ window.Sentry = Sentry; | |
|
||
Sentry.init({ | ||
dsn: 'https://[email protected]/1337', | ||
transport: Sentry.makeBrowserOfflineTransport(Sentry.makeFetchTransport), | ||
transport: Sentry.makeBrowserOfflineTransport(), | ||
}); |
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.
Check failure
Code scanning / CodeQL
Missing regular expression anchor