Originally, I planned to use their libraries, either ga.js, analytics.js, or gtag.js, in order to easily send analytics. However, after experimentation, all three of those methods were written for events in a web page and not a service workers. In order for our analytics to not interfere with analytics from other sites (since they all use the same window "message queue"), I have to put the analytics logic in the background service worker.
Previously, this was much easier since you could define a background.html file. However, with Manifest V3 (which google now requires), background pages have been replaced with service workers, which cannot have an html file.
So, finally, I ended up writing the analytics logic and passing it to google analytics via their API. I could not use the latest version of their API (GA4) since that also relied on the presence of a ClientID (requires gtag.js, which requires again a webpage), and instead used Universal Analytics
This PR
This PR sets up some initial analytics events. Here's a summary:
category
action
label
description
ui_result
process
rect_accuracy
Mean Squared error of rectangle width accuracy
ui_event
cancel_selection
ESC
user cancelled selection of an element with the escape key
ui_event
cancel_selection
window_click
user clicked an element which was not supported, cancelling selection
ui_event
target_found
VIDEO/IMG
a target image/video was found successfully
ui_event
drag_menu
;
where the menu was dragged to as a relative % from top left of the target
ui_event
recapture_interval
interval between a capture/recapture and the next recapture
Google Analytics
Originally, I planned to use their libraries, either ga.js, analytics.js, or gtag.js, in order to easily send analytics. However, after experimentation, all three of those methods were written for events in a web page and not a service workers. In order for our analytics to not interfere with analytics from other sites (since they all use the same window "message queue"), I have to put the analytics logic in the background service worker.
Previously, this was much easier since you could define a background.html file. However, with Manifest V3 (which google now requires), background pages have been replaced with service workers, which cannot have an html file.
So, finally, I ended up writing the analytics logic and passing it to google analytics via their API. I could not use the latest version of their API (GA4) since that also relied on the presence of a ClientID (requires gtag.js, which requires again a webpage), and instead used Universal Analytics
This PR
This PR sets up some initial analytics events. Here's a summary: