@blotoutio/edgetag-sdk-js 0.6.4 → 0.6.6
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 +137 -34
- package/index.d.ts +4 -1
- package/index.esm.js +137 -34
- package/package.json +4 -4
package/index.cjs
CHANGED
|
@@ -4,6 +4,18 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var uuid = require('uuid');
|
|
6
6
|
|
|
7
|
+
var api = /*#__PURE__*/Object.freeze({
|
|
8
|
+
__proto__: null,
|
|
9
|
+
get init () { return init; },
|
|
10
|
+
get tag () { return tag; },
|
|
11
|
+
get consent () { return consent; },
|
|
12
|
+
get user () { return user; },
|
|
13
|
+
get data () { return data; },
|
|
14
|
+
get getData () { return getData; },
|
|
15
|
+
get keys () { return keys; },
|
|
16
|
+
get getUserId () { return getUserId; }
|
|
17
|
+
});
|
|
18
|
+
|
|
7
19
|
/******************************************************************************
|
|
8
20
|
Copyright (c) Microsoft Corporation.
|
|
9
21
|
|
|
@@ -104,24 +116,56 @@ const saveKV = (data) => {
|
|
|
104
116
|
saveData('session', currentSession);
|
|
105
117
|
};
|
|
106
118
|
const saveLocal = (value, key) => {
|
|
107
|
-
|
|
119
|
+
try {
|
|
120
|
+
if (!localStorage) {
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
localStorage.setItem(key, JSON.stringify(value));
|
|
124
|
+
}
|
|
125
|
+
catch (_a) {
|
|
126
|
+
console.log('Local storage not supported');
|
|
127
|
+
}
|
|
108
128
|
};
|
|
109
129
|
const getLocal = (key) => {
|
|
110
|
-
|
|
111
|
-
|
|
130
|
+
try {
|
|
131
|
+
if (!localStorage) {
|
|
132
|
+
return {};
|
|
133
|
+
}
|
|
134
|
+
const data = localStorage.getItem(key);
|
|
135
|
+
if (!data) {
|
|
136
|
+
return {};
|
|
137
|
+
}
|
|
138
|
+
return JSON.parse(data) || {};
|
|
139
|
+
}
|
|
140
|
+
catch (_a) {
|
|
112
141
|
return {};
|
|
113
142
|
}
|
|
114
|
-
return JSON.parse(data) || {};
|
|
115
143
|
};
|
|
116
144
|
const saveSession = (value, key) => {
|
|
117
|
-
|
|
145
|
+
try {
|
|
146
|
+
if (!sessionStorage) {
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
149
|
+
sessionStorage.setItem(key, JSON.stringify(value));
|
|
150
|
+
}
|
|
151
|
+
catch (_a) {
|
|
152
|
+
console.log('Session storage not supported');
|
|
153
|
+
}
|
|
118
154
|
};
|
|
119
155
|
const getSession = (key) => {
|
|
120
|
-
|
|
121
|
-
|
|
156
|
+
try {
|
|
157
|
+
if (!sessionStorage) {
|
|
158
|
+
return {};
|
|
159
|
+
}
|
|
160
|
+
const data = sessionStorage.getItem(key);
|
|
161
|
+
if (!data) {
|
|
162
|
+
return {};
|
|
163
|
+
}
|
|
164
|
+
return JSON.parse(data) || {};
|
|
165
|
+
}
|
|
166
|
+
catch (_a) {
|
|
122
167
|
return {};
|
|
123
168
|
}
|
|
124
|
-
return JSON.parse(data) || {};
|
|
125
169
|
};
|
|
126
170
|
|
|
127
171
|
let endpointUrl = '';
|
|
@@ -164,6 +208,7 @@ const getKeysURL = () => {
|
|
|
164
208
|
return generateUrl(`/keys`);
|
|
165
209
|
};
|
|
166
210
|
|
|
211
|
+
let initialized = false;
|
|
167
212
|
let consentDisabled = false;
|
|
168
213
|
const providers = {};
|
|
169
214
|
const setPreferences = (preferences) => {
|
|
@@ -195,6 +240,10 @@ const setPreferences = (preferences) => {
|
|
|
195
240
|
};
|
|
196
241
|
const isConsentDisabled = () => consentDisabled;
|
|
197
242
|
const getProvidersPackage = () => providers;
|
|
243
|
+
const isInitialized = () => initialized;
|
|
244
|
+
const setInitialized = () => {
|
|
245
|
+
initialized = true;
|
|
246
|
+
};
|
|
198
247
|
|
|
199
248
|
const getUserAgent = () => {
|
|
200
249
|
const nav = navigator;
|
|
@@ -358,6 +407,24 @@ const addProviderVariable = (name, variables) => {
|
|
|
358
407
|
};
|
|
359
408
|
const getProviderVariables = (name) => manifestVariables[name] || {};
|
|
360
409
|
|
|
410
|
+
let stubs = [];
|
|
411
|
+
const addStubs = (newStubs) => {
|
|
412
|
+
stubs = [...stubs, ...newStubs];
|
|
413
|
+
};
|
|
414
|
+
const addStub = (stub) => {
|
|
415
|
+
stubs.push(stub);
|
|
416
|
+
};
|
|
417
|
+
const processStubs = () => {
|
|
418
|
+
try {
|
|
419
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
420
|
+
// @ts-ignore
|
|
421
|
+
stubs.forEach((stub) => api[stub.name](...(stub.arguments || [])));
|
|
422
|
+
}
|
|
423
|
+
catch (e) {
|
|
424
|
+
console.error(e);
|
|
425
|
+
}
|
|
426
|
+
};
|
|
427
|
+
|
|
361
428
|
const sendTag = ({ eventName, eventId, data, providerData, providers, options, }) => {
|
|
362
429
|
const payload = {
|
|
363
430
|
eventName,
|
|
@@ -372,6 +439,13 @@ const sendTag = ({ eventName, eventId, data, providerData, providers, options, }
|
|
|
372
439
|
postRequest(getTagURL(), payload, options).catch(info);
|
|
373
440
|
};
|
|
374
441
|
const handleTag = (eventName, data = {}, providers, options) => {
|
|
442
|
+
if (!isInitialized()) {
|
|
443
|
+
addStub({
|
|
444
|
+
name: 'tag',
|
|
445
|
+
arguments: [eventName, data, providers, options],
|
|
446
|
+
});
|
|
447
|
+
return;
|
|
448
|
+
}
|
|
375
449
|
if (!allowTag(providers)) {
|
|
376
450
|
console.log('No consent');
|
|
377
451
|
return;
|
|
@@ -385,21 +459,19 @@ const handleTag = (eventName, data = {}, providers, options) => {
|
|
|
385
459
|
const providerData = {};
|
|
386
460
|
if (providerPackages) {
|
|
387
461
|
Object.values(providerPackages).forEach((pkg) => {
|
|
388
|
-
if (!allowProvider(providers, pkg.name)) {
|
|
462
|
+
if (!pkg || !pkg.tag || !allowProvider(providers, pkg.name)) {
|
|
389
463
|
return;
|
|
390
464
|
}
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
providerData[pkg.name] = result;
|
|
402
|
-
}
|
|
465
|
+
const result = pkg.tag({
|
|
466
|
+
userId,
|
|
467
|
+
eventName,
|
|
468
|
+
eventId,
|
|
469
|
+
data,
|
|
470
|
+
sendTag,
|
|
471
|
+
manifestVariables: getProviderVariables(pkg.name),
|
|
472
|
+
});
|
|
473
|
+
if (result) {
|
|
474
|
+
providerData[pkg.name] = result;
|
|
403
475
|
}
|
|
404
476
|
});
|
|
405
477
|
}
|
|
@@ -413,6 +485,30 @@ const handleTag = (eventName, data = {}, providers, options) => {
|
|
|
413
485
|
});
|
|
414
486
|
};
|
|
415
487
|
|
|
488
|
+
const handleData = (data, options) => {
|
|
489
|
+
if (!data || Object.keys(data).length === 0) {
|
|
490
|
+
console.error('Provide data for data API.');
|
|
491
|
+
return;
|
|
492
|
+
}
|
|
493
|
+
saveKV(data);
|
|
494
|
+
postRequest(getDataURL(), { data }, options).catch(info);
|
|
495
|
+
};
|
|
496
|
+
|
|
497
|
+
const saveDataToEdge = (key, value, provider) => {
|
|
498
|
+
if (!value) {
|
|
499
|
+
return;
|
|
500
|
+
}
|
|
501
|
+
if (typeof value !== 'string') {
|
|
502
|
+
try {
|
|
503
|
+
value = JSON.stringify(value);
|
|
504
|
+
}
|
|
505
|
+
catch (_a) {
|
|
506
|
+
console.log('Error stringify value');
|
|
507
|
+
return;
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
handleData({ [`${provider}::${key}`]: value });
|
|
511
|
+
};
|
|
416
512
|
const handleCaptureQuery = (provider, key, persistType) => {
|
|
417
513
|
if (!window) {
|
|
418
514
|
return;
|
|
@@ -421,7 +517,15 @@ const handleCaptureQuery = (provider, key, persistType) => {
|
|
|
421
517
|
if (!params || !params.get(key)) {
|
|
422
518
|
return;
|
|
423
519
|
}
|
|
424
|
-
|
|
520
|
+
const data = params.get(key);
|
|
521
|
+
if (!data) {
|
|
522
|
+
return;
|
|
523
|
+
}
|
|
524
|
+
if (persistType === 'edge') {
|
|
525
|
+
saveDataToEdge(key, data, provider);
|
|
526
|
+
return;
|
|
527
|
+
}
|
|
528
|
+
saveDataPerKey(persistType, provider, data, key);
|
|
425
529
|
};
|
|
426
530
|
const handleCaptureStorage = (provider, key, persistType, location) => {
|
|
427
531
|
let data;
|
|
@@ -431,17 +535,20 @@ const handleCaptureStorage = (provider, key, persistType, location) => {
|
|
|
431
535
|
break;
|
|
432
536
|
}
|
|
433
537
|
case 'local': {
|
|
434
|
-
data =
|
|
538
|
+
data = getData$1('local', key);
|
|
435
539
|
break;
|
|
436
540
|
}
|
|
437
541
|
case 'session': {
|
|
438
|
-
data =
|
|
439
|
-
break;
|
|
542
|
+
data = getData$1('session', key);
|
|
440
543
|
}
|
|
441
544
|
}
|
|
442
545
|
if (!data) {
|
|
443
546
|
return;
|
|
444
547
|
}
|
|
548
|
+
if (persistType === 'edge') {
|
|
549
|
+
saveDataToEdge(key, data, provider);
|
|
550
|
+
return;
|
|
551
|
+
}
|
|
445
552
|
saveDataPerKey(persistType, provider, data, key);
|
|
446
553
|
};
|
|
447
554
|
const handleCapture = (provider, params) => {
|
|
@@ -483,6 +590,8 @@ const handleManifest = (manifest) => {
|
|
|
483
590
|
}
|
|
484
591
|
}
|
|
485
592
|
});
|
|
593
|
+
setInitialized();
|
|
594
|
+
processStubs();
|
|
486
595
|
savePerKey('local', tagStorage, providers, providersKey);
|
|
487
596
|
};
|
|
488
597
|
|
|
@@ -491,6 +600,9 @@ const handleInit = (preferences) => {
|
|
|
491
600
|
if (!success) {
|
|
492
601
|
return;
|
|
493
602
|
}
|
|
603
|
+
if (preferences.afterManifestEvents) {
|
|
604
|
+
addStubs(preferences.afterManifestEvents);
|
|
605
|
+
}
|
|
494
606
|
const url = new URL(getInitURL());
|
|
495
607
|
if (preferences.disableConsentCheck) {
|
|
496
608
|
url.searchParams.set('consentDisabled', 'true');
|
|
@@ -524,15 +636,6 @@ const handleUser = (key, value, options) => {
|
|
|
524
636
|
}, options).catch(info);
|
|
525
637
|
};
|
|
526
638
|
|
|
527
|
-
const handleData = (data, options) => {
|
|
528
|
-
if (!data || Object.keys(data).length === 0) {
|
|
529
|
-
console.error('Provide data for data API.');
|
|
530
|
-
return;
|
|
531
|
-
}
|
|
532
|
-
saveKV(data);
|
|
533
|
-
postRequest(getDataURL(), { data }, options).catch(info);
|
|
534
|
-
};
|
|
535
|
-
|
|
536
639
|
const handleGetData = (keys, callback) => {
|
|
537
640
|
if (!keys || keys.length === 0) {
|
|
538
641
|
console.error('Provide keys for get data API.');
|
package/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// TODO this all located in '@blotoutio/shared/utility-sdk'
|
|
2
2
|
|
|
3
|
-
type PersistType = 'local' | 'session'
|
|
3
|
+
type PersistType = 'local' | 'session' | 'edge'
|
|
4
4
|
|
|
5
5
|
type EventOptions = {
|
|
6
6
|
method?: 'beacon'
|
|
@@ -66,11 +66,14 @@ type UserKey =
|
|
|
66
66
|
| 'zip'
|
|
67
67
|
| 'address'
|
|
68
68
|
|
|
69
|
+
type Stub = { name: string; arguments: unknown[] }
|
|
70
|
+
|
|
69
71
|
type InitPreferences = {
|
|
70
72
|
edgeURL: string
|
|
71
73
|
disableConsentCheck?: boolean
|
|
72
74
|
userId?: string
|
|
73
75
|
providers?: ProviderInit[]
|
|
76
|
+
afterManifestEvents?: Stub[]
|
|
74
77
|
}
|
|
75
78
|
|
|
76
79
|
export declare const init: (preferences: InitPreferences) => void
|
package/index.esm.js
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
import { v4 } from 'uuid';
|
|
2
2
|
|
|
3
|
+
var api = /*#__PURE__*/Object.freeze({
|
|
4
|
+
__proto__: null,
|
|
5
|
+
get init () { return init; },
|
|
6
|
+
get tag () { return tag; },
|
|
7
|
+
get consent () { return consent; },
|
|
8
|
+
get user () { return user; },
|
|
9
|
+
get data () { return data; },
|
|
10
|
+
get getData () { return getData; },
|
|
11
|
+
get keys () { return keys; },
|
|
12
|
+
get getUserId () { return getUserId; }
|
|
13
|
+
});
|
|
14
|
+
|
|
3
15
|
/******************************************************************************
|
|
4
16
|
Copyright (c) Microsoft Corporation.
|
|
5
17
|
|
|
@@ -100,24 +112,56 @@ const saveKV = (data) => {
|
|
|
100
112
|
saveData('session', currentSession);
|
|
101
113
|
};
|
|
102
114
|
const saveLocal = (value, key) => {
|
|
103
|
-
|
|
115
|
+
try {
|
|
116
|
+
if (!localStorage) {
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
localStorage.setItem(key, JSON.stringify(value));
|
|
120
|
+
}
|
|
121
|
+
catch (_a) {
|
|
122
|
+
console.log('Local storage not supported');
|
|
123
|
+
}
|
|
104
124
|
};
|
|
105
125
|
const getLocal = (key) => {
|
|
106
|
-
|
|
107
|
-
|
|
126
|
+
try {
|
|
127
|
+
if (!localStorage) {
|
|
128
|
+
return {};
|
|
129
|
+
}
|
|
130
|
+
const data = localStorage.getItem(key);
|
|
131
|
+
if (!data) {
|
|
132
|
+
return {};
|
|
133
|
+
}
|
|
134
|
+
return JSON.parse(data) || {};
|
|
135
|
+
}
|
|
136
|
+
catch (_a) {
|
|
108
137
|
return {};
|
|
109
138
|
}
|
|
110
|
-
return JSON.parse(data) || {};
|
|
111
139
|
};
|
|
112
140
|
const saveSession = (value, key) => {
|
|
113
|
-
|
|
141
|
+
try {
|
|
142
|
+
if (!sessionStorage) {
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
145
|
+
sessionStorage.setItem(key, JSON.stringify(value));
|
|
146
|
+
}
|
|
147
|
+
catch (_a) {
|
|
148
|
+
console.log('Session storage not supported');
|
|
149
|
+
}
|
|
114
150
|
};
|
|
115
151
|
const getSession = (key) => {
|
|
116
|
-
|
|
117
|
-
|
|
152
|
+
try {
|
|
153
|
+
if (!sessionStorage) {
|
|
154
|
+
return {};
|
|
155
|
+
}
|
|
156
|
+
const data = sessionStorage.getItem(key);
|
|
157
|
+
if (!data) {
|
|
158
|
+
return {};
|
|
159
|
+
}
|
|
160
|
+
return JSON.parse(data) || {};
|
|
161
|
+
}
|
|
162
|
+
catch (_a) {
|
|
118
163
|
return {};
|
|
119
164
|
}
|
|
120
|
-
return JSON.parse(data) || {};
|
|
121
165
|
};
|
|
122
166
|
|
|
123
167
|
let endpointUrl = '';
|
|
@@ -160,6 +204,7 @@ const getKeysURL = () => {
|
|
|
160
204
|
return generateUrl(`/keys`);
|
|
161
205
|
};
|
|
162
206
|
|
|
207
|
+
let initialized = false;
|
|
163
208
|
let consentDisabled = false;
|
|
164
209
|
const providers = {};
|
|
165
210
|
const setPreferences = (preferences) => {
|
|
@@ -191,6 +236,10 @@ const setPreferences = (preferences) => {
|
|
|
191
236
|
};
|
|
192
237
|
const isConsentDisabled = () => consentDisabled;
|
|
193
238
|
const getProvidersPackage = () => providers;
|
|
239
|
+
const isInitialized = () => initialized;
|
|
240
|
+
const setInitialized = () => {
|
|
241
|
+
initialized = true;
|
|
242
|
+
};
|
|
194
243
|
|
|
195
244
|
const getUserAgent = () => {
|
|
196
245
|
const nav = navigator;
|
|
@@ -354,6 +403,24 @@ const addProviderVariable = (name, variables) => {
|
|
|
354
403
|
};
|
|
355
404
|
const getProviderVariables = (name) => manifestVariables[name] || {};
|
|
356
405
|
|
|
406
|
+
let stubs = [];
|
|
407
|
+
const addStubs = (newStubs) => {
|
|
408
|
+
stubs = [...stubs, ...newStubs];
|
|
409
|
+
};
|
|
410
|
+
const addStub = (stub) => {
|
|
411
|
+
stubs.push(stub);
|
|
412
|
+
};
|
|
413
|
+
const processStubs = () => {
|
|
414
|
+
try {
|
|
415
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
416
|
+
// @ts-ignore
|
|
417
|
+
stubs.forEach((stub) => api[stub.name](...(stub.arguments || [])));
|
|
418
|
+
}
|
|
419
|
+
catch (e) {
|
|
420
|
+
console.error(e);
|
|
421
|
+
}
|
|
422
|
+
};
|
|
423
|
+
|
|
357
424
|
const sendTag = ({ eventName, eventId, data, providerData, providers, options, }) => {
|
|
358
425
|
const payload = {
|
|
359
426
|
eventName,
|
|
@@ -368,6 +435,13 @@ const sendTag = ({ eventName, eventId, data, providerData, providers, options, }
|
|
|
368
435
|
postRequest(getTagURL(), payload, options).catch(info);
|
|
369
436
|
};
|
|
370
437
|
const handleTag = (eventName, data = {}, providers, options) => {
|
|
438
|
+
if (!isInitialized()) {
|
|
439
|
+
addStub({
|
|
440
|
+
name: 'tag',
|
|
441
|
+
arguments: [eventName, data, providers, options],
|
|
442
|
+
});
|
|
443
|
+
return;
|
|
444
|
+
}
|
|
371
445
|
if (!allowTag(providers)) {
|
|
372
446
|
console.log('No consent');
|
|
373
447
|
return;
|
|
@@ -381,21 +455,19 @@ const handleTag = (eventName, data = {}, providers, options) => {
|
|
|
381
455
|
const providerData = {};
|
|
382
456
|
if (providerPackages) {
|
|
383
457
|
Object.values(providerPackages).forEach((pkg) => {
|
|
384
|
-
if (!allowProvider(providers, pkg.name)) {
|
|
458
|
+
if (!pkg || !pkg.tag || !allowProvider(providers, pkg.name)) {
|
|
385
459
|
return;
|
|
386
460
|
}
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
providerData[pkg.name] = result;
|
|
398
|
-
}
|
|
461
|
+
const result = pkg.tag({
|
|
462
|
+
userId,
|
|
463
|
+
eventName,
|
|
464
|
+
eventId,
|
|
465
|
+
data,
|
|
466
|
+
sendTag,
|
|
467
|
+
manifestVariables: getProviderVariables(pkg.name),
|
|
468
|
+
});
|
|
469
|
+
if (result) {
|
|
470
|
+
providerData[pkg.name] = result;
|
|
399
471
|
}
|
|
400
472
|
});
|
|
401
473
|
}
|
|
@@ -409,6 +481,30 @@ const handleTag = (eventName, data = {}, providers, options) => {
|
|
|
409
481
|
});
|
|
410
482
|
};
|
|
411
483
|
|
|
484
|
+
const handleData = (data, options) => {
|
|
485
|
+
if (!data || Object.keys(data).length === 0) {
|
|
486
|
+
console.error('Provide data for data API.');
|
|
487
|
+
return;
|
|
488
|
+
}
|
|
489
|
+
saveKV(data);
|
|
490
|
+
postRequest(getDataURL(), { data }, options).catch(info);
|
|
491
|
+
};
|
|
492
|
+
|
|
493
|
+
const saveDataToEdge = (key, value, provider) => {
|
|
494
|
+
if (!value) {
|
|
495
|
+
return;
|
|
496
|
+
}
|
|
497
|
+
if (typeof value !== 'string') {
|
|
498
|
+
try {
|
|
499
|
+
value = JSON.stringify(value);
|
|
500
|
+
}
|
|
501
|
+
catch (_a) {
|
|
502
|
+
console.log('Error stringify value');
|
|
503
|
+
return;
|
|
504
|
+
}
|
|
505
|
+
}
|
|
506
|
+
handleData({ [`${provider}::${key}`]: value });
|
|
507
|
+
};
|
|
412
508
|
const handleCaptureQuery = (provider, key, persistType) => {
|
|
413
509
|
if (!window) {
|
|
414
510
|
return;
|
|
@@ -417,7 +513,15 @@ const handleCaptureQuery = (provider, key, persistType) => {
|
|
|
417
513
|
if (!params || !params.get(key)) {
|
|
418
514
|
return;
|
|
419
515
|
}
|
|
420
|
-
|
|
516
|
+
const data = params.get(key);
|
|
517
|
+
if (!data) {
|
|
518
|
+
return;
|
|
519
|
+
}
|
|
520
|
+
if (persistType === 'edge') {
|
|
521
|
+
saveDataToEdge(key, data, provider);
|
|
522
|
+
return;
|
|
523
|
+
}
|
|
524
|
+
saveDataPerKey(persistType, provider, data, key);
|
|
421
525
|
};
|
|
422
526
|
const handleCaptureStorage = (provider, key, persistType, location) => {
|
|
423
527
|
let data;
|
|
@@ -427,17 +531,20 @@ const handleCaptureStorage = (provider, key, persistType, location) => {
|
|
|
427
531
|
break;
|
|
428
532
|
}
|
|
429
533
|
case 'local': {
|
|
430
|
-
data =
|
|
534
|
+
data = getData$1('local', key);
|
|
431
535
|
break;
|
|
432
536
|
}
|
|
433
537
|
case 'session': {
|
|
434
|
-
data =
|
|
435
|
-
break;
|
|
538
|
+
data = getData$1('session', key);
|
|
436
539
|
}
|
|
437
540
|
}
|
|
438
541
|
if (!data) {
|
|
439
542
|
return;
|
|
440
543
|
}
|
|
544
|
+
if (persistType === 'edge') {
|
|
545
|
+
saveDataToEdge(key, data, provider);
|
|
546
|
+
return;
|
|
547
|
+
}
|
|
441
548
|
saveDataPerKey(persistType, provider, data, key);
|
|
442
549
|
};
|
|
443
550
|
const handleCapture = (provider, params) => {
|
|
@@ -479,6 +586,8 @@ const handleManifest = (manifest) => {
|
|
|
479
586
|
}
|
|
480
587
|
}
|
|
481
588
|
});
|
|
589
|
+
setInitialized();
|
|
590
|
+
processStubs();
|
|
482
591
|
savePerKey('local', tagStorage, providers, providersKey);
|
|
483
592
|
};
|
|
484
593
|
|
|
@@ -487,6 +596,9 @@ const handleInit = (preferences) => {
|
|
|
487
596
|
if (!success) {
|
|
488
597
|
return;
|
|
489
598
|
}
|
|
599
|
+
if (preferences.afterManifestEvents) {
|
|
600
|
+
addStubs(preferences.afterManifestEvents);
|
|
601
|
+
}
|
|
490
602
|
const url = new URL(getInitURL());
|
|
491
603
|
if (preferences.disableConsentCheck) {
|
|
492
604
|
url.searchParams.set('consentDisabled', 'true');
|
|
@@ -520,15 +632,6 @@ const handleUser = (key, value, options) => {
|
|
|
520
632
|
}, options).catch(info);
|
|
521
633
|
};
|
|
522
634
|
|
|
523
|
-
const handleData = (data, options) => {
|
|
524
|
-
if (!data || Object.keys(data).length === 0) {
|
|
525
|
-
console.error('Provide data for data API.');
|
|
526
|
-
return;
|
|
527
|
-
}
|
|
528
|
-
saveKV(data);
|
|
529
|
-
postRequest(getDataURL(), { data }, options).catch(info);
|
|
530
|
-
};
|
|
531
|
-
|
|
532
635
|
const handleGetData = (keys, callback) => {
|
|
533
636
|
if (!keys || keys.length === 0) {
|
|
534
637
|
console.error('Provide keys for get data API.');
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blotoutio/edgetag-sdk-js",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.6",
|
|
4
4
|
"description": "JS SDK for EdgeTag",
|
|
5
5
|
"author": "Blotout",
|
|
6
6
|
"license": "MIT",
|
|
@@ -8,9 +8,9 @@
|
|
|
8
8
|
"publishConfig": {
|
|
9
9
|
"access": "public"
|
|
10
10
|
},
|
|
11
|
-
"main": "./index.
|
|
12
|
-
"
|
|
13
|
-
"uuid": "
|
|
11
|
+
"main": "./index.cjs",
|
|
12
|
+
"dependencies": {
|
|
13
|
+
"uuid": "^9.0.0"
|
|
14
14
|
},
|
|
15
15
|
"repository": {
|
|
16
16
|
"type": "git",
|