@adv-re/segment-wrapper 4.36.2 โ 5.0.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.
- package/README.md +50 -45
- package/dist/index.d.mts +17 -92
- package/dist/index.d.ts +17 -92
- package/dist/index.js +177 -307
- package/dist/index.mjs +174 -305
- package/package.json +2 -2
- package/umd/index.js +1 -1
package/README.md
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
# @adv-re/segment-wrapper
|
|
2
2
|
|
|
3
|
-
Modern TypeScript abstraction layer on top of the Segment Analytics library with built-in support for
|
|
3
|
+
Modern TypeScript abstraction layer on top of the Segment Analytics library with built-in support for Segment integrations, Adobe Analytics, TCF compliance, and consent management.
|
|
4
4
|
|
|
5
5
|
## Features
|
|
6
6
|
|
|
7
7
|
- โจ **TypeScript Support** - Full type safety and IntelliSense
|
|
8
8
|
- ๐ **TCF/GDPR Compliance** - Built-in Transparency & Consent Framework support
|
|
9
|
-
- ๐ **Google Analytics 4** - Native GA4 integration with consent mode
|
|
10
9
|
- ๐ฏ **Adobe Analytics** - Adobe Visitor API integration
|
|
11
10
|
- ๐ **Middleware System** - Extensible source and destination middlewares
|
|
11
|
+
- ๐ **Campaign Tracking** - UTM and STC parameter parsing and forwarding
|
|
12
12
|
- ๐ **Universal ID** - User identification across domains
|
|
13
13
|
- ๐ฆ **Multiple Formats** - ESM, CommonJS, and UMD builds
|
|
14
|
-
- ๐งช **Well Tested** -
|
|
14
|
+
- ๐งช **Well Tested** - Comprehensive test coverage
|
|
15
15
|
|
|
16
16
|
## Installation
|
|
17
17
|
|
|
@@ -27,11 +27,14 @@ npm install @adv-re/segment-wrapper
|
|
|
27
27
|
import analytics from '@adv-re/segment-wrapper'
|
|
28
28
|
import {initConfig} from '@adv-re/segment-wrapper'
|
|
29
29
|
|
|
30
|
-
// Initialize configuration
|
|
30
|
+
// Initialize configuration (optional - for custom settings)
|
|
31
31
|
initConfig({
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
32
|
+
userIdPrefix: 'fc-',
|
|
33
|
+
adobeMarketingCloudOrgId: 'YOUR_ORG_ID@AdobeOrg',
|
|
34
|
+
sendXandrId: true,
|
|
35
|
+
defaultProperties: {
|
|
36
|
+
platform: 'web'
|
|
37
|
+
}
|
|
35
38
|
})
|
|
36
39
|
|
|
37
40
|
// Track events
|
|
@@ -71,7 +74,7 @@ await analytics.identify('user-123', {
|
|
|
71
74
|
|
|
72
75
|
```html
|
|
73
76
|
<!-- Specific version (recommended for production) -->
|
|
74
|
-
<script async src="https://unpkg.com/@adv-re/segment-wrapper@
|
|
77
|
+
<script async src="https://unpkg.com/@adv-re/segment-wrapper@5.0.0"></script>
|
|
75
78
|
|
|
76
79
|
<!-- Latest version (use only for development) -->
|
|
77
80
|
<script async src="https://unpkg.com/@adv-re/segment-wrapper"></script>
|
|
@@ -83,35 +86,23 @@ await analytics.identify('user-123', {
|
|
|
83
86
|
import {initConfig} from '@adv-re/segment-wrapper'
|
|
84
87
|
|
|
85
88
|
initConfig({
|
|
86
|
-
//
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
// Google Analytics 4
|
|
90
|
-
googleAnalyticsMeasurementId: 'G-XXXXXXXXXX',
|
|
91
|
-
googleAnalyticsConsentManagement: true,
|
|
92
|
-
googleAnalyticsConfig: {
|
|
93
|
-
// Custom GA4 config
|
|
94
|
-
},
|
|
89
|
+
// User ID Configuration
|
|
90
|
+
userIdPrefix: 'fc-',
|
|
95
91
|
|
|
96
92
|
// Adobe Analytics
|
|
97
|
-
|
|
93
|
+
adobeMarketingCloudOrgId: 'YOUR_ORG_ID@AdobeOrg',
|
|
98
94
|
|
|
99
|
-
//
|
|
100
|
-
|
|
95
|
+
// Xandr ID
|
|
96
|
+
sendXandrId: true,
|
|
101
97
|
|
|
102
|
-
//
|
|
103
|
-
universalId: 'user-universal-id',
|
|
104
|
-
userEmail: 'user@example.com',
|
|
105
|
-
|
|
106
|
-
// Middlewares
|
|
107
|
-
experimentalPageDataMiddleware: false,
|
|
108
|
-
|
|
109
|
-
// Other
|
|
98
|
+
// Default Properties (added to all track calls)
|
|
110
99
|
defaultProperties: {
|
|
111
100
|
platform: 'web',
|
|
112
101
|
app: 'my-app'
|
|
113
102
|
},
|
|
114
|
-
|
|
103
|
+
|
|
104
|
+
// Middlewares
|
|
105
|
+
experimentalPageDataMiddleware: false
|
|
115
106
|
})
|
|
116
107
|
```
|
|
117
108
|
|
|
@@ -134,6 +125,7 @@ See [Configuration Guide](./docs/configuration.md) for all available options.
|
|
|
134
125
|
- `getUniversalId()` - Get current Universal ID
|
|
135
126
|
- `getAdobeMCVisitorID()` - Get Adobe Marketing Cloud Visitor ID
|
|
136
127
|
- `getAdobeVisitorData()` - Get Adobe Visitor API data
|
|
128
|
+
- `getCampaignDetails()` - Get UTM/STC campaign parameters from URL
|
|
137
129
|
|
|
138
130
|
See [API Reference](./docs/api-reference.md) for detailed documentation.
|
|
139
131
|
|
|
@@ -174,29 +166,41 @@ Events are automatically blocked or modified based on user consent.
|
|
|
174
166
|
|
|
175
167
|
See [TCF Documentation](./docs/tcf-compliance.md) for more details.
|
|
176
168
|
|
|
177
|
-
###
|
|
169
|
+
### Campaign Tracking
|
|
178
170
|
|
|
179
|
-
|
|
171
|
+
Automatic UTM and STC campaign parameter parsing:
|
|
180
172
|
|
|
181
173
|
```typescript
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
174
|
+
import {getCampaignDetails} from '@adv-re/segment-wrapper'
|
|
175
|
+
|
|
176
|
+
// Get campaign details from URL
|
|
177
|
+
const campaign = getCampaignDetails()
|
|
178
|
+
// Returns: { utm_source: 'google', utm_medium: 'cpc', ... }
|
|
179
|
+
|
|
180
|
+
// Campaign parameters are automatically added to all events
|
|
181
|
+
// via the campaignContext middleware
|
|
190
182
|
```
|
|
191
183
|
|
|
192
184
|
Features:
|
|
193
185
|
|
|
194
|
-
-
|
|
195
|
-
-
|
|
196
|
-
-
|
|
197
|
-
|
|
186
|
+
- UTM parameter parsing (utm_source, utm_medium, utm_campaign, etc.)
|
|
187
|
+
- STC format support (custom Adevinta format: ?stc=medium-source-campaign)
|
|
188
|
+
- Automatic forwarding to Segment (and downstream destinations like GA4)
|
|
189
|
+
|
|
190
|
+
## Migration Guides
|
|
191
|
+
|
|
192
|
+
### Migrating from v4 to v5
|
|
193
|
+
|
|
194
|
+
See [Upgrade to v5 Guide](./docs/upgrade-to-v5.md) for step-by-step instructions on upgrading to version 5.
|
|
195
|
+
|
|
196
|
+
**Key changes in v5:**
|
|
197
|
+
|
|
198
|
+
- GA4 now managed by Segment Device Mode (no more direct gtag.js initialization)
|
|
199
|
+
- Removed `googleAnalyticsMeasurementId`, `googleAnalyticsConfig`, etc. configuration options
|
|
200
|
+
- Consent Mode sent as event properties instead of direct gtag calls
|
|
201
|
+
- Campaign tracking still supported (UTM/STC parameters)
|
|
198
202
|
|
|
199
|
-
|
|
203
|
+
### Migrating from @s-ui/segment-wrapper
|
|
200
204
|
|
|
201
205
|
See [Migration Guide](./docs/migration-guide.md) for step-by-step instructions on migrating from the legacy `@s-ui/segment-wrapper` package.
|
|
202
206
|
|
|
@@ -245,7 +249,8 @@ npm run lint
|
|
|
245
249
|
- [API Reference](./docs/api-reference.md)
|
|
246
250
|
- [Middleware System](./docs/middlewares.md)
|
|
247
251
|
- [TCF Compliance](./docs/tcf-compliance.md)
|
|
248
|
-
- [
|
|
252
|
+
- [Upgrade to v5 Guide](./docs/upgrade-to-v5.md)
|
|
253
|
+
- [Migration from @s-ui/segment-wrapper](./docs/migration-guide.md)
|
|
249
254
|
- [Examples](./docs/examples.md)
|
|
250
255
|
|
|
251
256
|
## License
|
package/dist/index.d.mts
CHANGED
|
@@ -59,10 +59,7 @@ interface IntegrationsObject {
|
|
|
59
59
|
'Adobe Analytics'?: boolean | {
|
|
60
60
|
marketingCloudVisitorId?: string;
|
|
61
61
|
};
|
|
62
|
-
'Google Analytics 4'?: boolean
|
|
63
|
-
clientId?: string;
|
|
64
|
-
sessionId?: string;
|
|
65
|
-
};
|
|
62
|
+
'Google Analytics 4'?: boolean;
|
|
66
63
|
Personas?: boolean;
|
|
67
64
|
Webhooks?: boolean;
|
|
68
65
|
Webhook?: boolean;
|
|
@@ -133,19 +130,6 @@ type DestinationMiddlewareFunction = (payload: {
|
|
|
133
130
|
next: (payload: MiddlewarePayload | null) => void;
|
|
134
131
|
integration: string;
|
|
135
132
|
}) => 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
133
|
/**
|
|
150
134
|
* GDPR Privacy values
|
|
151
135
|
* Contains the user's consent state for analytics and advertising tracking
|
|
@@ -238,22 +222,6 @@ type ContextEnhancer = (context: ContextObject) => ContextObject | Promise<Conte
|
|
|
238
222
|
* Segment Wrapper configuration object
|
|
239
223
|
*/
|
|
240
224
|
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
225
|
/**
|
|
258
226
|
* User ID prefix to prepend to all user identifications
|
|
259
227
|
*/
|
|
@@ -291,8 +259,6 @@ interface MPIConfig {
|
|
|
291
259
|
*/
|
|
292
260
|
interface WindowWithMPI extends Window {
|
|
293
261
|
__mpi?: MPIConfig;
|
|
294
|
-
gtag?: (...args: unknown[]) => void;
|
|
295
|
-
dataLayer?: unknown[];
|
|
296
262
|
google_tag_manager?: unknown;
|
|
297
263
|
__tcfapi?: (...args: unknown[]) => void;
|
|
298
264
|
}
|
|
@@ -315,7 +281,6 @@ type ConfigSetter = <K extends ConfigKey>(key: K, value: SegmentWrapperConfig[K]
|
|
|
315
281
|
/**
|
|
316
282
|
* Repository interfaces for external integrations
|
|
317
283
|
*/
|
|
318
|
-
|
|
319
284
|
/**
|
|
320
285
|
* Adobe Visitor API interface
|
|
321
286
|
*/
|
|
@@ -340,29 +305,6 @@ interface AdobeVisitorData$1 {
|
|
|
340
305
|
trackingServer?: string;
|
|
341
306
|
version?: string;
|
|
342
307
|
}
|
|
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
308
|
/**
|
|
367
309
|
* Xandr ID value
|
|
368
310
|
*/
|
|
@@ -390,19 +332,6 @@ interface STCParams {
|
|
|
390
332
|
term?: string | null;
|
|
391
333
|
id?: string | null;
|
|
392
334
|
}
|
|
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
335
|
/**
|
|
407
336
|
* Adobe repository interface
|
|
408
337
|
*/
|
|
@@ -638,7 +567,7 @@ declare const isClient: boolean;
|
|
|
638
567
|
*
|
|
639
568
|
* @example
|
|
640
569
|
* // Get specific value
|
|
641
|
-
* const
|
|
570
|
+
* const userIdPrefix = getConfig('userIdPrefix')
|
|
642
571
|
*/
|
|
643
572
|
declare function getConfig(): SegmentWrapperConfig;
|
|
644
573
|
declare function getConfig<K extends ConfigKey>(key: K): SegmentWrapperConfig[K];
|
|
@@ -649,7 +578,7 @@ declare function getConfig<K extends ConfigKey>(key: K): SegmentWrapperConfig[K]
|
|
|
649
578
|
* @param value - Value to set on the config key
|
|
650
579
|
*
|
|
651
580
|
* @example
|
|
652
|
-
* setConfig('
|
|
581
|
+
* setConfig('userIdPrefix', 'fc-')
|
|
653
582
|
*/
|
|
654
583
|
declare const setConfig: <K extends ConfigKey>(key: K, value: SegmentWrapperConfig[K]) => void;
|
|
655
584
|
/**
|
|
@@ -659,8 +588,9 @@ declare const setConfig: <K extends ConfigKey>(key: K, value: SegmentWrapperConf
|
|
|
659
588
|
*
|
|
660
589
|
* @example
|
|
661
590
|
* initConfig({
|
|
662
|
-
*
|
|
663
|
-
*
|
|
591
|
+
* userIdPrefix: 'fc-',
|
|
592
|
+
* adobeMarketingCloudOrgId: 'YOUR_ORG_ID@AdobeOrg',
|
|
593
|
+
* sendXandrId: true
|
|
664
594
|
* })
|
|
665
595
|
*/
|
|
666
596
|
declare const initConfig: (config: Partial<SegmentWrapperConfig>) => void;
|
|
@@ -730,23 +660,18 @@ declare const getUniversalId: () => string | undefined;
|
|
|
730
660
|
|
|
731
661
|
/**
|
|
732
662
|
* Google Analytics Repository
|
|
733
|
-
* Handles
|
|
663
|
+
* Handles campaign tracking (UTM/STC parameters)
|
|
734
664
|
*/
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
denied: "denied";
|
|
665
|
+
declare const trackingTagsTypes: {
|
|
666
|
+
readonly STC: "stc";
|
|
667
|
+
readonly UTM: "utm";
|
|
739
668
|
};
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
};
|
|
747
|
-
};
|
|
748
|
-
}
|
|
749
|
-
}
|
|
669
|
+
/**
|
|
670
|
+
* Get campaign details from URL parameters
|
|
671
|
+
*/
|
|
672
|
+
declare const getCampaignDetails: ({ needsTransformation }?: {
|
|
673
|
+
needsTransformation?: boolean;
|
|
674
|
+
}) => Record<string, unknown> | null;
|
|
750
675
|
|
|
751
676
|
/**
|
|
752
677
|
* Anonymous ID checking utility
|
|
@@ -913,4 +838,4 @@ declare const removeStorageItem: (key: string, type?: StorageType) => void;
|
|
|
913
838
|
* Modern TypeScript abstraction layer on top of the Segment Analytics library.
|
|
914
839
|
*/
|
|
915
840
|
|
|
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,
|
|
841
|
+
export { type AdobeConfig, type AdobeRepository, type AdobeVisitor, type AdobeVisitorData$1 as AdobeVisitorData, type AnalyticsCallback, type GdprPrivacyValue as AnalyticsGdprPrivacyValue, type AnalyticsOptions, type AnonymousIdCheckResult, type BorosTcfCookie, type CampaignDetails, type ConfigGetter, type ConfigKey, type ConfigSetter, type ContextEnhancer, type ContextObject, type CookieOptions, type DefaultContextProperties, type DestinationMiddlewareFunction, type DestinationMiddlewareParams, EVENTS, type ExternalId, type GDPRPrivacyValue, type GDPRState, type GetCampaignDetailsOptions, type GetXandrIdOptions, 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, getCampaignDetails, getConfig, getStorageItem, getUniversalId, hashEmail, initConfig, isClient, normalizeEmail, readCookie, removeCookie, removeStorageItem, saveCookie, setConfig, setStorageItem, storage, toCookieDomain, trackingTagsTypes };
|
package/dist/index.d.ts
CHANGED
|
@@ -59,10 +59,7 @@ interface IntegrationsObject {
|
|
|
59
59
|
'Adobe Analytics'?: boolean | {
|
|
60
60
|
marketingCloudVisitorId?: string;
|
|
61
61
|
};
|
|
62
|
-
'Google Analytics 4'?: boolean
|
|
63
|
-
clientId?: string;
|
|
64
|
-
sessionId?: string;
|
|
65
|
-
};
|
|
62
|
+
'Google Analytics 4'?: boolean;
|
|
66
63
|
Personas?: boolean;
|
|
67
64
|
Webhooks?: boolean;
|
|
68
65
|
Webhook?: boolean;
|
|
@@ -133,19 +130,6 @@ type DestinationMiddlewareFunction = (payload: {
|
|
|
133
130
|
next: (payload: MiddlewarePayload | null) => void;
|
|
134
131
|
integration: string;
|
|
135
132
|
}) => 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
133
|
/**
|
|
150
134
|
* GDPR Privacy values
|
|
151
135
|
* Contains the user's consent state for analytics and advertising tracking
|
|
@@ -238,22 +222,6 @@ type ContextEnhancer = (context: ContextObject) => ContextObject | Promise<Conte
|
|
|
238
222
|
* Segment Wrapper configuration object
|
|
239
223
|
*/
|
|
240
224
|
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
225
|
/**
|
|
258
226
|
* User ID prefix to prepend to all user identifications
|
|
259
227
|
*/
|
|
@@ -291,8 +259,6 @@ interface MPIConfig {
|
|
|
291
259
|
*/
|
|
292
260
|
interface WindowWithMPI extends Window {
|
|
293
261
|
__mpi?: MPIConfig;
|
|
294
|
-
gtag?: (...args: unknown[]) => void;
|
|
295
|
-
dataLayer?: unknown[];
|
|
296
262
|
google_tag_manager?: unknown;
|
|
297
263
|
__tcfapi?: (...args: unknown[]) => void;
|
|
298
264
|
}
|
|
@@ -315,7 +281,6 @@ type ConfigSetter = <K extends ConfigKey>(key: K, value: SegmentWrapperConfig[K]
|
|
|
315
281
|
/**
|
|
316
282
|
* Repository interfaces for external integrations
|
|
317
283
|
*/
|
|
318
|
-
|
|
319
284
|
/**
|
|
320
285
|
* Adobe Visitor API interface
|
|
321
286
|
*/
|
|
@@ -340,29 +305,6 @@ interface AdobeVisitorData$1 {
|
|
|
340
305
|
trackingServer?: string;
|
|
341
306
|
version?: string;
|
|
342
307
|
}
|
|
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
308
|
/**
|
|
367
309
|
* Xandr ID value
|
|
368
310
|
*/
|
|
@@ -390,19 +332,6 @@ interface STCParams {
|
|
|
390
332
|
term?: string | null;
|
|
391
333
|
id?: string | null;
|
|
392
334
|
}
|
|
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
335
|
/**
|
|
407
336
|
* Adobe repository interface
|
|
408
337
|
*/
|
|
@@ -638,7 +567,7 @@ declare const isClient: boolean;
|
|
|
638
567
|
*
|
|
639
568
|
* @example
|
|
640
569
|
* // Get specific value
|
|
641
|
-
* const
|
|
570
|
+
* const userIdPrefix = getConfig('userIdPrefix')
|
|
642
571
|
*/
|
|
643
572
|
declare function getConfig(): SegmentWrapperConfig;
|
|
644
573
|
declare function getConfig<K extends ConfigKey>(key: K): SegmentWrapperConfig[K];
|
|
@@ -649,7 +578,7 @@ declare function getConfig<K extends ConfigKey>(key: K): SegmentWrapperConfig[K]
|
|
|
649
578
|
* @param value - Value to set on the config key
|
|
650
579
|
*
|
|
651
580
|
* @example
|
|
652
|
-
* setConfig('
|
|
581
|
+
* setConfig('userIdPrefix', 'fc-')
|
|
653
582
|
*/
|
|
654
583
|
declare const setConfig: <K extends ConfigKey>(key: K, value: SegmentWrapperConfig[K]) => void;
|
|
655
584
|
/**
|
|
@@ -659,8 +588,9 @@ declare const setConfig: <K extends ConfigKey>(key: K, value: SegmentWrapperConf
|
|
|
659
588
|
*
|
|
660
589
|
* @example
|
|
661
590
|
* initConfig({
|
|
662
|
-
*
|
|
663
|
-
*
|
|
591
|
+
* userIdPrefix: 'fc-',
|
|
592
|
+
* adobeMarketingCloudOrgId: 'YOUR_ORG_ID@AdobeOrg',
|
|
593
|
+
* sendXandrId: true
|
|
664
594
|
* })
|
|
665
595
|
*/
|
|
666
596
|
declare const initConfig: (config: Partial<SegmentWrapperConfig>) => void;
|
|
@@ -730,23 +660,18 @@ declare const getUniversalId: () => string | undefined;
|
|
|
730
660
|
|
|
731
661
|
/**
|
|
732
662
|
* Google Analytics Repository
|
|
733
|
-
* Handles
|
|
663
|
+
* Handles campaign tracking (UTM/STC parameters)
|
|
734
664
|
*/
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
denied: "denied";
|
|
665
|
+
declare const trackingTagsTypes: {
|
|
666
|
+
readonly STC: "stc";
|
|
667
|
+
readonly UTM: "utm";
|
|
739
668
|
};
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
};
|
|
747
|
-
};
|
|
748
|
-
}
|
|
749
|
-
}
|
|
669
|
+
/**
|
|
670
|
+
* Get campaign details from URL parameters
|
|
671
|
+
*/
|
|
672
|
+
declare const getCampaignDetails: ({ needsTransformation }?: {
|
|
673
|
+
needsTransformation?: boolean;
|
|
674
|
+
}) => Record<string, unknown> | null;
|
|
750
675
|
|
|
751
676
|
/**
|
|
752
677
|
* Anonymous ID checking utility
|
|
@@ -913,4 +838,4 @@ declare const removeStorageItem: (key: string, type?: StorageType) => void;
|
|
|
913
838
|
* Modern TypeScript abstraction layer on top of the Segment Analytics library.
|
|
914
839
|
*/
|
|
915
840
|
|
|
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,
|
|
841
|
+
export { type AdobeConfig, type AdobeRepository, type AdobeVisitor, type AdobeVisitorData$1 as AdobeVisitorData, type AnalyticsCallback, type GdprPrivacyValue as AnalyticsGdprPrivacyValue, type AnalyticsOptions, type AnonymousIdCheckResult, type BorosTcfCookie, type CampaignDetails, type ConfigGetter, type ConfigKey, type ConfigSetter, type ContextEnhancer, type ContextObject, type CookieOptions, type DefaultContextProperties, type DestinationMiddlewareFunction, type DestinationMiddlewareParams, EVENTS, type ExternalId, type GDPRPrivacyValue, type GDPRState, type GetCampaignDetailsOptions, type GetXandrIdOptions, 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, getCampaignDetails, getConfig, getStorageItem, getUniversalId, hashEmail, initConfig, isClient, normalizeEmail, readCookie, removeCookie, removeStorageItem, saveCookie, setConfig, setStorageItem, storage, toCookieDomain, trackingTagsTypes };
|