-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
feat: added replay lifecycle hooks docs #17598
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
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -127,6 +127,38 @@ In `session` mode, this will upload any pending recording data to Sentry. In `bu | |
|
|
||
| Calling `flush()` while Session Replay is stopped will start a new session recording. | ||
|
|
||
| ## Lifecycle Hooks | ||
|
|
||
| <AvailableSince version="10.50.0" /> | ||
|
|
||
| You can listen to replay lifecycle events on the Sentry client to know when recording starts and stops. This is useful for wrapper libraries or custom UIs that need to stay in sync with replay state. | ||
|
|
||
| ```javascript | ||
| const client = Sentry.getClient(); | ||
|
|
||
| client.on('replayStart', ({ sessionId, recordingMode }) => { | ||
| // recordingMode: 'session' | 'buffer' | ||
| console.log(`Replay ${sessionId} started in ${recordingMode} mode`); | ||
| }); | ||
|
|
||
| client.on('replayEnd', ({ sessionId, reason }) => { | ||
| // reason: 'manual' | 'sessionExpired' | 'sendError' | 'mutationLimit' | ||
| // | 'eventBufferError' | 'eventBufferOverflow' | ||
| console.log(`Replay ${sessionId} ended: ${reason}`); | ||
|
Comment on lines
+139
to
+147
Contributor
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. Bug: The documentation for Suggested FixUpdate the documentation to replace Prompt for AI AgentDid we get this right? 👍 / 👎 to inform future reviews.
Member
Author
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. Nope, |
||
| }); | ||
| ``` | ||
|
|
||
| The `replayEnd` hook includes a typed `reason` so you can distinguish calling `replay.stop()` yourself from an internal stop: | ||
|
|
||
| | Reason | Description | | ||
| |--------|-------------| | ||
| | `manual` | You called `replay.stop()` | | ||
| | `sessionExpired` | The session exceeded max duration or idle timeout | | ||
| | `sendError` | The SDK failed to send recording data to Sentry | | ||
| | `mutationLimit` | The DOM mutation limit was exceeded | | ||
| | `eventBufferError` | The event buffer hit an internal error | | ||
| | `eventBufferOverflow` | The event buffer exceeded its size limit | | ||
|
|
||
| ## Examples of Custom Sampling | ||
|
|
||
| There are ways to enable custom sampling if you're interested in tracking a particular action or group, for example, a specific segment of users or a problematic URL. | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.