Track action usage

This commit is contained in:
Tom Moor
2023-02-10 18:56:12 -05:00
parent bb6f4b1c1e
commit fcbd4d3d28
10 changed files with 106 additions and 4 deletions

26
app/utils/Analytics.ts Normal file
View File

@@ -0,0 +1,26 @@
/**
* Helper class to track events across various analytics integrations
*/
export default class Analytics {
/**
* Send an event to Analytics
*
* @param event The event name
* @param action The action name
*/
public static track = (
event: string,
action: string,
metadata?: Record<string, string>
) => {
// GA3
ga?.("send", "event", event, action);
// GA4
window.dataLayer?.push({
event,
action,
...metadata,
});
};
}