feat: added replay lifecycle hooks docs#17598
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
1 Skipped Deployment
|
inventarSarah
left a comment
There was a problem hiding this comment.
Thank you, looks good to me👍
And I agree, in the current setup, this seems to be the best place for this content.
Co-authored-by: Sarah Mischinger <sarah@codingwriter.com>
| 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}`); |
There was a problem hiding this comment.
Bug: The documentation for replayStart and replayEnd hooks incorrectly uses sessionId instead of replayId in the payload example, which will be undefined for users.
Severity: MEDIUM
Suggested Fix
Update the documentation to replace sessionId with the correct identifier, replayId, in the code examples for the replayStart and replayEnd lifecycle hooks to match the actual SDK implementation.
Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent. Verify if this is a real issue. If it is, propose a fix; if not, explain why it's
not valid.
Location:
docs/platforms/javascript/common/session-replay/understanding-sessions.mdx#L139-L147
Potential issue: The documentation for the `replayStart` and `replayEnd` lifecycle hooks
incorrectly uses `sessionId` in the event payload examples. The Sentry JS Replay SDK
consistently uses `replayId` for the replay identifier in other contexts, such as
`replay.getReplayId()` and the wire format `replay_id`. Users who follow the
documentation and attempt to destructure `{ sessionId }` from the event payload will
receive `undefined`, causing their implementation to fail silently.
Did we get this right? 👍 / 👎 to inform future reviews.
There was a problem hiding this comment.
Nope, sessionId is the right payload value. No replayId is present.
This PR adds documentation for the replay client lifecycle hooks, it was released in
10.50.0via getsentry/sentry-javascript#20369I initially thought about adding
lifecycle.mdxfile and a sidebar item for replays, but maybe it is a bit of an overkill.