/** * trackd.one JavaScript SDK — privacy-first analytics. * No cookies, no storage, no device identifiers, no fingerprinting. */ /** Flat event properties. Nested objects/arrays, null and non-finite numbers are dropped; max 4 KB JSON. */ export type TrackdEventData = Record export interface TrackdOptions { /** Your trackd.one website / app id (UUID). Required. */ websiteId: string /** API host. Default: `https://trackd.one` */ host?: string /** e.g. `web`, `android`, `ios`, `react-native`, `windows`, `node` (servers / CLIs). Auto-detected when omitted. */ platform?: string /** Your app's version, e.g. `2.3.1`. */ appVersion?: string /** e.g. `Android 15`, `iOS 18.1`. */ osVersion?: string /** Screen resolution `WxH`. Auto-detected in browsers. */ screen?: string /** BCP-47 language tag. Auto-detected from navigator / Intl. */ language?: string /** `desktop` | `mobile` | `tablet`. Auto-detected in browsers. */ device?: 'desktop' | 'mobile' | 'tablet' | (string & {}) /** Log what the SDK does to the console. Default: false */ debug?: boolean /** Start enabled. Default: true */ enabled?: boolean /** Browser only: disable tracking when Global Privacy Control / Do Not Track is set. Default: true */ respectDoNotTrack?: boolean /** Browser only: flush via sendBeacon when the page is hidden. Default: true */ autoFlushOnHide?: boolean /** Detect platform/screen/language/device automatically. Default: true */ autoDetect?: boolean /** Flush when this many events are queued. Default: 20 */ flushAt?: number /** Flush at the latest this many ms after an event was queued. Default: 10000 (React Native: 30000) */ flushInterval?: number /** Max events per request (server limit 50). Default: 50 */ maxBatchSize?: number /** Max queued events; the oldest are dropped beyond this. Default: 500 */ maxQueueSize?: number /** Inactivity / background time in ms after which a new session starts. Default: 1800000 (30 min) */ sessionTimeout?: number /** Request timeout in ms. Default: 15000 */ requestTimeout?: number /** Custom fetch implementation (testing, proxies). Default: globalThis.fetch */ fetch?: (input: string, init?: any) => Promise<{ status: number; headers?: { get(name: string): string | null } }> /** Custom clock (ms epoch). Default: Date.now */ now?: () => number } export declare class Trackd { static readonly VERSION: string constructor(options: TrackdOptions) /** @deprecated legacy 0.x signature */ constructor(websiteId: string, options?: Omit) readonly websiteId: string readonly host: string readonly endpoint: string readonly enabled: boolean readonly context: Readonly> /** Number of events waiting to be sent. */ readonly queueSize: number /** Track a screen view (the app equivalent of a pageview). */ screen(name: string, title?: string): void /** Alias of `screen()`. */ screenView(name: string, title?: string): void /** Track a custom event. */ event(name: string, data?: TrackdEventData): void /** Track revenue — sent as event `purchase` with `{ amount, currency, order_id }`. */ revenue(amount: number, currency?: string, orderId?: string | number): void gameStart(level?: number, mode?: string): void levelComplete(level: number, score?: number, timeMs?: number): void gameOver(level: number, reason?: string): void videoWatch(videoId: string, durationMs?: number, completed?: boolean): void adView(adType: string, adId?: string): void tutorialStep(step: number, total: number, skipped?: boolean): void /** Send queued events now. Never rejects. */ flush(): Promise /** Enable/disable tracking. Disabling clears the queue. */ setEnabled(enabled: boolean): void /** Call when the app goes to the background (React Native / Electron). Browsers are handled automatically. */ onBackground(): Promise /** Call when the app returns to the foreground. */ onForeground(): void /** Remove listeners and timers. */ destroy(): void } /** @deprecated use `Trackd` */ export declare const TrackdSDK: typeof Trackd export default Trackd declare global { // eslint-disable-next-line no-var var Trackd: typeof import('./trackd').Trackd }