-
-
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.
feat(replay): Change the behavior of error-based sampling (#7768)
* feat: Add `startBuffering()` API to begin replay buffering. This is useful if you turn off `replaysSessionSampleRate` and `replaysOnErrorSampleRate` and want to manually decide when to start replay buffering. You can then call `flush()` to save the replay. * fix: Sample at a per error rate instead of per session rate. Previously we were sampling at a per-session rather than per-error. This means the sampling decision happened prior to any error occurrence. The sampling rate was not accurate if you had sessions with many errors. This is now changed so that in the case of capturing replays only on error, we begin buffering the replay immediately and only run the sampling decision when an error occurs.
- Loading branch information
Showing
31 changed files
with
942 additions
and
173 deletions.
There are no files selected for viewing
16 changes: 16 additions & 0 deletions
16
packages/browser-integration-tests/suites/replay/bufferMode/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 |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import * as Sentry from '@sentry/browser'; | ||
|
||
window.Sentry = Sentry; | ||
window.Replay = new Sentry.Replay({ | ||
flushMinDelay: 1000, | ||
flushMaxDelay: 1000, | ||
}); | ||
|
||
Sentry.init({ | ||
dsn: 'https://public@dsn.ingest.sentry.io/1337', | ||
sampleRate: 1, | ||
replaysSessionSampleRate: 0.0, | ||
replaysOnErrorSampleRate: 0.0, | ||
|
||
integrations: [window.Replay], | ||
}); |
18 changes: 18 additions & 0 deletions
18
packages/browser-integration-tests/suites/replay/bufferMode/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,18 @@ | ||
document.getElementById('go-background').addEventListener('click', () => { | ||
Object.defineProperty(document, 'hidden', { value: true, writable: true }); | ||
const ev = document.createEvent('Event'); | ||
ev.initEvent('visibilitychange'); | ||
document.dispatchEvent(ev); | ||
}); | ||
|
||
document.getElementById('error').addEventListener('click', () => { | ||
throw new Error('Ooops'); | ||
}); | ||
|
||
document.getElementById('error2').addEventListener('click', () => { | ||
throw new Error('Another error'); | ||
}); | ||
|
||
document.getElementById('log').addEventListener('click', () => { | ||
console.log('Some message'); | ||
}); |
12 changes: 12 additions & 0 deletions
12
packages/browser-integration-tests/suites/replay/bufferMode/template.html
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,12 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8" /> | ||
</head> | ||
<body> | ||
<button id="go-background">Go to background</button> | ||
<button id="error">Throw Error</button> | ||
<button id="error2">Another Error</button> | ||
<button id="log">Log stuff to the console</button> | ||
</body> | ||
</html> |
Oops, something went wrong.