Skip to content

Open source, privacy-first web analytics. Lightweight, cookie-free Google Analytics alternative. Self-hosted or cloud.

379 B
Raw Blame
type PlausibleTracker = (
  event: string,
  options?: { props?: Record<string, string> }
) => void

export function trackEvent(
  event: string,
  props?: Record<string, string>
): void {
  const plausible = (window as unknown as { plausible?: PlausibleTracker })
    .plausible
  if (typeof plausible === 'function') {
    plausible(event, props ? { props } : undefined)
  }
}