@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.
@@ -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] Display Tracker Popup");
392
- CONFIG.showPopUp && showTrackingPopup();
393
- console.log("[ANALYTICS] Hook Event Trackers");
394
- hookTrackers();
395
- console.log("[ANALYTICS] Hook Handlers to flush events (use when submisstionStrategy is configures as \"DEFER\"");
396
- hookFlushHandlers(CONFIG.submissionStrategy);
397
- console.log("[ANALYTICS] Find User Location Details");
398
- populateLocationDetails();
399
- console.log("[ANALYTICS] Initiate Session and Anonymous User ID");
400
- const anonId = generateAnonymousId();
401
- console.log("Tracking User as", anonId);
402
- startSession();
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
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@armco/analytics",
3
- "version": "0.0.11",
3
+ "version": "0.1.0",
4
4
  "description": "Browser Based Analytics interceptor for configured events",
5
5
  "main": "index.js",
6
6
  "type": "module",