question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Custom events (tags)

See original GitHub issue

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:

  • name (e.q. ‘add_to_card’, ‘checkout’) -> string
  • params (e.q. products added) -> JS Object

To add an tag an function can be added:

rrwebTag('add_to_card', {
    product: '12123',
    qty: 1,
    price: 20
})

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:

const events = YOUR_EVENTS;

const replayer = new rrweb.Replayer(events, {
    tags: {
        'add_to_card': '#453222',
        'checkout': '#885942'
    }
});
replayer.play();

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:14 (13 by maintainers)

github_iconTop GitHub Comments

1reaction
Yuyz0112commented, Apr 17, 2020

@heathdutton Yep, it’s stable now.

1reaction
Yuyz0112commented, Jun 25, 2019

@s-jakob

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
    }
  })
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

Custom event trigger - Tag Manager Help - Google Support
The custom event trigger is used to track interactions that occur on your website or mobile app that aren't handled by standard methods....
Read more >
Google Tag Manager Custom Event Trigger Explained
Google Tag Manager Custom Event is used for tracking interactions that might take place on your website or mobile app that isn't handled...
Read more >
Events | Tags - Google Developers
Custom events are events that you define. These events are not already automatically collected or recommended events. In practice, you should try to...
Read more >
How to set up GA4 Custom Events via Google Tag Manager
How to set up custom events GA4 using GTM ... Step-3: Name your tag 'Button Click' and click on 'Tag configuration'. ... Step-4:...
Read more >
5 Steps To Tag Your Own Website With Custom Event Tracking
Learn how to evaluate your Shopify store and add new event tracking via Google Tag Manager in less than an hour to unlock...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found