bensheldon / spectator_sport

Record and replay browser sessions in a self-hosted Rails Engine.
https://spectator-sport-demo-1ca285490d99.herokuapp.com/
MIT License
156 stars 3 forks source link

Thoughts about custom events, metadata, and labeling/tagging/searching #13

Open bensheldon opened 1 month ago

bensheldon commented 1 month ago

I've been thinking about how to support custom rrweb events, tracking metadata about a request or just content on the page, and ultimately associating those with recordings (and/or timestamps in a recording).

I'm partial to something simple like Turbo Attributes and Meta Tags in which the metadata is embedded into the HTML of webpage.

e.g. embedding something like

I dunno, those are what I'm thinking about. The rationale for it is:

janpeterka commented 1 month ago

I agree with using html as a way to define this, not javascript.

I can imagine multiple scenarios when you want to add custom event, and propose what ergonomics would I like.

However, I'm not sure how complicated this would be, and how much overhead would it add (especially as we can expect turbo-driven pages with dynamically changing content`. So maybe the last scenario (action) is too complicated and not that useful?

bensheldon commented 1 month ago

on some action (button click) -> also data attribute?

That's really interesting! Just noodling on it, I wonder about a syntax something like Stimulus's Actions

Something like:

<button data-spectator-event="click->event_name">Submit</button>

I wonder if we'd want to support any arbitrary javascript/dom event, or provide our own list (cause I imagine we'd want some Spectator Sport specific ones like "enters-viewport" and stuff.

bensheldon commented 1 month ago

Aside: I also think that the simplest and least javascript-heavy solution to implement would be best, or at least the compromise to balance against 😰

janpeterka commented 1 month ago

I have no idea about how this would be actually implemented (I tried to understand the current javascript and failed horribly), so I won't be much help in deciding that :sweat_smile:

And yes, I'm definitely influenced by stimulus, so I like that code :grin:

On the other hand, maybe solution which is based solely on loaded page (eg. could be in meta), will solve 90% of usecases?