@blotoutio/edgetag-sdk-js 0.8.5 → 0.9.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 +27 -3
- package/index.esm.js +27 -3
- package/package.json +1 -4
package/index.cjs
CHANGED
|
@@ -2,8 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var uuid = require('uuid');
|
|
6
|
-
|
|
7
5
|
function _interopNamespace(e) {
|
|
8
6
|
if (e && e.__esModule) return e;
|
|
9
7
|
var n = Object.create(null);
|
|
@@ -429,6 +427,32 @@ const encodeString = (name) => {
|
|
|
429
427
|
}
|
|
430
428
|
return btoa(name);
|
|
431
429
|
};
|
|
430
|
+
const getBasicRandomNumber = () => {
|
|
431
|
+
return parseInt((Math.random() * 10000000000).toString(), 10);
|
|
432
|
+
};
|
|
433
|
+
const generateUUID = () => {
|
|
434
|
+
let id = '';
|
|
435
|
+
try {
|
|
436
|
+
id = crypto.randomUUID();
|
|
437
|
+
if (!id) {
|
|
438
|
+
const array = new Uint32Array(20);
|
|
439
|
+
const numbers = crypto.getRandomValues(array);
|
|
440
|
+
for (let i = 0; i < 5; i++) {
|
|
441
|
+
const y = i * 3;
|
|
442
|
+
if (i !== 0) {
|
|
443
|
+
id += '-';
|
|
444
|
+
}
|
|
445
|
+
const sum = numbers[y + 1] + numbers[y + 2] + numbers[y + 3];
|
|
446
|
+
id += sum.toString();
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
catch (_a) {
|
|
451
|
+
id = `${getBasicRandomNumber()}-${getBasicRandomNumber()}-${getBasicRandomNumber()}-${getBasicRandomNumber()}-${getBasicRandomNumber()}`;
|
|
452
|
+
console.log('[EdgeTag] Crypto module not found');
|
|
453
|
+
}
|
|
454
|
+
return id;
|
|
455
|
+
};
|
|
432
456
|
const generateEventId = (name) => {
|
|
433
457
|
let time = Date.now().toString();
|
|
434
458
|
if (typeof performance !== 'undefined' &&
|
|
@@ -438,7 +462,7 @@ const generateEventId = (name) => {
|
|
|
438
462
|
time = perf.toFixed(4);
|
|
439
463
|
}
|
|
440
464
|
}
|
|
441
|
-
return `${encodeString(name)}-${
|
|
465
|
+
return `${encodeString(name)}-${generateUUID()}-${time}`;
|
|
442
466
|
};
|
|
443
467
|
|
|
444
468
|
const getCookieValue = (key) => {
|
package/index.esm.js
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { v4 } from 'uuid';
|
|
2
|
-
|
|
3
1
|
var api = /*#__PURE__*/Object.freeze({
|
|
4
2
|
__proto__: null,
|
|
5
3
|
get init () { return init; },
|
|
@@ -407,6 +405,32 @@ const encodeString = (name) => {
|
|
|
407
405
|
}
|
|
408
406
|
return btoa(name);
|
|
409
407
|
};
|
|
408
|
+
const getBasicRandomNumber = () => {
|
|
409
|
+
return parseInt((Math.random() * 10000000000).toString(), 10);
|
|
410
|
+
};
|
|
411
|
+
const generateUUID = () => {
|
|
412
|
+
let id = '';
|
|
413
|
+
try {
|
|
414
|
+
id = crypto.randomUUID();
|
|
415
|
+
if (!id) {
|
|
416
|
+
const array = new Uint32Array(20);
|
|
417
|
+
const numbers = crypto.getRandomValues(array);
|
|
418
|
+
for (let i = 0; i < 5; i++) {
|
|
419
|
+
const y = i * 3;
|
|
420
|
+
if (i !== 0) {
|
|
421
|
+
id += '-';
|
|
422
|
+
}
|
|
423
|
+
const sum = numbers[y + 1] + numbers[y + 2] + numbers[y + 3];
|
|
424
|
+
id += sum.toString();
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
catch (_a) {
|
|
429
|
+
id = `${getBasicRandomNumber()}-${getBasicRandomNumber()}-${getBasicRandomNumber()}-${getBasicRandomNumber()}-${getBasicRandomNumber()}`;
|
|
430
|
+
console.log('[EdgeTag] Crypto module not found');
|
|
431
|
+
}
|
|
432
|
+
return id;
|
|
433
|
+
};
|
|
410
434
|
const generateEventId = (name) => {
|
|
411
435
|
let time = Date.now().toString();
|
|
412
436
|
if (typeof performance !== 'undefined' &&
|
|
@@ -416,7 +440,7 @@ const generateEventId = (name) => {
|
|
|
416
440
|
time = perf.toFixed(4);
|
|
417
441
|
}
|
|
418
442
|
}
|
|
419
|
-
return `${encodeString(name)}-${
|
|
443
|
+
return `${encodeString(name)}-${generateUUID()}-${time}`;
|
|
420
444
|
};
|
|
421
445
|
|
|
422
446
|
const getCookieValue = (key) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blotoutio/edgetag-sdk-js",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.1",
|
|
4
4
|
"description": "JS SDK for EdgeTag",
|
|
5
5
|
"author": "Blotout",
|
|
6
6
|
"license": "MIT",
|
|
@@ -9,9 +9,6 @@
|
|
|
9
9
|
"access": "public"
|
|
10
10
|
},
|
|
11
11
|
"main": "./index.cjs",
|
|
12
|
-
"dependencies": {
|
|
13
|
-
"uuid": "^9.0.0"
|
|
14
|
-
},
|
|
15
12
|
"repository": {
|
|
16
13
|
"type": "git",
|
|
17
14
|
"url": "git+https://github.com/blotoutio/edgetag-sdk.git"
|