Skip to content

Commit 5f26034

Browse files
authored
feat(replay): Add flush method to integration (#6776)
1 parent 4b1bc47 commit 5f26034

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

packages/replay/README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,3 +223,9 @@ However, please note that it is _possible_ that the error count reported on the
223223
does not match the actual errors that have been captured.
224224
The reason for that is that errors _can_ be lost, e.g. a network request fails, or similar.
225225
This should not happen to often, but be aware that it is theoretically possible.
226+
227+
## Manually sending replay data
228+
229+
You can use `replay.flush()` to immediately send all currently captured replay data.
230+
This can be combined with `replaysOnErrorSampleRate: 1`
231+
in order to be able to send the last 60 seconds of replay data on-demand.

packages/replay/src/integration.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,17 @@ Sentry.init({ replaysOnErrorSampleRate: ${errorSampleRate} })`,
185185
this._replay.stop();
186186
}
187187

188+
/**
189+
* Immediately send all pending events.
190+
*/
191+
public flush(): Promise<void> | void {
192+
if (!this._replay || !this._replay.isEnabled()) {
193+
return;
194+
}
195+
196+
return this._replay.flushImmediate();
197+
}
198+
188199
/** Setup the integration. */
189200
private _setup(): void {
190201
// Client is not available in constructor, so we need to wait until setupOnce

0 commit comments

Comments
 (0)