mirror of
https://github.com/outline/outline.git
synced 2026-11-20 21:23:06 +03:00
* fix: Send analytics events through gtag and track WebMCP tool registration * Track WebMCP registration without a tool count
28 lines
601 B
TypeScript
28 lines
601 B
TypeScript
/**
|
|
* 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
|
|
* @param metadata Additional parameters to attach to the event
|
|
*/
|
|
public static track = (
|
|
event: string,
|
|
action: string,
|
|
metadata?: Record<string, string>
|
|
) => {
|
|
// GA3
|
|
if (window.ga) {
|
|
window.ga("send", "event", event, action);
|
|
}
|
|
|
|
// GA4
|
|
if (window.gtag) {
|
|
window.gtag("event", event, { action, ...metadata });
|
|
}
|
|
};
|
|
}
|