9 lines
399 B
TypeScript
9 lines
399 B
TypeScript
export function trackClientEvent(input: { type: "PAGE_VIEW" | "PROJECT_OPEN" | "MELODY_PLAY" | "PROJECT_LINK_CLICK"; path?: string; entityId?: string }) {
|
|
void fetch("/api/analytics", {
|
|
method: "POST",
|
|
headers: { "content-type": "application/json" },
|
|
body: JSON.stringify({ ...input, path: input.path || window.location.pathname }),
|
|
keepalive: true,
|
|
}).catch(() => undefined);
|
|
}
|