@blotoutio/edgetag-sdk-js 0.3.0 → 0.5.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 +1 -1
- package/api/data.d.ts +2 -0
- package/api/getData.d.ts +1 -0
- package/api/keys.d.ts +1 -0
- package/api/tag.d.ts +2 -2
- package/api/user.d.ts +2 -2
- package/common/storage.d.ts +1 -0
- package/common/utils.d.ts +1 -1
- package/{index.cjs.js → index.cjs} +85 -19
- package/index.d.ts +6 -3
- package/{index.esm.js → index.js} +83 -20
- package/network/endPoint.d.ts +4 -1
- package/network/utils.d.ts +2 -3
- package/package.json +12 -4
- package/typings/index.d.ts +13 -1
- package/typings/internal.d.ts +10 -8
- package/index.umd.js +0 -487
package/README.md
CHANGED
package/api/data.d.ts
ADDED
package/api/getData.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const handleGetData: (keys: string[], callback: (data: Record<string, string>) => void) => void;
|
package/api/keys.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const handleKeys: (callback: (keys: string[]) => void) => void;
|
package/api/tag.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { Data } from '../typings';
|
|
2
|
-
export declare const handleTag: (name: string, data?: Data
|
|
1
|
+
import { Data, EventOptions } from '../typings';
|
|
2
|
+
export declare const handleTag: (name: string, data?: Data, providers?: Data, options?: EventOptions) => void;
|
package/api/user.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare const handleUser: (key:
|
|
1
|
+
import { EventOptions, UserKey } from '../typings';
|
|
2
|
+
export declare const handleUser: (key: UserKey, value: string, options?: EventOptions) => void;
|
package/common/storage.d.ts
CHANGED
|
@@ -4,3 +4,4 @@ export declare const savePerKey: (persistType: PersistType, provider: string, va
|
|
|
4
4
|
export declare const getDataPerKey: (persistType: PersistType, provider: string, key: string) => unknown;
|
|
5
5
|
export declare const saveData: (persistType: PersistType, value: unknown, key?: string) => void;
|
|
6
6
|
export declare const getData: (persistType: PersistType, key?: string) => Record<string, Record<string, unknown>>;
|
|
7
|
+
export declare const saveKV: (data: Record<string, string>) => void;
|
package/common/utils.d.ts
CHANGED
|
@@ -34,7 +34,7 @@ const keyPrefix = `_worker`;
|
|
|
34
34
|
|
|
35
35
|
const initKey = `${keyPrefix}Store`;
|
|
36
36
|
const saveDataPerKey = (persistType, provider, value, key) => {
|
|
37
|
-
const storage = getData(persistType);
|
|
37
|
+
const storage = getData$1(persistType);
|
|
38
38
|
|
|
39
39
|
if (!storage['data']) {
|
|
40
40
|
storage['data'] = {};
|
|
@@ -48,7 +48,7 @@ const saveDataPerKey = (persistType, provider, value, key) => {
|
|
|
48
48
|
saveData(persistType, storage);
|
|
49
49
|
};
|
|
50
50
|
const savePerKey = (persistType, provider, value, key) => {
|
|
51
|
-
const storage = getData(persistType);
|
|
51
|
+
const storage = getData$1(persistType);
|
|
52
52
|
|
|
53
53
|
if (!storage[provider]) {
|
|
54
54
|
storage[provider] = {};
|
|
@@ -58,7 +58,7 @@ const savePerKey = (persistType, provider, value, key) => {
|
|
|
58
58
|
saveData(persistType, storage);
|
|
59
59
|
};
|
|
60
60
|
const getDataPerKey = (persistType, provider, key) => {
|
|
61
|
-
const storage = getData(persistType);
|
|
61
|
+
const storage = getData$1(persistType);
|
|
62
62
|
|
|
63
63
|
if (!storage[provider]) {
|
|
64
64
|
return undefined;
|
|
@@ -74,13 +74,27 @@ const saveData = (persistType, value, key = initKey) => {
|
|
|
74
74
|
|
|
75
75
|
saveLocal(value, key);
|
|
76
76
|
};
|
|
77
|
-
const getData = (persistType, key = initKey) => {
|
|
77
|
+
const getData$1 = (persistType, key = initKey) => {
|
|
78
78
|
if (persistType === 'session') {
|
|
79
79
|
return getSession(key);
|
|
80
80
|
}
|
|
81
81
|
|
|
82
82
|
return getLocal(key);
|
|
83
83
|
};
|
|
84
|
+
const saveKV = data => {
|
|
85
|
+
let currentSession = getData$1('session');
|
|
86
|
+
|
|
87
|
+
if (!currentSession) {
|
|
88
|
+
currentSession = {};
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
if (!currentSession['kv']) {
|
|
92
|
+
currentSession['kv'] = {};
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
currentSession['kv'] = Object.assign(Object.assign({}, currentSession['kv']), data);
|
|
96
|
+
saveData('session', currentSession);
|
|
97
|
+
};
|
|
84
98
|
|
|
85
99
|
const saveLocal = (value, key) => {
|
|
86
100
|
localStorage.setItem(key, JSON.stringify(value));
|
|
@@ -145,6 +159,15 @@ const getConsentURL = () => {
|
|
|
145
159
|
const getUserURL = () => {
|
|
146
160
|
return generateUrl('/user');
|
|
147
161
|
};
|
|
162
|
+
const getDataURL = () => {
|
|
163
|
+
return generateUrl(`/data`);
|
|
164
|
+
};
|
|
165
|
+
const getGetDataURL = keys => {
|
|
166
|
+
return generateUrl(`/data?keys=${encodeURIComponent(keys.join(','))}`);
|
|
167
|
+
};
|
|
168
|
+
const getKeysURL = () => {
|
|
169
|
+
return generateUrl(`/keys`);
|
|
170
|
+
};
|
|
148
171
|
|
|
149
172
|
let consentDisabled = false;
|
|
150
173
|
const setPreferences = preferences => {
|
|
@@ -246,13 +269,13 @@ const getStandardPayload = payload => {
|
|
|
246
269
|
userAgent: getUserAgent()
|
|
247
270
|
}, payload || {});
|
|
248
271
|
let storage = {};
|
|
249
|
-
const session = getData('session');
|
|
272
|
+
const session = getData$1('session');
|
|
250
273
|
|
|
251
274
|
if (session) {
|
|
252
275
|
storage = Object.assign(Object.assign({}, storage), session);
|
|
253
276
|
}
|
|
254
277
|
|
|
255
|
-
const local = getData('local');
|
|
278
|
+
const local = getData$1('local');
|
|
256
279
|
|
|
257
280
|
if (local) {
|
|
258
281
|
storage = Object.assign(Object.assign({}, storage), local);
|
|
@@ -270,7 +293,7 @@ function postRequest(url, data, options) {
|
|
|
270
293
|
|
|
271
294
|
const payload = getStandardPayload(data);
|
|
272
295
|
|
|
273
|
-
if (options && options.method === 'beacon'
|
|
296
|
+
if (options && options.method === 'beacon') {
|
|
274
297
|
return Promise.resolve(beacon(url, payload));
|
|
275
298
|
}
|
|
276
299
|
|
|
@@ -283,7 +306,7 @@ function getRequest(url, options) {
|
|
|
283
306
|
return Promise.reject(new Error('URL is empty'));
|
|
284
307
|
}
|
|
285
308
|
|
|
286
|
-
if (options && options.method === 'beacon'
|
|
309
|
+
if (options && options.method === 'beacon') {
|
|
287
310
|
return {
|
|
288
311
|
result: Promise.resolve(beacon(url))
|
|
289
312
|
};
|
|
@@ -307,7 +330,7 @@ const handleConsent = consent => {
|
|
|
307
330
|
postRequest(getConsentURL(), payload).catch(info);
|
|
308
331
|
};
|
|
309
332
|
|
|
310
|
-
const handleTag = (name, data, providers) => {
|
|
333
|
+
const handleTag = (name, data, providers, options) => {
|
|
311
334
|
const payload = {
|
|
312
335
|
eventName: name
|
|
313
336
|
};
|
|
@@ -325,7 +348,7 @@ const handleTag = (name, data, providers) => {
|
|
|
325
348
|
return;
|
|
326
349
|
}
|
|
327
350
|
|
|
328
|
-
postRequest(getTagURL(), payload).catch(info);
|
|
351
|
+
postRequest(getTagURL(), payload, options).catch(info);
|
|
329
352
|
};
|
|
330
353
|
|
|
331
354
|
const getCookieValue = key => {
|
|
@@ -449,33 +472,76 @@ const handleInit = preferences => {
|
|
|
449
472
|
}).catch(info);
|
|
450
473
|
};
|
|
451
474
|
|
|
452
|
-
const handleUser = (key, value) => {
|
|
475
|
+
const handleUser = (key, value, options) => {
|
|
453
476
|
if (!key || !value) {
|
|
454
|
-
console.error('Key or Value is missing in user
|
|
477
|
+
console.error('Key or Value is missing in user API.');
|
|
455
478
|
return;
|
|
456
479
|
}
|
|
457
480
|
|
|
458
|
-
|
|
481
|
+
saveKV({
|
|
482
|
+
[key]: value
|
|
483
|
+
});
|
|
484
|
+
postRequest(getUserURL(), {
|
|
459
485
|
key,
|
|
460
486
|
value
|
|
461
|
-
};
|
|
462
|
-
|
|
487
|
+
}, options).catch(info);
|
|
488
|
+
};
|
|
489
|
+
|
|
490
|
+
const handleData = (data, options) => {
|
|
491
|
+
if (!data || Object.keys(data).length === 0) {
|
|
492
|
+
console.error('Provide data for data API.');
|
|
493
|
+
return;
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
saveKV(data);
|
|
497
|
+
postRequest(getDataURL(), {
|
|
498
|
+
data
|
|
499
|
+
}, options).catch(info);
|
|
500
|
+
};
|
|
501
|
+
|
|
502
|
+
const handleGetData = (keys, callback) => {
|
|
503
|
+
if (!keys || keys.length === 0) {
|
|
504
|
+
console.error('Provide keys for get data API.');
|
|
505
|
+
return;
|
|
506
|
+
}
|
|
507
|
+
|
|
508
|
+
getRequest(getGetDataURL(keys)).then(result => {
|
|
509
|
+
callback((result === null || result === void 0 ? void 0 : result.result) || {});
|
|
510
|
+
}).catch(info);
|
|
511
|
+
};
|
|
512
|
+
|
|
513
|
+
const handleKeys = callback => {
|
|
514
|
+
getRequest(getKeysURL()).then(result => {
|
|
515
|
+
callback((result === null || result === void 0 ? void 0 : result.result) || []);
|
|
516
|
+
}).catch(info);
|
|
463
517
|
};
|
|
464
518
|
|
|
465
519
|
const init = preferences => {
|
|
466
520
|
handleInit(preferences);
|
|
467
521
|
};
|
|
468
|
-
const tag = (name, data, providers) => {
|
|
469
|
-
handleTag(name, data, providers);
|
|
522
|
+
const tag = (name, data, providers, options) => {
|
|
523
|
+
handleTag(name, data, providers, options);
|
|
470
524
|
};
|
|
471
525
|
const consent = consent => {
|
|
472
526
|
handleConsent(consent);
|
|
473
527
|
};
|
|
474
|
-
const user = (key, value) => {
|
|
475
|
-
handleUser(key, value);
|
|
528
|
+
const user = (key, value, options) => {
|
|
529
|
+
handleUser(key, value, options);
|
|
530
|
+
};
|
|
531
|
+
const data = (data, options) => {
|
|
532
|
+
handleData(data, options);
|
|
533
|
+
};
|
|
534
|
+
const getData = (keys, callback) => {
|
|
535
|
+
handleGetData(keys, callback);
|
|
536
|
+
};
|
|
537
|
+
const keys = callback => {
|
|
538
|
+
handleKeys(callback);
|
|
476
539
|
};
|
|
477
540
|
|
|
478
541
|
exports.consent = consent;
|
|
542
|
+
exports.data = data;
|
|
543
|
+
exports.getData = getData;
|
|
479
544
|
exports.init = init;
|
|
545
|
+
exports.keys = keys;
|
|
480
546
|
exports.tag = tag;
|
|
481
547
|
exports.user = user;
|
package/index.d.ts
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
import { Data, InitPreferences,
|
|
1
|
+
import { Data, EventOptions, InitPreferences, UserKey } from './typings';
|
|
2
2
|
export declare const init: (preferences: InitPreferences) => void;
|
|
3
|
-
export declare const tag: (name: string, data?: Data
|
|
3
|
+
export declare const tag: (name: string, data?: Data, providers?: Data, options?: EventOptions) => void;
|
|
4
4
|
export declare const consent: (consent: Data) => void;
|
|
5
|
-
export declare const user: (key:
|
|
5
|
+
export declare const user: (key: UserKey, value: string, options?: EventOptions) => void;
|
|
6
|
+
export declare const data: (data: Record<string, string>, options?: EventOptions) => void;
|
|
7
|
+
export declare const getData: (keys: string[], callback: (data: Record<string, string>) => void) => void;
|
|
8
|
+
export declare const keys: (callback: (keys: string[]) => void) => void;
|
|
@@ -30,7 +30,7 @@ const keyPrefix = `_worker`;
|
|
|
30
30
|
|
|
31
31
|
const initKey = `${keyPrefix}Store`;
|
|
32
32
|
const saveDataPerKey = (persistType, provider, value, key) => {
|
|
33
|
-
const storage = getData(persistType);
|
|
33
|
+
const storage = getData$1(persistType);
|
|
34
34
|
|
|
35
35
|
if (!storage['data']) {
|
|
36
36
|
storage['data'] = {};
|
|
@@ -44,7 +44,7 @@ const saveDataPerKey = (persistType, provider, value, key) => {
|
|
|
44
44
|
saveData(persistType, storage);
|
|
45
45
|
};
|
|
46
46
|
const savePerKey = (persistType, provider, value, key) => {
|
|
47
|
-
const storage = getData(persistType);
|
|
47
|
+
const storage = getData$1(persistType);
|
|
48
48
|
|
|
49
49
|
if (!storage[provider]) {
|
|
50
50
|
storage[provider] = {};
|
|
@@ -54,7 +54,7 @@ const savePerKey = (persistType, provider, value, key) => {
|
|
|
54
54
|
saveData(persistType, storage);
|
|
55
55
|
};
|
|
56
56
|
const getDataPerKey = (persistType, provider, key) => {
|
|
57
|
-
const storage = getData(persistType);
|
|
57
|
+
const storage = getData$1(persistType);
|
|
58
58
|
|
|
59
59
|
if (!storage[provider]) {
|
|
60
60
|
return undefined;
|
|
@@ -70,13 +70,27 @@ const saveData = (persistType, value, key = initKey) => {
|
|
|
70
70
|
|
|
71
71
|
saveLocal(value, key);
|
|
72
72
|
};
|
|
73
|
-
const getData = (persistType, key = initKey) => {
|
|
73
|
+
const getData$1 = (persistType, key = initKey) => {
|
|
74
74
|
if (persistType === 'session') {
|
|
75
75
|
return getSession(key);
|
|
76
76
|
}
|
|
77
77
|
|
|
78
78
|
return getLocal(key);
|
|
79
79
|
};
|
|
80
|
+
const saveKV = data => {
|
|
81
|
+
let currentSession = getData$1('session');
|
|
82
|
+
|
|
83
|
+
if (!currentSession) {
|
|
84
|
+
currentSession = {};
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
if (!currentSession['kv']) {
|
|
88
|
+
currentSession['kv'] = {};
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
currentSession['kv'] = Object.assign(Object.assign({}, currentSession['kv']), data);
|
|
92
|
+
saveData('session', currentSession);
|
|
93
|
+
};
|
|
80
94
|
|
|
81
95
|
const saveLocal = (value, key) => {
|
|
82
96
|
localStorage.setItem(key, JSON.stringify(value));
|
|
@@ -141,6 +155,15 @@ const getConsentURL = () => {
|
|
|
141
155
|
const getUserURL = () => {
|
|
142
156
|
return generateUrl('/user');
|
|
143
157
|
};
|
|
158
|
+
const getDataURL = () => {
|
|
159
|
+
return generateUrl(`/data`);
|
|
160
|
+
};
|
|
161
|
+
const getGetDataURL = keys => {
|
|
162
|
+
return generateUrl(`/data?keys=${encodeURIComponent(keys.join(','))}`);
|
|
163
|
+
};
|
|
164
|
+
const getKeysURL = () => {
|
|
165
|
+
return generateUrl(`/keys`);
|
|
166
|
+
};
|
|
144
167
|
|
|
145
168
|
let consentDisabled = false;
|
|
146
169
|
const setPreferences = preferences => {
|
|
@@ -242,13 +265,13 @@ const getStandardPayload = payload => {
|
|
|
242
265
|
userAgent: getUserAgent()
|
|
243
266
|
}, payload || {});
|
|
244
267
|
let storage = {};
|
|
245
|
-
const session = getData('session');
|
|
268
|
+
const session = getData$1('session');
|
|
246
269
|
|
|
247
270
|
if (session) {
|
|
248
271
|
storage = Object.assign(Object.assign({}, storage), session);
|
|
249
272
|
}
|
|
250
273
|
|
|
251
|
-
const local = getData('local');
|
|
274
|
+
const local = getData$1('local');
|
|
252
275
|
|
|
253
276
|
if (local) {
|
|
254
277
|
storage = Object.assign(Object.assign({}, storage), local);
|
|
@@ -266,7 +289,7 @@ function postRequest(url, data, options) {
|
|
|
266
289
|
|
|
267
290
|
const payload = getStandardPayload(data);
|
|
268
291
|
|
|
269
|
-
if (options && options.method === 'beacon'
|
|
292
|
+
if (options && options.method === 'beacon') {
|
|
270
293
|
return Promise.resolve(beacon(url, payload));
|
|
271
294
|
}
|
|
272
295
|
|
|
@@ -279,7 +302,7 @@ function getRequest(url, options) {
|
|
|
279
302
|
return Promise.reject(new Error('URL is empty'));
|
|
280
303
|
}
|
|
281
304
|
|
|
282
|
-
if (options && options.method === 'beacon'
|
|
305
|
+
if (options && options.method === 'beacon') {
|
|
283
306
|
return {
|
|
284
307
|
result: Promise.resolve(beacon(url))
|
|
285
308
|
};
|
|
@@ -303,7 +326,7 @@ const handleConsent = consent => {
|
|
|
303
326
|
postRequest(getConsentURL(), payload).catch(info);
|
|
304
327
|
};
|
|
305
328
|
|
|
306
|
-
const handleTag = (name, data, providers) => {
|
|
329
|
+
const handleTag = (name, data, providers, options) => {
|
|
307
330
|
const payload = {
|
|
308
331
|
eventName: name
|
|
309
332
|
};
|
|
@@ -321,7 +344,7 @@ const handleTag = (name, data, providers) => {
|
|
|
321
344
|
return;
|
|
322
345
|
}
|
|
323
346
|
|
|
324
|
-
postRequest(getTagURL(), payload).catch(info);
|
|
347
|
+
postRequest(getTagURL(), payload, options).catch(info);
|
|
325
348
|
};
|
|
326
349
|
|
|
327
350
|
const getCookieValue = key => {
|
|
@@ -445,30 +468,70 @@ const handleInit = preferences => {
|
|
|
445
468
|
}).catch(info);
|
|
446
469
|
};
|
|
447
470
|
|
|
448
|
-
const handleUser = (key, value) => {
|
|
471
|
+
const handleUser = (key, value, options) => {
|
|
449
472
|
if (!key || !value) {
|
|
450
|
-
console.error('Key or Value is missing in user
|
|
473
|
+
console.error('Key or Value is missing in user API.');
|
|
451
474
|
return;
|
|
452
475
|
}
|
|
453
476
|
|
|
454
|
-
|
|
477
|
+
saveKV({
|
|
478
|
+
[key]: value
|
|
479
|
+
});
|
|
480
|
+
postRequest(getUserURL(), {
|
|
455
481
|
key,
|
|
456
482
|
value
|
|
457
|
-
};
|
|
458
|
-
|
|
483
|
+
}, options).catch(info);
|
|
484
|
+
};
|
|
485
|
+
|
|
486
|
+
const handleData = (data, options) => {
|
|
487
|
+
if (!data || Object.keys(data).length === 0) {
|
|
488
|
+
console.error('Provide data for data API.');
|
|
489
|
+
return;
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
saveKV(data);
|
|
493
|
+
postRequest(getDataURL(), {
|
|
494
|
+
data
|
|
495
|
+
}, options).catch(info);
|
|
496
|
+
};
|
|
497
|
+
|
|
498
|
+
const handleGetData = (keys, callback) => {
|
|
499
|
+
if (!keys || keys.length === 0) {
|
|
500
|
+
console.error('Provide keys for get data API.');
|
|
501
|
+
return;
|
|
502
|
+
}
|
|
503
|
+
|
|
504
|
+
getRequest(getGetDataURL(keys)).then(result => {
|
|
505
|
+
callback((result === null || result === void 0 ? void 0 : result.result) || {});
|
|
506
|
+
}).catch(info);
|
|
507
|
+
};
|
|
508
|
+
|
|
509
|
+
const handleKeys = callback => {
|
|
510
|
+
getRequest(getKeysURL()).then(result => {
|
|
511
|
+
callback((result === null || result === void 0 ? void 0 : result.result) || []);
|
|
512
|
+
}).catch(info);
|
|
459
513
|
};
|
|
460
514
|
|
|
461
515
|
const init = preferences => {
|
|
462
516
|
handleInit(preferences);
|
|
463
517
|
};
|
|
464
|
-
const tag = (name, data, providers) => {
|
|
465
|
-
handleTag(name, data, providers);
|
|
518
|
+
const tag = (name, data, providers, options) => {
|
|
519
|
+
handleTag(name, data, providers, options);
|
|
466
520
|
};
|
|
467
521
|
const consent = consent => {
|
|
468
522
|
handleConsent(consent);
|
|
469
523
|
};
|
|
470
|
-
const user = (key, value) => {
|
|
471
|
-
handleUser(key, value);
|
|
524
|
+
const user = (key, value, options) => {
|
|
525
|
+
handleUser(key, value, options);
|
|
526
|
+
};
|
|
527
|
+
const data = (data, options) => {
|
|
528
|
+
handleData(data, options);
|
|
529
|
+
};
|
|
530
|
+
const getData = (keys, callback) => {
|
|
531
|
+
handleGetData(keys, callback);
|
|
532
|
+
};
|
|
533
|
+
const keys = callback => {
|
|
534
|
+
handleKeys(callback);
|
|
472
535
|
};
|
|
473
536
|
|
|
474
|
-
export { consent, init, tag, user };
|
|
537
|
+
export { consent, data, getData, init, keys, tag, user };
|
package/network/endPoint.d.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
export declare const getUrl: () => string;
|
|
2
|
-
export declare const setUrl: (url?: string
|
|
2
|
+
export declare const setUrl: (url?: string) => void;
|
|
3
3
|
export declare const getTagURL: () => string;
|
|
4
4
|
export declare const getInitURL: () => string;
|
|
5
5
|
export declare const getConsentURL: () => string;
|
|
6
6
|
export declare const getUserURL: () => string;
|
|
7
|
+
export declare const getDataURL: () => string;
|
|
8
|
+
export declare const getGetDataURL: (keys: string[]) => string;
|
|
9
|
+
export declare const getKeysURL: () => string;
|
package/network/utils.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
import { EventOptions } from '../typings';
|
|
2
|
-
|
|
3
|
-
export declare function
|
|
4
|
-
export declare function getRequest<Payload, Response>(url: string, options?: EventOptions): Promise<Response>;
|
|
2
|
+
export declare function postRequest<Payload, Response>(url: string, data?: Payload, options?: EventOptions): Promise<unknown>;
|
|
3
|
+
export declare function getRequest<Response>(url: string, options?: EventOptions): Promise<Response>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blotoutio/edgetag-sdk-js",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "JS SDK for EdgeTag",
|
|
5
5
|
"author": "Blotout",
|
|
6
6
|
"license": "MIT",
|
|
@@ -12,7 +12,15 @@
|
|
|
12
12
|
"type": "git",
|
|
13
13
|
"url": "git+https://github.com/blotoutio/edgetag-sdk.git"
|
|
14
14
|
},
|
|
15
|
-
"
|
|
16
|
-
"
|
|
17
|
-
"
|
|
15
|
+
"module": "./index.js",
|
|
16
|
+
"main": "./index.cjs",
|
|
17
|
+
"type": "module",
|
|
18
|
+
"types": "./index.d.ts",
|
|
19
|
+
"exports": {
|
|
20
|
+
".": {
|
|
21
|
+
"types": "./index.d.ts",
|
|
22
|
+
"import": "./index.js",
|
|
23
|
+
"require": "./index.cjs"
|
|
24
|
+
}
|
|
25
|
+
}
|
|
18
26
|
}
|
package/typings/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
type
|
|
1
|
+
type UserKey =
|
|
2
2
|
| 'email'
|
|
3
3
|
| 'phone'
|
|
4
4
|
| 'firstName'
|
|
@@ -9,6 +9,7 @@ type UserKeys =
|
|
|
9
9
|
| 'state'
|
|
10
10
|
| 'city'
|
|
11
11
|
| 'zip'
|
|
12
|
+
| 'address'
|
|
12
13
|
|
|
13
14
|
type Data = Record<string, unknown>
|
|
14
15
|
|
|
@@ -26,3 +27,14 @@ export declare const init: (preferences: InitPreferences) => void
|
|
|
26
27
|
export declare const tag: (name: string, data?: Data) => void
|
|
27
28
|
|
|
28
29
|
export declare const consent: (consent: Data) => void
|
|
30
|
+
|
|
31
|
+
export declare const user: (key: UserKey, value: string) => void
|
|
32
|
+
|
|
33
|
+
export declare const data: (data: Record<string, string>) => void
|
|
34
|
+
|
|
35
|
+
export declare const getData: (
|
|
36
|
+
keys: string[],
|
|
37
|
+
callback: (data: Record<string, string>) => void
|
|
38
|
+
) => void
|
|
39
|
+
|
|
40
|
+
export declare const keys: (callback: (keys: string[]) => void) => void
|
package/typings/internal.d.ts
CHANGED
|
@@ -1,30 +1,32 @@
|
|
|
1
|
-
import { Data,
|
|
1
|
+
import { Data, UserKey } from './index'
|
|
2
2
|
|
|
3
3
|
type PersistType = 'local' | 'session'
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
type Navigator = {
|
|
6
6
|
userAgent: string
|
|
7
7
|
brave: unknown
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
type TagPayload = {
|
|
11
11
|
eventName: string
|
|
12
12
|
data?: Data
|
|
13
13
|
providers?: Data
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
type ConsentPayload = {
|
|
17
17
|
consentString: Data
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
|
|
21
|
-
key:
|
|
20
|
+
type UserPayload = {
|
|
21
|
+
key: UserKey
|
|
22
22
|
value: string
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
type
|
|
25
|
+
type DataPayload = {
|
|
26
|
+
data: Record<string, string>
|
|
27
|
+
}
|
|
26
28
|
|
|
27
|
-
|
|
29
|
+
type PostPayload = {
|
|
28
30
|
pageUrl: string
|
|
29
31
|
userAgent: string
|
|
30
32
|
data?: Data
|
package/index.umd.js
DELETED
|
@@ -1,487 +0,0 @@
|
|
|
1
|
-
(function (global, factory) {
|
|
2
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
|
|
3
|
-
typeof define === 'function' && define.amd ? define(['exports'], factory) :
|
|
4
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.BlotoutEdgeTagSDKJS = {}));
|
|
5
|
-
})(this, (function (exports) { 'use strict';
|
|
6
|
-
|
|
7
|
-
/******************************************************************************
|
|
8
|
-
Copyright (c) Microsoft Corporation.
|
|
9
|
-
|
|
10
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
|
11
|
-
purpose with or without fee is hereby granted.
|
|
12
|
-
|
|
13
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
14
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
15
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
16
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
17
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
18
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
19
|
-
PERFORMANCE OF THIS SOFTWARE.
|
|
20
|
-
***************************************************************************** */
|
|
21
|
-
|
|
22
|
-
function __awaiter(thisArg, _arguments, P, generator) {
|
|
23
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
24
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
25
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
26
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
27
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
28
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
const tagStorage = 'edgeTag';
|
|
33
|
-
const consentKey = 'consent';
|
|
34
|
-
const providersKey = 'providers';
|
|
35
|
-
const keyPrefix = `_worker`;
|
|
36
|
-
|
|
37
|
-
const initKey = `${keyPrefix}Store`;
|
|
38
|
-
const saveDataPerKey = (persistType, provider, value, key) => {
|
|
39
|
-
const storage = getData(persistType);
|
|
40
|
-
|
|
41
|
-
if (!storage['data']) {
|
|
42
|
-
storage['data'] = {};
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
if (!storage['data'][provider]) {
|
|
46
|
-
storage['data'][provider] = {};
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
storage['data'][provider][key] = value;
|
|
50
|
-
saveData(persistType, storage);
|
|
51
|
-
};
|
|
52
|
-
const savePerKey = (persistType, provider, value, key) => {
|
|
53
|
-
const storage = getData(persistType);
|
|
54
|
-
|
|
55
|
-
if (!storage[provider]) {
|
|
56
|
-
storage[provider] = {};
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
storage[provider][key] = value;
|
|
60
|
-
saveData(persistType, storage);
|
|
61
|
-
};
|
|
62
|
-
const getDataPerKey = (persistType, provider, key) => {
|
|
63
|
-
const storage = getData(persistType);
|
|
64
|
-
|
|
65
|
-
if (!storage[provider]) {
|
|
66
|
-
return undefined;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
return storage[provider][key];
|
|
70
|
-
};
|
|
71
|
-
const saveData = (persistType, value, key = initKey) => {
|
|
72
|
-
if (persistType === 'session') {
|
|
73
|
-
saveSession(value, key);
|
|
74
|
-
return;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
saveLocal(value, key);
|
|
78
|
-
};
|
|
79
|
-
const getData = (persistType, key = initKey) => {
|
|
80
|
-
if (persistType === 'session') {
|
|
81
|
-
return getSession(key);
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
return getLocal(key);
|
|
85
|
-
};
|
|
86
|
-
|
|
87
|
-
const saveLocal = (value, key) => {
|
|
88
|
-
localStorage.setItem(key, JSON.stringify(value));
|
|
89
|
-
};
|
|
90
|
-
|
|
91
|
-
const getLocal = key => {
|
|
92
|
-
const data = localStorage.getItem(key);
|
|
93
|
-
|
|
94
|
-
if (!data) {
|
|
95
|
-
return {};
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
return JSON.parse(data) || {};
|
|
99
|
-
};
|
|
100
|
-
|
|
101
|
-
const saveSession = (value, key) => {
|
|
102
|
-
sessionStorage.setItem(key, JSON.stringify(value));
|
|
103
|
-
};
|
|
104
|
-
|
|
105
|
-
const getSession = key => {
|
|
106
|
-
const data = sessionStorage.getItem(key);
|
|
107
|
-
|
|
108
|
-
if (!data) {
|
|
109
|
-
return {};
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
return JSON.parse(data) || {};
|
|
113
|
-
};
|
|
114
|
-
|
|
115
|
-
let endpointUrl = '';
|
|
116
|
-
|
|
117
|
-
const generateUrl = path => {
|
|
118
|
-
const endpoint = getUrl();
|
|
119
|
-
|
|
120
|
-
if (!endpoint) {
|
|
121
|
-
console.log('URL is not valid');
|
|
122
|
-
return '';
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
return `${endpoint}${path}`;
|
|
126
|
-
};
|
|
127
|
-
|
|
128
|
-
const getUrl = () => {
|
|
129
|
-
return endpointUrl;
|
|
130
|
-
};
|
|
131
|
-
const setUrl = url => {
|
|
132
|
-
if (url == null) {
|
|
133
|
-
return;
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
endpointUrl = url;
|
|
137
|
-
};
|
|
138
|
-
const getTagURL = () => {
|
|
139
|
-
return generateUrl('/tag');
|
|
140
|
-
};
|
|
141
|
-
const getInitURL = () => {
|
|
142
|
-
return generateUrl('/init');
|
|
143
|
-
};
|
|
144
|
-
const getConsentURL = () => {
|
|
145
|
-
return generateUrl('/consent');
|
|
146
|
-
};
|
|
147
|
-
const getUserURL = () => {
|
|
148
|
-
return generateUrl('/user');
|
|
149
|
-
};
|
|
150
|
-
|
|
151
|
-
let consentDisabled = false;
|
|
152
|
-
const setPreferences = preferences => {
|
|
153
|
-
if (!preferences) {
|
|
154
|
-
return false;
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
if (!preferences.edgeURL) {
|
|
158
|
-
console.error('Please provide URL for EdgeTag');
|
|
159
|
-
return false;
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
consentDisabled = !!preferences.disableConsentCheck;
|
|
163
|
-
setUrl(preferences.edgeURL);
|
|
164
|
-
return true;
|
|
165
|
-
};
|
|
166
|
-
const isConsentDisabled = () => consentDisabled;
|
|
167
|
-
|
|
168
|
-
const getUserAgent = () => {
|
|
169
|
-
const nav = navigator;
|
|
170
|
-
let ua = nav.userAgent;
|
|
171
|
-
ua += nav.brave ? `${ua} Brave` : '';
|
|
172
|
-
return ua;
|
|
173
|
-
};
|
|
174
|
-
const allowTag = providers => {
|
|
175
|
-
const consent = getDataPerKey('local', tagStorage, consentKey);
|
|
176
|
-
|
|
177
|
-
if (isConsentDisabled()) {
|
|
178
|
-
return true;
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
if (!consent) {
|
|
182
|
-
return false;
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
if (consent['all']) {
|
|
186
|
-
return true;
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
if (!providers) {
|
|
190
|
-
return Object.values(consent).find(isAllowed => isAllowed) || false;
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
const allProviders = getDataPerKey('local', tagStorage, providersKey) || [];
|
|
194
|
-
|
|
195
|
-
for (const provider of allProviders) {
|
|
196
|
-
const tagProviderSetting = providers[provider];
|
|
197
|
-
|
|
198
|
-
if (tagProviderSetting || providers['all'] === true && tagProviderSetting === undefined || providers['all'] === false && tagProviderSetting === true) {
|
|
199
|
-
if (consent[provider]) {
|
|
200
|
-
return true;
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
return false;
|
|
206
|
-
};
|
|
207
|
-
|
|
208
|
-
const beacon = (url, payload) => {
|
|
209
|
-
let blob;
|
|
210
|
-
|
|
211
|
-
if (payload) {
|
|
212
|
-
blob = new Blob([JSON.stringify(payload)], {
|
|
213
|
-
type: 'application/json'
|
|
214
|
-
});
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
return navigator.sendBeacon(url, blob);
|
|
218
|
-
};
|
|
219
|
-
|
|
220
|
-
const ajax = (method, url, payload) => __awaiter(void 0, void 0, void 0, function* () {
|
|
221
|
-
return yield fetch(url, {
|
|
222
|
-
method,
|
|
223
|
-
headers: {
|
|
224
|
-
'Content-type': 'application/json; charset=utf-8',
|
|
225
|
-
Accept: 'application/json; charset=utf-8'
|
|
226
|
-
},
|
|
227
|
-
body: JSON.stringify(payload),
|
|
228
|
-
credentials: 'include'
|
|
229
|
-
}).then(response => response.json().then(data => ({
|
|
230
|
-
status: response.status,
|
|
231
|
-
body: data
|
|
232
|
-
}))).then(data => {
|
|
233
|
-
if (data.status < 200 || data.status >= 300) {
|
|
234
|
-
// Q: do we need to retry?
|
|
235
|
-
return Promise.reject(new Error(JSON.stringify(data.body)));
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
return Promise.resolve(data.body);
|
|
239
|
-
}).catch(error => {
|
|
240
|
-
// Q: do we need to retry?
|
|
241
|
-
return Promise.reject(new Error(error));
|
|
242
|
-
});
|
|
243
|
-
});
|
|
244
|
-
|
|
245
|
-
const getStandardPayload = payload => {
|
|
246
|
-
const data = Object.assign({
|
|
247
|
-
pageUrl: window.location.href,
|
|
248
|
-
userAgent: getUserAgent()
|
|
249
|
-
}, payload || {});
|
|
250
|
-
let storage = {};
|
|
251
|
-
const session = getData('session');
|
|
252
|
-
|
|
253
|
-
if (session) {
|
|
254
|
-
storage = Object.assign(Object.assign({}, storage), session);
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
const local = getData('local');
|
|
258
|
-
|
|
259
|
-
if (local) {
|
|
260
|
-
storage = Object.assign(Object.assign({}, storage), local);
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
data.storage = storage;
|
|
264
|
-
return data;
|
|
265
|
-
};
|
|
266
|
-
|
|
267
|
-
function postRequest(url, data, options) {
|
|
268
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
269
|
-
if (!url) {
|
|
270
|
-
return Promise.reject(new Error('URL is empty'));
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
const payload = getStandardPayload(data);
|
|
274
|
-
|
|
275
|
-
if (options && options.method === 'beacon' && navigator.sendBeacon) {
|
|
276
|
-
return Promise.resolve(beacon(url, payload));
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
return yield ajax('POST', url, payload);
|
|
280
|
-
});
|
|
281
|
-
}
|
|
282
|
-
function getRequest(url, options) {
|
|
283
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
284
|
-
if (!url) {
|
|
285
|
-
return Promise.reject(new Error('URL is empty'));
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
if (options && options.method === 'beacon' && navigator.sendBeacon) {
|
|
289
|
-
return {
|
|
290
|
-
result: Promise.resolve(beacon(url))
|
|
291
|
-
};
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
return yield ajax('GET', url);
|
|
295
|
-
});
|
|
296
|
-
}
|
|
297
|
-
|
|
298
|
-
const info = data => {
|
|
299
|
-
};
|
|
300
|
-
|
|
301
|
-
const saveConsent = consent => {
|
|
302
|
-
savePerKey('local', tagStorage, consent, consentKey);
|
|
303
|
-
};
|
|
304
|
-
const handleConsent = consent => {
|
|
305
|
-
const payload = {
|
|
306
|
-
consentString: consent
|
|
307
|
-
};
|
|
308
|
-
saveConsent(consent);
|
|
309
|
-
postRequest(getConsentURL(), payload).catch(info);
|
|
310
|
-
};
|
|
311
|
-
|
|
312
|
-
const handleTag = (name, data, providers) => {
|
|
313
|
-
const payload = {
|
|
314
|
-
eventName: name
|
|
315
|
-
};
|
|
316
|
-
|
|
317
|
-
if (data) {
|
|
318
|
-
payload.data = data;
|
|
319
|
-
}
|
|
320
|
-
|
|
321
|
-
if (providers) {
|
|
322
|
-
payload.providers = providers;
|
|
323
|
-
}
|
|
324
|
-
|
|
325
|
-
if (!allowTag(providers)) {
|
|
326
|
-
console.log('No consent');
|
|
327
|
-
return;
|
|
328
|
-
}
|
|
329
|
-
|
|
330
|
-
postRequest(getTagURL(), payload).catch(info);
|
|
331
|
-
};
|
|
332
|
-
|
|
333
|
-
const getCookieValue = key => {
|
|
334
|
-
const name = `${key}=`;
|
|
335
|
-
const decodedCookie = decodeURIComponent(document.cookie);
|
|
336
|
-
const ca = decodedCookie.split(';');
|
|
337
|
-
|
|
338
|
-
for (let i = 0; i < ca.length; i++) {
|
|
339
|
-
let c = ca[i];
|
|
340
|
-
|
|
341
|
-
while (c.charAt(0) === ' ') {
|
|
342
|
-
c = c.substring(1);
|
|
343
|
-
}
|
|
344
|
-
|
|
345
|
-
if (c.indexOf(name) === 0) {
|
|
346
|
-
return c.substring(name.length, c.length);
|
|
347
|
-
}
|
|
348
|
-
}
|
|
349
|
-
|
|
350
|
-
return '';
|
|
351
|
-
};
|
|
352
|
-
|
|
353
|
-
const handleCaptureQuery = (provider, key, persistType) => {
|
|
354
|
-
const params = new URLSearchParams(window.location.search);
|
|
355
|
-
|
|
356
|
-
if (!params || !params.get(key)) {
|
|
357
|
-
return;
|
|
358
|
-
}
|
|
359
|
-
|
|
360
|
-
saveDataPerKey(persistType, provider, params.get(key), key);
|
|
361
|
-
};
|
|
362
|
-
|
|
363
|
-
const handleCaptureStorage = (provider, key, persistType, location) => {
|
|
364
|
-
let data;
|
|
365
|
-
|
|
366
|
-
switch (location) {
|
|
367
|
-
case 'cookie':
|
|
368
|
-
{
|
|
369
|
-
data = getCookieValue(key);
|
|
370
|
-
break;
|
|
371
|
-
}
|
|
372
|
-
|
|
373
|
-
case 'local':
|
|
374
|
-
{
|
|
375
|
-
data = sessionStorage.getItem(key);
|
|
376
|
-
break;
|
|
377
|
-
}
|
|
378
|
-
|
|
379
|
-
case 'session':
|
|
380
|
-
{
|
|
381
|
-
data = localStorage.getItem(key);
|
|
382
|
-
break;
|
|
383
|
-
}
|
|
384
|
-
}
|
|
385
|
-
|
|
386
|
-
if (!data) {
|
|
387
|
-
return;
|
|
388
|
-
}
|
|
389
|
-
|
|
390
|
-
saveDataPerKey(persistType, provider, data, key);
|
|
391
|
-
};
|
|
392
|
-
|
|
393
|
-
const handleCapture = (provider, params) => {
|
|
394
|
-
params.forEach(param => {
|
|
395
|
-
switch (param.type) {
|
|
396
|
-
case 'query':
|
|
397
|
-
{
|
|
398
|
-
handleCaptureQuery(provider, param.key, param.persist);
|
|
399
|
-
break;
|
|
400
|
-
}
|
|
401
|
-
|
|
402
|
-
case 'storage':
|
|
403
|
-
{
|
|
404
|
-
handleCaptureStorage(provider, param.key, param.persist, param.location);
|
|
405
|
-
break;
|
|
406
|
-
}
|
|
407
|
-
}
|
|
408
|
-
});
|
|
409
|
-
};
|
|
410
|
-
|
|
411
|
-
const handleManifest = manifest => {
|
|
412
|
-
const providers = [];
|
|
413
|
-
manifest.forEach(provider => {
|
|
414
|
-
providers.push(provider.package);
|
|
415
|
-
Object.entries(provider.rules).forEach(([name, recipe]) => {
|
|
416
|
-
switch (name) {
|
|
417
|
-
case 'capture':
|
|
418
|
-
{
|
|
419
|
-
handleCapture(provider.package, recipe);
|
|
420
|
-
return;
|
|
421
|
-
}
|
|
422
|
-
}
|
|
423
|
-
});
|
|
424
|
-
});
|
|
425
|
-
savePerKey('local', tagStorage, providers, providersKey);
|
|
426
|
-
};
|
|
427
|
-
|
|
428
|
-
const handleInit = preferences => {
|
|
429
|
-
const success = setPreferences(preferences);
|
|
430
|
-
|
|
431
|
-
if (!success) {
|
|
432
|
-
return;
|
|
433
|
-
}
|
|
434
|
-
|
|
435
|
-
let url = `${getInitURL()}`;
|
|
436
|
-
|
|
437
|
-
if (preferences.disableConsentCheck) {
|
|
438
|
-
url = `${url}?consentDisabled=true`;
|
|
439
|
-
saveConsent({
|
|
440
|
-
all: true
|
|
441
|
-
});
|
|
442
|
-
}
|
|
443
|
-
|
|
444
|
-
getRequest(url).then(result => {
|
|
445
|
-
if (!result) {
|
|
446
|
-
console.log('init failed');
|
|
447
|
-
return;
|
|
448
|
-
}
|
|
449
|
-
|
|
450
|
-
handleManifest(result.result);
|
|
451
|
-
}).catch(info);
|
|
452
|
-
};
|
|
453
|
-
|
|
454
|
-
const handleUser = (key, value) => {
|
|
455
|
-
if (!key || !value) {
|
|
456
|
-
console.error('Key or Value is missing in user api.');
|
|
457
|
-
return;
|
|
458
|
-
}
|
|
459
|
-
|
|
460
|
-
const payload = {
|
|
461
|
-
key,
|
|
462
|
-
value
|
|
463
|
-
};
|
|
464
|
-
postRequest(getUserURL(), payload).catch(info);
|
|
465
|
-
};
|
|
466
|
-
|
|
467
|
-
const init = preferences => {
|
|
468
|
-
handleInit(preferences);
|
|
469
|
-
};
|
|
470
|
-
const tag = (name, data, providers) => {
|
|
471
|
-
handleTag(name, data, providers);
|
|
472
|
-
};
|
|
473
|
-
const consent = consent => {
|
|
474
|
-
handleConsent(consent);
|
|
475
|
-
};
|
|
476
|
-
const user = (key, value) => {
|
|
477
|
-
handleUser(key, value);
|
|
478
|
-
};
|
|
479
|
-
|
|
480
|
-
exports.consent = consent;
|
|
481
|
-
exports.init = init;
|
|
482
|
-
exports.tag = tag;
|
|
483
|
-
exports.user = user;
|
|
484
|
-
|
|
485
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
486
|
-
|
|
487
|
-
}));
|