blob: 014f72db978c015ce311e03619e32d1112a6ee52 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
|
/**
* Safe wrapper around umami's programmatic `track`. The analytics script is
* skipped on localhost, lazily loaded elsewhere, and routinely blocked by
* content blockers, so a bare `umami.track(...)` throws a ReferenceError that
* would take core actions (incrementing progress, syncing settings) down with
* it. Declarative `data-umami-event` attributes are handled by the script
* itself and never need this; reach for it only from event handlers.
*/
export const track = (event: string, data?: Record<string, unknown>): void => {
if (typeof umami !== "undefined") umami.track(event, data);
};
|