@armco/analytics 0.2.4 → 0.2.5
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/analytics.js +9 -13
- package/package.json +1 -1
package/analytics.js
CHANGED
|
@@ -139,7 +139,7 @@ function enrichEventData(data) {
|
|
|
139
139
|
address && !data.address && (data.address = address);
|
|
140
140
|
coordinates && !data.coordinates && (data.coordinates = coordinates);
|
|
141
141
|
!data.timestamp && (data.timestamp = new Date());
|
|
142
|
-
!data.userId && (data.userId = user ? user.email : ar_anonymous_id);
|
|
142
|
+
!data.userId && (data.userId = (user ? user.email : ar_anonymous_id));
|
|
143
143
|
!data.email && user && user.email && (data.email = user.email);
|
|
144
144
|
user && (data.user = user);
|
|
145
145
|
}
|
|
@@ -324,22 +324,14 @@ function handleTrackedItemClick(e) {
|
|
|
324
324
|
const value = 'value' in clickedElement && clickedElement.value
|
|
325
325
|
? clickedElement.value
|
|
326
326
|
: null;
|
|
327
|
-
const mergedData = Object.assign({}, dataAttributes, {
|
|
328
|
-
id,
|
|
327
|
+
const mergedData = Object.assign(Object.assign({}, dataAttributes), { id,
|
|
329
328
|
name,
|
|
330
329
|
classes,
|
|
331
330
|
textContent,
|
|
332
|
-
href,
|
|
333
|
-
tagName: elementType,
|
|
334
|
-
role,
|
|
331
|
+
href, tagName: elementType, role,
|
|
335
332
|
parentElementId,
|
|
336
|
-
|
|
337
|
-
trackEvent("CLICK", {
|
|
338
|
-
click: {
|
|
339
|
-
data: mergedData,
|
|
340
|
-
value,
|
|
341
|
-
},
|
|
342
|
-
});
|
|
333
|
+
value });
|
|
334
|
+
trackEvent("CLICK", { element: mergedData });
|
|
343
335
|
}
|
|
344
336
|
}
|
|
345
337
|
function hookTrackers() {
|
|
@@ -459,6 +451,10 @@ function loadAnalytics(config) {
|
|
|
459
451
|
console.log("[ANALYTICS] Logging page load");
|
|
460
452
|
trackEvent("PAGE");
|
|
461
453
|
});
|
|
454
|
+
window.addEventListener("popstate", (event) => {
|
|
455
|
+
const url = window.location.href;
|
|
456
|
+
trackEvent("NAV", { url });
|
|
457
|
+
});
|
|
462
458
|
}
|
|
463
459
|
else {
|
|
464
460
|
console.warn("[ANALYTICS] Analytics blocked by client, or disabled by configuration!");
|