@microsoft/applicationinsights-analytics-js 3.0.0-beta.2210-01 → 3.0.0-beta.2210-03
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/browser/applicationinsights-analytics-js.integrity.json +9 -9
- package/browser/applicationinsights-analytics-js.js +1013 -542
- package/browser/applicationinsights-analytics-js.js.map +1 -1
- package/browser/applicationinsights-analytics-js.min.js +2 -2
- package/browser/applicationinsights-analytics-js.min.js.map +1 -1
- package/dist/applicationinsights-analytics-js.api.json +5 -43
- package/dist/applicationinsights-analytics-js.api.md +2 -6
- package/dist/applicationinsights-analytics-js.d.ts +15 -18
- package/dist/applicationinsights-analytics-js.js +1013 -542
- package/dist/applicationinsights-analytics-js.js.map +1 -1
- package/dist/applicationinsights-analytics-js.min.js +2 -2
- package/dist/applicationinsights-analytics-js.min.js.map +1 -1
- package/dist/applicationinsights-analytics-js.rollup.d.ts +15 -18
- package/dist-esm/JavaScriptSDK/AnalyticsPlugin.js +155 -148
- package/dist-esm/JavaScriptSDK/AnalyticsPlugin.js.map +1 -1
- package/dist-esm/JavaScriptSDK/Telemetry/PageViewManager.js +14 -15
- package/dist-esm/JavaScriptSDK/Telemetry/PageViewManager.js.map +1 -1
- package/dist-esm/JavaScriptSDK/Telemetry/PageViewPerformanceManager.js +9 -10
- package/dist-esm/JavaScriptSDK/Telemetry/PageViewPerformanceManager.js.map +1 -1
- package/dist-esm/JavaScriptSDK/Telemetry/PageVisitTimeManager.js +8 -9
- package/dist-esm/JavaScriptSDK/Telemetry/PageVisitTimeManager.js.map +1 -1
- package/dist-esm/JavaScriptSDK/Timing.js +1 -1
- package/dist-esm/JavaScriptSDK.Interfaces/ITelemetryConfig.js +1 -1
- package/dist-esm/__DynamicConstants.js +16 -24
- package/dist-esm/__DynamicConstants.js.map +1 -1
- package/dist-esm/applicationinsights-analytics-js.js +1 -1
- package/package.json +6 -6
- package/src/JavaScriptSDK/AnalyticsPlugin.ts +177 -175
- package/src/JavaScriptSDK/Telemetry/PageVisitTimeManager.ts +4 -4
- package/src/__DynamicConstants.ts +15 -23
- package/types/JavaScriptSDK/AnalyticsPlugin.d.ts +14 -17
- package/types/JavaScriptSDK/Telemetry/PageVisitTimeManager.d.ts +3 -3
- package/types/__DynamicConstants.d.ts +15 -23
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Application Insights JavaScript SDK - Web Analytics, 3.0.0-beta.2210-
|
|
2
|
+
* Application Insights JavaScript SDK - Web Analytics, 3.0.0-beta.2210-03
|
|
3
3
|
* Copyright (c) Microsoft and contributors. All rights reserved.
|
|
4
4
|
*/
|
|
5
5
|
/**
|
|
6
6
|
* ApplicationInsights.ts
|
|
7
7
|
* @copyright Microsoft 2018
|
|
8
8
|
*/
|
|
9
|
+
var _a;
|
|
9
10
|
import { __assignFn as __assign, __extendsFn as __extends } from "@microsoft/applicationinsights-shims";
|
|
10
11
|
import dynamicProto from "@microsoft/dynamicproto-js";
|
|
11
12
|
import { AnalyticsPluginIdentifier, Event as EventTelemetry, Exception, Metric, PageView, PageViewPerformance, PropertiesPluginIdentifier, RemoteDependencyData, Trace, createDistributedTraceContextFromTrace, createDomEvent, createTelemetryItem, dataSanitizeString, isCrossOriginError, strNotSpecified, stringToBoolOrDefault, utlDisableStorage, utlEnableStorage } from "@microsoft/applicationinsights-common";
|
|
12
|
-
import { BaseTelemetryPlugin, InstrumentEvent, arrForEach, createProcessTelemetryContext, createUniqueNamespace, dumpObj, eventOff, eventOn, generateW3CId, getDocument, getExceptionName, getHistory, getLocation, getWindow, hasHistory, hasWindow, isFunction, isNullOrUndefined, isString, isUndefined, mergeEvtNamespace, objDefineAccessors,
|
|
13
|
-
import {
|
|
13
|
+
import { BaseTelemetryPlugin, InstrumentEvent, arrForEach, createProcessTelemetryContext, createUniqueNamespace, dumpObj, eventOff, eventOn, generateW3CId, getDocument, getExceptionName, getHistory, getLocation, getWindow, hasHistory, hasWindow, isFunction, isNullOrUndefined, isString, isUndefined, mergeEvtNamespace, objDefineAccessors, onConfigChange, safeGetCookieMgr, strUndefined, throwError } from "@microsoft/applicationinsights-core-js";
|
|
14
|
+
import { objDeepFreeze, objDefineProp } from "@nevware21/ts-utils";
|
|
15
|
+
import { _DYN_ADD_TELEMETRY_INITIA7, _DYN_AUTO_UNHANDLED_PROMI8, _DYN_COLUMN_NUMBER, _DYN_CORE, _DYN_DATA_TYPE, _DYN_DIAG_LOG, _DYN_ENVELOPE_TYPE, _DYN_ERROR, _DYN_ERROR_SRC, _DYN_EXCEPTION, _DYN_HREF, _DYN_IS_STORAGE_USE_DISAB0, _DYN_LENGTH, _DYN_LINE_NUMBER, _DYN_MESSAGE, _DYN_POPULATE_PAGE_VIEW_P4, _DYN_SEND_EXCEPTION_INTER5, _DYN_SEND_PAGE_VIEW_INTER2, _DYN_SEND_PAGE_VIEW_PERFO3, _DYN_TO_STRING, _DYN_TRACK, _DYN_TRACK_PAGE_VIEW, _DYN_TRACK_PREVIOUS_PAGE_1, _DYN__ADD_HOOK, _DYN__CREATE_AUTO_EXCEPTI6, _DYN__ONERROR } from "../__DynamicConstants";
|
|
14
16
|
import { PageViewManager } from "./Telemetry/PageViewManager";
|
|
15
17
|
import { PageViewPerformanceManager } from "./Telemetry/PageViewPerformanceManager";
|
|
16
18
|
import { PageVisitTimeManager } from "./Telemetry/PageVisitTimeManager";
|
|
@@ -33,41 +35,39 @@ function _getReason(error) {
|
|
|
33
35
|
return error || "";
|
|
34
36
|
}
|
|
35
37
|
var MinMilliSeconds = 60000;
|
|
36
|
-
|
|
38
|
+
var defaultValues = objDeepFreeze((_a = {
|
|
39
|
+
sessionRenewalMs: { set: _chkConfigMilliseconds, v: 30 * 60 * 1000 },
|
|
40
|
+
sessionExpirationMs: { set: _chkConfigMilliseconds, v: 24 * 60 * 60 * 1000 },
|
|
41
|
+
disableExceptionTracking: { set: stringToBoolOrDefault },
|
|
42
|
+
autoTrackPageVisitTime: { set: stringToBoolOrDefault },
|
|
43
|
+
overridePageViewDuration: { set: stringToBoolOrDefault },
|
|
44
|
+
enableUnhandledPromiseRejectionTracking: { set: stringToBoolOrDefault }
|
|
45
|
+
},
|
|
46
|
+
_a[_DYN_AUTO_UNHANDLED_PROMI8 /* @min:autoUnhandledPromiseInstrumented */] = false,
|
|
47
|
+
_a.samplingPercentage = { isVal: _chkSampling, v: 100 },
|
|
48
|
+
_a.isStorageUseDisabled = { set: stringToBoolOrDefault },
|
|
49
|
+
_a.isBrowserLinkTrackingEnabled = { set: stringToBoolOrDefault },
|
|
50
|
+
_a.enableAutoRouteTracking = { set: stringToBoolOrDefault },
|
|
51
|
+
_a.namePrefix = "",
|
|
52
|
+
_a.enableDebug = { set: stringToBoolOrDefault },
|
|
53
|
+
_a.disableFlushOnBeforeUnload = { set: stringToBoolOrDefault },
|
|
54
|
+
_a.disableFlushOnUnload = { set: stringToBoolOrDefault, fb: "disableFlushOnBeforeUnload" },
|
|
55
|
+
_a));
|
|
56
|
+
function _chkConfigMilliseconds(value, defValue) {
|
|
37
57
|
value = value || defValue;
|
|
38
58
|
if (value < MinMilliSeconds) {
|
|
39
59
|
value = MinMilliSeconds;
|
|
40
60
|
}
|
|
41
|
-
return value;
|
|
61
|
+
return +value;
|
|
42
62
|
}
|
|
43
|
-
function
|
|
44
|
-
|
|
45
|
-
config = {};
|
|
46
|
-
}
|
|
47
|
-
// set default values
|
|
48
|
-
config.sessionRenewalMs = _configMilliseconds(config.sessionRenewalMs, 30 * 60 * 1000);
|
|
49
|
-
config.sessionExpirationMs = _configMilliseconds(config.sessionExpirationMs, 24 * 60 * 60 * 1000);
|
|
50
|
-
config[_DYN_DISABLE_EXCEPTION_TR0 /* @min:%2edisableExceptionTracking */] = stringToBoolOrDefault(config[_DYN_DISABLE_EXCEPTION_TR0 /* @min:%2edisableExceptionTracking */]);
|
|
51
|
-
config[_DYN_AUTO_TRACK_PAGE_VISI1 /* @min:%2eautoTrackPageVisitTime */] = stringToBoolOrDefault(config[_DYN_AUTO_TRACK_PAGE_VISI1 /* @min:%2eautoTrackPageVisitTime */]);
|
|
52
|
-
config[_DYN_OVERRIDE_PAGE_VIEW_D2 /* @min:%2eoverridePageViewDuration */] = stringToBoolOrDefault(config[_DYN_OVERRIDE_PAGE_VIEW_D2 /* @min:%2eoverridePageViewDuration */]);
|
|
53
|
-
config[_DYN_ENABLE_UNHANDLED_PRO3 /* @min:%2eenableUnhandledPromiseRejectionTracking */] = stringToBoolOrDefault(config[_DYN_ENABLE_UNHANDLED_PRO3 /* @min:%2eenableUnhandledPromiseRejectionTracking */]);
|
|
54
|
-
if (isNaN(config[_DYN_SAMPLING_PERCENTAGE /* @min:%2esamplingPercentage */]) || config[_DYN_SAMPLING_PERCENTAGE /* @min:%2esamplingPercentage */] <= 0 || config[_DYN_SAMPLING_PERCENTAGE /* @min:%2esamplingPercentage */] >= 100) {
|
|
55
|
-
config[_DYN_SAMPLING_PERCENTAGE /* @min:%2esamplingPercentage */] = 100;
|
|
56
|
-
}
|
|
57
|
-
config[_DYN_IS_STORAGE_USE_DISAB4 /* @min:%2eisStorageUseDisabled */] = stringToBoolOrDefault(config[_DYN_IS_STORAGE_USE_DISAB4 /* @min:%2eisStorageUseDisabled */]);
|
|
58
|
-
config[_DYN_IS_BROWSER_LINK_TRAC5 /* @min:%2eisBrowserLinkTrackingEnabled */] = stringToBoolOrDefault(config[_DYN_IS_BROWSER_LINK_TRAC5 /* @min:%2eisBrowserLinkTrackingEnabled */]);
|
|
59
|
-
config[_DYN_ENABLE_AUTO_ROUTE_TR6 /* @min:%2eenableAutoRouteTracking */] = stringToBoolOrDefault(config[_DYN_ENABLE_AUTO_ROUTE_TR6 /* @min:%2eenableAutoRouteTracking */]);
|
|
60
|
-
config[_DYN_NAME_PREFIX /* @min:%2enamePrefix */] = config[_DYN_NAME_PREFIX /* @min:%2enamePrefix */] || "";
|
|
61
|
-
config.enableDebug = stringToBoolOrDefault(config.enableDebug);
|
|
62
|
-
config[_DYN_DISABLE_FLUSH_ON_BEF7 /* @min:%2edisableFlushOnBeforeUnload */] = stringToBoolOrDefault(config[_DYN_DISABLE_FLUSH_ON_BEF7 /* @min:%2edisableFlushOnBeforeUnload */]);
|
|
63
|
-
config.disableFlushOnUnload = stringToBoolOrDefault(config.disableFlushOnUnload, config[_DYN_DISABLE_FLUSH_ON_BEF7 /* @min:%2edisableFlushOnBeforeUnload */]);
|
|
64
|
-
return config;
|
|
63
|
+
function _chkSampling(value) {
|
|
64
|
+
return !isNaN(value) && value > 0 && value <= 100;
|
|
65
65
|
}
|
|
66
66
|
function _updateStorageUsage(extConfig) {
|
|
67
67
|
// Not resetting the storage usage as someone may have manually called utlDisableStorage, so this will only
|
|
68
68
|
// reset based if the configuration option is provided
|
|
69
|
-
if (!isUndefined(extConfig[
|
|
70
|
-
if (extConfig[
|
|
69
|
+
if (!isUndefined(extConfig[_DYN_IS_STORAGE_USE_DISAB0 /* @min:%2eisStorageUseDisabled */])) {
|
|
70
|
+
if (extConfig[_DYN_IS_STORAGE_USE_DISAB0 /* @min:%2eisStorageUseDisabled */]) {
|
|
71
71
|
utlDisableStorage();
|
|
72
72
|
}
|
|
73
73
|
else {
|
|
@@ -96,6 +96,8 @@ var AnalyticsPlugin = /** @class */ (function (_super) {
|
|
|
96
96
|
var _autoExceptionInstrumented;
|
|
97
97
|
var _enableUnhandledPromiseRejectionTracking;
|
|
98
98
|
var _autoUnhandledPromiseInstrumented;
|
|
99
|
+
var _extConfig;
|
|
100
|
+
var _autoTrackPageVisitTime;
|
|
99
101
|
// Counts number of trackAjax invocations.
|
|
100
102
|
// By default we only monitor X ajax call per view to avoid too much load.
|
|
101
103
|
// Default value is set in config.
|
|
@@ -106,7 +108,7 @@ var AnalyticsPlugin = /** @class */ (function (_super) {
|
|
|
106
108
|
var _currUri;
|
|
107
109
|
var _evtNamespace;
|
|
108
110
|
dynamicProto(AnalyticsPlugin, _this, function (_self, _base) {
|
|
109
|
-
var _addHook = _base
|
|
111
|
+
var _addHook = _base[_DYN__ADD_HOOK /* @min:%2e_addHook */];
|
|
110
112
|
_initDefaults();
|
|
111
113
|
_self.getCookieMgr = function () {
|
|
112
114
|
return safeGetCookieMgr(_self[_DYN_CORE /* @min:%2ecore */]);
|
|
@@ -151,7 +153,7 @@ var AnalyticsPlugin = /** @class */ (function (_super) {
|
|
|
151
153
|
};
|
|
152
154
|
/**
|
|
153
155
|
* @description Log a diagnostic message
|
|
154
|
-
* @param
|
|
156
|
+
* @param trace
|
|
155
157
|
* @param ICustomProperties.
|
|
156
158
|
* @memberof ApplicationInsights
|
|
157
159
|
*/
|
|
@@ -170,8 +172,8 @@ var AnalyticsPlugin = /** @class */ (function (_super) {
|
|
|
170
172
|
* use the name and average fields of {@link IMetricTelemetry}. If you take measurements
|
|
171
173
|
* frequently, you can reduce the telemetry bandwidth by aggregating multiple measurements
|
|
172
174
|
* and sending the resulting average at intervals
|
|
173
|
-
* @param
|
|
174
|
-
* @param
|
|
175
|
+
* @param metric - input object argument. Only name and average are mandatory.
|
|
176
|
+
* @param } customProperties additional data used to filter metrics in the
|
|
175
177
|
* portal. Defaults to empty.
|
|
176
178
|
* @memberof ApplicationInsights
|
|
177
179
|
*/
|
|
@@ -186,16 +188,16 @@ var AnalyticsPlugin = /** @class */ (function (_super) {
|
|
|
186
188
|
};
|
|
187
189
|
/**
|
|
188
190
|
* Logs that a page or other item was viewed.
|
|
189
|
-
* @param IPageViewTelemetry The string you used as the name in startTrackPage. Defaults to the document title.
|
|
190
|
-
* @param customProperties Additional data used to filter events and metrics. Defaults to empty.
|
|
191
|
+
* @param IPageViewTelemetry - The string you used as the name in startTrackPage. Defaults to the document title.
|
|
192
|
+
* @param customProperties - Additional data used to filter events and metrics. Defaults to empty.
|
|
191
193
|
* If a user wants to provide duration for pageLoad, it'll have to be in pageView.properties.duration
|
|
192
194
|
*/
|
|
193
195
|
_self[_DYN_TRACK_PAGE_VIEW /* @min:%2etrackPageView */] = function (pageView, customProperties) {
|
|
194
196
|
try {
|
|
195
197
|
var inPv = pageView || {};
|
|
196
198
|
_pageViewManager[_DYN_TRACK_PAGE_VIEW /* @min:%2etrackPageView */](inPv, __assign(__assign(__assign({}, inPv.properties), inPv.measurements), customProperties));
|
|
197
|
-
if (
|
|
198
|
-
_pageVisitTimeManager[
|
|
199
|
+
if (_autoTrackPageVisitTime) {
|
|
200
|
+
_pageVisitTimeManager[_DYN_TRACK_PREVIOUS_PAGE_1 /* @min:%2etrackPreviousPageVisit */](inPv.name, inPv.uri);
|
|
199
201
|
}
|
|
200
202
|
}
|
|
201
203
|
catch (e) {
|
|
@@ -204,11 +206,11 @@ var AnalyticsPlugin = /** @class */ (function (_super) {
|
|
|
204
206
|
};
|
|
205
207
|
/**
|
|
206
208
|
* Create a page view telemetry item and send it to the SDK pipeline through the core.track API
|
|
207
|
-
* @param pageView Page view item to be sent
|
|
208
|
-
* @param properties Custom properties (Part C) that a user can add to the telemetry item
|
|
209
|
-
* @param systemProperties System level properties (Part A) that a user can add to the telemetry item
|
|
209
|
+
* @param pageView - Page view item to be sent
|
|
210
|
+
* @param properties - Custom properties (Part C) that a user can add to the telemetry item
|
|
211
|
+
* @param systemProperties - System level properties (Part A) that a user can add to the telemetry item
|
|
210
212
|
*/
|
|
211
|
-
_self[
|
|
213
|
+
_self[_DYN_SEND_PAGE_VIEW_INTER2 /* @min:%2esendPageViewInternal */] = function (pageView, properties, systemProperties) {
|
|
212
214
|
var doc = getDocument();
|
|
213
215
|
if (doc) {
|
|
214
216
|
pageView.refUri = pageView.refUri === undefined ? doc.referrer : pageView.refUri;
|
|
@@ -223,7 +225,7 @@ var AnalyticsPlugin = /** @class */ (function (_super) {
|
|
|
223
225
|
* @param pageViewPerformance
|
|
224
226
|
* @param properties
|
|
225
227
|
*/
|
|
226
|
-
_self[
|
|
228
|
+
_self[_DYN_SEND_PAGE_VIEW_PERFO3 /* @min:%2esendPageViewPerformanceInternal */] = function (pageViewPerformance, properties, systemProperties) {
|
|
227
229
|
var telemetryItem = createTelemetryItem(pageViewPerformance, PageViewPerformance[_DYN_DATA_TYPE /* @min:%2edataType */], PageViewPerformance[_DYN_ENVELOPE_TYPE /* @min:%2eenvelopeType */], _self[_DYN_DIAG_LOG /* @min:%2ediagLog */](), properties, systemProperties);
|
|
228
230
|
_self[_DYN_CORE /* @min:%2ecore */][_DYN_TRACK /* @min:%2etrack */](telemetryItem);
|
|
229
231
|
};
|
|
@@ -235,8 +237,8 @@ var AnalyticsPlugin = /** @class */ (function (_super) {
|
|
|
235
237
|
_self.trackPageViewPerformance = function (pageViewPerformance, customProperties) {
|
|
236
238
|
var inPvp = pageViewPerformance || {};
|
|
237
239
|
try {
|
|
238
|
-
_pageViewPerformanceManager[
|
|
239
|
-
_self[
|
|
240
|
+
_pageViewPerformanceManager[_DYN_POPULATE_PAGE_VIEW_P4 /* @min:%2epopulatePageViewPerformanceEvent */](inPvp);
|
|
241
|
+
_self[_DYN_SEND_PAGE_VIEW_PERFO3 /* @min:%2esendPageViewPerformanceInternal */](inPvp, customProperties);
|
|
240
242
|
}
|
|
241
243
|
catch (e) {
|
|
242
244
|
_throwInternal(1 /* eLoggingSeverity.CRITICAL */, 37 /* _eInternalMessageId.TrackPVFailed */, "trackPageViewPerformance failed, page view will not be collected: " + getExceptionName(e), { exception: dumpObj(e) });
|
|
@@ -246,7 +248,7 @@ var AnalyticsPlugin = /** @class */ (function (_super) {
|
|
|
246
248
|
* Starts the timer for tracking a page load time. Use this instead of `trackPageView` if you want to control when the page view timer starts and stops,
|
|
247
249
|
* but don't want to calculate the duration yourself. This method doesn't send any telemetry. Call `stopTrackPage` to log the end of the page view
|
|
248
250
|
* and send the event.
|
|
249
|
-
* @param name A string that idenfities this item, unique within this HTML document. Defaults to the document title.
|
|
251
|
+
* @param name - A string that idenfities this item, unique within this HTML document. Defaults to the document title.
|
|
250
252
|
*/
|
|
251
253
|
_self.startTrackPage = function (name) {
|
|
252
254
|
try {
|
|
@@ -279,8 +281,8 @@ var AnalyticsPlugin = /** @class */ (function (_super) {
|
|
|
279
281
|
url = loc && loc[_DYN_HREF /* @min:%2ehref */] || "";
|
|
280
282
|
}
|
|
281
283
|
_pageTracking.stop(name, url, properties, measurement);
|
|
282
|
-
if (
|
|
283
|
-
_pageVisitTimeManager[
|
|
284
|
+
if (_autoTrackPageVisitTime) {
|
|
285
|
+
_pageVisitTimeManager[_DYN_TRACK_PREVIOUS_PAGE_1 /* @min:%2etrackPreviousPageVisit */](name, url);
|
|
284
286
|
}
|
|
285
287
|
}
|
|
286
288
|
catch (e) {
|
|
@@ -293,7 +295,7 @@ var AnalyticsPlugin = /** @class */ (function (_super) {
|
|
|
293
295
|
* @param properties
|
|
294
296
|
* @param systemProperties
|
|
295
297
|
*/
|
|
296
|
-
_self[
|
|
298
|
+
_self[_DYN_SEND_EXCEPTION_INTER5 /* @min:%2esendExceptionInternal */] = function (exception, customProperties, systemProperties) {
|
|
297
299
|
var theError = exception[_DYN_EXCEPTION /* @min:%2eexception */] || exception[_DYN_ERROR /* @min:%2eerror */] || new Error(strNotSpecified);
|
|
298
300
|
var exceptionPartB = new Exception(_self[_DYN_DIAG_LOG /* @min:%2ediagLog */](), theError, exception.properties || customProperties, exception.measurements, exception.severityLevel, exception.id).toInterface();
|
|
299
301
|
var telemetryItem = createTelemetryItem(exceptionPartB, Exception[_DYN_DATA_TYPE /* @min:%2edataType */], Exception[_DYN_ENVELOPE_TYPE /* @min:%2eenvelopeType */], _self[_DYN_DIAG_LOG /* @min:%2ediagLog */](), customProperties, systemProperties);
|
|
@@ -302,8 +304,8 @@ var AnalyticsPlugin = /** @class */ (function (_super) {
|
|
|
302
304
|
/**
|
|
303
305
|
* Log an exception you have caught.
|
|
304
306
|
*
|
|
305
|
-
* @param
|
|
306
|
-
* @param
|
|
307
|
+
* @param exception - Object which contains exception to be sent
|
|
308
|
+
* @param } customProperties Additional data used to filter pages and metrics in the portal. Defaults to empty.
|
|
307
309
|
*
|
|
308
310
|
* Any property of type double will be considered a measurement, and will be treated by Application Insights as a metric.
|
|
309
311
|
* @memberof ApplicationInsights
|
|
@@ -313,7 +315,7 @@ var AnalyticsPlugin = /** @class */ (function (_super) {
|
|
|
313
315
|
exception[_DYN_EXCEPTION /* @min:%2eexception */] = exception[_DYN_ERROR /* @min:%2eerror */];
|
|
314
316
|
}
|
|
315
317
|
try {
|
|
316
|
-
_self[
|
|
318
|
+
_self[_DYN_SEND_EXCEPTION_INTER5 /* @min:%2esendExceptionInternal */](exception, customProperties);
|
|
317
319
|
}
|
|
318
320
|
catch (e) {
|
|
319
321
|
_throwInternal(1 /* eLoggingSeverity.CRITICAL */, 35 /* _eInternalMessageId.TrackExceptionFailed */, "trackException failed, exception will not be collected: " + getExceptionName(e), { exception: dumpObj(e) });
|
|
@@ -321,7 +323,7 @@ var AnalyticsPlugin = /** @class */ (function (_super) {
|
|
|
321
323
|
};
|
|
322
324
|
/**
|
|
323
325
|
* @description Custom error handler for Application Insights Analytics
|
|
324
|
-
* @param
|
|
326
|
+
* @param exception
|
|
325
327
|
* @memberof ApplicationInsights
|
|
326
328
|
*/
|
|
327
329
|
_self[_DYN__ONERROR /* @min:%2e_onerror */] = function (exception) {
|
|
@@ -345,7 +347,7 @@ var AnalyticsPlugin = /** @class */ (function (_super) {
|
|
|
345
347
|
message: exception[_DYN_MESSAGE /* @min:%2emessage */]
|
|
346
348
|
};
|
|
347
349
|
if (isCrossOriginError(exception.message, exception.url, exception.lineNumber, exception.columnNumber, exception[_DYN_ERROR /* @min:%2eerror */])) {
|
|
348
|
-
_sendCORSException(Exception[
|
|
350
|
+
_sendCORSException(Exception[_DYN__CREATE_AUTO_EXCEPTI6 /* @min:%2eCreateAutoException */]("Script error: The browser's same-origin policy prevents us from getting the details of this exception. Consider using the 'crossorigin' attribute.", url, exception[_DYN_LINE_NUMBER /* @min:%2elineNumber */] || 0, exception[_DYN_COLUMN_NUMBER /* @min:%2ecolumnNumber */] || 0, error, evt, null, errorSrc), properties);
|
|
349
351
|
}
|
|
350
352
|
else {
|
|
351
353
|
if (!exception[_DYN_ERROR_SRC /* @min:%2eerrorSrc */]) {
|
|
@@ -360,10 +362,10 @@ var AnalyticsPlugin = /** @class */ (function (_super) {
|
|
|
360
362
|
+ getExceptionName(e), { exception: dumpObj(e), errorString: errorString });
|
|
361
363
|
}
|
|
362
364
|
};
|
|
363
|
-
_self[
|
|
365
|
+
_self[_DYN_ADD_TELEMETRY_INITIA7 /* @min:%2eaddTelemetryInitializer */] = function (telemetryInitializer) {
|
|
364
366
|
if (_self[_DYN_CORE /* @min:%2ecore */]) {
|
|
365
367
|
// Just add to the core
|
|
366
|
-
return _self[_DYN_CORE /* @min:%2ecore */][
|
|
368
|
+
return _self[_DYN_CORE /* @min:%2ecore */][_DYN_ADD_TELEMETRY_INITIA7 /* @min:%2eaddTelemetryInitializer */](telemetryInitializer);
|
|
367
369
|
}
|
|
368
370
|
// Handle "pre-initialization" telemetry initializers (for backward compatibility)
|
|
369
371
|
if (!_preInitTelemetryInitializers) {
|
|
@@ -383,16 +385,14 @@ var AnalyticsPlugin = /** @class */ (function (_super) {
|
|
|
383
385
|
_evtNamespace = mergeEvtNamespace(createUniqueNamespace(_self.identifier), core.evtNamespace && core.evtNamespace());
|
|
384
386
|
if (_preInitTelemetryInitializers) {
|
|
385
387
|
arrForEach(_preInitTelemetryInitializers, function (initializer) {
|
|
386
|
-
core[
|
|
388
|
+
core[_DYN_ADD_TELEMETRY_INITIA7 /* @min:%2eaddTelemetryInitializer */](initializer);
|
|
387
389
|
});
|
|
388
390
|
_preInitTelemetryInitializers = null;
|
|
389
391
|
}
|
|
390
|
-
|
|
391
|
-
_updateStorageUsage(extConfig);
|
|
392
|
+
_populateDefaults(config);
|
|
392
393
|
_pageViewPerformanceManager = new PageViewPerformanceManager(_self[_DYN_CORE /* @min:%2ecore */]);
|
|
393
|
-
_pageViewManager = new PageViewManager(_this,
|
|
394
|
+
_pageViewManager = new PageViewManager(_this, _extConfig.overridePageViewDuration, _self[_DYN_CORE /* @min:%2ecore */], _pageViewPerformanceManager);
|
|
394
395
|
_pageVisitTimeManager = new PageVisitTimeManager(_self[_DYN_DIAG_LOG /* @min:%2ediagLog */](), function (pageName, pageUrl, pageVisitTime) { return trackPageVisitTime(pageName, pageUrl, pageVisitTime); });
|
|
395
|
-
_updateBrowserLinkTracking(extConfig, config);
|
|
396
396
|
_eventTracking = new Timing(_self[_DYN_DIAG_LOG /* @min:%2ediagLog */](), "trackEvent");
|
|
397
397
|
_eventTracking.action =
|
|
398
398
|
function (name, url, duration, properties, measurements) {
|
|
@@ -419,11 +419,11 @@ var AnalyticsPlugin = /** @class */ (function (_super) {
|
|
|
419
419
|
properties: properties,
|
|
420
420
|
measurements: measurements
|
|
421
421
|
};
|
|
422
|
-
_self[
|
|
422
|
+
_self[_DYN_SEND_PAGE_VIEW_INTER2 /* @min:%2esendPageViewInternal */](pageViewItem, properties);
|
|
423
423
|
};
|
|
424
424
|
if (hasWindow()) {
|
|
425
|
-
_updateExceptionTracking(
|
|
426
|
-
_updateLocationChange(
|
|
425
|
+
_updateExceptionTracking();
|
|
426
|
+
_updateLocationChange();
|
|
427
427
|
}
|
|
428
428
|
}
|
|
429
429
|
catch (e) {
|
|
@@ -439,30 +439,22 @@ var AnalyticsPlugin = /** @class */ (function (_super) {
|
|
|
439
439
|
_initDefaults();
|
|
440
440
|
};
|
|
441
441
|
function _populateDefaults(config) {
|
|
442
|
-
var ctx = createProcessTelemetryContext(null, config, _self[_DYN_CORE /* @min:%2ecore */]);
|
|
443
442
|
var identifier = _self.identifier;
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
});
|
|
455
|
-
}
|
|
456
|
-
return extConfig;
|
|
457
|
-
}
|
|
458
|
-
function _updateBrowserLinkTracking(extConfig, config) {
|
|
459
|
-
_isBrowserLinkTrackingEnabled = extConfig[_DYN_IS_BROWSER_LINK_TRAC5 /* @min:%2eisBrowserLinkTrackingEnabled */] || config[_DYN_IS_BROWSER_LINK_TRAC5 /* @min:%2eisBrowserLinkTrackingEnabled */];
|
|
460
|
-
_addDefaultTelemetryInitializers();
|
|
443
|
+
var core = _self[_DYN_CORE /* @min:%2ecore */];
|
|
444
|
+
_self[_DYN__ADD_HOOK /* @min:%2e_addHook */](onConfigChange(config, function () {
|
|
445
|
+
var ctx = createProcessTelemetryContext(null, config, core);
|
|
446
|
+
_extConfig = ctx.getExtCfg(identifier, defaultValues);
|
|
447
|
+
_autoTrackPageVisitTime = _extConfig.autoTrackPageVisitTime;
|
|
448
|
+
_updateStorageUsage(_extConfig);
|
|
449
|
+
// _updateBrowserLinkTracking
|
|
450
|
+
_isBrowserLinkTrackingEnabled = _extConfig.isBrowserLinkTrackingEnabled;
|
|
451
|
+
_addDefaultTelemetryInitializers();
|
|
452
|
+
}));
|
|
461
453
|
}
|
|
462
454
|
/**
|
|
463
455
|
* Log a page visit time
|
|
464
456
|
* @param pageName Name of page
|
|
465
|
-
* @param pageVisitDuration Duration of visit to the page in
|
|
457
|
+
* @param pageVisitDuration Duration of visit to the page in milliseconds
|
|
466
458
|
*/
|
|
467
459
|
function trackPageVisitTime(pageName, pageUrl, pageVisitTime) {
|
|
468
460
|
var properties = { PageName: pageName, PageUrl: pageUrl };
|
|
@@ -490,7 +482,7 @@ var AnalyticsPlugin = /** @class */ (function (_super) {
|
|
|
490
482
|
}
|
|
491
483
|
return true;
|
|
492
484
|
};
|
|
493
|
-
_self[
|
|
485
|
+
_self[_DYN__ADD_HOOK /* @min:%2e_addHook */](_self[_DYN_ADD_TELEMETRY_INITIA7 /* @min:%2eaddTelemetryInitializer */](dropBrowserLinkRequests));
|
|
494
486
|
_browserLinkInitializerAdded = true;
|
|
495
487
|
}
|
|
496
488
|
}
|
|
@@ -498,37 +490,41 @@ var AnalyticsPlugin = /** @class */ (function (_super) {
|
|
|
498
490
|
var telemetryItem = createTelemetryItem(exception, Exception[_DYN_DATA_TYPE /* @min:%2edataType */], Exception[_DYN_ENVELOPE_TYPE /* @min:%2eenvelopeType */], _self[_DYN_DIAG_LOG /* @min:%2ediagLog */](), properties);
|
|
499
491
|
_self[_DYN_CORE /* @min:%2ecore */][_DYN_TRACK /* @min:%2etrack */](telemetryItem);
|
|
500
492
|
}
|
|
501
|
-
function _updateExceptionTracking(
|
|
493
|
+
function _updateExceptionTracking() {
|
|
502
494
|
var _window = getWindow();
|
|
503
495
|
var locn = getLocation(true);
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
496
|
+
_self[_DYN__ADD_HOOK /* @min:%2e_addHook */](onConfigChange(_extConfig, function () {
|
|
497
|
+
_disableExceptionTracking = _extConfig.disableExceptionTracking;
|
|
498
|
+
if (!_disableExceptionTracking && !_autoExceptionInstrumented && !_extConfig.autoExceptionInstrumented) {
|
|
499
|
+
// We want to enable exception auto collection and it has not been done so yet
|
|
500
|
+
_addHook(InstrumentEvent(_window, "onerror", {
|
|
501
|
+
ns: _evtNamespace,
|
|
502
|
+
rsp: function (callDetails, message, url, lineNumber, columnNumber, error) {
|
|
503
|
+
if (!_disableExceptionTracking && callDetails.rslt !== true) {
|
|
504
|
+
_self[_DYN__ONERROR /* @min:%2e_onerror */](Exception[_DYN__CREATE_AUTO_EXCEPTI6 /* @min:%2eCreateAutoException */](message, url, lineNumber, columnNumber, error, callDetails.evt));
|
|
505
|
+
}
|
|
512
506
|
}
|
|
513
|
-
}
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
}
|
|
517
|
-
_addUnhandledPromiseRejectionTracking(
|
|
507
|
+
}, false));
|
|
508
|
+
_autoExceptionInstrumented = true;
|
|
509
|
+
}
|
|
510
|
+
}));
|
|
511
|
+
_addUnhandledPromiseRejectionTracking(_window, locn);
|
|
518
512
|
}
|
|
519
|
-
function _updateLocationChange(
|
|
513
|
+
function _updateLocationChange() {
|
|
520
514
|
var win = getWindow();
|
|
521
515
|
var locn = getLocation(true);
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
516
|
+
_self[_DYN__ADD_HOOK /* @min:%2e_addHook */](onConfigChange(_extConfig, function () {
|
|
517
|
+
_enableAutoRouteTracking = _extConfig.enableAutoRouteTracking === true;
|
|
518
|
+
/**
|
|
519
|
+
* Create a custom "locationchange" event which is triggered each time the history object is changed
|
|
520
|
+
*/
|
|
521
|
+
if (win && _enableAutoRouteTracking && !_historyListenerAdded && hasHistory()) {
|
|
522
|
+
var _history = getHistory();
|
|
523
|
+
if (isFunction(_history.pushState) && isFunction(_history.replaceState) && typeof Event !== strUndefined) {
|
|
524
|
+
_addHistoryListener(win, _history, locn);
|
|
525
|
+
}
|
|
530
526
|
}
|
|
531
|
-
}
|
|
527
|
+
}));
|
|
532
528
|
}
|
|
533
529
|
function _getDistributedTraceCtx() {
|
|
534
530
|
var distributedTraceCtx = null;
|
|
@@ -550,8 +546,12 @@ var AnalyticsPlugin = /** @class */ (function (_super) {
|
|
|
550
546
|
/**
|
|
551
547
|
* Create a custom "locationchange" event which is triggered each time the history object is changed
|
|
552
548
|
*/
|
|
553
|
-
function _addHistoryListener(
|
|
554
|
-
|
|
549
|
+
function _addHistoryListener(win, history, locn) {
|
|
550
|
+
if (_historyListenerAdded) {
|
|
551
|
+
return;
|
|
552
|
+
}
|
|
553
|
+
// Name Prefix is only referenced during the initial initialization and cannot be changed afterwards
|
|
554
|
+
var namePrefix = _extConfig.namePrefix || "";
|
|
555
555
|
function _popstateHandler() {
|
|
556
556
|
if (_enableAutoRouteTracking) {
|
|
557
557
|
_dispatchEvent(win, createDomEvent(namePrefix + "locationchange"));
|
|
@@ -583,50 +583,50 @@ var AnalyticsPlugin = /** @class */ (function (_super) {
|
|
|
583
583
|
}).bind(this, _prevUri), _self.autoRoutePVDelay);
|
|
584
584
|
}
|
|
585
585
|
}
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
_dispatchEvent(win, createDomEvent(namePrefix + "locationchange"));
|
|
593
|
-
}
|
|
586
|
+
_addHook(InstrumentEvent(history, "pushState", {
|
|
587
|
+
ns: _evtNamespace,
|
|
588
|
+
rsp: function () {
|
|
589
|
+
if (_enableAutoRouteTracking) {
|
|
590
|
+
_dispatchEvent(win, createDomEvent(namePrefix + "pushState"));
|
|
591
|
+
_dispatchEvent(win, createDomEvent(namePrefix + "locationchange"));
|
|
594
592
|
}
|
|
595
|
-
}
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
593
|
+
}
|
|
594
|
+
}, true));
|
|
595
|
+
_addHook(InstrumentEvent(history, "replaceState", {
|
|
596
|
+
ns: _evtNamespace,
|
|
597
|
+
rsp: function () {
|
|
598
|
+
if (_enableAutoRouteTracking) {
|
|
599
|
+
_dispatchEvent(win, createDomEvent(namePrefix + "replaceState"));
|
|
600
|
+
_dispatchEvent(win, createDomEvent(namePrefix + "locationchange"));
|
|
603
601
|
}
|
|
604
|
-
}
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
602
|
+
}
|
|
603
|
+
}, true));
|
|
604
|
+
eventOn(win, namePrefix + "popstate", _popstateHandler, _evtNamespace);
|
|
605
|
+
eventOn(win, namePrefix + "locationchange", _locationChangeHandler, _evtNamespace);
|
|
606
|
+
_historyListenerAdded = true;
|
|
609
607
|
}
|
|
610
|
-
function _addUnhandledPromiseRejectionTracking(
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
608
|
+
function _addUnhandledPromiseRejectionTracking(_window, _location) {
|
|
609
|
+
_self[_DYN__ADD_HOOK /* @min:%2e_addHook */](onConfigChange(_extConfig, function () {
|
|
610
|
+
_enableUnhandledPromiseRejectionTracking = _extConfig.enableUnhandledPromiseRejectionTracking === true;
|
|
611
|
+
_autoExceptionInstrumented = _autoExceptionInstrumented || _extConfig[_DYN_AUTO_UNHANDLED_PROMI8 /* @min:%2eautoUnhandledPromiseInstrumented */];
|
|
612
|
+
if (_enableUnhandledPromiseRejectionTracking && !_autoUnhandledPromiseInstrumented) {
|
|
613
|
+
// We want to enable exception auto collection and it has not been done so yet
|
|
614
|
+
_addHook(InstrumentEvent(_window, "onunhandledrejection", {
|
|
615
|
+
ns: _evtNamespace,
|
|
616
|
+
rsp: function (callDetails, error) {
|
|
617
|
+
if (_enableUnhandledPromiseRejectionTracking && callDetails.rslt !== true) { // handled could be typeof function
|
|
618
|
+
_self[_DYN__ONERROR /* @min:%2e_onerror */](Exception[_DYN__CREATE_AUTO_EXCEPTI6 /* @min:%2eCreateAutoException */](_getReason(error), _location ? _location[_DYN_HREF /* @min:%2ehref */] : "", 0, 0, error, callDetails.evt));
|
|
619
|
+
}
|
|
619
620
|
}
|
|
620
|
-
}
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
}
|
|
621
|
+
}, false));
|
|
622
|
+
_extConfig[_DYN_AUTO_UNHANDLED_PROMI8 /* @min:%2eautoUnhandledPromiseInstrumented */] = _autoUnhandledPromiseInstrumented = true;
|
|
623
|
+
}
|
|
624
|
+
}));
|
|
625
625
|
}
|
|
626
626
|
/**
|
|
627
627
|
* This method will throw exceptions in debug mode or attempt to log the error as a console warning.
|
|
628
|
-
* @param severity {eLoggingSeverity} - The severity of the log message
|
|
629
|
-
* @param
|
|
628
|
+
* @param severity - {eLoggingSeverity} - The severity of the log message
|
|
629
|
+
* @param msgId - {_eInternalLogMessage} - The log message.
|
|
630
630
|
*/
|
|
631
631
|
function _throwInternal(severity, msgId, msg, properties, isUserAct) {
|
|
632
632
|
_self[_DYN_DIAG_LOG /* @min:%2ediagLog */]().throwInternal(severity, msgId, msg, properties, isUserAct);
|
|
@@ -646,6 +646,7 @@ var AnalyticsPlugin = /** @class */ (function (_super) {
|
|
|
646
646
|
_autoExceptionInstrumented = false;
|
|
647
647
|
_enableUnhandledPromiseRejectionTracking = false;
|
|
648
648
|
_autoUnhandledPromiseInstrumented = false;
|
|
649
|
+
_autoTrackPageVisitTime = false;
|
|
649
650
|
// Counts number of trackAjax invocations.
|
|
650
651
|
// By default we only monitor X ajax call per view to avoid too much load.
|
|
651
652
|
// Default value is set in config.
|
|
@@ -656,6 +657,13 @@ var AnalyticsPlugin = /** @class */ (function (_super) {
|
|
|
656
657
|
_prevUri = location && location[_DYN_HREF /* @min:%2ehref */] || "";
|
|
657
658
|
_currUri = null;
|
|
658
659
|
_evtNamespace = null;
|
|
660
|
+
_extConfig = null;
|
|
661
|
+
// Define _self.config
|
|
662
|
+
objDefineProp(_self, "config", {
|
|
663
|
+
configurable: true,
|
|
664
|
+
enumerable: true,
|
|
665
|
+
get: function () { return _extConfig; }
|
|
666
|
+
});
|
|
659
667
|
}
|
|
660
668
|
// For backward compatibility
|
|
661
669
|
objDefineAccessors(_self, "_pageViewManager", function () { return _pageViewManager; });
|
|
@@ -683,8 +691,7 @@ var AnalyticsPlugin = /** @class */ (function (_super) {
|
|
|
683
691
|
// Removed Stub for AnalyticsPlugin.prototype._onerror.
|
|
684
692
|
// Removed Stub for AnalyticsPlugin.prototype.addTelemetryInitializer.
|
|
685
693
|
// Removed Stub for AnalyticsPlugin.prototype.initialize.
|
|
686
|
-
AnalyticsPlugin.Version = "3.0.0-beta.2210-
|
|
687
|
-
AnalyticsPlugin.getDefaultConfig = _getDefaultConfig;
|
|
694
|
+
AnalyticsPlugin.Version = "3.0.0-beta.2210-03"; // Not currently used anywhere
|
|
688
695
|
return AnalyticsPlugin;
|
|
689
696
|
}(BaseTelemetryPlugin));
|
|
690
697
|
export { AnalyticsPlugin };
|