@microsoft/applicationinsights-analytics-js 2.7.5-nightly.2203-03 → 2.7.5

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 +668 -1624
  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 +278 -97
  7. package/dist/applicationinsights-analytics-js.api.md +18 -8
  8. package/dist/applicationinsights-analytics-js.d.ts +104 -9
  9. package/dist/applicationinsights-analytics-js.js +668 -1624
  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 +104 -9
  14. package/dist-esm/JavaScriptSDK/ApplicationInsights.js +606 -0
  15. package/dist-esm/JavaScriptSDK/ApplicationInsights.js.map +1 -0
  16. package/dist-esm/JavaScriptSDK/Telemetry/PageViewManager.js +8 -21
  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.Interfaces/ITelemetryConfig.js +1 -1
  23. package/dist-esm/applicationinsights-analytics-js.js +2 -2
  24. package/dist-esm/applicationinsights-analytics-js.js.map +1 -1
  25. package/package.json +60 -63
  26. package/src/JavaScriptSDK/{AnalyticsPlugin.ts → ApplicationInsights.ts} +325 -403
  27. package/src/JavaScriptSDK/Telemetry/PageViewManager.ts +13 -32
  28. package/src/JavaScriptSDK/Telemetry/PageViewPerformanceManager.ts +6 -6
  29. package/src/JavaScriptSDK/Telemetry/PageVisitTimeManager.ts +1 -1
  30. package/src/applicationinsights-analytics-js.ts +1 -1
  31. package/types/JavaScriptSDK/{AnalyticsPlugin.d.ts → ApplicationInsights.d.ts} +16 -12
  32. package/types/JavaScriptSDK/Telemetry/PageViewManager.d.ts +1 -2
  33. package/types/JavaScriptSDK/Telemetry/PageViewPerformanceManager.d.ts +9 -9
  34. package/types/JavaScriptSDK/Telemetry/PageVisitTimeManager.d.ts +4 -4
  35. package/types/applicationinsights-analytics-js.d.ts +1 -1
  36. package/types/tsdoc-metadata.json +1 -1
  37. package/dist-esm/JavaScriptSDK/AnalyticsPlugin.js +0 -674
  38. package/dist-esm/JavaScriptSDK/AnalyticsPlugin.js.map +0 -1
  39. package/dist-esm/JavaScriptSDK/Timing.js +0 -39
  40. package/dist-esm/JavaScriptSDK/Timing.js.map +0 -1
  41. package/src/JavaScriptSDK/Timing.ts +0 -46
  42. package/types/JavaScriptSDK/Timing.d.ts +0 -18
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * Application Insights JavaScript SDK - Web Analytics, 2.7.5-nightly.2203-03
2
+ * Application Insights JavaScript SDK - Web Analytics, 2.7.5
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  */
5
5
  (function (global, factory) {
@@ -75,9 +75,7 @@
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) {
79
- d.__proto__ = b;
80
- }) ||
78
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
81
79
  function (d, b) {
82
80
  for (var p in b) {
83
81
  if (b[strShimHasOwnProperty](p)) {
@@ -92,14 +90,12 @@
92
90
  throwTypeError("Class extends value " + String(b) + " is not a constructor or null");
93
91
  }
94
92
  extendStaticsFn(d, b);
95
- function __() {
96
- this.constructor = d;
97
- }
93
+ function __() { this.constructor = d; }
98
94
  d[strShimPrototype] = b === null ? objCreateFn(b) : (__[strShimPrototype] = b[strShimPrototype], new __());
99
95
  }
100
96
 
101
97
  /*!
102
- * Microsoft Dynamic Proto Utility, 1.1.4
98
+ * Microsoft Dynamic Proto Utility, 1.1.5
103
99
  * Copyright (c) Microsoft and contributors. All rights reserved.
104
100
  */
105
101
  var Constructor = 'constructor';
@@ -112,12 +108,13 @@
112
108
  var DynInstChkTag = '_dynInstChk';
113
109
  var DynAllowInstChkTag = DynInstChkTag;
114
110
  var DynProtoDefaultOptions = '_dfOpts';
111
+ var DynProtoPolyProto = "_dynProto";
115
112
  var UnknownValue = '_unknown_';
116
- var str__Proto$1 = "__proto__";
113
+ var str__Proto = "__proto__";
117
114
  var strUseBaseInst = 'useBaseInst';
118
115
  var strSetInstFuncs = 'setInstFuncs';
119
116
  var Obj = Object;
120
- var _objGetPrototypeOf$1 = Obj["getPrototypeOf"];
117
+ var _objGetPrototypeOf = Obj["getPrototypeOf"];
121
118
  var _dynamicNames = 0;
122
119
  function _hasOwnProperty(obj, prop) {
123
120
  return obj && Obj[Prototype].hasOwnProperty.call(obj, prop);
@@ -128,13 +125,16 @@
128
125
  function _isObjectArrayOrFunctionPrototype(target) {
129
126
  return _isObjectOrArrayPrototype(target) || target === Function[Prototype];
130
127
  }
131
- function _getObjProto$1(target) {
128
+ function _getObjProto(target) {
132
129
  if (target) {
133
- if (_objGetPrototypeOf$1) {
134
- return _objGetPrototypeOf$1(target);
130
+ if (_objGetPrototypeOf) {
131
+ return _objGetPrototypeOf(target);
135
132
  }
136
- var newProto = target[str__Proto$1] || target[Prototype] || (target[Constructor] ? target[Constructor][Prototype] : null);
133
+ var newProto = target[DynProtoPolyProto] || target[str__Proto] || target[Prototype] || (target[Constructor] ? target[Constructor][Prototype] : null);
137
134
  if (newProto) {
135
+ if (!target[DynProtoPolyProto]) {
136
+ target[DynProtoPolyProto] = newProto;
137
+ }
138
138
  return newProto;
139
139
  }
140
140
  }
@@ -199,16 +199,16 @@
199
199
  _forEachProp(instFuncs, function (name) {
200
200
  baseFuncs[name] = _instFuncProxy(thisTarget, instFuncs, name);
201
201
  });
202
- var baseProto = _getObjProto$1(classProto);
202
+ var baseProto = _getObjProto(classProto);
203
203
  var visited = [];
204
204
  while (baseProto && !_isObjectArrayOrFunctionPrototype(baseProto) && !_hasVisited(visited, baseProto)) {
205
205
  _forEachProp(baseProto, function (name) {
206
- if (!baseFuncs[name] && _isDynamicCandidate(baseProto, name, !_objGetPrototypeOf$1)) {
206
+ if (!baseFuncs[name] && _isDynamicCandidate(baseProto, name, !_objGetPrototypeOf)) {
207
207
  baseFuncs[name] = _instFuncProxy(thisTarget, baseProto, name);
208
208
  }
209
209
  });
210
210
  visited.push(baseProto);
211
- baseProto = _getObjProto$1(baseProto);
211
+ baseProto = _getObjProto(baseProto);
212
212
  }
213
213
  return baseFuncs;
214
214
  }
@@ -222,7 +222,7 @@
222
222
  }
223
223
  if (!instFunc[DynInstChkTag] && instFuncTable[DynAllowInstChkTag] !== false) {
224
224
  var canAddInst = !_hasOwnProperty(target, funcName);
225
- var objProto = _getObjProto$1(target);
225
+ var objProto = _getObjProto(target);
226
226
  var visited = [];
227
227
  while (canAddInst && objProto && !_isObjectArrayOrFunctionPrototype(objProto) && !_hasVisited(visited, objProto)) {
228
228
  var protoFunc = objProto[funcName];
@@ -231,7 +231,7 @@
231
231
  break;
232
232
  }
233
233
  visited.push(objProto);
234
- objProto = _getObjProto$1(objProto);
234
+ objProto = _getObjProto(objProto);
235
235
  }
236
236
  try {
237
237
  if (canAddInst) {
@@ -249,7 +249,7 @@
249
249
  function _getProtoFunc(funcName, proto, currentDynProtoProxy) {
250
250
  var protoFunc = proto[funcName];
251
251
  if (protoFunc === currentDynProtoProxy) {
252
- protoFunc = _getObjProto$1(proto)[funcName];
252
+ protoFunc = _getObjProto(proto)[funcName];
253
253
  }
254
254
  if (typeof protoFunc !== strFunction) {
255
255
  _throwTypeError("[" + funcName + "] is not a " + strFunction);
@@ -283,18 +283,19 @@
283
283
  }
284
284
  }
285
285
  function _checkPrototype(classProto, thisTarget) {
286
- if (_objGetPrototypeOf$1) {
286
+ if (_objGetPrototypeOf) {
287
287
  var visited = [];
288
- var thisProto = _getObjProto$1(thisTarget);
288
+ var thisProto = _getObjProto(thisTarget);
289
289
  while (thisProto && !_isObjectArrayOrFunctionPrototype(thisProto) && !_hasVisited(visited, thisProto)) {
290
290
  if (thisProto === classProto) {
291
291
  return true;
292
292
  }
293
293
  visited.push(thisProto);
294
- thisProto = _getObjProto$1(thisProto);
294
+ thisProto = _getObjProto(thisProto);
295
295
  }
296
+ return false;
296
297
  }
297
- return false;
298
+ return true;
298
299
  }
299
300
  function _getObjName(target, unknownValue) {
300
301
  if (_hasOwnProperty(target, Prototype)) {
@@ -327,7 +328,7 @@
327
328
  var instFuncs = _getInstanceFuncs(target);
328
329
  var baseFuncs = _getBaseFuncs(classProto, target, instFuncs, useBaseInst);
329
330
  delegateFunc(target, baseFuncs);
330
- var setInstanceFunc = !!_objGetPrototypeOf$1 && !!perfOptions[strSetInstFuncs];
331
+ var setInstanceFunc = !!_objGetPrototypeOf && !!perfOptions[strSetInstFuncs];
331
332
  if (setInstanceFunc && options) {
332
333
  setInstanceFunc = !!options[strSetInstFuncs];
333
334
  }
@@ -339,25 +340,102 @@
339
340
  };
340
341
  dynamicProto[DynProtoDefaultOptions] = perfDefaults;
341
342
 
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";
343
+ var LoggingSeverity;
344
+ (function (LoggingSeverity) {
345
+ LoggingSeverity[LoggingSeverity["CRITICAL"] = 1] = "CRITICAL";
346
+ LoggingSeverity[LoggingSeverity["WARNING"] = 2] = "WARNING";
347
+ })(LoggingSeverity || (LoggingSeverity = {}));
348
+ var _InternalMessageId = {
349
+ BrowserDoesNotSupportLocalStorage: 0,
350
+ BrowserCannotReadLocalStorage: 1,
351
+ BrowserCannotReadSessionStorage: 2,
352
+ BrowserCannotWriteLocalStorage: 3,
353
+ BrowserCannotWriteSessionStorage: 4,
354
+ BrowserFailedRemovalFromLocalStorage: 5,
355
+ BrowserFailedRemovalFromSessionStorage: 6,
356
+ CannotSendEmptyTelemetry: 7,
357
+ ClientPerformanceMathError: 8,
358
+ ErrorParsingAISessionCookie: 9,
359
+ ErrorPVCalc: 10,
360
+ ExceptionWhileLoggingError: 11,
361
+ FailedAddingTelemetryToBuffer: 12,
362
+ FailedMonitorAjaxAbort: 13,
363
+ FailedMonitorAjaxDur: 14,
364
+ FailedMonitorAjaxOpen: 15,
365
+ FailedMonitorAjaxRSC: 16,
366
+ FailedMonitorAjaxSend: 17,
367
+ FailedMonitorAjaxGetCorrelationHeader: 18,
368
+ FailedToAddHandlerForOnBeforeUnload: 19,
369
+ FailedToSendQueuedTelemetry: 20,
370
+ FailedToReportDataLoss: 21,
371
+ FlushFailed: 22,
372
+ MessageLimitPerPVExceeded: 23,
373
+ MissingRequiredFieldSpecification: 24,
374
+ NavigationTimingNotSupported: 25,
375
+ OnError: 26,
376
+ SessionRenewalDateIsZero: 27,
377
+ SenderNotInitialized: 28,
378
+ StartTrackEventFailed: 29,
379
+ StopTrackEventFailed: 30,
380
+ StartTrackFailed: 31,
381
+ StopTrackFailed: 32,
382
+ TelemetrySampledAndNotSent: 33,
383
+ TrackEventFailed: 34,
384
+ TrackExceptionFailed: 35,
385
+ TrackMetricFailed: 36,
386
+ TrackPVFailed: 37,
387
+ TrackPVFailedCalc: 38,
388
+ TrackTraceFailed: 39,
389
+ TransmissionFailed: 40,
390
+ FailedToSetStorageBuffer: 41,
391
+ FailedToRestoreStorageBuffer: 42,
392
+ InvalidBackendResponse: 43,
393
+ FailedToFixDepricatedValues: 44,
394
+ InvalidDurationValue: 45,
395
+ TelemetryEnvelopeInvalid: 46,
396
+ CreateEnvelopeError: 47,
397
+ CannotSerializeObject: 48,
398
+ CannotSerializeObjectNonSerializable: 49,
399
+ CircularReferenceDetected: 50,
400
+ ClearAuthContextFailed: 51,
401
+ ExceptionTruncated: 52,
402
+ IllegalCharsInName: 53,
403
+ ItemNotInArray: 54,
404
+ MaxAjaxPerPVExceeded: 55,
405
+ MessageTruncated: 56,
406
+ NameTooLong: 57,
407
+ SampleRateOutOfRange: 58,
408
+ SetAuthContextFailed: 59,
409
+ SetAuthContextFailedAccountName: 60,
410
+ StringValueTooLong: 61,
411
+ StartCalledMoreThanOnce: 62,
412
+ StopCalledWithoutStart: 63,
413
+ TelemetryInitializerFailed: 64,
414
+ TrackArgumentsNotSpecified: 65,
415
+ UrlTooLong: 66,
416
+ SessionStorageBufferFull: 67,
417
+ CannotAccessCookie: 68,
418
+ IdTooLong: 69,
419
+ InvalidEvent: 70,
420
+ FailedMonitorAjaxSetRequestHeader: 71,
421
+ SendBrowserInfoOnUserInit: 72,
422
+ PluginException: 73,
423
+ NotificationException: 74,
424
+ SnippetScriptLoadFailure: 99,
425
+ InvalidInstrumentationKey: 100,
426
+ CannotParseAiBlobValue: 101,
427
+ InvalidContentBlob: 102,
428
+ TrackPageActionEventFailed: 103,
429
+ FailedAddingCustomDefinedRequestContext: 104,
430
+ InMemoryStorageBufferFull: 105
431
+ };
350
432
 
351
433
  var strToISOString = "toISOString";
352
434
  var cStrEndsWith = "endsWith";
353
435
  var strMap = "map";
354
436
  var cStrTrim = "trim";
355
437
  var strToString = "toString";
356
- var str__Proto = "__proto__";
357
- var strConstructor = "constructor";
358
- var _objDefineProperty$1 = ObjDefineProperty;
359
- var _objFreeze = ObjClass.freeze;
360
- var _objKeys = ObjClass.keys;
438
+ var _objDefineProperty = ObjDefineProperty;
361
439
  var StringProto = String[strShimPrototype];
362
440
  var _strTrim = StringProto[cStrTrim];
363
441
  var _strEndsWith = StringProto[cStrEndsWith];
@@ -366,23 +444,7 @@
366
444
  var _isArray = Array.isArray;
367
445
  var _objToString = ObjProto[strToString];
368
446
  var _fnToString = ObjHasOwnProperty[strToString];
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
- }
447
+ _fnToString.call(ObjClass);
386
448
  function isUndefined(value) {
387
449
  return value === undefined || typeof value === strShimUndefined;
388
450
  }
@@ -392,28 +454,12 @@
392
454
  function isNotNullOrUndefined(value) {
393
455
  return !isNullOrUndefined(value);
394
456
  }
395
- function hasOwnProperty(obj, prop) {
396
- return !!(obj && ObjHasOwnProperty.call(obj, prop));
397
- }
398
457
  function isObject(value) {
399
458
  return !!(value && typeof value === strShimObject);
400
459
  }
401
460
  function isFunction(value) {
402
461
  return !!(value && typeof value === strShimFunction);
403
462
  }
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
- }
417
463
  function objForEachKey(target, callbackfn) {
418
464
  if (target) {
419
465
  for (var prop in target) {
@@ -462,25 +508,6 @@
462
508
  function isString(value) {
463
509
  return typeof value === "string";
464
510
  }
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
- }
484
511
  function toISOString(date) {
485
512
  if (date) {
486
513
  return _dataToISOString ? date[strToISOString]() : _toISOStringPoly(date);
@@ -546,42 +573,8 @@
546
573
  }
547
574
  return str;
548
575
  }
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
- }
583
576
  function objDefineAccessors(target, prop, getProp, setProp) {
584
- if (_objDefineProperty$1) {
577
+ if (_objDefineProperty) {
585
578
  try {
586
579
  var descriptor = {
587
580
  enumerable: true,
@@ -593,7 +586,7 @@
593
586
  if (setProp) {
594
587
  descriptor.set = setProp;
595
588
  }
596
- _objDefineProperty$1(target, prop, descriptor);
589
+ _objDefineProperty(target, prop, descriptor);
597
590
  return true;
598
591
  }
599
592
  catch (e) {
@@ -601,10 +594,6 @@
601
594
  }
602
595
  return false;
603
596
  }
604
- function _doNothing(value) {
605
- return value;
606
- }
607
- var objFreeze = _objFreeze || _doNothing;
608
597
  function dateNow() {
609
598
  var dt = Date;
610
599
  return dt.now ? dt.now() : new dt().getTime();
@@ -613,7 +602,7 @@
613
602
  if (isError(object)) {
614
603
  return object.name;
615
604
  }
616
- return strEmpty$1;
605
+ return "";
617
606
  }
618
607
  function setValue(target, field, value, valChk, srcChk) {
619
608
  var theValue = value;
@@ -632,88 +621,6 @@
632
621
  function throwError(message) {
633
622
  throw new Error(message);
634
623
  }
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
- }
717
624
 
718
625
  var strWindow = "window";
719
626
  var strDocument = "document";
@@ -816,14 +723,14 @@
816
723
  var nav = getNavigator();
817
724
  if (nav && (nav.userAgent !== _navUserAgentCheck || _isTrident === null)) {
818
725
  _navUserAgentCheck = nav.userAgent;
819
- var userAgent = (_navUserAgentCheck || strEmpty$1).toLowerCase();
726
+ var userAgent = (_navUserAgentCheck || "").toLowerCase();
820
727
  _isTrident = (strContains(userAgent, strMsie) || strContains(userAgent, strTrident));
821
728
  }
822
729
  return _isTrident;
823
730
  }
824
731
  function dumpObj(object) {
825
732
  var objectTypeDump = Object[strShimPrototype].toString.call(object);
826
- var propertyValueDump = strEmpty$1;
733
+ var propertyValueDump = "";
827
734
  if (objectTypeDump === "[object Error]") {
828
735
  propertyValueDump = "{ stack: '" + object.stack + "', message: '" + object.message + "', name: '" + object.name + "'";
829
736
  }
@@ -856,9 +763,9 @@
856
763
  var strWarnToConsole = "warnToConsole";
857
764
  function _sanitizeDiagnosticText(text) {
858
765
  if (text) {
859
- return "\"" + text.replace(/\"/g, strEmpty$1) + "\"";
766
+ return "\"" + text.replace(/\"/g, "") + "\"";
860
767
  }
861
- return strEmpty$1;
768
+ return "";
862
769
  }
863
770
  function _logToConsole(func, message) {
864
771
  var theConsole = getConsole();
@@ -880,12 +787,12 @@
880
787
  _self.message =
881
788
  (isUserAct ? AiUserActionablePrefix : AiNonUserActionablePrefix) +
882
789
  msgId;
883
- var strProps = strEmpty$1;
790
+ var strProps = "";
884
791
  if (hasJSON()) {
885
792
  strProps = getJSON().stringify(properties);
886
793
  }
887
- var diagnosticText = (msg ? " message:" + _sanitizeDiagnosticText(msg) : strEmpty$1) +
888
- (properties ? " props:" + _sanitizeDiagnosticText(strProps) : strEmpty$1);
794
+ var diagnosticText = (msg ? " message:" + _sanitizeDiagnosticText(msg) : "") +
795
+ (properties ? " props:" + _sanitizeDiagnosticText(strProps) : "");
889
796
  _self.message += diagnosticText;
890
797
  }
891
798
  _InternalLogMessage.dataType = "MessageData";
@@ -912,10 +819,10 @@
912
819
  if (isUserAct === void 0) { isUserAct = false; }
913
820
  var message = new _InternalLogMessage(msgId, msg, isUserAct, properties);
914
821
  if (_self.enableDebugExceptions()) {
915
- throw message;
822
+ throw dumpObj(message);
916
823
  }
917
824
  else {
918
- var logFunc = severity === 1 ? strErrorToConsole : strWarnToConsole;
825
+ var logFunc = severity === LoggingSeverity.CRITICAL ? strErrorToConsole : strWarnToConsole;
919
826
  if (!isUndefined(message.message)) {
920
827
  var logLevel = _self.consoleLoggingLevel();
921
828
  if (isUserAct) {
@@ -933,7 +840,7 @@
933
840
  _self.logInternalMessage(severity, message);
934
841
  }
935
842
  else {
936
- _debugExtMsg("throw" + (severity === 1 ? "Critical" : "Warning"), message);
843
+ _debugExtMsg("throw" + (severity === LoggingSeverity.CRITICAL ? "Critical" : "Warning"), message);
937
844
  }
938
845
  }
939
846
  };
@@ -965,13 +872,13 @@
965
872
  if (severity <= _self.telemetryLoggingLevel()) {
966
873
  _self.queue.push(message);
967
874
  _messageCount++;
968
- _debugExtMsg((severity === 1 ? "error" : "warn"), message);
875
+ _debugExtMsg((severity === LoggingSeverity.CRITICAL ? "error" : "warn"), message);
969
876
  }
970
877
  if (_messageCount === _self.maxInternalMessageLimit()) {
971
878
  var throttleLimitMessage = "Internal events throttle limit per PageView reached for this app.";
972
- var throttleMessage = new _InternalLogMessage(23 , throttleLimitMessage, false);
879
+ var throttleMessage = new _InternalLogMessage(_InternalMessageId.MessageLimitPerPVExceeded, throttleLimitMessage, false);
973
880
  _self.queue.push(throttleMessage);
974
- if (severity === 1 ) {
881
+ if (severity === LoggingSeverity.CRITICAL) {
975
882
  _self.errorToConsole(throttleLimitMessage);
976
883
  }
977
884
  else {
@@ -1000,10 +907,6 @@
1000
907
  }
1001
908
  return DiagnosticLogger;
1002
909
  }());
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
- }
1007
910
 
1008
911
  var strExecutionContextKey = "ctx";
1009
912
  var PerfEvent = /** @class */ (function () {
@@ -1117,495 +1020,252 @@
1117
1020
  return func();
1118
1021
  }
1119
1022
 
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;
1128
- }
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
- }
1023
+ var TelemetryPluginChain = /** @class */ (function () {
1024
+ function TelemetryPluginChain(plugin, defItemCtx) {
1025
+ var _self = this;
1026
+ var _nextProxy = null;
1027
+ var _hasProcessTelemetry = isFunction(plugin.processTelemetry);
1028
+ var _hasSetNext = isFunction(plugin.setNextPlugin);
1029
+ _self._hasRun = false;
1030
+ _self.getPlugin = function () {
1031
+ return plugin;
1032
+ };
1033
+ _self.getNext = function () {
1034
+ return _nextProxy;
1035
+ };
1036
+ _self.setNext = function (nextPlugin) {
1037
+ _nextProxy = nextPlugin;
1038
+ };
1039
+ _self.processTelemetry = function (env, itemCtx) {
1040
+ if (!itemCtx) {
1041
+ itemCtx = defItemCtx;
1042
+ }
1043
+ var identifier = plugin ? plugin.identifier : "TelemetryPluginChain";
1044
+ doPerf(itemCtx ? itemCtx.core() : null, function () { return identifier + ":processTelemetry"; }, function () {
1045
+ if (plugin && _hasProcessTelemetry) {
1046
+ _self._hasRun = true;
1047
+ try {
1048
+ itemCtx.setNext(_nextProxy);
1049
+ if (_hasSetNext) {
1050
+ plugin.setNextPlugin(_nextProxy);
1051
+ }
1052
+ _nextProxy && (_nextProxy._hasRun = false);
1053
+ plugin.processTelemetry(env, itemCtx);
1054
+ }
1055
+ catch (error) {
1056
+ var hasRun = _nextProxy && _nextProxy._hasRun;
1057
+ if (!_nextProxy || !hasRun) {
1058
+ itemCtx.diagLog().throwInternal(LoggingSeverity.CRITICAL, _InternalMessageId.PluginException, "Plugin [" + plugin.identifier + "] failed during processTelemetry - " + dumpObj(error));
1059
+ }
1060
+ if (_nextProxy && !hasRun) {
1061
+ _nextProxy.processTelemetry(env, itemCtx);
1062
+ }
1063
+ }
1064
+ }
1065
+ else if (_nextProxy) {
1066
+ _self._hasRun = true;
1067
+ _nextProxy.processTelemetry(env, itemCtx);
1068
+ }
1069
+ }, function () { return ({ item: env }); }, !(env.sync));
1070
+ };
1184
1071
  }
1185
- return result;
1186
- }
1072
+ return TelemetryPluginChain;
1073
+ }());
1187
1074
 
1188
- var _objDefineProperty = ObjDefineProperty;
1189
- var version = "2.7.5-nightly.2203-03";
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;
1075
+ function _createProxyChain(plugins, itemCtx) {
1076
+ var proxies = [];
1077
+ if (plugins && plugins.length > 0) {
1078
+ var lastProxy = null;
1079
+ for (var idx = 0; idx < plugins.length; idx++) {
1080
+ var thePlugin = plugins[idx];
1081
+ if (thePlugin && isFunction(thePlugin.processTelemetry)) {
1082
+ var newProxy = new TelemetryPluginChain(thePlugin, itemCtx);
1083
+ proxies.push(newProxy);
1084
+ if (lastProxy) {
1085
+ lastProxy.setNext(newProxy);
1218
1086
  }
1087
+ lastProxy = newProxy;
1219
1088
  }
1220
1089
  }
1221
- catch (e) {
1222
- }
1223
1090
  }
1224
- return theCache;
1225
- }
1226
- function createUniqueNamespace(name, includeVersion) {
1227
- if (includeVersion === void 0) { includeVersion = false; }
1228
- return normalizeJsName(name + (_dataUid++) + (includeVersion ? "." + version : "") + instanceName);
1091
+ return proxies.length > 0 ? proxies[0] : null;
1229
1092
  }
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
- }
1093
+ function _copyProxyChain(proxy, itemCtx, startAt) {
1094
+ var plugins = [];
1095
+ var add = startAt ? false : true;
1096
+ if (proxy) {
1097
+ while (proxy) {
1098
+ var thePlugin = proxy.getPlugin();
1099
+ if (add || thePlugin === startAt) {
1100
+ add = true;
1101
+ plugins.push(thePlugin);
1254
1102
  }
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
- });
1103
+ proxy = proxy.getNext();
1322
1104
  }
1323
1105
  }
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
- }
1106
+ if (!add) {
1107
+ plugins.push(startAt);
1393
1108
  }
1394
- return context;
1109
+ return _createProxyChain(plugins, itemCtx);
1395
1110
  }
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);
1111
+ function _copyPluginChain(srcPlugins, itemCtx, startAt) {
1112
+ var plugins = srcPlugins;
1113
+ var add = false;
1114
+ if (startAt && srcPlugins) {
1115
+ plugins = [];
1116
+ arrForEach(srcPlugins, function (thePlugin) {
1117
+ if (add || thePlugin === startAt) {
1118
+ add = true;
1119
+ plugins.push(thePlugin);
1441
1120
  }
1442
1121
  });
1443
1122
  }
1444
- function _createNew(plugins, startAt) {
1445
- if (plugins === void 0) { plugins = null; }
1446
- if (isArray(plugins)) {
1447
- plugins = createTelemetryProxyChain(plugins, config, core, startAt);
1123
+ if (startAt && !add) {
1124
+ if (!plugins) {
1125
+ plugins = [];
1448
1126
  }
1449
- return createProcessTelemetryUpdateContext(plugins || context.getNext(), config, core, startAt);
1127
+ plugins.push(startAt);
1450
1128
  }
1451
- context.processNext = _processNext;
1452
- context.createNew = _createNew;
1453
- return context;
1129
+ return _createProxyChain(plugins, itemCtx);
1454
1130
  }
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;
1131
+ var ProcessTelemetryContext = /** @class */ (function () {
1132
+ function ProcessTelemetryContext(plugins, config, core, startAt) {
1133
+ var _self = this;
1134
+ var _nextProxy = null;
1135
+ if (startAt !== null) {
1136
+ if (plugins && isFunction(plugins.getPlugin)) {
1137
+ _nextProxy = _copyProxyChain(plugins, _self, startAt || plugins.getPlugin());
1463
1138
  }
1464
- if (add && thePlugin && isFunction(thePlugin.processTelemetry)) {
1465
- var newProxy = createTelemetryPluginProxy(thePlugin, config, core);
1466
- if (!firstProxy) {
1467
- firstProxy = newProxy;
1139
+ else {
1140
+ if (startAt) {
1141
+ _nextProxy = _copyPluginChain(plugins, _self, startAt);
1468
1142
  }
1469
- if (lastProxy_1) {
1470
- lastProxy_1._setNext(newProxy);
1143
+ else if (isUndefined(startAt)) {
1144
+ _nextProxy = _createProxyChain(plugins, _self);
1471
1145
  }
1472
- lastProxy_1 = newProxy;
1473
1146
  }
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;
1505
- }
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
1147
  }
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);
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
- }
1148
+ _self.core = function () {
1149
+ return core;
1150
+ };
1151
+ _self.diagLog = function () {
1152
+ return safeGetLogger(core, config);
1153
+ };
1154
+ _self.getCfg = function () {
1155
+ return config;
1156
+ };
1157
+ _self.getExtCfg = function (identifier, defaultValue) {
1158
+ if (defaultValue === void 0) { defaultValue = {}; }
1159
+ var theConfig;
1160
+ if (config) {
1161
+ var extConfig = config.extensionConfig;
1162
+ if (extConfig && identifier) {
1163
+ theConfig = extConfig[identifier];
1543
1164
  }
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;
1553
1165
  }
1554
- var pluginState = _getPluginState(plugin);
1555
- if (pluginState[strTeardown] || pluginState[strDisabled]) {
1556
- return false;
1166
+ return (theConfig ? theConfig : defaultValue);
1167
+ };
1168
+ _self.getConfig = function (identifier, field, defaultValue) {
1169
+ if (defaultValue === void 0) { defaultValue = false; }
1170
+ var theValue;
1171
+ var extConfig = _self.getExtCfg(identifier, null);
1172
+ if (extConfig && !isNullOrUndefined(extConfig[field])) {
1173
+ theValue = extConfig[field];
1557
1174
  }
1558
- if (hasSetNext) {
1559
- plugin.setNextPlugin(nextProxy);
1175
+ else if (config && !isNullOrUndefined(config[field])) {
1176
+ theValue = config[field];
1560
1177
  }
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
- }
1567
- }
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
- }
1581
- }
1178
+ return !isNullOrUndefined(theValue) ? theValue : defaultValue;
1179
+ };
1180
+ _self.hasNext = function () {
1181
+ return _nextProxy != null;
1182
+ };
1183
+ _self.getNext = function () {
1184
+ return _nextProxy;
1185
+ };
1186
+ _self.setNext = function (nextPlugin) {
1187
+ _nextProxy = nextPlugin;
1188
+ };
1189
+ _self.processNext = function (env) {
1190
+ var nextPlugin = _nextProxy;
1191
+ if (nextPlugin) {
1192
+ _nextProxy = nextPlugin.getNext();
1193
+ nextPlugin.processTelemetry(env, _self);
1582
1194
  }
1583
- return hasRun;
1584
- }
1585
- if (!_processChain(unloadCtx, _callTeardown, "unload", function () { }, unloadState.isAsync)) {
1586
- unloadCtx.processNext(unloadState);
1587
- }
1195
+ };
1196
+ _self.createNew = function (plugins, startAt) {
1197
+ if (plugins === void 0) { plugins = null; }
1198
+ return new ProcessTelemetryContext(plugins || _nextProxy, config, core, startAt);
1199
+ };
1588
1200
  }
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
- }
1201
+ return ProcessTelemetryContext;
1202
+ }());
1203
+
1204
+ var strExtensionConfig = "extensionConfig";
1205
+
1206
+ var strGetPlugin = "getPlugin";
1207
+ var BaseTelemetryPlugin = /** @class */ (function () {
1208
+ function BaseTelemetryPlugin() {
1209
+ var _self = this;
1210
+ var _isinitialized = false;
1211
+ var _rootCtx = null;
1212
+ var _nextPlugin = null;
1213
+ _self.core = null;
1214
+ _self.diagLog = function (itemCtx) {
1215
+ return _self._getTelCtx(itemCtx).diagLog();
1216
+ };
1217
+ _self.isInitialized = function () {
1218
+ return _isinitialized;
1219
+ };
1220
+ _self.setInitialized = function (isInitialized) {
1221
+ _isinitialized = isInitialized;
1222
+ };
1223
+ _self.setNextPlugin = function (next) {
1224
+ _nextPlugin = next;
1225
+ };
1226
+ _self.processNext = function (env, itemCtx) {
1227
+ if (itemCtx) {
1228
+ itemCtx.processNext(env);
1229
+ }
1230
+ else if (_nextPlugin && isFunction(_nextPlugin.processTelemetry)) {
1231
+ _nextPlugin.processTelemetry(env, null);
1232
+ }
1233
+ };
1234
+ _self._getTelCtx = function (currentCtx) {
1235
+ if (currentCtx === void 0) { currentCtx = null; }
1236
+ var itemCtx = currentCtx;
1237
+ if (!itemCtx) {
1238
+ var rootCtx = _rootCtx || new ProcessTelemetryContext(null, {}, _self.core);
1239
+ if (_nextPlugin && _nextPlugin[strGetPlugin]) {
1240
+ itemCtx = rootCtx.createNew(null, _nextPlugin[strGetPlugin]);
1241
+ }
1242
+ else {
1243
+ itemCtx = rootCtx.createNew(null, _nextPlugin);
1599
1244
  }
1600
1245
  }
1601
- return hasRun;
1602
- }
1603
- if (!_processChain(updateCtx, _callUpdate, "update", function () { }, false)) {
1604
- updateCtx.processNext(updateState);
1605
- }
1246
+ return itemCtx;
1247
+ };
1248
+ _self._baseTelInit = function (config, core, extensions, pluginChain) {
1249
+ if (config) {
1250
+ setValue(config, strExtensionConfig, [], null, isNullOrUndefined);
1251
+ }
1252
+ if (!pluginChain && core) {
1253
+ pluginChain = core.getProcessTelContext().getNext();
1254
+ }
1255
+ var nextPlugin = _nextPlugin;
1256
+ if (_nextPlugin && _nextPlugin[strGetPlugin]) {
1257
+ nextPlugin = _nextPlugin[strGetPlugin]();
1258
+ }
1259
+ _self.core = core;
1260
+ _rootCtx = new ProcessTelemetryContext(pluginChain, config, core, nextPlugin);
1261
+ _isinitialized = true;
1262
+ };
1606
1263
  }
1607
- return objFreeze(proxyChain);
1608
- }
1264
+ BaseTelemetryPlugin.prototype.initialize = function (config, core, extensions, pluginChain) {
1265
+ this._baseTelInit(config, core, extensions, pluginChain);
1266
+ };
1267
+ return BaseTelemetryPlugin;
1268
+ }());
1609
1269
 
1610
1270
  var strToGMTString = "toGMTString";
1611
1271
  var strToUTCString = "toUTCString";
@@ -1615,6 +1275,7 @@
1615
1275
  var strIsCookieUseDisabled = "isCookieUseDisabled";
1616
1276
  var strDisableCookiesUsage = "disableCookiesUsage";
1617
1277
  var strConfigCookieMgr = "_ckMgr";
1278
+ var strEmpty = "";
1618
1279
  var _supportsCookies = null;
1619
1280
  var _allowUaSameSite = null;
1620
1281
  var _parsedCookieValue = null;
@@ -1691,7 +1352,7 @@
1691
1352
  var result = false;
1692
1353
  if (_isMgrEnabled(cookieMgr)) {
1693
1354
  var values = {};
1694
- var theValue = strTrim(value || strEmpty$1);
1355
+ var theValue = strTrim(value || strEmpty);
1695
1356
  var idx = theValue.indexOf(";");
1696
1357
  if (idx !== -1) {
1697
1358
  theValue = strTrim(value.substring(0, idx));
@@ -1706,11 +1367,11 @@
1706
1367
  if (expireMs > 0) {
1707
1368
  var expiry = new Date();
1708
1369
  expiry.setTime(expireMs);
1709
- setValue(values, strExpires, _formatDate(expiry, !_isIE ? strToUTCString : strToGMTString) || _formatDate(expiry, _isIE ? strToGMTString : strToUTCString) || strEmpty$1, isTruthy);
1370
+ setValue(values, strExpires, _formatDate(expiry, !_isIE ? strToUTCString : strToGMTString) || _formatDate(expiry, _isIE ? strToGMTString : strToUTCString) || strEmpty, isTruthy);
1710
1371
  }
1711
1372
  }
1712
1373
  if (!_isIE) {
1713
- setValue(values, "max-age", strEmpty$1 + maxAgeSec, null, isUndefined);
1374
+ setValue(values, "max-age", strEmpty + maxAgeSec, null, isUndefined);
1714
1375
  }
1715
1376
  }
1716
1377
  var location_1 = getLocation();
@@ -1731,7 +1392,7 @@
1731
1392
  return result;
1732
1393
  },
1733
1394
  get: function (name) {
1734
- var value = strEmpty$1;
1395
+ var value = strEmpty;
1735
1396
  if (_isMgrEnabled(cookieMgr)) {
1736
1397
  value = (cookieMgrConfig.getCookie || _getCookieValue)(name);
1737
1398
  }
@@ -1756,7 +1417,7 @@
1756
1417
  values["max-age"] = "0";
1757
1418
  }
1758
1419
  var delCookie = cookieMgrConfig.delCookie || _setCookieValue;
1759
- delCookie(name, _formatCookieValue(strEmpty$1, values));
1420
+ delCookie(name, _formatCookieValue(strEmpty, values));
1760
1421
  result = true;
1761
1422
  }
1762
1423
  return result;
@@ -1773,7 +1434,7 @@
1773
1434
  _supportsCookies = doc[strCookie] !== undefined;
1774
1435
  }
1775
1436
  catch (e) {
1776
- _throwInternal(logger, 2 , 68 , "Cannot access document.cookie - " + getExceptionName(e), { exception: dumpObj(e) });
1437
+ logger && logger.throwInternal(LoggingSeverity.WARNING, _InternalMessageId.CannotAccessCookie, "Cannot access document.cookie - " + getExceptionName(e), { exception: dumpObj(e) });
1777
1438
  }
1778
1439
  }
1779
1440
  return _supportsCookies;
@@ -1783,7 +1444,7 @@
1783
1444
  if (theValue && theValue.length) {
1784
1445
  var parts = strTrim(theValue).split(";");
1785
1446
  arrForEach(parts, function (thePart) {
1786
- thePart = strTrim(thePart || strEmpty$1);
1447
+ thePart = strTrim(thePart || strEmpty);
1787
1448
  if (thePart) {
1788
1449
  var idx = thePart.indexOf("=");
1789
1450
  if (idx === -1) {
@@ -1804,21 +1465,21 @@
1804
1465
  return null;
1805
1466
  }
1806
1467
  function _formatCookieValue(value, values) {
1807
- var cookieValue = value || strEmpty$1;
1468
+ var cookieValue = value || strEmpty;
1808
1469
  objForEachKey(values, function (name, theValue) {
1809
- cookieValue += "; " + name + (!isNullOrUndefined(theValue) ? "=" + theValue : strEmpty$1);
1470
+ cookieValue += "; " + name + (!isNullOrUndefined(theValue) ? "=" + theValue : strEmpty);
1810
1471
  });
1811
1472
  return cookieValue;
1812
1473
  }
1813
1474
  function _getCookieValue(name) {
1814
- var cookieValue = strEmpty$1;
1475
+ var cookieValue = strEmpty;
1815
1476
  if (_doc) {
1816
- var theCookie = _doc[strCookie] || strEmpty$1;
1477
+ var theCookie = _doc[strCookie] || strEmpty;
1817
1478
  if (_parsedCookieValue !== theCookie) {
1818
1479
  _cookieCache = _extractParts(theCookie);
1819
1480
  _parsedCookieValue = theCookie;
1820
1481
  }
1821
- cookieValue = strTrim(_cookieCache[name] || strEmpty$1);
1482
+ cookieValue = strTrim(_cookieCache[name] || strEmpty);
1822
1483
  }
1823
1484
  return cookieValue;
1824
1485
  }
@@ -1849,354 +1510,63 @@
1849
1510
  if (strContains(userAgent, "UCBrowser/12") || strContains(userAgent, "UCBrowser/11")) {
1850
1511
  return true;
1851
1512
  }
1852
- return false;
1853
- }
1854
-
1855
- var strExtensionConfig = "extensionConfig";
1856
-
1857
- function createUnloadHandlerContainer() {
1858
- var handlers = [];
1859
- function _addHandler(handler) {
1860
- if (handler) {
1861
- handlers.push(handler);
1862
- }
1863
- }
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
- };
1879
- }
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
- }
2022
- }
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] = [];
2082
- }
2083
- return registeredEvents;
2084
- }
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
- }
2093
- }
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;
1513
+ return false;
2108
1514
  }
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
- }
2120
- }
1515
+
1516
+ var UInt32Mask = 0x100000000;
1517
+ var MaxUInt32 = 0xffffffff;
1518
+ var _mwcSeeded = false;
1519
+ var _mwcW = 123456789;
1520
+ var _mwcZ = 987654321;
1521
+ function _mwcSeed(seedValue) {
1522
+ if (seedValue < 0) {
1523
+ seedValue >>>= 0;
2121
1524
  }
1525
+ _mwcW = (123456789 + seedValue) & MaxUInt32;
1526
+ _mwcZ = (987654321 - seedValue) & MaxUInt32;
1527
+ _mwcSeeded = true;
2122
1528
  }
2123
- function _unregisterEvents(target, evtName, unRegFn) {
2124
- if (evtName.type) {
2125
- _doUnregister(target, _getRegisteredEvents(target, evtName.type), evtName, unRegFn);
1529
+ function _autoSeedMwc() {
1530
+ try {
1531
+ var now = dateNow() & 0x7fffffff;
1532
+ _mwcSeed(((Math.random() * UInt32Mask) ^ now) + now);
2126
1533
  }
2127
- else {
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
- }
1534
+ catch (e) {
2135
1535
  }
2136
1536
  }
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];
1537
+ function random32(signed) {
1538
+ var value;
1539
+ var c = getCrypto() || getMsCrypto();
1540
+ if (c && c.getRandomValues) {
1541
+ value = c.getRandomValues(new Uint32Array(1))[0] & MaxUInt32;
1542
+ }
1543
+ else if (isIE()) {
1544
+ if (!_mwcSeeded) {
1545
+ _autoSeedMwc();
2145
1546
  }
2146
- newNamespaces = (_getEvtNamespace("xx", newNamespaces).ns).split(".");
1547
+ value = mwcRandom32() & MaxUInt32;
2147
1548
  }
2148
1549
  else {
2149
- newNamespaces = theNamespace;
1550
+ value = Math.floor((UInt32Mask * Math.random()) | 0);
2150
1551
  }
2151
- return newNamespaces;
2152
- }
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
- }
1552
+ if (!signed) {
1553
+ value >>>= 0;
2172
1554
  }
2173
- return result;
1555
+ return value;
2174
1556
  }
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
- }
1557
+ function mwcRandom32(signed) {
1558
+ _mwcZ = (36969 * (_mwcZ & 0xFFFF) + (_mwcZ >> 16)) & MaxUInt32;
1559
+ _mwcW = (18000 * (_mwcW & 0xFFFF) + (_mwcW >> 16)) & MaxUInt32;
1560
+ var value = (((_mwcZ << 16) + (_mwcW & 0xFFFF)) >>> 0) & MaxUInt32 | 0;
1561
+ if (!signed) {
1562
+ value >>>= 0;
2194
1563
  }
1564
+ return value;
2195
1565
  }
2196
1566
 
2197
1567
  function generateW3CId() {
2198
1568
  var hexValues = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f"];
2199
- var oct = strEmpty$1, tmp;
1569
+ var oct = "", tmp;
2200
1570
  for (var a = 0; a < 4; a++) {
2201
1571
  tmp = random32();
2202
1572
  oct +=
@@ -2213,232 +1583,6 @@
2213
1583
  return oct.substr(0, 8) + oct.substr(9, 4) + "4" + oct.substr(13, 3) + clockSequenceHi + oct.substr(16, 3) + oct.substr(19, 12);
2214
1584
  }
2215
1585
 
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
- });
2348
- }
2349
- }
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
- }
2398
- }
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;
2440
- }
2441
-
2442
1586
  function dataSanitizeKeyAndAddUniqueness(logger, key, map) {
2443
1587
  var origLength = key.length;
2444
1588
  var field = dataSanitizeKey(logger, key);
@@ -2459,7 +1603,7 @@
2459
1603
  name = strTrim(name.toString());
2460
1604
  if (name.length > 150 ) {
2461
1605
  nameTrunc = name.substring(0, 150 );
2462
- _throwInternal(logger, 2 , _InternalMessageId.NameTooLong, "name is too long. It has been truncated to " + 150 + " characters.", { name: name }, true);
1606
+ logger && logger.throwInternal(LoggingSeverity.WARNING, _InternalMessageId.NameTooLong, "name is too long. It has been truncated to " + 150 + " characters.", { name: name }, true);
2463
1607
  }
2464
1608
  }
2465
1609
  return nameTrunc || name;
@@ -2472,7 +1616,7 @@
2472
1616
  value = strTrim(value);
2473
1617
  if (value.toString().length > maxLength) {
2474
1618
  valueTrunc = value.toString().substring(0, maxLength);
2475
- _throwInternal(logger, 2 , _InternalMessageId.StringValueTooLong, "string value is too long. It has been truncated to " + maxLength + " characters.", { value: value }, true);
1619
+ logger && logger.throwInternal(LoggingSeverity.WARNING, _InternalMessageId.StringValueTooLong, "string value is too long. It has been truncated to " + maxLength + " characters.", { value: value }, true);
2476
1620
  }
2477
1621
  }
2478
1622
  return valueTrunc || value;
@@ -2485,7 +1629,7 @@
2485
1629
  if (message) {
2486
1630
  if (message.length > 32768 ) {
2487
1631
  messageTrunc = message.substring(0, 32768 );
2488
- _throwInternal(logger, 2 , _InternalMessageId.MessageTruncated, "message is too long, it has been truncated to " + 32768 + " characters.", { message: message }, true);
1632
+ logger && logger.throwInternal(LoggingSeverity.WARNING, _InternalMessageId.MessageTruncated, "message is too long, it has been truncated to " + 32768 + " characters.", { message: message }, true);
2489
1633
  }
2490
1634
  }
2491
1635
  return messageTrunc || message;
@@ -2496,7 +1640,7 @@
2496
1640
  var value = "" + exception;
2497
1641
  if (value.length > 32768 ) {
2498
1642
  exceptionTrunc = value.substring(0, 32768 );
2499
- _throwInternal(logger, 2 , _InternalMessageId.ExceptionTruncated, "exception is too long, it has been truncated to " + 32768 + " characters.", { exception: exception }, true);
1643
+ logger && logger.throwInternal(LoggingSeverity.WARNING, _InternalMessageId.ExceptionTruncated, "exception is too long, it has been truncated to " + 32768 + " characters.", { exception: exception }, true);
2500
1644
  }
2501
1645
  }
2502
1646
  return exceptionTrunc || exception;
@@ -2510,7 +1654,7 @@
2510
1654
  value = getJSON().stringify(value);
2511
1655
  }
2512
1656
  catch (e) {
2513
- _throwInternal(logger, 2 , _InternalMessageId.CannotSerializeObjectNonSerializable, "custom property is not valid", { exception: e }, true);
1657
+ logger && logger.throwInternal(LoggingSeverity.WARNING, _InternalMessageId.CannotSerializeObjectNonSerializable, "custom property is not valid", { exception: e }, true);
2514
1658
  }
2515
1659
  }
2516
1660
  value = dataSanitizeString(logger, value, 8192 );
@@ -2541,7 +1685,7 @@
2541
1685
  input = strTrim(input);
2542
1686
  if (input.length > maxLength) {
2543
1687
  inputTrunc = input.substring(0, maxLength);
2544
- _throwInternal(logger, 2 , _msgId, "input is too long, it has been truncated to " + maxLength + " characters.", { data: input }, true);
1688
+ logger && logger.throwInternal(LoggingSeverity.WARNING, _msgId, "input is too long, it has been truncated to " + maxLength + " characters.", { data: input }, true);
2545
1689
  }
2546
1690
  }
2547
1691
  return inputTrunc || input;
@@ -2566,7 +1710,6 @@
2566
1710
  return event;
2567
1711
  }
2568
1712
 
2569
- var strEmpty = "";
2570
1713
  function stringToBoolOrDefault(str, defaultValue) {
2571
1714
  if (defaultValue === void 0) { defaultValue = false; }
2572
1715
  if (str === undefined || str === null) {
@@ -2579,16 +1722,16 @@
2579
1722
  totalms = 0;
2580
1723
  }
2581
1724
  totalms = Math.round(totalms);
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;
1725
+ var ms = "" + totalms % 1000;
1726
+ var sec = "" + Math.floor(totalms / 1000) % 60;
1727
+ var min = "" + Math.floor(totalms / (1000 * 60)) % 60;
1728
+ var hour = "" + Math.floor(totalms / (1000 * 60 * 60)) % 24;
2586
1729
  var days = Math.floor(totalms / (1000 * 60 * 60 * 24));
2587
1730
  ms = ms.length === 1 ? "00" + ms : ms.length === 2 ? "0" + ms : ms;
2588
1731
  sec = sec.length < 2 ? "0" + sec : sec;
2589
1732
  min = min.length < 2 ? "0" + min : min;
2590
1733
  hour = hour.length < 2 ? "0" + hour : hour;
2591
- return (days > 0 ? days + "." : strEmpty) + hour + ":" + min + ":" + sec + "." + ms;
1734
+ return (days > 0 ? days + "." : "") + hour + ":" + min + ":" + sec + "." + ms;
2592
1735
  }
2593
1736
  function isCrossOriginError(message, url, lineNumber, columnNumber, error) {
2594
1737
  return !error && isString(message) && (message === "Script error." || message === "Script error");
@@ -2597,17 +1740,18 @@
2597
1740
  var strNotSpecified = "not_specified";
2598
1741
  var strIkey = "iKey";
2599
1742
 
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
- });
1743
+ var StorageType;
1744
+ (function (StorageType) {
1745
+ StorageType[StorageType["LocalStorage"] = 0] = "LocalStorage";
1746
+ StorageType[StorageType["SessionStorage"] = 1] = "SessionStorage";
1747
+ })(StorageType || (StorageType = {}));
1748
+ var DistributedTracingModes;
1749
+ (function (DistributedTracingModes) {
1750
+ DistributedTracingModes[DistributedTracingModes["AI"] = 0] = "AI";
1751
+ DistributedTracingModes[DistributedTracingModes["AI_AND_W3C"] = 1] = "AI_AND_W3C";
1752
+ DistributedTracingModes[DistributedTracingModes["W3C"] = 2] = "W3C";
1753
+ })(DistributedTracingModes || (DistributedTracingModes = {}));
2609
1754
 
2610
- var _canUseLocalStorage = undefined;
2611
1755
  var _canUseSessionStorage = undefined;
2612
1756
  function _getVerifiedStorageObject(storageType) {
2613
1757
  try {
@@ -2634,21 +1778,10 @@
2634
1778
  return null;
2635
1779
  }
2636
1780
  function utlDisableStorage() {
2637
- _canUseLocalStorage = false;
2638
1781
  _canUseSessionStorage = false;
2639
1782
  }
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) {
1783
+ function utlCanUseSessionStorage() {
1784
+ if (_canUseSessionStorage === undefined) {
2652
1785
  _canUseSessionStorage = !!_getVerifiedStorageObject(StorageType.SessionStorage);
2653
1786
  }
2654
1787
  return _canUseSessionStorage;
@@ -2661,7 +1794,7 @@
2661
1794
  }
2662
1795
  catch (e) {
2663
1796
  _canUseSessionStorage = false;
2664
- _throwInternal(logger, 2 , _InternalMessageId.BrowserCannotReadSessionStorage, "Browser failed read of session storage. " + getExceptionName(e), { exception: dumpObj(e) });
1797
+ logger.throwInternal(LoggingSeverity.WARNING, _InternalMessageId.BrowserCannotReadSessionStorage, "Browser failed read of session storage. " + getExceptionName(e), { exception: dumpObj(e) });
2665
1798
  }
2666
1799
  }
2667
1800
  return null;
@@ -2675,7 +1808,7 @@
2675
1808
  }
2676
1809
  catch (e) {
2677
1810
  _canUseSessionStorage = false;
2678
- _throwInternal(logger, 2 , _InternalMessageId.BrowserCannotWriteSessionStorage, "Browser failed write to session storage. " + getExceptionName(e), { exception: dumpObj(e) });
1811
+ logger.throwInternal(LoggingSeverity.WARNING, _InternalMessageId.BrowserCannotWriteSessionStorage, "Browser failed write to session storage. " + getExceptionName(e), { exception: dumpObj(e) });
2679
1812
  }
2680
1813
  }
2681
1814
  return false;
@@ -2689,7 +1822,7 @@
2689
1822
  }
2690
1823
  catch (e) {
2691
1824
  _canUseSessionStorage = false;
2692
- _throwInternal(logger, 2 , _InternalMessageId.BrowserFailedRemovalFromSessionStorage, "Browser failed removal of session storage item. " + getExceptionName(e), { exception: dumpObj(e) });
1825
+ logger.throwInternal(LoggingSeverity.WARNING, _InternalMessageId.BrowserFailedRemovalFromSessionStorage, "Browser failed removal of session storage item. " + getExceptionName(e), { exception: dumpObj(e) });
2693
1826
  }
2694
1827
  }
2695
1828
  return false;
@@ -3601,9 +2734,11 @@
3601
2734
  if (core) {
3602
2735
  _logger = core.logger;
3603
2736
  }
3604
- function _flushChannels(isAsync) {
2737
+ function _flushChannels() {
3605
2738
  if (core) {
3606
- core.flush(isAsync);
2739
+ arrForEach(core.getTransmissionControls(), function (queues) {
2740
+ arrForEach(queues, function (q) { return q.flush(true); });
2741
+ });
3607
2742
  }
3608
2743
  }
3609
2744
  function _addQueue(cb) {
@@ -3626,7 +2761,7 @@
3626
2761
  intervalHandle = null;
3627
2762
  }
3628
2763
  if (doFlush) {
3629
- _flushChannels(true);
2764
+ _flushChannels();
3630
2765
  }
3631
2766
  }), 100);
3632
2767
  }
@@ -3644,7 +2779,7 @@
3644
2779
  }
3645
2780
  if (!pageViewPerformanceManager.isPerformanceTimingSupported()) {
3646
2781
  appInsights.sendPageViewInternal(pageView, customProperties);
3647
- _flushChannels(true);
2782
+ _flushChannels();
3648
2783
  _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.");
3649
2784
  return;
3650
2785
  }
@@ -3670,7 +2805,7 @@
3670
2805
  customProperties["duration"] = customDuration;
3671
2806
  }
3672
2807
  appInsights.sendPageViewInternal(pageView, customProperties);
3673
- _flushChannels(true);
2808
+ _flushChannels();
3674
2809
  pageViewSent = true;
3675
2810
  }
3676
2811
  var maxDurationLimit = 60000;
@@ -3716,17 +2851,6 @@
3716
2851
  return processed;
3717
2852
  });
3718
2853
  };
3719
- _self.teardown = function (unloadCtx, unloadState) {
3720
- if (intervalHandle) {
3721
- clearInterval(intervalHandle);
3722
- intervalHandle = null;
3723
- var allItems = itemQueue.slice(0);
3724
- itemQueue = [];
3725
- arrForEach(allItems, function (item) {
3726
- if (item()) ;
3727
- });
3728
- }
3729
- };
3730
2854
  });
3731
2855
  }
3732
2856
  return PageViewManager;
@@ -3921,33 +3045,6 @@
3921
3045
  return PageViewPerformanceManager;
3922
3046
  }());
3923
3047
 
3924
- var Timing = /** @class */ (function () {
3925
- function Timing(logger, name) {
3926
- var _self = this;
3927
- var _events = {};
3928
- _self.start = function (name) {
3929
- if (typeof _events[name] !== "undefined") {
3930
- _throwInternal(logger, LoggingSeverity.WARNING, _InternalMessageId.StartCalledMoreThanOnce, "start was called more than once for this event without calling stop.", { name: name, key: name }, true);
3931
- }
3932
- _events[name] = +new Date;
3933
- };
3934
- _self.stop = function (name, url, properties, measurements) {
3935
- var start = _events[name];
3936
- if (isNaN(start)) {
3937
- _throwInternal(logger, LoggingSeverity.WARNING, _InternalMessageId.StopCalledWithoutStart, "stop was called without a corresponding start.", { name: name, key: name }, true);
3938
- }
3939
- else {
3940
- var end = +new Date;
3941
- var duration = dateTimeUtilsDuration(start, end);
3942
- _self.action(name, url, duration, properties, measurements);
3943
- }
3944
- delete _events[name];
3945
- _events[name] = undefined;
3946
- };
3947
- }
3948
- return Timing;
3949
- }());
3950
-
3951
3048
  var durationProperty = "duration";
3952
3049
  var strEvent = "event";
3953
3050
  function _dispatchEvent(target, evnt) {
@@ -3965,78 +3062,47 @@
3965
3062
  }
3966
3063
  return error || "";
3967
3064
  }
3968
- var MinMilliSeconds = 60000;
3969
- function _configMilliseconds(value, defValue) {
3970
- value = value || defValue;
3971
- if (value < MinMilliSeconds) {
3972
- value = MinMilliSeconds;
3973
- }
3974
- return value;
3975
- }
3976
- function _getDefaultConfig(config) {
3977
- if (!config) {
3978
- config = {};
3979
- }
3980
- config.sessionRenewalMs = _configMilliseconds(config.sessionRenewalMs, 30 * 60 * 1000);
3981
- config.sessionExpirationMs = _configMilliseconds(config.sessionExpirationMs, 24 * 60 * 60 * 1000);
3982
- config.disableExceptionTracking = stringToBoolOrDefault(config.disableExceptionTracking);
3983
- config.autoTrackPageVisitTime = stringToBoolOrDefault(config.autoTrackPageVisitTime);
3984
- config.overridePageViewDuration = stringToBoolOrDefault(config.overridePageViewDuration);
3985
- config.enableUnhandledPromiseRejectionTracking = stringToBoolOrDefault(config.enableUnhandledPromiseRejectionTracking);
3986
- if (isNaN(config.samplingPercentage) || config.samplingPercentage <= 0 || config.samplingPercentage >= 100) {
3987
- config.samplingPercentage = 100;
3988
- }
3989
- config.isStorageUseDisabled = stringToBoolOrDefault(config.isStorageUseDisabled);
3990
- config.isBrowserLinkTrackingEnabled = stringToBoolOrDefault(config.isBrowserLinkTrackingEnabled);
3991
- config.enableAutoRouteTracking = stringToBoolOrDefault(config.enableAutoRouteTracking);
3992
- config.namePrefix = config.namePrefix || "";
3993
- config.enableDebug = stringToBoolOrDefault(config.enableDebug);
3994
- config.disableFlushOnBeforeUnload = stringToBoolOrDefault(config.disableFlushOnBeforeUnload);
3995
- config.disableFlushOnUnload = stringToBoolOrDefault(config.disableFlushOnUnload, config.disableFlushOnBeforeUnload);
3996
- return config;
3997
- }
3998
- function _updateStorageUsage(extConfig) {
3999
- if (!isUndefined(extConfig.isStorageUseDisabled)) {
4000
- if (extConfig.isStorageUseDisabled) {
4001
- utlDisableStorage();
4002
- }
4003
- else {
4004
- utlEnableStorage();
4005
- }
4006
- }
4007
- }
4008
- var AnalyticsPlugin = /** @class */ (function (_super) {
4009
- __extendsFn(AnalyticsPlugin, _super);
4010
- function AnalyticsPlugin() {
3065
+ var ApplicationInsights = /** @class */ (function (_super) {
3066
+ __extendsFn(ApplicationInsights, _super);
3067
+ function ApplicationInsights() {
4011
3068
  var _this = _super.call(this) || this;
4012
3069
  _this.identifier = AnalyticsPluginIdentifier;
4013
3070
  _this.priority = 180;
4014
3071
  _this.autoRoutePVDelay = 500;
4015
3072
  var _eventTracking;
4016
3073
  var _pageTracking;
4017
- var _pageViewManager;
4018
- var _pageViewPerformanceManager;
4019
- var _pageVisitTimeManager;
4020
- var _preInitTelemetryInitializers;
4021
- var _isBrowserLinkTrackingEnabled;
4022
- var _browserLinkInitializerAdded;
4023
- var _enableAutoRouteTracking;
4024
- var _historyListenerAdded;
4025
- var _disableExceptionTracking;
4026
- var _autoExceptionInstrumented;
4027
- var _enableUnhandledPromiseRejectionTracking;
4028
- var _autoUnhandledPromiseInstrumented;
3074
+ var _properties;
4029
3075
  var _prevUri;
4030
3076
  var _currUri;
4031
- var _evtNamespace;
4032
- dynamicProto(AnalyticsPlugin, _this, function (_self, _base) {
4033
- var _addHook = _base._addHook;
4034
- _initDefaults();
3077
+ dynamicProto(ApplicationInsights, _this, function (_self, _base) {
3078
+ var location = getLocation(true);
3079
+ _prevUri = location && location.href || "";
4035
3080
  _self.getCookieMgr = function () {
4036
3081
  return safeGetCookieMgr(_self.core);
4037
3082
  };
4038
3083
  _self.processTelemetry = function (env, itemCtx) {
4039
- _self.processNext(env, itemCtx);
3084
+ doPerf(_self.core, function () { return _self.identifier + ":processTelemetry"; }, function () {
3085
+ var doNotSendItem = false;
3086
+ var telemetryInitializersCount = _self._telemetryInitializers.length;
3087
+ itemCtx = _self._getTelCtx(itemCtx);
3088
+ for (var i = 0; i < telemetryInitializersCount; ++i) {
3089
+ var telemetryInitializer = _self._telemetryInitializers[i];
3090
+ if (telemetryInitializer) {
3091
+ try {
3092
+ if (telemetryInitializer.apply(null, [env]) === false) {
3093
+ doNotSendItem = true;
3094
+ break;
3095
+ }
3096
+ }
3097
+ catch (e) {
3098
+ itemCtx.diagLog().throwInternal(LoggingSeverity.CRITICAL, _InternalMessageId.TelemetryInitializerFailed, "One of telemetry initializers failed, telemetry item will not be sent: " + getExceptionName(e), { exception: dumpObj(e) }, true);
3099
+ }
3100
+ }
3101
+ }
3102
+ if (!doNotSendItem) {
3103
+ _self.processNext(env, itemCtx);
3104
+ }
3105
+ }, function () { return ({ item: env }); }, !(env.sync));
4040
3106
  };
4041
3107
  _self.trackEvent = function (event, customProperties) {
4042
3108
  try {
@@ -4044,7 +3110,7 @@
4044
3110
  _self.core.track(telemetryItem);
4045
3111
  }
4046
3112
  catch (e) {
4047
- _throwInternal(LoggingSeverity.WARNING, _InternalMessageId.TrackTraceFailed, "trackTrace failed, trace will not be collected: " + getExceptionName(e), { exception: dumpObj(e) });
3113
+ _self.diagLog().throwInternal(LoggingSeverity.WARNING, _InternalMessageId.TrackTraceFailed, "trackTrace failed, trace will not be collected: " + getExceptionName(e), { exception: dumpObj(e) });
4048
3114
  }
4049
3115
  };
4050
3116
  _self.startTrackEvent = function (name) {
@@ -4052,7 +3118,7 @@
4052
3118
  _eventTracking.start(name);
4053
3119
  }
4054
3120
  catch (e) {
4055
- _throwInternal(LoggingSeverity.CRITICAL, _InternalMessageId.StartTrackEventFailed, "startTrackEvent failed, event will not be collected: " + getExceptionName(e), { exception: dumpObj(e) });
3121
+ _self.diagLog().throwInternal(LoggingSeverity.CRITICAL, _InternalMessageId.StartTrackEventFailed, "startTrackEvent failed, event will not be collected: " + getExceptionName(e), { exception: dumpObj(e) });
4056
3122
  }
4057
3123
  };
4058
3124
  _self.stopTrackEvent = function (name, properties, measurements) {
@@ -4060,7 +3126,7 @@
4060
3126
  _eventTracking.stop(name, undefined, properties);
4061
3127
  }
4062
3128
  catch (e) {
4063
- _throwInternal(LoggingSeverity.CRITICAL, _InternalMessageId.StopTrackEventFailed, "stopTrackEvent failed, event will not be collected: " + getExceptionName(e), { exception: dumpObj(e) });
3129
+ _self.diagLog().throwInternal(LoggingSeverity.CRITICAL, _InternalMessageId.StopTrackEventFailed, "stopTrackEvent failed, event will not be collected: " + getExceptionName(e), { exception: dumpObj(e) });
4064
3130
  }
4065
3131
  };
4066
3132
  _self.trackTrace = function (trace, customProperties) {
@@ -4069,7 +3135,7 @@
4069
3135
  _self.core.track(telemetryItem);
4070
3136
  }
4071
3137
  catch (e) {
4072
- _throwInternal(LoggingSeverity.WARNING, _InternalMessageId.TrackTraceFailed, "trackTrace failed, trace will not be collected: " + getExceptionName(e), { exception: dumpObj(e) });
3138
+ _self.diagLog().throwInternal(LoggingSeverity.WARNING, _InternalMessageId.TrackTraceFailed, "trackTrace failed, trace will not be collected: " + getExceptionName(e), { exception: dumpObj(e) });
4073
3139
  }
4074
3140
  };
4075
3141
  _self.trackMetric = function (metric, customProperties) {
@@ -4078,19 +3144,19 @@
4078
3144
  _self.core.track(telemetryItem);
4079
3145
  }
4080
3146
  catch (e) {
4081
- _throwInternal(LoggingSeverity.CRITICAL, _InternalMessageId.TrackMetricFailed, "trackMetric failed, metric will not be collected: " + getExceptionName(e), { exception: dumpObj(e) });
3147
+ _self.diagLog().throwInternal(LoggingSeverity.CRITICAL, _InternalMessageId.TrackMetricFailed, "trackMetric failed, metric will not be collected: " + getExceptionName(e), { exception: dumpObj(e) });
4082
3148
  }
4083
3149
  };
4084
3150
  _self.trackPageView = function (pageView, customProperties) {
4085
3151
  try {
4086
3152
  var inPv = pageView || {};
4087
- _pageViewManager.trackPageView(inPv, __assignFn(__assignFn(__assignFn({}, inPv.properties), inPv.measurements), customProperties));
3153
+ _self._pageViewManager.trackPageView(inPv, __assignFn(__assignFn(__assignFn({}, inPv.properties), inPv.measurements), customProperties));
4088
3154
  if (_self.config.autoTrackPageVisitTime) {
4089
- _pageVisitTimeManager.trackPreviousPageVisit(inPv.name, inPv.uri);
3155
+ _self._pageVisitTimeManager.trackPreviousPageVisit(inPv.name, inPv.uri);
4090
3156
  }
4091
3157
  }
4092
3158
  catch (e) {
4093
- _throwInternal(LoggingSeverity.CRITICAL, _InternalMessageId.TrackPVFailed, "trackPageView failed, page view will not be collected: " + getExceptionName(e), { exception: dumpObj(e) });
3159
+ _self.diagLog().throwInternal(LoggingSeverity.CRITICAL, _InternalMessageId.TrackPVFailed, "trackPageView failed, page view will not be collected: " + getExceptionName(e), { exception: dumpObj(e) });
4094
3160
  }
4095
3161
  };
4096
3162
  _self.sendPageViewInternal = function (pageView, properties, systemProperties) {
@@ -4106,13 +3172,12 @@
4106
3172
  _self.core.track(telemetryItem);
4107
3173
  };
4108
3174
  _self.trackPageViewPerformance = function (pageViewPerformance, customProperties) {
4109
- var inPvp = pageViewPerformance || {};
4110
3175
  try {
4111
- _pageViewPerformanceManager.populatePageViewPerformanceEvent(inPvp);
4112
- _self.sendPageViewPerformanceInternal(inPvp, customProperties);
3176
+ _self._pageViewPerformanceManager.populatePageViewPerformanceEvent(pageViewPerformance);
3177
+ _self.sendPageViewPerformanceInternal(pageViewPerformance, customProperties);
4113
3178
  }
4114
3179
  catch (e) {
4115
- _throwInternal(LoggingSeverity.CRITICAL, _InternalMessageId.TrackPVFailed, "trackPageViewPerformance failed, page view will not be collected: " + getExceptionName(e), { exception: dumpObj(e) });
3180
+ _self.diagLog().throwInternal(LoggingSeverity.CRITICAL, _InternalMessageId.TrackPVFailed, "trackPageViewPerformance failed, page view will not be collected: " + getExceptionName(e), { exception: dumpObj(e) });
4116
3181
  }
4117
3182
  };
4118
3183
  _self.startTrackPage = function (name) {
@@ -4124,7 +3189,7 @@
4124
3189
  _pageTracking.start(name);
4125
3190
  }
4126
3191
  catch (e) {
4127
- _throwInternal(LoggingSeverity.CRITICAL, _InternalMessageId.StartTrackFailed, "startTrackPage failed, page view may not be collected: " + getExceptionName(e), { exception: dumpObj(e) });
3192
+ _self.diagLog().throwInternal(LoggingSeverity.CRITICAL, _InternalMessageId.StartTrackFailed, "startTrackPage failed, page view may not be collected: " + getExceptionName(e), { exception: dumpObj(e) });
4128
3193
  }
4129
3194
  };
4130
3195
  _self.stopTrackPage = function (name, url, properties, measurement) {
@@ -4139,11 +3204,11 @@
4139
3204
  }
4140
3205
  _pageTracking.stop(name, url, properties, measurement);
4141
3206
  if (_self.config.autoTrackPageVisitTime) {
4142
- _pageVisitTimeManager.trackPreviousPageVisit(name, url);
3207
+ _self._pageVisitTimeManager.trackPreviousPageVisit(name, url);
4143
3208
  }
4144
3209
  }
4145
3210
  catch (e) {
4146
- _throwInternal(LoggingSeverity.CRITICAL, _InternalMessageId.StopTrackFailed, "stopTrackPage failed, page view will not be collected: " + getExceptionName(e), { exception: dumpObj(e) });
3211
+ _self.diagLog().throwInternal(LoggingSeverity.CRITICAL, _InternalMessageId.StopTrackFailed, "stopTrackPage failed, page view will not be collected: " + getExceptionName(e), { exception: dumpObj(e) });
4147
3212
  }
4148
3213
  };
4149
3214
  _self.sendExceptionInternal = function (exception, customProperties, systemProperties) {
@@ -4153,14 +3218,11 @@
4153
3218
  _self.core.track(telemetryItem);
4154
3219
  };
4155
3220
  _self.trackException = function (exception, customProperties) {
4156
- if (exception && !exception.exception && exception.error) {
4157
- exception.exception = exception.error;
4158
- }
4159
3221
  try {
4160
3222
  _self.sendExceptionInternal(exception, customProperties);
4161
3223
  }
4162
3224
  catch (e) {
4163
- _throwInternal(LoggingSeverity.CRITICAL, _InternalMessageId.TrackExceptionFailed, "trackException failed, exception will not be collected: " + getExceptionName(e), { exception: dumpObj(e) });
3225
+ _self.diagLog().throwInternal(LoggingSeverity.CRITICAL, _InternalMessageId.TrackExceptionFailed, "trackException failed, exception will not be collected: " + getExceptionName(e), { exception: dumpObj(e) });
4164
3226
  }
4165
3227
  };
4166
3228
  _self._onerror = function (exception) {
@@ -4194,98 +3256,158 @@
4194
3256
  }
4195
3257
  catch (e) {
4196
3258
  var errorString = error ? (error.name + ", " + error.message) : "null";
4197
- _throwInternal(LoggingSeverity.CRITICAL, _InternalMessageId.ExceptionWhileLoggingError, "_onError threw exception while logging error, error will not be collected: "
3259
+ _self.diagLog().throwInternal(LoggingSeverity.CRITICAL, _InternalMessageId.ExceptionWhileLoggingError, "_onError threw exception while logging error, error will not be collected: "
4198
3260
  + getExceptionName(e), { exception: dumpObj(e), errorString: errorString });
4199
3261
  }
4200
3262
  };
4201
3263
  _self.addTelemetryInitializer = function (telemetryInitializer) {
4202
- if (_self.core) {
4203
- return _self.core.addTelemetryInitializer(telemetryInitializer);
4204
- }
4205
- if (!_preInitTelemetryInitializers) {
4206
- _preInitTelemetryInitializers = [];
4207
- }
4208
- _preInitTelemetryInitializers.push(telemetryInitializer);
3264
+ _self._telemetryInitializers.push(telemetryInitializer);
4209
3265
  };
4210
3266
  _self.initialize = function (config, core, extensions, pluginChain) {
4211
3267
  if (_self.isInitialized()) {
4212
3268
  return;
4213
3269
  }
4214
3270
  if (isNullOrUndefined(core)) {
4215
- throwError("Error initializing");
3271
+ throw Error("Error initializing");
4216
3272
  }
4217
3273
  _base.initialize(config, core, extensions, pluginChain);
4218
- try {
4219
- _evtNamespace = mergeEvtNamespace(createUniqueNamespace(_self.identifier), core.evtNamespace && core.evtNamespace());
4220
- if (_preInitTelemetryInitializers) {
4221
- arrForEach(_preInitTelemetryInitializers, function (initializer) {
4222
- core.addTelemetryInitializer(initializer);
4223
- });
4224
- _preInitTelemetryInitializers = null;
4225
- }
4226
- var extConfig = _populateDefaults(config);
4227
- _updateStorageUsage(extConfig);
4228
- _pageViewPerformanceManager = new PageViewPerformanceManager(_self.core);
4229
- _pageViewManager = new PageViewManager(_this, extConfig.overridePageViewDuration, _self.core, _pageViewPerformanceManager);
4230
- _pageVisitTimeManager = new PageVisitTimeManager(_self.diagLog(), function (pageName, pageUrl, pageVisitTime) { return trackPageVisitTime(pageName, pageUrl, pageVisitTime); });
4231
- _updateBrowserLinkTracking(extConfig, config);
4232
- _eventTracking = new Timing(_self.diagLog(), "trackEvent");
4233
- _eventTracking.action =
4234
- function (name, url, duration, properties) {
4235
- if (!properties) {
4236
- properties = {};
4237
- }
4238
- properties[durationProperty] = duration.toString();
4239
- _self.trackEvent({ name: name, properties: properties });
4240
- };
4241
- _pageTracking = new Timing(_self.diagLog(), "trackPageView");
4242
- _pageTracking.action = function (name, url, duration, properties, measurements) {
4243
- if (isNullOrUndefined(properties)) {
3274
+ _self.setInitialized(false);
3275
+ var ctx = _self._getTelCtx();
3276
+ var identifier = _self.identifier;
3277
+ _self.config = ctx.getExtCfg(identifier);
3278
+ var defaults = ApplicationInsights.getDefaultConfig(config);
3279
+ if (defaults !== undefined) {
3280
+ objForEachKey(defaults, function (field, value) {
3281
+ _self.config[field] = ctx.getConfig(identifier, field, value);
3282
+ if (_self.config[field] === undefined) {
3283
+ _self.config[field] = value;
3284
+ }
3285
+ });
3286
+ }
3287
+ if (_self.config.isStorageUseDisabled) {
3288
+ utlDisableStorage();
3289
+ }
3290
+ var configGetters = {
3291
+ instrumentationKey: function () { return config.instrumentationKey; },
3292
+ accountId: function () { return _self.config.accountId || config.accountId; },
3293
+ sessionRenewalMs: function () { return _self.config.sessionRenewalMs || config.sessionRenewalMs; },
3294
+ sessionExpirationMs: function () { return _self.config.sessionExpirationMs || config.sessionExpirationMs; },
3295
+ sampleRate: function () { return _self.config.samplingPercentage || config.samplingPercentage; },
3296
+ sdkExtension: function () { return _self.config.sdkExtension || config.sdkExtension; },
3297
+ isBrowserLinkTrackingEnabled: function () { return _self.config.isBrowserLinkTrackingEnabled || config.isBrowserLinkTrackingEnabled; },
3298
+ appId: function () { return _self.config.appId || config.appId; }
3299
+ };
3300
+ _self._pageViewPerformanceManager = new PageViewPerformanceManager(_self.core);
3301
+ _self._pageViewManager = new PageViewManager(_this, _self.config.overridePageViewDuration, _self.core, _self._pageViewPerformanceManager);
3302
+ _self._pageVisitTimeManager = new PageVisitTimeManager(_self.diagLog(), function (pageName, pageUrl, pageVisitTime) { return trackPageVisitTime(pageName, pageUrl, pageVisitTime); });
3303
+ _self._telemetryInitializers = _self._telemetryInitializers || [];
3304
+ _addDefaultTelemetryInitializers(configGetters);
3305
+ _eventTracking = new Timing(_self.diagLog(), "trackEvent");
3306
+ _eventTracking.action =
3307
+ function (name, url, duration, properties) {
3308
+ if (!properties) {
4244
3309
  properties = {};
4245
3310
  }
4246
3311
  properties[durationProperty] = duration.toString();
4247
- var pageViewItem = {
4248
- name: name,
4249
- uri: url,
4250
- properties: properties,
4251
- measurements: measurements
4252
- };
4253
- _self.sendPageViewInternal(pageViewItem, properties);
3312
+ _self.trackEvent({ name: name, properties: properties });
4254
3313
  };
4255
- if (hasWindow()) {
4256
- _updateExceptionTracking(extConfig);
4257
- _updateLocationChange(extConfig);
3314
+ _pageTracking = new Timing(_self.diagLog(), "trackPageView");
3315
+ _pageTracking.action = function (name, url, duration, properties, measurements) {
3316
+ if (isNullOrUndefined(properties)) {
3317
+ properties = {};
4258
3318
  }
4259
- }
4260
- catch (e) {
4261
- _self.setInitialized(false);
4262
- throw e;
4263
- }
4264
- };
4265
- _self._doTeardown = function (unloadCtx, unloadState) {
4266
- _pageViewManager && _pageViewManager.teardown(unloadCtx, unloadState);
4267
- eventOff(window, null, null, _evtNamespace);
4268
- _initDefaults();
4269
- };
4270
- function _populateDefaults(config) {
4271
- var ctx = createProcessTelemetryContext(null, config, _self.core);
4272
- var identifier = _self.identifier;
4273
- var defaults = _getDefaultConfig(config);
4274
- var extConfig = _self.config = ctx.getExtCfg(identifier);
4275
- if (defaults !== undefined) {
4276
- objForEachKey(defaults, function (field, value) {
4277
- extConfig[field] = ctx.getConfig(identifier, field, value);
4278
- if (extConfig[field] === undefined) {
4279
- extConfig = value;
3319
+ properties[durationProperty] = duration.toString();
3320
+ var pageViewItem = {
3321
+ name: name,
3322
+ uri: url,
3323
+ properties: properties,
3324
+ measurements: measurements
3325
+ };
3326
+ _self.sendPageViewInternal(pageViewItem, properties);
3327
+ };
3328
+ var _window = getWindow();
3329
+ var _history = getHistory();
3330
+ var _location = getLocation(true);
3331
+ var instance = _this;
3332
+ if (_self.config.disableExceptionTracking === false &&
3333
+ !_self.config.autoExceptionInstrumented && _window) {
3334
+ var onerror_1 = "onerror";
3335
+ var originalOnError_1 = _window[onerror_1];
3336
+ _window.onerror = function (message, url, lineNumber, columnNumber, error) {
3337
+ var evt = _window[strEvent];
3338
+ var handled = originalOnError_1 && originalOnError_1(message, url, lineNumber, columnNumber, error);
3339
+ if (handled !== true) {
3340
+ instance._onerror(Exception.CreateAutoException(message, url, lineNumber, columnNumber, error, evt));
3341
+ }
3342
+ return handled;
3343
+ };
3344
+ _self.config.autoExceptionInstrumented = true;
3345
+ }
3346
+ if (_self.config.disableExceptionTracking === false &&
3347
+ _self.config.enableUnhandledPromiseRejectionTracking === true &&
3348
+ !_self.config.autoUnhandledPromiseInstrumented && _window) {
3349
+ var onunhandledrejection_1 = "onunhandledrejection";
3350
+ var originalOnUnhandledRejection_1 = _window[onunhandledrejection_1];
3351
+ _window[onunhandledrejection_1] = function (error) {
3352
+ var evt = _window[strEvent];
3353
+ var handled = originalOnUnhandledRejection_1 && originalOnUnhandledRejection_1.call(_window, error);
3354
+ if (handled !== true) {
3355
+ instance._onerror(Exception.CreateAutoException(_getReason(error), _location ? _location.href : "", 0, 0, error, evt));
3356
+ }
3357
+ return handled;
3358
+ };
3359
+ _self.config.autoUnhandledPromiseInstrumented = true;
3360
+ }
3361
+ if (_self.config.enableAutoRouteTracking === true
3362
+ && _history && isFunction(_history.pushState) && isFunction(_history.replaceState)
3363
+ && _window
3364
+ && typeof Event !== "undefined") {
3365
+ var _self_1 = _this;
3366
+ arrForEach(extensions, function (extension) {
3367
+ if (extension.identifier === PropertiesPluginIdentifier) {
3368
+ _properties = extension;
4280
3369
  }
4281
3370
  });
3371
+ _history.pushState = (function (f) { return function pushState() {
3372
+ var ret = f.apply(this, arguments);
3373
+ _dispatchEvent(_window, createDomEvent(_self_1.config.namePrefix + "pushState"));
3374
+ _dispatchEvent(_window, createDomEvent(_self_1.config.namePrefix + "locationchange"));
3375
+ return ret;
3376
+ }; })(_history.pushState);
3377
+ _history.replaceState = (function (f) { return function replaceState() {
3378
+ var ret = f.apply(this, arguments);
3379
+ _dispatchEvent(_window, createDomEvent(_self_1.config.namePrefix + "replaceState"));
3380
+ _dispatchEvent(_window, createDomEvent(_self_1.config.namePrefix + "locationchange"));
3381
+ return ret;
3382
+ }; })(_history.replaceState);
3383
+ if (_window.addEventListener) {
3384
+ _window.addEventListener(_self_1.config.namePrefix + "popstate", function () {
3385
+ _dispatchEvent(_window, createDomEvent(_self_1.config.namePrefix + "locationchange"));
3386
+ });
3387
+ _window.addEventListener(_self_1.config.namePrefix + "locationchange", function () {
3388
+ if (_properties && _properties.context && _properties.context.telemetryTrace) {
3389
+ _properties.context.telemetryTrace.traceID = generateW3CId();
3390
+ var traceLocationName = "_unknown_";
3391
+ if (_location && _location.pathname) {
3392
+ traceLocationName = _location.pathname + (_location.hash || "");
3393
+ }
3394
+ _properties.context.telemetryTrace.name = dataSanitizeString(_self_1.diagLog(), traceLocationName);
3395
+ }
3396
+ if (_currUri) {
3397
+ _prevUri = _currUri;
3398
+ _currUri = _location && _location.href || "";
3399
+ }
3400
+ else {
3401
+ _currUri = _location && _location.href || "";
3402
+ }
3403
+ setTimeout((function (uri) {
3404
+ _self_1.trackPageView({ refUri: uri, properties: { duration: 0 } });
3405
+ }).bind(_this, _prevUri), _self_1.autoRoutePVDelay);
3406
+ });
3407
+ }
4282
3408
  }
4283
- return extConfig;
4284
- }
4285
- function _updateBrowserLinkTracking(extConfig, config) {
4286
- _isBrowserLinkTrackingEnabled = extConfig.isBrowserLinkTrackingEnabled || config.isBrowserLinkTrackingEnabled;
4287
- _addDefaultTelemetryInitializers();
4288
- }
3409
+ _self.setInitialized(true);
3410
+ };
4289
3411
  function trackPageVisitTime(pageName, pageUrl, pageVisitTime) {
4290
3412
  var properties = { PageName: pageName, PageUrl: pageUrl };
4291
3413
  _self.trackMetric({
@@ -4296,11 +3418,11 @@
4296
3418
  sampleCount: 1
4297
3419
  }, properties);
4298
3420
  }
4299
- function _addDefaultTelemetryInitializers() {
4300
- if (!_browserLinkInitializerAdded && _isBrowserLinkTrackingEnabled) {
3421
+ function _addDefaultTelemetryInitializers(configGetters) {
3422
+ if (!configGetters.isBrowserLinkTrackingEnabled()) {
4301
3423
  var browserLinkPaths_1 = ["/browserLinkSignalR/", "/__browserLink/"];
4302
3424
  var dropBrowserLinkRequests = function (envelope) {
4303
- if (_isBrowserLinkTrackingEnabled && envelope.baseType === RemoteDependencyData.dataType) {
3425
+ if (envelope.baseType === RemoteDependencyData.dataType) {
4304
3426
  var remoteData = envelope.baseData;
4305
3427
  if (remoteData) {
4306
3428
  for (var i = 0; i < browserLinkPaths_1.length; i++) {
@@ -4312,150 +3434,72 @@
4312
3434
  }
4313
3435
  return true;
4314
3436
  };
4315
- _self.addTelemetryInitializer(dropBrowserLinkRequests);
4316
- _browserLinkInitializerAdded = true;
3437
+ _addTelemetryInitializer(dropBrowserLinkRequests);
4317
3438
  }
4318
3439
  }
3440
+ function _addTelemetryInitializer(telemetryInitializer) {
3441
+ _self._telemetryInitializers.push(telemetryInitializer);
3442
+ }
4319
3443
  function _sendCORSException(exception, properties) {
4320
3444
  var telemetryItem = TelemetryItemCreator.create(exception, Exception.dataType, Exception.envelopeType, _self.diagLog(), properties);
4321
3445
  _self.core.track(telemetryItem);
4322
3446
  }
4323
- function _updateExceptionTracking(extConfig) {
4324
- var _window = getWindow();
4325
- var locn = getLocation(true);
4326
- _disableExceptionTracking = extConfig.disableExceptionTracking;
4327
- if (!_disableExceptionTracking && !_autoExceptionInstrumented && !extConfig.autoExceptionInstrumented) {
4328
- _addHook(InstrumentFunc(_window, "onerror", {
4329
- ns: _evtNamespace,
4330
- rsp: function (callDetails, message, url, lineNumber, columnNumber, error) {
4331
- if (!_disableExceptionTracking && callDetails.rslt !== true) {
4332
- _self._onerror(Exception.CreateAutoException(message, url, lineNumber, columnNumber, error, callDetails.evt));
4333
- }
4334
- }
4335
- }));
4336
- _autoExceptionInstrumented = true;
4337
- }
4338
- _addUnhandledPromiseRejectionTracking(extConfig, _window, locn);
4339
- }
4340
- function _updateLocationChange(extConfig) {
4341
- var win = getWindow();
4342
- var locn = getLocation(true);
4343
- _enableAutoRouteTracking = extConfig.enableAutoRouteTracking === true;
4344
- if (win && _enableAutoRouteTracking && hasHistory()) {
4345
- var _history = getHistory();
4346
- if (isFunction(_history.pushState) && isFunction(_history.replaceState) && typeof Event !== strShimUndefined) {
4347
- _addHistoryListener(extConfig, win, _history, locn);
4348
- }
4349
- }
4350
- }
4351
- function _addHistoryListener(extConfig, win, history, locn) {
4352
- function _popstateHandler() {
4353
- if (_enableAutoRouteTracking) {
4354
- _dispatchEvent(win, createDomEvent(extConfig.namePrefix + "locationchange"));
4355
- }
4356
- }
4357
- function _locationChangeHandler() {
4358
- if (_currUri) {
4359
- _prevUri = _currUri;
4360
- _currUri = locn && locn.href || "";
4361
- }
4362
- else {
4363
- _currUri = locn && locn.href || "";
4364
- }
4365
- if (_enableAutoRouteTracking) {
4366
- var properties = _self.core.getPlugin(PropertiesPluginIdentifier);
4367
- if (properties) {
4368
- var context = properties.plugin.context;
4369
- if (context && context.telemetryTrace) {
4370
- context.telemetryTrace.traceID = generateW3CId();
4371
- var traceLocationName = "_unknown_";
4372
- if (locn && locn.pathname) {
4373
- traceLocationName = locn.pathname + (locn.hash || "");
4374
- }
4375
- context.telemetryTrace.name = dataSanitizeString(_self.diagLog(), traceLocationName);
4376
- }
4377
- }
4378
- setTimeout((function (uri) {
4379
- _self.trackPageView({ refUri: uri, properties: { duration: 0 } });
4380
- }).bind(this, _prevUri), _self.autoRoutePVDelay);
4381
- }
4382
- }
4383
- if (!_historyListenerAdded) {
4384
- _addHook(InstrumentFunc(history, "pushState", {
4385
- ns: _evtNamespace,
4386
- rsp: function () {
4387
- if (_enableAutoRouteTracking) {
4388
- _dispatchEvent(win, createDomEvent(extConfig.namePrefix + "pushState"));
4389
- _dispatchEvent(win, createDomEvent(extConfig.namePrefix + "locationchange"));
4390
- }
4391
- }
4392
- }));
4393
- _addHook(InstrumentFunc(history, "replaceState", {
4394
- ns: _evtNamespace,
4395
- rsp: function () {
4396
- if (_enableAutoRouteTracking) {
4397
- _dispatchEvent(win, createDomEvent(extConfig.namePrefix + "replaceState"));
4398
- _dispatchEvent(win, createDomEvent(extConfig.namePrefix + "locationchange"));
4399
- }
4400
- }
4401
- }));
4402
- eventOn(win, extConfig.namePrefix + "popstate", _popstateHandler, _evtNamespace);
4403
- eventOn(win, extConfig.namePrefix + "locationchange", _locationChangeHandler, _evtNamespace);
4404
- _historyListenerAdded = true;
4405
- }
4406
- }
4407
- function _addUnhandledPromiseRejectionTracking(extConfig, _window, _location) {
4408
- _enableUnhandledPromiseRejectionTracking = extConfig.enableUnhandledPromiseRejectionTracking === true;
4409
- if (_enableUnhandledPromiseRejectionTracking && !_autoUnhandledPromiseInstrumented) {
4410
- _addHook(InstrumentFunc(_window, "onunhandledrejection", {
4411
- ns: _evtNamespace,
4412
- rsp: function (callDetails, error) {
4413
- if (_enableUnhandledPromiseRejectionTracking && callDetails.rslt !== true) {
4414
- _self._onerror(Exception.CreateAutoException(_getReason(error), _location ? _location.href : "", 0, 0, error, callDetails.evt));
4415
- }
4416
- }
4417
- }));
4418
- _autoUnhandledPromiseInstrumented = true;
4419
- extConfig.autoUnhandledPromiseInstrumented = _autoUnhandledPromiseInstrumented;
4420
- }
4421
- }
4422
- function _throwInternal(severity, msgId, msg, properties, isUserAct) {
4423
- _self.diagLog().throwInternal(severity, msgId, msg, properties, isUserAct);
4424
- }
4425
- function _initDefaults() {
4426
- _eventTracking = null;
4427
- _pageTracking = null;
4428
- _pageViewManager = null;
4429
- _pageViewPerformanceManager = null;
4430
- _pageVisitTimeManager = null;
4431
- _preInitTelemetryInitializers = null;
4432
- _isBrowserLinkTrackingEnabled = false;
4433
- _browserLinkInitializerAdded = false;
4434
- _enableAutoRouteTracking = false;
4435
- _historyListenerAdded = false;
4436
- _disableExceptionTracking = false;
4437
- _autoExceptionInstrumented = false;
4438
- _enableUnhandledPromiseRejectionTracking = false;
4439
- _autoUnhandledPromiseInstrumented = false;
4440
- var location = getLocation(true);
4441
- _prevUri = location && location.href || "";
4442
- _currUri = null;
4443
- _evtNamespace = null;
4444
- }
4445
- objDefineAccessors(_self, "_pageViewManager", function () { return _pageViewManager; });
4446
- objDefineAccessors(_self, "_pageViewPerformanceManager", function () { return _pageViewPerformanceManager; });
4447
- objDefineAccessors(_self, "_pageVisitTimeManager", function () { return _pageVisitTimeManager; });
4448
- objDefineAccessors(_self, "_evtNamespace", function () { return "." + _evtNamespace; });
4449
3447
  });
4450
3448
  return _this;
4451
3449
  }
4452
- AnalyticsPlugin.Version = "2.7.5-nightly.2203-03";
4453
- AnalyticsPlugin.getDefaultConfig = _getDefaultConfig;
4454
- return AnalyticsPlugin;
3450
+ ApplicationInsights.getDefaultConfig = function (config) {
3451
+ if (!config) {
3452
+ config = {};
3453
+ }
3454
+ config.sessionRenewalMs = 30 * 60 * 1000;
3455
+ config.sessionExpirationMs = 24 * 60 * 60 * 1000;
3456
+ config.disableExceptionTracking = stringToBoolOrDefault(config.disableExceptionTracking);
3457
+ config.autoTrackPageVisitTime = stringToBoolOrDefault(config.autoTrackPageVisitTime);
3458
+ config.overridePageViewDuration = stringToBoolOrDefault(config.overridePageViewDuration);
3459
+ config.enableUnhandledPromiseRejectionTracking = stringToBoolOrDefault(config.enableUnhandledPromiseRejectionTracking);
3460
+ if (isNaN(config.samplingPercentage) || config.samplingPercentage <= 0 || config.samplingPercentage >= 100) {
3461
+ config.samplingPercentage = 100;
3462
+ }
3463
+ config.isStorageUseDisabled = stringToBoolOrDefault(config.isStorageUseDisabled);
3464
+ config.isBrowserLinkTrackingEnabled = stringToBoolOrDefault(config.isBrowserLinkTrackingEnabled);
3465
+ config.enableAutoRouteTracking = stringToBoolOrDefault(config.enableAutoRouteTracking);
3466
+ config.namePrefix = config.namePrefix || "";
3467
+ config.enableDebug = stringToBoolOrDefault(config.enableDebug);
3468
+ config.disableFlushOnBeforeUnload = stringToBoolOrDefault(config.disableFlushOnBeforeUnload);
3469
+ config.disableFlushOnUnload = stringToBoolOrDefault(config.disableFlushOnUnload, config.disableFlushOnBeforeUnload);
3470
+ return config;
3471
+ };
3472
+ ApplicationInsights.Version = "2.7.5";
3473
+ return ApplicationInsights;
4455
3474
  }(BaseTelemetryPlugin));
3475
+ var Timing = /** @class */ (function () {
3476
+ function Timing(logger, name) {
3477
+ var _self = this;
3478
+ var _events = {};
3479
+ _self.start = function (name) {
3480
+ if (typeof _events[name] !== "undefined") {
3481
+ logger.throwInternal(LoggingSeverity.WARNING, _InternalMessageId.StartCalledMoreThanOnce, "start was called more than once for this event without calling stop.", { name: name, key: name }, true);
3482
+ }
3483
+ _events[name] = +new Date;
3484
+ };
3485
+ _self.stop = function (name, url, properties, measurements) {
3486
+ var start = _events[name];
3487
+ if (isNaN(start)) {
3488
+ logger.throwInternal(LoggingSeverity.WARNING, _InternalMessageId.StopCalledWithoutStart, "stop was called without a corresponding start.", { name: name, key: name }, true);
3489
+ }
3490
+ else {
3491
+ var end = +new Date;
3492
+ var duration = dateTimeUtilsDuration(start, end);
3493
+ _self.action(name, url, duration, properties, measurements);
3494
+ }
3495
+ delete _events[name];
3496
+ _events[name] = undefined;
3497
+ };
3498
+ }
3499
+ return Timing;
3500
+ }());
4456
3501
 
4457
- exports.AnalyticsPlugin = AnalyticsPlugin;
4458
- exports.ApplicationInsights = AnalyticsPlugin;
3502
+ exports.ApplicationInsights = ApplicationInsights;
4459
3503
 
4460
3504
  (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 });
4461
3505