@microsoft/applicationinsights-analytics-js 3.0.0-beta.2303-06 → 3.0.0-beta.2303-10

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.
@@ -6,8 +6,9 @@ import {
6
6
  utlCanUseSessionStorage, utlGetSessionStorage, utlRemoveSessionStorage, utlSetSessionStorage
7
7
  } from "@microsoft/applicationinsights-common";
8
8
  import {
9
- IDiagnosticLogger, _warnToConsole, dateNow, dumpObj, getJSON, hasJSON, objDefineAccessors, throwError
9
+ IDiagnosticLogger, _warnToConsole, dateNow, dumpObj, getJSON, hasJSON, throwError
10
10
  } from "@microsoft/applicationinsights-core-js";
11
+ import { objDefine } from "@nevware21/ts-utils";
11
12
 
12
13
  /**
13
14
  * Used to track page visit durations
@@ -47,38 +48,23 @@ export class PageVisitTimeManager {
47
48
  let prevPageVisitData: PageVisitData = null;
48
49
  try {
49
50
  prevPageVisitData = stopPageVisitTimer();
50
- startPageVisitTimer(pageName, pageUrl);
51
-
52
- } catch (e) {
53
- _warnToConsole(logger, "Call to restart failed: " + dumpObj(e));
54
- prevPageVisitData = null;
55
- }
56
-
57
- return prevPageVisitData;
58
- }
59
-
60
- /**
61
- * Starts timing visit duration of pageName
62
- * @param pageName
63
- * @returns {}
64
- */
65
- function startPageVisitTimer(pageName: string, pageUrl: string) {
66
- try {
67
51
  if (utlCanUseSessionStorage()) {
68
52
  if (utlGetSessionStorage(logger, prevPageVisitDataKeyName) != null) {
69
53
  throwError("Cannot call startPageVisit consecutively without first calling stopPageVisit");
70
54
  }
71
55
 
72
- const currPageVisitData = new PageVisitData(pageName, pageUrl);
73
- const currPageVisitDataStr = getJSON().stringify(currPageVisitData);
56
+ const currPageVisitDataStr = getJSON().stringify(new PageVisitData(pageName, pageUrl));
74
57
  utlSetSessionStorage(logger, prevPageVisitDataKeyName, currPageVisitDataStr);
75
58
  }
59
+
76
60
  } catch (e) {
77
- // TODO: Remove this catch in next phase, since if start is called twice in a row the exception needs to be propagated out
78
- _warnToConsole(logger, "Call to start failed: " + dumpObj(e));
61
+ _warnToConsole(logger, "Call to restart failed: " + dumpObj(e));
62
+ prevPageVisitData = null;
79
63
  }
64
+
65
+ return prevPageVisitData;
80
66
  }
81
-
67
+
82
68
  /**
83
69
  * Stops timing of current page, if exists.
84
70
  * @returns {PageVisitData} Page visit data (including duration) of pageName from call to start, if exists. Null if not.
@@ -112,8 +98,8 @@ export class PageVisitTimeManager {
112
98
  }
113
99
 
114
100
  // For backward compatibility
115
- objDefineAccessors(_self, "_logger", () => logger);
116
- objDefineAccessors(_self, "pageVisitTimeTrackingHandler", () => pageVisitTimeTrackingHandler);
101
+ objDefine<any>(_self, "_logger", { g: () => logger });
102
+ objDefine<any>(_self, "pageVisitTimeTrackingHandler", { g: () => pageVisitTimeTrackingHandler});
117
103
  });
118
104
  }
119
105