Web SDK

@vortexauth/web

pnpm add @vortexauth/web

VortexAnalyticsClient extends the core client with browser behaviour:

  • LocalStorage-backed event queue and anonymous id, so events survive restarts.
  • Flush on visibilitychange and a keepalive flush on pagehide, so events queued during a session leave before the tab closes.
  • Autocapture: initial page and SPA route changes as screen.viewed, global errors, session tracking driven by tab visibility.
  • Link attribution: a vx_link token on the landing URL is captured at construction and stamped on subsequent events.
import { VortexAnalyticsClient } from '@vortexauth/web';

const analytics = new VortexAnalyticsClient({ dsn: process.env.NEXT_PUBLIC_VORTEX_DSN! });
analytics.track({ event: 'checkout.completed', properties: { plan: 'pro' } });
await analytics.identify({ externalUserId: user.id });

Options worth knowing: environment ('production' by default — set 'development' in debug builds), autocapture, flushIntervalMs, maxBatchSize, defaultProperties.