@adv-re/segment-wrapper 4.36.0-beta.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,916 @@
1
+ /**
2
+ * Core Segment Analytics types
3
+ */
4
+ /**
5
+ * Segment Analytics instance available on window.analytics
6
+ */
7
+ interface SegmentAnalytics {
8
+ track: (event: string, properties?: Record<string, unknown>, options?: AnalyticsOptions, callback?: AnalyticsCallback) => void;
9
+ page: (name?: string, properties?: Record<string, unknown>, options?: AnalyticsOptions, callback?: AnalyticsCallback) => void;
10
+ identify: (userId: string | number, traits?: Record<string, unknown>, options?: AnalyticsOptions, callback?: AnalyticsCallback) => void;
11
+ reset: () => void;
12
+ ready: (callback: () => void) => void;
13
+ addSourceMiddleware?: (middleware: SourceMiddlewareFunction) => void;
14
+ addDestinationMiddleware?: (middleware: DestinationMiddlewareFunction) => void;
15
+ user?: () => SegmentUser;
16
+ }
17
+ /**
18
+ * Segment user object
19
+ */
20
+ interface SegmentUser {
21
+ id: () => string | null;
22
+ anonymousId: () => string | null;
23
+ traits: () => Record<string, unknown>;
24
+ }
25
+ /**
26
+ * Callback function for analytics methods
27
+ */
28
+ type AnalyticsCallback = (...args: unknown[]) => void;
29
+ /**
30
+ * Options/context object for analytics methods
31
+ */
32
+ interface AnalyticsOptions {
33
+ integrations?: IntegrationsObject;
34
+ context?: ContextObject;
35
+ anonymousId?: string;
36
+ ip?: string;
37
+ [key: string]: unknown;
38
+ }
39
+ /**
40
+ * Context object that can be passed to analytics methods
41
+ */
42
+ interface ContextObject {
43
+ integrations?: IntegrationsObject;
44
+ traits?: Record<string, unknown>;
45
+ campaign?: CampaignDetails;
46
+ page?: PageContext;
47
+ userAgent?: string;
48
+ ip?: string;
49
+ locale?: string;
50
+ timezone?: string;
51
+ externalIds?: ExternalId[];
52
+ [key: string]: unknown;
53
+ }
54
+ /**
55
+ * Integrations configuration object
56
+ */
57
+ interface IntegrationsObject {
58
+ All?: boolean;
59
+ 'Adobe Analytics'?: boolean | {
60
+ marketingCloudVisitorId?: string;
61
+ };
62
+ 'Google Analytics 4'?: boolean | {
63
+ clientId?: string;
64
+ sessionId?: string;
65
+ };
66
+ Personas?: boolean;
67
+ Webhooks?: boolean;
68
+ Webhook?: boolean;
69
+ [integrationName: string]: boolean | Record<string, unknown> | undefined;
70
+ }
71
+ /**
72
+ * Campaign details from URL parameters
73
+ */
74
+ interface CampaignDetails {
75
+ campaign_id?: string;
76
+ campaign_name?: string;
77
+ campaign_source?: string;
78
+ campaign_medium?: string;
79
+ campaign_term?: string;
80
+ campaign_content?: string;
81
+ [key: string]: string | undefined;
82
+ }
83
+ /**
84
+ * Page context information
85
+ */
86
+ interface PageContext {
87
+ path?: string;
88
+ referrer?: string;
89
+ search?: string;
90
+ title?: string;
91
+ url?: string;
92
+ [key: string]: unknown;
93
+ }
94
+ /**
95
+ * External ID for cross-platform identification
96
+ */
97
+ interface ExternalId {
98
+ id: string;
99
+ type: string;
100
+ collection?: string;
101
+ encoding?: string;
102
+ }
103
+ /**
104
+ * Middleware payload object
105
+ */
106
+ interface MiddlewarePayload {
107
+ obj: {
108
+ type: string;
109
+ event?: string;
110
+ userId?: string | number;
111
+ anonymousId?: string;
112
+ properties?: Record<string, unknown>;
113
+ traits?: Record<string, unknown>;
114
+ context?: ContextObject;
115
+ integrations?: IntegrationsObject;
116
+ [key: string]: unknown;
117
+ };
118
+ [key: string]: unknown;
119
+ }
120
+ /**
121
+ * Source middleware function signature
122
+ */
123
+ type SourceMiddlewareFunction = (payload: {
124
+ payload: MiddlewarePayload;
125
+ next: (payload: MiddlewarePayload | null) => void;
126
+ integrations: IntegrationsObject;
127
+ }) => void;
128
+ /**
129
+ * Destination middleware function signature
130
+ */
131
+ type DestinationMiddlewareFunction = (payload: {
132
+ payload: MiddlewarePayload;
133
+ next: (payload: MiddlewarePayload | null) => void;
134
+ integration: string;
135
+ }) => void;
136
+ /**
137
+ * Google Consents for Consent Mode
138
+ */
139
+ interface GoogleConsents {
140
+ analytics_storage?: ConsentValue;
141
+ ad_storage?: ConsentValue;
142
+ ad_user_data?: ConsentValue;
143
+ ad_personalization?: ConsentValue;
144
+ }
145
+ /**
146
+ * Consent value for Google Consent Mode
147
+ */
148
+ type ConsentValue = 'granted' | 'denied';
149
+ /**
150
+ * GDPR Privacy values
151
+ * Contains the user's consent state for analytics and advertising tracking
152
+ */
153
+ interface GdprPrivacyValue {
154
+ analytics: string;
155
+ advertising: string;
156
+ }
157
+
158
+ declare const _default: {
159
+ page: (event?: string, properties?: Record<string, unknown>, context?: AnalyticsOptions, callback?: AnalyticsCallback) => Promise<void>;
160
+ identify: (userIdParam: string | number, traits?: Record<string, unknown>, options?: AnalyticsOptions, callback?: AnalyticsCallback) => Promise<void>;
161
+ track: (event: string, properties?: Record<string, unknown>, context?: AnalyticsOptions, callback?: AnalyticsCallback) => Promise<void>;
162
+ reset: () => Promise<void>;
163
+ };
164
+
165
+ /**
166
+ * Middleware types for source and destination middlewares
167
+ */
168
+
169
+ /**
170
+ * Source middleware parameters
171
+ */
172
+ interface SourceMiddlewareParams {
173
+ payload: MiddlewarePayload;
174
+ next: (payload: MiddlewarePayload | null) => void;
175
+ integrations: IntegrationsObject;
176
+ }
177
+ /**
178
+ * Destination middleware parameters
179
+ */
180
+ interface DestinationMiddlewareParams {
181
+ payload: MiddlewarePayload;
182
+ next: (payload: MiddlewarePayload | null) => void;
183
+ integration: string;
184
+ }
185
+ /**
186
+ * User traits for middleware
187
+ */
188
+ interface UserTraits {
189
+ email?: string;
190
+ name?: string;
191
+ userId?: string | number;
192
+ [key: string]: unknown;
193
+ }
194
+ /**
195
+ * Screen information for middleware
196
+ */
197
+ interface ScreenInfo {
198
+ width: number;
199
+ height: number;
200
+ density: number;
201
+ }
202
+ /**
203
+ * Page data for middleware
204
+ */
205
+ interface PageData {
206
+ path: string;
207
+ referrer: string;
208
+ search: string;
209
+ title: string;
210
+ url: string;
211
+ }
212
+ /**
213
+ * Context properties that can be added by middlewares
214
+ */
215
+ interface DefaultContextProperties {
216
+ platform: string;
217
+ clientVersion: string;
218
+ gdpr_privacy?: string;
219
+ gdpr_privacy_advertising?: string;
220
+ analytics_storage?: string;
221
+ google_consents?: {
222
+ analytics_storage?: string;
223
+ ad_storage?: string;
224
+ ad_user_data?: string;
225
+ ad_personalization?: string;
226
+ };
227
+ [key: string]: unknown;
228
+ }
229
+ /**
230
+ * Middleware context enhancement function
231
+ */
232
+ type ContextEnhancer = (context: ContextObject) => ContextObject | Promise<ContextObject>;
233
+
234
+ /**
235
+ * Configuration types for segment-wrapper
236
+ */
237
+ /**
238
+ * Segment Wrapper configuration object
239
+ */
240
+ interface SegmentWrapperConfig {
241
+ /**
242
+ * Google Analytics Measurement ID (e.g., G-XXXXXXXXXX)
243
+ */
244
+ googleAnalyticsMeasurementId?: string;
245
+ /**
246
+ * Google Analytics data layer name (default: 'dataLayer')
247
+ */
248
+ googleAnalyticsDataLayer?: string;
249
+ /**
250
+ * Google Analytics additional config
251
+ */
252
+ googleAnalyticsConfig?: Record<string, unknown>;
253
+ /**
254
+ * Enable Google Analytics Consent Management
255
+ */
256
+ googleAnalyticsConsentManagement?: boolean;
257
+ /**
258
+ * User ID prefix to prepend to all user identifications
259
+ */
260
+ userIdPrefix?: string;
261
+ /**
262
+ * Default properties to attach to all track calls
263
+ */
264
+ defaultProperties?: Record<string, unknown>;
265
+ /**
266
+ * Enable experimental page data middleware
267
+ */
268
+ experimentalPageDataMiddleware?: boolean;
269
+ /**
270
+ * Enable sending Xandr ID in external IDs
271
+ */
272
+ sendXandrId?: boolean;
273
+ /**
274
+ * Adobe Marketing Cloud Organization ID
275
+ */
276
+ adobeMarketingCloudOrgId?: string;
277
+ /**
278
+ * Custom configuration values
279
+ */
280
+ [key: string]: unknown;
281
+ }
282
+ /**
283
+ * MPI (Multi-Platform Interface) configuration structure
284
+ */
285
+ interface MPIConfig {
286
+ segmentWrapper?: SegmentWrapperConfig;
287
+ [key: string]: unknown;
288
+ }
289
+ /**
290
+ * Window interface extension for MPI config
291
+ */
292
+ interface WindowWithMPI extends Window {
293
+ __mpi?: MPIConfig;
294
+ gtag?: (...args: unknown[]) => void;
295
+ dataLayer?: unknown[];
296
+ google_tag_manager?: unknown;
297
+ __tcfapi?: (...args: unknown[]) => void;
298
+ }
299
+ /**
300
+ * Configuration keys that can be used with getConfig/setConfig
301
+ */
302
+ type ConfigKey = keyof SegmentWrapperConfig;
303
+ /**
304
+ * Configuration getter function type
305
+ */
306
+ type ConfigGetter = {
307
+ (): SegmentWrapperConfig;
308
+ <K extends ConfigKey>(key: K): SegmentWrapperConfig[K];
309
+ };
310
+ /**
311
+ * Configuration setter function type
312
+ */
313
+ type ConfigSetter = <K extends ConfigKey>(key: K, value: SegmentWrapperConfig[K]) => void;
314
+
315
+ /**
316
+ * Repository interfaces for external integrations
317
+ */
318
+
319
+ /**
320
+ * Adobe Visitor API interface
321
+ */
322
+ interface AdobeVisitor {
323
+ getMarketingCloudVisitorID: () => string | undefined;
324
+ version?: string;
325
+ }
326
+ /**
327
+ * Adobe repository configuration
328
+ */
329
+ interface AdobeConfig {
330
+ ADOBE_ORG_ID?: string;
331
+ DEFAULT_DEMDEX_VERSION?: string;
332
+ TIME_BETWEEN_RETRIES?: number;
333
+ TIMES_TO_RETRY?: number;
334
+ TRACKING_SERVER?: string;
335
+ }
336
+ /**
337
+ * Adobe visitor data
338
+ */
339
+ interface AdobeVisitorData$1 {
340
+ trackingServer?: string;
341
+ version?: string;
342
+ }
343
+ /**
344
+ * Google Analytics fields
345
+ */
346
+ interface GoogleAnalyticsFields {
347
+ client_id?: string;
348
+ session_id?: string;
349
+ }
350
+ /**
351
+ * Google Tag Manager data layer
352
+ */
353
+ type DataLayer = unknown[];
354
+ /**
355
+ * Google gtag function
356
+ */
357
+ type GtagFunction = (...args: unknown[]) => void;
358
+ /**
359
+ * Consent state value (numeric)
360
+ */
361
+ type ConsentStateValue = 1 | 2;
362
+ /**
363
+ * Google Consent Mode command types
364
+ */
365
+ type ConsentCommand = 'default' | 'update';
366
+ /**
367
+ * Xandr ID value
368
+ */
369
+ type XandrId = string;
370
+ /**
371
+ * Options for getting Xandr ID
372
+ */
373
+ interface GetXandrIdOptions {
374
+ gdprPrivacyValueAdvertising?: string;
375
+ }
376
+ /**
377
+ * Options for getting campaign details
378
+ */
379
+ interface GetCampaignDetailsOptions {
380
+ needsTransformation?: boolean;
381
+ }
382
+ /**
383
+ * STC (Schibsted Tracking Code) structure
384
+ */
385
+ interface STCParams {
386
+ medium: string | null;
387
+ source: string | null;
388
+ campaign: string | null;
389
+ content?: string | null;
390
+ term?: string | null;
391
+ id?: string | null;
392
+ }
393
+ /**
394
+ * Google repository interface
395
+ */
396
+ interface GoogleRepository {
397
+ loadGoogleAnalytics: () => Promise<boolean>;
398
+ getGoogleClientId: () => Promise<string>;
399
+ getGoogleSessionId: () => Promise<string>;
400
+ setGoogleUserId: (userId: string | number) => void;
401
+ getCampaignDetails: (options?: GetCampaignDetailsOptions) => CampaignDetails;
402
+ sendGoogleConsents: (command: ConsentCommand, consents?: GoogleConsents) => void;
403
+ getConsentState: () => ConsentStateValue | undefined;
404
+ getGoogleConsentValue: (consentType: keyof GoogleConsents) => ConsentValue | undefined;
405
+ }
406
+ /**
407
+ * Adobe repository interface
408
+ */
409
+ interface AdobeRepository {
410
+ getAdobeMCVisitorID: () => Promise<string>;
411
+ getAdobeVisitorData: () => Promise<AdobeVisitorData$1>;
412
+ getAdobeMarketingCloudVisitorIdFromWindow: () => Promise<string>;
413
+ }
414
+ /**
415
+ * Xandr repository interface
416
+ */
417
+ interface XandrRepository {
418
+ getXandrId: (options?: GetXandrIdOptions) => Promise<XandrId>;
419
+ }
420
+ /**
421
+ * Window interface extension for segment wrapper globals
422
+ */
423
+ interface WindowWithSegmentWrapper extends Window {
424
+ __SEGMENT_WRAPPER?: {
425
+ ADOBE_ORG_ID?: string;
426
+ DEFAULT_DEMDEX_VERSION?: string;
427
+ TIME_BETWEEN_RETRIES?: number;
428
+ TIMES_TO_RETRY?: number;
429
+ TRACKING_SERVER?: string;
430
+ };
431
+ Visitor?: {
432
+ getInstance: (orgId: string, servers?: {
433
+ trackingServer?: string;
434
+ trackingServerSecure?: string;
435
+ }) => AdobeVisitor;
436
+ };
437
+ }
438
+
439
+ /**
440
+ * Utility types
441
+ */
442
+ /**
443
+ * Cookie options
444
+ */
445
+ interface CookieOptions {
446
+ domain?: string;
447
+ path?: string;
448
+ expires?: Date | string | number;
449
+ maxAge?: number;
450
+ secure?: boolean;
451
+ sameSite?: 'Strict' | 'Lax' | 'None';
452
+ }
453
+ /**
454
+ * Storage type
455
+ */
456
+ type StorageType = 'localStorage' | 'sessionStorage';
457
+ /**
458
+ * Storage interface
459
+ */
460
+ interface Storage {
461
+ getItem: (key: string) => string | null;
462
+ setItem: (key: string, value: string) => void;
463
+ removeItem: (key: string) => void;
464
+ clear: () => void;
465
+ }
466
+ /**
467
+ * Anonymous ID check result
468
+ */
469
+ interface AnonymousIdCheckResult {
470
+ anonymousId: string;
471
+ isNew: boolean;
472
+ }
473
+ /**
474
+ * Email hash algorithm
475
+ */
476
+ type HashAlgorithm = 'sha256' | 'md5';
477
+ /**
478
+ * Hashed email result
479
+ */
480
+ interface HashedEmail {
481
+ value: string;
482
+ algorithm: HashAlgorithm;
483
+ }
484
+
485
+ /**
486
+ * TCF (Transparency & Consent Framework) types
487
+ */
488
+ /**
489
+ * TCF API version
490
+ */
491
+ type TCFApiVersion = 2;
492
+ /**
493
+ * User GDPR consent state
494
+ */
495
+ declare enum UserGDPR {
496
+ ACCEPTED = "accepted",
497
+ DECLINED = "declined",
498
+ UNKNOWN = "unknown"
499
+ }
500
+ /**
501
+ * GDPR Privacy value per category
502
+ */
503
+ interface GDPRPrivacyValue {
504
+ analytics?: UserGDPR;
505
+ advertising?: UserGDPR;
506
+ }
507
+ /**
508
+ * TCF events
509
+ */
510
+ declare enum TCFEvents {
511
+ LOADED = "tcloaded",
512
+ USER_ACTION_COMPLETE = "useractioncomplete"
513
+ }
514
+ /**
515
+ * TCF data structure from CMP
516
+ */
517
+ interface TCData {
518
+ tcString?: string;
519
+ tcfPolicyVersion?: number;
520
+ cmpId?: number;
521
+ cmpVersion?: number;
522
+ gdprApplies?: boolean;
523
+ eventStatus: string;
524
+ cmpStatus?: string;
525
+ listenerId?: number;
526
+ isServiceSpecific?: boolean;
527
+ useNonStandardStacks?: boolean;
528
+ publisherCC?: string;
529
+ purposeOneTreatment?: boolean;
530
+ outOfBand?: {
531
+ allowedVendors?: Record<string, boolean>;
532
+ disclosedVendors?: Record<string, boolean>;
533
+ };
534
+ purpose?: {
535
+ consents?: Record<number, boolean>;
536
+ legitimateInterests?: Record<number, boolean>;
537
+ };
538
+ vendor?: {
539
+ consents?: Record<number, boolean>;
540
+ legitimateInterests?: Record<number, boolean>;
541
+ };
542
+ specialFeatureOptins?: Record<number, boolean>;
543
+ publisher?: {
544
+ consents?: Record<number, boolean>;
545
+ legitimateInterests?: Record<number, boolean>;
546
+ customPurpose?: {
547
+ consents?: Record<number, boolean>;
548
+ legitimateInterests?: Record<number, boolean>;
549
+ };
550
+ restrictions?: Record<string, Record<number, number>>;
551
+ };
552
+ }
553
+ /**
554
+ * TCF API callback
555
+ */
556
+ type TCFCallback = (tcData: TCData, success: boolean) => void;
557
+ /**
558
+ * TCF API command types
559
+ */
560
+ type TCFCommand = 'addEventListener' | 'removeEventListener' | 'getTCData' | 'ping';
561
+ /**
562
+ * TCF API function
563
+ */
564
+ type TCFApi = (command: string, version: number, callback: TCFCallback, parameter?: unknown) => void;
565
+ /**
566
+ * GDPR state manager
567
+ */
568
+ interface GDPRState {
569
+ listeners: Array<(value: GDPRPrivacyValue) => void>;
570
+ value?: GDPRPrivacyValue;
571
+ addListener: (callback: (value: GDPRPrivacyValue) => void) => void;
572
+ get: () => GDPRPrivacyValue | undefined;
573
+ set: (value: GDPRPrivacyValue) => void;
574
+ }
575
+ /**
576
+ * Needed purposes for different tracking categories
577
+ */
578
+ interface NeededPurposes {
579
+ analytics: number[];
580
+ advertising: number[];
581
+ }
582
+ /**
583
+ * Boros TCF cookie structure
584
+ */
585
+ interface BorosTcfCookie {
586
+ uuid?: string;
587
+ created?: string;
588
+ version?: string;
589
+ [key: string]: unknown;
590
+ }
591
+
592
+ /**
593
+ * Universal ID types
594
+ */
595
+ /**
596
+ * Universal ID data structure
597
+ */
598
+ interface UniversalIdData {
599
+ universalId?: string;
600
+ email?: string;
601
+ hashedEmail?: string;
602
+ timestamp?: number;
603
+ }
604
+ /**
605
+ * Universal ID listener callback
606
+ */
607
+ type UniversalIdListener = (data: UniversalIdData) => void;
608
+ /**
609
+ * Universal ID event detail
610
+ */
611
+ interface UniversalIdEventDetail {
612
+ universalId?: string;
613
+ hashedEmail?: string;
614
+ }
615
+ /**
616
+ * Universal ID custom event
617
+ */
618
+ interface UniversalIdEvent extends CustomEvent {
619
+ detail: UniversalIdEventDetail;
620
+ }
621
+
622
+ /**
623
+ * Configuration module for segment-wrapper
624
+ */
625
+
626
+ /**
627
+ * Check if code is running in a browser environment
628
+ */
629
+ declare const isClient: boolean;
630
+ /**
631
+ * Get the Segment Wrapper config from window.
632
+ * Can be called with no arguments to get the full config object,
633
+ * or with a key to get a specific config value.
634
+ *
635
+ * @example
636
+ * // Get full config
637
+ * const config = getConfig()
638
+ *
639
+ * @example
640
+ * // Get specific value
641
+ * const measurementId = getConfig('googleAnalyticsMeasurementId')
642
+ */
643
+ declare function getConfig(): SegmentWrapperConfig;
644
+ declare function getConfig<K extends ConfigKey>(key: K): SegmentWrapperConfig[K];
645
+ /**
646
+ * Set a config value to the Segment Wrapper config
647
+ *
648
+ * @param key - Config key to update
649
+ * @param value - Value to set on the config key
650
+ *
651
+ * @example
652
+ * setConfig('googleAnalyticsMeasurementId', 'G-XXXXXXXXXX')
653
+ */
654
+ declare const setConfig: <K extends ConfigKey>(key: K, value: SegmentWrapperConfig[K]) => void;
655
+ /**
656
+ * Initialize segment wrapper configuration
657
+ *
658
+ * @param config - Configuration object to set
659
+ *
660
+ * @example
661
+ * initConfig({
662
+ * googleAnalyticsMeasurementId: 'G-XXXXXXXXXX',
663
+ * userIdPrefix: 'user_'
664
+ * })
665
+ */
666
+ declare const initConfig: (config: Partial<SegmentWrapperConfig>) => void;
667
+ /**
668
+ * Clear all segment wrapper configuration
669
+ */
670
+ declare const clearConfig: () => void;
671
+
672
+ /**
673
+ * Event constants used throughout the segment wrapper
674
+ */
675
+ declare const EVENTS: {
676
+ readonly GA4_INIT_EVENT_SENT: "ga4InitEventSent";
677
+ };
678
+
679
+ /**
680
+ * Adobe Analytics Repository
681
+ * Handles Adobe Marketing Cloud Visitor ID integration
682
+ */
683
+ interface AdobeGlobalConfig {
684
+ ADOBE_ORG_ID?: string;
685
+ DEFAULT_DEMDEX_VERSION: string;
686
+ TIME_BETWEEN_RETRIES: number;
687
+ TIMES_TO_RETRY: number;
688
+ SERVERS: {
689
+ trackingServer?: string;
690
+ trackingServerSecure?: string;
691
+ };
692
+ }
693
+ interface DemdexInstance {
694
+ getMarketingCloudVisitorID: () => string | undefined;
695
+ version?: string;
696
+ }
697
+ interface AdobeVisitorData {
698
+ trackingServer?: string;
699
+ version: string;
700
+ }
701
+ declare global {
702
+ interface Window {
703
+ __SEGMENT_WRAPPER?: {
704
+ ADOBE_ORG_ID?: string;
705
+ DEFAULT_DEMDEX_VERSION?: string;
706
+ TIME_BETWEEN_RETRIES?: number;
707
+ TIMES_TO_RETRY?: number;
708
+ TRACKING_SERVER?: string;
709
+ };
710
+ Visitor?: {
711
+ getInstance: (orgId: string, servers: AdobeGlobalConfig['SERVERS']) => DemdexInstance;
712
+ };
713
+ }
714
+ }
715
+ /**
716
+ * Get Adobe Visitor Data including tracking server and version
717
+ */
718
+ declare const getAdobeVisitorData: () => Promise<AdobeVisitorData>;
719
+ /**
720
+ * Get Adobe Marketing Cloud Visitor ID
721
+ * Can use custom getter, import visitor API, or get from window
722
+ */
723
+ declare const getAdobeMCVisitorID: () => Promise<string | undefined>;
724
+
725
+ /**
726
+ * Get Universal ID
727
+ * Attempts to get it from config, or generates it from user email
728
+ */
729
+ declare const getUniversalId: () => string | undefined;
730
+
731
+ /**
732
+ * Google Analytics Repository
733
+ * Handles Google Analytics 4 integration and Consent Mode
734
+ */
735
+
736
+ declare const CONSENT_STATES: {
737
+ granted: "granted";
738
+ denied: "denied";
739
+ };
740
+ declare global {
741
+ interface Window {
742
+ gtag?: (...args: unknown[]) => void;
743
+ google_tag_data?: {
744
+ ics?: {
745
+ getConsentState?: (consentType: string) => number | undefined;
746
+ };
747
+ };
748
+ }
749
+ }
750
+
751
+ /**
752
+ * Anonymous ID checking utility
753
+ */
754
+ /**
755
+ * Check and reset anonymous ID if it matches the "no consents" placeholder
756
+ *
757
+ * This function checks if the user's anonymous ID is set to a placeholder value
758
+ * used when the user hasn't given consent. If it matches, it resets the ID to null
759
+ * so Segment can generate a new proper anonymous ID.
760
+ *
761
+ * @example
762
+ * // Call after analytics is ready
763
+ * window.analytics.ready(checkAnonymousId)
764
+ */
765
+ declare const checkAnonymousId: () => void;
766
+
767
+ /**
768
+ * Cookie utilities for segment-wrapper
769
+ */
770
+ /**
771
+ * Read a cookie value by name
772
+ *
773
+ * @param cookieName - The name of the cookie to read
774
+ * @returns The cookie value or null if not found
775
+ *
776
+ * @example
777
+ * const value = readCookie('session_id')
778
+ */
779
+ declare function readCookie(cookieName: string): string | null;
780
+ /**
781
+ * Save a cookie with the given name and data
782
+ *
783
+ * @param cookieName - The name of the cookie
784
+ * @param data - The data to store in the cookie
785
+ * @param options - Cookie options
786
+ *
787
+ * @example
788
+ * saveCookie('user_id', '12345', { maxAge: 86400, sameSite: 'Strict' })
789
+ */
790
+ declare function saveCookie(cookieName: string, data: string, options?: {
791
+ maxAge?: number;
792
+ path?: string;
793
+ reduceDomain?: boolean;
794
+ sameSite?: 'Strict' | 'Lax' | 'None';
795
+ }): void;
796
+ /**
797
+ * Remove a cookie by name
798
+ *
799
+ * @param cookieName - The name of the cookie to remove
800
+ * @param options - Cookie options (path, domain, sameSite)
801
+ *
802
+ * @example
803
+ * removeCookie('session_id')
804
+ */
805
+ declare function removeCookie(cookieName: string, options?: {
806
+ path?: string;
807
+ reduceDomain?: boolean;
808
+ sameSite?: 'Strict' | 'Lax' | 'None';
809
+ }): void;
810
+ /**
811
+ * Reduces the domain to main domain name
812
+ * Examples:
813
+ * - www.mywebpage.es -> .mywebpage.es
814
+ * - www.my.newwebpage.net -> .newwebpage.net
815
+ * - www.mywebpage.co.uk -> .mywebpage.co.uk
816
+ *
817
+ * @param domain - The domain to reduce (defaults to current hostname)
818
+ * @returns Dot + main domain
819
+ */
820
+ declare const toCookieDomain: (domain?: string) => string;
821
+
822
+ /**
823
+ * Email hashing utilities
824
+ */
825
+ /**
826
+ * Normalize email by lowering case and extracting + and . symbols for gmail
827
+ *
828
+ * @param email - Email to normalize
829
+ * @returns Normalized email. If not valid, returns an empty string
830
+ *
831
+ * @example
832
+ * normalizeEmail('User.Name+tag@Gmail.com')
833
+ * // Returns: 'username@gmail.com'
834
+ */
835
+ declare function normalizeEmail(email: string): string;
836
+ /**
837
+ * Create a Universal ID from an email using SHA256 hashing
838
+ *
839
+ * @param email - Email to hash
840
+ * @returns SHA256 hash of normalized email, or empty string if invalid
841
+ *
842
+ * @example
843
+ * createUniversalId('user@example.com')
844
+ * // Returns: 'b4c9a289323b21a01c3e940f150eb9b8c542587f1abfd8f0e1cc1ffc5e475514'
845
+ */
846
+ declare function createUniversalId(email: string): string;
847
+ /**
848
+ * Hash an email using MD5
849
+ *
850
+ * @param email - Email to hash
851
+ * @returns MD5 hash of normalized email, or empty string if invalid
852
+ *
853
+ * @example
854
+ * hashEmail('user@example.com')
855
+ * // Returns: '5f4dcc3b5aa765d61d8327deb882cf99'
856
+ */
857
+ declare function hashEmail(email: string): string;
858
+
859
+ /**
860
+ * Storage utilities for localStorage and sessionStorage
861
+ */
862
+
863
+ type StorageMethod = 'getItem' | 'setItem' | 'removeItem';
864
+ interface StorageParams {
865
+ /** Storage type to use */
866
+ type?: StorageType;
867
+ /** Method to call on the storage */
868
+ method?: StorageMethod;
869
+ /** Key to store/retrieve */
870
+ key: string;
871
+ /** Value to store (only for setItem) */
872
+ value?: string;
873
+ }
874
+ /**
875
+ * Use this function to store and retrieve data from localStorage or sessionStorage
876
+ *
877
+ * @param params - Storage parameters
878
+ * @returns The value from getItem, or void for setItem/removeItem
879
+ *
880
+ * @example
881
+ * // Get item
882
+ * const value = storage({ key: 'user_id' })
883
+ *
884
+ * @example
885
+ * // Set item
886
+ * storage({ key: 'user_id', value: '12345', method: 'setItem' })
887
+ *
888
+ * @example
889
+ * // Remove item
890
+ * storage({ key: 'user_id', method: 'removeItem' })
891
+ *
892
+ * @example
893
+ * // Use sessionStorage
894
+ * const value = storage({ type: 'sessionStorage', key: 'temp_data' })
895
+ */
896
+ declare const storage: ({ type, method, key, value }: StorageParams) => string | null | void;
897
+ /**
898
+ * Get an item from storage
899
+ */
900
+ declare const getStorageItem: (key: string, type?: StorageType) => string | null;
901
+ /**
902
+ * Set an item in storage
903
+ */
904
+ declare const setStorageItem: (key: string, value: string, type?: StorageType) => void;
905
+ /**
906
+ * Remove an item from storage
907
+ */
908
+ declare const removeStorageItem: (key: string, type?: StorageType) => void;
909
+
910
+ /**
911
+ * @adv-re/segment-wrapper
912
+ *
913
+ * Modern TypeScript abstraction layer on top of the Segment Analytics library.
914
+ */
915
+
916
+ export { type AdobeConfig, type AdobeRepository, type AdobeVisitor, type AdobeVisitorData$1 as AdobeVisitorData, type AnalyticsCallback, type GdprPrivacyValue as AnalyticsGdprPrivacyValue, type AnalyticsOptions, type AnonymousIdCheckResult, type BorosTcfCookie, CONSENT_STATES, type CampaignDetails, type ConfigGetter, type ConfigKey, type ConfigSetter, type ConsentCommand, type ConsentStateValue, type ConsentValue, type ContextEnhancer, type ContextObject, type CookieOptions, type DataLayer, type DefaultContextProperties, type DestinationMiddlewareFunction, type DestinationMiddlewareParams, EVENTS, type ExternalId, type GDPRPrivacyValue, type GDPRState, type GetCampaignDetailsOptions, type GetXandrIdOptions, type GoogleAnalyticsFields, type GoogleConsents, type GoogleRepository, type GtagFunction, type HashAlgorithm, type HashedEmail, type IntegrationsObject, type MPIConfig, type MiddlewarePayload, type NeededPurposes, type PageContext, type PageData, type STCParams, type ScreenInfo, type SegmentAnalytics, type SegmentUser, type SegmentWrapperConfig, type SourceMiddlewareFunction, type SourceMiddlewareParams, type Storage, type StorageType, type TCData, type TCFApi, type TCFApiVersion, type TCFCallback, type TCFCommand, TCFEvents, type UniversalIdData, type UniversalIdEvent, type UniversalIdEventDetail, type UniversalIdListener, UserGDPR, type UserTraits, type WindowWithMPI, type WindowWithSegmentWrapper, type XandrId, type XandrRepository, checkAnonymousId, clearConfig, createUniversalId, _default as default, getAdobeMCVisitorID, getAdobeVisitorData, getConfig, getStorageItem, getUniversalId, hashEmail, initConfig, isClient, normalizeEmail, readCookie, removeCookie, removeStorageItem, saveCookie, setConfig, setStorageItem, storage, toCookieDomain };