@flusterduck/svelte
v0.7.18
Published
SvelteKit rage click detection and UX analytics. Tracks dead clicks, form abandonment, scroll frustration. Hotjar/FullStory alternative for Svelte apps.
Downloads
176
Maintainers
Keywords
Readme
@flusterduck/svelte
SvelteKit integration for Flusterduck. Exports plain functions for initialization and tracking. No Svelte-specific wrappers are needed since the SDK is framework-agnostic; this package adds SSR guards and a SvelteKit-idiomatic entry point.
Installation
npm install flusterduck @flusterduck/svelteUsage
Initialize in your root layout's onMount so it only runs in the browser:
// src/routes/+layout.svelte
import { onMount } from 'svelte';
import { initFlusterduck, destroyFlusterduck } from '@flusterduck/svelte';
onMount(() => {
initFlusterduck({
key: 'fd_pub_...',
environment: 'production',
});
return () => destroyFlusterduck();
});Tracking
import { signal, track, identify } from '@flusterduck/svelte';
// Custom friction signal with optional weight (0-100)
signal('filter_spiral', { element: '.filter-bar', weight: 20 });
// Business event
track('plan_selected', { plan: 'scale' });
// Segment
identify({ plan: 'scale', role: 'admin' });Consent
import { setConsent, optOut } from '@flusterduck/svelte';
setConsent(true); // start tracking after cookie acceptance
optOut(); // stop and clear sessionAPI
initFlusterduck(config: Config): void
destroyFlusterduck(): void
signal(name: string, data?: { element?: string; metadata?: Record<string, unknown>; weight?: number }): void
track(name: string, metadata?: Record<string, unknown>): void
identify(segment: Record<string, string>): void
setConsent(consented: boolean): void
optOut(): voidAll Config options from the core flusterduck package are supported.
signal, track, and identify are also exported as trackSignal, trackBusinessEvent, and identifySegment for naming parity with the other framework packages' hook return values.
