@blotoutio/edgetag-sdk-js 0.51.1 → 0.52.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.
- package/index.cjs.js +545 -408
- package/index.d.ts +29 -6
- package/index.mjs +545 -408
- package/package.json +1 -1
package/index.mjs
CHANGED
|
@@ -13,11 +13,174 @@ var api = /*#__PURE__*/Object.freeze({
|
|
|
13
13
|
get user () { return user; }
|
|
14
14
|
});
|
|
15
15
|
|
|
16
|
-
const
|
|
17
|
-
const
|
|
18
|
-
|
|
16
|
+
const isBool = (v) => typeof v == 'boolean';
|
|
17
|
+
const isRecord = (v) => !!v && typeof v == 'object' && !Array.isArray(v);
|
|
18
|
+
/**
|
|
19
|
+
* This function validates user consent for a given provider and tag name.
|
|
20
|
+
* It should be used in conjunction with `UserConsent`, not `ProvidersConfig`.
|
|
21
|
+
*/
|
|
22
|
+
const hasUserConsent = (consent, provider, tagName) => {
|
|
23
|
+
if (!isRecord(consent)) {
|
|
24
|
+
return false;
|
|
25
|
+
}
|
|
26
|
+
let allowed = isBool(consent.all) ? consent.all : false;
|
|
27
|
+
if (provider in consent) {
|
|
28
|
+
const providerSpecific = consent[provider];
|
|
29
|
+
if (isBool(providerSpecific)) {
|
|
30
|
+
allowed = providerSpecific;
|
|
31
|
+
}
|
|
32
|
+
else if (isRecord(providerSpecific)) {
|
|
33
|
+
if ('all' in providerSpecific && isBool(providerSpecific.all)) {
|
|
34
|
+
allowed = providerSpecific.all;
|
|
35
|
+
}
|
|
36
|
+
if (tagName in providerSpecific && isBool(providerSpecific[tagName])) {
|
|
37
|
+
allowed = providerSpecific[tagName];
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return allowed;
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
* This function validates user consent for a given provider type, not based on tagName.
|
|
45
|
+
*/
|
|
46
|
+
const hasUserConsentForProvider = (consent, provider) => {
|
|
47
|
+
if (!isRecord(consent)) {
|
|
48
|
+
return false;
|
|
49
|
+
}
|
|
50
|
+
let allowed = isBool(consent.all) ? consent.all : false;
|
|
51
|
+
if (provider in consent) {
|
|
52
|
+
const providerSpecific = consent[provider];
|
|
53
|
+
if (isBool(providerSpecific)) {
|
|
54
|
+
allowed = providerSpecific;
|
|
55
|
+
}
|
|
56
|
+
else if (isRecord(providerSpecific)) {
|
|
57
|
+
return Object.keys(providerSpecific).some((instance) => providerSpecific[instance] === true);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
return allowed;
|
|
61
|
+
};
|
|
62
|
+
/**
|
|
63
|
+
* This function validates provider allowance for a given provider and tag name.
|
|
64
|
+
* It should not be used to validate `UserConsent`.
|
|
65
|
+
*/
|
|
66
|
+
const isProviderInstanceAllowed = (providersConfig, provider, tagName) => {
|
|
67
|
+
if (!isRecord(providersConfig)) {
|
|
68
|
+
return true;
|
|
69
|
+
}
|
|
70
|
+
if (provider in providersConfig) {
|
|
71
|
+
const providerSpecific = providersConfig[provider];
|
|
72
|
+
if (isBool(providerSpecific)) {
|
|
73
|
+
return providerSpecific;
|
|
74
|
+
}
|
|
75
|
+
if (isRecord(providerSpecific)) {
|
|
76
|
+
const tagKeys = Object.keys(providerSpecific).filter((k) => k != 'all');
|
|
77
|
+
if (tagName in providerSpecific && isBool(providerSpecific[tagName])) {
|
|
78
|
+
return providerSpecific[tagName];
|
|
79
|
+
}
|
|
80
|
+
return isBool(providerSpecific.all)
|
|
81
|
+
? providerSpecific.all
|
|
82
|
+
: tagKeys.length == 0;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
const providerKeys = Object.keys(providersConfig).filter((k) => k != 'all');
|
|
86
|
+
return isBool(providersConfig.all)
|
|
87
|
+
? providersConfig.all
|
|
88
|
+
: providerKeys.length == 0;
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
const upsert = (map, key, update, createDefault) => {
|
|
92
|
+
const currentValue = map.has(key)
|
|
93
|
+
? map.get(key)
|
|
94
|
+
: createDefault();
|
|
95
|
+
return map.set(key, update(currentValue));
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
const expand = (str) => str.split(',').flatMap((entry) => {
|
|
99
|
+
if (!entry.includes('-')) {
|
|
100
|
+
return entry;
|
|
101
|
+
}
|
|
102
|
+
const result = [];
|
|
103
|
+
const [start, end] = entry.split('-').map(Number);
|
|
104
|
+
for (let i = start; i <= end; i++) {
|
|
105
|
+
result.push(i.toString());
|
|
106
|
+
}
|
|
107
|
+
return result;
|
|
108
|
+
});
|
|
109
|
+
/**
|
|
110
|
+
* Exported from https://en.wikipedia.org/wiki/List_of_North_American_Numbering_Plan_area_codes
|
|
111
|
+
*
|
|
112
|
+
* In Dev Tools, select the `tbody` element containing the area codes and run the following code,
|
|
113
|
+
* replacing the emdash character with a simple endash:
|
|
114
|
+
*
|
|
115
|
+
* ```ts
|
|
116
|
+
* [...$0.querySelectorAll('td:first-child')]
|
|
117
|
+
* .filter(cell => cell.firstChild.nodeName != 'A')
|
|
118
|
+
* .map(cell => cell.textContent.trim()).join(',')
|
|
119
|
+
* ```
|
|
120
|
+
*/
|
|
121
|
+
new Set([
|
|
122
|
+
...expand('200,211,221,222,230,232,233,235,237-238,241,243,244,245,247,255,257,258-259,261,265,266,271,273,274,275,277,278,280,282,283,285-287,288,290-299'),
|
|
123
|
+
...expand('300,311,322,324,327,328,333,335,338,342,344,348-349,353,355,356,357-359,362,366,369,370-379,381,382,383-384,387,388,389,390-399'),
|
|
124
|
+
...expand('400,411,420,421-422,426-427,428,429,433,439,444,446,449,451-454,455,456,457,459,460,461-462,465,466,467,471,476,477,481-483,485-486,487,488,489,490-499'),
|
|
125
|
+
...expand('511,532,535,536,537,538,542-543,545-547,549-550,552-554,555,556,558,560,565,568,569,576,578,583,589,590-599'),
|
|
126
|
+
...expand('611,621,624,625,627,632,633,634-635,637-638,642-643,644,648,652-654,655,663,665,666,668,673-676,677,679,685,686,687,688,690-699'),
|
|
127
|
+
...expand('711,722,723,729,733,735-736,739,741,744,745-746,748,749-751,752,755,756,759,761,764,766,768,776,777,783,788,789,790-799'),
|
|
128
|
+
...expand('811,821,822,823-824,827,834,836,841-842,846,851,852-853,871,874-875,879,880-887,889,890-899'),
|
|
129
|
+
...expand('911,921,922,923,924,926,927,932,933,935,942,944,946,950,953,955,957-958,960-969,974,975,976,977,981-982,987,988,990-999'),
|
|
130
|
+
]);
|
|
131
|
+
|
|
132
|
+
// eslint-disable-next-line @nx/enforce-module-boundaries
|
|
133
|
+
let edgeTagSettings;
|
|
134
|
+
const initSettings = (destination, options) => {
|
|
135
|
+
if (!edgeTagSettings) {
|
|
136
|
+
edgeTagSettings = {};
|
|
137
|
+
}
|
|
138
|
+
edgeTagSettings[destination] = {
|
|
139
|
+
destination,
|
|
140
|
+
initialized: false,
|
|
141
|
+
stubs: [],
|
|
142
|
+
channels: new Map(),
|
|
143
|
+
...options,
|
|
144
|
+
};
|
|
145
|
+
};
|
|
146
|
+
const setSetting = (options, destination) => {
|
|
147
|
+
if (!edgeTagSettings) {
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
if (!destination) {
|
|
151
|
+
Object.keys(edgeTagSettings).forEach((key) => {
|
|
152
|
+
edgeTagSettings[key] = {
|
|
153
|
+
...edgeTagSettings[key],
|
|
154
|
+
...options,
|
|
155
|
+
};
|
|
156
|
+
});
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
edgeTagSettings[destination] = {
|
|
160
|
+
...edgeTagSettings[destination],
|
|
161
|
+
...options,
|
|
162
|
+
};
|
|
163
|
+
};
|
|
164
|
+
const getSetting = (destination, key) => {
|
|
165
|
+
var _a;
|
|
166
|
+
return (_a = edgeTagSettings === null || edgeTagSettings === void 0 ? void 0 : edgeTagSettings[destination]) === null || _a === void 0 ? void 0 : _a[key];
|
|
167
|
+
};
|
|
168
|
+
const getInstances = () => {
|
|
169
|
+
return Object.keys(edgeTagSettings || {});
|
|
170
|
+
};
|
|
171
|
+
const addChannel = (destination, pkg, tagName) => upsert(getSetting(destination, 'channels'), pkg, (names) => names.add(tagName), () => new Set());
|
|
172
|
+
const getProviderVariables = (destination, packageId) => {
|
|
173
|
+
const setting = getSetting(destination, 'packages');
|
|
174
|
+
if (!setting) {
|
|
175
|
+
return [];
|
|
176
|
+
}
|
|
177
|
+
return (setting
|
|
178
|
+
.filter((pkg) => pkg.package === packageId)
|
|
179
|
+
.map((pkg) => ({
|
|
180
|
+
tagName: pkg.tagName,
|
|
181
|
+
variableSet: pkg.variables || {},
|
|
182
|
+
})) || []);
|
|
19
183
|
};
|
|
20
|
-
const getConfig = () => _config;
|
|
21
184
|
|
|
22
185
|
const getUserAgent = () => {
|
|
23
186
|
try {
|
|
@@ -28,11 +191,11 @@ const getUserAgent = () => {
|
|
|
28
191
|
return '';
|
|
29
192
|
}
|
|
30
193
|
};
|
|
31
|
-
const getReferrer = () => {
|
|
194
|
+
const getReferrer = (destination) => {
|
|
32
195
|
let referrer = '';
|
|
33
196
|
try {
|
|
34
197
|
const referrerUrl = new URL(document.referrer);
|
|
35
|
-
const pageUrl = new URL(getPageUrl());
|
|
198
|
+
const pageUrl = new URL(getPageUrl(destination));
|
|
36
199
|
if (referrerUrl.host !== pageUrl.host) {
|
|
37
200
|
referrer = referrerUrl.href;
|
|
38
201
|
}
|
|
@@ -42,22 +205,22 @@ const getReferrer = () => {
|
|
|
42
205
|
return referrer;
|
|
43
206
|
}
|
|
44
207
|
};
|
|
45
|
-
const getPageUrl = () => {
|
|
208
|
+
const getPageUrl = (destination) => {
|
|
46
209
|
try {
|
|
47
210
|
// we need to leave this one in for existing Custom pixel customers
|
|
48
211
|
if (window.edgetagData && window.edgetagData['pageUrl']) {
|
|
49
212
|
return window.edgetagData['pageUrl'];
|
|
50
213
|
}
|
|
51
|
-
const
|
|
52
|
-
return pageUrl || window.location.href;
|
|
214
|
+
const config = getSetting(destination, 'config');
|
|
215
|
+
return (config === null || config === void 0 ? void 0 : config.pageUrl) || window.location.href;
|
|
53
216
|
}
|
|
54
217
|
catch {
|
|
55
218
|
return '';
|
|
56
219
|
}
|
|
57
220
|
};
|
|
58
|
-
const getSearch = () => {
|
|
221
|
+
const getSearch = (destination) => {
|
|
59
222
|
try {
|
|
60
|
-
return new URL(getPageUrl()).search;
|
|
223
|
+
return new URL(getPageUrl(destination)).search;
|
|
61
224
|
}
|
|
62
225
|
catch {
|
|
63
226
|
return '';
|
|
@@ -144,9 +307,9 @@ const error = (data) => {
|
|
|
144
307
|
console.error('[EdgeTag]', getMessage(data));
|
|
145
308
|
};
|
|
146
309
|
|
|
147
|
-
const initKey = `${keyPrefix}
|
|
148
|
-
const saveDataPerKey = (persistType, provider, value, key) => {
|
|
149
|
-
const storage = getData$1(persistType);
|
|
310
|
+
const initKey = `${keyPrefix}StoreMultiple`;
|
|
311
|
+
const saveDataPerKey = (destination, persistType, provider, value, key) => {
|
|
312
|
+
const storage = getData$1(destination, persistType);
|
|
150
313
|
if (!storage['data']) {
|
|
151
314
|
storage['data'] = {};
|
|
152
315
|
}
|
|
@@ -154,49 +317,54 @@ const saveDataPerKey = (persistType, provider, value, key) => {
|
|
|
154
317
|
storage['data'][provider] = {};
|
|
155
318
|
}
|
|
156
319
|
storage['data'][provider][key] = value;
|
|
157
|
-
saveData(persistType, storage);
|
|
320
|
+
saveData(destination, persistType, storage);
|
|
158
321
|
};
|
|
159
|
-
const
|
|
160
|
-
const
|
|
322
|
+
const saveKV = (destination, data) => {
|
|
323
|
+
const currentSession = getData$1(destination, 'session');
|
|
324
|
+
if (!currentSession['kv']) {
|
|
325
|
+
currentSession['kv'] = {};
|
|
326
|
+
}
|
|
327
|
+
currentSession['kv'] = {
|
|
328
|
+
...currentSession['kv'],
|
|
329
|
+
...data,
|
|
330
|
+
};
|
|
331
|
+
saveData(destination, 'session', currentSession);
|
|
332
|
+
};
|
|
333
|
+
const savePerKey = (destination, persistType, provider, value, key) => {
|
|
334
|
+
const storage = getData$1(destination, persistType);
|
|
161
335
|
if (!storage[provider]) {
|
|
162
336
|
storage[provider] = {};
|
|
163
337
|
}
|
|
164
338
|
storage[provider][key] = value;
|
|
165
|
-
saveData(persistType, storage);
|
|
339
|
+
saveData(destination, persistType, storage);
|
|
166
340
|
};
|
|
167
|
-
const getDataPerKey = (persistType, provider, key) => {
|
|
168
|
-
const storage = getData$1(persistType);
|
|
341
|
+
const getDataPerKey = (destination, persistType, provider, key) => {
|
|
342
|
+
const storage = getData$1(destination, persistType);
|
|
169
343
|
if (!storage[provider]) {
|
|
170
344
|
return undefined;
|
|
171
345
|
}
|
|
172
346
|
return storage[provider][key];
|
|
173
347
|
};
|
|
174
|
-
const saveData = (persistType, value, key = initKey) => {
|
|
348
|
+
const saveData = (destination, persistType, value, key = initKey) => {
|
|
175
349
|
if (persistType === 'session') {
|
|
176
|
-
|
|
350
|
+
const data = getSession(key);
|
|
351
|
+
data[destination] = value;
|
|
352
|
+
saveSession(data, key);
|
|
177
353
|
return;
|
|
178
354
|
}
|
|
179
|
-
|
|
355
|
+
const data = getLocal(key);
|
|
356
|
+
data[destination] = value;
|
|
357
|
+
saveLocal(data, key);
|
|
180
358
|
};
|
|
181
|
-
const getData$1 = (persistType, key = initKey) => {
|
|
359
|
+
const getData$1 = (destination, persistType, key = initKey) => {
|
|
360
|
+
let data;
|
|
182
361
|
if (persistType === 'session') {
|
|
183
|
-
|
|
362
|
+
data = getSession(key);
|
|
184
363
|
}
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
const saveKV = (data) => {
|
|
188
|
-
let currentSession = getData$1('session');
|
|
189
|
-
if (!currentSession) {
|
|
190
|
-
currentSession = {};
|
|
191
|
-
}
|
|
192
|
-
if (!currentSession['kv']) {
|
|
193
|
-
currentSession['kv'] = {};
|
|
364
|
+
else {
|
|
365
|
+
data = getLocal(key);
|
|
194
366
|
}
|
|
195
|
-
|
|
196
|
-
...currentSession['kv'],
|
|
197
|
-
...data,
|
|
198
|
-
};
|
|
199
|
-
saveData('session', currentSession);
|
|
367
|
+
return (data === null || data === void 0 ? void 0 : data[destination]) || {};
|
|
200
368
|
};
|
|
201
369
|
const saveLocal = (value, key) => {
|
|
202
370
|
try {
|
|
@@ -319,17 +487,23 @@ const getCookieValue = (key) => {
|
|
|
319
487
|
}
|
|
320
488
|
};
|
|
321
489
|
|
|
322
|
-
|
|
323
|
-
const
|
|
324
|
-
if (
|
|
325
|
-
return
|
|
490
|
+
const getUserId$1 = (destination) => {
|
|
491
|
+
const userId = getSetting(destination, 'userId');
|
|
492
|
+
if (userId) {
|
|
493
|
+
return userId;
|
|
326
494
|
}
|
|
327
|
-
// leaving this for backward compatibility as worker was maybe not updated yet
|
|
328
|
-
// reference https://github.com/blotoutio/solutions/issues/1960
|
|
329
495
|
return getCookieValue(cookieKey);
|
|
330
496
|
};
|
|
331
|
-
const
|
|
332
|
-
|
|
497
|
+
const handleGetUserId = (options) => {
|
|
498
|
+
if (options === null || options === void 0 ? void 0 : options.destination) {
|
|
499
|
+
return getUserId$1(options.destination);
|
|
500
|
+
}
|
|
501
|
+
const instances = getInstances();
|
|
502
|
+
if (instances.length > 1) {
|
|
503
|
+
error('Multiple instances detected! Please provide a destination.');
|
|
504
|
+
return '';
|
|
505
|
+
}
|
|
506
|
+
return getUserId$1(instances[0]);
|
|
333
507
|
};
|
|
334
508
|
|
|
335
509
|
const beacon = (url, payload) => {
|
|
@@ -344,12 +518,12 @@ const beacon = (url, payload) => {
|
|
|
344
518
|
return Promise.reject(new Error('Beacon not supported.'));
|
|
345
519
|
}
|
|
346
520
|
};
|
|
347
|
-
const ajax = (method, url, payload) => fetch(url, {
|
|
521
|
+
const ajax = (destination, method, url, payload) => fetch(url, {
|
|
348
522
|
method,
|
|
349
523
|
headers: {
|
|
350
524
|
'Content-type': 'application/json; charset=utf-8',
|
|
351
525
|
Accept: 'application/json; charset=utf-8',
|
|
352
|
-
EdgeTagUserId:
|
|
526
|
+
EdgeTagUserId: getUserId$1(destination),
|
|
353
527
|
},
|
|
354
528
|
body: JSON.stringify(payload),
|
|
355
529
|
credentials: 'include',
|
|
@@ -363,26 +537,26 @@ const ajax = (method, url, payload) => fetch(url, {
|
|
|
363
537
|
}
|
|
364
538
|
return Promise.resolve(body);
|
|
365
539
|
});
|
|
366
|
-
const getStandardPayload = (payload) => {
|
|
540
|
+
const getStandardPayload = (destination, payload) => {
|
|
367
541
|
const data = {
|
|
368
|
-
pageUrl: getPageUrl(),
|
|
542
|
+
pageUrl: getPageUrl(destination),
|
|
369
543
|
pageTitle: getPageTitle(),
|
|
370
544
|
userAgent: getUserAgent(),
|
|
371
|
-
referrer: getReferrer(),
|
|
372
|
-
search: getSearch(),
|
|
545
|
+
referrer: getReferrer(destination),
|
|
546
|
+
search: getSearch(destination),
|
|
373
547
|
locale: getLocale(),
|
|
374
|
-
sdkVersion: "0.
|
|
548
|
+
sdkVersion: "0.52.1" ,
|
|
375
549
|
...(payload || {}),
|
|
376
550
|
};
|
|
377
551
|
let storage = {};
|
|
378
|
-
const session = getData$1('session');
|
|
552
|
+
const session = getData$1(destination, 'session');
|
|
379
553
|
if (session) {
|
|
380
554
|
storage = {
|
|
381
555
|
...storage,
|
|
382
556
|
...session,
|
|
383
557
|
};
|
|
384
558
|
}
|
|
385
|
-
const local = getData$1('local');
|
|
559
|
+
const local = getData$1(destination, 'local');
|
|
386
560
|
if (local) {
|
|
387
561
|
storage = {
|
|
388
562
|
...storage,
|
|
@@ -396,11 +570,13 @@ async function postRequest(url, data, options) {
|
|
|
396
570
|
if (!url) {
|
|
397
571
|
return Promise.reject(new Error('URL is empty.'));
|
|
398
572
|
}
|
|
399
|
-
const
|
|
573
|
+
const parsedUrl = new URL(url);
|
|
574
|
+
const destination = parsedUrl.origin;
|
|
575
|
+
const payload = getStandardPayload(destination, data);
|
|
400
576
|
if (options && options.method === 'beacon') {
|
|
401
577
|
return Promise.resolve(beacon(url, payload));
|
|
402
578
|
}
|
|
403
|
-
return await ajax('POST', url, payload);
|
|
579
|
+
return await ajax(destination, 'POST', url, payload);
|
|
404
580
|
}
|
|
405
581
|
async function getRequest(url, options) {
|
|
406
582
|
if (!url) {
|
|
@@ -411,170 +587,44 @@ async function getRequest(url, options) {
|
|
|
411
587
|
result: Promise.resolve(beacon(url)),
|
|
412
588
|
};
|
|
413
589
|
}
|
|
414
|
-
|
|
590
|
+
const parsedUrl = new URL(url);
|
|
591
|
+
const destination = parsedUrl.origin;
|
|
592
|
+
return await ajax(destination, 'GET', url);
|
|
415
593
|
}
|
|
416
594
|
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
const endpoint = getUrl();
|
|
420
|
-
if (!endpoint) {
|
|
595
|
+
const generateUrl = (destination, path) => {
|
|
596
|
+
if (!destination) {
|
|
421
597
|
log('URL is not valid');
|
|
422
598
|
return '';
|
|
423
599
|
}
|
|
424
|
-
return `${
|
|
600
|
+
return `${destination}${path}`;
|
|
425
601
|
};
|
|
426
|
-
const
|
|
427
|
-
|
|
428
|
-
};
|
|
429
|
-
const setUrl = (url) => {
|
|
430
|
-
if (url == null) {
|
|
431
|
-
return;
|
|
432
|
-
}
|
|
433
|
-
endpointUrl = url;
|
|
434
|
-
};
|
|
435
|
-
const getTagURL = (options) => {
|
|
436
|
-
const url = new URL(generateUrl('/tag'));
|
|
602
|
+
const getTagURL = (destination, options) => {
|
|
603
|
+
const parsedUrl = new URL(generateUrl(destination, '/tag'));
|
|
437
604
|
if (options === null || options === void 0 ? void 0 : options.sync) {
|
|
438
|
-
|
|
605
|
+
parsedUrl.searchParams.set('sync', 'true');
|
|
439
606
|
}
|
|
440
|
-
return
|
|
607
|
+
return parsedUrl.toString();
|
|
441
608
|
};
|
|
442
|
-
const getInitURL = () => {
|
|
443
|
-
return generateUrl('/init');
|
|
609
|
+
const getInitURL = (destination) => {
|
|
610
|
+
return generateUrl(destination, '/init');
|
|
444
611
|
};
|
|
445
|
-
const getConsentURL = () => {
|
|
446
|
-
return generateUrl('/consent');
|
|
612
|
+
const getConsentURL = (destination) => {
|
|
613
|
+
return generateUrl(destination, '/consent');
|
|
447
614
|
};
|
|
448
|
-
const getUserURL = () => {
|
|
449
|
-
return generateUrl('/user');
|
|
615
|
+
const getUserURL = (destination) => {
|
|
616
|
+
return generateUrl(destination, '/user');
|
|
450
617
|
};
|
|
451
|
-
const getDataURL = () => {
|
|
452
|
-
return generateUrl(`/data`);
|
|
618
|
+
const getDataURL = (destination) => {
|
|
619
|
+
return generateUrl(destination, `/data`);
|
|
453
620
|
};
|
|
454
|
-
const getGetDataURL = (keys) => {
|
|
455
|
-
return generateUrl(`/data?keys=${encodeURIComponent(keys.join(','))}`);
|
|
621
|
+
const getGetDataURL = (destination, keys) => {
|
|
622
|
+
return generateUrl(destination, `/data?keys=${encodeURIComponent(keys.join(','))}`);
|
|
456
623
|
};
|
|
457
|
-
const getKeysURL = () => {
|
|
458
|
-
return generateUrl(`/keys`);
|
|
624
|
+
const getKeysURL = (destination) => {
|
|
625
|
+
return generateUrl(destination, `/keys`);
|
|
459
626
|
};
|
|
460
627
|
|
|
461
|
-
const isBool = (v) => typeof v == 'boolean';
|
|
462
|
-
const isRecord = (v) => !!v && typeof v == 'object' && !Array.isArray(v);
|
|
463
|
-
/**
|
|
464
|
-
* This function validates user consent for a given provider and tag name.
|
|
465
|
-
* It should be used in conjunction with `UserConsent`, not `ProvidersConfig`.
|
|
466
|
-
*/
|
|
467
|
-
const hasUserConsent = (consent, provider, tagName) => {
|
|
468
|
-
if (!isRecord(consent)) {
|
|
469
|
-
return false;
|
|
470
|
-
}
|
|
471
|
-
let allowed = isBool(consent.all) ? consent.all : false;
|
|
472
|
-
if (provider in consent) {
|
|
473
|
-
const providerSpecific = consent[provider];
|
|
474
|
-
if (isBool(providerSpecific)) {
|
|
475
|
-
allowed = providerSpecific;
|
|
476
|
-
}
|
|
477
|
-
else if (isRecord(providerSpecific)) {
|
|
478
|
-
if ('all' in providerSpecific && isBool(providerSpecific.all)) {
|
|
479
|
-
allowed = providerSpecific.all;
|
|
480
|
-
}
|
|
481
|
-
if (tagName in providerSpecific && isBool(providerSpecific[tagName])) {
|
|
482
|
-
allowed = providerSpecific[tagName];
|
|
483
|
-
}
|
|
484
|
-
}
|
|
485
|
-
}
|
|
486
|
-
return allowed;
|
|
487
|
-
};
|
|
488
|
-
/**
|
|
489
|
-
* This function validates user consent for a given provider type, not based on tagName.
|
|
490
|
-
*/
|
|
491
|
-
const hasUserConsentForProvider = (consent, provider) => {
|
|
492
|
-
if (!isRecord(consent)) {
|
|
493
|
-
return false;
|
|
494
|
-
}
|
|
495
|
-
let allowed = isBool(consent.all) ? consent.all : false;
|
|
496
|
-
if (provider in consent) {
|
|
497
|
-
const providerSpecific = consent[provider];
|
|
498
|
-
if (isBool(providerSpecific)) {
|
|
499
|
-
allowed = providerSpecific;
|
|
500
|
-
}
|
|
501
|
-
else if (isRecord(providerSpecific)) {
|
|
502
|
-
return Object.keys(providerSpecific).some((instance) => providerSpecific[instance] === true);
|
|
503
|
-
}
|
|
504
|
-
}
|
|
505
|
-
return allowed;
|
|
506
|
-
};
|
|
507
|
-
/**
|
|
508
|
-
* This function validates provider allowance for a given provider and tag name.
|
|
509
|
-
* It should not be used to validate `UserConsent`.
|
|
510
|
-
*/
|
|
511
|
-
const isProviderInstanceAllowed = (providersConfig, provider, tagName) => {
|
|
512
|
-
if (!isRecord(providersConfig)) {
|
|
513
|
-
return true;
|
|
514
|
-
}
|
|
515
|
-
if (provider in providersConfig) {
|
|
516
|
-
const providerSpecific = providersConfig[provider];
|
|
517
|
-
if (isBool(providerSpecific)) {
|
|
518
|
-
return providerSpecific;
|
|
519
|
-
}
|
|
520
|
-
if (isRecord(providerSpecific)) {
|
|
521
|
-
const tagKeys = Object.keys(providerSpecific).filter((k) => k != 'all');
|
|
522
|
-
if (tagName in providerSpecific && isBool(providerSpecific[tagName])) {
|
|
523
|
-
return providerSpecific[tagName];
|
|
524
|
-
}
|
|
525
|
-
return isBool(providerSpecific.all)
|
|
526
|
-
? providerSpecific.all
|
|
527
|
-
: tagKeys.length == 0;
|
|
528
|
-
}
|
|
529
|
-
}
|
|
530
|
-
const providerKeys = Object.keys(providersConfig).filter((k) => k != 'all');
|
|
531
|
-
return isBool(providersConfig.all)
|
|
532
|
-
? providersConfig.all
|
|
533
|
-
: providerKeys.length == 0;
|
|
534
|
-
};
|
|
535
|
-
|
|
536
|
-
const upsert = (map, key, update, createDefault) => {
|
|
537
|
-
const currentValue = map.has(key)
|
|
538
|
-
? map.get(key)
|
|
539
|
-
: createDefault();
|
|
540
|
-
return map.set(key, update(currentValue));
|
|
541
|
-
};
|
|
542
|
-
|
|
543
|
-
const expand = (str) => str.split(',').flatMap((entry) => {
|
|
544
|
-
if (!entry.includes('-')) {
|
|
545
|
-
return entry;
|
|
546
|
-
}
|
|
547
|
-
const result = [];
|
|
548
|
-
const [start, end] = entry.split('-').map(Number);
|
|
549
|
-
for (let i = start; i <= end; i++) {
|
|
550
|
-
result.push(i.toString());
|
|
551
|
-
}
|
|
552
|
-
return result;
|
|
553
|
-
});
|
|
554
|
-
/**
|
|
555
|
-
* Exported from https://en.wikipedia.org/wiki/List_of_North_American_Numbering_Plan_area_codes
|
|
556
|
-
*
|
|
557
|
-
* In Dev Tools, select the `tbody` element containing the area codes and run the following code,
|
|
558
|
-
* replacing the emdash character with a simple endash:
|
|
559
|
-
*
|
|
560
|
-
* ```ts
|
|
561
|
-
* [...$0.querySelectorAll('td:first-child')]
|
|
562
|
-
* .filter(cell => cell.firstChild.nodeName != 'A')
|
|
563
|
-
* .map(cell => cell.textContent.trim()).join(',')
|
|
564
|
-
* ```
|
|
565
|
-
*/
|
|
566
|
-
new Set([
|
|
567
|
-
...expand('200,211,221,222,230,232,233,235,237-238,241,243,244,245,247,255,257,258-259,261,265,266,271,273,274,275,277,278,280,282,283,285-287,288,290-299'),
|
|
568
|
-
...expand('300,311,322,324,327,328,333,335,338,342,344,348-349,353,355,356,357-359,362,366,369,370-379,381,382,383-384,387,388,389,390-399'),
|
|
569
|
-
...expand('400,411,420,421-422,426-427,428,429,433,439,444,446,449,451-454,455,456,457,459,460,461-462,465,466,467,471,476,477,481-483,485-486,487,488,489,490-499'),
|
|
570
|
-
...expand('511,532,535,536,537,538,542-543,545-547,549-550,552-554,555,556,558,560,565,568,569,576,578,583,589,590-599'),
|
|
571
|
-
...expand('611,621,624,625,627,632,633,634-635,637-638,642-643,644,648,652-654,655,663,665,666,668,673-676,677,679,685,686,687,688,690-699'),
|
|
572
|
-
...expand('711,722,723,729,733,735-736,739,741,744,745-746,748,749-751,752,755,756,759,761,764,766,768,776,777,783,788,789,790-799'),
|
|
573
|
-
...expand('811,821,822,823-824,827,834,836,841-842,846,851,852-853,871,874-875,879,880-887,889,890-899'),
|
|
574
|
-
...expand('911,921,922,923,924,926,927,932,933,935,942,944,946,950,953,955,957-958,960-969,974,975,976,977,981-982,987,988,990-999'),
|
|
575
|
-
]);
|
|
576
|
-
|
|
577
|
-
let initialized = false;
|
|
578
628
|
const providersPackages = {};
|
|
579
629
|
const setPreferences = (preferences) => {
|
|
580
630
|
var _a;
|
|
@@ -585,7 +635,6 @@ const setPreferences = (preferences) => {
|
|
|
585
635
|
error('Please provide URL for EdgeTag');
|
|
586
636
|
return false;
|
|
587
637
|
}
|
|
588
|
-
!!preferences.disableConsentCheck;
|
|
589
638
|
(_a = preferences.providers) === null || _a === void 0 ? void 0 : _a.forEach((provider) => {
|
|
590
639
|
if (!provider.name) {
|
|
591
640
|
return;
|
|
@@ -605,52 +654,54 @@ const setPreferences = (preferences) => {
|
|
|
605
654
|
catch {
|
|
606
655
|
// do nothing
|
|
607
656
|
}
|
|
608
|
-
|
|
657
|
+
initSettings(preferences.edgeURL, {
|
|
658
|
+
disableConsent: !!preferences.disableConsentCheck,
|
|
659
|
+
});
|
|
609
660
|
return true;
|
|
610
661
|
};
|
|
611
|
-
const getProvidersPackage = () =>
|
|
612
|
-
const
|
|
613
|
-
const
|
|
614
|
-
|
|
662
|
+
const getProvidersPackage = (destination) => {
|
|
663
|
+
const packages = getSetting(destination, 'packages');
|
|
664
|
+
const providers = [];
|
|
665
|
+
packages === null || packages === void 0 ? void 0 : packages.forEach((pkg) => {
|
|
666
|
+
const provider = providersPackages[pkg.package];
|
|
667
|
+
if (!provider) {
|
|
668
|
+
return;
|
|
669
|
+
}
|
|
670
|
+
providers.push(provider);
|
|
671
|
+
});
|
|
672
|
+
return providers;
|
|
615
673
|
};
|
|
616
|
-
const configuredTags = new Map();
|
|
617
|
-
const addConfiguredTag = (pkg, tagName) => upsert(configuredTags, pkg, (names) => names.add(tagName), () => new Set());
|
|
618
|
-
const getConfiguredTags = () => configuredTags;
|
|
619
674
|
|
|
620
|
-
const
|
|
621
|
-
const
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
[tagName]: variables || {},
|
|
625
|
-
};
|
|
626
|
-
};
|
|
627
|
-
const getProviderVariables = (name) => {
|
|
628
|
-
if (!name) {
|
|
629
|
-
return {};
|
|
675
|
+
const getConsent$1 = (destination) => {
|
|
676
|
+
const storageConsent = getDataPerKey(destination, 'local', tagStorage, consentKey);
|
|
677
|
+
if (storageConsent) {
|
|
678
|
+
return storageConsent;
|
|
630
679
|
}
|
|
631
|
-
return
|
|
680
|
+
return getSetting(destination, 'consent');
|
|
632
681
|
};
|
|
633
682
|
|
|
634
|
-
|
|
635
|
-
const addStubs = (newStubs) => {
|
|
636
|
-
stubs = [...stubs, ...newStubs];
|
|
637
|
-
};
|
|
638
|
-
const addStub = (stub) => {
|
|
639
|
-
stubs.push(stub);
|
|
640
|
-
};
|
|
641
|
-
const processStubs = () => {
|
|
683
|
+
const processStubs = (destination) => {
|
|
642
684
|
try {
|
|
685
|
+
const stubs = getSetting(destination, 'stubs');
|
|
643
686
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
644
687
|
// @ts-ignore
|
|
645
688
|
stubs.forEach((stub) => api[stub.name](...(stub.arguments || [])));
|
|
646
|
-
|
|
689
|
+
setSetting({
|
|
690
|
+
stubs: [],
|
|
691
|
+
}, destination);
|
|
647
692
|
}
|
|
648
693
|
catch (e) {
|
|
649
694
|
error(e);
|
|
650
695
|
}
|
|
651
696
|
};
|
|
697
|
+
const addStub = (destination, stub) => {
|
|
698
|
+
const otherStubs = getSetting(destination, 'stubs') || [];
|
|
699
|
+
setSetting({
|
|
700
|
+
stubs: [...otherStubs, stub],
|
|
701
|
+
}, destination);
|
|
702
|
+
};
|
|
652
703
|
|
|
653
|
-
const sendTag = ({ eventName, eventId, data, providerData, providers, options
|
|
704
|
+
const sendTag = (destination, { eventName, eventId, data, providerData, providers, options }) => {
|
|
654
705
|
const payload = {
|
|
655
706
|
eventName,
|
|
656
707
|
eventId,
|
|
@@ -661,11 +712,11 @@ const sendTag = ({ eventName, eventId, data, providerData, providers, options, }
|
|
|
661
712
|
if (providers) {
|
|
662
713
|
payload.providers = providers;
|
|
663
714
|
}
|
|
664
|
-
postRequest(getTagURL(options), payload, options).catch(error);
|
|
715
|
+
postRequest(getTagURL(destination, options), payload, options).catch(error);
|
|
665
716
|
};
|
|
666
|
-
const
|
|
667
|
-
if (!
|
|
668
|
-
addStub({
|
|
717
|
+
const processTag = (destination, eventName, data = {}, providers, options) => {
|
|
718
|
+
if (!getSetting(destination, 'initialized')) {
|
|
719
|
+
addStub(destination, {
|
|
669
720
|
name: 'tag',
|
|
670
721
|
arguments: [eventName, data, providers, options],
|
|
671
722
|
});
|
|
@@ -675,12 +726,12 @@ const handleTag = (eventName, data = {}, providers, options) => {
|
|
|
675
726
|
if (!eventId) {
|
|
676
727
|
eventId = generateEventId(eventName);
|
|
677
728
|
}
|
|
678
|
-
const providerPackages = getProvidersPackage();
|
|
679
|
-
const configuredTags =
|
|
680
|
-
const userId =
|
|
729
|
+
const providerPackages = getProvidersPackage(destination);
|
|
730
|
+
const configuredTags = getSetting(destination, 'channels');
|
|
731
|
+
const userId = getUserId$1(destination);
|
|
681
732
|
const providerData = {};
|
|
682
|
-
const consent = getConsent$1();
|
|
683
|
-
for (const pkg of
|
|
733
|
+
const consent = getConsent$1(destination);
|
|
734
|
+
for (const pkg of providerPackages) {
|
|
684
735
|
if (!pkg || !pkg.name || !pkg.tag) {
|
|
685
736
|
continue;
|
|
686
737
|
}
|
|
@@ -688,26 +739,25 @@ const handleTag = (eventName, data = {}, providers, options) => {
|
|
|
688
739
|
log(`Provider ${pkg.name} is not in allow list`);
|
|
689
740
|
continue;
|
|
690
741
|
}
|
|
691
|
-
const variables = getProviderVariables(pkg.name);
|
|
742
|
+
const variables = getProviderVariables(destination, pkg.name);
|
|
692
743
|
const result = {};
|
|
693
|
-
const providerVariables = Object.entries(variables);
|
|
694
744
|
const executionContext = new Map();
|
|
695
|
-
for (const
|
|
696
|
-
if (!isProviderInstanceAllowed(providers, pkg.name, tagName)) {
|
|
697
|
-
log(`Provider instance is not allowed (${pkg.name}: ${tagName})`);
|
|
745
|
+
for (const variable of variables) {
|
|
746
|
+
if (!isProviderInstanceAllowed(providers, pkg.name, variable.tagName)) {
|
|
747
|
+
log(`Provider instance is not allowed (${pkg.name}: ${variable.tagName})`);
|
|
698
748
|
continue;
|
|
699
749
|
}
|
|
700
|
-
if (!hasUserConsent(consent, pkg.name, tagName)) {
|
|
701
|
-
log(`Consent is missing (${pkg.name}: ${tagName})`);
|
|
750
|
+
if (!hasUserConsent(consent, pkg.name, variable.tagName)) {
|
|
751
|
+
log(`Consent is missing (${pkg.name}: ${variable.tagName})`);
|
|
702
752
|
continue;
|
|
703
753
|
}
|
|
704
|
-
result[tagName] = pkg.tag({
|
|
754
|
+
result[variable.tagName] = pkg.tag({
|
|
705
755
|
userId,
|
|
706
756
|
eventName,
|
|
707
757
|
eventId,
|
|
708
758
|
data: JSON.parse(JSON.stringify(data)),
|
|
709
|
-
sendTag,
|
|
710
|
-
manifestVariables: variableSet,
|
|
759
|
+
sendTag: sendTag.bind(null, destination),
|
|
760
|
+
manifestVariables: variable.variableSet,
|
|
711
761
|
executionContext,
|
|
712
762
|
});
|
|
713
763
|
}
|
|
@@ -716,7 +766,7 @@ const handleTag = (eventName, data = {}, providers, options) => {
|
|
|
716
766
|
if (!hasAllowedManifestTags(configuredTags, consent, providers)) {
|
|
717
767
|
return;
|
|
718
768
|
}
|
|
719
|
-
sendTag({
|
|
769
|
+
sendTag(destination, {
|
|
720
770
|
eventName,
|
|
721
771
|
eventId,
|
|
722
772
|
data,
|
|
@@ -725,6 +775,15 @@ const handleTag = (eventName, data = {}, providers, options) => {
|
|
|
725
775
|
options,
|
|
726
776
|
});
|
|
727
777
|
};
|
|
778
|
+
const handleTag = (eventName, data = {}, providers, options) => {
|
|
779
|
+
if (options === null || options === void 0 ? void 0 : options.destination) {
|
|
780
|
+
processTag(options.destination, eventName, data, providers, options);
|
|
781
|
+
return;
|
|
782
|
+
}
|
|
783
|
+
getInstances().forEach((instance) => {
|
|
784
|
+
processTag(instance, eventName, data, providers, options);
|
|
785
|
+
});
|
|
786
|
+
};
|
|
728
787
|
const hasAllowedManifestTags = (tags, consent, providersConfig) => {
|
|
729
788
|
for (const [pkg, tagNames] of tags) {
|
|
730
789
|
for (const tagName of tagNames) {
|
|
@@ -737,29 +796,38 @@ const hasAllowedManifestTags = (tags, consent, providersConfig) => {
|
|
|
737
796
|
return false;
|
|
738
797
|
};
|
|
739
798
|
|
|
740
|
-
const
|
|
741
|
-
|
|
742
|
-
error('Provide keys for get data API.');
|
|
743
|
-
return;
|
|
744
|
-
}
|
|
745
|
-
getRequest(getGetDataURL(keys))
|
|
799
|
+
const processGetData = (destination, keys, callback) => {
|
|
800
|
+
getRequest(getGetDataURL(destination, keys))
|
|
746
801
|
.then((result) => {
|
|
747
802
|
callback((result === null || result === void 0 ? void 0 : result.result) || {});
|
|
748
803
|
})
|
|
749
804
|
.catch(error);
|
|
750
805
|
};
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
error('Provide data for data API.');
|
|
806
|
+
const handleGetData = (keys, callback, options) => {
|
|
807
|
+
if (!keys || keys.length === 0) {
|
|
808
|
+
error('Provide keys for get data API.');
|
|
755
809
|
return;
|
|
756
810
|
}
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
const
|
|
762
|
-
|
|
811
|
+
if (options === null || options === void 0 ? void 0 : options.destination) {
|
|
812
|
+
processGetData(options.destination, keys, callback);
|
|
813
|
+
return;
|
|
814
|
+
}
|
|
815
|
+
const instances = getInstances();
|
|
816
|
+
if (instances.length > 1) {
|
|
817
|
+
error('Multiple instances found! Please provide destination.');
|
|
818
|
+
callback({});
|
|
819
|
+
return;
|
|
820
|
+
}
|
|
821
|
+
processGetData(instances[0], keys, callback);
|
|
822
|
+
};
|
|
823
|
+
|
|
824
|
+
const processData = (destination, data, providers, options) => {
|
|
825
|
+
saveKV(destination, data);
|
|
826
|
+
const providerPackages = getProvidersPackage(destination);
|
|
827
|
+
const configuredTags = getSetting(destination, 'channels');
|
|
828
|
+
const userId = getUserId$1(destination);
|
|
829
|
+
const consent = getConsent$1(destination);
|
|
830
|
+
for (const pkg of providerPackages) {
|
|
763
831
|
if (!pkg || !pkg.user || !pkg.name) {
|
|
764
832
|
continue;
|
|
765
833
|
}
|
|
@@ -767,70 +835,92 @@ const handleData = (data, providers, options) => {
|
|
|
767
835
|
log(`Provider ${pkg.name} is not in allow list`);
|
|
768
836
|
continue;
|
|
769
837
|
}
|
|
770
|
-
const variables = getProviderVariables(pkg.name);
|
|
771
|
-
for (const
|
|
772
|
-
if (!isProviderInstanceAllowed(providers, pkg.name, tagName)) {
|
|
773
|
-
log(`Data not allowed for ${pkg.name} (${tagName})`);
|
|
838
|
+
const variables = getProviderVariables(destination, pkg.name);
|
|
839
|
+
for (const variable of variables) {
|
|
840
|
+
if (!isProviderInstanceAllowed(providers, pkg.name, variable.tagName)) {
|
|
841
|
+
log(`Data not allowed for ${pkg.name} (${variable.tagName})`);
|
|
774
842
|
continue;
|
|
775
843
|
}
|
|
776
|
-
if (!hasUserConsent(consent, pkg.name, tagName)) {
|
|
777
|
-
log(`Consent is missing for ${pkg.name} (${tagName})`);
|
|
844
|
+
if (!hasUserConsent(consent, pkg.name, variable.tagName)) {
|
|
845
|
+
log(`Consent is missing for ${pkg.name} (${variable.tagName})`);
|
|
778
846
|
continue;
|
|
779
847
|
}
|
|
780
848
|
pkg.user({
|
|
781
849
|
userId,
|
|
782
850
|
data,
|
|
783
|
-
manifestVariables: variableSet,
|
|
851
|
+
manifestVariables: variable.variableSet,
|
|
784
852
|
});
|
|
785
853
|
}
|
|
786
854
|
}
|
|
787
|
-
postRequest(getDataURL(), { data, providers }, options).catch(error);
|
|
855
|
+
postRequest(getDataURL(destination), { data, providers }, options).catch(error);
|
|
788
856
|
};
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
857
|
+
const handleData = (data, providers, options) => {
|
|
858
|
+
if (!data || Object.keys(data).length === 0) {
|
|
859
|
+
error('Provide data for data API.');
|
|
860
|
+
return;
|
|
861
|
+
}
|
|
862
|
+
if (options === null || options === void 0 ? void 0 : options.destination) {
|
|
863
|
+
processData(options.destination, data, providers, options);
|
|
864
|
+
return;
|
|
865
|
+
}
|
|
866
|
+
getInstances().forEach((destination) => {
|
|
867
|
+
processData(destination, data, providers, options);
|
|
868
|
+
});
|
|
794
869
|
};
|
|
870
|
+
|
|
795
871
|
const handleConsent = (consent, options) => {
|
|
796
|
-
|
|
872
|
+
if (options === null || options === void 0 ? void 0 : options.destination) {
|
|
873
|
+
processConsent(options.destination, consent, options === null || options === void 0 ? void 0 : options.localSave);
|
|
874
|
+
return;
|
|
875
|
+
}
|
|
876
|
+
getInstances().forEach((destination) => {
|
|
877
|
+
processConsent(destination, consent, options === null || options === void 0 ? void 0 : options.localSave);
|
|
878
|
+
});
|
|
879
|
+
};
|
|
880
|
+
const saveConsent = (destination, consent) => {
|
|
881
|
+
setSetting({
|
|
882
|
+
consent,
|
|
883
|
+
}, destination);
|
|
884
|
+
savePerKey(destination, 'local', tagStorage, consent, consentKey);
|
|
885
|
+
};
|
|
886
|
+
const processConsent = (destination, consent, localSave) => {
|
|
887
|
+
const existingConsent = getConsent$1(destination);
|
|
797
888
|
if (areEqual(existingConsent, consent)) {
|
|
798
889
|
return;
|
|
799
890
|
}
|
|
800
891
|
const payload = {
|
|
801
892
|
consentString: consent,
|
|
802
893
|
};
|
|
803
|
-
saveConsent(consent);
|
|
804
|
-
if (!
|
|
805
|
-
postRequest(getConsentURL(), payload).catch(error);
|
|
894
|
+
saveConsent(destination, consent);
|
|
895
|
+
if (!localSave) {
|
|
896
|
+
postRequest(getConsentURL(destination), payload).catch(error);
|
|
806
897
|
}
|
|
807
|
-
const userId =
|
|
808
|
-
const providerPackages = getProvidersPackage();
|
|
898
|
+
const userId = getUserId$1(destination);
|
|
899
|
+
const providerPackages = getProvidersPackage(destination);
|
|
809
900
|
const executionContext = new Map();
|
|
810
901
|
/* Calling Init for all provider instances based on consent check */
|
|
811
|
-
for (const pkg of
|
|
902
|
+
for (const pkg of providerPackages) {
|
|
812
903
|
if (!pkg || !pkg.name || !pkg.init) {
|
|
813
904
|
continue;
|
|
814
905
|
}
|
|
815
|
-
const variables = getProviderVariables(pkg.name);
|
|
816
|
-
const
|
|
817
|
-
|
|
818
|
-
const hasConsent = hasUserConsent(consent, pkg.name, tagName);
|
|
906
|
+
const variables = getProviderVariables(destination, pkg.name);
|
|
907
|
+
for (const variable of variables) {
|
|
908
|
+
const hasConsent = hasUserConsent(consent, pkg.name, variable.tagName);
|
|
819
909
|
if (!hasConsent) {
|
|
820
910
|
continue;
|
|
821
911
|
}
|
|
822
912
|
pkg.init({
|
|
823
913
|
userId,
|
|
824
914
|
isNewUser: false,
|
|
825
|
-
baseUrl:
|
|
915
|
+
baseUrl: destination,
|
|
826
916
|
manifest: {
|
|
827
|
-
tagName,
|
|
828
|
-
variables:
|
|
917
|
+
tagName: variable.tagName,
|
|
918
|
+
variables: variable.variableSet,
|
|
829
919
|
package: pkg.name,
|
|
830
920
|
},
|
|
831
|
-
sendTag,
|
|
832
|
-
sendEdgeData:
|
|
833
|
-
getEdgeData:
|
|
921
|
+
sendTag: sendTag.bind(null, destination),
|
|
922
|
+
sendEdgeData: processData.bind(null, destination),
|
|
923
|
+
getEdgeData: processGetData.bind(null, destination),
|
|
834
924
|
keyName: `${keyPrefix}Store`,
|
|
835
925
|
executionContext,
|
|
836
926
|
session: null,
|
|
@@ -840,6 +930,7 @@ const handleConsent = (consent, options) => {
|
|
|
840
930
|
try {
|
|
841
931
|
window.dispatchEvent(new CustomEvent('edgetag-consent', {
|
|
842
932
|
detail: {
|
|
933
|
+
destination,
|
|
843
934
|
oldConsent: existingConsent,
|
|
844
935
|
newConsent: consent,
|
|
845
936
|
},
|
|
@@ -858,20 +949,10 @@ const handleConsent = (consent, options) => {
|
|
|
858
949
|
pkg.consent({ hasConsent });
|
|
859
950
|
}
|
|
860
951
|
};
|
|
861
|
-
const setConsent = (newConsent) => {
|
|
862
|
-
memoryConsent = newConsent;
|
|
863
|
-
};
|
|
864
|
-
const getConsent$1 = () => {
|
|
865
|
-
const storageConsent = getDataPerKey('local', tagStorage, consentKey);
|
|
866
|
-
if (storageConsent) {
|
|
867
|
-
return storageConsent;
|
|
868
|
-
}
|
|
869
|
-
return memoryConsent;
|
|
870
|
-
};
|
|
871
952
|
|
|
872
953
|
const cacheKey = `${keyPrefix}Cache`;
|
|
873
954
|
const identity = (v) => v;
|
|
874
|
-
const saveDataToEdge = (key, value, provider) => {
|
|
955
|
+
const saveDataToEdge = (destination, key, value, provider) => {
|
|
875
956
|
if (!value) {
|
|
876
957
|
return;
|
|
877
958
|
}
|
|
@@ -885,9 +966,11 @@ const saveDataToEdge = (key, value, provider) => {
|
|
|
885
966
|
return;
|
|
886
967
|
}
|
|
887
968
|
}
|
|
888
|
-
handleData({ [`${provider}::${key}`]: updatedValue }
|
|
969
|
+
handleData({ [`${provider}::${key}`]: updatedValue }, undefined, {
|
|
970
|
+
destination,
|
|
971
|
+
});
|
|
889
972
|
};
|
|
890
|
-
const handleCaptureQuery = (provider, key, persistType, map) => {
|
|
973
|
+
const handleCaptureQuery = (destination, provider, key, persistType, map) => {
|
|
891
974
|
try {
|
|
892
975
|
if (!window) {
|
|
893
976
|
return;
|
|
@@ -896,7 +979,7 @@ const handleCaptureQuery = (provider, key, persistType, map) => {
|
|
|
896
979
|
catch {
|
|
897
980
|
return;
|
|
898
981
|
}
|
|
899
|
-
const params = new URLSearchParams(getSearch());
|
|
982
|
+
const params = new URLSearchParams(getSearch(destination));
|
|
900
983
|
if (!params || !params.get(key)) {
|
|
901
984
|
return;
|
|
902
985
|
}
|
|
@@ -905,27 +988,29 @@ const handleCaptureQuery = (provider, key, persistType, map) => {
|
|
|
905
988
|
return;
|
|
906
989
|
}
|
|
907
990
|
if (persistType === 'edge') {
|
|
908
|
-
saveDataToEdge(key, data, provider);
|
|
991
|
+
saveDataToEdge(destination, key, data, provider);
|
|
909
992
|
return;
|
|
910
993
|
}
|
|
911
|
-
saveDataPerKey(persistType, provider, data, key);
|
|
994
|
+
saveDataPerKey(destination, persistType, provider, data, key);
|
|
912
995
|
};
|
|
913
|
-
const getFromCache = (persistType, provider, key) => {
|
|
996
|
+
const getFromCache = (destination, persistType, provider, key) => {
|
|
914
997
|
var _a;
|
|
915
|
-
const
|
|
998
|
+
const type = persistType === 'edge' ? 'local' : persistType;
|
|
999
|
+
const cache = getData$1(destination, type, cacheKey);
|
|
916
1000
|
return (_a = cache[provider]) === null || _a === void 0 ? void 0 : _a[key];
|
|
917
1001
|
};
|
|
918
|
-
const saveToCache = (persistType, provider, key, value) => {
|
|
919
|
-
const
|
|
1002
|
+
const saveToCache = (destination, persistType, provider, key, value) => {
|
|
1003
|
+
const type = persistType === 'edge' ? 'local' : persistType;
|
|
1004
|
+
const cache = getData$1(destination, type, cacheKey);
|
|
920
1005
|
if (!cache[provider]) {
|
|
921
1006
|
cache[provider] = { [key]: value };
|
|
922
1007
|
}
|
|
923
1008
|
else {
|
|
924
1009
|
cache[provider][key] = value;
|
|
925
1010
|
}
|
|
926
|
-
saveData(
|
|
1011
|
+
saveData(destination, type, cache, cacheKey);
|
|
927
1012
|
};
|
|
928
|
-
const handleCaptureStorage = (provider, key, persistType, location, map) => {
|
|
1013
|
+
const handleCaptureStorage = (destination, provider, key, persistType, location, map) => {
|
|
929
1014
|
let data;
|
|
930
1015
|
try {
|
|
931
1016
|
switch (location) {
|
|
@@ -948,44 +1033,43 @@ const handleCaptureStorage = (provider, key, persistType, location, map) => {
|
|
|
948
1033
|
if (!data) {
|
|
949
1034
|
return;
|
|
950
1035
|
}
|
|
951
|
-
const cachedKey = `${
|
|
952
|
-
const cachedValue = getFromCache(persistType, provider, cachedKey);
|
|
1036
|
+
const cachedKey = `${getUserId$1(destination)}/${key}`;
|
|
1037
|
+
const cachedValue = getFromCache(destination, persistType, provider, cachedKey);
|
|
953
1038
|
if (persistType === 'edge' && cachedValue !== data) {
|
|
954
|
-
saveDataToEdge(key, data, provider);
|
|
955
|
-
saveToCache(persistType, provider, cachedKey, data);
|
|
1039
|
+
saveDataToEdge(destination, key, data, provider);
|
|
1040
|
+
saveToCache(destination, persistType, provider, cachedKey, data);
|
|
956
1041
|
return;
|
|
957
1042
|
}
|
|
958
|
-
saveDataPerKey(persistType, provider, data, key);
|
|
1043
|
+
saveDataPerKey(destination, persistType, provider, data, key);
|
|
959
1044
|
};
|
|
960
|
-
const handleCapture = (provider, params, capture) => {
|
|
1045
|
+
const handleCapture = (destination, provider, params, capture) => {
|
|
961
1046
|
params.forEach((param) => {
|
|
962
1047
|
switch (param.type) {
|
|
963
1048
|
case 'query': {
|
|
964
|
-
handleCaptureQuery(provider, param.key, param.persist, capture === null || capture === void 0 ? void 0 : capture.bind(null, param));
|
|
1049
|
+
handleCaptureQuery(destination, provider, param.key, param.persist, capture === null || capture === void 0 ? void 0 : capture.bind(null, param));
|
|
965
1050
|
break;
|
|
966
1051
|
}
|
|
967
1052
|
case 'storage': {
|
|
968
|
-
handleCaptureStorage(provider, param.key, param.persist, param.location, capture === null || capture === void 0 ? void 0 : capture.bind(null, param));
|
|
1053
|
+
handleCaptureStorage(destination, provider, param.key, param.persist, param.location, capture === null || capture === void 0 ? void 0 : capture.bind(null, param));
|
|
969
1054
|
break;
|
|
970
1055
|
}
|
|
971
1056
|
}
|
|
972
1057
|
});
|
|
973
1058
|
};
|
|
974
1059
|
|
|
975
|
-
const handleManifest = (
|
|
976
|
-
const providerPackages = getProvidersPackage();
|
|
977
|
-
const userId =
|
|
1060
|
+
const handleManifest = (destination, response) => {
|
|
1061
|
+
const providerPackages = getProvidersPackage(destination);
|
|
1062
|
+
const userId = getUserId$1(destination);
|
|
978
1063
|
const executionContext = new Map();
|
|
979
1064
|
const manifest = response.result;
|
|
980
1065
|
manifest.forEach((provider) => {
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
const pkg = providerPackages[provider.package];
|
|
1066
|
+
addChannel(destination, provider.package, provider.tagName);
|
|
1067
|
+
const pkg = providerPackages.find((pkg) => pkg.name === provider.package);
|
|
984
1068
|
if (provider.rules) {
|
|
985
1069
|
Object.entries(provider.rules).forEach(([name, recipe]) => {
|
|
986
1070
|
switch (name) {
|
|
987
1071
|
case 'capture': {
|
|
988
|
-
handleCapture(provider.package, recipe, pkg === null || pkg === void 0 ? void 0 : pkg.capture);
|
|
1072
|
+
handleCapture(destination, provider.package, recipe, pkg === null || pkg === void 0 ? void 0 : pkg.capture);
|
|
989
1073
|
return;
|
|
990
1074
|
}
|
|
991
1075
|
}
|
|
@@ -993,36 +1077,27 @@ const handleManifest = (response, consent) => {
|
|
|
993
1077
|
}
|
|
994
1078
|
if (pkg && pkg.name && pkg.init) {
|
|
995
1079
|
/* this defines if the consent is given for a specific instance of a provider */
|
|
996
|
-
const hasConsent = hasUserConsent(consent, pkg.name, provider.tagName);
|
|
1080
|
+
const hasConsent = hasUserConsent(getSetting(destination, 'consent'), pkg.name, provider.tagName);
|
|
997
1081
|
if (hasConsent) {
|
|
998
1082
|
pkg.init({
|
|
999
1083
|
userId,
|
|
1000
1084
|
isNewUser: !!response.isNewUser,
|
|
1001
1085
|
session: response.session,
|
|
1002
|
-
baseUrl:
|
|
1086
|
+
baseUrl: destination,
|
|
1003
1087
|
manifest: provider,
|
|
1004
|
-
sendTag,
|
|
1005
|
-
sendEdgeData:
|
|
1006
|
-
getEdgeData:
|
|
1088
|
+
sendTag: sendTag.bind(null, destination),
|
|
1089
|
+
sendEdgeData: processData.bind(null, destination),
|
|
1090
|
+
getEdgeData: processGetData.bind(null, destination),
|
|
1007
1091
|
keyName: `${keyPrefix}Store`,
|
|
1008
1092
|
executionContext,
|
|
1009
1093
|
});
|
|
1010
1094
|
}
|
|
1011
1095
|
}
|
|
1012
1096
|
});
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
};
|
|
1016
|
-
|
|
1017
|
-
let initIsNewUser = undefined;
|
|
1018
|
-
const handleIsNewUser = () => {
|
|
1019
|
-
if (initIsNewUser !== undefined) {
|
|
1020
|
-
return initIsNewUser;
|
|
1021
|
-
}
|
|
1022
|
-
return undefined;
|
|
1023
|
-
};
|
|
1024
|
-
const setIsNewUSer = (isNewUser) => {
|
|
1025
|
-
initIsNewUser = isNewUser;
|
|
1097
|
+
setSetting({
|
|
1098
|
+
initialized: true,
|
|
1099
|
+
}, destination);
|
|
1100
|
+
processStubs(destination);
|
|
1026
1101
|
};
|
|
1027
1102
|
|
|
1028
1103
|
const handleInit = (preferences) => {
|
|
@@ -1031,15 +1106,17 @@ const handleInit = (preferences) => {
|
|
|
1031
1106
|
return;
|
|
1032
1107
|
}
|
|
1033
1108
|
if (preferences.afterManifestEvents) {
|
|
1034
|
-
|
|
1109
|
+
setSetting({
|
|
1110
|
+
stubs: preferences.afterManifestEvents,
|
|
1111
|
+
}, preferences.edgeURL);
|
|
1035
1112
|
}
|
|
1036
|
-
const url = new URL(getInitURL());
|
|
1113
|
+
const url = new URL(getInitURL(preferences.edgeURL));
|
|
1037
1114
|
if (preferences.disableConsentCheck) {
|
|
1038
1115
|
url.searchParams.set('consentDisabled', 'true');
|
|
1039
|
-
saveConsent({ all: true });
|
|
1116
|
+
saveConsent(preferences.edgeURL, { all: true });
|
|
1040
1117
|
}
|
|
1041
1118
|
if (preferences.userId) {
|
|
1042
|
-
|
|
1119
|
+
setSetting({ userId: preferences.userId }, preferences.edgeURL);
|
|
1043
1120
|
url.searchParams.set('userId', preferences.userId);
|
|
1044
1121
|
}
|
|
1045
1122
|
getRequest(url.href)
|
|
@@ -1048,18 +1125,17 @@ const handleInit = (preferences) => {
|
|
|
1048
1125
|
error('Initialization failed');
|
|
1049
1126
|
return;
|
|
1050
1127
|
}
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
setIsNewUSer(result.isNewUser);
|
|
1059
|
-
handleManifest(result, consent || result.consent);
|
|
1128
|
+
setSetting({
|
|
1129
|
+
isNewUser: result.isNewUser,
|
|
1130
|
+
consent: getConsent$1(preferences.edgeURL) || result.consent,
|
|
1131
|
+
userId: result.userId,
|
|
1132
|
+
packages: result.result,
|
|
1133
|
+
}, preferences.edgeURL);
|
|
1134
|
+
handleManifest(preferences.edgeURL, result);
|
|
1060
1135
|
try {
|
|
1061
1136
|
window.dispatchEvent(new CustomEvent('edgetag-initialized', {
|
|
1062
1137
|
detail: {
|
|
1138
|
+
destination: preferences.edgeURL,
|
|
1063
1139
|
userId: result.userId,
|
|
1064
1140
|
isNewUser: result.isNewUser,
|
|
1065
1141
|
consent: result.consent,
|
|
@@ -1075,19 +1151,15 @@ const handleInit = (preferences) => {
|
|
|
1075
1151
|
.catch(error);
|
|
1076
1152
|
};
|
|
1077
1153
|
|
|
1078
|
-
const
|
|
1079
|
-
|
|
1080
|
-
error('Key or Value is missing in user API.');
|
|
1081
|
-
return;
|
|
1082
|
-
}
|
|
1083
|
-
saveKV({
|
|
1154
|
+
const processUser = (destination, key, value, providers, options) => {
|
|
1155
|
+
saveKV(destination, {
|
|
1084
1156
|
[key]: value,
|
|
1085
1157
|
});
|
|
1086
|
-
const providerPackages = getProvidersPackage();
|
|
1087
|
-
const configuredTags =
|
|
1088
|
-
const consent = getConsent$1();
|
|
1089
|
-
const userId =
|
|
1090
|
-
for (const pkg of
|
|
1158
|
+
const providerPackages = getProvidersPackage(destination);
|
|
1159
|
+
const configuredTags = getSetting(destination, 'channels');
|
|
1160
|
+
const consent = getConsent$1(destination);
|
|
1161
|
+
const userId = getUserId$1(destination);
|
|
1162
|
+
for (const pkg of providerPackages) {
|
|
1091
1163
|
if (!pkg || !pkg.name || !pkg.user) {
|
|
1092
1164
|
continue;
|
|
1093
1165
|
}
|
|
@@ -1095,47 +1167,73 @@ const handleUser = (key, value, providers, options) => {
|
|
|
1095
1167
|
log(`Provider ${pkg.name} is not in allow list`);
|
|
1096
1168
|
continue;
|
|
1097
1169
|
}
|
|
1098
|
-
const variables = getProviderVariables(pkg.name);
|
|
1099
|
-
for (const
|
|
1100
|
-
if (!isProviderInstanceAllowed(providers, pkg.name, tagName)) {
|
|
1101
|
-
log(`User not allowed for ${pkg.name} (${tagName})`);
|
|
1170
|
+
const variables = getProviderVariables(destination, pkg.name);
|
|
1171
|
+
for (const variable of variables) {
|
|
1172
|
+
if (!isProviderInstanceAllowed(providers, pkg.name, variable.tagName)) {
|
|
1173
|
+
log(`User not allowed for ${pkg.name} (${variable.tagName})`);
|
|
1102
1174
|
continue;
|
|
1103
1175
|
}
|
|
1104
|
-
if (!hasUserConsent(consent, pkg.name, tagName)) {
|
|
1105
|
-
log(`User doesn't have consent for ${pkg.name} (${tagName})`);
|
|
1176
|
+
if (!hasUserConsent(consent, pkg.name, variable.tagName)) {
|
|
1177
|
+
log(`User doesn't have consent for ${pkg.name} (${variable.tagName})`);
|
|
1106
1178
|
continue;
|
|
1107
1179
|
}
|
|
1108
1180
|
pkg.user({
|
|
1109
1181
|
userId,
|
|
1110
1182
|
data: { [key]: value },
|
|
1111
|
-
manifestVariables: variableSet,
|
|
1183
|
+
manifestVariables: variable.variableSet,
|
|
1112
1184
|
});
|
|
1113
1185
|
}
|
|
1114
1186
|
}
|
|
1115
|
-
postRequest(getUserURL(), {
|
|
1187
|
+
postRequest(getUserURL(destination), {
|
|
1116
1188
|
key,
|
|
1117
1189
|
value,
|
|
1118
1190
|
providers,
|
|
1119
1191
|
}, options).catch(error);
|
|
1120
1192
|
};
|
|
1193
|
+
const handleUser = (key, value, providers, options) => {
|
|
1194
|
+
if (!key || !value) {
|
|
1195
|
+
error('Key or Value is missing in user API.');
|
|
1196
|
+
return;
|
|
1197
|
+
}
|
|
1198
|
+
if (options === null || options === void 0 ? void 0 : options.destination) {
|
|
1199
|
+
processUser(options.destination, key, value, providers, options);
|
|
1200
|
+
return;
|
|
1201
|
+
}
|
|
1202
|
+
getInstances().forEach((destination) => {
|
|
1203
|
+
processUser(destination, key, value, providers, options);
|
|
1204
|
+
});
|
|
1205
|
+
};
|
|
1121
1206
|
|
|
1122
|
-
const
|
|
1123
|
-
getRequest(getKeysURL())
|
|
1207
|
+
const processKeys = (destination, callback) => {
|
|
1208
|
+
getRequest(getKeysURL(destination))
|
|
1124
1209
|
.then((result) => {
|
|
1125
1210
|
callback((result === null || result === void 0 ? void 0 : result.result) || []);
|
|
1126
1211
|
})
|
|
1127
1212
|
.catch(error);
|
|
1128
1213
|
};
|
|
1214
|
+
const handleKeys = (callback, options) => {
|
|
1215
|
+
if (options === null || options === void 0 ? void 0 : options.destination) {
|
|
1216
|
+
processKeys(options.destination, callback);
|
|
1217
|
+
return;
|
|
1218
|
+
}
|
|
1219
|
+
const instances = getInstances();
|
|
1220
|
+
if (instances.length > 1) {
|
|
1221
|
+
error('Multiple instances found! Please provide destination.');
|
|
1222
|
+
callback([]);
|
|
1223
|
+
return;
|
|
1224
|
+
}
|
|
1225
|
+
processKeys(instances[0], callback);
|
|
1226
|
+
};
|
|
1129
1227
|
|
|
1130
|
-
const
|
|
1131
|
-
getRequest(getConsentURL())
|
|
1228
|
+
const processGetConsent = (destination, callback) => {
|
|
1229
|
+
getRequest(getConsentURL(destination))
|
|
1132
1230
|
.then((result) => {
|
|
1133
1231
|
// this will try to return the consent data stored in Edge
|
|
1134
1232
|
return result === null || result === void 0 ? void 0 : result.result;
|
|
1135
1233
|
})
|
|
1136
1234
|
.catch(() => undefined)
|
|
1137
1235
|
.then((result) => {
|
|
1138
|
-
const consent = result !== null && result !== void 0 ? result : getConsent$1(); // this is a default value i.e. value from local storage and memory incase Edge doesn't have consent
|
|
1236
|
+
const consent = result !== null && result !== void 0 ? result : getConsent$1(destination); // this is a default value i.e. value from local storage and memory incase Edge doesn't have consent
|
|
1139
1237
|
if (consent) {
|
|
1140
1238
|
callback(consent);
|
|
1141
1239
|
}
|
|
@@ -1144,9 +1242,48 @@ const handleGetConsent = (callback) => {
|
|
|
1144
1242
|
}
|
|
1145
1243
|
});
|
|
1146
1244
|
};
|
|
1245
|
+
const handleGetConsent = (callback, options) => {
|
|
1246
|
+
if (options === null || options === void 0 ? void 0 : options.destination) {
|
|
1247
|
+
processGetConsent(options.destination, callback);
|
|
1248
|
+
return;
|
|
1249
|
+
}
|
|
1250
|
+
const instances = getInstances();
|
|
1251
|
+
if (instances.length > 1) {
|
|
1252
|
+
callback(null, new Error('Multiple instances found! Please provide destination.'));
|
|
1253
|
+
return;
|
|
1254
|
+
}
|
|
1255
|
+
processGetConsent(instances[0], callback);
|
|
1256
|
+
};
|
|
1147
1257
|
|
|
1148
|
-
const
|
|
1149
|
-
|
|
1258
|
+
const handleIsNewUser = (options) => {
|
|
1259
|
+
if (options === null || options === void 0 ? void 0 : options.destination) {
|
|
1260
|
+
return getSetting(options.destination, 'isNewUser');
|
|
1261
|
+
}
|
|
1262
|
+
const instances = getInstances();
|
|
1263
|
+
if (instances.length > 1) {
|
|
1264
|
+
error('Multiple instances found! Please provide destination.');
|
|
1265
|
+
return undefined;
|
|
1266
|
+
}
|
|
1267
|
+
return getSetting(instances[0], 'isNewUser');
|
|
1268
|
+
};
|
|
1269
|
+
|
|
1270
|
+
const processConfig = (destination, config) => {
|
|
1271
|
+
const existingConfig = getSetting(destination, 'config');
|
|
1272
|
+
setSetting({
|
|
1273
|
+
config: {
|
|
1274
|
+
...existingConfig,
|
|
1275
|
+
...config,
|
|
1276
|
+
},
|
|
1277
|
+
}, destination);
|
|
1278
|
+
};
|
|
1279
|
+
const handleConfig = (config, options) => {
|
|
1280
|
+
if (options === null || options === void 0 ? void 0 : options.destination) {
|
|
1281
|
+
processConfig(options.destination, config);
|
|
1282
|
+
return;
|
|
1283
|
+
}
|
|
1284
|
+
getInstances().forEach((destination) => {
|
|
1285
|
+
processConfig(destination, config);
|
|
1286
|
+
});
|
|
1150
1287
|
};
|
|
1151
1288
|
|
|
1152
1289
|
const init = (preferences) => {
|
|
@@ -1164,23 +1301,23 @@ const user = (key, value, providers, options) => {
|
|
|
1164
1301
|
const data = (value, providers, options) => {
|
|
1165
1302
|
handleData(value, providers, options);
|
|
1166
1303
|
};
|
|
1167
|
-
const getData = (keys, callback) => {
|
|
1168
|
-
handleGetData(keys, callback);
|
|
1304
|
+
const getData = (keys, callback, options) => {
|
|
1305
|
+
handleGetData(keys, callback, options);
|
|
1169
1306
|
};
|
|
1170
|
-
const keys = (callback) => {
|
|
1171
|
-
handleKeys(callback);
|
|
1307
|
+
const keys = (callback, options) => {
|
|
1308
|
+
handleKeys(callback, options);
|
|
1172
1309
|
};
|
|
1173
|
-
const getUserId = () => {
|
|
1174
|
-
return handleGetUserId();
|
|
1310
|
+
const getUserId = (options) => {
|
|
1311
|
+
return handleGetUserId(options);
|
|
1175
1312
|
};
|
|
1176
|
-
const getConsent = (callback) => {
|
|
1177
|
-
handleGetConsent(callback);
|
|
1313
|
+
const getConsent = (callback, options) => {
|
|
1314
|
+
handleGetConsent(callback, options);
|
|
1178
1315
|
};
|
|
1179
|
-
const isNewUser = () => {
|
|
1180
|
-
return handleIsNewUser();
|
|
1316
|
+
const isNewUser = (options) => {
|
|
1317
|
+
return handleIsNewUser(options);
|
|
1181
1318
|
};
|
|
1182
|
-
const setConfig = (config) => {
|
|
1183
|
-
|
|
1319
|
+
const setConfig = (config, options) => {
|
|
1320
|
+
handleConfig(config, options);
|
|
1184
1321
|
};
|
|
1185
1322
|
|
|
1186
1323
|
export { consent, data, getConsent, getData, getUserId, init, isNewUser, keys, setConfig, tag, user };
|