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
feat(replay): Add beforeAddRecordingEvent
Replay option
#8124
Conversation
Allows you to modify/filter recording events for replays. Note this is only a recording event, not the replay event.
f6ab9a2
to
f8cfe73
Compare
size-limit report 📦
|
({ replay, integration } = await mockSdk({ | ||
replayOptions: { | ||
beforeAddRecordingEvent: event => { | ||
const eventData = event.data as Record<string, any>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Types are not ideal here :/
I'll work on a follow-up to see how we can improve them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me!
@@ -2,6 +2,8 @@ | |||
|
|||
## Unreleased | |||
|
|||
- feat(replay): Add `beforeAddRecordingEvent` Replay option |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No action required, just as a side note: You don't have to add this entry to the unreleased section. We always create a changelog PR when we release which is when we add all entries.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah thought it would make it easier for whoever is publishing
packages/replay/src/types.ts
Outdated
/** | ||
* Callback before adding a recording event | ||
*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
l: Let's add a sentence about what to use this function for and what to return(i.e. returning null will drop the event). Just to make it a little clearer to users
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, we should probably point out that dropping one event here won't result in the entire replay being dropped, wdyt?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've also added the condition that we only call this callback for custom events, e.g. only when event.type == 5 (otherwise we risk user error breaking the replay), thoughts on that @Lms24?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes that sounds good to me 👍 less chances for folks to screw things up with the actual replay! Let's just make sure we point this out in the JSDoc
@Lms24 One question I forgot to ask... does this option belong in the Replay integration instanciation, or root Sentry SDK |
I thought about this a little and I'd prefer it to be a Replay integration option, especially given that it's now only called for custom events. I know that his option is in a way similar to e.g. |
Agreed 👍 |
@billyvg @Lms24 Thank you so much for adding this, we'll try it out soon. ✌️ Regarding whether options are better placed in |
@jcfrancisco We recently added some documentation for this. FWIW this is also how we do it at Sentry. |
Allows you to modify/filter custom recording events for replays. Note this is only a recording event, not the replay event. Custom means that the events do not relate or affect the DOM recording, but rather they are additional events that the Replay integration adds for additional features.
This adds an option for the Replay integration
beforeAddRecordingEvent
to process a recording (rrweb) event before it is added to the event buffer. Example:Closes #8127