sovereign-intelligence
Front door to Drake Stapleton's sovereign stack.
Brought by drakestapleton
sovereign-intelligence / docs / archive / drakestapleton.com-old / src / lib / tracking.ts
| 1 | declare global { |
| 2 | interface Window { |
| 3 | dataLayer?: unknown[]; |
| 4 | gtag?: (...args: unknown[]) => void; |
| 5 | } |
| 6 | } |
| 7 | |
| 8 | export function trackEvent(action: string, params: Record<string, unknown> = {}) { |
| 9 | if (typeof window === "undefined") { |
| 10 | return; |
| 11 | } |
| 12 | if (typeof window.gtag === "function") { |
| 13 | window.gtag("event", action, params); |
| 14 | } |
| 15 | } |
| 16 | |
| 17 | export function trackRepoOutbound(repoName: string, destinationUrl: string) { |
| 18 | trackEvent("repo_outbound_click", { |
| 19 | repo_name: repoName, |
| 20 | destination_url: destinationUrl, |
| 21 | event_category: "engagement", |
| 22 | event_label: repoName, |
| 23 | }); |
| 24 | } |