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

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 +676 -1630
  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 +676 -1630
  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.2204-03
2
+ * Application Insights JavaScript SDK - Web Analytics, 2.7.6
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.6
103
99
  * Copyright (c) Microsoft and contributors. All rights reserved.
104
100
  */
105
101
  var Constructor = 'constructor';
@@ -113,11 +109,14 @@
113
109
  var DynAllowInstChkTag = DynInstChkTag;
114
110
  var DynProtoDefaultOptions = '_dfOpts';
115
111
  var UnknownValue = '_unknown_';
116
- var str__Proto$1 = "__proto__";
112
+ var str__Proto = "__proto__";
113
+ var DynProtoBaseProto = "_dyn" + str__Proto;
114
+ var DynProtoCurrent = "_dynInstProto";
117
115
  var strUseBaseInst = 'useBaseInst';
118
116
  var strSetInstFuncs = 'setInstFuncs';
119
117
  var Obj = Object;
120
- var _objGetPrototypeOf$1 = Obj["getPrototypeOf"];
118
+ var _objGetPrototypeOf = Obj["getPrototypeOf"];
119
+ var _objGetOwnProps = Obj["getOwnPropertyNames"];
121
120
  var _dynamicNames = 0;
122
121
  function _hasOwnProperty(obj, prop) {
123
122
  return obj && Obj[Prototype].hasOwnProperty.call(obj, prop);
@@ -128,23 +127,26 @@
128
127
  function _isObjectArrayOrFunctionPrototype(target) {
129
128
  return _isObjectOrArrayPrototype(target) || target === Function[Prototype];
130
129
  }
131
- function _getObjProto$1(target) {
130
+ function _getObjProto(target) {
131
+ var newProto;
132
132
  if (target) {
133
- if (_objGetPrototypeOf$1) {
134
- return _objGetPrototypeOf$1(target);
133
+ if (_objGetPrototypeOf) {
134
+ return _objGetPrototypeOf(target);
135
135
  }
136
- var newProto = target[str__Proto$1] || target[Prototype] || (target[Constructor] ? target[Constructor][Prototype] : null);
137
- if (newProto) {
138
- return newProto;
136
+ var curProto = target[str__Proto] || target[Prototype] || (target[Constructor] ? target[Constructor][Prototype] : null);
137
+ newProto = target[DynProtoBaseProto] || curProto;
138
+ if (!_hasOwnProperty(target, DynProtoBaseProto)) {
139
+ delete target[DynProtoCurrent];
140
+ newProto = target[DynProtoBaseProto] = target[DynProtoCurrent] || target[DynProtoBaseProto];
141
+ target[DynProtoCurrent] = curProto;
139
142
  }
140
143
  }
141
- return null;
144
+ return newProto;
142
145
  }
143
146
  function _forEachProp(target, func) {
144
147
  var props = [];
145
- var getOwnProps = Obj["getOwnPropertyNames"];
146
- if (getOwnProps) {
147
- props = getOwnProps(target);
148
+ if (_objGetOwnProps) {
149
+ props = _objGetOwnProps(target);
148
150
  }
149
151
  else {
150
152
  for (var name_1 in target) {
@@ -199,16 +201,16 @@
199
201
  _forEachProp(instFuncs, function (name) {
200
202
  baseFuncs[name] = _instFuncProxy(thisTarget, instFuncs, name);
201
203
  });
202
- var baseProto = _getObjProto$1(classProto);
204
+ var baseProto = _getObjProto(classProto);
203
205
  var visited = [];
204
206
  while (baseProto && !_isObjectArrayOrFunctionPrototype(baseProto) && !_hasVisited(visited, baseProto)) {
205
207
  _forEachProp(baseProto, function (name) {
206
- if (!baseFuncs[name] && _isDynamicCandidate(baseProto, name, !_objGetPrototypeOf$1)) {
208
+ if (!baseFuncs[name] && _isDynamicCandidate(baseProto, name, !_objGetPrototypeOf)) {
207
209
  baseFuncs[name] = _instFuncProxy(thisTarget, baseProto, name);
208
210
  }
209
211
  });
210
212
  visited.push(baseProto);
211
- baseProto = _getObjProto$1(baseProto);
213
+ baseProto = _getObjProto(baseProto);
212
214
  }
213
215
  return baseFuncs;
214
216
  }
@@ -222,7 +224,7 @@
222
224
  }
223
225
  if (!instFunc[DynInstChkTag] && instFuncTable[DynAllowInstChkTag] !== false) {
224
226
  var canAddInst = !_hasOwnProperty(target, funcName);
225
- var objProto = _getObjProto$1(target);
227
+ var objProto = _getObjProto(target);
226
228
  var visited = [];
227
229
  while (canAddInst && objProto && !_isObjectArrayOrFunctionPrototype(objProto) && !_hasVisited(visited, objProto)) {
228
230
  var protoFunc = objProto[funcName];
@@ -231,7 +233,7 @@
231
233
  break;
232
234
  }
233
235
  visited.push(objProto);
234
- objProto = _getObjProto$1(objProto);
236
+ objProto = _getObjProto(objProto);
235
237
  }
236
238
  try {
237
239
  if (canAddInst) {
@@ -249,7 +251,7 @@
249
251
  function _getProtoFunc(funcName, proto, currentDynProtoProxy) {
250
252
  var protoFunc = proto[funcName];
251
253
  if (protoFunc === currentDynProtoProxy) {
252
- protoFunc = _getObjProto$1(proto)[funcName];
254
+ protoFunc = _getObjProto(proto)[funcName];
253
255
  }
254
256
  if (typeof protoFunc !== strFunction) {
255
257
  _throwTypeError("[" + funcName + "] is not a " + strFunction);
@@ -283,18 +285,19 @@
283
285
  }
284
286
  }
285
287
  function _checkPrototype(classProto, thisTarget) {
286
- if (_objGetPrototypeOf$1) {
288
+ if (_objGetPrototypeOf) {
287
289
  var visited = [];
288
- var thisProto = _getObjProto$1(thisTarget);
290
+ var thisProto = _getObjProto(thisTarget);
289
291
  while (thisProto && !_isObjectArrayOrFunctionPrototype(thisProto) && !_hasVisited(visited, thisProto)) {
290
292
  if (thisProto === classProto) {
291
293
  return true;
292
294
  }
293
295
  visited.push(thisProto);
294
- thisProto = _getObjProto$1(thisProto);
296
+ thisProto = _getObjProto(thisProto);
295
297
  }
298
+ return false;
296
299
  }
297
- return false;
300
+ return true;
298
301
  }
299
302
  function _getObjName(target, unknownValue) {
300
303
  if (_hasOwnProperty(target, Prototype)) {
@@ -327,7 +330,7 @@
327
330
  var instFuncs = _getInstanceFuncs(target);
328
331
  var baseFuncs = _getBaseFuncs(classProto, target, instFuncs, useBaseInst);
329
332
  delegateFunc(target, baseFuncs);
330
- var setInstanceFunc = !!_objGetPrototypeOf$1 && !!perfOptions[strSetInstFuncs];
333
+ var setInstanceFunc = !!_objGetPrototypeOf && !!perfOptions[strSetInstFuncs];
331
334
  if (setInstanceFunc && options) {
332
335
  setInstanceFunc = !!options[strSetInstFuncs];
333
336
  }
@@ -339,25 +342,102 @@
339
342
  };
340
343
  dynamicProto[DynProtoDefaultOptions] = perfDefaults;
341
344
 
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";
345
+ var LoggingSeverity;
346
+ (function (LoggingSeverity) {
347
+ LoggingSeverity[LoggingSeverity["CRITICAL"] = 1] = "CRITICAL";
348
+ LoggingSeverity[LoggingSeverity["WARNING"] = 2] = "WARNING";
349
+ })(LoggingSeverity || (LoggingSeverity = {}));
350
+ var _InternalMessageId = {
351
+ BrowserDoesNotSupportLocalStorage: 0,
352
+ BrowserCannotReadLocalStorage: 1,
353
+ BrowserCannotReadSessionStorage: 2,
354
+ BrowserCannotWriteLocalStorage: 3,
355
+ BrowserCannotWriteSessionStorage: 4,
356
+ BrowserFailedRemovalFromLocalStorage: 5,
357
+ BrowserFailedRemovalFromSessionStorage: 6,
358
+ CannotSendEmptyTelemetry: 7,
359
+ ClientPerformanceMathError: 8,
360
+ ErrorParsingAISessionCookie: 9,
361
+ ErrorPVCalc: 10,
362
+ ExceptionWhileLoggingError: 11,
363
+ FailedAddingTelemetryToBuffer: 12,
364
+ FailedMonitorAjaxAbort: 13,
365
+ FailedMonitorAjaxDur: 14,
366
+ FailedMonitorAjaxOpen: 15,
367
+ FailedMonitorAjaxRSC: 16,
368
+ FailedMonitorAjaxSend: 17,
369
+ FailedMonitorAjaxGetCorrelationHeader: 18,
370
+ FailedToAddHandlerForOnBeforeUnload: 19,
371
+ FailedToSendQueuedTelemetry: 20,
372
+ FailedToReportDataLoss: 21,
373
+ FlushFailed: 22,
374
+ MessageLimitPerPVExceeded: 23,
375
+ MissingRequiredFieldSpecification: 24,
376
+ NavigationTimingNotSupported: 25,
377
+ OnError: 26,
378
+ SessionRenewalDateIsZero: 27,
379
+ SenderNotInitialized: 28,
380
+ StartTrackEventFailed: 29,
381
+ StopTrackEventFailed: 30,
382
+ StartTrackFailed: 31,
383
+ StopTrackFailed: 32,
384
+ TelemetrySampledAndNotSent: 33,
385
+ TrackEventFailed: 34,
386
+ TrackExceptionFailed: 35,
387
+ TrackMetricFailed: 36,
388
+ TrackPVFailed: 37,
389
+ TrackPVFailedCalc: 38,
390
+ TrackTraceFailed: 39,
391
+ TransmissionFailed: 40,
392
+ FailedToSetStorageBuffer: 41,
393
+ FailedToRestoreStorageBuffer: 42,
394
+ InvalidBackendResponse: 43,
395
+ FailedToFixDepricatedValues: 44,
396
+ InvalidDurationValue: 45,
397
+ TelemetryEnvelopeInvalid: 46,
398
+ CreateEnvelopeError: 47,
399
+ CannotSerializeObject: 48,
400
+ CannotSerializeObjectNonSerializable: 49,
401
+ CircularReferenceDetected: 50,
402
+ ClearAuthContextFailed: 51,
403
+ ExceptionTruncated: 52,
404
+ IllegalCharsInName: 53,
405
+ ItemNotInArray: 54,
406
+ MaxAjaxPerPVExceeded: 55,
407
+ MessageTruncated: 56,
408
+ NameTooLong: 57,
409
+ SampleRateOutOfRange: 58,
410
+ SetAuthContextFailed: 59,
411
+ SetAuthContextFailedAccountName: 60,
412
+ StringValueTooLong: 61,
413
+ StartCalledMoreThanOnce: 62,
414
+ StopCalledWithoutStart: 63,
415
+ TelemetryInitializerFailed: 64,
416
+ TrackArgumentsNotSpecified: 65,
417
+ UrlTooLong: 66,
418
+ SessionStorageBufferFull: 67,
419
+ CannotAccessCookie: 68,
420
+ IdTooLong: 69,
421
+ InvalidEvent: 70,
422
+ FailedMonitorAjaxSetRequestHeader: 71,
423
+ SendBrowserInfoOnUserInit: 72,
424
+ PluginException: 73,
425
+ NotificationException: 74,
426
+ SnippetScriptLoadFailure: 99,
427
+ InvalidInstrumentationKey: 100,
428
+ CannotParseAiBlobValue: 101,
429
+ InvalidContentBlob: 102,
430
+ TrackPageActionEventFailed: 103,
431
+ FailedAddingCustomDefinedRequestContext: 104,
432
+ InMemoryStorageBufferFull: 105
433
+ };
350
434
 
351
435
  var strToISOString = "toISOString";
352
436
  var cStrEndsWith = "endsWith";
353
437
  var strMap = "map";
354
438
  var cStrTrim = "trim";
355
439
  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;
440
+ var _objDefineProperty = ObjDefineProperty;
361
441
  var StringProto = String[strShimPrototype];
362
442
  var _strTrim = StringProto[cStrTrim];
363
443
  var _strEndsWith = StringProto[cStrEndsWith];
@@ -366,23 +446,7 @@
366
446
  var _isArray = Array.isArray;
367
447
  var _objToString = ObjProto[strToString];
368
448
  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
- }
449
+ _fnToString.call(ObjClass);
386
450
  function isUndefined(value) {
387
451
  return value === undefined || typeof value === strShimUndefined;
388
452
  }
@@ -392,28 +456,12 @@
392
456
  function isNotNullOrUndefined(value) {
393
457
  return !isNullOrUndefined(value);
394
458
  }
395
- function hasOwnProperty(obj, prop) {
396
- return !!(obj && ObjHasOwnProperty.call(obj, prop));
397
- }
398
459
  function isObject(value) {
399
460
  return !!(value && typeof value === strShimObject);
400
461
  }
401
462
  function isFunction(value) {
402
463
  return !!(value && typeof value === strShimFunction);
403
464
  }
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
465
  function objForEachKey(target, callbackfn) {
418
466
  if (target) {
419
467
  for (var prop in target) {
@@ -462,25 +510,6 @@
462
510
  function isString(value) {
463
511
  return typeof value === "string";
464
512
  }
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
513
  function toISOString(date) {
485
514
  if (date) {
486
515
  return _dataToISOString ? date[strToISOString]() : _toISOStringPoly(date);
@@ -546,42 +575,8 @@
546
575
  }
547
576
  return str;
548
577
  }
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
578
  function objDefineAccessors(target, prop, getProp, setProp) {
584
- if (_objDefineProperty$1) {
579
+ if (_objDefineProperty) {
585
580
  try {
586
581
  var descriptor = {
587
582
  enumerable: true,
@@ -593,7 +588,7 @@
593
588
  if (setProp) {
594
589
  descriptor.set = setProp;
595
590
  }
596
- _objDefineProperty$1(target, prop, descriptor);
591
+ _objDefineProperty(target, prop, descriptor);
597
592
  return true;
598
593
  }
599
594
  catch (e) {
@@ -601,10 +596,6 @@
601
596
  }
602
597
  return false;
603
598
  }
604
- function _doNothing(value) {
605
- return value;
606
- }
607
- var objFreeze = _objFreeze || _doNothing;
608
599
  function dateNow() {
609
600
  var dt = Date;
610
601
  return dt.now ? dt.now() : new dt().getTime();
@@ -613,7 +604,7 @@
613
604
  if (isError(object)) {
614
605
  return object.name;
615
606
  }
616
- return strEmpty$1;
607
+ return "";
617
608
  }
618
609
  function setValue(target, field, value, valChk, srcChk) {
619
610
  var theValue = value;
@@ -632,88 +623,6 @@
632
623
  function throwError(message) {
633
624
  throw new Error(message);
634
625
  }
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
626
 
718
627
  var strWindow = "window";
719
628
  var strDocument = "document";
@@ -816,14 +725,14 @@
816
725
  var nav = getNavigator();
817
726
  if (nav && (nav.userAgent !== _navUserAgentCheck || _isTrident === null)) {
818
727
  _navUserAgentCheck = nav.userAgent;
819
- var userAgent = (_navUserAgentCheck || strEmpty$1).toLowerCase();
728
+ var userAgent = (_navUserAgentCheck || "").toLowerCase();
820
729
  _isTrident = (strContains(userAgent, strMsie) || strContains(userAgent, strTrident));
821
730
  }
822
731
  return _isTrident;
823
732
  }
824
733
  function dumpObj(object) {
825
734
  var objectTypeDump = Object[strShimPrototype].toString.call(object);
826
- var propertyValueDump = strEmpty$1;
735
+ var propertyValueDump = "";
827
736
  if (objectTypeDump === "[object Error]") {
828
737
  propertyValueDump = "{ stack: '" + object.stack + "', message: '" + object.message + "', name: '" + object.name + "'";
829
738
  }
@@ -856,9 +765,9 @@
856
765
  var strWarnToConsole = "warnToConsole";
857
766
  function _sanitizeDiagnosticText(text) {
858
767
  if (text) {
859
- return "\"" + text.replace(/\"/g, strEmpty$1) + "\"";
768
+ return "\"" + text.replace(/\"/g, "") + "\"";
860
769
  }
861
- return strEmpty$1;
770
+ return "";
862
771
  }
863
772
  function _logToConsole(func, message) {
864
773
  var theConsole = getConsole();
@@ -880,12 +789,12 @@
880
789
  _self.message =
881
790
  (isUserAct ? AiUserActionablePrefix : AiNonUserActionablePrefix) +
882
791
  msgId;
883
- var strProps = strEmpty$1;
792
+ var strProps = "";
884
793
  if (hasJSON()) {
885
794
  strProps = getJSON().stringify(properties);
886
795
  }
887
- var diagnosticText = (msg ? " message:" + _sanitizeDiagnosticText(msg) : strEmpty$1) +
888
- (properties ? " props:" + _sanitizeDiagnosticText(strProps) : strEmpty$1);
796
+ var diagnosticText = (msg ? " message:" + _sanitizeDiagnosticText(msg) : "") +
797
+ (properties ? " props:" + _sanitizeDiagnosticText(strProps) : "");
889
798
  _self.message += diagnosticText;
890
799
  }
891
800
  _InternalLogMessage.dataType = "MessageData";
@@ -912,10 +821,10 @@
912
821
  if (isUserAct === void 0) { isUserAct = false; }
913
822
  var message = new _InternalLogMessage(msgId, msg, isUserAct, properties);
914
823
  if (_self.enableDebugExceptions()) {
915
- throw message;
824
+ throw dumpObj(message);
916
825
  }
917
826
  else {
918
- var logFunc = severity === 1 ? strErrorToConsole : strWarnToConsole;
827
+ var logFunc = severity === LoggingSeverity.CRITICAL ? strErrorToConsole : strWarnToConsole;
919
828
  if (!isUndefined(message.message)) {
920
829
  var logLevel = _self.consoleLoggingLevel();
921
830
  if (isUserAct) {
@@ -933,7 +842,7 @@
933
842
  _self.logInternalMessage(severity, message);
934
843
  }
935
844
  else {
936
- _debugExtMsg("throw" + (severity === 1 ? "Critical" : "Warning"), message);
845
+ _debugExtMsg("throw" + (severity === LoggingSeverity.CRITICAL ? "Critical" : "Warning"), message);
937
846
  }
938
847
  }
939
848
  };
@@ -965,13 +874,13 @@
965
874
  if (severity <= _self.telemetryLoggingLevel()) {
966
875
  _self.queue.push(message);
967
876
  _messageCount++;
968
- _debugExtMsg((severity === 1 ? "error" : "warn"), message);
877
+ _debugExtMsg((severity === LoggingSeverity.CRITICAL ? "error" : "warn"), message);
969
878
  }
970
879
  if (_messageCount === _self.maxInternalMessageLimit()) {
971
880
  var throttleLimitMessage = "Internal events throttle limit per PageView reached for this app.";
972
- var throttleMessage = new _InternalLogMessage(23 , throttleLimitMessage, false);
881
+ var throttleMessage = new _InternalLogMessage(_InternalMessageId.MessageLimitPerPVExceeded, throttleLimitMessage, false);
973
882
  _self.queue.push(throttleMessage);
974
- if (severity === 1 ) {
883
+ if (severity === LoggingSeverity.CRITICAL) {
975
884
  _self.errorToConsole(throttleLimitMessage);
976
885
  }
977
886
  else {
@@ -1000,10 +909,6 @@
1000
909
  }
1001
910
  return DiagnosticLogger;
1002
911
  }());
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
912
 
1008
913
  var strExecutionContextKey = "ctx";
1009
914
  var PerfEvent = /** @class */ (function () {
@@ -1117,495 +1022,252 @@
1117
1022
  return func();
1118
1023
  }
1119
1024
 
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
- }
1025
+ var TelemetryPluginChain = /** @class */ (function () {
1026
+ function TelemetryPluginChain(plugin, defItemCtx) {
1027
+ var _self = this;
1028
+ var _nextProxy = null;
1029
+ var _hasProcessTelemetry = isFunction(plugin.processTelemetry);
1030
+ var _hasSetNext = isFunction(plugin.setNextPlugin);
1031
+ _self._hasRun = false;
1032
+ _self.getPlugin = function () {
1033
+ return plugin;
1034
+ };
1035
+ _self.getNext = function () {
1036
+ return _nextProxy;
1037
+ };
1038
+ _self.setNext = function (nextPlugin) {
1039
+ _nextProxy = nextPlugin;
1040
+ };
1041
+ _self.processTelemetry = function (env, itemCtx) {
1042
+ if (!itemCtx) {
1043
+ itemCtx = defItemCtx;
1044
+ }
1045
+ var identifier = plugin ? plugin.identifier : "TelemetryPluginChain";
1046
+ doPerf(itemCtx ? itemCtx.core() : null, function () { return identifier + ":processTelemetry"; }, function () {
1047
+ if (plugin && _hasProcessTelemetry) {
1048
+ _self._hasRun = true;
1049
+ try {
1050
+ itemCtx.setNext(_nextProxy);
1051
+ if (_hasSetNext) {
1052
+ plugin.setNextPlugin(_nextProxy);
1053
+ }
1054
+ _nextProxy && (_nextProxy._hasRun = false);
1055
+ plugin.processTelemetry(env, itemCtx);
1056
+ }
1057
+ catch (error) {
1058
+ var hasRun = _nextProxy && _nextProxy._hasRun;
1059
+ if (!_nextProxy || !hasRun) {
1060
+ itemCtx.diagLog().throwInternal(LoggingSeverity.CRITICAL, _InternalMessageId.PluginException, "Plugin [" + plugin.identifier + "] failed during processTelemetry - " + dumpObj(error));
1061
+ }
1062
+ if (_nextProxy && !hasRun) {
1063
+ _nextProxy.processTelemetry(env, itemCtx);
1064
+ }
1065
+ }
1066
+ }
1067
+ else if (_nextProxy) {
1068
+ _self._hasRun = true;
1069
+ _nextProxy.processTelemetry(env, itemCtx);
1070
+ }
1071
+ }, function () { return ({ item: env }); }, !(env.sync));
1072
+ };
1184
1073
  }
1185
- return result;
1186
- }
1074
+ return TelemetryPluginChain;
1075
+ }());
1187
1076
 
1188
- var _objDefineProperty = ObjDefineProperty;
1189
- var version = "2.7.5-nightly.2204-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;
1077
+ function _createProxyChain(plugins, itemCtx) {
1078
+ var proxies = [];
1079
+ if (plugins && plugins.length > 0) {
1080
+ var lastProxy = null;
1081
+ for (var idx = 0; idx < plugins.length; idx++) {
1082
+ var thePlugin = plugins[idx];
1083
+ if (thePlugin && isFunction(thePlugin.processTelemetry)) {
1084
+ var newProxy = new TelemetryPluginChain(thePlugin, itemCtx);
1085
+ proxies.push(newProxy);
1086
+ if (lastProxy) {
1087
+ lastProxy.setNext(newProxy);
1218
1088
  }
1089
+ lastProxy = newProxy;
1219
1090
  }
1220
1091
  }
1221
- catch (e) {
1222
- }
1223
1092
  }
1224
- return theCache;
1093
+ return proxies.length > 0 ? proxies[0] : null;
1225
1094
  }
1226
- function createUniqueNamespace(name, includeVersion) {
1227
- if (includeVersion === void 0) { includeVersion = false; }
1228
- return normalizeJsName(name + (_dataUid++) + (includeVersion ? "." + version : "") + instanceName);
1229
- }
1230
- function createElmNodeData(name) {
1231
- var data = {
1232
- id: createUniqueNamespace("_aiData-" + (name || "") + "." + version),
1233
- accept: function (target) {
1234
- return _canAcceptData(target);
1235
- },
1236
- get: function (target, name, defValue, addDefault) {
1237
- var theCache = target[data.id];
1238
- if (!theCache) {
1239
- if (addDefault) {
1240
- theCache = _getCache(data, target);
1241
- theCache[normalizeJsName(name)] = defValue;
1242
- }
1243
- return defValue;
1244
- }
1245
- return theCache[normalizeJsName(name)];
1246
- },
1247
- kill: function (target, name) {
1248
- if (target && target[name]) {
1249
- try {
1250
- delete target[name];
1251
- }
1252
- catch (e) {
1253
- }
1095
+ function _copyProxyChain(proxy, itemCtx, startAt) {
1096
+ var plugins = [];
1097
+ var add = startAt ? false : true;
1098
+ if (proxy) {
1099
+ while (proxy) {
1100
+ var thePlugin = proxy.getPlugin();
1101
+ if (add || thePlugin === startAt) {
1102
+ add = true;
1103
+ plugins.push(thePlugin);
1254
1104
  }
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
- });
1105
+ proxy = proxy.getNext();
1322
1106
  }
1323
1107
  }
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
- }
1108
+ if (!add) {
1109
+ plugins.push(startAt);
1393
1110
  }
1394
- return context;
1111
+ return _createProxyChain(plugins, itemCtx);
1395
1112
  }
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);
1113
+ function _copyPluginChain(srcPlugins, itemCtx, startAt) {
1114
+ var plugins = srcPlugins;
1115
+ var add = false;
1116
+ if (startAt && srcPlugins) {
1117
+ plugins = [];
1118
+ arrForEach(srcPlugins, function (thePlugin) {
1119
+ if (add || thePlugin === startAt) {
1120
+ add = true;
1121
+ plugins.push(thePlugin);
1441
1122
  }
1442
1123
  });
1443
1124
  }
1444
- function _createNew(plugins, startAt) {
1445
- if (plugins === void 0) { plugins = null; }
1446
- if (isArray(plugins)) {
1447
- plugins = createTelemetryProxyChain(plugins, config, core, startAt);
1125
+ if (startAt && !add) {
1126
+ if (!plugins) {
1127
+ plugins = [];
1448
1128
  }
1449
- return createProcessTelemetryUpdateContext(plugins || context.getNext(), config, core, startAt);
1129
+ plugins.push(startAt);
1450
1130
  }
1451
- context.processNext = _processNext;
1452
- context.createNew = _createNew;
1453
- return context;
1131
+ return _createProxyChain(plugins, itemCtx);
1454
1132
  }
1455
- function createTelemetryProxyChain(plugins, config, core, startAt) {
1456
- var firstProxy = null;
1457
- var add = startAt ? false : true;
1458
- if (isArray(plugins) && plugins.length > 0) {
1459
- var lastProxy_1 = null;
1460
- arrForEach(plugins, function (thePlugin) {
1461
- if (!add && startAt === thePlugin) {
1462
- add = true;
1133
+ var ProcessTelemetryContext = /** @class */ (function () {
1134
+ function ProcessTelemetryContext(plugins, config, core, startAt) {
1135
+ var _self = this;
1136
+ var _nextProxy = null;
1137
+ if (startAt !== null) {
1138
+ if (plugins && isFunction(plugins.getPlugin)) {
1139
+ _nextProxy = _copyProxyChain(plugins, _self, startAt || plugins.getPlugin());
1463
1140
  }
1464
- if (add && thePlugin && isFunction(thePlugin.processTelemetry)) {
1465
- var newProxy = createTelemetryPluginProxy(thePlugin, config, core);
1466
- if (!firstProxy) {
1467
- firstProxy = newProxy;
1141
+ else {
1142
+ if (startAt) {
1143
+ _nextProxy = _copyPluginChain(plugins, _self, startAt);
1468
1144
  }
1469
- if (lastProxy_1) {
1470
- lastProxy_1._setNext(newProxy);
1145
+ else if (isUndefined(startAt)) {
1146
+ _nextProxy = _createProxyChain(plugins, _self);
1471
1147
  }
1472
- lastProxy_1 = newProxy;
1473
1148
  }
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
- }
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
1149
  }
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
- }
1150
+ _self.core = function () {
1151
+ return core;
1152
+ };
1153
+ _self.diagLog = function () {
1154
+ return safeGetLogger(core, config);
1155
+ };
1156
+ _self.getCfg = function () {
1157
+ return config;
1158
+ };
1159
+ _self.getExtCfg = function (identifier, defaultValue) {
1160
+ if (defaultValue === void 0) { defaultValue = {}; }
1161
+ var theConfig;
1162
+ if (config) {
1163
+ var extConfig = config.extensionConfig;
1164
+ if (extConfig && identifier) {
1165
+ theConfig = extConfig[identifier];
1543
1166
  }
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
1167
  }
1554
- var pluginState = _getPluginState(plugin);
1555
- if (pluginState[strTeardown] || pluginState[strDisabled]) {
1556
- return false;
1168
+ return (theConfig ? theConfig : defaultValue);
1169
+ };
1170
+ _self.getConfig = function (identifier, field, defaultValue) {
1171
+ if (defaultValue === void 0) { defaultValue = false; }
1172
+ var theValue;
1173
+ var extConfig = _self.getExtCfg(identifier, null);
1174
+ if (extConfig && !isNullOrUndefined(extConfig[field])) {
1175
+ theValue = extConfig[field];
1557
1176
  }
1558
- if (hasSetNext) {
1559
- plugin.setNextPlugin(nextProxy);
1177
+ else if (config && !isNullOrUndefined(config[field])) {
1178
+ theValue = config[field];
1560
1179
  }
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
- }
1180
+ return !isNullOrUndefined(theValue) ? theValue : defaultValue;
1181
+ };
1182
+ _self.hasNext = function () {
1183
+ return _nextProxy != null;
1184
+ };
1185
+ _self.getNext = function () {
1186
+ return _nextProxy;
1187
+ };
1188
+ _self.setNext = function (nextPlugin) {
1189
+ _nextProxy = nextPlugin;
1190
+ };
1191
+ _self.processNext = function (env) {
1192
+ var nextPlugin = _nextProxy;
1193
+ if (nextPlugin) {
1194
+ _nextProxy = nextPlugin.getNext();
1195
+ nextPlugin.processTelemetry(env, _self);
1582
1196
  }
1583
- return hasRun;
1584
- }
1585
- if (!_processChain(unloadCtx, _callTeardown, "unload", function () { }, unloadState.isAsync)) {
1586
- unloadCtx.processNext(unloadState);
1587
- }
1197
+ };
1198
+ _self.createNew = function (plugins, startAt) {
1199
+ if (plugins === void 0) { plugins = null; }
1200
+ return new ProcessTelemetryContext(plugins || _nextProxy, config, core, startAt);
1201
+ };
1588
1202
  }
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
- }
1203
+ return ProcessTelemetryContext;
1204
+ }());
1205
+
1206
+ var strExtensionConfig = "extensionConfig";
1207
+
1208
+ var strGetPlugin = "getPlugin";
1209
+ var BaseTelemetryPlugin = /** @class */ (function () {
1210
+ function BaseTelemetryPlugin() {
1211
+ var _self = this;
1212
+ var _isinitialized = false;
1213
+ var _rootCtx = null;
1214
+ var _nextPlugin = null;
1215
+ _self.core = null;
1216
+ _self.diagLog = function (itemCtx) {
1217
+ return _self._getTelCtx(itemCtx).diagLog();
1218
+ };
1219
+ _self.isInitialized = function () {
1220
+ return _isinitialized;
1221
+ };
1222
+ _self.setInitialized = function (isInitialized) {
1223
+ _isinitialized = isInitialized;
1224
+ };
1225
+ _self.setNextPlugin = function (next) {
1226
+ _nextPlugin = next;
1227
+ };
1228
+ _self.processNext = function (env, itemCtx) {
1229
+ if (itemCtx) {
1230
+ itemCtx.processNext(env);
1231
+ }
1232
+ else if (_nextPlugin && isFunction(_nextPlugin.processTelemetry)) {
1233
+ _nextPlugin.processTelemetry(env, null);
1234
+ }
1235
+ };
1236
+ _self._getTelCtx = function (currentCtx) {
1237
+ if (currentCtx === void 0) { currentCtx = null; }
1238
+ var itemCtx = currentCtx;
1239
+ if (!itemCtx) {
1240
+ var rootCtx = _rootCtx || new ProcessTelemetryContext(null, {}, _self.core);
1241
+ if (_nextPlugin && _nextPlugin[strGetPlugin]) {
1242
+ itemCtx = rootCtx.createNew(null, _nextPlugin[strGetPlugin]);
1243
+ }
1244
+ else {
1245
+ itemCtx = rootCtx.createNew(null, _nextPlugin);
1599
1246
  }
1600
1247
  }
1601
- return hasRun;
1602
- }
1603
- if (!_processChain(updateCtx, _callUpdate, "update", function () { }, false)) {
1604
- updateCtx.processNext(updateState);
1605
- }
1248
+ return itemCtx;
1249
+ };
1250
+ _self._baseTelInit = function (config, core, extensions, pluginChain) {
1251
+ if (config) {
1252
+ setValue(config, strExtensionConfig, [], null, isNullOrUndefined);
1253
+ }
1254
+ if (!pluginChain && core) {
1255
+ pluginChain = core.getProcessTelContext().getNext();
1256
+ }
1257
+ var nextPlugin = _nextPlugin;
1258
+ if (_nextPlugin && _nextPlugin[strGetPlugin]) {
1259
+ nextPlugin = _nextPlugin[strGetPlugin]();
1260
+ }
1261
+ _self.core = core;
1262
+ _rootCtx = new ProcessTelemetryContext(pluginChain, config, core, nextPlugin);
1263
+ _isinitialized = true;
1264
+ };
1606
1265
  }
1607
- return objFreeze(proxyChain);
1608
- }
1266
+ BaseTelemetryPlugin.prototype.initialize = function (config, core, extensions, pluginChain) {
1267
+ this._baseTelInit(config, core, extensions, pluginChain);
1268
+ };
1269
+ return BaseTelemetryPlugin;
1270
+ }());
1609
1271
 
1610
1272
  var strToGMTString = "toGMTString";
1611
1273
  var strToUTCString = "toUTCString";
@@ -1615,6 +1277,7 @@
1615
1277
  var strIsCookieUseDisabled = "isCookieUseDisabled";
1616
1278
  var strDisableCookiesUsage = "disableCookiesUsage";
1617
1279
  var strConfigCookieMgr = "_ckMgr";
1280
+ var strEmpty = "";
1618
1281
  var _supportsCookies = null;
1619
1282
  var _allowUaSameSite = null;
1620
1283
  var _parsedCookieValue = null;
@@ -1691,7 +1354,7 @@
1691
1354
  var result = false;
1692
1355
  if (_isMgrEnabled(cookieMgr)) {
1693
1356
  var values = {};
1694
- var theValue = strTrim(value || strEmpty$1);
1357
+ var theValue = strTrim(value || strEmpty);
1695
1358
  var idx = theValue.indexOf(";");
1696
1359
  if (idx !== -1) {
1697
1360
  theValue = strTrim(value.substring(0, idx));
@@ -1706,11 +1369,11 @@
1706
1369
  if (expireMs > 0) {
1707
1370
  var expiry = new Date();
1708
1371
  expiry.setTime(expireMs);
1709
- setValue(values, strExpires, _formatDate(expiry, !_isIE ? strToUTCString : strToGMTString) || _formatDate(expiry, _isIE ? strToGMTString : strToUTCString) || strEmpty$1, isTruthy);
1372
+ setValue(values, strExpires, _formatDate(expiry, !_isIE ? strToUTCString : strToGMTString) || _formatDate(expiry, _isIE ? strToGMTString : strToUTCString) || strEmpty, isTruthy);
1710
1373
  }
1711
1374
  }
1712
1375
  if (!_isIE) {
1713
- setValue(values, "max-age", strEmpty$1 + maxAgeSec, null, isUndefined);
1376
+ setValue(values, "max-age", strEmpty + maxAgeSec, null, isUndefined);
1714
1377
  }
1715
1378
  }
1716
1379
  var location_1 = getLocation();
@@ -1731,7 +1394,7 @@
1731
1394
  return result;
1732
1395
  },
1733
1396
  get: function (name) {
1734
- var value = strEmpty$1;
1397
+ var value = strEmpty;
1735
1398
  if (_isMgrEnabled(cookieMgr)) {
1736
1399
  value = (cookieMgrConfig.getCookie || _getCookieValue)(name);
1737
1400
  }
@@ -1756,7 +1419,7 @@
1756
1419
  values["max-age"] = "0";
1757
1420
  }
1758
1421
  var delCookie = cookieMgrConfig.delCookie || _setCookieValue;
1759
- delCookie(name, _formatCookieValue(strEmpty$1, values));
1422
+ delCookie(name, _formatCookieValue(strEmpty, values));
1760
1423
  result = true;
1761
1424
  }
1762
1425
  return result;
@@ -1773,7 +1436,7 @@
1773
1436
  _supportsCookies = doc[strCookie] !== undefined;
1774
1437
  }
1775
1438
  catch (e) {
1776
- _throwInternal(logger, 2 , 68 , "Cannot access document.cookie - " + getExceptionName(e), { exception: dumpObj(e) });
1439
+ logger && logger.throwInternal(LoggingSeverity.WARNING, _InternalMessageId.CannotAccessCookie, "Cannot access document.cookie - " + getExceptionName(e), { exception: dumpObj(e) });
1777
1440
  }
1778
1441
  }
1779
1442
  return _supportsCookies;
@@ -1783,7 +1446,7 @@
1783
1446
  if (theValue && theValue.length) {
1784
1447
  var parts = strTrim(theValue).split(";");
1785
1448
  arrForEach(parts, function (thePart) {
1786
- thePart = strTrim(thePart || strEmpty$1);
1449
+ thePart = strTrim(thePart || strEmpty);
1787
1450
  if (thePart) {
1788
1451
  var idx = thePart.indexOf("=");
1789
1452
  if (idx === -1) {
@@ -1804,21 +1467,21 @@
1804
1467
  return null;
1805
1468
  }
1806
1469
  function _formatCookieValue(value, values) {
1807
- var cookieValue = value || strEmpty$1;
1470
+ var cookieValue = value || strEmpty;
1808
1471
  objForEachKey(values, function (name, theValue) {
1809
- cookieValue += "; " + name + (!isNullOrUndefined(theValue) ? "=" + theValue : strEmpty$1);
1472
+ cookieValue += "; " + name + (!isNullOrUndefined(theValue) ? "=" + theValue : strEmpty);
1810
1473
  });
1811
1474
  return cookieValue;
1812
1475
  }
1813
1476
  function _getCookieValue(name) {
1814
- var cookieValue = strEmpty$1;
1477
+ var cookieValue = strEmpty;
1815
1478
  if (_doc) {
1816
- var theCookie = _doc[strCookie] || strEmpty$1;
1479
+ var theCookie = _doc[strCookie] || strEmpty;
1817
1480
  if (_parsedCookieValue !== theCookie) {
1818
1481
  _cookieCache = _extractParts(theCookie);
1819
1482
  _parsedCookieValue = theCookie;
1820
1483
  }
1821
- cookieValue = strTrim(_cookieCache[name] || strEmpty$1);
1484
+ cookieValue = strTrim(_cookieCache[name] || strEmpty);
1822
1485
  }
1823
1486
  return cookieValue;
1824
1487
  }
@@ -1849,354 +1512,63 @@
1849
1512
  if (strContains(userAgent, "UCBrowser/12") || strContains(userAgent, "UCBrowser/11")) {
1850
1513
  return true;
1851
1514
  }
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;
1515
+ return false;
2108
1516
  }
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
- }
1517
+
1518
+ var UInt32Mask = 0x100000000;
1519
+ var MaxUInt32 = 0xffffffff;
1520
+ var _mwcSeeded = false;
1521
+ var _mwcW = 123456789;
1522
+ var _mwcZ = 987654321;
1523
+ function _mwcSeed(seedValue) {
1524
+ if (seedValue < 0) {
1525
+ seedValue >>>= 0;
2121
1526
  }
1527
+ _mwcW = (123456789 + seedValue) & MaxUInt32;
1528
+ _mwcZ = (987654321 - seedValue) & MaxUInt32;
1529
+ _mwcSeeded = true;
2122
1530
  }
2123
- function _unregisterEvents(target, evtName, unRegFn) {
2124
- if (evtName.type) {
2125
- _doUnregister(target, _getRegisteredEvents(target, evtName.type), evtName, unRegFn);
1531
+ function _autoSeedMwc() {
1532
+ try {
1533
+ var now = dateNow() & 0x7fffffff;
1534
+ _mwcSeed(((Math.random() * UInt32Mask) ^ now) + now);
2126
1535
  }
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
- }
1536
+ catch (e) {
2135
1537
  }
2136
1538
  }
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];
1539
+ function random32(signed) {
1540
+ var value;
1541
+ var c = getCrypto() || getMsCrypto();
1542
+ if (c && c.getRandomValues) {
1543
+ value = c.getRandomValues(new Uint32Array(1))[0] & MaxUInt32;
1544
+ }
1545
+ else if (isIE()) {
1546
+ if (!_mwcSeeded) {
1547
+ _autoSeedMwc();
2145
1548
  }
2146
- newNamespaces = (_getEvtNamespace("xx", newNamespaces).ns).split(".");
1549
+ value = mwcRandom32() & MaxUInt32;
2147
1550
  }
2148
1551
  else {
2149
- newNamespaces = theNamespace;
1552
+ value = Math.floor((UInt32Mask * Math.random()) | 0);
2150
1553
  }
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
- }
1554
+ if (!signed) {
1555
+ value >>>= 0;
2172
1556
  }
2173
- return result;
1557
+ return value;
2174
1558
  }
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
- }
1559
+ function mwcRandom32(signed) {
1560
+ _mwcZ = (36969 * (_mwcZ & 0xFFFF) + (_mwcZ >> 16)) & MaxUInt32;
1561
+ _mwcW = (18000 * (_mwcW & 0xFFFF) + (_mwcW >> 16)) & MaxUInt32;
1562
+ var value = (((_mwcZ << 16) + (_mwcW & 0xFFFF)) >>> 0) & MaxUInt32 | 0;
1563
+ if (!signed) {
1564
+ value >>>= 0;
2194
1565
  }
1566
+ return value;
2195
1567
  }
2196
1568
 
2197
1569
  function generateW3CId() {
2198
1570
  var hexValues = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f"];
2199
- var oct = strEmpty$1, tmp;
1571
+ var oct = "", tmp;
2200
1572
  for (var a = 0; a < 4; a++) {
2201
1573
  tmp = random32();
2202
1574
  oct +=
@@ -2213,232 +1585,6 @@
2213
1585
  return oct.substr(0, 8) + oct.substr(9, 4) + "4" + oct.substr(13, 3) + clockSequenceHi + oct.substr(16, 3) + oct.substr(19, 12);
2214
1586
  }
2215
1587
 
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
1588
  function dataSanitizeKeyAndAddUniqueness(logger, key, map) {
2443
1589
  var origLength = key.length;
2444
1590
  var field = dataSanitizeKey(logger, key);
@@ -2459,7 +1605,7 @@
2459
1605
  name = strTrim(name.toString());
2460
1606
  if (name.length > 150 ) {
2461
1607
  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);
1608
+ logger && logger.throwInternal(LoggingSeverity.WARNING, _InternalMessageId.NameTooLong, "name is too long. It has been truncated to " + 150 + " characters.", { name: name }, true);
2463
1609
  }
2464
1610
  }
2465
1611
  return nameTrunc || name;
@@ -2472,7 +1618,7 @@
2472
1618
  value = strTrim(value);
2473
1619
  if (value.toString().length > maxLength) {
2474
1620
  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);
1621
+ logger && logger.throwInternal(LoggingSeverity.WARNING, _InternalMessageId.StringValueTooLong, "string value is too long. It has been truncated to " + maxLength + " characters.", { value: value }, true);
2476
1622
  }
2477
1623
  }
2478
1624
  return valueTrunc || value;
@@ -2485,7 +1631,7 @@
2485
1631
  if (message) {
2486
1632
  if (message.length > 32768 ) {
2487
1633
  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);
1634
+ logger && logger.throwInternal(LoggingSeverity.WARNING, _InternalMessageId.MessageTruncated, "message is too long, it has been truncated to " + 32768 + " characters.", { message: message }, true);
2489
1635
  }
2490
1636
  }
2491
1637
  return messageTrunc || message;
@@ -2496,7 +1642,7 @@
2496
1642
  var value = "" + exception;
2497
1643
  if (value.length > 32768 ) {
2498
1644
  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);
1645
+ logger && logger.throwInternal(LoggingSeverity.WARNING, _InternalMessageId.ExceptionTruncated, "exception is too long, it has been truncated to " + 32768 + " characters.", { exception: exception }, true);
2500
1646
  }
2501
1647
  }
2502
1648
  return exceptionTrunc || exception;
@@ -2510,7 +1656,7 @@
2510
1656
  value = getJSON().stringify(value);
2511
1657
  }
2512
1658
  catch (e) {
2513
- _throwInternal(logger, 2 , _InternalMessageId.CannotSerializeObjectNonSerializable, "custom property is not valid", { exception: e }, true);
1659
+ logger && logger.throwInternal(LoggingSeverity.WARNING, _InternalMessageId.CannotSerializeObjectNonSerializable, "custom property is not valid", { exception: e }, true);
2514
1660
  }
2515
1661
  }
2516
1662
  value = dataSanitizeString(logger, value, 8192 );
@@ -2541,7 +1687,7 @@
2541
1687
  input = strTrim(input);
2542
1688
  if (input.length > maxLength) {
2543
1689
  inputTrunc = input.substring(0, maxLength);
2544
- _throwInternal(logger, 2 , _msgId, "input is too long, it has been truncated to " + maxLength + " characters.", { data: input }, true);
1690
+ logger && logger.throwInternal(LoggingSeverity.WARNING, _msgId, "input is too long, it has been truncated to " + maxLength + " characters.", { data: input }, true);
2545
1691
  }
2546
1692
  }
2547
1693
  return inputTrunc || input;
@@ -2566,7 +1712,6 @@
2566
1712
  return event;
2567
1713
  }
2568
1714
 
2569
- var strEmpty = "";
2570
1715
  function stringToBoolOrDefault(str, defaultValue) {
2571
1716
  if (defaultValue === void 0) { defaultValue = false; }
2572
1717
  if (str === undefined || str === null) {
@@ -2579,16 +1724,16 @@
2579
1724
  totalms = 0;
2580
1725
  }
2581
1726
  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;
1727
+ var ms = "" + totalms % 1000;
1728
+ var sec = "" + Math.floor(totalms / 1000) % 60;
1729
+ var min = "" + Math.floor(totalms / (1000 * 60)) % 60;
1730
+ var hour = "" + Math.floor(totalms / (1000 * 60 * 60)) % 24;
2586
1731
  var days = Math.floor(totalms / (1000 * 60 * 60 * 24));
2587
1732
  ms = ms.length === 1 ? "00" + ms : ms.length === 2 ? "0" + ms : ms;
2588
1733
  sec = sec.length < 2 ? "0" + sec : sec;
2589
1734
  min = min.length < 2 ? "0" + min : min;
2590
1735
  hour = hour.length < 2 ? "0" + hour : hour;
2591
- return (days > 0 ? days + "." : strEmpty) + hour + ":" + min + ":" + sec + "." + ms;
1736
+ return (days > 0 ? days + "." : "") + hour + ":" + min + ":" + sec + "." + ms;
2592
1737
  }
2593
1738
  function isCrossOriginError(message, url, lineNumber, columnNumber, error) {
2594
1739
  return !error && isString(message) && (message === "Script error." || message === "Script error");
@@ -2597,17 +1742,18 @@
2597
1742
  var strNotSpecified = "not_specified";
2598
1743
  var strIkey = "iKey";
2599
1744
 
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
- });
1745
+ var StorageType;
1746
+ (function (StorageType) {
1747
+ StorageType[StorageType["LocalStorage"] = 0] = "LocalStorage";
1748
+ StorageType[StorageType["SessionStorage"] = 1] = "SessionStorage";
1749
+ })(StorageType || (StorageType = {}));
1750
+ var DistributedTracingModes;
1751
+ (function (DistributedTracingModes) {
1752
+ DistributedTracingModes[DistributedTracingModes["AI"] = 0] = "AI";
1753
+ DistributedTracingModes[DistributedTracingModes["AI_AND_W3C"] = 1] = "AI_AND_W3C";
1754
+ DistributedTracingModes[DistributedTracingModes["W3C"] = 2] = "W3C";
1755
+ })(DistributedTracingModes || (DistributedTracingModes = {}));
2609
1756
 
2610
- var _canUseLocalStorage = undefined;
2611
1757
  var _canUseSessionStorage = undefined;
2612
1758
  function _getVerifiedStorageObject(storageType) {
2613
1759
  try {
@@ -2634,21 +1780,10 @@
2634
1780
  return null;
2635
1781
  }
2636
1782
  function utlDisableStorage() {
2637
- _canUseLocalStorage = false;
2638
1783
  _canUseSessionStorage = false;
2639
1784
  }
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) {
1785
+ function utlCanUseSessionStorage() {
1786
+ if (_canUseSessionStorage === undefined) {
2652
1787
  _canUseSessionStorage = !!_getVerifiedStorageObject(StorageType.SessionStorage);
2653
1788
  }
2654
1789
  return _canUseSessionStorage;
@@ -2661,7 +1796,7 @@
2661
1796
  }
2662
1797
  catch (e) {
2663
1798
  _canUseSessionStorage = false;
2664
- _throwInternal(logger, 2 , _InternalMessageId.BrowserCannotReadSessionStorage, "Browser failed read of session storage. " + getExceptionName(e), { exception: dumpObj(e) });
1799
+ logger.throwInternal(LoggingSeverity.WARNING, _InternalMessageId.BrowserCannotReadSessionStorage, "Browser failed read of session storage. " + getExceptionName(e), { exception: dumpObj(e) });
2665
1800
  }
2666
1801
  }
2667
1802
  return null;
@@ -2675,7 +1810,7 @@
2675
1810
  }
2676
1811
  catch (e) {
2677
1812
  _canUseSessionStorage = false;
2678
- _throwInternal(logger, 2 , _InternalMessageId.BrowserCannotWriteSessionStorage, "Browser failed write to session storage. " + getExceptionName(e), { exception: dumpObj(e) });
1813
+ logger.throwInternal(LoggingSeverity.WARNING, _InternalMessageId.BrowserCannotWriteSessionStorage, "Browser failed write to session storage. " + getExceptionName(e), { exception: dumpObj(e) });
2679
1814
  }
2680
1815
  }
2681
1816
  return false;
@@ -2689,7 +1824,7 @@
2689
1824
  }
2690
1825
  catch (e) {
2691
1826
  _canUseSessionStorage = false;
2692
- _throwInternal(logger, 2 , _InternalMessageId.BrowserFailedRemovalFromSessionStorage, "Browser failed removal of session storage item. " + getExceptionName(e), { exception: dumpObj(e) });
1827
+ logger.throwInternal(LoggingSeverity.WARNING, _InternalMessageId.BrowserFailedRemovalFromSessionStorage, "Browser failed removal of session storage item. " + getExceptionName(e), { exception: dumpObj(e) });
2693
1828
  }
2694
1829
  }
2695
1830
  return false;
@@ -3601,9 +2736,11 @@
3601
2736
  if (core) {
3602
2737
  _logger = core.logger;
3603
2738
  }
3604
- function _flushChannels(isAsync) {
2739
+ function _flushChannels() {
3605
2740
  if (core) {
3606
- core.flush(isAsync);
2741
+ arrForEach(core.getTransmissionControls(), function (queues) {
2742
+ arrForEach(queues, function (q) { return q.flush(true); });
2743
+ });
3607
2744
  }
3608
2745
  }
3609
2746
  function _addQueue(cb) {
@@ -3626,7 +2763,7 @@
3626
2763
  intervalHandle = null;
3627
2764
  }
3628
2765
  if (doFlush) {
3629
- _flushChannels(true);
2766
+ _flushChannels();
3630
2767
  }
3631
2768
  }), 100);
3632
2769
  }
@@ -3644,7 +2781,7 @@
3644
2781
  }
3645
2782
  if (!pageViewPerformanceManager.isPerformanceTimingSupported()) {
3646
2783
  appInsights.sendPageViewInternal(pageView, customProperties);
3647
- _flushChannels(true);
2784
+ _flushChannels();
3648
2785
  _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
2786
  return;
3650
2787
  }
@@ -3670,7 +2807,7 @@
3670
2807
  customProperties["duration"] = customDuration;
3671
2808
  }
3672
2809
  appInsights.sendPageViewInternal(pageView, customProperties);
3673
- _flushChannels(true);
2810
+ _flushChannels();
3674
2811
  pageViewSent = true;
3675
2812
  }
3676
2813
  var maxDurationLimit = 60000;
@@ -3716,17 +2853,6 @@
3716
2853
  return processed;
3717
2854
  });
3718
2855
  };
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
2856
  });
3731
2857
  }
3732
2858
  return PageViewManager;
@@ -3921,33 +3047,6 @@
3921
3047
  return PageViewPerformanceManager;
3922
3048
  }());
3923
3049
 
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
3050
  var durationProperty = "duration";
3952
3051
  var strEvent = "event";
3953
3052
  function _dispatchEvent(target, evnt) {
@@ -3965,78 +3064,47 @@
3965
3064
  }
3966
3065
  return error || "";
3967
3066
  }
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() {
3067
+ var ApplicationInsights = /** @class */ (function (_super) {
3068
+ __extendsFn(ApplicationInsights, _super);
3069
+ function ApplicationInsights() {
4011
3070
  var _this = _super.call(this) || this;
4012
3071
  _this.identifier = AnalyticsPluginIdentifier;
4013
3072
  _this.priority = 180;
4014
3073
  _this.autoRoutePVDelay = 500;
4015
3074
  var _eventTracking;
4016
3075
  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;
3076
+ var _properties;
4029
3077
  var _prevUri;
4030
3078
  var _currUri;
4031
- var _evtNamespace;
4032
- dynamicProto(AnalyticsPlugin, _this, function (_self, _base) {
4033
- var _addHook = _base._addHook;
4034
- _initDefaults();
3079
+ dynamicProto(ApplicationInsights, _this, function (_self, _base) {
3080
+ var location = getLocation(true);
3081
+ _prevUri = location && location.href || "";
4035
3082
  _self.getCookieMgr = function () {
4036
3083
  return safeGetCookieMgr(_self.core);
4037
3084
  };
4038
3085
  _self.processTelemetry = function (env, itemCtx) {
4039
- _self.processNext(env, itemCtx);
3086
+ doPerf(_self.core, function () { return _self.identifier + ":processTelemetry"; }, function () {
3087
+ var doNotSendItem = false;
3088
+ var telemetryInitializersCount = _self._telemetryInitializers.length;
3089
+ itemCtx = _self._getTelCtx(itemCtx);
3090
+ for (var i = 0; i < telemetryInitializersCount; ++i) {
3091
+ var telemetryInitializer = _self._telemetryInitializers[i];
3092
+ if (telemetryInitializer) {
3093
+ try {
3094
+ if (telemetryInitializer.apply(null, [env]) === false) {
3095
+ doNotSendItem = true;
3096
+ break;
3097
+ }
3098
+ }
3099
+ catch (e) {
3100
+ itemCtx.diagLog().throwInternal(LoggingSeverity.CRITICAL, _InternalMessageId.TelemetryInitializerFailed, "One of telemetry initializers failed, telemetry item will not be sent: " + getExceptionName(e), { exception: dumpObj(e) }, true);
3101
+ }
3102
+ }
3103
+ }
3104
+ if (!doNotSendItem) {
3105
+ _self.processNext(env, itemCtx);
3106
+ }
3107
+ }, function () { return ({ item: env }); }, !(env.sync));
4040
3108
  };
4041
3109
  _self.trackEvent = function (event, customProperties) {
4042
3110
  try {
@@ -4044,7 +3112,7 @@
4044
3112
  _self.core.track(telemetryItem);
4045
3113
  }
4046
3114
  catch (e) {
4047
- _throwInternal(LoggingSeverity.WARNING, _InternalMessageId.TrackTraceFailed, "trackTrace failed, trace will not be collected: " + getExceptionName(e), { exception: dumpObj(e) });
3115
+ _self.diagLog().throwInternal(LoggingSeverity.WARNING, _InternalMessageId.TrackTraceFailed, "trackTrace failed, trace will not be collected: " + getExceptionName(e), { exception: dumpObj(e) });
4048
3116
  }
4049
3117
  };
4050
3118
  _self.startTrackEvent = function (name) {
@@ -4052,7 +3120,7 @@
4052
3120
  _eventTracking.start(name);
4053
3121
  }
4054
3122
  catch (e) {
4055
- _throwInternal(LoggingSeverity.CRITICAL, _InternalMessageId.StartTrackEventFailed, "startTrackEvent failed, event will not be collected: " + getExceptionName(e), { exception: dumpObj(e) });
3123
+ _self.diagLog().throwInternal(LoggingSeverity.CRITICAL, _InternalMessageId.StartTrackEventFailed, "startTrackEvent failed, event will not be collected: " + getExceptionName(e), { exception: dumpObj(e) });
4056
3124
  }
4057
3125
  };
4058
3126
  _self.stopTrackEvent = function (name, properties, measurements) {
@@ -4060,7 +3128,7 @@
4060
3128
  _eventTracking.stop(name, undefined, properties);
4061
3129
  }
4062
3130
  catch (e) {
4063
- _throwInternal(LoggingSeverity.CRITICAL, _InternalMessageId.StopTrackEventFailed, "stopTrackEvent failed, event will not be collected: " + getExceptionName(e), { exception: dumpObj(e) });
3131
+ _self.diagLog().throwInternal(LoggingSeverity.CRITICAL, _InternalMessageId.StopTrackEventFailed, "stopTrackEvent failed, event will not be collected: " + getExceptionName(e), { exception: dumpObj(e) });
4064
3132
  }
4065
3133
  };
4066
3134
  _self.trackTrace = function (trace, customProperties) {
@@ -4069,7 +3137,7 @@
4069
3137
  _self.core.track(telemetryItem);
4070
3138
  }
4071
3139
  catch (e) {
4072
- _throwInternal(LoggingSeverity.WARNING, _InternalMessageId.TrackTraceFailed, "trackTrace failed, trace will not be collected: " + getExceptionName(e), { exception: dumpObj(e) });
3140
+ _self.diagLog().throwInternal(LoggingSeverity.WARNING, _InternalMessageId.TrackTraceFailed, "trackTrace failed, trace will not be collected: " + getExceptionName(e), { exception: dumpObj(e) });
4073
3141
  }
4074
3142
  };
4075
3143
  _self.trackMetric = function (metric, customProperties) {
@@ -4078,19 +3146,19 @@
4078
3146
  _self.core.track(telemetryItem);
4079
3147
  }
4080
3148
  catch (e) {
4081
- _throwInternal(LoggingSeverity.CRITICAL, _InternalMessageId.TrackMetricFailed, "trackMetric failed, metric will not be collected: " + getExceptionName(e), { exception: dumpObj(e) });
3149
+ _self.diagLog().throwInternal(LoggingSeverity.CRITICAL, _InternalMessageId.TrackMetricFailed, "trackMetric failed, metric will not be collected: " + getExceptionName(e), { exception: dumpObj(e) });
4082
3150
  }
4083
3151
  };
4084
3152
  _self.trackPageView = function (pageView, customProperties) {
4085
3153
  try {
4086
3154
  var inPv = pageView || {};
4087
- _pageViewManager.trackPageView(inPv, __assignFn(__assignFn(__assignFn({}, inPv.properties), inPv.measurements), customProperties));
3155
+ _self._pageViewManager.trackPageView(inPv, __assignFn(__assignFn(__assignFn({}, inPv.properties), inPv.measurements), customProperties));
4088
3156
  if (_self.config.autoTrackPageVisitTime) {
4089
- _pageVisitTimeManager.trackPreviousPageVisit(inPv.name, inPv.uri);
3157
+ _self._pageVisitTimeManager.trackPreviousPageVisit(inPv.name, inPv.uri);
4090
3158
  }
4091
3159
  }
4092
3160
  catch (e) {
4093
- _throwInternal(LoggingSeverity.CRITICAL, _InternalMessageId.TrackPVFailed, "trackPageView failed, page view will not be collected: " + getExceptionName(e), { exception: dumpObj(e) });
3161
+ _self.diagLog().throwInternal(LoggingSeverity.CRITICAL, _InternalMessageId.TrackPVFailed, "trackPageView failed, page view will not be collected: " + getExceptionName(e), { exception: dumpObj(e) });
4094
3162
  }
4095
3163
  };
4096
3164
  _self.sendPageViewInternal = function (pageView, properties, systemProperties) {
@@ -4106,13 +3174,12 @@
4106
3174
  _self.core.track(telemetryItem);
4107
3175
  };
4108
3176
  _self.trackPageViewPerformance = function (pageViewPerformance, customProperties) {
4109
- var inPvp = pageViewPerformance || {};
4110
3177
  try {
4111
- _pageViewPerformanceManager.populatePageViewPerformanceEvent(inPvp);
4112
- _self.sendPageViewPerformanceInternal(inPvp, customProperties);
3178
+ _self._pageViewPerformanceManager.populatePageViewPerformanceEvent(pageViewPerformance);
3179
+ _self.sendPageViewPerformanceInternal(pageViewPerformance, customProperties);
4113
3180
  }
4114
3181
  catch (e) {
4115
- _throwInternal(LoggingSeverity.CRITICAL, _InternalMessageId.TrackPVFailed, "trackPageViewPerformance failed, page view will not be collected: " + getExceptionName(e), { exception: dumpObj(e) });
3182
+ _self.diagLog().throwInternal(LoggingSeverity.CRITICAL, _InternalMessageId.TrackPVFailed, "trackPageViewPerformance failed, page view will not be collected: " + getExceptionName(e), { exception: dumpObj(e) });
4116
3183
  }
4117
3184
  };
4118
3185
  _self.startTrackPage = function (name) {
@@ -4124,7 +3191,7 @@
4124
3191
  _pageTracking.start(name);
4125
3192
  }
4126
3193
  catch (e) {
4127
- _throwInternal(LoggingSeverity.CRITICAL, _InternalMessageId.StartTrackFailed, "startTrackPage failed, page view may not be collected: " + getExceptionName(e), { exception: dumpObj(e) });
3194
+ _self.diagLog().throwInternal(LoggingSeverity.CRITICAL, _InternalMessageId.StartTrackFailed, "startTrackPage failed, page view may not be collected: " + getExceptionName(e), { exception: dumpObj(e) });
4128
3195
  }
4129
3196
  };
4130
3197
  _self.stopTrackPage = function (name, url, properties, measurement) {
@@ -4139,11 +3206,11 @@
4139
3206
  }
4140
3207
  _pageTracking.stop(name, url, properties, measurement);
4141
3208
  if (_self.config.autoTrackPageVisitTime) {
4142
- _pageVisitTimeManager.trackPreviousPageVisit(name, url);
3209
+ _self._pageVisitTimeManager.trackPreviousPageVisit(name, url);
4143
3210
  }
4144
3211
  }
4145
3212
  catch (e) {
4146
- _throwInternal(LoggingSeverity.CRITICAL, _InternalMessageId.StopTrackFailed, "stopTrackPage failed, page view will not be collected: " + getExceptionName(e), { exception: dumpObj(e) });
3213
+ _self.diagLog().throwInternal(LoggingSeverity.CRITICAL, _InternalMessageId.StopTrackFailed, "stopTrackPage failed, page view will not be collected: " + getExceptionName(e), { exception: dumpObj(e) });
4147
3214
  }
4148
3215
  };
4149
3216
  _self.sendExceptionInternal = function (exception, customProperties, systemProperties) {
@@ -4153,14 +3220,11 @@
4153
3220
  _self.core.track(telemetryItem);
4154
3221
  };
4155
3222
  _self.trackException = function (exception, customProperties) {
4156
- if (exception && !exception.exception && exception.error) {
4157
- exception.exception = exception.error;
4158
- }
4159
3223
  try {
4160
3224
  _self.sendExceptionInternal(exception, customProperties);
4161
3225
  }
4162
3226
  catch (e) {
4163
- _throwInternal(LoggingSeverity.CRITICAL, _InternalMessageId.TrackExceptionFailed, "trackException failed, exception will not be collected: " + getExceptionName(e), { exception: dumpObj(e) });
3227
+ _self.diagLog().throwInternal(LoggingSeverity.CRITICAL, _InternalMessageId.TrackExceptionFailed, "trackException failed, exception will not be collected: " + getExceptionName(e), { exception: dumpObj(e) });
4164
3228
  }
4165
3229
  };
4166
3230
  _self._onerror = function (exception) {
@@ -4194,98 +3258,158 @@
4194
3258
  }
4195
3259
  catch (e) {
4196
3260
  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: "
3261
+ _self.diagLog().throwInternal(LoggingSeverity.CRITICAL, _InternalMessageId.ExceptionWhileLoggingError, "_onError threw exception while logging error, error will not be collected: "
4198
3262
  + getExceptionName(e), { exception: dumpObj(e), errorString: errorString });
4199
3263
  }
4200
3264
  };
4201
3265
  _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);
3266
+ _self._telemetryInitializers.push(telemetryInitializer);
4209
3267
  };
4210
3268
  _self.initialize = function (config, core, extensions, pluginChain) {
4211
3269
  if (_self.isInitialized()) {
4212
3270
  return;
4213
3271
  }
4214
3272
  if (isNullOrUndefined(core)) {
4215
- throwError("Error initializing");
3273
+ throw Error("Error initializing");
4216
3274
  }
4217
3275
  _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)) {
3276
+ _self.setInitialized(false);
3277
+ var ctx = _self._getTelCtx();
3278
+ var identifier = _self.identifier;
3279
+ _self.config = ctx.getExtCfg(identifier);
3280
+ var defaults = ApplicationInsights.getDefaultConfig(config);
3281
+ if (defaults !== undefined) {
3282
+ objForEachKey(defaults, function (field, value) {
3283
+ _self.config[field] = ctx.getConfig(identifier, field, value);
3284
+ if (_self.config[field] === undefined) {
3285
+ _self.config[field] = value;
3286
+ }
3287
+ });
3288
+ }
3289
+ if (_self.config.isStorageUseDisabled) {
3290
+ utlDisableStorage();
3291
+ }
3292
+ var configGetters = {
3293
+ instrumentationKey: function () { return config.instrumentationKey; },
3294
+ accountId: function () { return _self.config.accountId || config.accountId; },
3295
+ sessionRenewalMs: function () { return _self.config.sessionRenewalMs || config.sessionRenewalMs; },
3296
+ sessionExpirationMs: function () { return _self.config.sessionExpirationMs || config.sessionExpirationMs; },
3297
+ sampleRate: function () { return _self.config.samplingPercentage || config.samplingPercentage; },
3298
+ sdkExtension: function () { return _self.config.sdkExtension || config.sdkExtension; },
3299
+ isBrowserLinkTrackingEnabled: function () { return _self.config.isBrowserLinkTrackingEnabled || config.isBrowserLinkTrackingEnabled; },
3300
+ appId: function () { return _self.config.appId || config.appId; }
3301
+ };
3302
+ _self._pageViewPerformanceManager = new PageViewPerformanceManager(_self.core);
3303
+ _self._pageViewManager = new PageViewManager(_this, _self.config.overridePageViewDuration, _self.core, _self._pageViewPerformanceManager);
3304
+ _self._pageVisitTimeManager = new PageVisitTimeManager(_self.diagLog(), function (pageName, pageUrl, pageVisitTime) { return trackPageVisitTime(pageName, pageUrl, pageVisitTime); });
3305
+ _self._telemetryInitializers = _self._telemetryInitializers || [];
3306
+ _addDefaultTelemetryInitializers(configGetters);
3307
+ _eventTracking = new Timing(_self.diagLog(), "trackEvent");
3308
+ _eventTracking.action =
3309
+ function (name, url, duration, properties) {
3310
+ if (!properties) {
4244
3311
  properties = {};
4245
3312
  }
4246
3313
  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);
3314
+ _self.trackEvent({ name: name, properties: properties });
4254
3315
  };
4255
- if (hasWindow()) {
4256
- _updateExceptionTracking(extConfig);
4257
- _updateLocationChange(extConfig);
3316
+ _pageTracking = new Timing(_self.diagLog(), "trackPageView");
3317
+ _pageTracking.action = function (name, url, duration, properties, measurements) {
3318
+ if (isNullOrUndefined(properties)) {
3319
+ properties = {};
4258
3320
  }
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;
3321
+ properties[durationProperty] = duration.toString();
3322
+ var pageViewItem = {
3323
+ name: name,
3324
+ uri: url,
3325
+ properties: properties,
3326
+ measurements: measurements
3327
+ };
3328
+ _self.sendPageViewInternal(pageViewItem, properties);
3329
+ };
3330
+ var _window = getWindow();
3331
+ var _history = getHistory();
3332
+ var _location = getLocation(true);
3333
+ var instance = _this;
3334
+ if (_self.config.disableExceptionTracking === false &&
3335
+ !_self.config.autoExceptionInstrumented && _window) {
3336
+ var onerror_1 = "onerror";
3337
+ var originalOnError_1 = _window[onerror_1];
3338
+ _window.onerror = function (message, url, lineNumber, columnNumber, error) {
3339
+ var evt = _window[strEvent];
3340
+ var handled = originalOnError_1 && originalOnError_1(message, url, lineNumber, columnNumber, error);
3341
+ if (handled !== true) {
3342
+ instance._onerror(Exception.CreateAutoException(message, url, lineNumber, columnNumber, error, evt));
3343
+ }
3344
+ return handled;
3345
+ };
3346
+ _self.config.autoExceptionInstrumented = true;
3347
+ }
3348
+ if (_self.config.disableExceptionTracking === false &&
3349
+ _self.config.enableUnhandledPromiseRejectionTracking === true &&
3350
+ !_self.config.autoUnhandledPromiseInstrumented && _window) {
3351
+ var onunhandledrejection_1 = "onunhandledrejection";
3352
+ var originalOnUnhandledRejection_1 = _window[onunhandledrejection_1];
3353
+ _window[onunhandledrejection_1] = function (error) {
3354
+ var evt = _window[strEvent];
3355
+ var handled = originalOnUnhandledRejection_1 && originalOnUnhandledRejection_1.call(_window, error);
3356
+ if (handled !== true) {
3357
+ instance._onerror(Exception.CreateAutoException(_getReason(error), _location ? _location.href : "", 0, 0, error, evt));
3358
+ }
3359
+ return handled;
3360
+ };
3361
+ _self.config.autoUnhandledPromiseInstrumented = true;
3362
+ }
3363
+ if (_self.config.enableAutoRouteTracking === true
3364
+ && _history && isFunction(_history.pushState) && isFunction(_history.replaceState)
3365
+ && _window
3366
+ && typeof Event !== "undefined") {
3367
+ var _self_1 = _this;
3368
+ arrForEach(extensions, function (extension) {
3369
+ if (extension.identifier === PropertiesPluginIdentifier) {
3370
+ _properties = extension;
4280
3371
  }
4281
3372
  });
3373
+ _history.pushState = (function (f) { return function pushState() {
3374
+ var ret = f.apply(this, arguments);
3375
+ _dispatchEvent(_window, createDomEvent(_self_1.config.namePrefix + "pushState"));
3376
+ _dispatchEvent(_window, createDomEvent(_self_1.config.namePrefix + "locationchange"));
3377
+ return ret;
3378
+ }; })(_history.pushState);
3379
+ _history.replaceState = (function (f) { return function replaceState() {
3380
+ var ret = f.apply(this, arguments);
3381
+ _dispatchEvent(_window, createDomEvent(_self_1.config.namePrefix + "replaceState"));
3382
+ _dispatchEvent(_window, createDomEvent(_self_1.config.namePrefix + "locationchange"));
3383
+ return ret;
3384
+ }; })(_history.replaceState);
3385
+ if (_window.addEventListener) {
3386
+ _window.addEventListener(_self_1.config.namePrefix + "popstate", function () {
3387
+ _dispatchEvent(_window, createDomEvent(_self_1.config.namePrefix + "locationchange"));
3388
+ });
3389
+ _window.addEventListener(_self_1.config.namePrefix + "locationchange", function () {
3390
+ if (_properties && _properties.context && _properties.context.telemetryTrace) {
3391
+ _properties.context.telemetryTrace.traceID = generateW3CId();
3392
+ var traceLocationName = "_unknown_";
3393
+ if (_location && _location.pathname) {
3394
+ traceLocationName = _location.pathname + (_location.hash || "");
3395
+ }
3396
+ _properties.context.telemetryTrace.name = dataSanitizeString(_self_1.diagLog(), traceLocationName);
3397
+ }
3398
+ if (_currUri) {
3399
+ _prevUri = _currUri;
3400
+ _currUri = _location && _location.href || "";
3401
+ }
3402
+ else {
3403
+ _currUri = _location && _location.href || "";
3404
+ }
3405
+ setTimeout((function (uri) {
3406
+ _self_1.trackPageView({ refUri: uri, properties: { duration: 0 } });
3407
+ }).bind(_this, _prevUri), _self_1.autoRoutePVDelay);
3408
+ });
3409
+ }
4282
3410
  }
4283
- return extConfig;
4284
- }
4285
- function _updateBrowserLinkTracking(extConfig, config) {
4286
- _isBrowserLinkTrackingEnabled = extConfig.isBrowserLinkTrackingEnabled || config.isBrowserLinkTrackingEnabled;
4287
- _addDefaultTelemetryInitializers();
4288
- }
3411
+ _self.setInitialized(true);
3412
+ };
4289
3413
  function trackPageVisitTime(pageName, pageUrl, pageVisitTime) {
4290
3414
  var properties = { PageName: pageName, PageUrl: pageUrl };
4291
3415
  _self.trackMetric({
@@ -4296,11 +3420,11 @@
4296
3420
  sampleCount: 1
4297
3421
  }, properties);
4298
3422
  }
4299
- function _addDefaultTelemetryInitializers() {
4300
- if (!_browserLinkInitializerAdded && _isBrowserLinkTrackingEnabled) {
3423
+ function _addDefaultTelemetryInitializers(configGetters) {
3424
+ if (!configGetters.isBrowserLinkTrackingEnabled()) {
4301
3425
  var browserLinkPaths_1 = ["/browserLinkSignalR/", "/__browserLink/"];
4302
3426
  var dropBrowserLinkRequests = function (envelope) {
4303
- if (_isBrowserLinkTrackingEnabled && envelope.baseType === RemoteDependencyData.dataType) {
3427
+ if (envelope.baseType === RemoteDependencyData.dataType) {
4304
3428
  var remoteData = envelope.baseData;
4305
3429
  if (remoteData) {
4306
3430
  for (var i = 0; i < browserLinkPaths_1.length; i++) {
@@ -4312,150 +3436,72 @@
4312
3436
  }
4313
3437
  return true;
4314
3438
  };
4315
- _self.addTelemetryInitializer(dropBrowserLinkRequests);
4316
- _browserLinkInitializerAdded = true;
3439
+ _addTelemetryInitializer(dropBrowserLinkRequests);
4317
3440
  }
4318
3441
  }
3442
+ function _addTelemetryInitializer(telemetryInitializer) {
3443
+ _self._telemetryInitializers.push(telemetryInitializer);
3444
+ }
4319
3445
  function _sendCORSException(exception, properties) {
4320
3446
  var telemetryItem = TelemetryItemCreator.create(exception, Exception.dataType, Exception.envelopeType, _self.diagLog(), properties);
4321
3447
  _self.core.track(telemetryItem);
4322
3448
  }
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
3449
  });
4450
3450
  return _this;
4451
3451
  }
4452
- AnalyticsPlugin.Version = "2.7.5-nightly.2204-03";
4453
- AnalyticsPlugin.getDefaultConfig = _getDefaultConfig;
4454
- return AnalyticsPlugin;
3452
+ ApplicationInsights.getDefaultConfig = function (config) {
3453
+ if (!config) {
3454
+ config = {};
3455
+ }
3456
+ config.sessionRenewalMs = 30 * 60 * 1000;
3457
+ config.sessionExpirationMs = 24 * 60 * 60 * 1000;
3458
+ config.disableExceptionTracking = stringToBoolOrDefault(config.disableExceptionTracking);
3459
+ config.autoTrackPageVisitTime = stringToBoolOrDefault(config.autoTrackPageVisitTime);
3460
+ config.overridePageViewDuration = stringToBoolOrDefault(config.overridePageViewDuration);
3461
+ config.enableUnhandledPromiseRejectionTracking = stringToBoolOrDefault(config.enableUnhandledPromiseRejectionTracking);
3462
+ if (isNaN(config.samplingPercentage) || config.samplingPercentage <= 0 || config.samplingPercentage >= 100) {
3463
+ config.samplingPercentage = 100;
3464
+ }
3465
+ config.isStorageUseDisabled = stringToBoolOrDefault(config.isStorageUseDisabled);
3466
+ config.isBrowserLinkTrackingEnabled = stringToBoolOrDefault(config.isBrowserLinkTrackingEnabled);
3467
+ config.enableAutoRouteTracking = stringToBoolOrDefault(config.enableAutoRouteTracking);
3468
+ config.namePrefix = config.namePrefix || "";
3469
+ config.enableDebug = stringToBoolOrDefault(config.enableDebug);
3470
+ config.disableFlushOnBeforeUnload = stringToBoolOrDefault(config.disableFlushOnBeforeUnload);
3471
+ config.disableFlushOnUnload = stringToBoolOrDefault(config.disableFlushOnUnload, config.disableFlushOnBeforeUnload);
3472
+ return config;
3473
+ };
3474
+ ApplicationInsights.Version = "2.7.6";
3475
+ return ApplicationInsights;
4455
3476
  }(BaseTelemetryPlugin));
3477
+ var Timing = /** @class */ (function () {
3478
+ function Timing(logger, name) {
3479
+ var _self = this;
3480
+ var _events = {};
3481
+ _self.start = function (name) {
3482
+ if (typeof _events[name] !== "undefined") {
3483
+ logger.throwInternal(LoggingSeverity.WARNING, _InternalMessageId.StartCalledMoreThanOnce, "start was called more than once for this event without calling stop.", { name: name, key: name }, true);
3484
+ }
3485
+ _events[name] = +new Date;
3486
+ };
3487
+ _self.stop = function (name, url, properties, measurements) {
3488
+ var start = _events[name];
3489
+ if (isNaN(start)) {
3490
+ logger.throwInternal(LoggingSeverity.WARNING, _InternalMessageId.StopCalledWithoutStart, "stop was called without a corresponding start.", { name: name, key: name }, true);
3491
+ }
3492
+ else {
3493
+ var end = +new Date;
3494
+ var duration = dateTimeUtilsDuration(start, end);
3495
+ _self.action(name, url, duration, properties, measurements);
3496
+ }
3497
+ delete _events[name];
3498
+ _events[name] = undefined;
3499
+ };
3500
+ }
3501
+ return Timing;
3502
+ }());
4456
3503
 
4457
- exports.AnalyticsPlugin = AnalyticsPlugin;
4458
- exports.ApplicationInsights = AnalyticsPlugin;
3504
+ exports.ApplicationInsights = ApplicationInsights;
4459
3505
 
4460
3506
  (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
3507