@microsoft/applicationinsights-analytics-js 2.8.0-nightly.2202-06 → 2.8.0-nightly.2204-04

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.
Files changed (42) hide show
  1. package/browser/applicationinsights-analytics-js.integrity.json +9 -9
  2. package/browser/applicationinsights-analytics-js.js +1774 -924
  3. package/browser/applicationinsights-analytics-js.js.map +1 -1
  4. package/browser/applicationinsights-analytics-js.min.js +2 -2
  5. package/browser/applicationinsights-analytics-js.min.js.map +1 -1
  6. package/dist/applicationinsights-analytics-js.api.json +138 -229
  7. package/dist/applicationinsights-analytics-js.api.md +8 -18
  8. package/dist/applicationinsights-analytics-js.d.ts +9 -104
  9. package/dist/applicationinsights-analytics-js.js +1774 -924
  10. package/dist/applicationinsights-analytics-js.js.map +1 -1
  11. package/dist/applicationinsights-analytics-js.min.js +2 -2
  12. package/dist/applicationinsights-analytics-js.min.js.map +1 -1
  13. package/dist/applicationinsights-analytics-js.rollup.d.ts +9 -104
  14. package/dist-esm/JavaScriptSDK/AnalyticsPlugin.js +674 -0
  15. package/dist-esm/JavaScriptSDK/AnalyticsPlugin.js.map +1 -0
  16. package/dist-esm/JavaScriptSDK/Telemetry/PageViewManager.js +21 -8
  17. package/dist-esm/JavaScriptSDK/Telemetry/PageViewManager.js.map +1 -1
  18. package/dist-esm/JavaScriptSDK/Telemetry/PageViewPerformanceManager.js +10 -10
  19. package/dist-esm/JavaScriptSDK/Telemetry/PageViewPerformanceManager.js.map +1 -1
  20. package/dist-esm/JavaScriptSDK/Telemetry/PageVisitTimeManager.js +5 -5
  21. package/dist-esm/JavaScriptSDK/Telemetry/PageVisitTimeManager.js.map +1 -1
  22. package/dist-esm/JavaScriptSDK/Timing.js +39 -0
  23. package/dist-esm/JavaScriptSDK/Timing.js.map +1 -0
  24. package/dist-esm/JavaScriptSDK.Interfaces/ITelemetryConfig.js +1 -1
  25. package/dist-esm/applicationinsights-analytics-js.js +2 -2
  26. package/dist-esm/applicationinsights-analytics-js.js.map +1 -1
  27. package/package.json +6 -6
  28. package/src/JavaScriptSDK/{ApplicationInsights.ts → AnalyticsPlugin.ts} +403 -325
  29. package/src/JavaScriptSDK/Telemetry/PageViewManager.ts +32 -13
  30. package/src/JavaScriptSDK/Telemetry/PageViewPerformanceManager.ts +6 -6
  31. package/src/JavaScriptSDK/Telemetry/PageVisitTimeManager.ts +1 -1
  32. package/src/JavaScriptSDK/Timing.ts +46 -0
  33. package/src/applicationinsights-analytics-js.ts +1 -1
  34. package/types/JavaScriptSDK/{ApplicationInsights.d.ts → AnalyticsPlugin.d.ts} +12 -16
  35. package/types/JavaScriptSDK/Telemetry/PageViewManager.d.ts +2 -1
  36. package/types/JavaScriptSDK/Telemetry/PageViewPerformanceManager.d.ts +9 -9
  37. package/types/JavaScriptSDK/Telemetry/PageVisitTimeManager.d.ts +4 -4
  38. package/types/JavaScriptSDK/Timing.d.ts +18 -0
  39. package/types/applicationinsights-analytics-js.d.ts +1 -1
  40. package/types/tsdoc-metadata.json +1 -1
  41. package/dist-esm/JavaScriptSDK/ApplicationInsights.js +0 -606
  42. package/dist-esm/JavaScriptSDK/ApplicationInsights.js.map +0 -1
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * Application Insights JavaScript SDK - Web Analytics, 2.8.0-nightly.2202-06
2
+ * Application Insights JavaScript SDK - Web Analytics, 2.8.0-nightly.2204-04
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  */
5
5
  (function (global, factory) {
@@ -75,7 +75,9 @@
75
75
  var __assignFn = ObjAssign || __objAssignFnImpl;
76
76
  var extendStaticsFn = function (d, b) {
77
77
  extendStaticsFn = ObjClass["setPrototypeOf"] ||
78
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
78
+ ({ __proto__: [] } instanceof Array && function (d, b) {
79
+ d.__proto__ = b;
80
+ }) ||
79
81
  function (d, b) {
80
82
  for (var p in b) {
81
83
  if (b[strShimHasOwnProperty](p)) {
@@ -90,7 +92,9 @@
90
92
  throwTypeError("Class extends value " + String(b) + " is not a constructor or null");
91
93
  }
92
94
  extendStaticsFn(d, b);
93
- function __() { this.constructor = d; }
95
+ function __() {
96
+ this.constructor = d;
97
+ }
94
98
  d[strShimPrototype] = b === null ? objCreateFn(b) : (__[strShimPrototype] = b[strShimPrototype], new __());
95
99
  }
96
100
 
@@ -109,11 +113,11 @@
109
113
  var DynAllowInstChkTag = DynInstChkTag;
110
114
  var DynProtoDefaultOptions = '_dfOpts';
111
115
  var UnknownValue = '_unknown_';
112
- var str__Proto = "__proto__";
116
+ var str__Proto$1 = "__proto__";
113
117
  var strUseBaseInst = 'useBaseInst';
114
118
  var strSetInstFuncs = 'setInstFuncs';
115
119
  var Obj = Object;
116
- var _objGetPrototypeOf = Obj["getPrototypeOf"];
120
+ var _objGetPrototypeOf$1 = Obj["getPrototypeOf"];
117
121
  var _dynamicNames = 0;
118
122
  function _hasOwnProperty(obj, prop) {
119
123
  return obj && Obj[Prototype].hasOwnProperty.call(obj, prop);
@@ -124,12 +128,12 @@
124
128
  function _isObjectArrayOrFunctionPrototype(target) {
125
129
  return _isObjectOrArrayPrototype(target) || target === Function[Prototype];
126
130
  }
127
- function _getObjProto(target) {
131
+ function _getObjProto$1(target) {
128
132
  if (target) {
129
- if (_objGetPrototypeOf) {
130
- return _objGetPrototypeOf(target);
133
+ if (_objGetPrototypeOf$1) {
134
+ return _objGetPrototypeOf$1(target);
131
135
  }
132
- var newProto = target[str__Proto] || target[Prototype] || (target[Constructor] ? target[Constructor][Prototype] : null);
136
+ var newProto = target[str__Proto$1] || target[Prototype] || (target[Constructor] ? target[Constructor][Prototype] : null);
133
137
  if (newProto) {
134
138
  return newProto;
135
139
  }
@@ -195,16 +199,16 @@
195
199
  _forEachProp(instFuncs, function (name) {
196
200
  baseFuncs[name] = _instFuncProxy(thisTarget, instFuncs, name);
197
201
  });
198
- var baseProto = _getObjProto(classProto);
202
+ var baseProto = _getObjProto$1(classProto);
199
203
  var visited = [];
200
204
  while (baseProto && !_isObjectArrayOrFunctionPrototype(baseProto) && !_hasVisited(visited, baseProto)) {
201
205
  _forEachProp(baseProto, function (name) {
202
- if (!baseFuncs[name] && _isDynamicCandidate(baseProto, name, !_objGetPrototypeOf)) {
206
+ if (!baseFuncs[name] && _isDynamicCandidate(baseProto, name, !_objGetPrototypeOf$1)) {
203
207
  baseFuncs[name] = _instFuncProxy(thisTarget, baseProto, name);
204
208
  }
205
209
  });
206
210
  visited.push(baseProto);
207
- baseProto = _getObjProto(baseProto);
211
+ baseProto = _getObjProto$1(baseProto);
208
212
  }
209
213
  return baseFuncs;
210
214
  }
@@ -218,7 +222,7 @@
218
222
  }
219
223
  if (!instFunc[DynInstChkTag] && instFuncTable[DynAllowInstChkTag] !== false) {
220
224
  var canAddInst = !_hasOwnProperty(target, funcName);
221
- var objProto = _getObjProto(target);
225
+ var objProto = _getObjProto$1(target);
222
226
  var visited = [];
223
227
  while (canAddInst && objProto && !_isObjectArrayOrFunctionPrototype(objProto) && !_hasVisited(visited, objProto)) {
224
228
  var protoFunc = objProto[funcName];
@@ -227,7 +231,7 @@
227
231
  break;
228
232
  }
229
233
  visited.push(objProto);
230
- objProto = _getObjProto(objProto);
234
+ objProto = _getObjProto$1(objProto);
231
235
  }
232
236
  try {
233
237
  if (canAddInst) {
@@ -245,7 +249,7 @@
245
249
  function _getProtoFunc(funcName, proto, currentDynProtoProxy) {
246
250
  var protoFunc = proto[funcName];
247
251
  if (protoFunc === currentDynProtoProxy) {
248
- protoFunc = _getObjProto(proto)[funcName];
252
+ protoFunc = _getObjProto$1(proto)[funcName];
249
253
  }
250
254
  if (typeof protoFunc !== strFunction) {
251
255
  _throwTypeError("[" + funcName + "] is not a " + strFunction);
@@ -279,15 +283,15 @@
279
283
  }
280
284
  }
281
285
  function _checkPrototype(classProto, thisTarget) {
282
- if (_objGetPrototypeOf) {
286
+ if (_objGetPrototypeOf$1) {
283
287
  var visited = [];
284
- var thisProto = _getObjProto(thisTarget);
288
+ var thisProto = _getObjProto$1(thisTarget);
285
289
  while (thisProto && !_isObjectArrayOrFunctionPrototype(thisProto) && !_hasVisited(visited, thisProto)) {
286
290
  if (thisProto === classProto) {
287
291
  return true;
288
292
  }
289
293
  visited.push(thisProto);
290
- thisProto = _getObjProto(thisProto);
294
+ thisProto = _getObjProto$1(thisProto);
291
295
  }
292
296
  }
293
297
  return false;
@@ -323,7 +327,7 @@
323
327
  var instFuncs = _getInstanceFuncs(target);
324
328
  var baseFuncs = _getBaseFuncs(classProto, target, instFuncs, useBaseInst);
325
329
  delegateFunc(target, baseFuncs);
326
- var setInstanceFunc = !!_objGetPrototypeOf && !!perfOptions[strSetInstFuncs];
330
+ var setInstanceFunc = !!_objGetPrototypeOf$1 && !!perfOptions[strSetInstFuncs];
327
331
  if (setInstanceFunc && options) {
328
332
  setInstanceFunc = !!options[strSetInstFuncs];
329
333
  }
@@ -335,102 +339,25 @@
335
339
  };
336
340
  dynamicProto[DynProtoDefaultOptions] = perfDefaults;
337
341
 
338
- var LoggingSeverity;
339
- (function (LoggingSeverity) {
340
- LoggingSeverity[LoggingSeverity["CRITICAL"] = 1] = "CRITICAL";
341
- LoggingSeverity[LoggingSeverity["WARNING"] = 2] = "WARNING";
342
- })(LoggingSeverity || (LoggingSeverity = {}));
343
- var _InternalMessageId = {
344
- BrowserDoesNotSupportLocalStorage: 0,
345
- BrowserCannotReadLocalStorage: 1,
346
- BrowserCannotReadSessionStorage: 2,
347
- BrowserCannotWriteLocalStorage: 3,
348
- BrowserCannotWriteSessionStorage: 4,
349
- BrowserFailedRemovalFromLocalStorage: 5,
350
- BrowserFailedRemovalFromSessionStorage: 6,
351
- CannotSendEmptyTelemetry: 7,
352
- ClientPerformanceMathError: 8,
353
- ErrorParsingAISessionCookie: 9,
354
- ErrorPVCalc: 10,
355
- ExceptionWhileLoggingError: 11,
356
- FailedAddingTelemetryToBuffer: 12,
357
- FailedMonitorAjaxAbort: 13,
358
- FailedMonitorAjaxDur: 14,
359
- FailedMonitorAjaxOpen: 15,
360
- FailedMonitorAjaxRSC: 16,
361
- FailedMonitorAjaxSend: 17,
362
- FailedMonitorAjaxGetCorrelationHeader: 18,
363
- FailedToAddHandlerForOnBeforeUnload: 19,
364
- FailedToSendQueuedTelemetry: 20,
365
- FailedToReportDataLoss: 21,
366
- FlushFailed: 22,
367
- MessageLimitPerPVExceeded: 23,
368
- MissingRequiredFieldSpecification: 24,
369
- NavigationTimingNotSupported: 25,
370
- OnError: 26,
371
- SessionRenewalDateIsZero: 27,
372
- SenderNotInitialized: 28,
373
- StartTrackEventFailed: 29,
374
- StopTrackEventFailed: 30,
375
- StartTrackFailed: 31,
376
- StopTrackFailed: 32,
377
- TelemetrySampledAndNotSent: 33,
378
- TrackEventFailed: 34,
379
- TrackExceptionFailed: 35,
380
- TrackMetricFailed: 36,
381
- TrackPVFailed: 37,
382
- TrackPVFailedCalc: 38,
383
- TrackTraceFailed: 39,
384
- TransmissionFailed: 40,
385
- FailedToSetStorageBuffer: 41,
386
- FailedToRestoreStorageBuffer: 42,
387
- InvalidBackendResponse: 43,
388
- FailedToFixDepricatedValues: 44,
389
- InvalidDurationValue: 45,
390
- TelemetryEnvelopeInvalid: 46,
391
- CreateEnvelopeError: 47,
392
- CannotSerializeObject: 48,
393
- CannotSerializeObjectNonSerializable: 49,
394
- CircularReferenceDetected: 50,
395
- ClearAuthContextFailed: 51,
396
- ExceptionTruncated: 52,
397
- IllegalCharsInName: 53,
398
- ItemNotInArray: 54,
399
- MaxAjaxPerPVExceeded: 55,
400
- MessageTruncated: 56,
401
- NameTooLong: 57,
402
- SampleRateOutOfRange: 58,
403
- SetAuthContextFailed: 59,
404
- SetAuthContextFailedAccountName: 60,
405
- StringValueTooLong: 61,
406
- StartCalledMoreThanOnce: 62,
407
- StopCalledWithoutStart: 63,
408
- TelemetryInitializerFailed: 64,
409
- TrackArgumentsNotSpecified: 65,
410
- UrlTooLong: 66,
411
- SessionStorageBufferFull: 67,
412
- CannotAccessCookie: 68,
413
- IdTooLong: 69,
414
- InvalidEvent: 70,
415
- FailedMonitorAjaxSetRequestHeader: 71,
416
- SendBrowserInfoOnUserInit: 72,
417
- PluginException: 73,
418
- NotificationException: 74,
419
- SnippetScriptLoadFailure: 99,
420
- InvalidInstrumentationKey: 100,
421
- CannotParseAiBlobValue: 101,
422
- InvalidContentBlob: 102,
423
- TrackPageActionEventFailed: 103,
424
- FailedAddingCustomDefinedRequestContext: 104,
425
- InMemoryStorageBufferFull: 105
426
- };
342
+ var strEmpty$1 = "";
343
+ var strSetNextPlugin = "setNextPlugin";
344
+ var strIsInitialized = "isInitialized";
345
+ var strTeardown = "teardown";
346
+ var strCore = "core";
347
+ var strUpdate = "update";
348
+ var strDisabled = "disabled";
349
+ var strDoTeardown = "_doTeardown";
427
350
 
428
351
  var strToISOString = "toISOString";
429
352
  var cStrEndsWith = "endsWith";
430
353
  var strMap = "map";
431
354
  var cStrTrim = "trim";
432
355
  var strToString = "toString";
433
- var _objDefineProperty = ObjDefineProperty;
356
+ var str__Proto = "__proto__";
357
+ var strConstructor = "constructor";
358
+ var _objDefineProperty$1 = ObjDefineProperty;
359
+ var _objFreeze = ObjClass.freeze;
360
+ var _objKeys = ObjClass.keys;
434
361
  var StringProto = String[strShimPrototype];
435
362
  var _strTrim = StringProto[cStrTrim];
436
363
  var _strEndsWith = StringProto[cStrEndsWith];
@@ -439,7 +366,23 @@
439
366
  var _isArray = Array.isArray;
440
367
  var _objToString = ObjProto[strToString];
441
368
  var _fnToString = ObjHasOwnProperty[strToString];
442
- _fnToString.call(ObjClass);
369
+ var _objFunctionString = _fnToString.call(ObjClass);
370
+ var rCamelCase = /-([a-z])/g;
371
+ var rNormalizeInvalid = /([^\w\d_$])/g;
372
+ var rLeadingNumeric = /^(\d+[\w\d_$])/;
373
+ var _objGetPrototypeOf = Object["getPrototypeOf"];
374
+ function _getObjProto(target) {
375
+ if (target) {
376
+ if (_objGetPrototypeOf) {
377
+ return _objGetPrototypeOf(target);
378
+ }
379
+ var newProto = target[str__Proto] || target[strShimPrototype] || target[strConstructor];
380
+ if (newProto) {
381
+ return newProto;
382
+ }
383
+ }
384
+ return null;
385
+ }
443
386
  function isUndefined(value) {
444
387
  return value === undefined || typeof value === strShimUndefined;
445
388
  }
@@ -449,12 +392,28 @@
449
392
  function isNotNullOrUndefined(value) {
450
393
  return !isNullOrUndefined(value);
451
394
  }
395
+ function hasOwnProperty(obj, prop) {
396
+ return !!(obj && ObjHasOwnProperty.call(obj, prop));
397
+ }
452
398
  function isObject(value) {
453
399
  return !!(value && typeof value === strShimObject);
454
400
  }
455
401
  function isFunction(value) {
456
402
  return !!(value && typeof value === strShimFunction);
457
403
  }
404
+ function normalizeJsName(name) {
405
+ var value = name;
406
+ if (value && isString(value)) {
407
+ value = value.replace(rCamelCase, function (_all, letter) {
408
+ return letter.toUpperCase();
409
+ });
410
+ value = value.replace(rNormalizeInvalid, "_");
411
+ value = value.replace(rLeadingNumeric, function (_all, match) {
412
+ return "_" + match;
413
+ });
414
+ }
415
+ return value;
416
+ }
458
417
  function objForEachKey(target, callbackfn) {
459
418
  if (target) {
460
419
  for (var prop in target) {
@@ -503,6 +462,25 @@
503
462
  function isString(value) {
504
463
  return typeof value === "string";
505
464
  }
465
+ function isBoolean(value) {
466
+ return typeof value === "boolean";
467
+ }
468
+ function isPlainObject(value) {
469
+ var result = false;
470
+ if (value && typeof value === "object") {
471
+ var proto = _objGetPrototypeOf ? _objGetPrototypeOf(value) : _getObjProto(value);
472
+ if (!proto) {
473
+ result = true;
474
+ }
475
+ else {
476
+ if (proto[strConstructor] && ObjHasOwnProperty.call(proto, strConstructor)) {
477
+ proto = proto[strConstructor];
478
+ }
479
+ result = typeof proto === strShimFunction && _fnToString.call(proto) === _objFunctionString;
480
+ }
481
+ }
482
+ return result;
483
+ }
506
484
  function toISOString(date) {
507
485
  if (date) {
508
486
  return _dataToISOString ? date[strToISOString]() : _toISOStringPoly(date);
@@ -568,8 +546,42 @@
568
546
  }
569
547
  return str;
570
548
  }
549
+ var _objKeysHasDontEnumBug = !({ toString: null }).propertyIsEnumerable("toString");
550
+ var _objKeysDontEnums = [
551
+ "toString",
552
+ "toLocaleString",
553
+ "valueOf",
554
+ "hasOwnProperty",
555
+ "isPrototypeOf",
556
+ "propertyIsEnumerable",
557
+ "constructor"
558
+ ];
559
+ function objKeys(obj) {
560
+ var objType = typeof obj;
561
+ if (objType !== strShimFunction && (objType !== strShimObject || obj === null)) {
562
+ throwTypeError("objKeys called on non-object");
563
+ }
564
+ if (!_objKeysHasDontEnumBug && _objKeys) {
565
+ return _objKeys(obj);
566
+ }
567
+ var result = [];
568
+ for (var prop in obj) {
569
+ if (obj && ObjHasOwnProperty.call(obj, prop)) {
570
+ result.push(prop);
571
+ }
572
+ }
573
+ if (_objKeysHasDontEnumBug) {
574
+ var dontEnumsLength = _objKeysDontEnums.length;
575
+ for (var lp = 0; lp < dontEnumsLength; lp++) {
576
+ if (obj && ObjHasOwnProperty.call(obj, _objKeysDontEnums[lp])) {
577
+ result.push(_objKeysDontEnums[lp]);
578
+ }
579
+ }
580
+ }
581
+ return result;
582
+ }
571
583
  function objDefineAccessors(target, prop, getProp, setProp) {
572
- if (_objDefineProperty) {
584
+ if (_objDefineProperty$1) {
573
585
  try {
574
586
  var descriptor = {
575
587
  enumerable: true,
@@ -581,7 +593,7 @@
581
593
  if (setProp) {
582
594
  descriptor.set = setProp;
583
595
  }
584
- _objDefineProperty(target, prop, descriptor);
596
+ _objDefineProperty$1(target, prop, descriptor);
585
597
  return true;
586
598
  }
587
599
  catch (e) {
@@ -589,6 +601,10 @@
589
601
  }
590
602
  return false;
591
603
  }
604
+ function _doNothing(value) {
605
+ return value;
606
+ }
607
+ var objFreeze = _objFreeze || _doNothing;
592
608
  function dateNow() {
593
609
  var dt = Date;
594
610
  return dt.now ? dt.now() : new dt().getTime();
@@ -597,7 +613,7 @@
597
613
  if (isError(object)) {
598
614
  return object.name;
599
615
  }
600
- return "";
616
+ return strEmpty$1;
601
617
  }
602
618
  function setValue(target, field, value, valChk, srcChk) {
603
619
  var theValue = value;
@@ -616,6 +632,88 @@
616
632
  function throwError(message) {
617
633
  throw new Error(message);
618
634
  }
635
+ function _createProxyFunction(source, funcName) {
636
+ var srcFunc = null;
637
+ var src = null;
638
+ if (isFunction(source)) {
639
+ srcFunc = source;
640
+ }
641
+ else {
642
+ src = source;
643
+ }
644
+ return function () {
645
+ var originalArguments = arguments;
646
+ if (srcFunc) {
647
+ src = srcFunc();
648
+ }
649
+ if (src) {
650
+ return src[funcName].apply(src, originalArguments);
651
+ }
652
+ };
653
+ }
654
+ function proxyFunctionAs(target, name, source, theFunc, overwriteTarget) {
655
+ if (overwriteTarget === void 0) { overwriteTarget = true; }
656
+ if (target && name && source) {
657
+ if (overwriteTarget || isUndefined(target[name])) {
658
+ target[name] = _createProxyFunction(source, theFunc);
659
+ }
660
+ }
661
+ }
662
+ function createEnumStyle(values) {
663
+ var enumClass = {};
664
+ objForEachKey(values, function (field, value) {
665
+ enumClass[field] = value;
666
+ if (!isUndefined(enumClass[value])) {
667
+ throwError("[" + value + "] exists for " + field);
668
+ }
669
+ enumClass[value] = field;
670
+ });
671
+ return objFreeze(enumClass);
672
+ }
673
+ function objExtend(obj1, obj2, obj3, obj4, obj5, obj6) {
674
+ var theArgs = arguments;
675
+ var extended = theArgs[0] || {};
676
+ var argLen = theArgs.length;
677
+ var deep = false;
678
+ var idx = 1;
679
+ if (argLen > 0 && isBoolean(extended)) {
680
+ deep = extended;
681
+ extended = theArgs[idx] || {};
682
+ idx++;
683
+ }
684
+ if (!isObject(extended)) {
685
+ extended = {};
686
+ }
687
+ for (; idx < argLen; idx++) {
688
+ var arg = theArgs[idx];
689
+ var isArgArray = isArray(arg);
690
+ var isArgObj = isObject(arg);
691
+ for (var prop in arg) {
692
+ var propOk = (isArgArray && (prop in arg)) || (isArgObj && (ObjHasOwnProperty.call(arg, prop)));
693
+ if (!propOk) {
694
+ continue;
695
+ }
696
+ var newValue = arg[prop];
697
+ var isNewArray = void 0;
698
+ if (deep && newValue && ((isNewArray = isArray(newValue)) || isPlainObject(newValue))) {
699
+ var clone = extended[prop];
700
+ if (isNewArray) {
701
+ if (!isArray(clone)) {
702
+ clone = [];
703
+ }
704
+ }
705
+ else if (!isPlainObject(clone)) {
706
+ clone = {};
707
+ }
708
+ newValue = objExtend(deep, clone, newValue);
709
+ }
710
+ if (newValue !== undefined) {
711
+ extended[prop] = newValue;
712
+ }
713
+ }
714
+ }
715
+ return extended;
716
+ }
619
717
 
620
718
  var strWindow = "window";
621
719
  var strDocument = "document";
@@ -718,14 +816,14 @@
718
816
  var nav = getNavigator();
719
817
  if (nav && (nav.userAgent !== _navUserAgentCheck || _isTrident === null)) {
720
818
  _navUserAgentCheck = nav.userAgent;
721
- var userAgent = (_navUserAgentCheck || "").toLowerCase();
819
+ var userAgent = (_navUserAgentCheck || strEmpty$1).toLowerCase();
722
820
  _isTrident = (strContains(userAgent, strMsie) || strContains(userAgent, strTrident));
723
821
  }
724
822
  return _isTrident;
725
823
  }
726
824
  function dumpObj(object) {
727
825
  var objectTypeDump = Object[strShimPrototype].toString.call(object);
728
- var propertyValueDump = "";
826
+ var propertyValueDump = strEmpty$1;
729
827
  if (objectTypeDump === "[object Error]") {
730
828
  propertyValueDump = "{ stack: '" + object.stack + "', message: '" + object.message + "', name: '" + object.name + "'";
731
829
  }
@@ -758,9 +856,9 @@
758
856
  var strWarnToConsole = "warnToConsole";
759
857
  function _sanitizeDiagnosticText(text) {
760
858
  if (text) {
761
- return "\"" + text.replace(/\"/g, "") + "\"";
859
+ return "\"" + text.replace(/\"/g, strEmpty$1) + "\"";
762
860
  }
763
- return "";
861
+ return strEmpty$1;
764
862
  }
765
863
  function _logToConsole(func, message) {
766
864
  var theConsole = getConsole();
@@ -782,12 +880,12 @@
782
880
  _self.message =
783
881
  (isUserAct ? AiUserActionablePrefix : AiNonUserActionablePrefix) +
784
882
  msgId;
785
- var strProps = "";
883
+ var strProps = strEmpty$1;
786
884
  if (hasJSON()) {
787
885
  strProps = getJSON().stringify(properties);
788
886
  }
789
- var diagnosticText = (msg ? " message:" + _sanitizeDiagnosticText(msg) : "") +
790
- (properties ? " props:" + _sanitizeDiagnosticText(strProps) : "");
887
+ var diagnosticText = (msg ? " message:" + _sanitizeDiagnosticText(msg) : strEmpty$1) +
888
+ (properties ? " props:" + _sanitizeDiagnosticText(strProps) : strEmpty$1);
791
889
  _self.message += diagnosticText;
792
890
  }
793
891
  _InternalLogMessage.dataType = "MessageData";
@@ -817,7 +915,7 @@
817
915
  throw message;
818
916
  }
819
917
  else {
820
- var logFunc = severity === LoggingSeverity.CRITICAL ? strErrorToConsole : strWarnToConsole;
918
+ var logFunc = severity === 1 ? strErrorToConsole : strWarnToConsole;
821
919
  if (!isUndefined(message.message)) {
822
920
  var logLevel = _self.consoleLoggingLevel();
823
921
  if (isUserAct) {
@@ -835,7 +933,7 @@
835
933
  _self.logInternalMessage(severity, message);
836
934
  }
837
935
  else {
838
- _debugExtMsg("throw" + (severity === LoggingSeverity.CRITICAL ? "Critical" : "Warning"), message);
936
+ _debugExtMsg("throw" + (severity === 1 ? "Critical" : "Warning"), message);
839
937
  }
840
938
  }
841
939
  };
@@ -867,13 +965,13 @@
867
965
  if (severity <= _self.telemetryLoggingLevel()) {
868
966
  _self.queue.push(message);
869
967
  _messageCount++;
870
- _debugExtMsg((severity === LoggingSeverity.CRITICAL ? "error" : "warn"), message);
968
+ _debugExtMsg((severity === 1 ? "error" : "warn"), message);
871
969
  }
872
970
  if (_messageCount === _self.maxInternalMessageLimit()) {
873
971
  var throttleLimitMessage = "Internal events throttle limit per PageView reached for this app.";
874
- var throttleMessage = new _InternalLogMessage(_InternalMessageId.MessageLimitPerPVExceeded, throttleLimitMessage, false);
972
+ var throttleMessage = new _InternalLogMessage(23 , throttleLimitMessage, false);
875
973
  _self.queue.push(throttleMessage);
876
- if (severity === LoggingSeverity.CRITICAL) {
974
+ if (severity === 1 ) {
877
975
  _self.errorToConsole(throttleLimitMessage);
878
976
  }
879
977
  else {
@@ -902,6 +1000,10 @@
902
1000
  }
903
1001
  return DiagnosticLogger;
904
1002
  }());
1003
+ function _throwInternal(logger, severity, msgId, msg, properties, isUserAct) {
1004
+ if (isUserAct === void 0) { isUserAct = false; }
1005
+ (logger || new DiagnosticLogger()).throwInternal(severity, msgId, msg, properties, isUserAct);
1006
+ }
905
1007
 
906
1008
  var strExecutionContextKey = "ctx";
907
1009
  var PerfEvent = /** @class */ (function () {
@@ -1015,252 +1117,495 @@
1015
1117
  return func();
1016
1118
  }
1017
1119
 
1018
- var TelemetryPluginChain = /** @class */ (function () {
1019
- function TelemetryPluginChain(plugin, defItemCtx) {
1020
- var _self = this;
1021
- var _nextProxy = null;
1022
- var _hasProcessTelemetry = isFunction(plugin.processTelemetry);
1023
- var _hasSetNext = isFunction(plugin.setNextPlugin);
1024
- _self._hasRun = false;
1025
- _self.getPlugin = function () {
1026
- return plugin;
1027
- };
1028
- _self.getNext = function () {
1029
- return _nextProxy;
1030
- };
1031
- _self.setNext = function (nextPlugin) {
1032
- _nextProxy = nextPlugin;
1033
- };
1034
- _self.processTelemetry = function (env, itemCtx) {
1035
- if (!itemCtx) {
1036
- itemCtx = defItemCtx;
1037
- }
1038
- var identifier = plugin ? plugin.identifier : "TelemetryPluginChain";
1039
- doPerf(itemCtx ? itemCtx.core() : null, function () { return identifier + ":processTelemetry"; }, function () {
1040
- if (plugin && _hasProcessTelemetry) {
1041
- _self._hasRun = true;
1042
- try {
1043
- itemCtx.setNext(_nextProxy);
1044
- if (_hasSetNext) {
1045
- plugin.setNextPlugin(_nextProxy);
1046
- }
1047
- _nextProxy && (_nextProxy._hasRun = false);
1048
- plugin.processTelemetry(env, itemCtx);
1049
- }
1050
- catch (error) {
1051
- var hasRun = _nextProxy && _nextProxy._hasRun;
1052
- if (!_nextProxy || !hasRun) {
1053
- itemCtx.diagLog().throwInternal(LoggingSeverity.CRITICAL, _InternalMessageId.PluginException, "Plugin [" + plugin.identifier + "] failed during processTelemetry - " + dumpObj(error));
1054
- }
1055
- if (_nextProxy && !hasRun) {
1056
- _nextProxy.processTelemetry(env, itemCtx);
1057
- }
1058
- }
1059
- }
1060
- else if (_nextProxy) {
1061
- _self._hasRun = true;
1062
- _nextProxy.processTelemetry(env, itemCtx);
1063
- }
1064
- }, function () { return ({ item: env }); }, !(env.sync));
1065
- };
1120
+ var UInt32Mask = 0x100000000;
1121
+ var MaxUInt32 = 0xffffffff;
1122
+ var _mwcSeeded = false;
1123
+ var _mwcW = 123456789;
1124
+ var _mwcZ = 987654321;
1125
+ function _mwcSeed(seedValue) {
1126
+ if (seedValue < 0) {
1127
+ seedValue >>>= 0;
1066
1128
  }
1067
- return TelemetryPluginChain;
1068
- }());
1129
+ _mwcW = (123456789 + seedValue) & MaxUInt32;
1130
+ _mwcZ = (987654321 - seedValue) & MaxUInt32;
1131
+ _mwcSeeded = true;
1132
+ }
1133
+ function _autoSeedMwc() {
1134
+ try {
1135
+ var now = dateNow() & 0x7fffffff;
1136
+ _mwcSeed(((Math.random() * UInt32Mask) ^ now) + now);
1137
+ }
1138
+ catch (e) {
1139
+ }
1140
+ }
1141
+ function random32(signed) {
1142
+ var value = 0;
1143
+ var c = getCrypto() || getMsCrypto();
1144
+ if (c && c.getRandomValues) {
1145
+ value = c.getRandomValues(new Uint32Array(1))[0] & MaxUInt32;
1146
+ }
1147
+ if (value === 0 && isIE()) {
1148
+ if (!_mwcSeeded) {
1149
+ _autoSeedMwc();
1150
+ }
1151
+ value = mwcRandom32() & MaxUInt32;
1152
+ }
1153
+ if (value === 0) {
1154
+ value = Math.floor((UInt32Mask * Math.random()) | 0);
1155
+ }
1156
+ if (!signed) {
1157
+ value >>>= 0;
1158
+ }
1159
+ return value;
1160
+ }
1161
+ function mwcRandom32(signed) {
1162
+ _mwcZ = (36969 * (_mwcZ & 0xFFFF) + (_mwcZ >> 16)) & MaxUInt32;
1163
+ _mwcW = (18000 * (_mwcW & 0xFFFF) + (_mwcW >> 16)) & MaxUInt32;
1164
+ var value = (((_mwcZ << 16) + (_mwcW & 0xFFFF)) >>> 0) & MaxUInt32 | 0;
1165
+ if (!signed) {
1166
+ value >>>= 0;
1167
+ }
1168
+ return value;
1169
+ }
1170
+ function newId(maxLength) {
1171
+ if (maxLength === void 0) { maxLength = 22; }
1172
+ var base64chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
1173
+ var number = random32() >>> 0;
1174
+ var chars = 0;
1175
+ var result = strEmpty$1;
1176
+ while (result.length < maxLength) {
1177
+ chars++;
1178
+ result += base64chars.charAt(number & 0x3F);
1179
+ number >>>= 6;
1180
+ if (chars === 5) {
1181
+ number = (((random32() << 2) & 0xFFFFFFFF) | (number & 0x03)) >>> 0;
1182
+ chars = 0;
1183
+ }
1184
+ }
1185
+ return result;
1186
+ }
1069
1187
 
1070
- function _createProxyChain(plugins, itemCtx) {
1071
- var proxies = [];
1072
- if (plugins && plugins.length > 0) {
1073
- var lastProxy = null;
1074
- for (var idx = 0; idx < plugins.length; idx++) {
1075
- var thePlugin = plugins[idx];
1076
- if (thePlugin && isFunction(thePlugin.processTelemetry)) {
1077
- var newProxy = new TelemetryPluginChain(thePlugin, itemCtx);
1078
- proxies.push(newProxy);
1079
- if (lastProxy) {
1080
- lastProxy.setNext(newProxy);
1188
+ var _objDefineProperty = ObjDefineProperty;
1189
+ var version = "2.8.0-nightly.2204-04";
1190
+ var instanceName = "." + newId(6);
1191
+ var _dataUid = 0;
1192
+ function _createAccessor(target, prop, value) {
1193
+ if (_objDefineProperty) {
1194
+ try {
1195
+ _objDefineProperty(target, prop, {
1196
+ value: value,
1197
+ enumerable: false,
1198
+ configurable: true
1199
+ });
1200
+ return true;
1201
+ }
1202
+ catch (e) {
1203
+ }
1204
+ }
1205
+ return false;
1206
+ }
1207
+ function _canAcceptData(target) {
1208
+ return target.nodeType === 1 || target.nodeType === 9 || !(+target.nodeType);
1209
+ }
1210
+ function _getCache(data, target) {
1211
+ var theCache = target[data.id];
1212
+ if (!theCache) {
1213
+ theCache = {};
1214
+ try {
1215
+ if (_canAcceptData(target)) {
1216
+ if (!_createAccessor(target, data.id, theCache)) {
1217
+ target[data.id] = theCache;
1081
1218
  }
1082
- lastProxy = newProxy;
1083
1219
  }
1084
1220
  }
1221
+ catch (e) {
1222
+ }
1085
1223
  }
1086
- return proxies.length > 0 ? proxies[0] : null;
1224
+ return theCache;
1087
1225
  }
1088
- function _copyProxyChain(proxy, itemCtx, startAt) {
1089
- var plugins = [];
1090
- var add = startAt ? false : true;
1091
- if (proxy) {
1092
- while (proxy) {
1093
- var thePlugin = proxy.getPlugin();
1094
- if (add || thePlugin === startAt) {
1095
- add = true;
1096
- plugins.push(thePlugin);
1226
+ function createUniqueNamespace(name, includeVersion) {
1227
+ if (includeVersion === void 0) { includeVersion = false; }
1228
+ return normalizeJsName(name + (_dataUid++) + (includeVersion ? "." + version : "") + instanceName);
1229
+ }
1230
+ function createElmNodeData(name) {
1231
+ var data = {
1232
+ id: createUniqueNamespace("_aiData-" + (name || "") + "." + version),
1233
+ accept: function (target) {
1234
+ return _canAcceptData(target);
1235
+ },
1236
+ get: function (target, name, defValue, addDefault) {
1237
+ var theCache = target[data.id];
1238
+ if (!theCache) {
1239
+ if (addDefault) {
1240
+ theCache = _getCache(data, target);
1241
+ theCache[normalizeJsName(name)] = defValue;
1242
+ }
1243
+ return defValue;
1244
+ }
1245
+ return theCache[normalizeJsName(name)];
1246
+ },
1247
+ kill: function (target, name) {
1248
+ if (target && target[name]) {
1249
+ try {
1250
+ delete target[name];
1251
+ }
1252
+ catch (e) {
1253
+ }
1097
1254
  }
1098
- proxy = proxy.getNext();
1255
+ }
1256
+ };
1257
+ return data;
1258
+ }
1259
+
1260
+ var pluginStateData = createElmNodeData("plugin");
1261
+ function _getPluginState(plugin) {
1262
+ return pluginStateData.get(plugin, "state", {}, true);
1263
+ }
1264
+
1265
+ var strTelemetryPluginChain = "TelemetryPluginChain";
1266
+ var strHasRunFlags = "_hasRun";
1267
+ var strGetTelCtx = "_getTelCtx";
1268
+ var _chainId = 0;
1269
+ function _getNextProxyStart(proxy, config, core, startAt) {
1270
+ while (proxy) {
1271
+ if (proxy.getPlugin() === startAt) {
1272
+ return proxy;
1273
+ }
1274
+ proxy = proxy.getNext();
1275
+ }
1276
+ return createTelemetryProxyChain([startAt], config, core);
1277
+ }
1278
+ function _createInternalContext(telemetryChain, config, core, startAt) {
1279
+ var _nextProxy = null;
1280
+ var _onComplete = [];
1281
+ if (startAt !== null) {
1282
+ _nextProxy = startAt ? _getNextProxyStart(telemetryChain, config, core, startAt) : telemetryChain;
1283
+ }
1284
+ var context = {
1285
+ _next: _moveNext,
1286
+ ctx: {
1287
+ core: function () {
1288
+ return core;
1289
+ },
1290
+ diagLog: function () {
1291
+ return safeGetLogger(core, config);
1292
+ },
1293
+ getCfg: function () {
1294
+ return config;
1295
+ },
1296
+ getExtCfg: _getExtCfg,
1297
+ getConfig: _getConfig,
1298
+ hasNext: function () {
1299
+ return !!_nextProxy;
1300
+ },
1301
+ getNext: function () {
1302
+ return _nextProxy;
1303
+ },
1304
+ setNext: function (nextPlugin) {
1305
+ _nextProxy = nextPlugin;
1306
+ },
1307
+ iterate: _iterateChain,
1308
+ onComplete: _addOnComplete
1309
+ }
1310
+ };
1311
+ function _addOnComplete(onComplete, that) {
1312
+ var args = [];
1313
+ for (var _i = 2; _i < arguments.length; _i++) {
1314
+ args[_i - 2] = arguments[_i];
1315
+ }
1316
+ if (onComplete) {
1317
+ _onComplete.push({
1318
+ func: onComplete,
1319
+ self: !isUndefined(that) ? that : context.ctx,
1320
+ args: args
1321
+ });
1099
1322
  }
1100
1323
  }
1101
- if (!add) {
1102
- plugins.push(startAt);
1324
+ function _moveNext() {
1325
+ var nextProxy = _nextProxy;
1326
+ _nextProxy = nextProxy ? nextProxy.getNext() : null;
1327
+ if (!nextProxy) {
1328
+ var onComplete = _onComplete;
1329
+ if (onComplete && onComplete.length > 0) {
1330
+ arrForEach(onComplete, function (completeDetails) {
1331
+ try {
1332
+ completeDetails.func.call(completeDetails.self, completeDetails.args);
1333
+ }
1334
+ catch (e) {
1335
+ _throwInternal(core.logger, 2 , 73 , "Unexpected Exception during onComplete - " + dumpObj(e));
1336
+ }
1337
+ });
1338
+ _onComplete = [];
1339
+ }
1340
+ }
1341
+ return nextProxy;
1342
+ }
1343
+ function _getExtCfg(identifier, defaultValue, mergeDefault) {
1344
+ if (defaultValue === void 0) { defaultValue = {}; }
1345
+ if (mergeDefault === void 0) { mergeDefault = 0 ; }
1346
+ var theConfig;
1347
+ if (config) {
1348
+ var extConfig = config.extensionConfig;
1349
+ if (extConfig && identifier) {
1350
+ theConfig = extConfig[identifier];
1351
+ }
1352
+ }
1353
+ if (!theConfig) {
1354
+ theConfig = defaultValue;
1355
+ }
1356
+ else if (isObject(defaultValue)) {
1357
+ if (mergeDefault !== 0 ) {
1358
+ var newConfig_1 = objExtend(true, defaultValue, theConfig);
1359
+ if (config && mergeDefault === 2 ) {
1360
+ objForEachKey(defaultValue, function (field) {
1361
+ if (isNullOrUndefined(newConfig_1[field])) {
1362
+ var cfgValue = config[field];
1363
+ if (!isNullOrUndefined(cfgValue)) {
1364
+ newConfig_1[field] = cfgValue;
1365
+ }
1366
+ }
1367
+ });
1368
+ }
1369
+ }
1370
+ }
1371
+ return theConfig;
1372
+ }
1373
+ function _getConfig(identifier, field, defaultValue) {
1374
+ if (defaultValue === void 0) { defaultValue = false; }
1375
+ var theValue;
1376
+ var extConfig = _getExtCfg(identifier, null);
1377
+ if (extConfig && !isNullOrUndefined(extConfig[field])) {
1378
+ theValue = extConfig[field];
1379
+ }
1380
+ else if (config && !isNullOrUndefined(config[field])) {
1381
+ theValue = config[field];
1382
+ }
1383
+ return !isNullOrUndefined(theValue) ? theValue : defaultValue;
1384
+ }
1385
+ function _iterateChain(cb) {
1386
+ var nextPlugin;
1387
+ while (!!(nextPlugin = context._next())) {
1388
+ var plugin = nextPlugin.getPlugin();
1389
+ if (plugin) {
1390
+ cb(plugin);
1391
+ }
1392
+ }
1103
1393
  }
1104
- return _createProxyChain(plugins, itemCtx);
1394
+ return context;
1105
1395
  }
1106
- function _copyPluginChain(srcPlugins, itemCtx, startAt) {
1107
- var plugins = srcPlugins;
1108
- var add = false;
1109
- if (startAt && srcPlugins) {
1110
- plugins = [];
1111
- arrForEach(srcPlugins, function (thePlugin) {
1112
- if (add || thePlugin === startAt) {
1113
- add = true;
1114
- plugins.push(thePlugin);
1396
+ function createProcessTelemetryContext(telemetryChain, config, core, startAt) {
1397
+ var internalContext = _createInternalContext(telemetryChain, config, core, startAt);
1398
+ var context = internalContext.ctx;
1399
+ function _processNext(env) {
1400
+ var nextPlugin = internalContext._next();
1401
+ nextPlugin && nextPlugin.processTelemetry(env, context);
1402
+ return !nextPlugin;
1403
+ }
1404
+ function _createNew(plugins, startAt) {
1405
+ if (plugins === void 0) { plugins = null; }
1406
+ if (isArray(plugins)) {
1407
+ plugins = createTelemetryProxyChain(plugins, config, core, startAt);
1408
+ }
1409
+ return createProcessTelemetryContext(plugins || context.getNext(), config, core, startAt);
1410
+ }
1411
+ context.processNext = _processNext;
1412
+ context.createNew = _createNew;
1413
+ return context;
1414
+ }
1415
+ function createProcessTelemetryUnloadContext(telemetryChain, config, core, startAt) {
1416
+ var internalContext = _createInternalContext(telemetryChain, config, core, startAt);
1417
+ var context = internalContext.ctx;
1418
+ function _processNext(unloadState) {
1419
+ var nextPlugin = internalContext._next();
1420
+ nextPlugin && nextPlugin.unload(context, unloadState);
1421
+ return !nextPlugin;
1422
+ }
1423
+ function _createNew(plugins, startAt) {
1424
+ if (plugins === void 0) { plugins = null; }
1425
+ if (isArray(plugins)) {
1426
+ plugins = createTelemetryProxyChain(plugins, config, core, startAt);
1427
+ }
1428
+ return createProcessTelemetryUnloadContext(plugins || context.getNext(), config, core, startAt);
1429
+ }
1430
+ context.processNext = _processNext;
1431
+ context.createNew = _createNew;
1432
+ return context;
1433
+ }
1434
+ function createProcessTelemetryUpdateContext(telemetryChain, config, core, startAt) {
1435
+ var internalContext = _createInternalContext(telemetryChain, config, core, startAt);
1436
+ var context = internalContext.ctx;
1437
+ function _processNext(updateState) {
1438
+ return context.iterate(function (plugin) {
1439
+ if (isFunction(plugin[strUpdate])) {
1440
+ plugin[strUpdate](context, updateState);
1115
1441
  }
1116
1442
  });
1117
1443
  }
1118
- if (startAt && !add) {
1119
- if (!plugins) {
1120
- plugins = [];
1444
+ function _createNew(plugins, startAt) {
1445
+ if (plugins === void 0) { plugins = null; }
1446
+ if (isArray(plugins)) {
1447
+ plugins = createTelemetryProxyChain(plugins, config, core, startAt);
1121
1448
  }
1122
- plugins.push(startAt);
1449
+ return createProcessTelemetryUpdateContext(plugins || context.getNext(), config, core, startAt);
1123
1450
  }
1124
- return _createProxyChain(plugins, itemCtx);
1451
+ context.processNext = _processNext;
1452
+ context.createNew = _createNew;
1453
+ return context;
1125
1454
  }
1126
- var ProcessTelemetryContext = /** @class */ (function () {
1127
- function ProcessTelemetryContext(plugins, config, core, startAt) {
1128
- var _self = this;
1129
- var _nextProxy = null;
1130
- if (startAt !== null) {
1131
- if (plugins && isFunction(plugins.getPlugin)) {
1132
- _nextProxy = _copyProxyChain(plugins, _self, startAt || plugins.getPlugin());
1455
+ function createTelemetryProxyChain(plugins, config, core, startAt) {
1456
+ var firstProxy = null;
1457
+ var add = startAt ? false : true;
1458
+ if (isArray(plugins) && plugins.length > 0) {
1459
+ var lastProxy_1 = null;
1460
+ arrForEach(plugins, function (thePlugin) {
1461
+ if (!add && startAt === thePlugin) {
1462
+ add = true;
1133
1463
  }
1134
- else {
1135
- if (startAt) {
1136
- _nextProxy = _copyPluginChain(plugins, _self, startAt);
1464
+ if (add && thePlugin && isFunction(thePlugin.processTelemetry)) {
1465
+ var newProxy = createTelemetryPluginProxy(thePlugin, config, core);
1466
+ if (!firstProxy) {
1467
+ firstProxy = newProxy;
1137
1468
  }
1138
- else if (isUndefined(startAt)) {
1139
- _nextProxy = _createProxyChain(plugins, _self);
1469
+ if (lastProxy_1) {
1470
+ lastProxy_1._setNext(newProxy);
1140
1471
  }
1472
+ lastProxy_1 = newProxy;
1141
1473
  }
1474
+ });
1475
+ }
1476
+ if (startAt && !firstProxy) {
1477
+ return createTelemetryProxyChain([startAt], config, core);
1478
+ }
1479
+ return firstProxy;
1480
+ }
1481
+ function createTelemetryPluginProxy(plugin, config, core) {
1482
+ var nextProxy = null;
1483
+ var hasProcessTelemetry = isFunction(plugin.processTelemetry);
1484
+ var hasSetNext = isFunction(plugin.setNextPlugin);
1485
+ var chainId;
1486
+ if (plugin) {
1487
+ chainId = plugin.identifier + "-" + plugin.priority + "-" + _chainId++;
1488
+ }
1489
+ else {
1490
+ chainId = "Unknown-0-" + _chainId++;
1491
+ }
1492
+ var proxyChain = {
1493
+ getPlugin: function () {
1494
+ return plugin;
1495
+ },
1496
+ getNext: function () {
1497
+ return nextProxy;
1498
+ },
1499
+ processTelemetry: _processTelemetry,
1500
+ unload: _unloadPlugin,
1501
+ update: _updatePlugin,
1502
+ _id: chainId,
1503
+ _setNext: function (nextPlugin) {
1504
+ nextProxy = nextPlugin;
1142
1505
  }
1143
- _self.core = function () {
1144
- return core;
1145
- };
1146
- _self.diagLog = function () {
1147
- return safeGetLogger(core, config);
1148
- };
1149
- _self.getCfg = function () {
1150
- return config;
1151
- };
1152
- _self.getExtCfg = function (identifier, defaultValue) {
1153
- if (defaultValue === void 0) { defaultValue = {}; }
1154
- var theConfig;
1155
- if (config) {
1156
- var extConfig = config.extensionConfig;
1157
- if (extConfig && identifier) {
1158
- theConfig = extConfig[identifier];
1506
+ };
1507
+ function _getTelCtx() {
1508
+ var itemCtx;
1509
+ if (plugin && isFunction(plugin[strGetTelCtx])) {
1510
+ itemCtx = plugin[strGetTelCtx]();
1511
+ }
1512
+ if (!itemCtx) {
1513
+ itemCtx = createProcessTelemetryContext(proxyChain, config, core);
1514
+ }
1515
+ return itemCtx;
1516
+ }
1517
+ function _processChain(itemCtx, processPluginFn, name, details, isAsync) {
1518
+ var hasRun = false;
1519
+ var identifier = plugin ? plugin.identifier : strTelemetryPluginChain;
1520
+ var hasRunContext = itemCtx[strHasRunFlags];
1521
+ if (!hasRunContext) {
1522
+ hasRunContext = itemCtx[strHasRunFlags] = {};
1523
+ }
1524
+ itemCtx.setNext(nextProxy);
1525
+ if (plugin) {
1526
+ doPerf(itemCtx[strCore](), function () { return identifier + ":" + name; }, function () {
1527
+ hasRunContext[chainId] = true;
1528
+ try {
1529
+ var nextId = nextProxy ? nextProxy._id : strEmpty$1;
1530
+ if (nextId) {
1531
+ hasRunContext[nextId] = false;
1532
+ }
1533
+ hasRun = processPluginFn(itemCtx);
1159
1534
  }
1535
+ catch (error) {
1536
+ var hasNextRun = nextProxy ? hasRunContext[nextProxy._id] : true;
1537
+ if (hasNextRun) {
1538
+ hasRun = true;
1539
+ }
1540
+ if (!nextProxy || !hasNextRun) {
1541
+ _throwInternal(itemCtx.diagLog(), 1 , 73 , "Plugin [" + plugin.identifier + "] failed during " + name + " - " + dumpObj(error) + ", run flags: " + dumpObj(hasRunContext));
1542
+ }
1543
+ }
1544
+ }, details, isAsync);
1545
+ }
1546
+ return hasRun;
1547
+ }
1548
+ function _processTelemetry(env, itemCtx) {
1549
+ itemCtx = itemCtx || _getTelCtx();
1550
+ function _callProcessTelemetry(itemCtx) {
1551
+ if (!plugin || !hasProcessTelemetry) {
1552
+ return false;
1160
1553
  }
1161
- return (theConfig ? theConfig : defaultValue);
1162
- };
1163
- _self.getConfig = function (identifier, field, defaultValue) {
1164
- if (defaultValue === void 0) { defaultValue = false; }
1165
- var theValue;
1166
- var extConfig = _self.getExtCfg(identifier, null);
1167
- if (extConfig && !isNullOrUndefined(extConfig[field])) {
1168
- theValue = extConfig[field];
1169
- }
1170
- else if (config && !isNullOrUndefined(config[field])) {
1171
- theValue = config[field];
1554
+ var pluginState = _getPluginState(plugin);
1555
+ if (pluginState[strTeardown] || pluginState[strDisabled]) {
1556
+ return false;
1172
1557
  }
1173
- return !isNullOrUndefined(theValue) ? theValue : defaultValue;
1174
- };
1175
- _self.hasNext = function () {
1176
- return _nextProxy != null;
1177
- };
1178
- _self.getNext = function () {
1179
- return _nextProxy;
1180
- };
1181
- _self.setNext = function (nextPlugin) {
1182
- _nextProxy = nextPlugin;
1183
- };
1184
- _self.processNext = function (env) {
1185
- var nextPlugin = _nextProxy;
1186
- if (nextPlugin) {
1187
- _nextProxy = nextPlugin.getNext();
1188
- nextPlugin.processTelemetry(env, _self);
1558
+ if (hasSetNext) {
1559
+ plugin.setNextPlugin(nextProxy);
1189
1560
  }
1190
- };
1191
- _self.createNew = function (plugins, startAt) {
1192
- if (plugins === void 0) { plugins = null; }
1193
- return new ProcessTelemetryContext(plugins || _nextProxy, config, core, startAt);
1194
- };
1561
+ plugin.processTelemetry(env, itemCtx);
1562
+ return true;
1563
+ }
1564
+ if (!_processChain(itemCtx, _callProcessTelemetry, "processTelemetry", function () { return ({ item: env }); }, !(env.sync))) {
1565
+ itemCtx.processNext(env);
1566
+ }
1195
1567
  }
1196
- return ProcessTelemetryContext;
1197
- }());
1198
-
1199
- var strExtensionConfig = "extensionConfig";
1200
-
1201
- var strGetPlugin = "getPlugin";
1202
- var BaseTelemetryPlugin = /** @class */ (function () {
1203
- function BaseTelemetryPlugin() {
1204
- var _self = this;
1205
- var _isinitialized = false;
1206
- var _rootCtx = null;
1207
- var _nextPlugin = null;
1208
- _self.core = null;
1209
- _self.diagLog = function (itemCtx) {
1210
- return _self._getTelCtx(itemCtx).diagLog();
1211
- };
1212
- _self.isInitialized = function () {
1213
- return _isinitialized;
1214
- };
1215
- _self.setInitialized = function (isInitialized) {
1216
- _isinitialized = isInitialized;
1217
- };
1218
- _self.setNextPlugin = function (next) {
1219
- _nextPlugin = next;
1220
- };
1221
- _self.processNext = function (env, itemCtx) {
1222
- if (itemCtx) {
1223
- itemCtx.processNext(env);
1224
- }
1225
- else if (_nextPlugin && isFunction(_nextPlugin.processTelemetry)) {
1226
- _nextPlugin.processTelemetry(env, null);
1227
- }
1228
- };
1229
- _self._getTelCtx = function (currentCtx) {
1230
- if (currentCtx === void 0) { currentCtx = null; }
1231
- var itemCtx = currentCtx;
1232
- if (!itemCtx) {
1233
- var rootCtx = _rootCtx || new ProcessTelemetryContext(null, {}, _self.core);
1234
- if (_nextPlugin && _nextPlugin[strGetPlugin]) {
1235
- itemCtx = rootCtx.createNew(null, _nextPlugin[strGetPlugin]);
1236
- }
1237
- else {
1238
- itemCtx = rootCtx.createNew(null, _nextPlugin);
1568
+ function _unloadPlugin(unloadCtx, unloadState) {
1569
+ function _callTeardown() {
1570
+ var hasRun = false;
1571
+ if (plugin) {
1572
+ var pluginState = _getPluginState(plugin);
1573
+ var pluginCore = plugin[strCore] || pluginState.core;
1574
+ if (plugin && (!pluginCore || pluginCore === unloadCtx[strCore]()) && !pluginState[strTeardown]) {
1575
+ pluginState[strCore] = null;
1576
+ pluginState[strTeardown] = true;
1577
+ pluginState[strIsInitialized] = false;
1578
+ if (plugin[strTeardown] && plugin[strTeardown](unloadCtx, unloadState) === true) {
1579
+ hasRun = true;
1580
+ }
1239
1581
  }
1240
1582
  }
1241
- return itemCtx;
1242
- };
1243
- _self._baseTelInit = function (config, core, extensions, pluginChain) {
1244
- if (config) {
1245
- setValue(config, strExtensionConfig, [], null, isNullOrUndefined);
1246
- }
1247
- if (!pluginChain && core) {
1248
- pluginChain = core.getProcessTelContext().getNext();
1249
- }
1250
- var nextPlugin = _nextPlugin;
1251
- if (_nextPlugin && _nextPlugin[strGetPlugin]) {
1252
- nextPlugin = _nextPlugin[strGetPlugin]();
1583
+ return hasRun;
1584
+ }
1585
+ if (!_processChain(unloadCtx, _callTeardown, "unload", function () { }, unloadState.isAsync)) {
1586
+ unloadCtx.processNext(unloadState);
1587
+ }
1588
+ }
1589
+ function _updatePlugin(updateCtx, updateState) {
1590
+ function _callUpdate() {
1591
+ var hasRun = false;
1592
+ if (plugin) {
1593
+ var pluginState = _getPluginState(plugin);
1594
+ var pluginCore = plugin[strCore] || pluginState.core;
1595
+ if (plugin && (!pluginCore || pluginCore === updateCtx[strCore]()) && !pluginState[strTeardown]) {
1596
+ if (plugin[strUpdate] && plugin[strUpdate](updateCtx, updateState) === true) {
1597
+ hasRun = true;
1598
+ }
1599
+ }
1253
1600
  }
1254
- _self.core = core;
1255
- _rootCtx = new ProcessTelemetryContext(pluginChain, config, core, nextPlugin);
1256
- _isinitialized = true;
1257
- };
1601
+ return hasRun;
1602
+ }
1603
+ if (!_processChain(updateCtx, _callUpdate, "update", function () { }, false)) {
1604
+ updateCtx.processNext(updateState);
1605
+ }
1258
1606
  }
1259
- BaseTelemetryPlugin.prototype.initialize = function (config, core, extensions, pluginChain) {
1260
- this._baseTelInit(config, core, extensions, pluginChain);
1261
- };
1262
- return BaseTelemetryPlugin;
1263
- }());
1607
+ return objFreeze(proxyChain);
1608
+ }
1264
1609
 
1265
1610
  var strToGMTString = "toGMTString";
1266
1611
  var strToUTCString = "toUTCString";
@@ -1270,7 +1615,6 @@
1270
1615
  var strIsCookieUseDisabled = "isCookieUseDisabled";
1271
1616
  var strDisableCookiesUsage = "disableCookiesUsage";
1272
1617
  var strConfigCookieMgr = "_ckMgr";
1273
- var strEmpty = "";
1274
1618
  var _supportsCookies = null;
1275
1619
  var _allowUaSameSite = null;
1276
1620
  var _parsedCookieValue = null;
@@ -1347,7 +1691,7 @@
1347
1691
  var result = false;
1348
1692
  if (_isMgrEnabled(cookieMgr)) {
1349
1693
  var values = {};
1350
- var theValue = strTrim(value || strEmpty);
1694
+ var theValue = strTrim(value || strEmpty$1);
1351
1695
  var idx = theValue.indexOf(";");
1352
1696
  if (idx !== -1) {
1353
1697
  theValue = strTrim(value.substring(0, idx));
@@ -1362,11 +1706,11 @@
1362
1706
  if (expireMs > 0) {
1363
1707
  var expiry = new Date();
1364
1708
  expiry.setTime(expireMs);
1365
- setValue(values, strExpires, _formatDate(expiry, !_isIE ? strToUTCString : strToGMTString) || _formatDate(expiry, _isIE ? strToGMTString : strToUTCString) || strEmpty, isTruthy);
1709
+ setValue(values, strExpires, _formatDate(expiry, !_isIE ? strToUTCString : strToGMTString) || _formatDate(expiry, _isIE ? strToGMTString : strToUTCString) || strEmpty$1, isTruthy);
1366
1710
  }
1367
1711
  }
1368
1712
  if (!_isIE) {
1369
- setValue(values, "max-age", strEmpty + maxAgeSec, null, isUndefined);
1713
+ setValue(values, "max-age", strEmpty$1 + maxAgeSec, null, isUndefined);
1370
1714
  }
1371
1715
  }
1372
1716
  var location_1 = getLocation();
@@ -1387,7 +1731,7 @@
1387
1731
  return result;
1388
1732
  },
1389
1733
  get: function (name) {
1390
- var value = strEmpty;
1734
+ var value = strEmpty$1;
1391
1735
  if (_isMgrEnabled(cookieMgr)) {
1392
1736
  value = (cookieMgrConfig.getCookie || _getCookieValue)(name);
1393
1737
  }
@@ -1412,7 +1756,7 @@
1412
1756
  values["max-age"] = "0";
1413
1757
  }
1414
1758
  var delCookie = cookieMgrConfig.delCookie || _setCookieValue;
1415
- delCookie(name, _formatCookieValue(strEmpty, values));
1759
+ delCookie(name, _formatCookieValue(strEmpty$1, values));
1416
1760
  result = true;
1417
1761
  }
1418
1762
  return result;
@@ -1429,7 +1773,7 @@
1429
1773
  _supportsCookies = doc[strCookie] !== undefined;
1430
1774
  }
1431
1775
  catch (e) {
1432
- logger && logger.throwInternal(LoggingSeverity.WARNING, _InternalMessageId.CannotAccessCookie, "Cannot access document.cookie - " + getExceptionName(e), { exception: dumpObj(e) });
1776
+ _throwInternal(logger, 2 , 68 , "Cannot access document.cookie - " + getExceptionName(e), { exception: dumpObj(e) });
1433
1777
  }
1434
1778
  }
1435
1779
  return _supportsCookies;
@@ -1439,7 +1783,7 @@
1439
1783
  if (theValue && theValue.length) {
1440
1784
  var parts = strTrim(theValue).split(";");
1441
1785
  arrForEach(parts, function (thePart) {
1442
- thePart = strTrim(thePart || strEmpty);
1786
+ thePart = strTrim(thePart || strEmpty$1);
1443
1787
  if (thePart) {
1444
1788
  var idx = thePart.indexOf("=");
1445
1789
  if (idx === -1) {
@@ -1460,21 +1804,21 @@
1460
1804
  return null;
1461
1805
  }
1462
1806
  function _formatCookieValue(value, values) {
1463
- var cookieValue = value || strEmpty;
1807
+ var cookieValue = value || strEmpty$1;
1464
1808
  objForEachKey(values, function (name, theValue) {
1465
- cookieValue += "; " + name + (!isNullOrUndefined(theValue) ? "=" + theValue : strEmpty);
1809
+ cookieValue += "; " + name + (!isNullOrUndefined(theValue) ? "=" + theValue : strEmpty$1);
1466
1810
  });
1467
1811
  return cookieValue;
1468
1812
  }
1469
1813
  function _getCookieValue(name) {
1470
- var cookieValue = strEmpty;
1814
+ var cookieValue = strEmpty$1;
1471
1815
  if (_doc) {
1472
- var theCookie = _doc[strCookie] || strEmpty;
1816
+ var theCookie = _doc[strCookie] || strEmpty$1;
1473
1817
  if (_parsedCookieValue !== theCookie) {
1474
1818
  _cookieCache = _extractParts(theCookie);
1475
1819
  _parsedCookieValue = theCookie;
1476
1820
  }
1477
- cookieValue = strTrim(_cookieCache[name] || strEmpty);
1821
+ cookieValue = strTrim(_cookieCache[name] || strEmpty$1);
1478
1822
  }
1479
1823
  return cookieValue;
1480
1824
  }
@@ -1508,74 +1852,591 @@
1508
1852
  return false;
1509
1853
  }
1510
1854
 
1511
- var UInt32Mask = 0x100000000;
1512
- var MaxUInt32 = 0xffffffff;
1513
- var _mwcSeeded = false;
1514
- var _mwcW = 123456789;
1515
- var _mwcZ = 987654321;
1516
- function _mwcSeed(seedValue) {
1517
- if (seedValue < 0) {
1518
- seedValue >>>= 0;
1855
+ var strExtensionConfig = "extensionConfig";
1856
+
1857
+ function createUnloadHandlerContainer() {
1858
+ var handlers = [];
1859
+ function _addHandler(handler) {
1860
+ if (handler) {
1861
+ handlers.push(handler);
1862
+ }
1519
1863
  }
1520
- _mwcW = (123456789 + seedValue) & MaxUInt32;
1521
- _mwcZ = (987654321 - seedValue) & MaxUInt32;
1522
- _mwcSeeded = true;
1864
+ function _runHandlers(unloadCtx, unloadState) {
1865
+ arrForEach(handlers, function (handler) {
1866
+ try {
1867
+ handler(unloadCtx, unloadState);
1868
+ }
1869
+ catch (e) {
1870
+ _throwInternal(unloadCtx.diagLog(), 2 , 73 , "Unexpected error calling unload handler - " + dumpObj(e));
1871
+ }
1872
+ });
1873
+ handlers = [];
1874
+ }
1875
+ return {
1876
+ add: _addHandler,
1877
+ run: _runHandlers
1878
+ };
1523
1879
  }
1524
- function _autoSeedMwc() {
1525
- try {
1526
- var now = dateNow() & 0x7fffffff;
1527
- _mwcSeed(((Math.random() * UInt32Mask) ^ now) + now);
1880
+
1881
+ var strGetPlugin = "getPlugin";
1882
+ var BaseTelemetryPlugin = /** @class */ (function () {
1883
+ function BaseTelemetryPlugin() {
1884
+ var _self = this;
1885
+ var _isinitialized;
1886
+ var _rootCtx;
1887
+ var _nextPlugin;
1888
+ var _unloadHandlerContainer;
1889
+ var _hooks;
1890
+ _initDefaults();
1891
+ dynamicProto(BaseTelemetryPlugin, _self, function (_self) {
1892
+ _self.initialize = function (config, core, extensions, pluginChain) {
1893
+ _setDefaults(config, core, pluginChain);
1894
+ _isinitialized = true;
1895
+ };
1896
+ _self.teardown = function (unloadCtx, unloadState) {
1897
+ if (!_self.core || (unloadCtx && _self.core !== unloadCtx.core())) {
1898
+ return;
1899
+ }
1900
+ var result;
1901
+ var unloadDone = false;
1902
+ var theUnloadCtx = unloadCtx || createProcessTelemetryUnloadContext(null, {}, _self.core, _nextPlugin && _nextPlugin[strGetPlugin] ? _nextPlugin[strGetPlugin]() : _nextPlugin);
1903
+ var theUnloadState = unloadState || {
1904
+ reason: 0 ,
1905
+ isAsync: false
1906
+ };
1907
+ function _unloadCallback() {
1908
+ if (!unloadDone) {
1909
+ unloadDone = true;
1910
+ _unloadHandlerContainer.run(theUnloadCtx, unloadState);
1911
+ arrForEach(_hooks, function (fn) {
1912
+ fn.rm();
1913
+ });
1914
+ _hooks = [];
1915
+ if (result === true) {
1916
+ theUnloadCtx.processNext(theUnloadState);
1917
+ }
1918
+ _initDefaults();
1919
+ }
1920
+ }
1921
+ if (!_self[strDoTeardown] || _self[strDoTeardown](theUnloadCtx, theUnloadState, _unloadCallback) !== true) {
1922
+ _unloadCallback();
1923
+ }
1924
+ else {
1925
+ result = true;
1926
+ }
1927
+ return result;
1928
+ };
1929
+ _self.update = function (updateCtx, updateState) {
1930
+ if (!_self.core || (updateCtx && _self.core !== updateCtx.core())) {
1931
+ return;
1932
+ }
1933
+ var result;
1934
+ var updateDone = false;
1935
+ var theUpdateCtx = updateCtx || createProcessTelemetryUpdateContext(null, {}, _self.core, _nextPlugin && _nextPlugin[strGetPlugin] ? _nextPlugin[strGetPlugin]() : _nextPlugin);
1936
+ var theUpdateState = updateState || {
1937
+ reason: 0
1938
+ };
1939
+ function _updateCallback() {
1940
+ if (!updateDone) {
1941
+ updateDone = true;
1942
+ _setDefaults(theUpdateCtx.getCfg(), theUpdateCtx.core(), theUpdateCtx.getNext());
1943
+ }
1944
+ }
1945
+ if (!_self._doUpdate || _self._doUpdate(theUpdateCtx, theUpdateState, _updateCallback) !== true) {
1946
+ _updateCallback();
1947
+ }
1948
+ else {
1949
+ result = true;
1950
+ }
1951
+ return result;
1952
+ };
1953
+ _self._addHook = function (hooks) {
1954
+ if (hooks) {
1955
+ if (isArray(hooks)) {
1956
+ _hooks = _hooks.concat(hooks);
1957
+ }
1958
+ else {
1959
+ _hooks.push(hooks);
1960
+ }
1961
+ }
1962
+ };
1963
+ proxyFunctionAs(_self, "_addUnloadCb", function () { return _unloadHandlerContainer; }, "add");
1964
+ });
1965
+ _self.diagLog = function (itemCtx) {
1966
+ return _getTelCtx(itemCtx).diagLog();
1967
+ };
1968
+ _self[strIsInitialized] = function () {
1969
+ return _isinitialized;
1970
+ };
1971
+ _self.setInitialized = function (isInitialized) {
1972
+ _isinitialized = isInitialized;
1973
+ };
1974
+ _self[strSetNextPlugin] = function (next) {
1975
+ _nextPlugin = next;
1976
+ };
1977
+ _self.processNext = function (env, itemCtx) {
1978
+ if (itemCtx) {
1979
+ itemCtx.processNext(env);
1980
+ }
1981
+ else if (_nextPlugin && isFunction(_nextPlugin.processTelemetry)) {
1982
+ _nextPlugin.processTelemetry(env, null);
1983
+ }
1984
+ };
1985
+ _self._getTelCtx = _getTelCtx;
1986
+ function _getTelCtx(currentCtx) {
1987
+ if (currentCtx === void 0) { currentCtx = null; }
1988
+ var itemCtx = currentCtx;
1989
+ if (!itemCtx) {
1990
+ var rootCtx = _rootCtx || createProcessTelemetryContext(null, {}, _self.core);
1991
+ if (_nextPlugin && _nextPlugin[strGetPlugin]) {
1992
+ itemCtx = rootCtx.createNew(null, _nextPlugin[strGetPlugin]);
1993
+ }
1994
+ else {
1995
+ itemCtx = rootCtx.createNew(null, _nextPlugin);
1996
+ }
1997
+ }
1998
+ return itemCtx;
1999
+ }
2000
+ function _setDefaults(config, core, pluginChain) {
2001
+ if (config) {
2002
+ setValue(config, strExtensionConfig, [], null, isNullOrUndefined);
2003
+ }
2004
+ if (!pluginChain && core) {
2005
+ pluginChain = core.getProcessTelContext().getNext();
2006
+ }
2007
+ var nextPlugin = _nextPlugin;
2008
+ if (_nextPlugin && _nextPlugin[strGetPlugin]) {
2009
+ nextPlugin = _nextPlugin[strGetPlugin]();
2010
+ }
2011
+ _self.core = core;
2012
+ _rootCtx = createProcessTelemetryContext(pluginChain, config, core, nextPlugin);
2013
+ }
2014
+ function _initDefaults() {
2015
+ _isinitialized = false;
2016
+ _self.core = null;
2017
+ _rootCtx = null;
2018
+ _nextPlugin = null;
2019
+ _hooks = [];
2020
+ _unloadHandlerContainer = createUnloadHandlerContainer();
2021
+ }
1528
2022
  }
1529
- catch (e) {
2023
+ return BaseTelemetryPlugin;
2024
+ }());
2025
+
2026
+ var strOnPrefix = "on";
2027
+ var strAttachEvent = "attachEvent";
2028
+ var strAddEventHelper = "addEventListener";
2029
+ var strDetachEvent = "detachEvent";
2030
+ var strRemoveEventListener = "removeEventListener";
2031
+ var strEvents = "events";
2032
+ createUniqueNamespace("aiEvtPageHide");
2033
+ createUniqueNamespace("aiEvtPageShow");
2034
+ var rRemoveEmptyNs = /\.[\.]+/g;
2035
+ var rRemoveTrailingEmptyNs = /[\.]+$/;
2036
+ var _guid = 1;
2037
+ var elmNodeData = createElmNodeData("events");
2038
+ var eventNamespace = /^([^.]*)(?:\.(.+)|)/;
2039
+ function _normalizeNamespace(name) {
2040
+ if (name && name.replace) {
2041
+ return name.replace(/^\s*\.*|\.*\s*$/g, "");
2042
+ }
2043
+ return name;
2044
+ }
2045
+ function _getEvtNamespace(eventName, evtNamespace) {
2046
+ if (evtNamespace) {
2047
+ var theNamespace_1 = "";
2048
+ if (isArray(evtNamespace)) {
2049
+ theNamespace_1 = "";
2050
+ arrForEach(evtNamespace, function (name) {
2051
+ name = _normalizeNamespace(name);
2052
+ if (name) {
2053
+ if (name[0] !== ".") {
2054
+ name = "." + name;
2055
+ }
2056
+ theNamespace_1 += name;
2057
+ }
2058
+ });
2059
+ }
2060
+ else {
2061
+ theNamespace_1 = _normalizeNamespace(evtNamespace);
2062
+ }
2063
+ if (theNamespace_1) {
2064
+ if (theNamespace_1[0] !== ".") {
2065
+ theNamespace_1 = "." + theNamespace_1;
2066
+ }
2067
+ eventName = (eventName || "") + theNamespace_1;
2068
+ }
2069
+ }
2070
+ var parsedEvent = (eventNamespace.exec(eventName || "") || []);
2071
+ return {
2072
+ type: parsedEvent[1],
2073
+ ns: ((parsedEvent[2] || "").replace(rRemoveEmptyNs, ".").replace(rRemoveTrailingEmptyNs, "").split(".").sort()).join(".")
2074
+ };
2075
+ }
2076
+ function _getRegisteredEvents(target, evtName, addDefault) {
2077
+ if (addDefault === void 0) { addDefault = true; }
2078
+ var aiEvts = elmNodeData.get(target, strEvents, {}, addDefault);
2079
+ var registeredEvents = aiEvts[evtName];
2080
+ if (!registeredEvents) {
2081
+ registeredEvents = aiEvts[evtName] = [];
1530
2082
  }
2083
+ return registeredEvents;
1531
2084
  }
1532
- function random32(signed) {
1533
- var value;
1534
- var c = getCrypto() || getMsCrypto();
1535
- if (c && c.getRandomValues) {
1536
- value = c.getRandomValues(new Uint32Array(1))[0] & MaxUInt32;
2085
+ function _doDetach(obj, evtName, handlerRef, useCapture) {
2086
+ if (obj && evtName && evtName.type) {
2087
+ if (obj[strRemoveEventListener]) {
2088
+ obj[strRemoveEventListener](evtName.type, handlerRef, useCapture);
2089
+ }
2090
+ else if (obj[strDetachEvent]) {
2091
+ obj[strDetachEvent](strOnPrefix + evtName.type, handlerRef);
2092
+ }
1537
2093
  }
1538
- else if (isIE()) {
1539
- if (!_mwcSeeded) {
1540
- _autoSeedMwc();
2094
+ }
2095
+ function _doAttach(obj, evtName, handlerRef, useCapture) {
2096
+ var result = false;
2097
+ if (obj && evtName && evtName.type && handlerRef) {
2098
+ if (obj[strAddEventHelper]) {
2099
+ obj[strAddEventHelper](evtName.type, handlerRef, useCapture);
2100
+ result = true;
2101
+ }
2102
+ else if (obj[strAttachEvent]) {
2103
+ obj[strAttachEvent](strOnPrefix + evtName.type, handlerRef);
2104
+ result = true;
2105
+ }
2106
+ }
2107
+ return result;
2108
+ }
2109
+ function _doUnregister(target, events, evtName, unRegFn) {
2110
+ var idx = events.length;
2111
+ while (idx--) {
2112
+ var theEvent = events[idx];
2113
+ if (theEvent) {
2114
+ if (!evtName.ns || evtName.ns === theEvent.evtName.ns) {
2115
+ if (!unRegFn || unRegFn(theEvent)) {
2116
+ _doDetach(target, theEvent.evtName, theEvent.handler, theEvent.capture);
2117
+ events.splice(idx, 1);
2118
+ }
2119
+ }
1541
2120
  }
1542
- value = mwcRandom32() & MaxUInt32;
2121
+ }
2122
+ }
2123
+ function _unregisterEvents(target, evtName, unRegFn) {
2124
+ if (evtName.type) {
2125
+ _doUnregister(target, _getRegisteredEvents(target, evtName.type), evtName, unRegFn);
1543
2126
  }
1544
2127
  else {
1545
- value = Math.floor((UInt32Mask * Math.random()) | 0);
2128
+ var eventCache = elmNodeData.get(target, strEvents, {});
2129
+ objForEachKey(eventCache, function (evtType, events) {
2130
+ _doUnregister(target, events, evtName, unRegFn);
2131
+ });
2132
+ if (objKeys(eventCache).length === 0) {
2133
+ elmNodeData.kill(target, strEvents);
2134
+ }
1546
2135
  }
1547
- if (!signed) {
1548
- value >>>= 0;
2136
+ }
2137
+ function mergeEvtNamespace(theNamespace, namespaces) {
2138
+ var newNamespaces;
2139
+ if (namespaces) {
2140
+ if (isArray(namespaces)) {
2141
+ newNamespaces = [theNamespace].concat(namespaces);
2142
+ }
2143
+ else {
2144
+ newNamespaces = [theNamespace, namespaces];
2145
+ }
2146
+ newNamespaces = (_getEvtNamespace("xx", newNamespaces).ns).split(".");
1549
2147
  }
1550
- return value;
2148
+ else {
2149
+ newNamespaces = theNamespace;
2150
+ }
2151
+ return newNamespaces;
1551
2152
  }
1552
- function mwcRandom32(signed) {
1553
- _mwcZ = (36969 * (_mwcZ & 0xFFFF) + (_mwcZ >> 16)) & MaxUInt32;
1554
- _mwcW = (18000 * (_mwcW & 0xFFFF) + (_mwcW >> 16)) & MaxUInt32;
1555
- var value = (((_mwcZ << 16) + (_mwcW & 0xFFFF)) >>> 0) & MaxUInt32 | 0;
1556
- if (!signed) {
1557
- value >>>= 0;
2153
+ function eventOn(target, eventName, handlerRef, evtNamespace, useCapture) {
2154
+ if (useCapture === void 0) { useCapture = false; }
2155
+ var result = false;
2156
+ if (target) {
2157
+ try {
2158
+ var evtName = _getEvtNamespace(eventName, evtNamespace);
2159
+ result = _doAttach(target, evtName, handlerRef, useCapture);
2160
+ if (result && elmNodeData.accept(target)) {
2161
+ var registeredEvent = {
2162
+ guid: _guid++,
2163
+ evtName: evtName,
2164
+ handler: handlerRef,
2165
+ capture: useCapture
2166
+ };
2167
+ _getRegisteredEvents(target, evtName.type).push(registeredEvent);
2168
+ }
2169
+ }
2170
+ catch (e) {
2171
+ }
2172
+ }
2173
+ return result;
2174
+ }
2175
+ function eventOff(target, eventName, handlerRef, evtNamespace, useCapture) {
2176
+ if (useCapture === void 0) { useCapture = false; }
2177
+ if (target) {
2178
+ try {
2179
+ var evtName_1 = _getEvtNamespace(eventName, evtNamespace);
2180
+ var found_1 = false;
2181
+ _unregisterEvents(target, evtName_1, function (regEvent) {
2182
+ if ((evtName_1.ns && !handlerRef) || regEvent.handler === handlerRef) {
2183
+ found_1 = true;
2184
+ return true;
2185
+ }
2186
+ return false;
2187
+ });
2188
+ if (!found_1) {
2189
+ _doDetach(target, evtName_1, handlerRef, useCapture);
2190
+ }
2191
+ }
2192
+ catch (e) {
2193
+ }
2194
+ }
2195
+ }
2196
+
2197
+ function generateW3CId() {
2198
+ var hexValues = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f"];
2199
+ var oct = strEmpty$1, tmp;
2200
+ for (var a = 0; a < 4; a++) {
2201
+ tmp = random32();
2202
+ oct +=
2203
+ hexValues[tmp & 0xF] +
2204
+ hexValues[tmp >> 4 & 0xF] +
2205
+ hexValues[tmp >> 8 & 0xF] +
2206
+ hexValues[tmp >> 12 & 0xF] +
2207
+ hexValues[tmp >> 16 & 0xF] +
2208
+ hexValues[tmp >> 20 & 0xF] +
2209
+ hexValues[tmp >> 24 & 0xF] +
2210
+ hexValues[tmp >> 28 & 0xF];
2211
+ }
2212
+ var clockSequenceHi = hexValues[8 + (random32() & 0x03) | 0];
2213
+ return oct.substr(0, 8) + oct.substr(9, 4) + "4" + oct.substr(13, 3) + clockSequenceHi + oct.substr(16, 3) + oct.substr(19, 12);
2214
+ }
2215
+
2216
+ var LoggingSeverity = createEnumStyle({
2217
+ CRITICAL: 1 ,
2218
+ WARNING: 2
2219
+ });
2220
+ var _InternalMessageId = createEnumStyle({
2221
+ BrowserDoesNotSupportLocalStorage: 0 ,
2222
+ BrowserCannotReadLocalStorage: 1 ,
2223
+ BrowserCannotReadSessionStorage: 2 ,
2224
+ BrowserCannotWriteLocalStorage: 3 ,
2225
+ BrowserCannotWriteSessionStorage: 4 ,
2226
+ BrowserFailedRemovalFromLocalStorage: 5 ,
2227
+ BrowserFailedRemovalFromSessionStorage: 6 ,
2228
+ CannotSendEmptyTelemetry: 7 ,
2229
+ ClientPerformanceMathError: 8 ,
2230
+ ErrorParsingAISessionCookie: 9 ,
2231
+ ErrorPVCalc: 10 ,
2232
+ ExceptionWhileLoggingError: 11 ,
2233
+ FailedAddingTelemetryToBuffer: 12 ,
2234
+ FailedMonitorAjaxAbort: 13 ,
2235
+ FailedMonitorAjaxDur: 14 ,
2236
+ FailedMonitorAjaxOpen: 15 ,
2237
+ FailedMonitorAjaxRSC: 16 ,
2238
+ FailedMonitorAjaxSend: 17 ,
2239
+ FailedMonitorAjaxGetCorrelationHeader: 18 ,
2240
+ FailedToAddHandlerForOnBeforeUnload: 19 ,
2241
+ FailedToSendQueuedTelemetry: 20 ,
2242
+ FailedToReportDataLoss: 21 ,
2243
+ FlushFailed: 22 ,
2244
+ MessageLimitPerPVExceeded: 23 ,
2245
+ MissingRequiredFieldSpecification: 24 ,
2246
+ NavigationTimingNotSupported: 25 ,
2247
+ OnError: 26 ,
2248
+ SessionRenewalDateIsZero: 27 ,
2249
+ SenderNotInitialized: 28 ,
2250
+ StartTrackEventFailed: 29 ,
2251
+ StopTrackEventFailed: 30 ,
2252
+ StartTrackFailed: 31 ,
2253
+ StopTrackFailed: 32 ,
2254
+ TelemetrySampledAndNotSent: 33 ,
2255
+ TrackEventFailed: 34 ,
2256
+ TrackExceptionFailed: 35 ,
2257
+ TrackMetricFailed: 36 ,
2258
+ TrackPVFailed: 37 ,
2259
+ TrackPVFailedCalc: 38 ,
2260
+ TrackTraceFailed: 39 ,
2261
+ TransmissionFailed: 40 ,
2262
+ FailedToSetStorageBuffer: 41 ,
2263
+ FailedToRestoreStorageBuffer: 42 ,
2264
+ InvalidBackendResponse: 43 ,
2265
+ FailedToFixDepricatedValues: 44 ,
2266
+ InvalidDurationValue: 45 ,
2267
+ TelemetryEnvelopeInvalid: 46 ,
2268
+ CreateEnvelopeError: 47 ,
2269
+ CannotSerializeObject: 48 ,
2270
+ CannotSerializeObjectNonSerializable: 49 ,
2271
+ CircularReferenceDetected: 50 ,
2272
+ ClearAuthContextFailed: 51 ,
2273
+ ExceptionTruncated: 52 ,
2274
+ IllegalCharsInName: 53 ,
2275
+ ItemNotInArray: 54 ,
2276
+ MaxAjaxPerPVExceeded: 55 ,
2277
+ MessageTruncated: 56 ,
2278
+ NameTooLong: 57 ,
2279
+ SampleRateOutOfRange: 58 ,
2280
+ SetAuthContextFailed: 59 ,
2281
+ SetAuthContextFailedAccountName: 60 ,
2282
+ StringValueTooLong: 61 ,
2283
+ StartCalledMoreThanOnce: 62 ,
2284
+ StopCalledWithoutStart: 63 ,
2285
+ TelemetryInitializerFailed: 64 ,
2286
+ TrackArgumentsNotSpecified: 65 ,
2287
+ UrlTooLong: 66 ,
2288
+ SessionStorageBufferFull: 67 ,
2289
+ CannotAccessCookie: 68 ,
2290
+ IdTooLong: 69 ,
2291
+ InvalidEvent: 70 ,
2292
+ FailedMonitorAjaxSetRequestHeader: 71 ,
2293
+ SendBrowserInfoOnUserInit: 72 ,
2294
+ PluginException: 73 ,
2295
+ NotificationException: 74 ,
2296
+ SnippetScriptLoadFailure: 99 ,
2297
+ InvalidInstrumentationKey: 100 ,
2298
+ CannotParseAiBlobValue: 101 ,
2299
+ InvalidContentBlob: 102 ,
2300
+ TrackPageActionEventFailed: 103 ,
2301
+ FailedAddingCustomDefinedRequestContext: 104 ,
2302
+ InMemoryStorageBufferFull: 105
2303
+ });
2304
+
2305
+ var aiInstrumentHooks = "_aiHooks";
2306
+ var cbNames = [
2307
+ "req", "rsp", "hkErr", "fnErr"
2308
+ ];
2309
+ function _arrLoop(arr, fn) {
2310
+ if (arr) {
2311
+ for (var lp = 0; lp < arr.length; lp++) {
2312
+ if (fn(arr[lp], lp)) {
2313
+ break;
2314
+ }
2315
+ }
2316
+ }
2317
+ }
2318
+ function _doCallbacks(hooks, callDetails, cbArgs, hookCtx, type) {
2319
+ if (type >= 0 && type <= 2 ) {
2320
+ _arrLoop(hooks, function (hook, idx) {
2321
+ var cbks = hook.cbks;
2322
+ var cb = cbks[cbNames[type]];
2323
+ if (cb) {
2324
+ callDetails.ctx = function () {
2325
+ var ctx = hookCtx[idx] = (hookCtx[idx] || {});
2326
+ return ctx;
2327
+ };
2328
+ try {
2329
+ cb.apply(callDetails.inst, cbArgs);
2330
+ }
2331
+ catch (err) {
2332
+ var orgEx = callDetails.err;
2333
+ try {
2334
+ var hookErrorCb = cbks[cbNames[2 ]];
2335
+ if (hookErrorCb) {
2336
+ callDetails.err = err;
2337
+ hookErrorCb.apply(callDetails.inst, cbArgs);
2338
+ }
2339
+ }
2340
+ catch (e) {
2341
+ }
2342
+ finally {
2343
+ callDetails.err = orgEx;
2344
+ }
2345
+ }
2346
+ }
2347
+ });
1558
2348
  }
1559
- return value;
1560
2349
  }
1561
-
1562
- function generateW3CId() {
1563
- var hexValues = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f"];
1564
- var oct = "", tmp;
1565
- for (var a = 0; a < 4; a++) {
1566
- tmp = random32();
1567
- oct +=
1568
- hexValues[tmp & 0xF] +
1569
- hexValues[tmp >> 4 & 0xF] +
1570
- hexValues[tmp >> 8 & 0xF] +
1571
- hexValues[tmp >> 12 & 0xF] +
1572
- hexValues[tmp >> 16 & 0xF] +
1573
- hexValues[tmp >> 20 & 0xF] +
1574
- hexValues[tmp >> 24 & 0xF] +
1575
- hexValues[tmp >> 28 & 0xF];
2350
+ function _createFunctionHook(aiHook) {
2351
+ return function () {
2352
+ var funcThis = this;
2353
+ var orgArgs = arguments;
2354
+ var hooks = aiHook.h;
2355
+ var funcArgs = {
2356
+ name: aiHook.n,
2357
+ inst: funcThis,
2358
+ ctx: null,
2359
+ set: _replaceArg
2360
+ };
2361
+ var hookCtx = [];
2362
+ var cbArgs = _createArgs([funcArgs], orgArgs);
2363
+ funcArgs.evt = getGlobalInst("event");
2364
+ function _createArgs(target, theArgs) {
2365
+ _arrLoop(theArgs, function (arg) {
2366
+ target.push(arg);
2367
+ });
2368
+ return target;
2369
+ }
2370
+ function _replaceArg(idx, value) {
2371
+ orgArgs = _createArgs([], orgArgs);
2372
+ orgArgs[idx] = value;
2373
+ cbArgs = _createArgs([funcArgs], orgArgs);
2374
+ }
2375
+ _doCallbacks(hooks, funcArgs, cbArgs, hookCtx, 0 );
2376
+ var theFunc = aiHook.f;
2377
+ try {
2378
+ funcArgs.rslt = theFunc.apply(funcThis, orgArgs);
2379
+ }
2380
+ catch (err) {
2381
+ funcArgs.err = err;
2382
+ _doCallbacks(hooks, funcArgs, cbArgs, hookCtx, 3 );
2383
+ throw err;
2384
+ }
2385
+ _doCallbacks(hooks, funcArgs, cbArgs, hookCtx, 1 );
2386
+ return funcArgs.rslt;
2387
+ };
2388
+ }
2389
+ function _getOwner(target, name, checkPrototype) {
2390
+ var owner = null;
2391
+ if (target) {
2392
+ if (hasOwnProperty(target, name)) {
2393
+ owner = target;
2394
+ }
2395
+ else if (checkPrototype) {
2396
+ owner = _getOwner(_getObjProto(target), name, false);
2397
+ }
1576
2398
  }
1577
- var clockSequenceHi = hexValues[8 + (random32() & 0x03) | 0];
1578
- return oct.substr(0, 8) + oct.substr(9, 4) + "4" + oct.substr(13, 3) + clockSequenceHi + oct.substr(16, 3) + oct.substr(19, 12);
2399
+ return owner;
2400
+ }
2401
+ function InstrumentFunc(target, funcName, callbacks, checkPrototype) {
2402
+ if (checkPrototype === void 0) { checkPrototype = true; }
2403
+ if (target && funcName && callbacks) {
2404
+ var owner = _getOwner(target, funcName, checkPrototype);
2405
+ if (owner) {
2406
+ var fn = owner[funcName];
2407
+ if (typeof fn === strShimFunction) {
2408
+ var aiHook_1 = fn[aiInstrumentHooks];
2409
+ if (!aiHook_1) {
2410
+ aiHook_1 = {
2411
+ i: 0,
2412
+ n: funcName,
2413
+ f: fn,
2414
+ h: []
2415
+ };
2416
+ var newFunc = _createFunctionHook(aiHook_1);
2417
+ newFunc[aiInstrumentHooks] = aiHook_1;
2418
+ owner[funcName] = newFunc;
2419
+ }
2420
+ var theHook = {
2421
+ id: aiHook_1.i,
2422
+ cbks: callbacks,
2423
+ rm: function () {
2424
+ var id = this.id;
2425
+ _arrLoop(aiHook_1.h, function (hook, idx) {
2426
+ if (hook.id === id) {
2427
+ aiHook_1.h.splice(idx, 1);
2428
+ return 1;
2429
+ }
2430
+ });
2431
+ }
2432
+ };
2433
+ aiHook_1.i++;
2434
+ aiHook_1.h.push(theHook);
2435
+ return theHook;
2436
+ }
2437
+ }
2438
+ }
2439
+ return null;
1579
2440
  }
1580
2441
 
1581
2442
  function dataSanitizeKeyAndAddUniqueness(logger, key, map) {
@@ -1598,7 +2459,7 @@
1598
2459
  name = strTrim(name.toString());
1599
2460
  if (name.length > 150 ) {
1600
2461
  nameTrunc = name.substring(0, 150 );
1601
- logger && logger.throwInternal(LoggingSeverity.WARNING, _InternalMessageId.NameTooLong, "name is too long. It has been truncated to " + 150 + " characters.", { name: name }, true);
2462
+ _throwInternal(logger, 2 , _InternalMessageId.NameTooLong, "name is too long. It has been truncated to " + 150 + " characters.", { name: name }, true);
1602
2463
  }
1603
2464
  }
1604
2465
  return nameTrunc || name;
@@ -1611,7 +2472,7 @@
1611
2472
  value = strTrim(value);
1612
2473
  if (value.toString().length > maxLength) {
1613
2474
  valueTrunc = value.toString().substring(0, maxLength);
1614
- logger && logger.throwInternal(LoggingSeverity.WARNING, _InternalMessageId.StringValueTooLong, "string value is too long. It has been truncated to " + maxLength + " characters.", { value: value }, true);
2475
+ _throwInternal(logger, 2 , _InternalMessageId.StringValueTooLong, "string value is too long. It has been truncated to " + maxLength + " characters.", { value: value }, true);
1615
2476
  }
1616
2477
  }
1617
2478
  return valueTrunc || value;
@@ -1624,7 +2485,7 @@
1624
2485
  if (message) {
1625
2486
  if (message.length > 32768 ) {
1626
2487
  messageTrunc = message.substring(0, 32768 );
1627
- logger && logger.throwInternal(LoggingSeverity.WARNING, _InternalMessageId.MessageTruncated, "message is too long, it has been truncated to " + 32768 + " characters.", { message: message }, true);
2488
+ _throwInternal(logger, 2 , _InternalMessageId.MessageTruncated, "message is too long, it has been truncated to " + 32768 + " characters.", { message: message }, true);
1628
2489
  }
1629
2490
  }
1630
2491
  return messageTrunc || message;
@@ -1635,7 +2496,7 @@
1635
2496
  var value = "" + exception;
1636
2497
  if (value.length > 32768 ) {
1637
2498
  exceptionTrunc = value.substring(0, 32768 );
1638
- logger && logger.throwInternal(LoggingSeverity.WARNING, _InternalMessageId.ExceptionTruncated, "exception is too long, it has been truncated to " + 32768 + " characters.", { exception: exception }, true);
2499
+ _throwInternal(logger, 2 , _InternalMessageId.ExceptionTruncated, "exception is too long, it has been truncated to " + 32768 + " characters.", { exception: exception }, true);
1639
2500
  }
1640
2501
  }
1641
2502
  return exceptionTrunc || exception;
@@ -1649,7 +2510,7 @@
1649
2510
  value = getJSON().stringify(value);
1650
2511
  }
1651
2512
  catch (e) {
1652
- logger && logger.throwInternal(LoggingSeverity.WARNING, _InternalMessageId.CannotSerializeObjectNonSerializable, "custom property is not valid", { exception: e }, true);
2513
+ _throwInternal(logger, 2 , _InternalMessageId.CannotSerializeObjectNonSerializable, "custom property is not valid", { exception: e }, true);
1653
2514
  }
1654
2515
  }
1655
2516
  value = dataSanitizeString(logger, value, 8192 );
@@ -1680,7 +2541,7 @@
1680
2541
  input = strTrim(input);
1681
2542
  if (input.length > maxLength) {
1682
2543
  inputTrunc = input.substring(0, maxLength);
1683
- logger && logger.throwInternal(LoggingSeverity.WARNING, _msgId, "input is too long, it has been truncated to " + maxLength + " characters.", { data: input }, true);
2544
+ _throwInternal(logger, 2 , _msgId, "input is too long, it has been truncated to " + maxLength + " characters.", { data: input }, true);
1684
2545
  }
1685
2546
  }
1686
2547
  return inputTrunc || input;
@@ -1705,6 +2566,7 @@
1705
2566
  return event;
1706
2567
  }
1707
2568
 
2569
+ var strEmpty = "";
1708
2570
  function stringToBoolOrDefault(str, defaultValue) {
1709
2571
  if (defaultValue === void 0) { defaultValue = false; }
1710
2572
  if (str === undefined || str === null) {
@@ -1717,16 +2579,16 @@
1717
2579
  totalms = 0;
1718
2580
  }
1719
2581
  totalms = Math.round(totalms);
1720
- var ms = "" + totalms % 1000;
1721
- var sec = "" + Math.floor(totalms / 1000) % 60;
1722
- var min = "" + Math.floor(totalms / (1000 * 60)) % 60;
1723
- var hour = "" + Math.floor(totalms / (1000 * 60 * 60)) % 24;
2582
+ var ms = strEmpty + totalms % 1000;
2583
+ var sec = strEmpty + Math.floor(totalms / 1000) % 60;
2584
+ var min = strEmpty + Math.floor(totalms / (1000 * 60)) % 60;
2585
+ var hour = strEmpty + Math.floor(totalms / (1000 * 60 * 60)) % 24;
1724
2586
  var days = Math.floor(totalms / (1000 * 60 * 60 * 24));
1725
2587
  ms = ms.length === 1 ? "00" + ms : ms.length === 2 ? "0" + ms : ms;
1726
2588
  sec = sec.length < 2 ? "0" + sec : sec;
1727
2589
  min = min.length < 2 ? "0" + min : min;
1728
2590
  hour = hour.length < 2 ? "0" + hour : hour;
1729
- return (days > 0 ? days + "." : "") + hour + ":" + min + ":" + sec + "." + ms;
2591
+ return (days > 0 ? days + "." : strEmpty) + hour + ":" + min + ":" + sec + "." + ms;
1730
2592
  }
1731
2593
  function isCrossOriginError(message, url, lineNumber, columnNumber, error) {
1732
2594
  return !error && isString(message) && (message === "Script error." || message === "Script error");
@@ -1735,18 +2597,17 @@
1735
2597
  var strNotSpecified = "not_specified";
1736
2598
  var strIkey = "iKey";
1737
2599
 
1738
- var StorageType;
1739
- (function (StorageType) {
1740
- StorageType[StorageType["LocalStorage"] = 0] = "LocalStorage";
1741
- StorageType[StorageType["SessionStorage"] = 1] = "SessionStorage";
1742
- })(StorageType || (StorageType = {}));
1743
- var DistributedTracingModes;
1744
- (function (DistributedTracingModes) {
1745
- DistributedTracingModes[DistributedTracingModes["AI"] = 0] = "AI";
1746
- DistributedTracingModes[DistributedTracingModes["AI_AND_W3C"] = 1] = "AI_AND_W3C";
1747
- DistributedTracingModes[DistributedTracingModes["W3C"] = 2] = "W3C";
1748
- })(DistributedTracingModes || (DistributedTracingModes = {}));
2600
+ var StorageType = createEnumStyle({
2601
+ LocalStorage: 0 ,
2602
+ SessionStorage: 1
2603
+ });
2604
+ createEnumStyle({
2605
+ AI: 0 ,
2606
+ AI_AND_W3C: 1 ,
2607
+ W3C: 2
2608
+ });
1749
2609
 
2610
+ var _canUseLocalStorage = undefined;
1750
2611
  var _canUseSessionStorage = undefined;
1751
2612
  function _getVerifiedStorageObject(storageType) {
1752
2613
  try {
@@ -1773,10 +2634,21 @@
1773
2634
  return null;
1774
2635
  }
1775
2636
  function utlDisableStorage() {
2637
+ _canUseLocalStorage = false;
1776
2638
  _canUseSessionStorage = false;
1777
2639
  }
1778
- function utlCanUseSessionStorage() {
1779
- if (_canUseSessionStorage === undefined) {
2640
+ function utlEnableStorage() {
2641
+ _canUseLocalStorage = utlCanUseLocalStorage(true);
2642
+ _canUseSessionStorage = utlCanUseSessionStorage(true);
2643
+ }
2644
+ function utlCanUseLocalStorage(reset) {
2645
+ if (reset || _canUseLocalStorage === undefined) {
2646
+ _canUseLocalStorage = !!_getVerifiedStorageObject(StorageType.LocalStorage);
2647
+ }
2648
+ return _canUseLocalStorage;
2649
+ }
2650
+ function utlCanUseSessionStorage(reset) {
2651
+ if (reset || _canUseSessionStorage === undefined) {
1780
2652
  _canUseSessionStorage = !!_getVerifiedStorageObject(StorageType.SessionStorage);
1781
2653
  }
1782
2654
  return _canUseSessionStorage;
@@ -1789,7 +2661,7 @@
1789
2661
  }
1790
2662
  catch (e) {
1791
2663
  _canUseSessionStorage = false;
1792
- logger.throwInternal(LoggingSeverity.WARNING, _InternalMessageId.BrowserCannotReadSessionStorage, "Browser failed read of session storage. " + getExceptionName(e), { exception: dumpObj(e) });
2664
+ _throwInternal(logger, 2 , _InternalMessageId.BrowserCannotReadSessionStorage, "Browser failed read of session storage. " + getExceptionName(e), { exception: dumpObj(e) });
1793
2665
  }
1794
2666
  }
1795
2667
  return null;
@@ -1803,7 +2675,7 @@
1803
2675
  }
1804
2676
  catch (e) {
1805
2677
  _canUseSessionStorage = false;
1806
- logger.throwInternal(LoggingSeverity.WARNING, _InternalMessageId.BrowserCannotWriteSessionStorage, "Browser failed write to session storage. " + getExceptionName(e), { exception: dumpObj(e) });
2678
+ _throwInternal(logger, 2 , _InternalMessageId.BrowserCannotWriteSessionStorage, "Browser failed write to session storage. " + getExceptionName(e), { exception: dumpObj(e) });
1807
2679
  }
1808
2680
  }
1809
2681
  return false;
@@ -1817,7 +2689,7 @@
1817
2689
  }
1818
2690
  catch (e) {
1819
2691
  _canUseSessionStorage = false;
1820
- logger.throwInternal(LoggingSeverity.WARNING, _InternalMessageId.BrowserFailedRemovalFromSessionStorage, "Browser failed removal of session storage item. " + getExceptionName(e), { exception: dumpObj(e) });
2692
+ _throwInternal(logger, 2 , _InternalMessageId.BrowserFailedRemovalFromSessionStorage, "Browser failed removal of session storage item. " + getExceptionName(e), { exception: dumpObj(e) });
1821
2693
  }
1822
2694
  }
1823
2695
  return false;
@@ -1913,57 +2785,23 @@
1913
2785
  return result;
1914
2786
  }
1915
2787
 
1916
- var EventData = /** @class */ (function () {
1917
- function EventData() {
1918
- this.ver = 2;
1919
- this.properties = {};
1920
- this.measurements = {};
1921
- }
1922
- return EventData;
1923
- }());
1924
-
1925
- var Event$1 = /** @class */ (function (_super) {
1926
- __extendsFn(Event, _super);
2788
+ var Event$1 = /** @class */ (function () {
1927
2789
  function Event(logger, name, properties, measurements) {
1928
- var _this = _super.call(this) || this;
1929
- _this.aiDataContract = {
2790
+ this.aiDataContract = {
1930
2791
  ver: 1 ,
1931
2792
  name: 1 ,
1932
2793
  properties: 0 ,
1933
2794
  measurements: 0
1934
2795
  };
1935
- _this.name = dataSanitizeString(logger, name) || strNotSpecified;
1936
- _this.properties = dataSanitizeProperties(logger, properties);
1937
- _this.measurements = dataSanitizeMeasurements(logger, measurements);
1938
- return _this;
2796
+ var _self = this;
2797
+ _self.ver = 2;
2798
+ _self.name = dataSanitizeString(logger, name) || strNotSpecified;
2799
+ _self.properties = dataSanitizeProperties(logger, properties);
2800
+ _self.measurements = dataSanitizeMeasurements(logger, measurements);
1939
2801
  }
1940
2802
  Event.envelopeType = "Microsoft.ApplicationInsights.{0}.Event";
1941
2803
  Event.dataType = "EventData";
1942
2804
  return Event;
1943
- }(EventData));
1944
-
1945
- var StackFrame = /** @class */ (function () {
1946
- function StackFrame() {
1947
- }
1948
- return StackFrame;
1949
- }());
1950
-
1951
- var ExceptionData = /** @class */ (function () {
1952
- function ExceptionData() {
1953
- this.ver = 2;
1954
- this.exceptions = [];
1955
- this.properties = {};
1956
- this.measurements = {};
1957
- }
1958
- return ExceptionData;
1959
- }());
1960
-
1961
- var ExceptionDetails = /** @class */ (function () {
1962
- function ExceptionDetails() {
1963
- this.hasFullStack = true;
1964
- this.parsedStack = [];
1965
- }
1966
- return ExceptionDetails;
1967
2805
  }());
1968
2806
 
1969
2807
  var NoMethod = "<no_method>";
@@ -2207,50 +3045,48 @@
2207
3045
  }
2208
3046
  return "" + (errorObj || "");
2209
3047
  }
2210
- var Exception = /** @class */ (function (_super) {
2211
- __extendsFn(Exception, _super);
3048
+ var Exception = /** @class */ (function () {
2212
3049
  function Exception(logger, exception, properties, measurements, severityLevel, id) {
2213
- var _this = _super.call(this) || this;
2214
- _this.aiDataContract = {
3050
+ this.aiDataContract = {
2215
3051
  ver: 1 ,
2216
3052
  exceptions: 1 ,
2217
3053
  severityLevel: 0 ,
2218
3054
  properties: 0 ,
2219
3055
  measurements: 0
2220
3056
  };
3057
+ var _self = this;
3058
+ _self.ver = 2;
2221
3059
  if (!_isExceptionInternal(exception)) {
2222
3060
  if (!properties) {
2223
3061
  properties = {};
2224
3062
  }
2225
- _this.exceptions = [new _ExceptionDetails(logger, exception, properties)];
2226
- _this.properties = dataSanitizeProperties(logger, properties);
2227
- _this.measurements = dataSanitizeMeasurements(logger, measurements);
3063
+ _self.exceptions = [new _ExceptionDetails(logger, exception, properties)];
3064
+ _self.properties = dataSanitizeProperties(logger, properties);
3065
+ _self.measurements = dataSanitizeMeasurements(logger, measurements);
2228
3066
  if (severityLevel) {
2229
- _this.severityLevel = severityLevel;
3067
+ _self.severityLevel = severityLevel;
2230
3068
  }
2231
3069
  if (id) {
2232
- _this.id = id;
3070
+ _self.id = id;
2233
3071
  }
2234
3072
  }
2235
3073
  else {
2236
- _this.exceptions = exception.exceptions;
2237
- _this.properties = exception.properties;
2238
- _this.measurements = exception.measurements;
3074
+ _self.exceptions = exception.exceptions || [];
3075
+ _self.properties = exception.properties;
3076
+ _self.measurements = exception.measurements;
2239
3077
  if (exception.severityLevel) {
2240
- _this.severityLevel = exception.severityLevel;
3078
+ _self.severityLevel = exception.severityLevel;
2241
3079
  }
2242
3080
  if (exception.id) {
2243
- _this.id = exception.id;
3081
+ _self.id = exception.id;
2244
3082
  }
2245
3083
  if (exception.problemGroup) {
2246
- _this.problemGroup = exception.problemGroup;
3084
+ _self.problemGroup = exception.problemGroup;
2247
3085
  }
2248
- _this.ver = 2;
2249
3086
  if (!isNullOrUndefined(exception.isManual)) {
2250
- _this.isManual = exception.isManual;
3087
+ _self.isManual = exception.isManual;
2251
3088
  }
2252
3089
  }
2253
- return _this;
2254
3090
  }
2255
3091
  Exception.CreateAutoException = function (message, url, lineNumber, columnNumber, error, evt, stack, errorSrc) {
2256
3092
  var errorType = _getErrorType(error || evt || message);
@@ -2304,12 +3140,10 @@
2304
3140
  Exception.dataType = "ExceptionData";
2305
3141
  Exception.formatError = _formatErrorCode;
2306
3142
  return Exception;
2307
- }(ExceptionData));
2308
- var _ExceptionDetails = /** @class */ (function (_super) {
2309
- __extendsFn(_ExceptionDetails, _super);
3143
+ }());
3144
+ var _ExceptionDetails = /** @class */ (function () {
2310
3145
  function _ExceptionDetails(logger, exception, properties) {
2311
- var _this = _super.call(this) || this;
2312
- _this.aiDataContract = {
3146
+ this.aiDataContract = {
2313
3147
  id: 0 ,
2314
3148
  outerId: 0 ,
2315
3149
  typeName: 1 ,
@@ -2318,41 +3152,42 @@
2318
3152
  stack: 0 ,
2319
3153
  parsedStack: 2
2320
3154
  };
3155
+ var _self = this;
2321
3156
  if (!_isExceptionDetailsInternal(exception)) {
2322
3157
  var error = exception;
2323
3158
  var evt = error && error.evt;
2324
3159
  if (!isError(error)) {
2325
3160
  error = error[strError] || evt || error;
2326
3161
  }
2327
- _this.typeName = dataSanitizeString(logger, _getErrorType(error)) || strNotSpecified;
2328
- _this.message = dataSanitizeMessage(logger, _formatMessage(exception || error, _this.typeName)) || strNotSpecified;
3162
+ _self.typeName = dataSanitizeString(logger, _getErrorType(error)) || strNotSpecified;
3163
+ _self.message = dataSanitizeMessage(logger, _formatMessage(exception || error, _self.typeName)) || strNotSpecified;
2329
3164
  var stack = exception[strStackDetails] || _getStackFromErrorObj(exception);
2330
- _this.parsedStack = _parseStack(stack);
2331
- _this[strStack] = dataSanitizeException(logger, _formatStackTrace(stack));
2332
- _this.hasFullStack = isArray(_this.parsedStack) && _this.parsedStack.length > 0;
3165
+ _self.parsedStack = _parseStack(stack);
3166
+ _self[strStack] = dataSanitizeException(logger, _formatStackTrace(stack));
3167
+ _self.hasFullStack = isArray(_self.parsedStack) && _self.parsedStack.length > 0;
2333
3168
  if (properties) {
2334
- properties.typeName = properties.typeName || _this.typeName;
3169
+ properties.typeName = properties.typeName || _self.typeName;
2335
3170
  }
2336
3171
  }
2337
3172
  else {
2338
- _this.typeName = exception.typeName;
2339
- _this.message = exception.message;
2340
- _this[strStack] = exception[strStack];
2341
- _this.parsedStack = exception.parsedStack;
2342
- _this.hasFullStack = exception.hasFullStack;
3173
+ _self.typeName = exception.typeName;
3174
+ _self.message = exception.message;
3175
+ _self[strStack] = exception[strStack];
3176
+ _self.parsedStack = exception.parsedStack || [];
3177
+ _self.hasFullStack = exception.hasFullStack;
2343
3178
  }
2344
- return _this;
2345
3179
  }
2346
3180
  _ExceptionDetails.prototype.toInterface = function () {
2347
- var parsedStack = this.parsedStack instanceof Array
2348
- && arrMap(this.parsedStack, function (frame) { return frame.toInterface(); });
3181
+ var _self = this;
3182
+ var parsedStack = _self.parsedStack instanceof Array
3183
+ && arrMap(_self.parsedStack, function (frame) { return frame.toInterface(); });
2349
3184
  var exceptionDetailsInterface = {
2350
- id: this.id,
2351
- outerId: this.outerId,
2352
- typeName: this.typeName,
2353
- message: this.message,
2354
- hasFullStack: this.hasFullStack,
2355
- stack: this[strStack],
3185
+ id: _self.id,
3186
+ outerId: _self.outerId,
3187
+ typeName: _self.typeName,
3188
+ message: _self.message,
3189
+ hasFullStack: _self.hasFullStack,
3190
+ stack: _self[strStack],
2356
3191
  parsedStack: parsedStack || undefined
2357
3192
  };
2358
3193
  return exceptionDetailsInterface;
@@ -2365,94 +3200,68 @@
2365
3200
  return exceptionDetails;
2366
3201
  };
2367
3202
  return _ExceptionDetails;
2368
- }(ExceptionDetails));
2369
- var _StackFrame = /** @class */ (function (_super) {
2370
- __extendsFn(_StackFrame, _super);
3203
+ }());
3204
+ var _StackFrame = /** @class */ (function () {
2371
3205
  function _StackFrame(sourceFrame, level) {
2372
- var _this = _super.call(this) || this;
2373
- _this.sizeInBytes = 0;
2374
- _this.aiDataContract = {
3206
+ this.aiDataContract = {
2375
3207
  level: 1 ,
2376
3208
  method: 1 ,
2377
3209
  assembly: 0 ,
2378
3210
  fileName: 0 ,
2379
3211
  line: 0
2380
3212
  };
3213
+ var _self = this;
3214
+ _self.sizeInBytes = 0;
2381
3215
  if (typeof sourceFrame === "string") {
2382
3216
  var frame = sourceFrame;
2383
- _this.level = level;
2384
- _this.method = NoMethod;
2385
- _this.assembly = strTrim(frame);
2386
- _this.fileName = "";
2387
- _this.line = 0;
3217
+ _self.level = level;
3218
+ _self.method = NoMethod;
3219
+ _self.assembly = strTrim(frame);
3220
+ _self.fileName = "";
3221
+ _self.line = 0;
2388
3222
  var matches = frame.match(_StackFrame.regex);
2389
3223
  if (matches && matches.length >= 5) {
2390
- _this.method = strTrim(matches[2]) || _this.method;
2391
- _this.fileName = strTrim(matches[4]);
2392
- _this.line = parseInt(matches[5]) || 0;
3224
+ _self.method = strTrim(matches[2]) || _self.method;
3225
+ _self.fileName = strTrim(matches[4]);
3226
+ _self.line = parseInt(matches[5]) || 0;
2393
3227
  }
2394
3228
  }
2395
3229
  else {
2396
- _this.level = sourceFrame.level;
2397
- _this.method = sourceFrame.method;
2398
- _this.assembly = sourceFrame.assembly;
2399
- _this.fileName = sourceFrame.fileName;
2400
- _this.line = sourceFrame.line;
2401
- _this.sizeInBytes = 0;
2402
- }
2403
- _this.sizeInBytes += _this.method.length;
2404
- _this.sizeInBytes += _this.fileName.length;
2405
- _this.sizeInBytes += _this.assembly.length;
2406
- _this.sizeInBytes += _StackFrame.baseSize;
2407
- _this.sizeInBytes += _this.level.toString().length;
2408
- _this.sizeInBytes += _this.line.toString().length;
2409
- return _this;
3230
+ _self.level = sourceFrame.level;
3231
+ _self.method = sourceFrame.method;
3232
+ _self.assembly = sourceFrame.assembly;
3233
+ _self.fileName = sourceFrame.fileName;
3234
+ _self.line = sourceFrame.line;
3235
+ _self.sizeInBytes = 0;
3236
+ }
3237
+ _self.sizeInBytes += _self.method.length;
3238
+ _self.sizeInBytes += _self.fileName.length;
3239
+ _self.sizeInBytes += _self.assembly.length;
3240
+ _self.sizeInBytes += _StackFrame.baseSize;
3241
+ _self.sizeInBytes += _self.level.toString().length;
3242
+ _self.sizeInBytes += _self.line.toString().length;
2410
3243
  }
2411
3244
  _StackFrame.CreateFromInterface = function (frame) {
2412
3245
  return new _StackFrame(frame, null );
2413
3246
  };
2414
3247
  _StackFrame.prototype.toInterface = function () {
3248
+ var _self = this;
2415
3249
  return {
2416
- level: this.level,
2417
- method: this.method,
2418
- assembly: this.assembly,
2419
- fileName: this.fileName,
2420
- line: this.line
3250
+ level: _self.level,
3251
+ method: _self.method,
3252
+ assembly: _self.assembly,
3253
+ fileName: _self.fileName,
3254
+ line: _self.line
2421
3255
  };
2422
3256
  };
2423
3257
  _StackFrame.regex = /^([\s]+at)?[\s]{0,50}([^\@\()]+?)[\s]{0,50}(\@|\()([^\(\n]+):([0-9]+):([0-9]+)(\)?)$/;
2424
3258
  _StackFrame.baseSize = 58;
2425
3259
  return _StackFrame;
2426
- }(StackFrame));
2427
-
2428
- var MetricData = /** @class */ (function () {
2429
- function MetricData() {
2430
- this.ver = 2;
2431
- this.metrics = [];
2432
- this.properties = {};
2433
- this.measurements = {};
2434
- }
2435
- return MetricData;
2436
- }());
2437
-
2438
- var DataPointType;
2439
- (function (DataPointType) {
2440
- DataPointType[DataPointType["Measurement"] = 0] = "Measurement";
2441
- DataPointType[DataPointType["Aggregation"] = 1] = "Aggregation";
2442
- })(DataPointType || (DataPointType = {}));
2443
-
2444
- var DataPoint$1 = /** @class */ (function () {
2445
- function DataPoint() {
2446
- this.kind = DataPointType.Measurement;
2447
- }
2448
- return DataPoint;
2449
3260
  }());
2450
3261
 
2451
- var DataPoint = /** @class */ (function (_super) {
2452
- __extendsFn(DataPoint, _super);
3262
+ var DataPoint = /** @class */ (function () {
2453
3263
  function DataPoint() {
2454
- var _this = _super !== null && _super.apply(this, arguments) || this;
2455
- _this.aiDataContract = {
3264
+ this.aiDataContract = {
2456
3265
  name: 1 ,
2457
3266
  kind: 0 ,
2458
3267
  value: 1 ,
@@ -2461,20 +3270,20 @@
2461
3270
  max: 0 ,
2462
3271
  stdDev: 0
2463
3272
  };
2464
- return _this;
3273
+ this.kind = 0 ;
2465
3274
  }
2466
3275
  return DataPoint;
2467
- }(DataPoint$1));
3276
+ }());
2468
3277
 
2469
- var Metric = /** @class */ (function (_super) {
2470
- __extendsFn(Metric, _super);
3278
+ var Metric = /** @class */ (function () {
2471
3279
  function Metric(logger, name, value, count, min, max, stdDev, properties, measurements) {
2472
- var _this = _super.call(this) || this;
2473
- _this.aiDataContract = {
3280
+ this.aiDataContract = {
2474
3281
  ver: 1 ,
2475
3282
  metrics: 1 ,
2476
3283
  properties: 0
2477
3284
  };
3285
+ var _self = this;
3286
+ _self.ver = 2;
2478
3287
  var dataPoint = new DataPoint();
2479
3288
  dataPoint.count = count > 0 ? count : undefined;
2480
3289
  dataPoint.max = isNaN(max) || max === null ? undefined : max;
@@ -2482,33 +3291,18 @@
2482
3291
  dataPoint.name = dataSanitizeString(logger, name) || strNotSpecified;
2483
3292
  dataPoint.value = value;
2484
3293
  dataPoint.stdDev = isNaN(stdDev) || stdDev === null ? undefined : stdDev;
2485
- _this.metrics = [dataPoint];
2486
- _this.properties = dataSanitizeProperties(logger, properties);
2487
- _this.measurements = dataSanitizeMeasurements(logger, measurements);
2488
- return _this;
3294
+ _self.metrics = [dataPoint];
3295
+ _self.properties = dataSanitizeProperties(logger, properties);
3296
+ _self.measurements = dataSanitizeMeasurements(logger, measurements);
2489
3297
  }
2490
3298
  Metric.envelopeType = "Microsoft.ApplicationInsights.{0}.Metric";
2491
3299
  Metric.dataType = "MetricData";
2492
3300
  return Metric;
2493
- }(MetricData));
2494
-
2495
- var PageViewData = /** @class */ (function (_super) {
2496
- __extendsFn(PageViewData, _super);
2497
- function PageViewData() {
2498
- var _this = _super.call(this) || this;
2499
- _this.ver = 2;
2500
- _this.properties = {};
2501
- _this.measurements = {};
2502
- return _this;
2503
- }
2504
- return PageViewData;
2505
- }(EventData));
3301
+ }());
2506
3302
 
2507
- var PageView = /** @class */ (function (_super) {
2508
- __extendsFn(PageView, _super);
3303
+ var PageView = /** @class */ (function () {
2509
3304
  function PageView(logger, name, url, durationMs, properties, measurements, id) {
2510
- var _this = _super.call(this) || this;
2511
- _this.aiDataContract = {
3305
+ this.aiDataContract = {
2512
3306
  ver: 1 ,
2513
3307
  name: 0 ,
2514
3308
  url: 0 ,
@@ -2517,37 +3311,26 @@
2517
3311
  measurements: 0 ,
2518
3312
  id: 0
2519
3313
  };
2520
- _this.id = dataSanitizeId(logger, id);
2521
- _this.url = dataSanitizeUrl(logger, url);
2522
- _this.name = dataSanitizeString(logger, name) || strNotSpecified;
3314
+ var _self = this;
3315
+ _self.ver = 2;
3316
+ _self.id = dataSanitizeId(logger, id);
3317
+ _self.url = dataSanitizeUrl(logger, url);
3318
+ _self.name = dataSanitizeString(logger, name) || strNotSpecified;
2523
3319
  if (!isNaN(durationMs)) {
2524
- _this.duration = msToTimeSpan(durationMs);
3320
+ _self.duration = msToTimeSpan(durationMs);
2525
3321
  }
2526
- _this.properties = dataSanitizeProperties(logger, properties);
2527
- _this.measurements = dataSanitizeMeasurements(logger, measurements);
2528
- return _this;
3322
+ _self.properties = dataSanitizeProperties(logger, properties);
3323
+ _self.measurements = dataSanitizeMeasurements(logger, measurements);
2529
3324
  }
2530
3325
  PageView.envelopeType = "Microsoft.ApplicationInsights.{0}.Pageview";
2531
3326
  PageView.dataType = "PageviewData";
2532
3327
  return PageView;
2533
- }(PageViewData));
2534
-
2535
- var RemoteDependencyData$1 = /** @class */ (function () {
2536
- function RemoteDependencyData() {
2537
- this.ver = 2;
2538
- this.success = true;
2539
- this.properties = {};
2540
- this.measurements = {};
2541
- }
2542
- return RemoteDependencyData;
2543
3328
  }());
2544
3329
 
2545
- var RemoteDependencyData = /** @class */ (function (_super) {
2546
- __extendsFn(RemoteDependencyData, _super);
3330
+ var RemoteDependencyData = /** @class */ (function () {
2547
3331
  function RemoteDependencyData(logger, id, absoluteUrl, commandName, value, success, resultCode, method, requestAPI, correlationContext, properties, measurements) {
2548
3332
  if (requestAPI === void 0) { requestAPI = "Ajax"; }
2549
- var _this = _super.call(this) || this;
2550
- _this.aiDataContract = {
3333
+ this.aiDataContract = {
2551
3334
  id: 1 ,
2552
3335
  ver: 1 ,
2553
3336
  name: 0 ,
@@ -2570,77 +3353,54 @@
2570
3353
  commandName: 0 ,
2571
3354
  dependencyTypeName: 0
2572
3355
  };
2573
- _this.id = id;
2574
- _this.duration = msToTimeSpan(value);
2575
- _this.success = success;
2576
- _this.resultCode = resultCode + "";
2577
- _this.type = dataSanitizeString(logger, requestAPI);
3356
+ var _self = this;
3357
+ _self.ver = 2;
3358
+ _self.id = id;
3359
+ _self.duration = msToTimeSpan(value);
3360
+ _self.success = success;
3361
+ _self.resultCode = resultCode + "";
3362
+ _self.type = dataSanitizeString(logger, requestAPI);
2578
3363
  var dependencyFields = AjaxHelperParseDependencyPath(logger, absoluteUrl, method, commandName);
2579
- _this.data = dataSanitizeUrl(logger, commandName) || dependencyFields.data;
2580
- _this.target = dataSanitizeString(logger, dependencyFields.target);
3364
+ _self.data = dataSanitizeUrl(logger, commandName) || dependencyFields.data;
3365
+ _self.target = dataSanitizeString(logger, dependencyFields.target);
2581
3366
  if (correlationContext) {
2582
- _this.target = "".concat(_this.target, " | ").concat(correlationContext);
3367
+ _self.target = "".concat(_self.target, " | ").concat(correlationContext);
2583
3368
  }
2584
- _this.name = dataSanitizeString(logger, dependencyFields.name);
2585
- _this.properties = dataSanitizeProperties(logger, properties);
2586
- _this.measurements = dataSanitizeMeasurements(logger, measurements);
2587
- return _this;
3369
+ _self.name = dataSanitizeString(logger, dependencyFields.name);
3370
+ _self.properties = dataSanitizeProperties(logger, properties);
3371
+ _self.measurements = dataSanitizeMeasurements(logger, measurements);
2588
3372
  }
2589
3373
  RemoteDependencyData.envelopeType = "Microsoft.ApplicationInsights.{0}.RemoteDependency";
2590
3374
  RemoteDependencyData.dataType = "RemoteDependencyData";
2591
3375
  return RemoteDependencyData;
2592
- }(RemoteDependencyData$1));
2593
-
2594
- var MessageData = /** @class */ (function () {
2595
- function MessageData() {
2596
- this.ver = 2;
2597
- this.properties = {};
2598
- this.measurements = {};
2599
- }
2600
- return MessageData;
2601
3376
  }());
2602
3377
 
2603
- var Trace = /** @class */ (function (_super) {
2604
- __extendsFn(Trace, _super);
3378
+ var Trace = /** @class */ (function () {
2605
3379
  function Trace(logger, message, severityLevel, properties, measurements) {
2606
- var _this = _super.call(this) || this;
2607
- _this.aiDataContract = {
3380
+ this.aiDataContract = {
2608
3381
  ver: 1 ,
2609
3382
  message: 1 ,
2610
3383
  severityLevel: 0 ,
2611
3384
  properties: 0
2612
3385
  };
3386
+ var _self = this;
3387
+ _self.ver = 2;
2613
3388
  message = message || strNotSpecified;
2614
- _this.message = dataSanitizeMessage(logger, message);
2615
- _this.properties = dataSanitizeProperties(logger, properties);
2616
- _this.measurements = dataSanitizeMeasurements(logger, measurements);
3389
+ _self.message = dataSanitizeMessage(logger, message);
3390
+ _self.properties = dataSanitizeProperties(logger, properties);
3391
+ _self.measurements = dataSanitizeMeasurements(logger, measurements);
2617
3392
  if (severityLevel) {
2618
- _this.severityLevel = severityLevel;
3393
+ _self.severityLevel = severityLevel;
2619
3394
  }
2620
- return _this;
2621
3395
  }
2622
3396
  Trace.envelopeType = "Microsoft.ApplicationInsights.{0}.Message";
2623
3397
  Trace.dataType = "MessageData";
2624
3398
  return Trace;
2625
- }(MessageData));
2626
-
2627
- var PageViewPerfData = /** @class */ (function (_super) {
2628
- __extendsFn(PageViewPerfData, _super);
2629
- function PageViewPerfData() {
2630
- var _this = _super.call(this) || this;
2631
- _this.ver = 2;
2632
- _this.properties = {};
2633
- _this.measurements = {};
2634
- return _this;
2635
- }
2636
- return PageViewPerfData;
2637
- }(PageViewData));
3399
+ }());
2638
3400
 
2639
- var PageViewPerformance = /** @class */ (function (_super) {
2640
- __extendsFn(PageViewPerformance, _super);
3401
+ var PageViewPerformance = /** @class */ (function () {
2641
3402
  function PageViewPerformance(logger, name, url, unused, properties, measurements, cs4BaseData) {
2642
- var _this = _super.call(this) || this;
2643
- _this.aiDataContract = {
3403
+ this.aiDataContract = {
2644
3404
  ver: 1 ,
2645
3405
  name: 0 ,
2646
3406
  url: 0 ,
@@ -2653,24 +3413,25 @@
2653
3413
  properties: 0 ,
2654
3414
  measurements: 0
2655
3415
  };
2656
- _this.url = dataSanitizeUrl(logger, url);
2657
- _this.name = dataSanitizeString(logger, name) || strNotSpecified;
2658
- _this.properties = dataSanitizeProperties(logger, properties);
2659
- _this.measurements = dataSanitizeMeasurements(logger, measurements);
3416
+ var _self = this;
3417
+ _self.ver = 2;
3418
+ _self.url = dataSanitizeUrl(logger, url);
3419
+ _self.name = dataSanitizeString(logger, name) || strNotSpecified;
3420
+ _self.properties = dataSanitizeProperties(logger, properties);
3421
+ _self.measurements = dataSanitizeMeasurements(logger, measurements);
2660
3422
  if (cs4BaseData) {
2661
- _this.domProcessing = cs4BaseData.domProcessing;
2662
- _this.duration = cs4BaseData.duration;
2663
- _this.networkConnect = cs4BaseData.networkConnect;
2664
- _this.perfTotal = cs4BaseData.perfTotal;
2665
- _this.receivedResponse = cs4BaseData.receivedResponse;
2666
- _this.sentRequest = cs4BaseData.sentRequest;
3423
+ _self.domProcessing = cs4BaseData.domProcessing;
3424
+ _self.duration = cs4BaseData.duration;
3425
+ _self.networkConnect = cs4BaseData.networkConnect;
3426
+ _self.perfTotal = cs4BaseData.perfTotal;
3427
+ _self.receivedResponse = cs4BaseData.receivedResponse;
3428
+ _self.sentRequest = cs4BaseData.sentRequest;
2667
3429
  }
2668
- return _this;
2669
3430
  }
2670
3431
  PageViewPerformance.envelopeType = "Microsoft.ApplicationInsights.{0}.PageviewPerformance";
2671
3432
  PageViewPerformance.dataType = "PageviewPerformanceData";
2672
3433
  return PageViewPerformance;
2673
- }(PageViewPerfData));
3434
+ }());
2674
3435
 
2675
3436
  var SeverityLevel;
2676
3437
  (function (SeverityLevel) {
@@ -2729,11 +3490,9 @@
2729
3490
  if (core) {
2730
3491
  _logger = core.logger;
2731
3492
  }
2732
- function _flushChannels() {
3493
+ function _flushChannels(isAsync) {
2733
3494
  if (core) {
2734
- arrForEach(core.getTransmissionControls(), function (queues) {
2735
- arrForEach(queues, function (q) { return q.flush(true); });
2736
- });
3495
+ core.flush(isAsync);
2737
3496
  }
2738
3497
  }
2739
3498
  function _addQueue(cb) {
@@ -2756,7 +3515,7 @@
2756
3515
  intervalHandle = null;
2757
3516
  }
2758
3517
  if (doFlush) {
2759
- _flushChannels();
3518
+ _flushChannels(true);
2760
3519
  }
2761
3520
  }), 100);
2762
3521
  }
@@ -2774,7 +3533,7 @@
2774
3533
  }
2775
3534
  if (!pageViewPerformanceManager.isPerformanceTimingSupported()) {
2776
3535
  appInsights.sendPageViewInternal(pageView, customProperties);
2777
- _flushChannels();
3536
+ _flushChannels(true);
2778
3537
  _logger.throwInternal(LoggingSeverity.WARNING, _InternalMessageId.NavigationTimingNotSupported, "trackPageView: navigation timing API used for calculation of page duration is not supported in this browser. This page view will be collected without duration and timing info.");
2779
3538
  return;
2780
3539
  }
@@ -2800,7 +3559,7 @@
2800
3559
  customProperties["duration"] = customDuration;
2801
3560
  }
2802
3561
  appInsights.sendPageViewInternal(pageView, customProperties);
2803
- _flushChannels();
3562
+ _flushChannels(true);
2804
3563
  pageViewSent = true;
2805
3564
  }
2806
3565
  var maxDurationLimit = 60000;
@@ -2846,6 +3605,17 @@
2846
3605
  return processed;
2847
3606
  });
2848
3607
  };
3608
+ _self.teardown = function (unloadCtx, unloadState) {
3609
+ if (intervalHandle) {
3610
+ clearInterval(intervalHandle);
3611
+ intervalHandle = null;
3612
+ var allItems = itemQueue.slice(0);
3613
+ itemQueue = [];
3614
+ arrForEach(allItems, function (item) {
3615
+ if (item()) ;
3616
+ });
3617
+ }
3618
+ };
2849
3619
  });
2850
3620
  }
2851
3621
  return PageViewManager;
@@ -3040,6 +3810,33 @@
3040
3810
  return PageViewPerformanceManager;
3041
3811
  }());
3042
3812
 
3813
+ var Timing = /** @class */ (function () {
3814
+ function Timing(logger, name) {
3815
+ var _self = this;
3816
+ var _events = {};
3817
+ _self.start = function (name) {
3818
+ if (typeof _events[name] !== "undefined") {
3819
+ _throwInternal(logger, LoggingSeverity.WARNING, _InternalMessageId.StartCalledMoreThanOnce, "start was called more than once for this event without calling stop.", { name: name, key: name }, true);
3820
+ }
3821
+ _events[name] = +new Date;
3822
+ };
3823
+ _self.stop = function (name, url, properties, measurements) {
3824
+ var start = _events[name];
3825
+ if (isNaN(start)) {
3826
+ _throwInternal(logger, LoggingSeverity.WARNING, _InternalMessageId.StopCalledWithoutStart, "stop was called without a corresponding start.", { name: name, key: name }, true);
3827
+ }
3828
+ else {
3829
+ var end = +new Date;
3830
+ var duration = dateTimeUtilsDuration(start, end);
3831
+ _self.action(name, url, duration, properties, measurements);
3832
+ }
3833
+ delete _events[name];
3834
+ _events[name] = undefined;
3835
+ };
3836
+ }
3837
+ return Timing;
3838
+ }());
3839
+
3043
3840
  var durationProperty = "duration";
3044
3841
  var strEvent = "event";
3045
3842
  function _dispatchEvent(target, evnt) {
@@ -3057,47 +3854,78 @@
3057
3854
  }
3058
3855
  return error || "";
3059
3856
  }
3060
- var ApplicationInsights = /** @class */ (function (_super) {
3061
- __extendsFn(ApplicationInsights, _super);
3062
- function ApplicationInsights() {
3857
+ var MinMilliSeconds = 60000;
3858
+ function _configMilliseconds(value, defValue) {
3859
+ value = value || defValue;
3860
+ if (value < MinMilliSeconds) {
3861
+ value = MinMilliSeconds;
3862
+ }
3863
+ return value;
3864
+ }
3865
+ function _getDefaultConfig(config) {
3866
+ if (!config) {
3867
+ config = {};
3868
+ }
3869
+ config.sessionRenewalMs = _configMilliseconds(config.sessionRenewalMs, 30 * 60 * 1000);
3870
+ config.sessionExpirationMs = _configMilliseconds(config.sessionExpirationMs, 24 * 60 * 60 * 1000);
3871
+ config.disableExceptionTracking = stringToBoolOrDefault(config.disableExceptionTracking);
3872
+ config.autoTrackPageVisitTime = stringToBoolOrDefault(config.autoTrackPageVisitTime);
3873
+ config.overridePageViewDuration = stringToBoolOrDefault(config.overridePageViewDuration);
3874
+ config.enableUnhandledPromiseRejectionTracking = stringToBoolOrDefault(config.enableUnhandledPromiseRejectionTracking);
3875
+ if (isNaN(config.samplingPercentage) || config.samplingPercentage <= 0 || config.samplingPercentage >= 100) {
3876
+ config.samplingPercentage = 100;
3877
+ }
3878
+ config.isStorageUseDisabled = stringToBoolOrDefault(config.isStorageUseDisabled);
3879
+ config.isBrowserLinkTrackingEnabled = stringToBoolOrDefault(config.isBrowserLinkTrackingEnabled);
3880
+ config.enableAutoRouteTracking = stringToBoolOrDefault(config.enableAutoRouteTracking);
3881
+ config.namePrefix = config.namePrefix || "";
3882
+ config.enableDebug = stringToBoolOrDefault(config.enableDebug);
3883
+ config.disableFlushOnBeforeUnload = stringToBoolOrDefault(config.disableFlushOnBeforeUnload);
3884
+ config.disableFlushOnUnload = stringToBoolOrDefault(config.disableFlushOnUnload, config.disableFlushOnBeforeUnload);
3885
+ return config;
3886
+ }
3887
+ function _updateStorageUsage(extConfig) {
3888
+ if (!isUndefined(extConfig.isStorageUseDisabled)) {
3889
+ if (extConfig.isStorageUseDisabled) {
3890
+ utlDisableStorage();
3891
+ }
3892
+ else {
3893
+ utlEnableStorage();
3894
+ }
3895
+ }
3896
+ }
3897
+ var AnalyticsPlugin = /** @class */ (function (_super) {
3898
+ __extendsFn(AnalyticsPlugin, _super);
3899
+ function AnalyticsPlugin() {
3063
3900
  var _this = _super.call(this) || this;
3064
3901
  _this.identifier = AnalyticsPluginIdentifier;
3065
3902
  _this.priority = 180;
3066
3903
  _this.autoRoutePVDelay = 500;
3067
3904
  var _eventTracking;
3068
3905
  var _pageTracking;
3069
- var _properties;
3906
+ var _pageViewManager;
3907
+ var _pageViewPerformanceManager;
3908
+ var _pageVisitTimeManager;
3909
+ var _preInitTelemetryInitializers;
3910
+ var _isBrowserLinkTrackingEnabled;
3911
+ var _browserLinkInitializerAdded;
3912
+ var _enableAutoRouteTracking;
3913
+ var _historyListenerAdded;
3914
+ var _disableExceptionTracking;
3915
+ var _autoExceptionInstrumented;
3916
+ var _enableUnhandledPromiseRejectionTracking;
3917
+ var _autoUnhandledPromiseInstrumented;
3070
3918
  var _prevUri;
3071
3919
  var _currUri;
3072
- dynamicProto(ApplicationInsights, _this, function (_self, _base) {
3073
- var location = getLocation(true);
3074
- _prevUri = location && location.href || "";
3920
+ var _evtNamespace;
3921
+ dynamicProto(AnalyticsPlugin, _this, function (_self, _base) {
3922
+ var _addHook = _base._addHook;
3923
+ _initDefaults();
3075
3924
  _self.getCookieMgr = function () {
3076
3925
  return safeGetCookieMgr(_self.core);
3077
3926
  };
3078
3927
  _self.processTelemetry = function (env, itemCtx) {
3079
- doPerf(_self.core, function () { return _self.identifier + ":processTelemetry"; }, function () {
3080
- var doNotSendItem = false;
3081
- var telemetryInitializersCount = _self._telemetryInitializers.length;
3082
- itemCtx = _self._getTelCtx(itemCtx);
3083
- for (var i = 0; i < telemetryInitializersCount; ++i) {
3084
- var telemetryInitializer = _self._telemetryInitializers[i];
3085
- if (telemetryInitializer) {
3086
- try {
3087
- if (telemetryInitializer.apply(null, [env]) === false) {
3088
- doNotSendItem = true;
3089
- break;
3090
- }
3091
- }
3092
- catch (e) {
3093
- itemCtx.diagLog().throwInternal(LoggingSeverity.CRITICAL, _InternalMessageId.TelemetryInitializerFailed, "One of telemetry initializers failed, telemetry item will not be sent: " + getExceptionName(e), { exception: dumpObj(e) }, true);
3094
- }
3095
- }
3096
- }
3097
- if (!doNotSendItem) {
3098
- _self.processNext(env, itemCtx);
3099
- }
3100
- }, function () { return ({ item: env }); }, !(env.sync));
3928
+ _self.processNext(env, itemCtx);
3101
3929
  };
3102
3930
  _self.trackEvent = function (event, customProperties) {
3103
3931
  try {
@@ -3105,7 +3933,7 @@
3105
3933
  _self.core.track(telemetryItem);
3106
3934
  }
3107
3935
  catch (e) {
3108
- _self.diagLog().throwInternal(LoggingSeverity.WARNING, _InternalMessageId.TrackTraceFailed, "trackTrace failed, trace will not be collected: " + getExceptionName(e), { exception: dumpObj(e) });
3936
+ _throwInternal(LoggingSeverity.WARNING, _InternalMessageId.TrackTraceFailed, "trackTrace failed, trace will not be collected: " + getExceptionName(e), { exception: dumpObj(e) });
3109
3937
  }
3110
3938
  };
3111
3939
  _self.startTrackEvent = function (name) {
@@ -3113,7 +3941,7 @@
3113
3941
  _eventTracking.start(name);
3114
3942
  }
3115
3943
  catch (e) {
3116
- _self.diagLog().throwInternal(LoggingSeverity.CRITICAL, _InternalMessageId.StartTrackEventFailed, "startTrackEvent failed, event will not be collected: " + getExceptionName(e), { exception: dumpObj(e) });
3944
+ _throwInternal(LoggingSeverity.CRITICAL, _InternalMessageId.StartTrackEventFailed, "startTrackEvent failed, event will not be collected: " + getExceptionName(e), { exception: dumpObj(e) });
3117
3945
  }
3118
3946
  };
3119
3947
  _self.stopTrackEvent = function (name, properties, measurements) {
@@ -3121,7 +3949,7 @@
3121
3949
  _eventTracking.stop(name, undefined, properties);
3122
3950
  }
3123
3951
  catch (e) {
3124
- _self.diagLog().throwInternal(LoggingSeverity.CRITICAL, _InternalMessageId.StopTrackEventFailed, "stopTrackEvent failed, event will not be collected: " + getExceptionName(e), { exception: dumpObj(e) });
3952
+ _throwInternal(LoggingSeverity.CRITICAL, _InternalMessageId.StopTrackEventFailed, "stopTrackEvent failed, event will not be collected: " + getExceptionName(e), { exception: dumpObj(e) });
3125
3953
  }
3126
3954
  };
3127
3955
  _self.trackTrace = function (trace, customProperties) {
@@ -3130,7 +3958,7 @@
3130
3958
  _self.core.track(telemetryItem);
3131
3959
  }
3132
3960
  catch (e) {
3133
- _self.diagLog().throwInternal(LoggingSeverity.WARNING, _InternalMessageId.TrackTraceFailed, "trackTrace failed, trace will not be collected: " + getExceptionName(e), { exception: dumpObj(e) });
3961
+ _throwInternal(LoggingSeverity.WARNING, _InternalMessageId.TrackTraceFailed, "trackTrace failed, trace will not be collected: " + getExceptionName(e), { exception: dumpObj(e) });
3134
3962
  }
3135
3963
  };
3136
3964
  _self.trackMetric = function (metric, customProperties) {
@@ -3139,19 +3967,19 @@
3139
3967
  _self.core.track(telemetryItem);
3140
3968
  }
3141
3969
  catch (e) {
3142
- _self.diagLog().throwInternal(LoggingSeverity.CRITICAL, _InternalMessageId.TrackMetricFailed, "trackMetric failed, metric will not be collected: " + getExceptionName(e), { exception: dumpObj(e) });
3970
+ _throwInternal(LoggingSeverity.CRITICAL, _InternalMessageId.TrackMetricFailed, "trackMetric failed, metric will not be collected: " + getExceptionName(e), { exception: dumpObj(e) });
3143
3971
  }
3144
3972
  };
3145
3973
  _self.trackPageView = function (pageView, customProperties) {
3146
3974
  try {
3147
3975
  var inPv = pageView || {};
3148
- _self._pageViewManager.trackPageView(inPv, __assignFn(__assignFn(__assignFn({}, inPv.properties), inPv.measurements), customProperties));
3976
+ _pageViewManager.trackPageView(inPv, __assignFn(__assignFn(__assignFn({}, inPv.properties), inPv.measurements), customProperties));
3149
3977
  if (_self.config.autoTrackPageVisitTime) {
3150
- _self._pageVisitTimeManager.trackPreviousPageVisit(inPv.name, inPv.uri);
3978
+ _pageVisitTimeManager.trackPreviousPageVisit(inPv.name, inPv.uri);
3151
3979
  }
3152
3980
  }
3153
3981
  catch (e) {
3154
- _self.diagLog().throwInternal(LoggingSeverity.CRITICAL, _InternalMessageId.TrackPVFailed, "trackPageView failed, page view will not be collected: " + getExceptionName(e), { exception: dumpObj(e) });
3982
+ _throwInternal(LoggingSeverity.CRITICAL, _InternalMessageId.TrackPVFailed, "trackPageView failed, page view will not be collected: " + getExceptionName(e), { exception: dumpObj(e) });
3155
3983
  }
3156
3984
  };
3157
3985
  _self.sendPageViewInternal = function (pageView, properties, systemProperties) {
@@ -3167,12 +3995,13 @@
3167
3995
  _self.core.track(telemetryItem);
3168
3996
  };
3169
3997
  _self.trackPageViewPerformance = function (pageViewPerformance, customProperties) {
3998
+ var inPvp = pageViewPerformance || {};
3170
3999
  try {
3171
- _self._pageViewPerformanceManager.populatePageViewPerformanceEvent(pageViewPerformance);
3172
- _self.sendPageViewPerformanceInternal(pageViewPerformance, customProperties);
4000
+ _pageViewPerformanceManager.populatePageViewPerformanceEvent(inPvp);
4001
+ _self.sendPageViewPerformanceInternal(inPvp, customProperties);
3173
4002
  }
3174
4003
  catch (e) {
3175
- _self.diagLog().throwInternal(LoggingSeverity.CRITICAL, _InternalMessageId.TrackPVFailed, "trackPageViewPerformance failed, page view will not be collected: " + getExceptionName(e), { exception: dumpObj(e) });
4004
+ _throwInternal(LoggingSeverity.CRITICAL, _InternalMessageId.TrackPVFailed, "trackPageViewPerformance failed, page view will not be collected: " + getExceptionName(e), { exception: dumpObj(e) });
3176
4005
  }
3177
4006
  };
3178
4007
  _self.startTrackPage = function (name) {
@@ -3184,7 +4013,7 @@
3184
4013
  _pageTracking.start(name);
3185
4014
  }
3186
4015
  catch (e) {
3187
- _self.diagLog().throwInternal(LoggingSeverity.CRITICAL, _InternalMessageId.StartTrackFailed, "startTrackPage failed, page view may not be collected: " + getExceptionName(e), { exception: dumpObj(e) });
4016
+ _throwInternal(LoggingSeverity.CRITICAL, _InternalMessageId.StartTrackFailed, "startTrackPage failed, page view may not be collected: " + getExceptionName(e), { exception: dumpObj(e) });
3188
4017
  }
3189
4018
  };
3190
4019
  _self.stopTrackPage = function (name, url, properties, measurement) {
@@ -3199,11 +4028,11 @@
3199
4028
  }
3200
4029
  _pageTracking.stop(name, url, properties, measurement);
3201
4030
  if (_self.config.autoTrackPageVisitTime) {
3202
- _self._pageVisitTimeManager.trackPreviousPageVisit(name, url);
4031
+ _pageVisitTimeManager.trackPreviousPageVisit(name, url);
3203
4032
  }
3204
4033
  }
3205
4034
  catch (e) {
3206
- _self.diagLog().throwInternal(LoggingSeverity.CRITICAL, _InternalMessageId.StopTrackFailed, "stopTrackPage failed, page view will not be collected: " + getExceptionName(e), { exception: dumpObj(e) });
4035
+ _throwInternal(LoggingSeverity.CRITICAL, _InternalMessageId.StopTrackFailed, "stopTrackPage failed, page view will not be collected: " + getExceptionName(e), { exception: dumpObj(e) });
3207
4036
  }
3208
4037
  };
3209
4038
  _self.sendExceptionInternal = function (exception, customProperties, systemProperties) {
@@ -3213,11 +4042,14 @@
3213
4042
  _self.core.track(telemetryItem);
3214
4043
  };
3215
4044
  _self.trackException = function (exception, customProperties) {
4045
+ if (exception && !exception.exception && exception.error) {
4046
+ exception.exception = exception.error;
4047
+ }
3216
4048
  try {
3217
4049
  _self.sendExceptionInternal(exception, customProperties);
3218
4050
  }
3219
4051
  catch (e) {
3220
- _self.diagLog().throwInternal(LoggingSeverity.CRITICAL, _InternalMessageId.TrackExceptionFailed, "trackException failed, exception will not be collected: " + getExceptionName(e), { exception: dumpObj(e) });
4052
+ _throwInternal(LoggingSeverity.CRITICAL, _InternalMessageId.TrackExceptionFailed, "trackException failed, exception will not be collected: " + getExceptionName(e), { exception: dumpObj(e) });
3221
4053
  }
3222
4054
  };
3223
4055
  _self._onerror = function (exception) {
@@ -3251,158 +4083,98 @@
3251
4083
  }
3252
4084
  catch (e) {
3253
4085
  var errorString = error ? (error.name + ", " + error.message) : "null";
3254
- _self.diagLog().throwInternal(LoggingSeverity.CRITICAL, _InternalMessageId.ExceptionWhileLoggingError, "_onError threw exception while logging error, error will not be collected: "
4086
+ _throwInternal(LoggingSeverity.CRITICAL, _InternalMessageId.ExceptionWhileLoggingError, "_onError threw exception while logging error, error will not be collected: "
3255
4087
  + getExceptionName(e), { exception: dumpObj(e), errorString: errorString });
3256
4088
  }
3257
4089
  };
3258
4090
  _self.addTelemetryInitializer = function (telemetryInitializer) {
3259
- _self._telemetryInitializers.push(telemetryInitializer);
4091
+ if (_self.core) {
4092
+ return _self.core.addTelemetryInitializer(telemetryInitializer);
4093
+ }
4094
+ if (!_preInitTelemetryInitializers) {
4095
+ _preInitTelemetryInitializers = [];
4096
+ }
4097
+ _preInitTelemetryInitializers.push(telemetryInitializer);
3260
4098
  };
3261
4099
  _self.initialize = function (config, core, extensions, pluginChain) {
3262
4100
  if (_self.isInitialized()) {
3263
4101
  return;
3264
4102
  }
3265
4103
  if (isNullOrUndefined(core)) {
3266
- throw Error("Error initializing");
4104
+ throwError("Error initializing");
3267
4105
  }
3268
4106
  _base.initialize(config, core, extensions, pluginChain);
3269
- _self.setInitialized(false);
3270
- var ctx = _self._getTelCtx();
3271
- var identifier = _self.identifier;
3272
- _self.config = ctx.getExtCfg(identifier);
3273
- var defaults = ApplicationInsights.getDefaultConfig(config);
3274
- if (defaults !== undefined) {
3275
- objForEachKey(defaults, function (field, value) {
3276
- _self.config[field] = ctx.getConfig(identifier, field, value);
3277
- if (_self.config[field] === undefined) {
3278
- _self.config[field] = value;
3279
- }
3280
- });
3281
- }
3282
- if (_self.config.isStorageUseDisabled) {
3283
- utlDisableStorage();
3284
- }
3285
- var configGetters = {
3286
- instrumentationKey: function () { return config.instrumentationKey; },
3287
- accountId: function () { return _self.config.accountId || config.accountId; },
3288
- sessionRenewalMs: function () { return _self.config.sessionRenewalMs || config.sessionRenewalMs; },
3289
- sessionExpirationMs: function () { return _self.config.sessionExpirationMs || config.sessionExpirationMs; },
3290
- sampleRate: function () { return _self.config.samplingPercentage || config.samplingPercentage; },
3291
- sdkExtension: function () { return _self.config.sdkExtension || config.sdkExtension; },
3292
- isBrowserLinkTrackingEnabled: function () { return _self.config.isBrowserLinkTrackingEnabled || config.isBrowserLinkTrackingEnabled; },
3293
- appId: function () { return _self.config.appId || config.appId; }
3294
- };
3295
- _self._pageViewPerformanceManager = new PageViewPerformanceManager(_self.core);
3296
- _self._pageViewManager = new PageViewManager(_this, _self.config.overridePageViewDuration, _self.core, _self._pageViewPerformanceManager);
3297
- _self._pageVisitTimeManager = new PageVisitTimeManager(_self.diagLog(), function (pageName, pageUrl, pageVisitTime) { return trackPageVisitTime(pageName, pageUrl, pageVisitTime); });
3298
- _self._telemetryInitializers = _self._telemetryInitializers || [];
3299
- _addDefaultTelemetryInitializers(configGetters);
3300
- _eventTracking = new Timing(_self.diagLog(), "trackEvent");
3301
- _eventTracking.action =
3302
- function (name, url, duration, properties) {
3303
- if (!properties) {
4107
+ try {
4108
+ _evtNamespace = mergeEvtNamespace(createUniqueNamespace(_self.identifier), core.evtNamespace && core.evtNamespace());
4109
+ if (_preInitTelemetryInitializers) {
4110
+ arrForEach(_preInitTelemetryInitializers, function (initializer) {
4111
+ core.addTelemetryInitializer(initializer);
4112
+ });
4113
+ _preInitTelemetryInitializers = null;
4114
+ }
4115
+ var extConfig = _populateDefaults(config);
4116
+ _updateStorageUsage(extConfig);
4117
+ _pageViewPerformanceManager = new PageViewPerformanceManager(_self.core);
4118
+ _pageViewManager = new PageViewManager(_this, extConfig.overridePageViewDuration, _self.core, _pageViewPerformanceManager);
4119
+ _pageVisitTimeManager = new PageVisitTimeManager(_self.diagLog(), function (pageName, pageUrl, pageVisitTime) { return trackPageVisitTime(pageName, pageUrl, pageVisitTime); });
4120
+ _updateBrowserLinkTracking(extConfig, config);
4121
+ _eventTracking = new Timing(_self.diagLog(), "trackEvent");
4122
+ _eventTracking.action =
4123
+ function (name, url, duration, properties) {
4124
+ if (!properties) {
4125
+ properties = {};
4126
+ }
4127
+ properties[durationProperty] = duration.toString();
4128
+ _self.trackEvent({ name: name, properties: properties });
4129
+ };
4130
+ _pageTracking = new Timing(_self.diagLog(), "trackPageView");
4131
+ _pageTracking.action = function (name, url, duration, properties, measurements) {
4132
+ if (isNullOrUndefined(properties)) {
3304
4133
  properties = {};
3305
4134
  }
3306
4135
  properties[durationProperty] = duration.toString();
3307
- _self.trackEvent({ name: name, properties: properties });
4136
+ var pageViewItem = {
4137
+ name: name,
4138
+ uri: url,
4139
+ properties: properties,
4140
+ measurements: measurements
4141
+ };
4142
+ _self.sendPageViewInternal(pageViewItem, properties);
3308
4143
  };
3309
- _pageTracking = new Timing(_self.diagLog(), "trackPageView");
3310
- _pageTracking.action = function (name, url, duration, properties, measurements) {
3311
- if (isNullOrUndefined(properties)) {
3312
- properties = {};
4144
+ if (hasWindow()) {
4145
+ _updateExceptionTracking(extConfig);
4146
+ _updateLocationChange(extConfig);
3313
4147
  }
3314
- properties[durationProperty] = duration.toString();
3315
- var pageViewItem = {
3316
- name: name,
3317
- uri: url,
3318
- properties: properties,
3319
- measurements: measurements
3320
- };
3321
- _self.sendPageViewInternal(pageViewItem, properties);
3322
- };
3323
- var _window = getWindow();
3324
- var _history = getHistory();
3325
- var _location = getLocation(true);
3326
- var instance = _this;
3327
- if (_self.config.disableExceptionTracking === false &&
3328
- !_self.config.autoExceptionInstrumented && _window) {
3329
- var onerror_1 = "onerror";
3330
- var originalOnError_1 = _window[onerror_1];
3331
- _window.onerror = function (message, url, lineNumber, columnNumber, error) {
3332
- var evt = _window[strEvent];
3333
- var handled = originalOnError_1 && originalOnError_1(message, url, lineNumber, columnNumber, error);
3334
- if (handled !== true) {
3335
- instance._onerror(Exception.CreateAutoException(message, url, lineNumber, columnNumber, error, evt));
3336
- }
3337
- return handled;
3338
- };
3339
- _self.config.autoExceptionInstrumented = true;
3340
- }
3341
- if (_self.config.disableExceptionTracking === false &&
3342
- _self.config.enableUnhandledPromiseRejectionTracking === true &&
3343
- !_self.config.autoUnhandledPromiseInstrumented && _window) {
3344
- var onunhandledrejection_1 = "onunhandledrejection";
3345
- var originalOnUnhandledRejection_1 = _window[onunhandledrejection_1];
3346
- _window[onunhandledrejection_1] = function (error) {
3347
- var evt = _window[strEvent];
3348
- var handled = originalOnUnhandledRejection_1 && originalOnUnhandledRejection_1.call(_window, error);
3349
- if (handled !== true) {
3350
- instance._onerror(Exception.CreateAutoException(_getReason(error), _location ? _location.href : "", 0, 0, error, evt));
3351
- }
3352
- return handled;
3353
- };
3354
- _self.config.autoUnhandledPromiseInstrumented = true;
3355
- }
3356
- if (_self.config.enableAutoRouteTracking === true
3357
- && _history && isFunction(_history.pushState) && isFunction(_history.replaceState)
3358
- && _window
3359
- && typeof Event !== "undefined") {
3360
- var _self_1 = _this;
3361
- arrForEach(extensions, function (extension) {
3362
- if (extension.identifier === PropertiesPluginIdentifier) {
3363
- _properties = extension;
4148
+ }
4149
+ catch (e) {
4150
+ _self.setInitialized(false);
4151
+ throw e;
4152
+ }
4153
+ };
4154
+ _self._doTeardown = function (unloadCtx, unloadState) {
4155
+ _pageViewManager && _pageViewManager.teardown(unloadCtx, unloadState);
4156
+ eventOff(window, null, null, _evtNamespace);
4157
+ _initDefaults();
4158
+ };
4159
+ function _populateDefaults(config) {
4160
+ var ctx = createProcessTelemetryContext(null, config, _self.core);
4161
+ var identifier = _self.identifier;
4162
+ var defaults = _getDefaultConfig(config);
4163
+ var extConfig = _self.config = ctx.getExtCfg(identifier);
4164
+ if (defaults !== undefined) {
4165
+ objForEachKey(defaults, function (field, value) {
4166
+ extConfig[field] = ctx.getConfig(identifier, field, value);
4167
+ if (extConfig[field] === undefined) {
4168
+ extConfig = value;
3364
4169
  }
3365
4170
  });
3366
- _history.pushState = (function (f) { return function pushState() {
3367
- var ret = f.apply(this, arguments);
3368
- _dispatchEvent(_window, createDomEvent(_self_1.config.namePrefix + "pushState"));
3369
- _dispatchEvent(_window, createDomEvent(_self_1.config.namePrefix + "locationchange"));
3370
- return ret;
3371
- }; })(_history.pushState);
3372
- _history.replaceState = (function (f) { return function replaceState() {
3373
- var ret = f.apply(this, arguments);
3374
- _dispatchEvent(_window, createDomEvent(_self_1.config.namePrefix + "replaceState"));
3375
- _dispatchEvent(_window, createDomEvent(_self_1.config.namePrefix + "locationchange"));
3376
- return ret;
3377
- }; })(_history.replaceState);
3378
- if (_window.addEventListener) {
3379
- _window.addEventListener(_self_1.config.namePrefix + "popstate", function () {
3380
- _dispatchEvent(_window, createDomEvent(_self_1.config.namePrefix + "locationchange"));
3381
- });
3382
- _window.addEventListener(_self_1.config.namePrefix + "locationchange", function () {
3383
- if (_properties && _properties.context && _properties.context.telemetryTrace) {
3384
- _properties.context.telemetryTrace.traceID = generateW3CId();
3385
- var traceLocationName = "_unknown_";
3386
- if (_location && _location.pathname) {
3387
- traceLocationName = _location.pathname + (_location.hash || "");
3388
- }
3389
- _properties.context.telemetryTrace.name = dataSanitizeString(_self_1.diagLog(), traceLocationName);
3390
- }
3391
- if (_currUri) {
3392
- _prevUri = _currUri;
3393
- _currUri = _location && _location.href || "";
3394
- }
3395
- else {
3396
- _currUri = _location && _location.href || "";
3397
- }
3398
- setTimeout((function (uri) {
3399
- _self_1.trackPageView({ refUri: uri, properties: { duration: 0 } });
3400
- }).bind(_this, _prevUri), _self_1.autoRoutePVDelay);
3401
- });
3402
- }
3403
4171
  }
3404
- _self.setInitialized(true);
3405
- };
4172
+ return extConfig;
4173
+ }
4174
+ function _updateBrowserLinkTracking(extConfig, config) {
4175
+ _isBrowserLinkTrackingEnabled = extConfig.isBrowserLinkTrackingEnabled || config.isBrowserLinkTrackingEnabled;
4176
+ _addDefaultTelemetryInitializers();
4177
+ }
3406
4178
  function trackPageVisitTime(pageName, pageUrl, pageVisitTime) {
3407
4179
  var properties = { PageName: pageName, PageUrl: pageUrl };
3408
4180
  _self.trackMetric({
@@ -3413,11 +4185,11 @@
3413
4185
  sampleCount: 1
3414
4186
  }, properties);
3415
4187
  }
3416
- function _addDefaultTelemetryInitializers(configGetters) {
3417
- if (!configGetters.isBrowserLinkTrackingEnabled()) {
4188
+ function _addDefaultTelemetryInitializers() {
4189
+ if (!_browserLinkInitializerAdded && _isBrowserLinkTrackingEnabled) {
3418
4190
  var browserLinkPaths_1 = ["/browserLinkSignalR/", "/__browserLink/"];
3419
4191
  var dropBrowserLinkRequests = function (envelope) {
3420
- if (envelope.baseType === RemoteDependencyData.dataType) {
4192
+ if (_isBrowserLinkTrackingEnabled && envelope.baseType === RemoteDependencyData.dataType) {
3421
4193
  var remoteData = envelope.baseData;
3422
4194
  if (remoteData) {
3423
4195
  for (var i = 0; i < browserLinkPaths_1.length; i++) {
@@ -3429,72 +4201,150 @@
3429
4201
  }
3430
4202
  return true;
3431
4203
  };
3432
- _addTelemetryInitializer(dropBrowserLinkRequests);
4204
+ _self.addTelemetryInitializer(dropBrowserLinkRequests);
4205
+ _browserLinkInitializerAdded = true;
3433
4206
  }
3434
4207
  }
3435
- function _addTelemetryInitializer(telemetryInitializer) {
3436
- _self._telemetryInitializers.push(telemetryInitializer);
3437
- }
3438
4208
  function _sendCORSException(exception, properties) {
3439
4209
  var telemetryItem = TelemetryItemCreator.create(exception, Exception.dataType, Exception.envelopeType, _self.diagLog(), properties);
3440
4210
  _self.core.track(telemetryItem);
3441
4211
  }
3442
- });
3443
- return _this;
3444
- }
3445
- ApplicationInsights.getDefaultConfig = function (config) {
3446
- if (!config) {
3447
- config = {};
3448
- }
3449
- config.sessionRenewalMs = 30 * 60 * 1000;
3450
- config.sessionExpirationMs = 24 * 60 * 60 * 1000;
3451
- config.disableExceptionTracking = stringToBoolOrDefault(config.disableExceptionTracking);
3452
- config.autoTrackPageVisitTime = stringToBoolOrDefault(config.autoTrackPageVisitTime);
3453
- config.overridePageViewDuration = stringToBoolOrDefault(config.overridePageViewDuration);
3454
- config.enableUnhandledPromiseRejectionTracking = stringToBoolOrDefault(config.enableUnhandledPromiseRejectionTracking);
3455
- if (isNaN(config.samplingPercentage) || config.samplingPercentage <= 0 || config.samplingPercentage >= 100) {
3456
- config.samplingPercentage = 100;
3457
- }
3458
- config.isStorageUseDisabled = stringToBoolOrDefault(config.isStorageUseDisabled);
3459
- config.isBrowserLinkTrackingEnabled = stringToBoolOrDefault(config.isBrowserLinkTrackingEnabled);
3460
- config.enableAutoRouteTracking = stringToBoolOrDefault(config.enableAutoRouteTracking);
3461
- config.namePrefix = config.namePrefix || "";
3462
- config.enableDebug = stringToBoolOrDefault(config.enableDebug);
3463
- config.disableFlushOnBeforeUnload = stringToBoolOrDefault(config.disableFlushOnBeforeUnload);
3464
- config.disableFlushOnUnload = stringToBoolOrDefault(config.disableFlushOnUnload, config.disableFlushOnBeforeUnload);
3465
- return config;
3466
- };
3467
- ApplicationInsights.Version = "2.8.0-nightly.2202-06";
3468
- return ApplicationInsights;
3469
- }(BaseTelemetryPlugin));
3470
- var Timing = /** @class */ (function () {
3471
- function Timing(logger, name) {
3472
- var _self = this;
3473
- var _events = {};
3474
- _self.start = function (name) {
3475
- if (typeof _events[name] !== "undefined") {
3476
- logger.throwInternal(LoggingSeverity.WARNING, _InternalMessageId.StartCalledMoreThanOnce, "start was called more than once for this event without calling stop.", { name: name, key: name }, true);
4212
+ function _updateExceptionTracking(extConfig) {
4213
+ var _window = getWindow();
4214
+ var locn = getLocation(true);
4215
+ _disableExceptionTracking = extConfig.disableExceptionTracking;
4216
+ if (!_disableExceptionTracking && !_autoExceptionInstrumented && !extConfig.autoExceptionInstrumented) {
4217
+ _addHook(InstrumentFunc(_window, "onerror", {
4218
+ ns: _evtNamespace,
4219
+ rsp: function (callDetails, message, url, lineNumber, columnNumber, error) {
4220
+ if (!_disableExceptionTracking && callDetails.rslt !== true) {
4221
+ _self._onerror(Exception.CreateAutoException(message, url, lineNumber, columnNumber, error, callDetails.evt));
4222
+ }
4223
+ }
4224
+ }));
4225
+ _autoExceptionInstrumented = true;
4226
+ }
4227
+ _addUnhandledPromiseRejectionTracking(extConfig, _window, locn);
3477
4228
  }
3478
- _events[name] = +new Date;
3479
- };
3480
- _self.stop = function (name, url, properties, measurements) {
3481
- var start = _events[name];
3482
- if (isNaN(start)) {
3483
- logger.throwInternal(LoggingSeverity.WARNING, _InternalMessageId.StopCalledWithoutStart, "stop was called without a corresponding start.", { name: name, key: name }, true);
4229
+ function _updateLocationChange(extConfig) {
4230
+ var win = getWindow();
4231
+ var locn = getLocation(true);
4232
+ _enableAutoRouteTracking = extConfig.enableAutoRouteTracking === true;
4233
+ if (win && _enableAutoRouteTracking && hasHistory()) {
4234
+ var _history = getHistory();
4235
+ if (isFunction(_history.pushState) && isFunction(_history.replaceState) && typeof Event !== strShimUndefined) {
4236
+ _addHistoryListener(extConfig, win, _history, locn);
4237
+ }
4238
+ }
3484
4239
  }
3485
- else {
3486
- var end = +new Date;
3487
- var duration = dateTimeUtilsDuration(start, end);
3488
- _self.action(name, url, duration, properties, measurements);
4240
+ function _addHistoryListener(extConfig, win, history, locn) {
4241
+ function _popstateHandler() {
4242
+ if (_enableAutoRouteTracking) {
4243
+ _dispatchEvent(win, createDomEvent(extConfig.namePrefix + "locationchange"));
4244
+ }
4245
+ }
4246
+ function _locationChangeHandler() {
4247
+ if (_currUri) {
4248
+ _prevUri = _currUri;
4249
+ _currUri = locn && locn.href || "";
4250
+ }
4251
+ else {
4252
+ _currUri = locn && locn.href || "";
4253
+ }
4254
+ if (_enableAutoRouteTracking) {
4255
+ var properties = _self.core.getPlugin(PropertiesPluginIdentifier);
4256
+ if (properties) {
4257
+ var context = properties.plugin.context;
4258
+ if (context && context.telemetryTrace) {
4259
+ context.telemetryTrace.traceID = generateW3CId();
4260
+ var traceLocationName = "_unknown_";
4261
+ if (locn && locn.pathname) {
4262
+ traceLocationName = locn.pathname + (locn.hash || "");
4263
+ }
4264
+ context.telemetryTrace.name = dataSanitizeString(_self.diagLog(), traceLocationName);
4265
+ }
4266
+ }
4267
+ setTimeout((function (uri) {
4268
+ _self.trackPageView({ refUri: uri, properties: { duration: 0 } });
4269
+ }).bind(this, _prevUri), _self.autoRoutePVDelay);
4270
+ }
4271
+ }
4272
+ if (!_historyListenerAdded) {
4273
+ _addHook(InstrumentFunc(history, "pushState", {
4274
+ ns: _evtNamespace,
4275
+ rsp: function () {
4276
+ if (_enableAutoRouteTracking) {
4277
+ _dispatchEvent(win, createDomEvent(extConfig.namePrefix + "pushState"));
4278
+ _dispatchEvent(win, createDomEvent(extConfig.namePrefix + "locationchange"));
4279
+ }
4280
+ }
4281
+ }));
4282
+ _addHook(InstrumentFunc(history, "replaceState", {
4283
+ ns: _evtNamespace,
4284
+ rsp: function () {
4285
+ if (_enableAutoRouteTracking) {
4286
+ _dispatchEvent(win, createDomEvent(extConfig.namePrefix + "replaceState"));
4287
+ _dispatchEvent(win, createDomEvent(extConfig.namePrefix + "locationchange"));
4288
+ }
4289
+ }
4290
+ }));
4291
+ eventOn(win, extConfig.namePrefix + "popstate", _popstateHandler, _evtNamespace);
4292
+ eventOn(win, extConfig.namePrefix + "locationchange", _locationChangeHandler, _evtNamespace);
4293
+ _historyListenerAdded = true;
4294
+ }
3489
4295
  }
3490
- delete _events[name];
3491
- _events[name] = undefined;
3492
- };
4296
+ function _addUnhandledPromiseRejectionTracking(extConfig, _window, _location) {
4297
+ _enableUnhandledPromiseRejectionTracking = extConfig.enableUnhandledPromiseRejectionTracking === true;
4298
+ if (_enableUnhandledPromiseRejectionTracking && !_autoUnhandledPromiseInstrumented) {
4299
+ _addHook(InstrumentFunc(_window, "onunhandledrejection", {
4300
+ ns: _evtNamespace,
4301
+ rsp: function (callDetails, error) {
4302
+ if (_enableUnhandledPromiseRejectionTracking && callDetails.rslt !== true) {
4303
+ _self._onerror(Exception.CreateAutoException(_getReason(error), _location ? _location.href : "", 0, 0, error, callDetails.evt));
4304
+ }
4305
+ }
4306
+ }));
4307
+ _autoUnhandledPromiseInstrumented = true;
4308
+ extConfig.autoUnhandledPromiseInstrumented = _autoUnhandledPromiseInstrumented;
4309
+ }
4310
+ }
4311
+ function _throwInternal(severity, msgId, msg, properties, isUserAct) {
4312
+ _self.diagLog().throwInternal(severity, msgId, msg, properties, isUserAct);
4313
+ }
4314
+ function _initDefaults() {
4315
+ _eventTracking = null;
4316
+ _pageTracking = null;
4317
+ _pageViewManager = null;
4318
+ _pageViewPerformanceManager = null;
4319
+ _pageVisitTimeManager = null;
4320
+ _preInitTelemetryInitializers = null;
4321
+ _isBrowserLinkTrackingEnabled = false;
4322
+ _browserLinkInitializerAdded = false;
4323
+ _enableAutoRouteTracking = false;
4324
+ _historyListenerAdded = false;
4325
+ _disableExceptionTracking = false;
4326
+ _autoExceptionInstrumented = false;
4327
+ _enableUnhandledPromiseRejectionTracking = false;
4328
+ _autoUnhandledPromiseInstrumented = false;
4329
+ var location = getLocation(true);
4330
+ _prevUri = location && location.href || "";
4331
+ _currUri = null;
4332
+ _evtNamespace = null;
4333
+ }
4334
+ objDefineAccessors(_self, "_pageViewManager", function () { return _pageViewManager; });
4335
+ objDefineAccessors(_self, "_pageViewPerformanceManager", function () { return _pageViewPerformanceManager; });
4336
+ objDefineAccessors(_self, "_pageVisitTimeManager", function () { return _pageVisitTimeManager; });
4337
+ objDefineAccessors(_self, "_evtNamespace", function () { return "." + _evtNamespace; });
4338
+ });
4339
+ return _this;
3493
4340
  }
3494
- return Timing;
3495
- }());
4341
+ AnalyticsPlugin.Version = "2.8.0-nightly.2204-04";
4342
+ AnalyticsPlugin.getDefaultConfig = _getDefaultConfig;
4343
+ return AnalyticsPlugin;
4344
+ }(BaseTelemetryPlugin));
3496
4345
 
3497
- exports.ApplicationInsights = ApplicationInsights;
4346
+ exports.AnalyticsPlugin = AnalyticsPlugin;
4347
+ exports.ApplicationInsights = AnalyticsPlugin;
3498
4348
 
3499
4349
  (function(obj, prop, descriptor) { /* ai_es3_polyfil defineProperty */ var func = Object["defineProperty"]; if (func) { try { return func(obj, prop, descriptor); } catch(e) { /* IE8 defines defineProperty, but will throw */ } } if (descriptor && typeof descriptor.value !== undefined) { obj[prop] = descriptor.value; } return obj; })(exports, '__esModule', { value: true });
3500
4350