@ninetailed/experience.js 7.5.3-beta.5 → 7.5.3
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
CHANGED
|
@@ -441,7 +441,18 @@ class Ninetailed {
|
|
|
441
441
|
const isConstructorNameNotObject = constructorName && constructorName !== 'Object';
|
|
442
442
|
experience_jsShared.logger.warn(`ElementSeenObserver.observeElement was called with an invalid element. Expected an Element but got ${typeof element}${isConstructorNameNotObject ? ` of type ${constructorName}` : ''}. This call will be ignored.`);
|
|
443
443
|
} else {
|
|
444
|
-
this.observedElements.
|
|
444
|
+
const existingPayloads = this.observedElements.get(element);
|
|
445
|
+
if (!existingPayloads) {
|
|
446
|
+
this.observedElements.set(element, [remaingPayload]);
|
|
447
|
+
} else {
|
|
448
|
+
const isPayloadAlreadyObserved = existingPayloads.some(payload => {
|
|
449
|
+
return JSON.stringify(payload) === JSON.stringify(remaingPayload);
|
|
450
|
+
});
|
|
451
|
+
if (isPayloadAlreadyObserved) {
|
|
452
|
+
return;
|
|
453
|
+
}
|
|
454
|
+
this.observedElements.set(element, [...existingPayloads, remaingPayload]);
|
|
455
|
+
}
|
|
445
456
|
this.elementSeenObserver.observe(element, Object.assign({
|
|
446
457
|
delay: this.componentViewTrackingThreshold
|
|
447
458
|
}, options));
|
|
@@ -452,11 +463,13 @@ class Ninetailed {
|
|
|
452
463
|
this.elementSeenObserver.unobserve(element);
|
|
453
464
|
};
|
|
454
465
|
this.onElementSeen = element => {
|
|
455
|
-
const
|
|
456
|
-
if (typeof
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
466
|
+
const payloads = this.observedElements.get(element);
|
|
467
|
+
if (typeof payloads !== 'undefined') {
|
|
468
|
+
for (const payload of payloads) {
|
|
469
|
+
this.trackComponentView(Object.assign({
|
|
470
|
+
element
|
|
471
|
+
}, payload));
|
|
472
|
+
}
|
|
460
473
|
}
|
|
461
474
|
};
|
|
462
475
|
this.identify = (uid, traits, options) => __awaiter(this, void 0, void 0, function* () {
|
package/index.js
CHANGED
|
@@ -434,7 +434,18 @@ class Ninetailed {
|
|
|
434
434
|
const isConstructorNameNotObject = constructorName && constructorName !== 'Object';
|
|
435
435
|
logger.warn(`ElementSeenObserver.observeElement was called with an invalid element. Expected an Element but got ${typeof element}${isConstructorNameNotObject ? ` of type ${constructorName}` : ''}. This call will be ignored.`);
|
|
436
436
|
} else {
|
|
437
|
-
this.observedElements.
|
|
437
|
+
const existingPayloads = this.observedElements.get(element);
|
|
438
|
+
if (!existingPayloads) {
|
|
439
|
+
this.observedElements.set(element, [remaingPayload]);
|
|
440
|
+
} else {
|
|
441
|
+
const isPayloadAlreadyObserved = existingPayloads.some(payload => {
|
|
442
|
+
return JSON.stringify(payload) === JSON.stringify(remaingPayload);
|
|
443
|
+
});
|
|
444
|
+
if (isPayloadAlreadyObserved) {
|
|
445
|
+
return;
|
|
446
|
+
}
|
|
447
|
+
this.observedElements.set(element, [...existingPayloads, remaingPayload]);
|
|
448
|
+
}
|
|
438
449
|
this.elementSeenObserver.observe(element, Object.assign({
|
|
439
450
|
delay: this.componentViewTrackingThreshold
|
|
440
451
|
}, options));
|
|
@@ -445,11 +456,13 @@ class Ninetailed {
|
|
|
445
456
|
this.elementSeenObserver.unobserve(element);
|
|
446
457
|
};
|
|
447
458
|
this.onElementSeen = element => {
|
|
448
|
-
const
|
|
449
|
-
if (typeof
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
459
|
+
const payloads = this.observedElements.get(element);
|
|
460
|
+
if (typeof payloads !== 'undefined') {
|
|
461
|
+
for (const payload of payloads) {
|
|
462
|
+
this.trackComponentView(Object.assign({
|
|
463
|
+
element
|
|
464
|
+
}, payload));
|
|
465
|
+
}
|
|
453
466
|
}
|
|
454
467
|
};
|
|
455
468
|
this.identify = (uid, traits, options) => __awaiter(this, void 0, void 0, function* () {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ninetailed/experience.js",
|
|
3
|
-
"version": "7.5.3
|
|
3
|
+
"version": "7.5.3",
|
|
4
4
|
"description": "Ninetailed SDK for javascript",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -13,7 +13,8 @@
|
|
|
13
13
|
"type": "module",
|
|
14
14
|
"types": "./src/index.d.ts",
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@
|
|
16
|
+
"@jest/globals": "27.5.1",
|
|
17
|
+
"@ninetailed/experience.js-shared": "7.5.3",
|
|
17
18
|
"analytics": "0.8.1",
|
|
18
19
|
"zod": "3.21.4"
|
|
19
20
|
},
|