@armco/analytics 0.0.11 → 0.0.12
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.d.ts +1 -1
- package/dist/analytics.js +20 -13
- package/package.json +1 -1
package/dist/analytics.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { startSession, getSessionId } from "./session";
|
|
2
2
|
import { User, Event } from "./index.d";
|
|
3
|
-
declare let enabled: boolean;
|
|
3
|
+
declare let enabled: boolean | null;
|
|
4
4
|
declare function loadConfiguration(): Promise<any>;
|
|
5
5
|
declare function getEnvironmentType(): 'browser' | 'node' | 'unknown';
|
|
6
6
|
export declare function sendBulkData(data: Event[], callback?: Function): Promise<void>;
|
package/dist/analytics.js
CHANGED
|
@@ -19,11 +19,11 @@ import { hookFlushHandlers, queueEvent } from './flush';
|
|
|
19
19
|
const tsConfigPath = getEnvironmentType() === "node" ? path.resolve(process.cwd(), 'tsconfig.json') : "../../../../tsConfig.json";
|
|
20
20
|
const packageJsonPath = getEnvironmentType() === "node" ? path.resolve(process.cwd(), 'package.json') : "../../../../package.json";
|
|
21
21
|
let ar_anonymous_id;
|
|
22
|
-
let enabled = isEnabled();
|
|
23
22
|
let user = null;
|
|
24
23
|
let apiKey = null;
|
|
25
24
|
let analyticsEndpoint;
|
|
26
25
|
let hostProjectName = null;
|
|
26
|
+
let enabled = null;
|
|
27
27
|
const CONFIG_FILE_NAME = "analyticsrc";
|
|
28
28
|
let region;
|
|
29
29
|
let address;
|
|
@@ -388,18 +388,25 @@ function init() {
|
|
|
388
388
|
apiKey = CONFIG.apiKey || null;
|
|
389
389
|
analyticsEndpoint = CONFIG.analyticsEndpoint || null;
|
|
390
390
|
hostProjectName = CONFIG.hostProjectName || (yield getHostProjectName()) || null;
|
|
391
|
-
console.log("[ANALYTICS]
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
391
|
+
console.log("[ANALYTICS] Check if Analytics enabled");
|
|
392
|
+
enabled = isEnabled();
|
|
393
|
+
if (enabled) {
|
|
394
|
+
console.log("[ANALYTICS] Display Tracker Popup");
|
|
395
|
+
CONFIG.showPopUp && showTrackingPopup();
|
|
396
|
+
console.log("[ANALYTICS] Hook Event Trackers");
|
|
397
|
+
hookTrackers();
|
|
398
|
+
console.log("[ANALYTICS] Hook Handlers to flush events (use when submissionStrategy is configured as \"DEFER\"");
|
|
399
|
+
hookFlushHandlers(CONFIG.submissionStrategy);
|
|
400
|
+
console.log("[ANALYTICS] Find User Location Details");
|
|
401
|
+
populateLocationDetails();
|
|
402
|
+
console.log("[ANALYTICS] Initiate Session and Anonymous User ID");
|
|
403
|
+
const anonId = generateAnonymousId();
|
|
404
|
+
console.log("Tracking User as", anonId);
|
|
405
|
+
startSession();
|
|
406
|
+
}
|
|
407
|
+
else {
|
|
408
|
+
console.warn("[ANALYTICS] Analytics blocked by client, or disabled by configuration!");
|
|
409
|
+
}
|
|
403
410
|
}
|
|
404
411
|
}));
|
|
405
412
|
}
|