@layers/client 1.4.11 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,698 @@
1
+ //#region ../wasm/src/types.d.ts
2
+ type Environment = 'development' | 'staging' | 'production';
3
+ type Platform = 'ios' | 'android' | 'react-native' | 'web' | 'node' | 'flutter' | 'macos';
4
+ interface DeviceContext {
5
+ platform?: Platform;
6
+ osVersion?: string;
7
+ appVersion?: string;
8
+ deviceModel?: string;
9
+ locale?: string;
10
+ buildNumber?: string;
11
+ screenSize?: string;
12
+ installId?: string;
13
+ idfa?: string;
14
+ idfv?: string;
15
+ attStatus?: string;
16
+ deeplinkId?: string;
17
+ timezone?: string;
18
+ }
19
+ interface ConsentState {
20
+ analytics?: boolean | null;
21
+ advertising?: boolean | null;
22
+ }
23
+ /**
24
+ * Event properties attached to track/screen calls.
25
+ *
26
+ * Supported value types:
27
+ * - `string` — text values (max 64 KB per value)
28
+ * - `number` — integers and floating-point numbers
29
+ * - `boolean` — true/false flags
30
+ * - `null` — explicit null to clear a property
31
+ * - Nested `Record<string, unknown>` objects (one level deep recommended)
32
+ *
33
+ * Keys must be plain strings (max 128 chars). Prototype-pollution keys
34
+ * (`__proto__`, `constructor`, `prototype`) are rejected. Maximum 100 keys
35
+ * per call, 1 MB total payload.
36
+ */
37
+ interface EventProperties {
38
+ [key: string]: unknown;
39
+ }
40
+ /**
41
+ * User properties set via `setUserProperties()`.
42
+ *
43
+ * Supported value types:
44
+ * - `string` — text values (max 64 KB per value)
45
+ * - `number` — integers and floating-point numbers
46
+ * - `boolean` — true/false flags
47
+ * - `null` — explicit null to clear a property
48
+ * - Nested `Record<string, unknown>` objects (one level deep recommended)
49
+ *
50
+ * Keys must be plain strings (max 128 chars). Prototype-pollution keys
51
+ * (`__proto__`, `constructor`, `prototype`) are rejected. Maximum 100 keys
52
+ * per call.
53
+ */
54
+ interface UserProperties {
55
+ [key: string]: unknown;
56
+ }
57
+ type LayersErrorCode = 'NOT_INITIALIZED' | 'ALREADY_INITIALIZED' | 'SHUT_DOWN' | 'INVALID_CONFIG' | 'INVALID_ARGUMENT' | 'QUEUE_FULL' | 'SERIALIZATION' | 'NETWORK' | 'HTTP' | 'CIRCUIT_OPEN' | 'RATE_LIMITED' | 'CONSENT_NOT_GRANTED' | 'PERSISTENCE' | 'REMOTE_CONFIG' | 'EVENT_DENIED' | 'INTERNAL';
58
+ declare class LayersError extends Error {
59
+ readonly code: LayersErrorCode;
60
+ readonly status?: number;
61
+ constructor(code: LayersErrorCode, message: string, status?: number);
62
+ }
63
+ //#endregion
64
+ //#region ../wasm/src/core.d.ts
65
+ declare module '../pkg/layers_core.js' {
66
+ interface WasmLayersCore {
67
+ updateRetryAfter(status: number, retryAfterHeader: string | null): void;
68
+ clearRetryAfter(): void;
69
+ isRetryAfterActive(): boolean;
70
+ retryAfterRemainingMs(): number;
71
+ group(group_id: string, properties: any): void;
72
+ }
73
+ }
74
+ //#endregion
75
+ //#region src/api-types.d.ts
76
+ interface BaseEvent {
77
+ event: string;
78
+ timestamp: string;
79
+ event_id?: string;
80
+ app_id: string;
81
+ app_user_id?: string;
82
+ user_id?: string;
83
+ anonymous_id?: string;
84
+ session_id?: string;
85
+ environment: 'development' | 'staging' | 'production';
86
+ platform: 'ios' | 'android' | 'react-native' | 'web' | 'node' | 'flutter' | 'macos';
87
+ os_version: string;
88
+ app_version: string;
89
+ build_number?: string;
90
+ device_model: string;
91
+ screen_size?: string;
92
+ locale: string;
93
+ install_id?: string;
94
+ install_source?: string;
95
+ campaign_hint?: string;
96
+ referrer?: string;
97
+ referrer_source?: string;
98
+ utm_source?: string;
99
+ utm_medium?: string;
100
+ utm_campaign?: string;
101
+ utm_content?: string;
102
+ utm_term?: string;
103
+ click_id_param?: string;
104
+ idfa?: string;
105
+ idfv?: string;
106
+ att_status?: 'authorized' | 'denied' | 'restricted' | 'not_determined';
107
+ country_code?: string;
108
+ subdivision1_code?: string;
109
+ properties?: Record<string, unknown>;
110
+ [key: string]: unknown;
111
+ }
112
+ interface EventsBatchPayload {
113
+ events: BaseEvent[];
114
+ batch_id?: string;
115
+ sent_at: string;
116
+ }
117
+ interface UserPropertiesPayload {
118
+ app_user_id?: string;
119
+ user_id?: string;
120
+ app_id: string;
121
+ properties: Record<string, unknown>;
122
+ timestamp: string;
123
+ }
124
+ interface ConsentPayload {
125
+ app_user_id?: string;
126
+ user_id?: string;
127
+ app_id: string;
128
+ consent: {
129
+ advertising?: boolean | null;
130
+ analytics?: boolean | null;
131
+ };
132
+ att_status?: 'authorized' | 'denied' | 'restricted' | 'not_determined';
133
+ timestamp: string;
134
+ }
135
+ interface RemoteConfigResponse {
136
+ config: {
137
+ att?: {
138
+ strategy: 'immediate' | 'after_onboarding' | 'after_paywall_view' | 'manual';
139
+ prompt_copy?: {
140
+ title?: string;
141
+ message?: string;
142
+ };
143
+ };
144
+ skan?: {
145
+ preset?: 'subscriptions' | 'engagement' | 'iap';
146
+ rules?: Record<string, unknown>;
147
+ lock_policy?: string;
148
+ };
149
+ events?: {
150
+ allowlist?: string[];
151
+ denylist?: string[];
152
+ sampling?: Record<string, number>;
153
+ sampling_rate?: number;
154
+ rate_limit?: {
155
+ per_minute?: number;
156
+ per_hour?: number;
157
+ per_event?: Record<string, {
158
+ per_minute?: number;
159
+ per_hour?: number;
160
+ }>;
161
+ };
162
+ };
163
+ connectors?: Record<string, {
164
+ enabled?: boolean;
165
+ app_id?: string;
166
+ pixel_id?: string;
167
+ test_mode?: boolean;
168
+ }>;
169
+ deeplinks?: {
170
+ allowed_hosts?: string[];
171
+ behavior?: string;
172
+ };
173
+ privacy?: {
174
+ killswitches?: string[];
175
+ analytics_enabled?: boolean;
176
+ advertising_enabled?: boolean;
177
+ };
178
+ };
179
+ version: string;
180
+ cache_ttl: number;
181
+ }
182
+ interface SKANPostbackPayload {
183
+ app_id: string;
184
+ version: string;
185
+ ad_network_id: string;
186
+ campaign_id?: string;
187
+ source_app_id?: string;
188
+ conversion_value?: number;
189
+ coarse_conversion_value?: string;
190
+ lock_window?: boolean;
191
+ postback_sequence_index?: number;
192
+ did_win?: boolean;
193
+ timestamp: string;
194
+ }
195
+ //#endregion
196
+ //#region src/attribution.d.ts
197
+ interface AttributionData {
198
+ click_id_param?: string;
199
+ click_id_value?: string;
200
+ utm_source?: string;
201
+ utm_medium?: string;
202
+ utm_campaign?: string;
203
+ utm_content?: string;
204
+ utm_term?: string;
205
+ referrer_url?: string;
206
+ captured_at: number;
207
+ }
208
+ /**
209
+ * Read stored attribution data, returning null if missing or expired.
210
+ */
211
+ declare function getAttribution(): AttributionData | null;
212
+ /**
213
+ * Return a flat property bag suitable for merging into event properties.
214
+ * Keys are prefixed with `$attribution_` to avoid collisions.
215
+ */
216
+ declare function getAttributionProperties(): Record<string, string>;
217
+ //#endregion
218
+ //#region src/capi.d.ts
219
+ /**
220
+ * Read Meta's _fbp cookie.
221
+ * Format set by Meta Pixel: fb.1.{timestamp}.{random}
222
+ */
223
+ declare function getFbpCookie(): string | undefined;
224
+ /**
225
+ * Read TikTok's _ttp cookie.
226
+ */
227
+ declare function getTtpCookie(): string | undefined;
228
+ /**
229
+ * Capture the current page URL.
230
+ * Required by Meta CAPI for every web event (event_source_url).
231
+ */
232
+ declare function getPageUrl(): string | undefined;
233
+ /**
234
+ * Format an fbclid value into Meta's fbc cookie format.
235
+ * Format: fb.1.{timestamp_ms}.{fbclid}
236
+ *
237
+ * @param fbclid - The raw fbclid parameter value from the URL
238
+ * @param timestampMs - Optional timestamp in milliseconds (defaults to Date.now())
239
+ */
240
+ declare function formatFbc(fbclid: string, timestampMs?: number): string;
241
+ /**
242
+ * Get the fbc value. Checks in order:
243
+ * 1. If an fbclid URL parameter is present, format it as fbc
244
+ * 2. If an _fbc cookie exists, return it
245
+ * 3. Return undefined
246
+ */
247
+ declare function getFbc(): string | undefined;
248
+ /**
249
+ * Build the full set of CAPI properties for an event.
250
+ * All values are optional — only present keys are included.
251
+ */
252
+ declare function getCapiProperties(): Record<string, string>;
253
+ //#endregion
254
+ //#region src/standard-events.d.ts
255
+ /**
256
+ * Predefined standard event name constants.
257
+ *
258
+ * Usage:
259
+ * ```ts
260
+ * import { StandardEvents } from '@layers/client';
261
+ * client.track(StandardEvents.PURCHASE, { amount: 9.99, currency: 'USD' });
262
+ * ```
263
+ */
264
+ declare const StandardEvents: {
265
+ readonly APP_OPEN: "app_open";
266
+ readonly LOGIN: "login";
267
+ readonly SIGN_UP: "sign_up";
268
+ readonly REGISTER: "register";
269
+ readonly PURCHASE: "purchase_success";
270
+ readonly ADD_TO_CART: "add_to_cart";
271
+ readonly ADD_TO_WISHLIST: "add_to_wishlist";
272
+ readonly INITIATE_CHECKOUT: "initiate_checkout";
273
+ readonly BEGIN_CHECKOUT: "begin_checkout";
274
+ readonly START_TRIAL: "start_trial";
275
+ readonly SUBSCRIBE: "subscribe";
276
+ readonly LEVEL_START: "level_start";
277
+ readonly LEVEL_COMPLETE: "level_complete";
278
+ readonly TUTORIAL_COMPLETE: "tutorial_complete";
279
+ readonly SEARCH: "search";
280
+ readonly VIEW_ITEM: "view_item";
281
+ readonly VIEW_CONTENT: "view_content";
282
+ readonly SHARE: "share";
283
+ readonly DEEP_LINK: "deep_link_opened";
284
+ readonly SCREEN_VIEW: "screen_view";
285
+ };
286
+ /** Union type of all standard event name strings. */
287
+ type StandardEventName = (typeof StandardEvents)[keyof typeof StandardEvents];
288
+ interface StandardEventPayload {
289
+ event: StandardEventName;
290
+ properties: EventProperties;
291
+ }
292
+ /** Build a login event. */
293
+ declare function loginEvent(method?: string): StandardEventPayload;
294
+ /** Build a sign-up event. */
295
+ declare function signUpEvent(method?: string): StandardEventPayload;
296
+ /** Build a register event. */
297
+ declare function registerEvent(method?: string): StandardEventPayload;
298
+ /** Build a purchase event. */
299
+ declare function purchaseEvent(amount: number, currency?: string, itemId?: string): StandardEventPayload;
300
+ /** Build an add-to-cart event. */
301
+ declare function addToCartEvent(itemId: string, price: number, quantity?: number): StandardEventPayload;
302
+ /** Build an add-to-wishlist event. */
303
+ declare function addToWishlistEvent(itemId: string, name?: string, price?: number): StandardEventPayload;
304
+ /** Build an initiate-checkout event. */
305
+ declare function initiateCheckoutEvent(value: number, currency?: string, itemCount?: number): StandardEventPayload;
306
+ /** Build a start-trial event. */
307
+ declare function startTrialEvent(plan?: string, durationDays?: number): StandardEventPayload;
308
+ /** Build a subscribe event. */
309
+ declare function subscribeEvent(plan: string, amount: number, currency?: string): StandardEventPayload;
310
+ /** Build a level-start event. */
311
+ declare function levelStartEvent(level: string): StandardEventPayload;
312
+ /** Build a level-complete event. */
313
+ declare function levelCompleteEvent(level: string, score?: number): StandardEventPayload;
314
+ /** Build a tutorial-complete event. */
315
+ declare function tutorialCompleteEvent(name?: string): StandardEventPayload;
316
+ /** Build a search event. */
317
+ declare function searchEvent(query: string, resultCount?: number): StandardEventPayload;
318
+ /** Build a view-item event. */
319
+ declare function viewItemEvent(itemId: string, name?: string, category?: string): StandardEventPayload;
320
+ /** Build a view-content event. */
321
+ declare function viewContentEvent(contentId: string, contentType?: string, name?: string): StandardEventPayload;
322
+ /** Build a share event. */
323
+ declare function shareEvent(contentType: string, method?: string, contentId?: string): StandardEventPayload;
324
+ /** Build a screen-view event. */
325
+ declare function screenViewEvent(name: string, screenClass?: string): StandardEventPayload;
326
+ //#endregion
327
+ //#region src/deep-links.d.ts
328
+ interface DeepLinkData {
329
+ url: string;
330
+ scheme: string;
331
+ host: string;
332
+ path: string;
333
+ queryParams: Record<string, string>;
334
+ timestamp: number;
335
+ }
336
+ /**
337
+ * Parse a URL string into structured DeepLinkData.
338
+ * Returns null if the URL cannot be parsed.
339
+ */
340
+ declare function parseDeepLink(url: string): DeepLinkData | null;
341
+ /**
342
+ * Set up a listener for URL changes in a web browser context.
343
+ * Listens for `popstate` and `hashchange` events and calls the callback
344
+ * with parsed deep link data on each URL change.
345
+ *
346
+ * Returns an unsubscribe function to remove the listeners.
347
+ */
348
+ declare function setupDeepLinkListener(onDeepLink: (data: DeepLinkData) => void): () => void;
349
+ //#endregion
350
+ //#region src/debug-overlay.d.ts
351
+ interface DebugOverlayState {
352
+ sdkVersion: string;
353
+ queueDepth: number;
354
+ sessionId: string;
355
+ installId: string | null;
356
+ appId: string;
357
+ environment: string;
358
+ isOnline: boolean;
359
+ recentEvents: readonly string[];
360
+ }
361
+ //#endregion
362
+ //#region src/commerce.d.ts
363
+ /** Event properties bag accepted by commerce functions. */
364
+ type EventProperties$1 = Record<string, unknown>;
365
+ /** Minimal Layers SDK interface required by the commerce module. */
366
+ interface WebCommerceTracker {
367
+ track(event: string, properties?: Record<string, any>): void;
368
+ }
369
+ /** Purchase details for trackPurchase. */
370
+ interface PurchaseParams {
371
+ productId: string;
372
+ /** Unit price of the item. Revenue is computed as `price * quantity`. */
373
+ price: number;
374
+ currency: string;
375
+ transactionId?: string;
376
+ quantity?: number;
377
+ isRestored?: boolean;
378
+ store?: string;
379
+ properties?: EventProperties$1;
380
+ }
381
+ /** Subscription details for trackSubscription. */
382
+ interface SubscriptionParams {
383
+ productId: string;
384
+ /** Unit price of the subscription. */
385
+ price: number;
386
+ currency: string;
387
+ period?: string;
388
+ transactionId?: string;
389
+ isRenewal?: boolean;
390
+ isTrial?: boolean;
391
+ subscriptionGroupId?: string;
392
+ originalTransactionId?: string;
393
+ properties?: EventProperties$1;
394
+ }
395
+ /** Cart item for order and checkout tracking. */
396
+ interface CartItem {
397
+ productId: string;
398
+ name: string;
399
+ price: number;
400
+ quantity?: number;
401
+ category?: string;
402
+ }
403
+ /** Order details for trackOrder. */
404
+ interface OrderParams {
405
+ orderId: string;
406
+ items: CartItem[];
407
+ subtotal: number;
408
+ currency?: string;
409
+ tax?: number;
410
+ shipping?: number;
411
+ discount?: number;
412
+ couponCode?: string;
413
+ properties?: EventProperties$1;
414
+ }
415
+ /** Refund details for trackRefund. */
416
+ interface RefundParams {
417
+ transactionId: string;
418
+ amount: number;
419
+ currency: string;
420
+ reason?: string;
421
+ properties?: EventProperties$1;
422
+ }
423
+ /** Purchase failure details for trackPurchaseFailed. */
424
+ interface PurchaseFailedParams {
425
+ productId: string;
426
+ currency: string;
427
+ errorCode: string | number;
428
+ errorMessage?: string;
429
+ properties?: EventProperties$1;
430
+ }
431
+ /**
432
+ * Track a successful purchase.
433
+ *
434
+ * ```ts
435
+ * import { trackPurchase } from '@layers/client';
436
+ *
437
+ * trackPurchase(layers, {
438
+ * productId: 'premium_monthly',
439
+ * price: 9.99,
440
+ * currency: 'USD',
441
+ * transactionId: 'txn_abc123',
442
+ * });
443
+ * ```
444
+ */
445
+ declare function trackPurchase(layers: WebCommerceTracker, params: PurchaseParams): void;
446
+ /**
447
+ * Track a failed purchase attempt.
448
+ */
449
+ declare function trackPurchaseFailed(layers: WebCommerceTracker, params: PurchaseFailedParams): void;
450
+ /**
451
+ * Track a subscription purchase or renewal.
452
+ *
453
+ * ```ts
454
+ * import { trackSubscription } from '@layers/client';
455
+ *
456
+ * trackSubscription(layers, {
457
+ * productId: 'pro_annual',
458
+ * price: 49.99,
459
+ * currency: 'USD',
460
+ * period: 'P1Y',
461
+ * });
462
+ * ```
463
+ */
464
+ declare function trackSubscription(layers: WebCommerceTracker, params: SubscriptionParams): void;
465
+ /**
466
+ * Track a completed order with multiple line items.
467
+ */
468
+ declare function trackOrder(layers: WebCommerceTracker, params: OrderParams): void;
469
+ /**
470
+ * Track an item being added to the cart.
471
+ */
472
+ declare function trackAddToCart(layers: WebCommerceTracker, item: CartItem, properties?: EventProperties$1): void;
473
+ /**
474
+ * Track an item being removed from the cart.
475
+ */
476
+ declare function trackRemoveFromCart(layers: WebCommerceTracker, item: CartItem, properties?: EventProperties$1): void;
477
+ /**
478
+ * Track beginning the checkout flow.
479
+ */
480
+ declare function trackBeginCheckout(layers: WebCommerceTracker, items: CartItem[], currency?: string, properties?: EventProperties$1): void;
481
+ /**
482
+ * Track viewing a product detail page.
483
+ */
484
+ declare function trackViewProduct(layers: WebCommerceTracker, productId: string, name: string, price: number, currency?: string, category?: string, properties?: EventProperties$1): void;
485
+ /**
486
+ * Track a refund.
487
+ */
488
+ declare function trackRefund(layers: WebCommerceTracker, params: RefundParams): void;
489
+ //#endregion
490
+ //#region src/index.d.ts
491
+ interface LayersConfig {
492
+ /** Unique application identifier issued by the Layers dashboard. */
493
+ appId: string;
494
+ /** Deployment environment label. @default "production" */
495
+ environment?: Environment;
496
+ /** Optional user identifier to associate events with from the start. */
497
+ appUserId?: string;
498
+ /** Enable verbose debug logging to the console. @default false */
499
+ enableDebug?: boolean;
500
+ /** Base URL for the Layers ingest API. @default "https://in.layers.com" */
501
+ baseUrl?: string;
502
+ /** How often the event queue is flushed, in milliseconds. @default 30000 */
503
+ flushIntervalMs?: number;
504
+ /** Number of queued events that triggers an automatic flush. @default 10 */
505
+ flushThreshold?: number;
506
+ /** Maximum number of events to hold in the queue before dropping. @default 1000 */
507
+ maxQueueSize?: number;
508
+ /**
509
+ * Whether to automatically fire an `app_open` event during init().
510
+ * Set to `false` if you want to fire the event manually.
511
+ * @default true
512
+ */
513
+ autoTrackAppOpen?: boolean;
514
+ /**
515
+ * Whether to automatically track `deep_link_opened` events when the URL
516
+ * changes (popstate/hashchange). The tracked event includes the parsed
517
+ * URL components and all query parameters.
518
+ * @default true
519
+ */
520
+ autoTrackDeepLinks?: boolean;
521
+ }
522
+ /**
523
+ * Attribution data that will be attached to all subsequent events.
524
+ * Matches the RN SDK's setAttributionData pattern.
525
+ */
526
+ interface WebAttributionData {
527
+ deeplinkId?: string | null;
528
+ gclid?: string | null;
529
+ fbclid?: string | null;
530
+ ttclid?: string | null;
531
+ msclkid?: string | null;
532
+ }
533
+ type ErrorListener = (error: Error) => void;
534
+ /**
535
+ * Listener for SDK initialization timing metrics.
536
+ *
537
+ * @param mainThreadDurationMs Time spent in the synchronous portion of init.
538
+ * @param totalDurationMs Total wall-clock time of the `init()` call,
539
+ * including all async work (remote config fetch, etc.).
540
+ */
541
+ type InitListener = (mainThreadDurationMs: number, totalDurationMs: number) => void;
542
+ declare class LayersClient {
543
+ private core;
544
+ private appUserId;
545
+ private isOnline;
546
+ private readonly enableDebug;
547
+ private readonly baseUrl;
548
+ private readonly config;
549
+ private onlineListener;
550
+ private offlineListener;
551
+ private visibilityListener;
552
+ private beforeUnloadListener;
553
+ private deepLinkUnsubscribe;
554
+ private readonly errorListeners;
555
+ private _installId;
556
+ private _hadPriorSdkState;
557
+ private _attributionData;
558
+ private static readonly MAX_RECENT_EVENTS;
559
+ private _recentEvents;
560
+ private _isInitialized;
561
+ private _initListener;
562
+ private _debugOverlayActive;
563
+ constructor(config: LayersConfig);
564
+ /** Initialize the client: detects device info, attaches lifecycle listeners, and fetches remote config. */
565
+ init(): Promise<void>;
566
+ /**
567
+ * Record a custom analytics event with an optional property bag.
568
+ *
569
+ * Events are batched and flushed automatically when the queue reaches
570
+ * `flushThreshold` or the periodic flush timer fires.
571
+ */
572
+ track(eventName: string, properties?: EventProperties): void;
573
+ /**
574
+ * Record a screen view event with an optional property bag.
575
+ *
576
+ * Events are batched and flushed automatically when the queue reaches
577
+ * `flushThreshold` or the periodic flush timer fires.
578
+ */
579
+ screen(screenName: string, properties?: EventProperties): void;
580
+ /** Set or update user-level properties that persist across sessions. */
581
+ setUserProperties(properties: UserProperties): void;
582
+ /** Set user-level properties with "set once" semantics — only keys not previously set are applied. */
583
+ setUserPropertiesOnce(properties: UserProperties): void;
584
+ /** Update the user's consent state for analytics and advertising data collection. */
585
+ setConsent(consent: ConsentState): void;
586
+ /**
587
+ * Associate all subsequent events with a group (company, team, organization).
588
+ * Pass `undefined` or empty string to clear the group association.
589
+ */
590
+ group(groupId: string | undefined, properties?: EventProperties): void;
591
+ /** Associate all subsequent events with the given user ID, or clear it with `undefined`. */
592
+ setAppUserId(appUserId: string | undefined): void;
593
+ /** @deprecated Use setAppUserId instead */
594
+ setUserId(userId: string): void;
595
+ /** Return the current app user ID, or `undefined` if not set. */
596
+ getAppUserId(): string | undefined;
597
+ /** @deprecated Use getAppUserId instead */
598
+ getUserId(): string | undefined;
599
+ /** Return the current anonymous session ID. */
600
+ getSessionId(): string;
601
+ /** Return the current consent state for analytics and advertising. */
602
+ getConsentState(): ConsentState;
603
+ /** Override device-level context fields (platform, OS, locale, etc.). */
604
+ setDeviceInfo(deviceInfo: DeviceContext): void;
605
+ /**
606
+ * Return the install ID (persistent UUID stored in localStorage).
607
+ * Generated on first init, persists across sessions.
608
+ */
609
+ getInstallId(): string | null;
610
+ /**
611
+ * Return the number of events currently queued.
612
+ */
613
+ getQueueDepth(): number;
614
+ /**
615
+ * Store attribution data that will be attached to all subsequent events.
616
+ *
617
+ * The values are persisted in localStorage so they survive page reloads.
618
+ * Pass `null` to clear a value.
619
+ *
620
+ * When set, `deeplinkId`, `gclid`, `fbclid`, `ttclid`, and/or `msclkid`
621
+ * are included in every event's properties.
622
+ */
623
+ setAttributionData(data: WebAttributionData): void;
624
+ /**
625
+ * Set a listener to receive SDK initialization timing metrics.
626
+ * Must be called **before** `init()` to receive the callback.
627
+ * Pass `null` to clear the listener.
628
+ */
629
+ setInitListener(listener: InitListener | null): void;
630
+ /**
631
+ * Enable the debug overlay — a lightweight DOM panel showing SDK state.
632
+ * The overlay updates every second with queue depth, session info, and recent events.
633
+ */
634
+ enableDebugOverlay(): void;
635
+ /**
636
+ * Disable and remove the debug overlay from the DOM.
637
+ */
638
+ disableDebugOverlay(): void;
639
+ /** Whether the SDK has completed async initialization. */
640
+ get isInitialized(): boolean;
641
+ /** SDK version string. */
642
+ getSdkVersion(): string;
643
+ /**
644
+ * Returns the most recent tracked events (newest first).
645
+ * Each entry is a formatted string like "12:34:56 event_name (3 props)".
646
+ */
647
+ getRecentEvents(): readonly string[];
648
+ /** Flush all queued events to the server. Falls back to synchronous persistence on failure. */
649
+ flush(): Promise<void>;
650
+ /** Immediately shut down the client, removing all event listeners. Queued events are persisted but not flushed. */
651
+ shutdown(): void;
652
+ /**
653
+ * Async shutdown: flushes remaining events before shutting down.
654
+ * @param timeoutMs Maximum time to wait for flush (default 3000ms).
655
+ */
656
+ shutdownAsync(timeoutMs?: number): Promise<void>;
657
+ private cleanupListeners;
658
+ /** End the current session and start a new one with a fresh session ID. */
659
+ startNewSession(): void;
660
+ /**
661
+ * Register an error listener. Errors from track/screen/flush
662
+ * that would otherwise be silently dropped are forwarded here.
663
+ */
664
+ on(event: 'error', listener: ErrorListener): this;
665
+ /**
666
+ * Remove a previously registered error listener.
667
+ */
668
+ off(event: 'error', listener: ErrorListener): this;
669
+ private emitError;
670
+ private initializeInstallId;
671
+ private shouldTreatAsNewInstall;
672
+ private restoreAttributionData;
673
+ /**
674
+ * Merge attribution properties into event properties.
675
+ * deeplink_id flows through DeviceContext; other fields flow through properties.
676
+ */
677
+ private mergeAttributionProperties;
678
+ /** Merge CAPI, attribution (url-based), setAttributionData, and user properties. */
679
+ private mergeAllProperties;
680
+ private checkClipboardAttribution;
681
+ private _trackedDeepLinkUrls;
682
+ private setupDeepLinkAutoTracking;
683
+ private trackInitTiming;
684
+ private recordRecentEvent;
685
+ private initializeDeviceInfo;
686
+ private detectOS;
687
+ private detectDeviceModel;
688
+ private detectLocale;
689
+ private detectScreenSize;
690
+ private setupNetworkListener;
691
+ private getBeaconUrl;
692
+ private setupLifecycleListeners;
693
+ private storageGet;
694
+ private storageSet;
695
+ }
696
+ //#endregion
697
+ export { getAttribution as $, addToWishlistEvent as A, signUpEvent as B, DeepLinkData as C, StandardEventPayload as D, StandardEventName as E, purchaseEvent as F, viewItemEvent as G, subscribeEvent as H, registerEvent as I, getFbc as J, formatFbc as K, screenViewEvent as L, levelCompleteEvent as M, levelStartEvent as N, StandardEvents as O, loginEvent as P, AttributionData as Q, searchEvent as R, DebugOverlayState as S, setupDeepLinkListener as T, tutorialCompleteEvent as U, startTrialEvent as V, viewContentEvent as W, getPageUrl as X, getFbpCookie as Y, getTtpCookie as Z, trackPurchaseFailed as _, WebAttributionData as a, SKANPostbackPayload as at, trackSubscription as b, PurchaseFailedParams as c, DeviceContext as ct, SubscriptionParams as d, LayersError as dt, getAttributionProperties as et, WebCommerceTracker as f, UserProperties as ft, trackPurchase as g, trackOrder as h, LayersConfig as i, RemoteConfigResponse as it, initiateCheckoutEvent as j, addToCartEvent as k, PurchaseParams as l, Environment as lt, trackBeginCheckout as m, InitListener as n, ConsentPayload as nt, CartItem as o, UserPropertiesPayload as ot, trackAddToCart as p, getCapiProperties as q, LayersClient as r, EventsBatchPayload as rt, OrderParams as s, ConsentState as st, ErrorListener as t, BaseEvent as tt, RefundParams as u, EventProperties as ut, trackRefund as v, parseDeepLink as w, trackViewProduct as x, trackRemoveFromCart as y, shareEvent as z };
698
+ //# sourceMappingURL=index-C6l4kIMP.d.ts.map