-
Notifications
You must be signed in to change notification settings - Fork 34
Bug 1867294: Support for automatically collecting element click events (first version) #1848
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
Conversation
…ttributes - changed extra_keys as per agreement in https://bugzilla.mozilla.org/show_bug.cgi?id=1867294
2ead1b3 to
53bf89c
Compare
Dexterp37
left a comment
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.
@abhi-agg please add a changelog entry!
I'm removing myself from review, leaving @rosahbruno and adding @quiiver (Wil, would you kindly take an high level look to make sure this is what you wanted?)
rosahbruno
left a comment
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.
Left a few initial comments. Do we think there might be a need for exposing the click event similar to what I did with the pageLoad event? That way if someone wants to use the event itself because of the dashboard they will end up with BUT they don't want to use the HTML attributes or they want to do something custom, etc. We could provide them with a GleanMetrics.recordClick() API so they can collect on their terms
quiiver
left a comment
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! Just a thought on extensibility. If I'm reading this correctly the only way to extend these auto collected events would be to re-create your own page_load and element_click event or you would need to extend the events defined in the core of glean.js making it a global change across all apps. While I don't think this is a blocker for this work here, I feel like this will come up as folks want to collect additional context along-side these default events.
- Remove absent values from event extra before recording
You are absolutely right on this one. Our plan is to talk to different products within Mozilla to gather their requirements on the additional context that they would like to collect for click events and extend glean.js click events in the next version. I have tried to share more details in this comment and would love to have your thoughts on this. So, please free to chime in in the bug 🙂 Thanks a lot for your inputs on this PR :) |
@rosahbruno So, Forgot to mention that I tested both modes:
in Debug Ping Viewer (details in the PR description) and both of them work. Please let me know if I missed something. |
| const htmlElement = event.target as HTMLElement; | ||
|
|
||
| const elementClickEventContext: ElementClickEventContext = {}; | ||
| if (htmlElement?.dataset?.gleanId) elementClickEventContext.id = htmlElement?.dataset?.gleanId; |
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.
NIT: Maybe individual preference, but these one-liner if's always feel less readable, but not a huge deal.
Description
This PR implements the first version to automatically collect click events on html elements:
data-glean-id,data-glean-type,data-glean-labeldata attributes.id: A string indicating an identifier of the clicked element (takes its value from element'sdata-glean-idattribute value if present)type: A string indicating the type of the clicked element (takes its value from element'sdata-glean-typeattribute value if present)label: A string indicating the label of the clicked element (takes its value from element'sdata-glean-labelattribute value if present)How clients can use it:
There are 2 options:
data-glean-id,data-glean-typeanddata-glean-labelattribute and settingConfiguration.enableAutoElementClickEventsoption totrueduring Glean.js initialization. e.g. Like this:Pull Request checklist
glean/folder, run:npm run testRuns all testsnpm run lintRuns all lintersCHANGELOG.mdor an explanation of why it does not need onemozilla/gleanrepository