@armco/analytics 0.0.11 → 0.1.0
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 +22 -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;
|
|
@@ -377,9 +377,11 @@ function showTrackingPopup() {
|
|
|
377
377
|
});
|
|
378
378
|
}
|
|
379
379
|
function init() {
|
|
380
|
+
var _a;
|
|
380
381
|
try {
|
|
381
382
|
environment = getEnvironmentType();
|
|
382
383
|
console.log("[ANALYTICS] Loading Configuration");
|
|
384
|
+
console.log("[ANALYTICS] Environment: ", (_a = process.env) === null || _a === void 0 ? void 0 : _a.NODE_ENV);
|
|
383
385
|
loadConfiguration()
|
|
384
386
|
.then((config) => __awaiter(this, void 0, void 0, function* () {
|
|
385
387
|
CONFIG = config;
|
|
@@ -388,18 +390,25 @@ function init() {
|
|
|
388
390
|
apiKey = CONFIG.apiKey || null;
|
|
389
391
|
analyticsEndpoint = CONFIG.analyticsEndpoint || null;
|
|
390
392
|
hostProjectName = CONFIG.hostProjectName || (yield getHostProjectName()) || null;
|
|
391
|
-
console.log("[ANALYTICS]
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
393
|
+
console.log("[ANALYTICS] Check if Analytics enabled");
|
|
394
|
+
enabled = isEnabled();
|
|
395
|
+
if (enabled) {
|
|
396
|
+
console.log("[ANALYTICS] Display Tracker Popup");
|
|
397
|
+
CONFIG.showPopUp && showTrackingPopup();
|
|
398
|
+
console.log("[ANALYTICS] Hook Event Trackers");
|
|
399
|
+
hookTrackers();
|
|
400
|
+
console.log("[ANALYTICS] Hook Handlers to flush events (use when submissionStrategy is configured as \"DEFER\"");
|
|
401
|
+
hookFlushHandlers(CONFIG.submissionStrategy);
|
|
402
|
+
console.log("[ANALYTICS] Find User Location Details");
|
|
403
|
+
populateLocationDetails();
|
|
404
|
+
console.log("[ANALYTICS] Initiate Session and Anonymous User ID");
|
|
405
|
+
const anonId = generateAnonymousId();
|
|
406
|
+
console.log("Tracking User as", anonId);
|
|
407
|
+
startSession();
|
|
408
|
+
}
|
|
409
|
+
else {
|
|
410
|
+
console.warn("[ANALYTICS] Analytics blocked by client, or disabled by configuration!");
|
|
411
|
+
}
|
|
403
412
|
}
|
|
404
413
|
}));
|
|
405
414
|
}
|