-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Custom events (tags) #81
Comments
Another option could be to add all possible custom tags when initializing the recorder and set an ID:
This IDs then get added to an offset (e.q. 1000) and set as type in the event when a tag is added. If the custom tag is not in the list the tags is ignored. The rrweb event object would then looks like this for the event 'add_to_card':
This would make the DB search easier when looking for recordings with this tag. |
Thanks for the proposal! The custom event is one of the most frequently asked features. And I want to make sure what's the scene that an event must be stored with other rrweb events. From your proposal, I found the replayer awareness is one of the good points that we should integrate this feature into rrweb. It would be nice if you can share more usages about the custom event. Thanks a lot. |
I need the tags to filter session recordings, which had specific events. Like in my example 'User added product to card' or 'User made a purchase'. |
Ok, and you will try to query events/tags and find them sessions to make the filter right? |
Does something like this look good to you? The data structure: enum EventType {
DomContentLoaded,
Load,
FullSnapshot,
IncrementalSnapshot,
Meta,
+ Custom,
}
+type customEvent<T = unknown> = {
+ type: EventType.Custom;
+ data: {
+ tag: string;
+ payload: T;
+ };
+};
type event =
| domContentLoadedEvent
| loadedEvent
| fullSnapshotEvent
| incrementalSnapshotEvent
| metaEvent
+ | customEvent; and the API: function addEvent<T>(tag: string, payload: T) {
emit({
type: EventType.Custom,
data: {
tag,
payload
}
})
} |
Hi @Yuyz0112 this looks perfect. I will do the filter on the server side. So i think there is no need für any other changes on the client side. |
@Yuyz0112 I believe the pa tag should be part of the payload, as not every custom event requires it. |
@marcospassos
So I think it is a good idea to add the first-class support for the |
This is the record side impl of custom event, according to the issue, we may also add first-class support for the custom event tag like display color labels in the replayer-ui.
Has added the client-side |
This patch introduce a breaking change in rrweb-record's API, so we will revert it in 0.7.x and release it in 0.8.
Looks like this is a live feature, but undocumented. Is it safe to use? I ask because of the reversions :) |
@heathdutton Yep, it's stable now. |
@Yuyz0112 - Is this added? Displaying tag colors on the player timeline like the below: const replayer = new rrweb.Replayer(events, {
tags: {
'add_to_card': '#453222',
'checkout': '#885942'
}
}); I'm trying to test this functionality in import Player from 'rrweb-player';
const player = new Player({
target: document.getElementById('preview'),
data: {
events: recordings,
autoPlay: false,
},
tags: {
foo: '#453222',
},
}); |
@rifaideen nope, not implmented yet. |
@Yuyz0112 - ah ok. It would be great if you have any examples on achieving the similar result. |
To mark special events in the recording it would be good to have the ability to add custom events. I think the type for this should be "tags". Similar to Google gtag events:
https://developers.google.com/gtagjs/reference/event
In the data field there should be fields like:
To add an tag an function can be added:
This tags can then be displayed during the playback as custom colored marker. The color can be defined when initializing the player as an JS Object:
The text was updated successfully, but these errors were encountered: