@armco/analytics 0.0.2 → 0.0.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/dist/analytics.js +18 -2
- package/package.json +1 -1
package/dist/analytics.js
CHANGED
|
@@ -256,7 +256,10 @@ function hookTrackers() {
|
|
|
256
256
|
if (environment === "browser") {
|
|
257
257
|
const TRACK_EVENTS = (CONFIG === null || CONFIG === void 0 ? void 0 : CONFIG.trackEvents) || ["click", "submit", "select-change"];
|
|
258
258
|
if (TRACK_EVENTS.indexOf("click") > -1) {
|
|
259
|
-
|
|
259
|
+
console.log("[ANALYTICS] Attaching Click handlers");
|
|
260
|
+
const clickables = Array.from(document.querySelectorAll('*'));
|
|
261
|
+
console.log("[ANALYTICS] Found " + clickables.length + " items that can be clicked!");
|
|
262
|
+
clickables
|
|
260
263
|
.filter((element) => {
|
|
261
264
|
return element.tagName === "BUTTON" ||
|
|
262
265
|
element.tagName === "A" ||
|
|
@@ -291,8 +294,10 @@ function hookTrackers() {
|
|
|
291
294
|
});
|
|
292
295
|
});
|
|
293
296
|
});
|
|
297
|
+
console.log("[ANALYTICS] Click handlers Attached");
|
|
294
298
|
}
|
|
295
299
|
if (TRACK_EVENTS.indexOf("submit") > -1) {
|
|
300
|
+
console.log("[ANALYTICS] Attaching Submit handlers");
|
|
296
301
|
document.addEventListener('submit', event => {
|
|
297
302
|
const formElement = event.target;
|
|
298
303
|
trackEvent('SUBMIT', {
|
|
@@ -302,8 +307,10 @@ function hookTrackers() {
|
|
|
302
307
|
}
|
|
303
308
|
});
|
|
304
309
|
});
|
|
310
|
+
console.log("[ANALYTICS] Submit handlers attached");
|
|
305
311
|
}
|
|
306
312
|
if (TRACK_EVENTS.indexOf("select-change") > -1) {
|
|
313
|
+
console.log("[ANALYTICS] Attaching Select OnChange handlers");
|
|
307
314
|
document.addEventListener('change', (event) => {
|
|
308
315
|
const target = event.target;
|
|
309
316
|
if (target.tagName === 'SELECT') {
|
|
@@ -312,6 +319,7 @@ function hookTrackers() {
|
|
|
312
319
|
trackEvent('SELECT_CHANGE', { value: selectedOptionValue, label: selectedOptionLabel });
|
|
313
320
|
}
|
|
314
321
|
});
|
|
322
|
+
console.log("[ANALYTICS] Select OnChange handlers attached");
|
|
315
323
|
}
|
|
316
324
|
}
|
|
317
325
|
}
|
|
@@ -353,18 +361,26 @@ function showTrackingPopup() {
|
|
|
353
361
|
function init() {
|
|
354
362
|
try {
|
|
355
363
|
environment = getEnvironmentType();
|
|
364
|
+
console.log("[ANALYTICS] Loading Configuration");
|
|
356
365
|
loadConfiguration()
|
|
357
366
|
.then((config) => __awaiter(this, void 0, void 0, function* () {
|
|
358
367
|
CONFIG = config;
|
|
359
368
|
if (CONFIG) {
|
|
369
|
+
console.log("[ANALYTICS] Configuration loaded");
|
|
360
370
|
apiKey = CONFIG.apiKey || null;
|
|
361
371
|
analyticsEndpoint = CONFIG.analyticsEndpoint || null;
|
|
362
372
|
hostProjectName = CONFIG.hostProjectName || (yield getHostProjectName()) || null;
|
|
373
|
+
console.log("[ANALYTICS] Display Tracker Popup");
|
|
363
374
|
showTrackingPopup();
|
|
375
|
+
console.log("[ANALYTICS] Hook Event Trackers");
|
|
364
376
|
hookTrackers();
|
|
377
|
+
console.log("[ANALYTICS] Hook Handlers to flush events (use when submisstionStrategy is configures as \"DEFER\"");
|
|
365
378
|
hookFlushHandlers(CONFIG.submissionStrategy);
|
|
379
|
+
console.log("[ANALYTICS] Find User Location Details");
|
|
366
380
|
populateLocationDetails();
|
|
367
|
-
|
|
381
|
+
console.log("[ANALYTICS] Initiate Session and Anonymous User ID");
|
|
382
|
+
const anonId = generateAnonymousId();
|
|
383
|
+
console.log("Tracking User as", anonId);
|
|
368
384
|
startSession();
|
|
369
385
|
}
|
|
370
386
|
}));
|