@joryio/web-sdk 0.0.0-stage → 1.3.0-beta.1

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.
Files changed (76) hide show
  1. package/CHANGELOG.md +5 -0
  2. package/LICENSE +54 -0
  3. package/README.md +497 -2
  4. package/dist/core/config.d.ts +101 -0
  5. package/dist/core/config.d.ts.map +1 -0
  6. package/dist/core/device.d.ts +14 -0
  7. package/dist/core/device.d.ts.map +1 -0
  8. package/dist/core/ecommerce.d.ts +67 -0
  9. package/dist/core/ecommerce.d.ts.map +1 -0
  10. package/dist/core/identity.d.ts +36 -0
  11. package/dist/core/identity.d.ts.map +1 -0
  12. package/dist/core/inapp.d.ts +169 -0
  13. package/dist/core/inapp.d.ts.map +1 -0
  14. package/dist/core/network.d.ts +158 -0
  15. package/dist/core/network.d.ts.map +1 -0
  16. package/dist/core/outbox.d.ts +79 -0
  17. package/dist/core/outbox.d.ts.map +1 -0
  18. package/dist/core/pending-attributes.d.ts +43 -0
  19. package/dist/core/pending-attributes.d.ts.map +1 -0
  20. package/dist/core/push.d.ts +59 -0
  21. package/dist/core/push.d.ts.map +1 -0
  22. package/dist/core/queue.d.ts +107 -0
  23. package/dist/core/queue.d.ts.map +1 -0
  24. package/dist/core/sdk.d.ts +169 -0
  25. package/dist/core/sdk.d.ts.map +1 -0
  26. package/dist/core/session.d.ts +36 -0
  27. package/dist/core/session.d.ts.map +1 -0
  28. package/dist/core/storage.d.ts +17 -0
  29. package/dist/core/storage.d.ts.map +1 -0
  30. package/dist/core/user.d.ts +28 -0
  31. package/dist/core/user.d.ts.map +1 -0
  32. package/dist/core/utm.d.ts +39 -0
  33. package/dist/core/utm.d.ts.map +1 -0
  34. package/dist/core/values.d.ts +3 -0
  35. package/dist/core/values.d.ts.map +1 -0
  36. package/dist/core/write-retry.d.ts +66 -0
  37. package/dist/core/write-retry.d.ts.map +1 -0
  38. package/dist/index.d.mts +711 -0
  39. package/dist/index.d.ts +21 -0
  40. package/dist/index.d.ts.map +1 -0
  41. package/dist/joryio-sw.js +6 -0
  42. package/dist/joryio.cjs.js +7265 -0
  43. package/dist/joryio.min.js +7 -0
  44. package/dist/joryio.min.js.map +1 -0
  45. package/dist/joryio.mjs +7254 -0
  46. package/dist/joryio.umd.js +7271 -0
  47. package/dist/utils/bucket-hash.d.ts +2 -0
  48. package/dist/utils/bucket-hash.d.ts.map +1 -0
  49. package/dist/utils/logger.d.ts +14 -0
  50. package/dist/utils/logger.d.ts.map +1 -0
  51. package/dist/utils/uuid.d.ts +3 -0
  52. package/dist/utils/uuid.d.ts.map +1 -0
  53. package/package.json +90 -4
  54. package/src/core/config.ts +362 -0
  55. package/src/core/device.ts +50 -0
  56. package/src/core/ecommerce.ts +482 -0
  57. package/src/core/identity.ts +251 -0
  58. package/src/core/inapp.ts +2419 -0
  59. package/src/core/network.ts +1261 -0
  60. package/src/core/outbox.ts +707 -0
  61. package/src/core/pending-attributes.ts +350 -0
  62. package/src/core/push.ts +667 -0
  63. package/src/core/queue.ts +894 -0
  64. package/src/core/sdk.ts +3108 -0
  65. package/src/core/session.ts +311 -0
  66. package/src/core/storage.ts +157 -0
  67. package/src/core/user.ts +203 -0
  68. package/src/core/utm.ts +304 -0
  69. package/src/core/values.ts +85 -0
  70. package/src/core/write-retry.ts +136 -0
  71. package/src/index.ts +305 -0
  72. package/src/snippet/loader.js +134 -0
  73. package/src/utils/bucket-hash.ts +44 -0
  74. package/src/utils/logger.ts +58 -0
  75. package/src/utils/uuid.ts +29 -0
  76. package/src/worker/joryio-sw.js +218 -0
@@ -0,0 +1,711 @@
1
+ type LogLevel = 'error' | 'warn' | 'info' | 'debug';
2
+ declare class Logger {
3
+ private enabled;
4
+ private level;
5
+ constructor(enabled: boolean, level?: LogLevel);
6
+ private shouldLog;
7
+ error(...args: any[]): void;
8
+ warn(...args: any[]): void;
9
+ info(...args: any[]): void;
10
+ debug(...args: any[]): void;
11
+ setEnabled(enabled: boolean): void;
12
+ setLevel(level: LogLevel): void;
13
+ }
14
+
15
+ declare class StorageManager {
16
+ private prefix;
17
+ private memoryStore;
18
+ private isLocalStorageAvailable;
19
+ private logger;
20
+ private static hashKey;
21
+ constructor(sdkKey: string, logger: Logger);
22
+ private checkLocalStorageAvailable;
23
+ private getKey;
24
+ storageKeyFor(key: string): string;
25
+ set<T>(key: string, value: T, expiresInDays?: number): void;
26
+ get<T>(key: string): T | null;
27
+ remove(key: string): void;
28
+ clear(): void;
29
+ }
30
+
31
+ interface UTMParameters {
32
+ utm_source?: string;
33
+ utm_medium?: string;
34
+ utm_campaign?: string;
35
+ utm_content?: string;
36
+ utm_term?: string;
37
+ referrer?: string;
38
+ landing_page?: string;
39
+ captured_at?: number;
40
+ }
41
+ interface UTMData {
42
+ current: UTMParameters | null;
43
+ firstTouch: UTMParameters | null;
44
+ lastTouch: UTMParameters | null;
45
+ }
46
+
47
+ interface SessionInfo {
48
+ sessionId: string;
49
+ sessionStart: number;
50
+ lastActivity: number;
51
+ isNewSession: boolean;
52
+ }
53
+
54
+ interface WriteOwner {
55
+ anonymousId: string;
56
+ userId?: string;
57
+ }
58
+ type WriteRecord = {
59
+ kind: 'alias';
60
+ payload: {
61
+ anonymousId: string;
62
+ userId?: string;
63
+ aliasLabel: string;
64
+ aliasName: string;
65
+ };
66
+ } | {
67
+ kind: 'subscription';
68
+ payload: {
69
+ channel: any;
70
+ status: any;
71
+ userId?: string;
72
+ anonymousId: string;
73
+ };
74
+ } | {
75
+ kind: 'group';
76
+ payload: {
77
+ groupId: string;
78
+ channel: any;
79
+ action: 'subscribe' | 'unsubscribe';
80
+ userId?: string;
81
+ anonymousId: string;
82
+ };
83
+ } | {
84
+ kind: 'marker';
85
+ payload: {
86
+ value: boolean;
87
+ userId?: string;
88
+ anonymousId: string;
89
+ };
90
+ };
91
+ type WriteRunner = (label: string, record: WriteRecord) => void;
92
+
93
+ declare enum SubscriptionStatus {
94
+ OPTED_IN = "optedIn",
95
+ SUBSCRIBED = "subscribed",
96
+ UNSUBSCRIBED = "unsubscribed"
97
+ }
98
+ type SubscriptionChannel = 'email' | 'sms' | 'whatsapp' | 'push' | 'viber';
99
+ type SubscriptionPreferences = Partial<Record<SubscriptionChannel, SubscriptionStatus>>;
100
+ declare class User {
101
+ private logger;
102
+ private network;
103
+ private identity;
104
+ private apiEndpoint;
105
+ private runWrite;
106
+ constructor(logger: Logger, network: NetworkClient, identity: IdentityManager, apiEndpoint: string, runWrite?: WriteRunner);
107
+ private sendOnce;
108
+ private ids;
109
+ setSubscription(channel: SubscriptionChannel, status: SubscriptionStatus): void;
110
+ setSubscriptions(preferences: SubscriptionPreferences): void;
111
+ addToSubscriptionGroup(groupId: string, channel?: SubscriptionChannel): void;
112
+ removeFromSubscriptionGroup(groupId: string, channel?: SubscriptionChannel): void;
113
+ private updateGroup;
114
+ }
115
+
116
+ interface NetworkRequest {
117
+ url: string;
118
+ method?: 'GET' | 'POST' | 'PUT' | 'DELETE';
119
+ headers?: Record<string, string>;
120
+ body?: any;
121
+ subjectUserId?: string | null;
122
+ }
123
+ interface NetworkResponse {
124
+ ok: boolean;
125
+ status: number;
126
+ data?: any;
127
+ error?: string;
128
+ retryAfterMs?: number;
129
+ softFailure?: boolean;
130
+ }
131
+ interface AttributeOps {
132
+ attributes?: Record<string, any>;
133
+ increment?: Record<string, number>;
134
+ append?: Record<string, any>;
135
+ remove?: Record<string, any>;
136
+ unset?: string[];
137
+ }
138
+ interface RetryConfig {
139
+ maxRetries: number;
140
+ backoffMs: number;
141
+ maxBackoffMs?: number;
142
+ timeoutMs?: number;
143
+ }
144
+ interface RetiredTokenStore {
145
+ load(): Record<string, unknown> | null;
146
+ update(mutate: (stored: Record<string, unknown>) => Record<string, unknown>): void;
147
+ }
148
+ type SdkAuthFailureReason = 'missing' | 'invalid' | 'expired' | 'sub_mismatch';
149
+ interface SdkAuthFailureInfo {
150
+ reason: SdkAuthFailureReason;
151
+ endpoint: string;
152
+ userId?: string | null;
153
+ }
154
+ type SdkAuthFailureCallback = (info: SdkAuthFailureInfo) => void | string | Promise<void | string>;
155
+ interface CircuitBreakerConfig {
156
+ failureThreshold: number;
157
+ cooldownMs: number;
158
+ }
159
+ type CircuitState = 'closed' | 'open' | 'half-open';
160
+ declare class NetworkClient {
161
+ private logger;
162
+ private sdkKey;
163
+ private retryConfig;
164
+ private circuitBreakerConfig;
165
+ private circuitState;
166
+ private consecutiveFailures;
167
+ private circuitOpenedAt;
168
+ private sdkAuthEnabled;
169
+ private sdkAuthToken;
170
+ private sdkAuthFailureCallback;
171
+ private retiredSdkAuthTokens;
172
+ private retiredTokenStore;
173
+ private sdkAuthTokenUser;
174
+ private keepaliveBytesInFlight;
175
+ private currentUserId;
176
+ private suspended;
177
+ constructor(sdkKey: string, logger: Logger, retryConfig: RetryConfig, circuitBreakerConfig?: Partial<CircuitBreakerConfig>);
178
+ setSdkAuthenticationEnabled(enabled: boolean): void;
179
+ setSdkAuthenticationToken(token: string | undefined): void;
180
+ retireSdkAuthToken(): void;
181
+ private retireToken;
182
+ switchUser(userId: string | null): void;
183
+ private adoptStandbyToken;
184
+ dropStandbySdkAuthTokens(keep?: Set<string>): void;
185
+ setRetiredTokenStore(store: RetiredTokenStore | null): void;
186
+ retiredSdkAuthUsers(): string[];
187
+ forgetRetiredSdkAuthTokensExcept(stillQueued: Set<string>, now?: number): number | null;
188
+ private saveRetiredTokens;
189
+ private sdkAuthTokenFor;
190
+ getCurrentUserId(): string | null;
191
+ setSdkAuthenticationFailureCallback(cb: SdkAuthFailureCallback | null): void;
192
+ setCurrentUserId(userId: string | null): void;
193
+ isSuspended(): boolean;
194
+ noteSuspended(status: number, data: any): boolean;
195
+ getSdkAuthHeaders(subjectUserId?: string | null): Record<string, string>;
196
+ keepaliveBudget(): number;
197
+ isSdkAuthError(status: number, data: any): boolean;
198
+ refreshSdkAuthToken(info: SdkAuthFailureInfo): Promise<string | undefined>;
199
+ request(request: NetworkRequest): Promise<NetworkResponse>;
200
+ private onRequestSuccess;
201
+ private onRequestFailure;
202
+ getCircuitBreakerState(): {
203
+ state: CircuitState;
204
+ consecutiveFailures: number;
205
+ openedAt: number;
206
+ };
207
+ private performFetch;
208
+ private parseResponse;
209
+ private shouldRetry;
210
+ private calculateBackoff;
211
+ private sleep;
212
+ sendEvents(apiEndpoint: string, events: any[], identify?: {
213
+ userId: string;
214
+ anonymousId: string;
215
+ attributes?: Record<string, any>;
216
+ }): Promise<NetworkResponse>;
217
+ supportsKeepalive(): boolean;
218
+ sendEventsKeepalive(apiEndpoint: string, events: any[], identify?: {
219
+ userId: string;
220
+ anonymousId: string;
221
+ attributes?: Record<string, any>;
222
+ }): Promise<NetworkResponse> | null;
223
+ postKeepalive(url: string, body: any): Promise<NetworkResponse> | null;
224
+ sendIdentify(apiEndpoint: string, userId: string, attributes: any, anonymousId?: string): Promise<NetworkResponse>;
225
+ sendAddAlias(apiEndpoint: string, payload: {
226
+ anonymousId: string;
227
+ userId?: string;
228
+ aliasLabel: string;
229
+ aliasName: string;
230
+ }): Promise<NetworkResponse>;
231
+ sendDeviceSession(apiEndpoint: string, payload: {
232
+ userId?: string;
233
+ anonymousId?: string;
234
+ deviceId: string;
235
+ platform: 'ios' | 'android' | 'web';
236
+ deviceInfo?: Record<string, any>;
237
+ }): Promise<NetworkResponse>;
238
+ sendSetAttributes(apiEndpoint: string, ops: AttributeOps, userId?: string | null, anonymousId?: string): Promise<NetworkResponse>;
239
+ sendSubscriptionUpdate(apiEndpoint: string, payload: {
240
+ channel: SubscriptionChannel;
241
+ status: 'optedIn' | 'subscribed' | 'unsubscribed';
242
+ userId?: string;
243
+ anonymousId?: string;
244
+ }): Promise<NetworkResponse>;
245
+ sendSubscriptionGroupUpdate(apiEndpoint: string, payload: {
246
+ groupId: string;
247
+ channel: SubscriptionChannel;
248
+ action: 'subscribe' | 'unsubscribe';
249
+ userId?: string;
250
+ anonymousId?: string;
251
+ }): Promise<NetworkResponse>;
252
+ }
253
+
254
+ type AttributeOpKind = 'set' | 'unset' | 'increment' | 'append' | 'remove';
255
+ interface AttributeEntry {
256
+ key: string;
257
+ kind: AttributeOpKind;
258
+ value?: any;
259
+ values?: any[];
260
+ inFlight?: boolean;
261
+ owner?: WriteOwner;
262
+ attempts?: number;
263
+ }
264
+ interface AttributeRequest {
265
+ ops: AttributeOps;
266
+ entries: AttributeEntry[];
267
+ owner?: WriteOwner;
268
+ }
269
+ type OwnerResolver = (owner: WriteOwner | undefined) => WriteOwner | undefined;
270
+ declare class PendingAttributes {
271
+ private readonly maxEntries;
272
+ private entries;
273
+ constructor(maxEntries?: number);
274
+ add(kind: AttributeOpKind, key: string, value?: any, owner?: WriteOwner): void;
275
+ mark(ops: AttributeOps, owner?: WriteOwner): void;
276
+ isEmpty(): boolean;
277
+ hasUnsent(): boolean;
278
+ nextRequest(resolve?: OwnerResolver): AttributeRequest | null;
279
+ peekRequest(resolve?: OwnerResolver): AttributeRequest | null;
280
+ toOps(): AttributeOps | null;
281
+ acknowledge(sent: AttributeEntry[]): void;
282
+ release(sent: AttributeEntry[], dropIncrements: boolean): number;
283
+ drop(sent: AttributeEntry[]): void;
284
+ dropIncrements(sent: AttributeEntry[]): void;
285
+ pending(anonymousId?: string): Record<string, any>;
286
+ serialize(): AttributeEntry[];
287
+ restore(stored: unknown): void;
288
+ pinOwner(anonymousId: string, userId: string): void;
289
+ clear(): void;
290
+ private build;
291
+ private lastFor;
292
+ private trim;
293
+ }
294
+
295
+ interface UserAttributes {
296
+ [key: string]: any;
297
+ }
298
+ interface UserIdentity {
299
+ userId: string | null;
300
+ anonymousId: string;
301
+ attributes: UserAttributes;
302
+ }
303
+ declare class IdentityManager {
304
+ readonly pending: PendingAttributes;
305
+ private storage;
306
+ private logger;
307
+ private userId;
308
+ private anonymousId;
309
+ private attributes;
310
+ constructor(storage: StorageManager, logger: Logger, userId?: string, anonymousId?: string);
311
+ identify(userId: string, attributes?: UserAttributes): void;
312
+ reset(): void;
313
+ adopt(anonymousId: string, userId: string | null): void;
314
+ setAttributes(attributes: UserAttributes): void;
315
+ setAttribute(key: string, value: any): void;
316
+ incrementAttribute(key: string, value?: number): void;
317
+ unsetAttribute(key: string): void;
318
+ addToArray(key: string, value: any): void;
319
+ removeFromArray(key: string, value: any): void;
320
+ getIdentity(): UserIdentity;
321
+ getUserId(): string | null;
322
+ getAnonymousId(): string;
323
+ getAttributes(): UserAttributes;
324
+ getAttribute(key: string): any;
325
+ isIdentified(): boolean;
326
+ }
327
+
328
+ declare const SDK_VERSION = "1.3.0";
329
+ interface InAppDisplayOptions {
330
+ defaultPosition?: 'top' | 'center' | 'bottom';
331
+ defaultAnimation?: 'fade' | 'slide' | 'none';
332
+ backdropColor?: string;
333
+ closeButtonColor?: string;
334
+ zIndex?: number;
335
+ }
336
+ interface InAppOptions {
337
+ enabled?: boolean;
338
+ evaluationMode?: 'differential-sync' | 'session-start-only';
339
+ syncInterval?: number;
340
+ displayOptions?: InAppDisplayOptions;
341
+ allowHtmlJsInAppMessages?: boolean;
342
+ onMessageDisplay?: (message: any) => void;
343
+ onMessageClick?: (message: any, action: string) => void;
344
+ onMessageDismiss?: (message: any, action: string) => void;
345
+ }
346
+ interface InitConfig {
347
+ sdkKey: string;
348
+ apiEndpoint?: string;
349
+ userId?: string;
350
+ anonymousId?: string;
351
+ batchSize?: number;
352
+ batchFlushInterval?: number;
353
+ sendImmediately?: boolean;
354
+ maxQueueSize?: number;
355
+ sessionTimeout?: number;
356
+ trackSessionStart?: boolean;
357
+ trackPageViews?: boolean;
358
+ captureUTM?: boolean;
359
+ resetSessionOnNewCampaign?: boolean;
360
+ trackPageProperties?: boolean;
361
+ trackDeviceProperties?: boolean;
362
+ inApp?: InAppOptions;
363
+ persistQueue?: boolean;
364
+ maxRetries?: number;
365
+ retryBackoffMs?: number;
366
+ requestTimeout?: number;
367
+ respectDoNotTrack?: boolean;
368
+ optOut?: boolean;
369
+ trackingConsent?: 'granted' | 'denied' | 'pending';
370
+ enableSdkAuthentication?: boolean;
371
+ sdkAuthenticationToken?: string;
372
+ enableDebug?: boolean;
373
+ logLevel?: 'error' | 'warn' | 'info' | 'debug';
374
+ plugins?: Array<Plugin>;
375
+ }
376
+ interface Plugin {
377
+ name: string;
378
+ version: string;
379
+ load(sdk: any): void | Promise<void>;
380
+ unload(): void | Promise<void>;
381
+ beforeTrack?(event: any): any | null;
382
+ afterTrack?(event: any): void;
383
+ }
384
+
385
+ interface InAppCampaign {
386
+ id: string;
387
+ name: string;
388
+ type: 'modal' | 'banner' | 'slideup' | 'fullscreen' | 'custom';
389
+ priority: number;
390
+ evaluationMode: 'differential-sync' | 'session-start-only';
391
+ frequencyCap?: {
392
+ maxImpressions?: number | null;
393
+ timeWindow: string;
394
+ minDelayBetweenImpressions?: number;
395
+ };
396
+ variantId?: string;
397
+ variantName?: string;
398
+ pendingId?: string;
399
+ deliveryToken?: string;
400
+ source?: string;
401
+ content?: {
402
+ kind: 'html';
403
+ html: string;
404
+ css: string;
405
+ assets?: unknown[];
406
+ } | {
407
+ kind: 'native';
408
+ title?: string;
409
+ body: string;
410
+ imageUrl?: string;
411
+ buttons?: Array<{
412
+ id: string;
413
+ text: string;
414
+ action: string;
415
+ url?: string;
416
+ }>;
417
+ closeButton?: boolean;
418
+ backdropDismissible?: boolean;
419
+ };
420
+ targeting?: {
421
+ filterGroups: any[];
422
+ };
423
+ triggers: InAppTrigger[];
424
+ reevaluateBeforeDisplay?: boolean;
425
+ watchedAttributes?: string[];
426
+ }
427
+ interface InAppTrigger {
428
+ type: 'immediate' | 'event' | 'attribute_change' | 'attribute_threshold' | 'push_notification_tap';
429
+ event?: string;
430
+ attribute?: string;
431
+ operator?: string;
432
+ value?: any;
433
+ delay?: number;
434
+ }
435
+ interface InAppMessage {
436
+ campaign: InAppCampaign;
437
+ renderedHtml: string;
438
+ displayedAt?: Date;
439
+ }
440
+
441
+ interface EcommerceProduct {
442
+ productId: string;
443
+ name: string;
444
+ price: number;
445
+ quantity?: number;
446
+ category?: string;
447
+ brand?: string;
448
+ variant?: string;
449
+ variantId?: string;
450
+ sku?: string;
451
+ imageUrl?: string;
452
+ url?: string;
453
+ }
454
+ interface EcommerceCartItem extends EcommerceProduct {
455
+ quantity: number;
456
+ }
457
+ interface EcommerceOrder {
458
+ orderId: string;
459
+ items: EcommerceCartItem[];
460
+ value: number;
461
+ currency?: string;
462
+ shipping?: number;
463
+ tax?: number;
464
+ discount?: number;
465
+ coupon?: string;
466
+ }
467
+ interface EcommerceConfig {
468
+ currency?: string;
469
+ }
470
+ declare class EcommerceTracker {
471
+ private sdk;
472
+ private config;
473
+ private logger;
474
+ constructor(sdk: JoryioSDK, config?: EcommerceConfig | null, logger?: Logger);
475
+ private guard;
476
+ private productProblem;
477
+ private itemsProblem;
478
+ private cartProblem;
479
+ private textProblem;
480
+ private amountsProblem;
481
+ private validItems;
482
+ private itemCount;
483
+ viewProduct(product: EcommerceProduct): void;
484
+ viewCategory(categoryId: string, categoryName: string, properties?: Record<string, any>): void;
485
+ search(query: string, resultCount?: number, properties?: Record<string, any>): void;
486
+ addToCart(item: EcommerceCartItem, cartValue?: number): void;
487
+ removeFromCart(item: EcommerceProduct, quantity?: number): void;
488
+ cartViewed(items: EcommerceCartItem[], cartValue: number): void;
489
+ updateCart(items: EcommerceCartItem[], cartValue: number): void;
490
+ startCheckout(items: EcommerceCartItem[], cartValue: number, properties?: Record<string, any>): void;
491
+ addPaymentInfo(paymentMethod: string, properties?: Record<string, any>): void;
492
+ purchase(order: EcommerceOrder): void;
493
+ orderFulfilled(orderId: string, trackingNumber?: string, carrier?: string): void;
494
+ orderDelivered(orderId: string): void;
495
+ orderCancelled(orderId: string, reason?: string): void;
496
+ orderRefunded(orderId: string, refundAmount?: number, reason?: string): void;
497
+ addToWishlist(product: EcommerceProduct): void;
498
+ removeFromWishlist(product: EcommerceProduct): void;
499
+ shareProduct(product: EcommerceProduct, shareMethod: string): void;
500
+ applyCoupon(couponCode: string, discountAmount?: number, discountType?: 'fixed' | 'percentage'): void;
501
+ removeCoupon(couponCode: string): void;
502
+ submitReview(productId: string, rating: number, reviewText?: string): void;
503
+ }
504
+ declare function createEcommerceTracker(sdk: JoryioSDK, config?: EcommerceConfig | null, logger?: Logger): EcommerceTracker;
505
+
506
+ interface PushManagerOptions {
507
+ canSend?: () => boolean;
508
+ canWithdraw?: () => boolean;
509
+ withdrawalUserId?: () => string | null;
510
+ storage?: StorageManager;
511
+ getDeviceId?: () => string | undefined;
512
+ onSubscribeSettled?: () => void;
513
+ }
514
+ interface PushSubscribeOptions {
515
+ swPath?: string;
516
+ scope?: string;
517
+ }
518
+ type PushPermissionState = 'granted' | 'denied' | 'notDetermined' | 'unavailable';
519
+ declare class PushManager {
520
+ private readonly logger;
521
+ private readonly network;
522
+ private readonly identity;
523
+ private readonly apiEndpoint;
524
+ private vapidKeyCache;
525
+ private prepared;
526
+ private lastPrepareError;
527
+ private readonly canSend;
528
+ private readonly canWithdraw;
529
+ private readonly withdrawalUserId;
530
+ private readonly storage;
531
+ private unregisterInFlight;
532
+ private unregisterTimer;
533
+ private readonly getDeviceId;
534
+ private readonly onSubscribeSettled;
535
+ constructor(logger: Logger, network: NetworkClient, identity: IdentityManager, apiEndpoint: string, options?: PushManagerOptions);
536
+ isSupported(): boolean;
537
+ getPermissionState(): PushPermissionState;
538
+ getExistingSubscription(options?: PushSubscribeOptions | null): Promise<PushSubscription | null>;
539
+ syncExistingSubscription(force?: boolean, options?: PushSubscribeOptions | null): Promise<void>;
540
+ setTrackingOptedOut(optedOut: boolean): Promise<void>;
541
+ prepare(options?: PushSubscribeOptions | null): Promise<boolean>;
542
+ subscribe(options?: PushSubscribeOptions | null): Promise<PushSubscription | null>;
543
+ private subscribeOnce;
544
+ unsubscribe(options?: PushSubscribeOptions | null): Promise<boolean>;
545
+ forget(): Promise<void>;
546
+ pendingUnregisterUsers(): string[];
547
+ private pendingUnregisters;
548
+ private storePendingUnregisters;
549
+ retryPendingUnregister(): void;
550
+ private sendPendingUnregister;
551
+ destroy(): void;
552
+ private logRegisterFailure;
553
+ private subscriptionKeyMatches;
554
+ private fetchVapidPublicKey;
555
+ private registerWithBackend;
556
+ }
557
+
558
+ type TrackingConsent = 'granted' | 'denied' | 'pending';
559
+ type PreInitDecision = {
560
+ method: 'optOut';
561
+ } | {
562
+ method: 'optIn';
563
+ } | {
564
+ method: 'updateConsent';
565
+ consent: TrackingConsent;
566
+ } | {
567
+ method: 'wipeData';
568
+ };
569
+ declare class JoryioSDK {
570
+ private static instance;
571
+ private config;
572
+ private logger;
573
+ private storage;
574
+ private session;
575
+ private static readonly ATTRIBUTE_FLUSH_DEBOUNCE_MS;
576
+ private attributeFlushTimer;
577
+ private attributeFlushInFlight;
578
+ private attributeFlushAgain;
579
+ private attributeGeneration;
580
+ private attributeFailures;
581
+ private identity;
582
+ private queue;
583
+ private network;
584
+ private utm;
585
+ private inapp;
586
+ private _user;
587
+ private _push;
588
+ private _ecommerce;
589
+ private isInitialized;
590
+ private isOptedOut;
591
+ private disabled;
592
+ private consentPending;
593
+ private userOptedOut;
594
+ private dntEnabled;
595
+ private trackingConsent;
596
+ private outbox;
597
+ private lastTrackedUrl;
598
+ private deviceId;
599
+ private boundHandlePageUnload;
600
+ private boundHandleOnline;
601
+ private boundHandleStorage;
602
+ private withdrawalUserId;
603
+ private optedOutAt;
604
+ private consentDeniedAt;
605
+ private lastDecisionStamp;
606
+ private awaitingSessionOf;
607
+ private pruneTimer;
608
+ constructor(config: InitConfig, preInit?: PreInitDecision[]);
609
+ private createOutbox;
610
+ private currentOwner;
611
+ private effectiveUserId;
612
+ private deferIdentify;
613
+ private releaseDeferredIdentify;
614
+ private forgetDeferredIdentify;
615
+ private scheduleRetiredTokenPrune;
616
+ private pruneRetiredTokens;
617
+ private handleStorageEvent;
618
+ private repersistPrivacyDecisions;
619
+ private storedStamp;
620
+ private noteDecisionStamps;
621
+ private nextDecisionStamp;
622
+ private storedOptOut;
623
+ private storedDenial;
624
+ private writeOptOut;
625
+ private writeOptIn;
626
+ private writeDenial;
627
+ private writeGrant;
628
+ private resolveOwner;
629
+ private pinAnonymousWrites;
630
+ private writeRequest;
631
+ private markerOps;
632
+ private sendWrite;
633
+ private onWriteSettled;
634
+ private syncWorkerReporting;
635
+ private initialConsent;
636
+ private storeConsent;
637
+ private applyPreInitDecision;
638
+ getTrackingConsent(): TrackingConsent;
639
+ isUserOptedOut(): boolean;
640
+ private syncOptOutMarker;
641
+ private recomputePrivacy;
642
+ private canSend;
643
+ private applyPrivacyState;
644
+ private releaseHeldWrites;
645
+ private runWrite;
646
+ private restoreAttributeWrites;
647
+ private persistAttributeWrites;
648
+ private flushQueueForWrite;
649
+ private trackSessionStart;
650
+ private trackSessionStartIfMissing;
651
+ private getOrCreateDeviceId;
652
+ private trackPageView;
653
+ track(eventName: string, properties?: Record<string, any>): void;
654
+ identify(userId: string): void;
655
+ addAlias(aliasLabel: string, aliasName: string): void;
656
+ setAttributes(attributes: Record<string, any>): void;
657
+ private sendAttributesAfterPendingIdentify;
658
+ private scheduleAttributeFlush;
659
+ private clearPendingAttributeWrites;
660
+ private flushAttributeOps;
661
+ private attributeRetryDelay;
662
+ private reportPushPermissionIfChanged;
663
+ setAttribute(key: string, value: any): void;
664
+ incrementAttribute(key: string, value?: number): void;
665
+ unsetAttribute(key: string): void;
666
+ addToArray(key: string, value: any): void;
667
+ removeFromArray(key: string, value: any): void;
668
+ reset(): Promise<void>;
669
+ wipeData(): Promise<void>;
670
+ private wipeLocalState;
671
+ private resyncInApp;
672
+ flush(): Promise<void>;
673
+ private flushEvents;
674
+ private classifyFailure;
675
+ private handlePageUnload;
676
+ private sendAttributesAtUnload;
677
+ optOut(): void;
678
+ optIn(): void;
679
+ updateConsent(consent: TrackingConsent): void;
680
+ private isDoNotTrackEnabled;
681
+ private loadPlugins;
682
+ private unloadPlugins;
683
+ get user(): User;
684
+ get push(): PushManager;
685
+ ecommerce(config?: EcommerceConfig): EcommerceTracker;
686
+ setSdkAuthenticationToken(token: string): void;
687
+ setSdkAuthenticationErrorCallback(cb: SdkAuthFailureCallback): void;
688
+ getAnonymousId(): string;
689
+ getUserId(): string | null;
690
+ private dataGate;
691
+ private liftDataGate;
692
+ private inflightSessionStartAtClear;
693
+ private isDroppingDataCalls;
694
+ ready(callback: (sdk: JoryioSDK) => void): void;
695
+ getIdentity(): UserIdentity;
696
+ getSessionInfo(): SessionInfo;
697
+ getUTMData(): UTMData;
698
+ updateUTM(): void;
699
+ syncInAppCampaigns(attributeChanges?: Record<string, any>): Promise<void>;
700
+ getInAppCampaigns(): InAppCampaign[];
701
+ displayInAppCampaign(campaignId: string): Promise<void>;
702
+ dismissInAppMessage(campaignId: string): void;
703
+ trackInAppConversion(campaignId: string, eventName: string): Promise<void>;
704
+ destroy(): Promise<void>;
705
+ static getInstance(): JoryioSDK | null;
706
+ }
707
+
708
+ declare function installSnippetQueue(win: any): void;
709
+
710
+ export { EcommerceTracker, JoryioSDK, PushManager, SDK_VERSION, SubscriptionStatus, User, createEcommerceTracker, JoryioSDK as default, installSnippetQueue };
711
+ export type { EcommerceCartItem, EcommerceConfig, EcommerceOrder, EcommerceProduct, InAppCampaign, InAppDisplayOptions, InAppMessage, InAppOptions, InAppTrigger, InitConfig, Plugin, PushPermissionState, PushSubscribeOptions, SdkAuthFailureCallback, SdkAuthFailureInfo, SdkAuthFailureReason, SubscriptionChannel, SubscriptionPreferences, TrackingConsent, UTMData, UTMParameters };