@@ -11,10 +11,23 @@ import "react-confirm-alert/src/react-confirm-alert.css" // Import css
1111// TODO: Change this to the correct key for production.
1212const GA4_KEY = "G-WZE3E5XCQ7"
1313
14+ type IAnalyticsEventCategory =
15+ | { category : "android" ; actions : [ "settings" , "reverse-tunnel" , "reload-app" , "shake-device" ] }
16+ | { category : "navigation" ; actions : [ "keyboard_shortcut" ] }
17+ | { category : "external_link" ; actions : [ "click" ] }
18+ | { category : "timeline" ; actions : [ "search" , "filter" , "reverse" , "clear" ] }
19+ | { category : "error" ; actions : [ "OverlayDropImage" ] }
20+ | { category : "overlay" ; actions : [ "OverlayDropImage" , "OverlayRemoveImage" , "OverlayShowDebug" ] }
21+ | { category : "dispatch" ; actions : [ "dispatchAbort" , "dispatchConfirm" ] }
22+ | { category : "subscription" ; actions : [ "addAbort" , "addConfirm" , "add" , "clear" ] }
23+ | { category : "snapshot" ; actions : [ "copy" , "restore" , "remove" , "copy" , "add" ] }
24+ | { category : "storybook" ; actions : [ "ToggleStorybook" ] }
25+ | { category : "custom_command" ; actions : [ "sendCommand" ] }
26+
1427// I had trouble importing this type from the react-ga4 package, so I'm defining it here.
1528type UaEventOptions = {
16- action : string
17- category : string
29+ category : IAnalyticsEventCategory [ "category" ]
30+ action : IAnalyticsEventCategory [ "actions" ] [ number ]
1831 label ?: string
1932 value ?: number
2033 nonInteraction ?: boolean
@@ -125,12 +138,12 @@ export const useAnalytics = () => {
125138
126139 // Send a custom command event
127140 const sendCustomCommandAnalyticsEvent = useCallback (
128- ( command : string , title : string ) => {
141+ ( command : string ) => {
129142 sendAnalyticsEvent ( {
130143 category : "custom_command" ,
131- action : command ,
144+ action : "sendCommand" ,
132145 nonInteraction : false ,
133- label : title ,
146+ label : command ,
134147 } )
135148 } ,
136149 [ sendAnalyticsEvent ]
0 commit comments