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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (160) hide show
  1. package/browser/applicationinsights-core-js.integrity.json +9 -9
  2. package/browser/applicationinsights-core-js.js +766 -1967
  3. package/browser/applicationinsights-core-js.js.map +1 -1
  4. package/browser/applicationinsights-core-js.min.js +2 -2
  5. package/browser/applicationinsights-core-js.min.js.map +1 -1
  6. package/dist/applicationinsights-core-js.api.json +9840 -16439
  7. package/dist/applicationinsights-core-js.api.md +48 -425
  8. package/dist/applicationinsights-core-js.d.ts +123 -784
  9. package/dist/applicationinsights-core-js.js +766 -1967
  10. package/dist/applicationinsights-core-js.js.map +1 -1
  11. package/dist/applicationinsights-core-js.min.js +2 -2
  12. package/dist/applicationinsights-core-js.min.js.map +1 -1
  13. package/dist/applicationinsights-core-js.rollup.d.ts +123 -784
  14. package/dist-esm/JavaScriptSDK/AppInsightsCore.js +69 -3
  15. package/dist-esm/JavaScriptSDK/AppInsightsCore.js.map +1 -1
  16. package/dist-esm/JavaScriptSDK/BaseCore.js +99 -496
  17. package/dist-esm/JavaScriptSDK/BaseCore.js.map +1 -1
  18. package/dist-esm/JavaScriptSDK/BaseTelemetryPlugin.js +21 -120
  19. package/dist-esm/JavaScriptSDK/BaseTelemetryPlugin.js.map +1 -1
  20. package/dist-esm/JavaScriptSDK/ChannelController.js +87 -202
  21. package/dist-esm/JavaScriptSDK/ChannelController.js.map +1 -1
  22. package/dist-esm/JavaScriptSDK/Constants.js +1 -1
  23. package/dist-esm/JavaScriptSDK/CookieMgr.js +4 -4
  24. package/dist-esm/JavaScriptSDK/CookieMgr.js.map +1 -1
  25. package/dist-esm/JavaScriptSDK/CoreUtils.js +148 -7
  26. package/dist-esm/JavaScriptSDK/CoreUtils.js.map +1 -1
  27. package/dist-esm/JavaScriptSDK/DbgExtensionUtils.js +1 -1
  28. package/dist-esm/JavaScriptSDK/DiagnosticLogger.js +14 -27
  29. package/dist-esm/JavaScriptSDK/DiagnosticLogger.js.map +1 -1
  30. package/dist-esm/JavaScriptSDK/EnvUtils.js +12 -13
  31. package/dist-esm/JavaScriptSDK/EnvUtils.js.map +1 -1
  32. package/dist-esm/JavaScriptSDK/HelperFuncs.js +86 -89
  33. package/dist-esm/JavaScriptSDK/HelperFuncs.js.map +1 -1
  34. package/dist-esm/JavaScriptSDK/InstrumentHooks.js +1 -3
  35. package/dist-esm/JavaScriptSDK/InstrumentHooks.js.map +1 -1
  36. package/dist-esm/JavaScriptSDK/NotificationManager.js +42 -37
  37. package/dist-esm/JavaScriptSDK/NotificationManager.js.map +1 -1
  38. package/dist-esm/JavaScriptSDK/PerfManager.js +1 -1
  39. package/dist-esm/JavaScriptSDK/ProcessTelemetryContext.js +119 -430
  40. package/dist-esm/JavaScriptSDK/ProcessTelemetryContext.js.map +1 -1
  41. package/dist-esm/JavaScriptSDK/RandomHelper.js +4 -30
  42. package/dist-esm/JavaScriptSDK/RandomHelper.js.map +1 -1
  43. package/dist-esm/JavaScriptSDK/TelemetryHelpers.js +14 -60
  44. package/dist-esm/JavaScriptSDK/TelemetryHelpers.js.map +1 -1
  45. package/dist-esm/JavaScriptSDK/TelemetryPluginChain.js +76 -0
  46. package/dist-esm/JavaScriptSDK/TelemetryPluginChain.js.map +1 -0
  47. package/dist-esm/JavaScriptSDK.Enums/EventsDiscardedReason.js +1 -1
  48. package/dist-esm/JavaScriptSDK.Enums/LoggingEnums.js +96 -90
  49. package/dist-esm/JavaScriptSDK.Enums/LoggingEnums.js.map +1 -1
  50. package/dist-esm/JavaScriptSDK.Enums/SendRequestReason.js +1 -1
  51. package/dist-esm/JavaScriptSDK.Interfaces/IAppInsightsCore.js +2 -1
  52. package/dist-esm/JavaScriptSDK.Interfaces/IAppInsightsCore.js.map +1 -1
  53. package/dist-esm/JavaScriptSDK.Interfaces/IChannelControls.js +1 -1
  54. package/dist-esm/JavaScriptSDK.Interfaces/IConfiguration.js +1 -1
  55. package/dist-esm/JavaScriptSDK.Interfaces/ICookieMgr.js +1 -1
  56. package/dist-esm/JavaScriptSDK.Interfaces/IDbgExtension.js +1 -1
  57. package/dist-esm/JavaScriptSDK.Interfaces/IDiagnosticLogger.js +1 -1
  58. package/dist-esm/JavaScriptSDK.Interfaces/IInstrumentHooks.js +1 -1
  59. package/dist-esm/JavaScriptSDK.Interfaces/INotificationListener.js +1 -1
  60. package/dist-esm/JavaScriptSDK.Interfaces/INotificationManager.js +1 -1
  61. package/dist-esm/JavaScriptSDK.Interfaces/IPerfEvent.js +1 -1
  62. package/dist-esm/JavaScriptSDK.Interfaces/IPerfManager.js +1 -1
  63. package/dist-esm/JavaScriptSDK.Interfaces/IProcessTelemetryContext.js +1 -1
  64. package/dist-esm/JavaScriptSDK.Interfaces/ITelemetryItem.js +1 -1
  65. package/dist-esm/JavaScriptSDK.Interfaces/ITelemetryPlugin.js +1 -1
  66. package/dist-esm/JavaScriptSDK.Interfaces/ITelemetryPluginChain.js +2 -1
  67. package/dist-esm/JavaScriptSDK.Interfaces/ITelemetryPluginChain.js.map +1 -1
  68. package/dist-esm/applicationinsights-core-js.js +7 -12
  69. package/dist-esm/applicationinsights-core-js.js.map +1 -1
  70. package/package.json +67 -70
  71. package/src/JavaScriptSDK/AppInsightsCore.ts +101 -2
  72. package/src/JavaScriptSDK/BaseCore.ts +120 -696
  73. package/src/JavaScriptSDK/BaseTelemetryPlugin.ts +31 -205
  74. package/src/JavaScriptSDK/ChannelController.ts +103 -242
  75. package/src/JavaScriptSDK/CookieMgr.ts +5 -7
  76. package/src/JavaScriptSDK/CoreUtils.ts +172 -8
  77. package/src/JavaScriptSDK/DiagnosticLogger.ts +14 -29
  78. package/src/JavaScriptSDK/EnvUtils.ts +12 -13
  79. package/src/JavaScriptSDK/HelperFuncs.ts +97 -123
  80. package/src/JavaScriptSDK/InstrumentHooks.ts +2 -4
  81. package/src/JavaScriptSDK/NotificationManager.ts +37 -34
  82. package/src/JavaScriptSDK/PerfManager.ts +7 -4
  83. package/src/JavaScriptSDK/ProcessTelemetryContext.ts +134 -543
  84. package/src/JavaScriptSDK/RandomHelper.ts +3 -35
  85. package/src/JavaScriptSDK/TelemetryHelpers.ts +21 -83
  86. package/src/JavaScriptSDK/TelemetryPluginChain.ts +120 -0
  87. package/src/JavaScriptSDK.Enums/LoggingEnums.ts +87 -184
  88. package/src/JavaScriptSDK.Enums/SendRequestReason.ts +0 -5
  89. package/src/JavaScriptSDK.Interfaces/IAppInsightsCore.ts +2 -82
  90. package/src/JavaScriptSDK.Interfaces/IChannelControls.ts +5 -16
  91. package/src/JavaScriptSDK.Interfaces/IInstrumentHooks.ts +6 -16
  92. package/src/JavaScriptSDK.Interfaces/IProcessTelemetryContext.ts +14 -94
  93. package/src/JavaScriptSDK.Interfaces/ITelemetryPlugin.ts +10 -28
  94. package/src/JavaScriptSDK.Interfaces/ITelemetryPluginChain.ts +11 -9
  95. package/types/JavaScriptSDK/AppInsightsCore.d.ts +21 -0
  96. package/types/JavaScriptSDK/BaseCore.d.ts +3 -81
  97. package/types/JavaScriptSDK/BaseTelemetryPlugin.d.ts +10 -53
  98. package/types/JavaScriptSDK/ChannelController.d.ts +17 -16
  99. package/types/JavaScriptSDK/CoreUtils.d.ts +48 -1
  100. package/types/JavaScriptSDK/DiagnosticLogger.d.ts +0 -10
  101. package/types/JavaScriptSDK/HelperFuncs.d.ts +32 -33
  102. package/types/JavaScriptSDK/PerfManager.d.ts +1 -1
  103. package/types/JavaScriptSDK/ProcessTelemetryContext.d.ts +6 -69
  104. package/types/JavaScriptSDK/RandomHelper.d.ts +0 -6
  105. package/types/JavaScriptSDK/TelemetryHelpers.d.ts +3 -23
  106. package/types/JavaScriptSDK/TelemetryPluginChain.d.ts +32 -0
  107. package/types/JavaScriptSDK.Enums/LoggingEnums.d.ts +2 -91
  108. package/types/JavaScriptSDK.Enums/SendRequestReason.d.ts +0 -4
  109. package/types/JavaScriptSDK.Interfaces/IAppInsightsCore.d.ts +1 -72
  110. package/types/JavaScriptSDK.Interfaces/IChannelControls.d.ts +5 -16
  111. package/types/JavaScriptSDK.Interfaces/IInstrumentHooks.d.ts +0 -9
  112. package/types/JavaScriptSDK.Interfaces/IProcessTelemetryContext.d.ts +11 -82
  113. package/types/JavaScriptSDK.Interfaces/ITelemetryPlugin.d.ts +8 -25
  114. package/types/JavaScriptSDK.Interfaces/ITelemetryPluginChain.d.ts +10 -9
  115. package/types/applicationinsights-core-js.d.ts +9 -18
  116. package/types/tsdoc-metadata.json +1 -1
  117. package/dist-esm/JavaScriptSDK/DataCacheHelper.js +0 -93
  118. package/dist-esm/JavaScriptSDK/DataCacheHelper.js.map +0 -1
  119. package/dist-esm/JavaScriptSDK/EventHelpers.js +0 -477
  120. package/dist-esm/JavaScriptSDK/EventHelpers.js.map +0 -1
  121. package/dist-esm/JavaScriptSDK/InternalConstants.js +0 -28
  122. package/dist-esm/JavaScriptSDK/InternalConstants.js.map +0 -1
  123. package/dist-esm/JavaScriptSDK/TelemetryInitializerPlugin.js +0 -81
  124. package/dist-esm/JavaScriptSDK/TelemetryInitializerPlugin.js.map +0 -1
  125. package/dist-esm/JavaScriptSDK/UnloadHandlerContainer.js +0 -33
  126. package/dist-esm/JavaScriptSDK/UnloadHandlerContainer.js.map +0 -1
  127. package/dist-esm/JavaScriptSDK.Enums/TelemetryUnloadReason.js +0 -8
  128. package/dist-esm/JavaScriptSDK.Enums/TelemetryUnloadReason.js.map +0 -1
  129. package/dist-esm/JavaScriptSDK.Enums/TelemetryUpdateReason.js +0 -8
  130. package/dist-esm/JavaScriptSDK.Enums/TelemetryUpdateReason.js.map +0 -1
  131. package/dist-esm/JavaScriptSDK.Interfaces/ITelemetryInitializers.js +0 -6
  132. package/dist-esm/JavaScriptSDK.Interfaces/ITelemetryInitializers.js.map +0 -1
  133. package/dist-esm/JavaScriptSDK.Interfaces/ITelemetryUnloadState.js +0 -8
  134. package/dist-esm/JavaScriptSDK.Interfaces/ITelemetryUnloadState.js.map +0 -1
  135. package/dist-esm/JavaScriptSDK.Interfaces/ITelemetryUpdateState.js +0 -8
  136. package/dist-esm/JavaScriptSDK.Interfaces/ITelemetryUpdateState.js.map +0 -1
  137. package/dist-esm/JavaScriptSDK.Interfaces/IUnloadableComponent.js +0 -6
  138. package/dist-esm/JavaScriptSDK.Interfaces/IUnloadableComponent.js.map +0 -1
  139. package/src/JavaScriptSDK/DataCacheHelper.ts +0 -106
  140. package/src/JavaScriptSDK/EventHelpers.ts +0 -550
  141. package/src/JavaScriptSDK/InternalConstants.ts +0 -26
  142. package/src/JavaScriptSDK/TelemetryInitializerPlugin.ts +0 -111
  143. package/src/JavaScriptSDK/UnloadHandlerContainer.ts +0 -46
  144. package/src/JavaScriptSDK.Enums/TelemetryUnloadReason.ts +0 -27
  145. package/src/JavaScriptSDK.Enums/TelemetryUpdateReason.ts +0 -27
  146. package/src/JavaScriptSDK.Interfaces/ITelemetryInitializers.ts +0 -16
  147. package/src/JavaScriptSDK.Interfaces/ITelemetryUnloadState.ts +0 -10
  148. package/src/JavaScriptSDK.Interfaces/ITelemetryUpdateState.ts +0 -34
  149. package/src/JavaScriptSDK.Interfaces/IUnloadableComponent.ts +0 -17
  150. package/types/JavaScriptSDK/DataCacheHelper.d.ts +0 -13
  151. package/types/JavaScriptSDK/EventHelpers.d.ts +0 -154
  152. package/types/JavaScriptSDK/InternalConstants.d.ts +0 -20
  153. package/types/JavaScriptSDK/TelemetryInitializerPlugin.d.ts +0 -16
  154. package/types/JavaScriptSDK/UnloadHandlerContainer.d.ts +0 -11
  155. package/types/JavaScriptSDK.Enums/TelemetryUnloadReason.d.ts +0 -21
  156. package/types/JavaScriptSDK.Enums/TelemetryUpdateReason.d.ts +0 -20
  157. package/types/JavaScriptSDK.Interfaces/ITelemetryInitializers.d.ts +0 -13
  158. package/types/JavaScriptSDK.Interfaces/ITelemetryUnloadState.d.ts +0 -6
  159. package/types/JavaScriptSDK.Interfaces/ITelemetryUpdateState.d.ts +0 -22
  160. package/types/JavaScriptSDK.Interfaces/IUnloadableComponent.d.ts +0 -13
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * Application Insights JavaScript SDK - Core, 2.7.5-nightly.2203-03
2
+ * Application Insights JavaScript SDK - Core, 2.7.5
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  */
5
5
  (function (global, factory) {
@@ -74,9 +74,7 @@
74
74
  (getGlobal() || {})["Reflect"];
75
75
  var extendStaticsFn = function (d, b) {
76
76
  extendStaticsFn = ObjClass["setPrototypeOf"] ||
77
- ({ __proto__: [] } instanceof Array && function (d, b) {
78
- d.__proto__ = b;
79
- }) ||
77
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
80
78
  function (d, b) {
81
79
  for (var p in b) {
82
80
  if (b[strShimHasOwnProperty](p)) {
@@ -91,9 +89,7 @@
91
89
  throwTypeError("Class extends value " + String(b) + " is not a constructor or null");
92
90
  }
93
91
  extendStaticsFn(d, b);
94
- function __() {
95
- this.constructor = d;
96
- }
92
+ function __() { this.constructor = d; }
97
93
  d[strShimPrototype] = b === null ? objCreateFn(b) : (__[strShimPrototype] = b[strShimPrototype], new __());
98
94
  }
99
95
  function __spreadArrayFn(to, from) {
@@ -104,7 +100,7 @@
104
100
  }
105
101
 
106
102
  /*!
107
- * Microsoft Dynamic Proto Utility, 1.1.4
103
+ * Microsoft Dynamic Proto Utility, 1.1.5
108
104
  * Copyright (c) Microsoft and contributors. All rights reserved.
109
105
  */
110
106
  var Constructor = 'constructor';
@@ -117,6 +113,7 @@
117
113
  var DynInstChkTag = '_dynInstChk';
118
114
  var DynAllowInstChkTag = DynInstChkTag;
119
115
  var DynProtoDefaultOptions = '_dfOpts';
116
+ var DynProtoPolyProto = "_dynProto";
120
117
  var UnknownValue = '_unknown_';
121
118
  var str__Proto$1 = "__proto__";
122
119
  var strUseBaseInst = 'useBaseInst';
@@ -138,8 +135,11 @@
138
135
  if (_objGetPrototypeOf$1) {
139
136
  return _objGetPrototypeOf$1(target);
140
137
  }
141
- var newProto = target[str__Proto$1] || target[Prototype] || (target[Constructor] ? target[Constructor][Prototype] : null);
138
+ var newProto = target[DynProtoPolyProto] || target[str__Proto$1] || target[Prototype] || (target[Constructor] ? target[Constructor][Prototype] : null);
142
139
  if (newProto) {
140
+ if (!target[DynProtoPolyProto]) {
141
+ target[DynProtoPolyProto] = newProto;
142
+ }
143
143
  return newProto;
144
144
  }
145
145
  }
@@ -298,8 +298,9 @@
298
298
  visited.push(thisProto);
299
299
  thisProto = _getObjProto$1(thisProto);
300
300
  }
301
+ return false;
301
302
  }
302
- return false;
303
+ return true;
303
304
  }
304
305
  function _getObjName(target, unknownValue) {
305
306
  if (_hasOwnProperty(target, Prototype)) {
@@ -344,27 +345,101 @@
344
345
  };
345
346
  dynamicProto[DynProtoDefaultOptions] = perfDefaults;
346
347
 
347
- var strEmpty = "";
348
- var strProcessTelemetry = "processTelemetry";
349
- var strPriority = "priority";
350
- var strSetNextPlugin = "setNextPlugin";
351
- var strIsInitialized = "isInitialized";
352
- var strTeardown = "teardown";
353
- var strCore = "core";
354
- var strUpdate = "update";
355
- var strDisabled = "disabled";
356
- var strDoTeardown = "_doTeardown";
357
- var strProcessNext = "processNext";
358
- var strResume = "resume";
359
- var strPause = "pause";
360
- var strNotificationListener = "NotificationListener";
361
- var strAddNotificationListener = "add" + strNotificationListener;
362
- var strRemoveNotificationListener = "remove" + strNotificationListener;
363
- var strEventsSent = "eventsSent";
364
- var strEventsDiscarded = "eventsDiscarded";
365
- var strEventsSendRequest = "eventsSendRequest";
366
- var strPerfEvent = "perfEvent";
348
+ exports.LoggingSeverity = void 0;
349
+ (function (LoggingSeverity) {
350
+ LoggingSeverity[LoggingSeverity["CRITICAL"] = 1] = "CRITICAL";
351
+ LoggingSeverity[LoggingSeverity["WARNING"] = 2] = "WARNING";
352
+ })(exports.LoggingSeverity || (exports.LoggingSeverity = {}));
353
+ var _InternalMessageId = {
354
+ BrowserDoesNotSupportLocalStorage: 0,
355
+ BrowserCannotReadLocalStorage: 1,
356
+ BrowserCannotReadSessionStorage: 2,
357
+ BrowserCannotWriteLocalStorage: 3,
358
+ BrowserCannotWriteSessionStorage: 4,
359
+ BrowserFailedRemovalFromLocalStorage: 5,
360
+ BrowserFailedRemovalFromSessionStorage: 6,
361
+ CannotSendEmptyTelemetry: 7,
362
+ ClientPerformanceMathError: 8,
363
+ ErrorParsingAISessionCookie: 9,
364
+ ErrorPVCalc: 10,
365
+ ExceptionWhileLoggingError: 11,
366
+ FailedAddingTelemetryToBuffer: 12,
367
+ FailedMonitorAjaxAbort: 13,
368
+ FailedMonitorAjaxDur: 14,
369
+ FailedMonitorAjaxOpen: 15,
370
+ FailedMonitorAjaxRSC: 16,
371
+ FailedMonitorAjaxSend: 17,
372
+ FailedMonitorAjaxGetCorrelationHeader: 18,
373
+ FailedToAddHandlerForOnBeforeUnload: 19,
374
+ FailedToSendQueuedTelemetry: 20,
375
+ FailedToReportDataLoss: 21,
376
+ FlushFailed: 22,
377
+ MessageLimitPerPVExceeded: 23,
378
+ MissingRequiredFieldSpecification: 24,
379
+ NavigationTimingNotSupported: 25,
380
+ OnError: 26,
381
+ SessionRenewalDateIsZero: 27,
382
+ SenderNotInitialized: 28,
383
+ StartTrackEventFailed: 29,
384
+ StopTrackEventFailed: 30,
385
+ StartTrackFailed: 31,
386
+ StopTrackFailed: 32,
387
+ TelemetrySampledAndNotSent: 33,
388
+ TrackEventFailed: 34,
389
+ TrackExceptionFailed: 35,
390
+ TrackMetricFailed: 36,
391
+ TrackPVFailed: 37,
392
+ TrackPVFailedCalc: 38,
393
+ TrackTraceFailed: 39,
394
+ TransmissionFailed: 40,
395
+ FailedToSetStorageBuffer: 41,
396
+ FailedToRestoreStorageBuffer: 42,
397
+ InvalidBackendResponse: 43,
398
+ FailedToFixDepricatedValues: 44,
399
+ InvalidDurationValue: 45,
400
+ TelemetryEnvelopeInvalid: 46,
401
+ CreateEnvelopeError: 47,
402
+ CannotSerializeObject: 48,
403
+ CannotSerializeObjectNonSerializable: 49,
404
+ CircularReferenceDetected: 50,
405
+ ClearAuthContextFailed: 51,
406
+ ExceptionTruncated: 52,
407
+ IllegalCharsInName: 53,
408
+ ItemNotInArray: 54,
409
+ MaxAjaxPerPVExceeded: 55,
410
+ MessageTruncated: 56,
411
+ NameTooLong: 57,
412
+ SampleRateOutOfRange: 58,
413
+ SetAuthContextFailed: 59,
414
+ SetAuthContextFailedAccountName: 60,
415
+ StringValueTooLong: 61,
416
+ StartCalledMoreThanOnce: 62,
417
+ StopCalledWithoutStart: 63,
418
+ TelemetryInitializerFailed: 64,
419
+ TrackArgumentsNotSpecified: 65,
420
+ UrlTooLong: 66,
421
+ SessionStorageBufferFull: 67,
422
+ CannotAccessCookie: 68,
423
+ IdTooLong: 69,
424
+ InvalidEvent: 70,
425
+ FailedMonitorAjaxSetRequestHeader: 71,
426
+ SendBrowserInfoOnUserInit: 72,
427
+ PluginException: 73,
428
+ NotificationException: 74,
429
+ SnippetScriptLoadFailure: 99,
430
+ InvalidInstrumentationKey: 100,
431
+ CannotParseAiBlobValue: 101,
432
+ InvalidContentBlob: 102,
433
+ TrackPageActionEventFailed: 103,
434
+ FailedAddingCustomDefinedRequestContext: 104,
435
+ InMemoryStorageBufferFull: 105
436
+ };
367
437
 
438
+ var strOnPrefix = "on";
439
+ var strAttachEvent = "attachEvent";
440
+ var strAddEventHelper = "addEventListener";
441
+ var strDetachEvent = "detachEvent";
442
+ var strRemoveEventListener = "removeEventListener";
368
443
  var strToISOString = "toISOString";
369
444
  var cStrEndsWith = "endsWith";
370
445
  var cStrStartsWith = "startsWith";
@@ -375,7 +450,7 @@
375
450
  var strToString = "toString";
376
451
  var str__Proto = "__proto__";
377
452
  var strConstructor = "constructor";
378
- var _objDefineProperty$1 = ObjDefineProperty;
453
+ var _objDefineProperty = ObjDefineProperty;
379
454
  var _objFreeze = ObjClass.freeze;
380
455
  var _objSeal = ObjClass.seal;
381
456
  var _objKeys = ObjClass.keys;
@@ -388,7 +463,7 @@
388
463
  var _isArray = Array.isArray;
389
464
  var _objToString = ObjProto[strToString];
390
465
  var _fnToString = ObjHasOwnProperty[strToString];
391
- var _objFunctionString = _fnToString.call(ObjClass);
466
+ _fnToString.call(ObjClass);
392
467
  var rCamelCase = /-([a-z])/g;
393
468
  var rNormalizeInvalid = /([^\w\d_$])/g;
394
469
  var rLeadingNumeric = /^(\d+[\w\d_$])/;
@@ -405,9 +480,6 @@
405
480
  }
406
481
  return null;
407
482
  }
408
- function objToString(obj) {
409
- return _objToString.call(obj);
410
- }
411
483
  function isTypeof(value, theType) {
412
484
  return typeof value === theType;
413
485
  }
@@ -432,6 +504,40 @@
432
504
  function isFunction(value) {
433
505
  return !!(value && typeof value === strShimFunction);
434
506
  }
507
+ function attachEvent(obj, eventNameWithoutOn, handlerRef, useCapture) {
508
+ if (useCapture === void 0) { useCapture = false; }
509
+ var result = false;
510
+ if (!isNullOrUndefined(obj)) {
511
+ try {
512
+ if (!isNullOrUndefined(obj[strAddEventHelper])) {
513
+ obj[strAddEventHelper](eventNameWithoutOn, handlerRef, useCapture);
514
+ result = true;
515
+ }
516
+ else if (!isNullOrUndefined(obj[strAttachEvent])) {
517
+ obj[strAttachEvent](strOnPrefix + eventNameWithoutOn, handlerRef);
518
+ result = true;
519
+ }
520
+ }
521
+ catch (e) {
522
+ }
523
+ }
524
+ return result;
525
+ }
526
+ function detachEvent(obj, eventNameWithoutOn, handlerRef, useCapture) {
527
+ if (useCapture === void 0) { useCapture = false; }
528
+ if (!isNullOrUndefined(obj)) {
529
+ try {
530
+ if (!isNullOrUndefined(obj[strRemoveEventListener])) {
531
+ obj[strRemoveEventListener](eventNameWithoutOn, handlerRef, useCapture);
532
+ }
533
+ else if (!isNullOrUndefined(obj[strDetachEvent])) {
534
+ obj[strDetachEvent](strOnPrefix + eventNameWithoutOn, handlerRef);
535
+ }
536
+ }
537
+ catch (e) {
538
+ }
539
+ }
540
+ }
435
541
  function normalizeJsName(name) {
436
542
  var value = name;
437
543
  if (value && isString(value)) {
@@ -525,22 +631,6 @@
525
631
  function isSymbol(value) {
526
632
  return typeof value === "symbol";
527
633
  }
528
- function isPlainObject(value) {
529
- var result = false;
530
- if (value && typeof value === "object") {
531
- var proto = _objGetPrototypeOf ? _objGetPrototypeOf(value) : _getObjProto(value);
532
- if (!proto) {
533
- result = true;
534
- }
535
- else {
536
- if (proto[strConstructor] && ObjHasOwnProperty.call(proto, strConstructor)) {
537
- proto = proto[strConstructor];
538
- }
539
- result = typeof proto === strShimFunction && _fnToString.call(proto) === _objFunctionString;
540
- }
541
- }
542
- return result;
543
- }
544
634
  function toISOString(date) {
545
635
  if (date) {
546
636
  return _dataToISOString ? date[strToISOString]() : _toISOStringPoly(date);
@@ -686,7 +776,7 @@
686
776
  return result;
687
777
  }
688
778
  function objDefineAccessors(target, prop, getProp, setProp) {
689
- if (_objDefineProperty$1) {
779
+ if (_objDefineProperty) {
690
780
  try {
691
781
  var descriptor = {
692
782
  enumerable: true,
@@ -698,7 +788,7 @@
698
788
  if (setProp) {
699
789
  descriptor.set = setProp;
700
790
  }
701
- _objDefineProperty$1(target, prop, descriptor);
791
+ _objDefineProperty(target, prop, descriptor);
702
792
  return true;
703
793
  }
704
794
  catch (e) {
@@ -719,7 +809,7 @@
719
809
  if (isError(object)) {
720
810
  return object.name;
721
811
  }
722
- return strEmpty;
812
+ return "";
723
813
  }
724
814
  function setValue(target, field, value, valChk, srcChk) {
725
815
  var theValue = value;
@@ -755,33 +845,19 @@
755
845
  function throwError(message) {
756
846
  throw new Error(message);
757
847
  }
758
- function _createProxyFunction(source, funcName) {
759
- var srcFunc = null;
760
- var src = null;
761
- if (isFunction(source)) {
762
- srcFunc = source;
763
- }
764
- else {
765
- src = source;
766
- }
767
- return function () {
768
- var originalArguments = arguments;
769
- if (srcFunc) {
770
- src = srcFunc();
771
- }
772
- if (src) {
773
- return src[funcName].apply(src, originalArguments);
774
- }
775
- };
776
- }
777
848
  function proxyAssign(target, source, chkSet) {
778
- if (target && source && isObject(target) && isObject(source)) {
849
+ if (target && source && target !== source && isObject(target) && isObject(source)) {
779
850
  var _loop_1 = function (field) {
780
851
  if (isString(field)) {
781
852
  var value = source[field];
782
853
  if (isFunction(value)) {
783
854
  if (!chkSet || chkSet(field, true, source, target)) {
784
- target[field] = _createProxyFunction(source, field);
855
+ target[field] = (function (funcName) {
856
+ return function () {
857
+ var originalArguments = arguments;
858
+ return source[funcName].apply(source, originalArguments);
859
+ };
860
+ })(field);
785
861
  }
786
862
  }
787
863
  else if (!chkSet || chkSet(field, false, source, target)) {
@@ -804,25 +880,6 @@
804
880
  }
805
881
  return target;
806
882
  }
807
- function proxyFunctionAs(target, name, source, theFunc, overwriteTarget) {
808
- if (overwriteTarget === void 0) { overwriteTarget = true; }
809
- if (target && name && source) {
810
- if (overwriteTarget || isUndefined(target[name])) {
811
- target[name] = _createProxyFunction(source, theFunc);
812
- }
813
- }
814
- }
815
- function proxyFunctions(target, source, functionsToProxy, overwriteTarget) {
816
- if (overwriteTarget === void 0) { overwriteTarget = true; }
817
- if (target && source && isObject(target) && isArray(functionsToProxy)) {
818
- arrForEach(functionsToProxy, function (theFuncName) {
819
- if (isString(theFuncName)) {
820
- proxyFunctionAs(target, theFuncName, source, theFuncName, overwriteTarget);
821
- }
822
- });
823
- }
824
- return target;
825
- }
826
883
  function createClassFromInterface(defaults) {
827
884
  return /** @class */ (function () {
828
885
  function class_1() {
@@ -836,67 +893,12 @@
836
893
  return class_1;
837
894
  }());
838
895
  }
839
- function createEnumStyle(values) {
840
- var enumClass = {};
841
- objForEachKey(values, function (field, value) {
842
- enumClass[field] = value;
843
- if (!isUndefined(enumClass[value])) {
844
- throwError("[" + value + "] exists for " + field);
845
- }
846
- enumClass[value] = field;
847
- });
848
- return objFreeze(enumClass);
849
- }
850
896
  function optimizeObject(theObject) {
851
897
  if (theObject && ObjAssign) {
852
898
  theObject = ObjClass(ObjAssign({}, theObject));
853
899
  }
854
900
  return theObject;
855
901
  }
856
- function objExtend(obj1, obj2, obj3, obj4, obj5, obj6) {
857
- var theArgs = arguments;
858
- var extended = theArgs[0] || {};
859
- var argLen = theArgs.length;
860
- var deep = false;
861
- var idx = 1;
862
- if (argLen > 0 && isBoolean(extended)) {
863
- deep = extended;
864
- extended = theArgs[idx] || {};
865
- idx++;
866
- }
867
- if (!isObject(extended)) {
868
- extended = {};
869
- }
870
- for (; idx < argLen; idx++) {
871
- var arg = theArgs[idx];
872
- var isArgArray = isArray(arg);
873
- var isArgObj = isObject(arg);
874
- for (var prop in arg) {
875
- var propOk = (isArgArray && (prop in arg)) || (isArgObj && (ObjHasOwnProperty.call(arg, prop)));
876
- if (!propOk) {
877
- continue;
878
- }
879
- var newValue = arg[prop];
880
- var isNewArray = void 0;
881
- if (deep && newValue && ((isNewArray = isArray(newValue)) || isPlainObject(newValue))) {
882
- var clone = extended[prop];
883
- if (isNewArray) {
884
- if (!isArray(clone)) {
885
- clone = [];
886
- }
887
- }
888
- else if (!isPlainObject(clone)) {
889
- clone = {};
890
- }
891
- newValue = objExtend(deep, clone, newValue);
892
- }
893
- if (newValue !== undefined) {
894
- extended[prop] = newValue;
895
- }
896
- }
897
- }
898
- return extended;
899
- }
900
902
 
901
903
  var strWindow = "window";
902
904
  var strDocument = "document";
@@ -912,7 +914,6 @@
912
914
  var strReactNative = "ReactNative";
913
915
  var strMsie = "msie";
914
916
  var strTrident = "trident/";
915
- var strXMLHttpRequest = "XMLHttpRequest";
916
917
  var _isTrident = null;
917
918
  var _navUserAgentCheck = null;
918
919
  var _enableMocks = false;
@@ -1039,7 +1040,7 @@
1039
1040
  var nav = getNavigator();
1040
1041
  if (nav && (nav.userAgent !== _navUserAgentCheck || _isTrident === null)) {
1041
1042
  _navUserAgentCheck = nav.userAgent;
1042
- var userAgent = (_navUserAgentCheck || strEmpty).toLowerCase();
1043
+ var userAgent = (_navUserAgentCheck || "").toLowerCase();
1043
1044
  _isTrident = (strContains(userAgent, strMsie) || strContains(userAgent, strTrident));
1044
1045
  }
1045
1046
  return _isTrident;
@@ -1048,9 +1049,9 @@
1048
1049
  if (userAgentStr === void 0) { userAgentStr = null; }
1049
1050
  if (!userAgentStr) {
1050
1051
  var navigator_1 = getNavigator() || {};
1051
- userAgentStr = navigator_1 ? (navigator_1.userAgent || strEmpty).toLowerCase() : strEmpty;
1052
+ userAgentStr = navigator_1 ? (navigator_1.userAgent || "").toLowerCase() : "";
1052
1053
  }
1053
- var ua = (userAgentStr || strEmpty).toLowerCase();
1054
+ var ua = (userAgentStr || "").toLowerCase();
1054
1055
  if (strContains(ua, strMsie)) {
1055
1056
  var doc = getDocument() || {};
1056
1057
  return Math.max(parseInt(ua.split(strMsie)[1]), (doc[strDocumentMode] || 0));
@@ -1065,7 +1066,7 @@
1065
1066
  }
1066
1067
  function dumpObj(object) {
1067
1068
  var objectTypeDump = Object[strShimPrototype].toString.call(object);
1068
- var propertyValueDump = strEmpty;
1069
+ var propertyValueDump = "";
1069
1070
  if (objectTypeDump === "[object Error]") {
1070
1071
  propertyValueDump = "{ stack: '" + object.stack + "', message: '" + object.message + "', name: '" + object.name + "'";
1071
1072
  }
@@ -1077,9 +1078,9 @@
1077
1078
  function isSafari(userAgentStr) {
1078
1079
  if (!userAgentStr || !isString(userAgentStr)) {
1079
1080
  var navigator_2 = getNavigator() || {};
1080
- userAgentStr = navigator_2 ? (navigator_2.userAgent || strEmpty).toLowerCase() : strEmpty;
1081
+ userAgentStr = navigator_2 ? (navigator_2.userAgent || "").toLowerCase() : "";
1081
1082
  }
1082
- var ua = (userAgentStr || strEmpty).toLowerCase();
1083
+ var ua = (userAgentStr || "").toLowerCase();
1083
1084
  return (ua.indexOf("safari") >= 0);
1084
1085
  }
1085
1086
  function isBeaconsSupported() {
@@ -1091,7 +1092,8 @@
1091
1092
  function isFetchSupported(withKeepAlive) {
1092
1093
  var isSupported = false;
1093
1094
  try {
1094
- isSupported = !!getGlobalInst("fetch");
1095
+ var fetchApi = getGlobalInst("fetch");
1096
+ isSupported = !!fetchApi;
1095
1097
  var request = getGlobalInst("Request");
1096
1098
  if (isSupported && withKeepAlive && request) {
1097
1099
  isSupported = _hasProperty(request, "keepalive");
@@ -1103,9 +1105,9 @@
1103
1105
  }
1104
1106
  function useXDomainRequest() {
1105
1107
  if (_useXDomainRequest === null) {
1106
- _useXDomainRequest = (typeof XDomainRequest !== strShimUndefined);
1108
+ _useXDomainRequest = (typeof XDomainRequest !== "undefined");
1107
1109
  if (_useXDomainRequest && isXhrSupported()) {
1108
- _useXDomainRequest = _useXDomainRequest && !_hasProperty(getGlobalInst(strXMLHttpRequest), "withCredentials");
1110
+ _useXDomainRequest = _useXDomainRequest && !_hasProperty(getGlobalInst("XMLHttpRequest"), "withCredentials");
1109
1111
  }
1110
1112
  }
1111
1113
  return _useXDomainRequest;
@@ -1113,7 +1115,7 @@
1113
1115
  function isXhrSupported() {
1114
1116
  var isSupported = false;
1115
1117
  try {
1116
- var xmlHttpRequest = getGlobalInst(strXMLHttpRequest);
1118
+ var xmlHttpRequest = getGlobalInst("XMLHttpRequest");
1117
1119
  isSupported = !!xmlHttpRequest;
1118
1120
  }
1119
1121
  catch (e) {
@@ -1167,9 +1169,9 @@
1167
1169
  var strWarnToConsole = "warnToConsole";
1168
1170
  function _sanitizeDiagnosticText(text) {
1169
1171
  if (text) {
1170
- return "\"" + text.replace(/\"/g, strEmpty) + "\"";
1172
+ return "\"" + text.replace(/\"/g, "") + "\"";
1171
1173
  }
1172
- return strEmpty;
1174
+ return "";
1173
1175
  }
1174
1176
  function _logToConsole(func, message) {
1175
1177
  var theConsole = getConsole();
@@ -1191,12 +1193,12 @@
1191
1193
  _self.message =
1192
1194
  (isUserAct ? AiUserActionablePrefix : AiNonUserActionablePrefix) +
1193
1195
  msgId;
1194
- var strProps = strEmpty;
1196
+ var strProps = "";
1195
1197
  if (hasJSON()) {
1196
1198
  strProps = getJSON().stringify(properties);
1197
1199
  }
1198
- var diagnosticText = (msg ? " message:" + _sanitizeDiagnosticText(msg) : strEmpty) +
1199
- (properties ? " props:" + _sanitizeDiagnosticText(strProps) : strEmpty);
1200
+ var diagnosticText = (msg ? " message:" + _sanitizeDiagnosticText(msg) : "") +
1201
+ (properties ? " props:" + _sanitizeDiagnosticText(strProps) : "");
1200
1202
  _self.message += diagnosticText;
1201
1203
  }
1202
1204
  _InternalLogMessage.dataType = "MessageData";
@@ -1223,10 +1225,10 @@
1223
1225
  if (isUserAct === void 0) { isUserAct = false; }
1224
1226
  var message = new _InternalLogMessage(msgId, msg, isUserAct, properties);
1225
1227
  if (_self.enableDebugExceptions()) {
1226
- throw message;
1228
+ throw dumpObj(message);
1227
1229
  }
1228
1230
  else {
1229
- var logFunc = severity === 1 ? strErrorToConsole : strWarnToConsole;
1231
+ var logFunc = severity === exports.LoggingSeverity.CRITICAL ? strErrorToConsole : strWarnToConsole;
1230
1232
  if (!isUndefined(message.message)) {
1231
1233
  var logLevel = _self.consoleLoggingLevel();
1232
1234
  if (isUserAct) {
@@ -1244,7 +1246,7 @@
1244
1246
  _self.logInternalMessage(severity, message);
1245
1247
  }
1246
1248
  else {
1247
- _debugExtMsg("throw" + (severity === 1 ? "Critical" : "Warning"), message);
1249
+ _debugExtMsg("throw" + (severity === exports.LoggingSeverity.CRITICAL ? "Critical" : "Warning"), message);
1248
1250
  }
1249
1251
  }
1250
1252
  };
@@ -1276,13 +1278,13 @@
1276
1278
  if (severity <= _self.telemetryLoggingLevel()) {
1277
1279
  _self.queue.push(message);
1278
1280
  _messageCount++;
1279
- _debugExtMsg((severity === 1 ? "error" : "warn"), message);
1281
+ _debugExtMsg((severity === exports.LoggingSeverity.CRITICAL ? "error" : "warn"), message);
1280
1282
  }
1281
1283
  if (_messageCount === _self.maxInternalMessageLimit()) {
1282
1284
  var throttleLimitMessage = "Internal events throttle limit per PageView reached for this app.";
1283
- var throttleMessage = new _InternalLogMessage(23 , throttleLimitMessage, false);
1285
+ var throttleMessage = new _InternalLogMessage(_InternalMessageId.MessageLimitPerPVExceeded, throttleLimitMessage, false);
1284
1286
  _self.queue.push(throttleMessage);
1285
- if (severity === 1 ) {
1287
+ if (severity === exports.LoggingSeverity.CRITICAL) {
1286
1288
  _self.errorToConsole(throttleLimitMessage);
1287
1289
  }
1288
1290
  else {
@@ -1311,10 +1313,6 @@
1311
1313
  }
1312
1314
  return DiagnosticLogger;
1313
1315
  }());
1314
- function _throwInternal(logger, severity, msgId, msg, properties, isUserAct) {
1315
- if (isUserAct === void 0) { isUserAct = false; }
1316
- (logger || new DiagnosticLogger()).throwInternal(severity, msgId, msg, properties, isUserAct);
1317
- }
1318
1316
 
1319
1317
  var strExecutionContextKey = "ctx";
1320
1318
  var _defaultPerfManager = null;
@@ -1463,587 +1461,369 @@
1463
1461
  return _defaultPerfManager;
1464
1462
  }
1465
1463
 
1466
- var UInt32Mask = 0x100000000;
1467
- var MaxUInt32 = 0xffffffff;
1468
- var _mwcSeeded = false;
1469
- var _mwcW = 123456789;
1470
- var _mwcZ = 987654321;
1471
- function _mwcSeed(seedValue) {
1472
- if (seedValue < 0) {
1473
- seedValue >>>= 0;
1474
- }
1475
- _mwcW = (123456789 + seedValue) & MaxUInt32;
1476
- _mwcZ = (987654321 - seedValue) & MaxUInt32;
1477
- _mwcSeeded = true;
1478
- }
1479
- function _autoSeedMwc() {
1480
- try {
1481
- var now = dateNow() & 0x7fffffff;
1482
- _mwcSeed(((Math.random() * UInt32Mask) ^ now) + now);
1483
- }
1484
- catch (e) {
1485
- }
1486
- }
1487
- function randomValue(maxValue) {
1488
- if (maxValue > 0) {
1489
- return Math.floor((random32() / MaxUInt32) * (maxValue + 1)) >>> 0;
1490
- }
1491
- return 0;
1492
- }
1493
- function random32(signed) {
1494
- var value = 0;
1495
- var c = getCrypto() || getMsCrypto();
1496
- if (c && c.getRandomValues) {
1497
- value = c.getRandomValues(new Uint32Array(1))[0] & MaxUInt32;
1464
+ var TelemetryPluginChain = /** @class */ (function () {
1465
+ function TelemetryPluginChain(plugin, defItemCtx) {
1466
+ var _self = this;
1467
+ var _nextProxy = null;
1468
+ var _hasProcessTelemetry = isFunction(plugin.processTelemetry);
1469
+ var _hasSetNext = isFunction(plugin.setNextPlugin);
1470
+ _self._hasRun = false;
1471
+ _self.getPlugin = function () {
1472
+ return plugin;
1473
+ };
1474
+ _self.getNext = function () {
1475
+ return _nextProxy;
1476
+ };
1477
+ _self.setNext = function (nextPlugin) {
1478
+ _nextProxy = nextPlugin;
1479
+ };
1480
+ _self.processTelemetry = function (env, itemCtx) {
1481
+ if (!itemCtx) {
1482
+ itemCtx = defItemCtx;
1483
+ }
1484
+ var identifier = plugin ? plugin.identifier : "TelemetryPluginChain";
1485
+ doPerf(itemCtx ? itemCtx.core() : null, function () { return identifier + ":processTelemetry"; }, function () {
1486
+ if (plugin && _hasProcessTelemetry) {
1487
+ _self._hasRun = true;
1488
+ try {
1489
+ itemCtx.setNext(_nextProxy);
1490
+ if (_hasSetNext) {
1491
+ plugin.setNextPlugin(_nextProxy);
1492
+ }
1493
+ _nextProxy && (_nextProxy._hasRun = false);
1494
+ plugin.processTelemetry(env, itemCtx);
1495
+ }
1496
+ catch (error) {
1497
+ var hasRun = _nextProxy && _nextProxy._hasRun;
1498
+ if (!_nextProxy || !hasRun) {
1499
+ itemCtx.diagLog().throwInternal(exports.LoggingSeverity.CRITICAL, _InternalMessageId.PluginException, "Plugin [" + plugin.identifier + "] failed during processTelemetry - " + dumpObj(error));
1500
+ }
1501
+ if (_nextProxy && !hasRun) {
1502
+ _nextProxy.processTelemetry(env, itemCtx);
1503
+ }
1504
+ }
1505
+ }
1506
+ else if (_nextProxy) {
1507
+ _self._hasRun = true;
1508
+ _nextProxy.processTelemetry(env, itemCtx);
1509
+ }
1510
+ }, function () { return ({ item: env }); }, !(env.sync));
1511
+ };
1498
1512
  }
1499
- if (value === 0 && isIE()) {
1500
- if (!_mwcSeeded) {
1501
- _autoSeedMwc();
1513
+ return TelemetryPluginChain;
1514
+ }());
1515
+
1516
+ function _createProxyChain(plugins, itemCtx) {
1517
+ var proxies = [];
1518
+ if (plugins && plugins.length > 0) {
1519
+ var lastProxy = null;
1520
+ for (var idx = 0; idx < plugins.length; idx++) {
1521
+ var thePlugin = plugins[idx];
1522
+ if (thePlugin && isFunction(thePlugin.processTelemetry)) {
1523
+ var newProxy = new TelemetryPluginChain(thePlugin, itemCtx);
1524
+ proxies.push(newProxy);
1525
+ if (lastProxy) {
1526
+ lastProxy.setNext(newProxy);
1527
+ }
1528
+ lastProxy = newProxy;
1529
+ }
1502
1530
  }
1503
- value = mwcRandom32() & MaxUInt32;
1504
- }
1505
- if (value === 0) {
1506
- value = Math.floor((UInt32Mask * Math.random()) | 0);
1507
- }
1508
- if (!signed) {
1509
- value >>>= 0;
1510
- }
1511
- return value;
1512
- }
1513
- function mwcRandomSeed(value) {
1514
- if (!value) {
1515
- _autoSeedMwc();
1516
- }
1517
- else {
1518
- _mwcSeed(value);
1519
- }
1520
- }
1521
- function mwcRandom32(signed) {
1522
- _mwcZ = (36969 * (_mwcZ & 0xFFFF) + (_mwcZ >> 16)) & MaxUInt32;
1523
- _mwcW = (18000 * (_mwcW & 0xFFFF) + (_mwcW >> 16)) & MaxUInt32;
1524
- var value = (((_mwcZ << 16) + (_mwcW & 0xFFFF)) >>> 0) & MaxUInt32 | 0;
1525
- if (!signed) {
1526
- value >>>= 0;
1527
1531
  }
1528
- return value;
1532
+ return proxies.length > 0 ? proxies[0] : null;
1529
1533
  }
1530
- function newId(maxLength) {
1531
- if (maxLength === void 0) { maxLength = 22; }
1532
- var base64chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
1533
- var number = random32() >>> 0;
1534
- var chars = 0;
1535
- var result = strEmpty;
1536
- while (result.length < maxLength) {
1537
- chars++;
1538
- result += base64chars.charAt(number & 0x3F);
1539
- number >>>= 6;
1540
- if (chars === 5) {
1541
- number = (((random32() << 2) & 0xFFFFFFFF) | (number & 0x03)) >>> 0;
1542
- chars = 0;
1534
+ function _copyProxyChain(proxy, itemCtx, startAt) {
1535
+ var plugins = [];
1536
+ var add = startAt ? false : true;
1537
+ if (proxy) {
1538
+ while (proxy) {
1539
+ var thePlugin = proxy.getPlugin();
1540
+ if (add || thePlugin === startAt) {
1541
+ add = true;
1542
+ plugins.push(thePlugin);
1543
+ }
1544
+ proxy = proxy.getNext();
1543
1545
  }
1544
1546
  }
1545
- return result;
1546
- }
1547
-
1548
- var _objDefineProperty = ObjDefineProperty;
1549
- var version = "2.7.5-nightly.2203-03";
1550
- var instanceName = "." + newId(6);
1551
- var _dataUid = 0;
1552
- function _createAccessor(target, prop, value) {
1553
- if (_objDefineProperty) {
1554
- try {
1555
- _objDefineProperty(target, prop, {
1556
- value: value,
1557
- enumerable: false,
1558
- configurable: true
1559
- });
1560
- return true;
1561
- }
1562
- catch (e) {
1563
- }
1547
+ if (!add) {
1548
+ plugins.push(startAt);
1564
1549
  }
1565
- return false;
1550
+ return _createProxyChain(plugins, itemCtx);
1566
1551
  }
1567
- function _canAcceptData(target) {
1568
- return target.nodeType === 1 || target.nodeType === 9 || !(+target.nodeType);
1569
- }
1570
- function _getCache(data, target) {
1571
- var theCache = target[data.id];
1572
- if (!theCache) {
1573
- theCache = {};
1574
- try {
1575
- if (_canAcceptData(target)) {
1576
- if (!_createAccessor(target, data.id, theCache)) {
1577
- target[data.id] = theCache;
1578
- }
1552
+ function _copyPluginChain(srcPlugins, itemCtx, startAt) {
1553
+ var plugins = srcPlugins;
1554
+ var add = false;
1555
+ if (startAt && srcPlugins) {
1556
+ plugins = [];
1557
+ arrForEach(srcPlugins, function (thePlugin) {
1558
+ if (add || thePlugin === startAt) {
1559
+ add = true;
1560
+ plugins.push(thePlugin);
1579
1561
  }
1562
+ });
1563
+ }
1564
+ if (startAt && !add) {
1565
+ if (!plugins) {
1566
+ plugins = [];
1580
1567
  }
1581
- catch (e) {
1582
- }
1568
+ plugins.push(startAt);
1583
1569
  }
1584
- return theCache;
1570
+ return _createProxyChain(plugins, itemCtx);
1585
1571
  }
1586
- function createUniqueNamespace(name, includeVersion) {
1587
- if (includeVersion === void 0) { includeVersion = false; }
1588
- return normalizeJsName(name + (_dataUid++) + (includeVersion ? "." + version : "") + instanceName);
1589
- }
1590
- function createElmNodeData(name) {
1591
- var data = {
1592
- id: createUniqueNamespace("_aiData-" + (name || "") + "." + version),
1593
- accept: function (target) {
1594
- return _canAcceptData(target);
1595
- },
1596
- get: function (target, name, defValue, addDefault) {
1597
- var theCache = target[data.id];
1598
- if (!theCache) {
1599
- if (addDefault) {
1600
- theCache = _getCache(data, target);
1601
- theCache[normalizeJsName(name)] = defValue;
1602
- }
1603
- return defValue;
1572
+ var ProcessTelemetryContext = /** @class */ (function () {
1573
+ function ProcessTelemetryContext(plugins, config, core, startAt) {
1574
+ var _self = this;
1575
+ var _nextProxy = null;
1576
+ if (startAt !== null) {
1577
+ if (plugins && isFunction(plugins.getPlugin)) {
1578
+ _nextProxy = _copyProxyChain(plugins, _self, startAt || plugins.getPlugin());
1604
1579
  }
1605
- return theCache[normalizeJsName(name)];
1606
- },
1607
- kill: function (target, name) {
1608
- if (target && target[name]) {
1609
- try {
1610
- delete target[name];
1580
+ else {
1581
+ if (startAt) {
1582
+ _nextProxy = _copyPluginChain(plugins, _self, startAt);
1611
1583
  }
1612
- catch (e) {
1584
+ else if (isUndefined(startAt)) {
1585
+ _nextProxy = _createProxyChain(plugins, _self);
1613
1586
  }
1614
1587
  }
1615
1588
  }
1616
- };
1617
- return data;
1618
- }
1619
-
1620
- var strDoUnload = "_doUnload";
1621
- var pluginStateData = createElmNodeData("plugin");
1622
- function _getPluginState(plugin) {
1623
- return pluginStateData.get(plugin, "state", {}, true);
1624
- }
1625
- function initializePlugins(processContext, extensions) {
1626
- var initPlugins = [];
1627
- var lastPlugin = null;
1628
- var proxy = processContext.getNext();
1629
- var pluginState;
1630
- while (proxy) {
1631
- var thePlugin = proxy.getPlugin();
1632
- if (thePlugin) {
1633
- if (lastPlugin &&
1634
- isFunction(lastPlugin[strSetNextPlugin]) &&
1635
- isFunction(thePlugin[strProcessTelemetry])) {
1636
- lastPlugin[strSetNextPlugin](thePlugin);
1637
- }
1638
- var isInitialized = false;
1639
- if (isFunction(thePlugin[strIsInitialized])) {
1640
- isInitialized = thePlugin[strIsInitialized]();
1589
+ _self.core = function () {
1590
+ return core;
1591
+ };
1592
+ _self.diagLog = function () {
1593
+ return safeGetLogger(core, config);
1594
+ };
1595
+ _self.getCfg = function () {
1596
+ return config;
1597
+ };
1598
+ _self.getExtCfg = function (identifier, defaultValue) {
1599
+ if (defaultValue === void 0) { defaultValue = {}; }
1600
+ var theConfig;
1601
+ if (config) {
1602
+ var extConfig = config.extensionConfig;
1603
+ if (extConfig && identifier) {
1604
+ theConfig = extConfig[identifier];
1605
+ }
1641
1606
  }
1642
- else {
1643
- pluginState = _getPluginState(thePlugin);
1644
- isInitialized = pluginState[strIsInitialized];
1607
+ return (theConfig ? theConfig : defaultValue);
1608
+ };
1609
+ _self.getConfig = function (identifier, field, defaultValue) {
1610
+ if (defaultValue === void 0) { defaultValue = false; }
1611
+ var theValue;
1612
+ var extConfig = _self.getExtCfg(identifier, null);
1613
+ if (extConfig && !isNullOrUndefined(extConfig[field])) {
1614
+ theValue = extConfig[field];
1645
1615
  }
1646
- if (!isInitialized) {
1647
- initPlugins.push(thePlugin);
1616
+ else if (config && !isNullOrUndefined(config[field])) {
1617
+ theValue = config[field];
1648
1618
  }
1649
- lastPlugin = thePlugin;
1650
- proxy = proxy.getNext();
1651
- }
1652
- }
1653
- arrForEach(initPlugins, function (thePlugin) {
1654
- var core = processContext.core();
1655
- thePlugin.initialize(processContext.getCfg(), core, extensions, processContext.getNext());
1656
- pluginState = _getPluginState(thePlugin);
1657
- if (!thePlugin[strCore] && !pluginState[strCore]) {
1658
- pluginState[strCore] = core;
1659
- }
1660
- pluginState[strIsInitialized] = true;
1661
- delete pluginState[strTeardown];
1662
- });
1663
- }
1664
- function sortPlugins(plugins) {
1665
- return plugins.sort(function (extA, extB) {
1666
- var result = 0;
1667
- var bHasProcess = isFunction(extB[strProcessTelemetry]);
1668
- if (isFunction(extA[strProcessTelemetry])) {
1669
- result = bHasProcess ? extA[strPriority] - extB[strPriority] : 1;
1670
- }
1671
- else if (bHasProcess) {
1672
- result = -1;
1673
- }
1674
- return result;
1675
- });
1676
- }
1677
- function unloadComponents(components, unloadCtx, unloadState, asyncCallback) {
1678
- var idx = 0;
1679
- function _doUnload() {
1680
- while (idx < components.length) {
1681
- var component = components[idx++];
1682
- if (component) {
1683
- var func = component[strDoUnload] || component[strDoTeardown];
1684
- if (isFunction(func)) {
1685
- if (func.call(component, unloadCtx, unloadState, _doUnload) === true) {
1686
- return true;
1687
- }
1688
- }
1619
+ return !isNullOrUndefined(theValue) ? theValue : defaultValue;
1620
+ };
1621
+ _self.hasNext = function () {
1622
+ return _nextProxy != null;
1623
+ };
1624
+ _self.getNext = function () {
1625
+ return _nextProxy;
1626
+ };
1627
+ _self.setNext = function (nextPlugin) {
1628
+ _nextProxy = nextPlugin;
1629
+ };
1630
+ _self.processNext = function (env) {
1631
+ var nextPlugin = _nextProxy;
1632
+ if (nextPlugin) {
1633
+ _nextProxy = nextPlugin.getNext();
1634
+ nextPlugin.processTelemetry(env, _self);
1689
1635
  }
1690
- }
1636
+ };
1637
+ _self.createNew = function (plugins, startAt) {
1638
+ if (plugins === void 0) { plugins = null; }
1639
+ return new ProcessTelemetryContext(plugins || _nextProxy, config, core, startAt);
1640
+ };
1691
1641
  }
1692
- return _doUnload();
1693
- }
1642
+ return ProcessTelemetryContext;
1643
+ }());
1694
1644
 
1695
- var strTelemetryPluginChain = "TelemetryPluginChain";
1696
- var strHasRunFlags = "_hasRun";
1697
- var strGetTelCtx = "_getTelCtx";
1698
- var _chainId = 0;
1699
- function _getNextProxyStart(proxy, config, core, startAt) {
1700
- while (proxy) {
1701
- if (proxy.getPlugin() === startAt) {
1702
- return proxy;
1703
- }
1704
- proxy = proxy.getNext();
1705
- }
1706
- return createTelemetryProxyChain([startAt], config, core);
1707
- }
1708
- function _createInternalContext(telemetryChain, config, core, startAt) {
1709
- var _nextProxy = null;
1710
- var _onComplete = [];
1711
- if (startAt !== null) {
1712
- _nextProxy = startAt ? _getNextProxyStart(telemetryChain, config, core, startAt) : telemetryChain;
1713
- }
1714
- var context = {
1715
- _next: _moveNext,
1716
- ctx: {
1717
- core: function () {
1718
- return core;
1719
- },
1720
- diagLog: function () {
1721
- return safeGetLogger(core, config);
1722
- },
1723
- getCfg: function () {
1724
- return config;
1725
- },
1726
- getExtCfg: _getExtCfg,
1727
- getConfig: _getConfig,
1728
- hasNext: function () {
1729
- return !!_nextProxy;
1730
- },
1731
- getNext: function () {
1732
- return _nextProxy;
1733
- },
1734
- setNext: function (nextPlugin) {
1735
- _nextProxy = nextPlugin;
1736
- },
1737
- iterate: _iterateChain,
1738
- onComplete: _addOnComplete
1739
- }
1740
- };
1741
- function _addOnComplete(onComplete, that) {
1742
- var args = [];
1743
- for (var _i = 2; _i < arguments.length; _i++) {
1744
- args[_i - 2] = arguments[_i];
1745
- }
1746
- if (onComplete) {
1747
- _onComplete.push({
1748
- func: onComplete,
1749
- self: !isUndefined(that) ? that : context.ctx,
1750
- args: args
1751
- });
1752
- }
1753
- }
1754
- function _moveNext() {
1755
- var nextProxy = _nextProxy;
1756
- _nextProxy = nextProxy ? nextProxy.getNext() : null;
1757
- if (!nextProxy) {
1758
- var onComplete = _onComplete;
1759
- if (onComplete && onComplete.length > 0) {
1760
- arrForEach(onComplete, function (completeDetails) {
1761
- try {
1762
- completeDetails.func.call(completeDetails.self, completeDetails.args);
1763
- }
1764
- catch (e) {
1765
- _throwInternal(core.logger, 2 , 73 , "Unexpected Exception during onComplete - " + dumpObj(e));
1766
- }
1767
- });
1768
- _onComplete = [];
1645
+ var strIKey = "iKey";
1646
+ var strExtensionConfig = "extensionConfig";
1647
+
1648
+ var strGetPlugin = "getPlugin";
1649
+ var BaseTelemetryPlugin = /** @class */ (function () {
1650
+ function BaseTelemetryPlugin() {
1651
+ var _self = this;
1652
+ var _isinitialized = false;
1653
+ var _rootCtx = null;
1654
+ var _nextPlugin = null;
1655
+ _self.core = null;
1656
+ _self.diagLog = function (itemCtx) {
1657
+ return _self._getTelCtx(itemCtx).diagLog();
1658
+ };
1659
+ _self.isInitialized = function () {
1660
+ return _isinitialized;
1661
+ };
1662
+ _self.setInitialized = function (isInitialized) {
1663
+ _isinitialized = isInitialized;
1664
+ };
1665
+ _self.setNextPlugin = function (next) {
1666
+ _nextPlugin = next;
1667
+ };
1668
+ _self.processNext = function (env, itemCtx) {
1669
+ if (itemCtx) {
1670
+ itemCtx.processNext(env);
1769
1671
  }
1770
- }
1771
- return nextProxy;
1772
- }
1773
- function _getExtCfg(identifier, defaultValue, mergeDefault) {
1774
- if (defaultValue === void 0) { defaultValue = {}; }
1775
- if (mergeDefault === void 0) { mergeDefault = 0 ; }
1776
- var theConfig;
1777
- if (config) {
1778
- var extConfig = config.extensionConfig;
1779
- if (extConfig && identifier) {
1780
- theConfig = extConfig[identifier];
1672
+ else if (_nextPlugin && isFunction(_nextPlugin.processTelemetry)) {
1673
+ _nextPlugin.processTelemetry(env, null);
1781
1674
  }
1782
- }
1783
- if (!theConfig) {
1784
- theConfig = defaultValue;
1785
- }
1786
- else if (isObject(defaultValue)) {
1787
- if (mergeDefault !== 0 ) {
1788
- var newConfig_1 = objExtend(true, defaultValue, theConfig);
1789
- if (config && mergeDefault === 2 ) {
1790
- objForEachKey(defaultValue, function (field) {
1791
- if (isNullOrUndefined(newConfig_1[field])) {
1792
- var cfgValue = config[field];
1793
- if (!isNullOrUndefined(cfgValue)) {
1794
- newConfig_1[field] = cfgValue;
1795
- }
1796
- }
1797
- });
1675
+ };
1676
+ _self._getTelCtx = function (currentCtx) {
1677
+ if (currentCtx === void 0) { currentCtx = null; }
1678
+ var itemCtx = currentCtx;
1679
+ if (!itemCtx) {
1680
+ var rootCtx = _rootCtx || new ProcessTelemetryContext(null, {}, _self.core);
1681
+ if (_nextPlugin && _nextPlugin[strGetPlugin]) {
1682
+ itemCtx = rootCtx.createNew(null, _nextPlugin[strGetPlugin]);
1683
+ }
1684
+ else {
1685
+ itemCtx = rootCtx.createNew(null, _nextPlugin);
1798
1686
  }
1799
1687
  }
1800
- }
1801
- return theConfig;
1802
- }
1803
- function _getConfig(identifier, field, defaultValue) {
1804
- if (defaultValue === void 0) { defaultValue = false; }
1805
- var theValue;
1806
- var extConfig = _getExtCfg(identifier, null);
1807
- if (extConfig && !isNullOrUndefined(extConfig[field])) {
1808
- theValue = extConfig[field];
1809
- }
1810
- else if (config && !isNullOrUndefined(config[field])) {
1811
- theValue = config[field];
1812
- }
1813
- return !isNullOrUndefined(theValue) ? theValue : defaultValue;
1814
- }
1815
- function _iterateChain(cb) {
1816
- var nextPlugin;
1817
- while (!!(nextPlugin = context._next())) {
1818
- var plugin = nextPlugin.getPlugin();
1819
- if (plugin) {
1820
- cb(plugin);
1688
+ return itemCtx;
1689
+ };
1690
+ _self._baseTelInit = function (config, core, extensions, pluginChain) {
1691
+ if (config) {
1692
+ setValue(config, strExtensionConfig, [], null, isNullOrUndefined);
1821
1693
  }
1822
- }
1823
- }
1824
- return context;
1825
- }
1826
- function createProcessTelemetryContext(telemetryChain, config, core, startAt) {
1827
- var internalContext = _createInternalContext(telemetryChain, config, core, startAt);
1828
- var context = internalContext.ctx;
1829
- function _processNext(env) {
1830
- var nextPlugin = internalContext._next();
1831
- nextPlugin && nextPlugin.processTelemetry(env, context);
1832
- return !nextPlugin;
1833
- }
1834
- function _createNew(plugins, startAt) {
1835
- if (plugins === void 0) { plugins = null; }
1836
- if (isArray(plugins)) {
1837
- plugins = createTelemetryProxyChain(plugins, config, core, startAt);
1838
- }
1839
- return createProcessTelemetryContext(plugins || context.getNext(), config, core, startAt);
1840
- }
1841
- context.processNext = _processNext;
1842
- context.createNew = _createNew;
1843
- return context;
1844
- }
1845
- function createProcessTelemetryUnloadContext(telemetryChain, config, core, startAt) {
1846
- var internalContext = _createInternalContext(telemetryChain, config, core, startAt);
1847
- var context = internalContext.ctx;
1848
- function _processNext(unloadState) {
1849
- var nextPlugin = internalContext._next();
1850
- nextPlugin && nextPlugin.unload(context, unloadState);
1851
- return !nextPlugin;
1852
- }
1853
- function _createNew(plugins, startAt) {
1854
- if (plugins === void 0) { plugins = null; }
1855
- if (isArray(plugins)) {
1856
- plugins = createTelemetryProxyChain(plugins, config, core, startAt);
1857
- }
1858
- return createProcessTelemetryUnloadContext(plugins || context.getNext(), config, core, startAt);
1859
- }
1860
- context.processNext = _processNext;
1861
- context.createNew = _createNew;
1862
- return context;
1863
- }
1864
- function createProcessTelemetryUpdateContext(telemetryChain, config, core, startAt) {
1865
- var internalContext = _createInternalContext(telemetryChain, config, core, startAt);
1866
- var context = internalContext.ctx;
1867
- function _processNext(updateState) {
1868
- return context.iterate(function (plugin) {
1869
- if (isFunction(plugin[strUpdate])) {
1870
- plugin[strUpdate](context, updateState);
1694
+ if (!pluginChain && core) {
1695
+ pluginChain = core.getProcessTelContext().getNext();
1871
1696
  }
1872
- });
1873
- }
1874
- function _createNew(plugins, startAt) {
1875
- if (plugins === void 0) { plugins = null; }
1876
- if (isArray(plugins)) {
1877
- plugins = createTelemetryProxyChain(plugins, config, core, startAt);
1878
- }
1879
- return createProcessTelemetryUpdateContext(plugins || context.getNext(), config, core, startAt);
1697
+ var nextPlugin = _nextPlugin;
1698
+ if (_nextPlugin && _nextPlugin[strGetPlugin]) {
1699
+ nextPlugin = _nextPlugin[strGetPlugin]();
1700
+ }
1701
+ _self.core = core;
1702
+ _rootCtx = new ProcessTelemetryContext(pluginChain, config, core, nextPlugin);
1703
+ _isinitialized = true;
1704
+ };
1880
1705
  }
1881
- context.processNext = _processNext;
1882
- context.createNew = _createNew;
1883
- return context;
1884
- }
1885
- function createTelemetryProxyChain(plugins, config, core, startAt) {
1886
- var firstProxy = null;
1887
- var add = startAt ? false : true;
1888
- if (isArray(plugins) && plugins.length > 0) {
1889
- var lastProxy_1 = null;
1890
- arrForEach(plugins, function (thePlugin) {
1891
- if (!add && startAt === thePlugin) {
1892
- add = true;
1706
+ BaseTelemetryPlugin.prototype.initialize = function (config, core, extensions, pluginChain) {
1707
+ this._baseTelInit(config, core, extensions, pluginChain);
1708
+ };
1709
+ return BaseTelemetryPlugin;
1710
+ }());
1711
+
1712
+ var processTelemetry = "processTelemetry";
1713
+ var priority = "priority";
1714
+ var setNextPlugin = "setNextPlugin";
1715
+ var isInitialized = "isInitialized";
1716
+ function initializePlugins(processContext, extensions) {
1717
+ var initPlugins = [];
1718
+ var lastPlugin = null;
1719
+ var proxy = processContext.getNext();
1720
+ while (proxy) {
1721
+ var thePlugin = proxy.getPlugin();
1722
+ if (thePlugin) {
1723
+ if (lastPlugin &&
1724
+ isFunction(lastPlugin[setNextPlugin]) &&
1725
+ isFunction(thePlugin[processTelemetry])) {
1726
+ lastPlugin[setNextPlugin](thePlugin);
1893
1727
  }
1894
- if (add && thePlugin && isFunction(thePlugin.processTelemetry)) {
1895
- var newProxy = createTelemetryPluginProxy(thePlugin, config, core);
1896
- if (!firstProxy) {
1897
- firstProxy = newProxy;
1898
- }
1899
- if (lastProxy_1) {
1900
- lastProxy_1._setNext(newProxy);
1901
- }
1902
- lastProxy_1 = newProxy;
1728
+ if (!isFunction(thePlugin[isInitialized]) || !thePlugin[isInitialized]()) {
1729
+ initPlugins.push(thePlugin);
1903
1730
  }
1904
- });
1905
- }
1906
- if (startAt && !firstProxy) {
1907
- return createTelemetryProxyChain([startAt], config, core);
1731
+ lastPlugin = thePlugin;
1732
+ proxy = proxy.getNext();
1733
+ }
1908
1734
  }
1909
- return firstProxy;
1735
+ arrForEach(initPlugins, function (thePlugin) {
1736
+ thePlugin.initialize(processContext.getCfg(), processContext.core(), extensions, processContext.getNext());
1737
+ });
1910
1738
  }
1911
- function createTelemetryPluginProxy(plugin, config, core) {
1912
- var nextProxy = null;
1913
- var hasProcessTelemetry = isFunction(plugin.processTelemetry);
1914
- var hasSetNext = isFunction(plugin.setNextPlugin);
1915
- var chainId;
1916
- if (plugin) {
1917
- chainId = plugin.identifier + "-" + plugin.priority + "-" + _chainId++;
1918
- }
1919
- else {
1920
- chainId = "Unknown-0-" + _chainId++;
1921
- }
1922
- var proxyChain = {
1923
- getPlugin: function () {
1924
- return plugin;
1925
- },
1926
- getNext: function () {
1927
- return nextProxy;
1928
- },
1929
- processTelemetry: _processTelemetry,
1930
- unload: _unloadPlugin,
1931
- update: _updatePlugin,
1932
- _id: chainId,
1933
- _setNext: function (nextPlugin) {
1934
- nextProxy = nextPlugin;
1935
- }
1936
- };
1937
- function _getTelCtx() {
1938
- var itemCtx;
1939
- if (plugin && isFunction(plugin[strGetTelCtx])) {
1940
- itemCtx = plugin[strGetTelCtx]();
1941
- }
1942
- if (!itemCtx) {
1943
- itemCtx = createProcessTelemetryContext(proxyChain, config, core);
1739
+ function sortPlugins(plugins) {
1740
+ return plugins.sort(function (extA, extB) {
1741
+ var result = 0;
1742
+ var bHasProcess = isFunction(extB[processTelemetry]);
1743
+ if (isFunction(extA[processTelemetry])) {
1744
+ result = bHasProcess ? extA[priority] - extB[priority] : 1;
1944
1745
  }
1945
- return itemCtx;
1946
- }
1947
- function _processChain(itemCtx, processPluginFn, name, details, isAsync) {
1948
- var hasRun = false;
1949
- var identifier = plugin ? plugin.identifier : strTelemetryPluginChain;
1950
- var hasRunContext = itemCtx[strHasRunFlags];
1951
- if (!hasRunContext) {
1952
- hasRunContext = itemCtx[strHasRunFlags] = {};
1746
+ else if (bHasProcess) {
1747
+ result = -1;
1953
1748
  }
1954
- itemCtx.setNext(nextProxy);
1955
- if (plugin) {
1956
- doPerf(itemCtx[strCore](), function () { return identifier + ":" + name; }, function () {
1957
- hasRunContext[chainId] = true;
1958
- try {
1959
- var nextId = nextProxy ? nextProxy._id : strEmpty;
1960
- if (nextId) {
1961
- hasRunContext[nextId] = false;
1962
- }
1963
- hasRun = processPluginFn(itemCtx);
1749
+ return result;
1750
+ });
1751
+ }
1752
+
1753
+ var ChannelControllerPriority = 500;
1754
+ var ChannelValidationMessage = "Channel has invalid priority";
1755
+ var ChannelController = /** @class */ (function (_super) {
1756
+ __extendsFn(ChannelController, _super);
1757
+ function ChannelController() {
1758
+ var _this = _super.call(this) || this;
1759
+ _this.identifier = "ChannelControllerPlugin";
1760
+ _this.priority = ChannelControllerPriority;
1761
+ var _channelQueue;
1762
+ dynamicProto(ChannelController, _this, function (_self, _base) {
1763
+ _self.setNextPlugin = function (next) {
1764
+ };
1765
+ _self.processTelemetry = function (item, itemCtx) {
1766
+ if (_channelQueue) {
1767
+ arrForEach(_channelQueue, function (queues) {
1768
+ if (queues.length > 0) {
1769
+ var chainCtx = _this._getTelCtx(itemCtx).createNew(queues);
1770
+ chainCtx.processNext(item);
1771
+ }
1772
+ });
1964
1773
  }
1965
- catch (error) {
1966
- var hasNextRun = nextProxy ? hasRunContext[nextProxy._id] : true;
1967
- if (hasNextRun) {
1968
- hasRun = true;
1969
- }
1970
- if (!nextProxy || !hasNextRun) {
1971
- _throwInternal(itemCtx.diagLog(), 1 , 73 , "Plugin [" + plugin.identifier + "] failed during " + name + " - " + dumpObj(error) + ", run flags: " + dumpObj(hasRunContext));
1972
- }
1774
+ };
1775
+ _self.getChannelControls = function () {
1776
+ return _channelQueue;
1777
+ };
1778
+ _self.initialize = function (config, core, extensions) {
1779
+ if (_self.isInitialized()) {
1780
+ return;
1973
1781
  }
1974
- }, details, isAsync);
1782
+ _base.initialize(config, core, extensions);
1783
+ _createChannelQueues((config || {}).channels, extensions);
1784
+ arrForEach(_channelQueue, function (queue) { return initializePlugins(new ProcessTelemetryContext(queue, config, core), extensions); });
1785
+ };
1786
+ });
1787
+ function _checkQueuePriority(queue) {
1788
+ arrForEach(queue, function (queueItem) {
1789
+ if (queueItem.priority < ChannelControllerPriority) {
1790
+ throwError(ChannelValidationMessage + queueItem.identifier);
1791
+ }
1792
+ });
1975
1793
  }
1976
- return hasRun;
1977
- }
1978
- function _processTelemetry(env, itemCtx) {
1979
- itemCtx = itemCtx || _getTelCtx();
1980
- function _callProcessTelemetry(itemCtx) {
1981
- if (!plugin || !hasProcessTelemetry) {
1982
- return false;
1983
- }
1984
- var pluginState = _getPluginState(plugin);
1985
- if (pluginState[strTeardown] || pluginState[strDisabled]) {
1986
- return false;
1987
- }
1988
- if (hasSetNext) {
1989
- plugin.setNextPlugin(nextProxy);
1794
+ function _addChannelQueue(queue) {
1795
+ if (queue && queue.length > 0) {
1796
+ queue = queue.sort(function (a, b) {
1797
+ return a.priority - b.priority;
1798
+ });
1799
+ _checkQueuePriority(queue);
1800
+ _channelQueue.push(queue);
1990
1801
  }
1991
- plugin.processTelemetry(env, itemCtx);
1992
- return true;
1993
- }
1994
- if (!_processChain(itemCtx, _callProcessTelemetry, "processTelemetry", function () { return ({ item: env }); }, !(env.sync))) {
1995
- itemCtx.processNext(env);
1996
1802
  }
1997
- }
1998
- function _unloadPlugin(unloadCtx, unloadState) {
1999
- function _callTeardown() {
2000
- var hasRun = false;
2001
- if (plugin) {
2002
- var pluginState = _getPluginState(plugin);
2003
- var pluginCore = plugin[strCore] || pluginState.core;
2004
- if (plugin && (!pluginCore || pluginCore === unloadCtx[strCore]()) && !pluginState[strTeardown]) {
2005
- pluginState[strCore] = null;
2006
- pluginState[strTeardown] = true;
2007
- pluginState[strIsInitialized] = false;
2008
- if (plugin[strTeardown] && plugin[strTeardown](unloadCtx, unloadState) === true) {
2009
- hasRun = true;
2010
- }
2011
- }
1803
+ function _createChannelQueues(channels, extensions) {
1804
+ _channelQueue = [];
1805
+ if (channels) {
1806
+ arrForEach(channels, function (queue) { return _addChannelQueue(queue); });
2012
1807
  }
2013
- return hasRun;
2014
- }
2015
- if (!_processChain(unloadCtx, _callTeardown, "unload", function () { }, unloadState.isAsync)) {
2016
- unloadCtx.processNext(unloadState);
2017
- }
2018
- }
2019
- function _updatePlugin(updateCtx, updateState) {
2020
- function _callUpdate() {
2021
- var hasRun = false;
2022
- if (plugin) {
2023
- var pluginState = _getPluginState(plugin);
2024
- var pluginCore = plugin[strCore] || pluginState.core;
2025
- if (plugin && (!pluginCore || pluginCore === updateCtx[strCore]()) && !pluginState[strTeardown]) {
2026
- if (plugin[strUpdate] && plugin[strUpdate](updateCtx, updateState) === true) {
2027
- hasRun = true;
1808
+ if (extensions) {
1809
+ var extensionQueue_1 = [];
1810
+ arrForEach(extensions, function (plugin) {
1811
+ if (plugin.priority > ChannelControllerPriority) {
1812
+ extensionQueue_1.push(plugin);
2028
1813
  }
2029
- }
1814
+ });
1815
+ _addChannelQueue(extensionQueue_1);
2030
1816
  }
2031
- return hasRun;
2032
1817
  }
2033
- if (!_processChain(updateCtx, _callUpdate, "update", function () { }, false)) {
2034
- updateCtx.processNext(updateState);
2035
- }
2036
- }
2037
- return objFreeze(proxyChain);
2038
- }
2039
- var ProcessTelemetryContext = /** @class */ (function () {
2040
- function ProcessTelemetryContext(pluginChain, config, core, startAt) {
2041
- var _self = this;
2042
- var context = createProcessTelemetryContext(pluginChain, config, core, startAt);
2043
- proxyFunctions(_self, context, objKeys(context));
1818
+ return _this;
2044
1819
  }
2045
- return ProcessTelemetryContext;
2046
- }());
1820
+ ChannelController._staticInit = (function () {
1821
+ var proto = ChannelController.prototype;
1822
+ objDefineAccessors(proto, "ChannelControls", proto.getChannelControls);
1823
+ objDefineAccessors(proto, "channelQueue", proto.getChannelControls);
1824
+ })();
1825
+ return ChannelController;
1826
+ }(BaseTelemetryPlugin));
2047
1827
 
2048
1828
  var strToGMTString = "toGMTString";
2049
1829
  var strToUTCString = "toUTCString";
@@ -2053,6 +1833,7 @@
2053
1833
  var strIsCookieUseDisabled = "isCookieUseDisabled";
2054
1834
  var strDisableCookiesUsage = "disableCookiesUsage";
2055
1835
  var strConfigCookieMgr = "_ckMgr";
1836
+ var strEmpty = "";
2056
1837
  var _supportsCookies = null;
2057
1838
  var _allowUaSameSite = null;
2058
1839
  var _parsedCookieValue = null;
@@ -2211,7 +1992,7 @@
2211
1992
  _supportsCookies = doc[strCookie] !== undefined;
2212
1993
  }
2213
1994
  catch (e) {
2214
- _throwInternal(logger, 2 , 68 , "Cannot access document.cookie - " + getExceptionName(e), { exception: dumpObj(e) });
1995
+ logger && logger.throwInternal(exports.LoggingSeverity.WARNING, _InternalMessageId.CannotAccessCookie, "Cannot access document.cookie - " + getExceptionName(e), { exception: dumpObj(e) });
2215
1996
  }
2216
1997
  }
2217
1998
  return _supportsCookies;
@@ -2290,583 +2071,118 @@
2290
2071
  return false;
2291
2072
  }
2292
2073
 
2293
- var strIKey = "iKey";
2294
- var strExtensionConfig = "extensionConfig";
2295
-
2296
- var ChannelControllerPriority = 500;
2297
- var ChannelValidationMessage = "Channel has invalid priority - ";
2298
- function _addChannelQueue(channelQueue, queue, config, core) {
2299
- if (queue && isArray(queue) && queue.length > 0) {
2300
- queue = queue.sort(function (a, b) {
2301
- return a.priority - b.priority;
2302
- });
2303
- arrForEach(queue, function (queueItem) {
2304
- if (queueItem.priority < ChannelControllerPriority) {
2305
- throwError(ChannelValidationMessage + queueItem.identifier);
2306
- }
2307
- });
2308
- channelQueue.push({
2309
- queue: objFreeze(queue),
2310
- chain: createTelemetryProxyChain(queue, config, core)
2311
- });
2312
- }
2074
+ var validationError = "Extensions must provide callback to initialize";
2075
+ var strNotificationManager = "_notificationManager";
2076
+ function _createPerfManager(core, notificationMgr) {
2077
+ return new PerfManager(notificationMgr);
2313
2078
  }
2314
- function createChannelControllerPlugin(channelQueue, core) {
2315
- var _a;
2316
- function _getTelCtx() {
2317
- return createProcessTelemetryContext(null, core.config, core, null);
2318
- }
2319
- function _processChannelQueue(theChannels, itemCtx, processFn, onComplete) {
2320
- var waiting = theChannels ? (theChannels.length + 1) : 1;
2321
- function _runChainOnComplete() {
2322
- waiting--;
2323
- if (waiting === 0) {
2324
- onComplete && onComplete();
2325
- onComplete = null;
2326
- }
2327
- }
2328
- if (waiting > 0) {
2329
- arrForEach(theChannels, function (channels) {
2330
- if (channels && channels.queue.length > 0) {
2331
- var channelChain = channels.chain;
2332
- var chainCtx = itemCtx.createNew(channelChain);
2333
- chainCtx.onComplete(_runChainOnComplete);
2334
- processFn(chainCtx);
2079
+ var BaseCore = /** @class */ (function () {
2080
+ function BaseCore() {
2081
+ var _isInitialized = false;
2082
+ var _eventQueue;
2083
+ var _channelController;
2084
+ var _notificationManager;
2085
+ var _perfManager;
2086
+ var _cookieManager;
2087
+ dynamicProto(BaseCore, this, function (_self) {
2088
+ _self._extensions = new Array();
2089
+ _channelController = new ChannelController();
2090
+ _self.logger = new DiagnosticLogger({ loggingLevelConsole: exports.LoggingSeverity.CRITICAL });
2091
+ _eventQueue = [];
2092
+ _self.isInitialized = function () { return _isInitialized; };
2093
+ _self.initialize = function (config, extensions, logger, notificationManager) {
2094
+ if (_self.isInitialized()) {
2095
+ throwError("Core should not be initialized more than once");
2335
2096
  }
2336
- else {
2337
- waiting--;
2097
+ if (!config || isNullOrUndefined(config.instrumentationKey)) {
2098
+ throwError("Please provide instrumentation key");
2338
2099
  }
2339
- });
2340
- }
2341
- _runChainOnComplete();
2342
- }
2343
- function _doUpdate(updateCtx, updateState) {
2344
- var theUpdateState = updateState || {
2345
- reason: 0
2346
- };
2347
- _processChannelQueue(channelQueue, updateCtx, function (chainCtx) {
2348
- chainCtx[strProcessNext](theUpdateState);
2349
- }, function () {
2350
- updateCtx[strProcessNext](theUpdateState);
2351
- });
2352
- return true;
2353
- }
2354
- function _doTeardown(unloadCtx, unloadState) {
2355
- var theUnloadState = unloadState || {
2356
- reason: 0 ,
2357
- isAsync: false
2358
- };
2359
- _processChannelQueue(channelQueue, unloadCtx, function (chainCtx) {
2360
- chainCtx[strProcessNext](theUnloadState);
2361
- }, function () {
2362
- unloadCtx[strProcessNext](theUnloadState);
2363
- isInitialized = false;
2364
- });
2365
- return true;
2366
- }
2367
- function _getChannel(pluginIdentifier) {
2368
- var thePlugin = null;
2369
- if (channelQueue && channelQueue.length > 0) {
2370
- arrForEach(channelQueue, function (channels) {
2371
- if (channels && channels.queue.length > 0) {
2372
- arrForEach(channels.queue, function (ext) {
2373
- if (ext.identifier === pluginIdentifier) {
2374
- thePlugin = ext;
2375
- return -1;
2376
- }
2377
- });
2378
- if (thePlugin) {
2379
- return -1;
2380
- }
2100
+ _notificationManager = notificationManager;
2101
+ _self[strNotificationManager] = notificationManager;
2102
+ _self.config = config || {};
2103
+ if (notificationManager && _self.config.disableDbgExt !== true) {
2104
+ notificationManager.addNotificationListener(getDebugListener(config));
2381
2105
  }
2382
- });
2383
- }
2384
- return thePlugin;
2385
- }
2386
- var isInitialized = false;
2387
- var channelController = (_a = {
2388
- identifier: "ChannelControllerPlugin",
2389
- priority: ChannelControllerPriority,
2390
- initialize: function (config, core, extensions, pluginChain) {
2391
- isInitialized = true;
2392
- arrForEach(channelQueue, function (channels) {
2393
- if (channels && channels.queue.length > 0) {
2394
- initializePlugins(createProcessTelemetryContext(channels.chain, config, core), extensions);
2395
- }
2396
- });
2397
- },
2398
- isInitialized: function () {
2399
- return isInitialized;
2400
- },
2401
- processTelemetry: function (item, itemCtx) {
2402
- _processChannelQueue(channelQueue, itemCtx || _getTelCtx(), function (chainCtx) {
2403
- chainCtx[strProcessNext](item);
2404
- }, function () {
2405
- itemCtx[strProcessNext](item);
2406
- });
2407
- },
2408
- update: _doUpdate
2409
- },
2410
- _a[strPause] = function () {
2411
- _processChannelQueue(channelQueue, _getTelCtx(), function (chainCtx) {
2412
- chainCtx.iterate(function (plugin) {
2413
- plugin[strPause] && plugin[strPause]();
2414
- });
2415
- }, null);
2416
- },
2417
- _a[strResume] = function () {
2418
- _processChannelQueue(channelQueue, _getTelCtx(), function (chainCtx) {
2419
- chainCtx.iterate(function (plugin) {
2420
- plugin[strResume] && plugin[strResume]();
2421
- });
2422
- }, null);
2423
- },
2424
- _a[strTeardown] = _doTeardown,
2425
- _a.getChannel = _getChannel,
2426
- _a.flush = function (isAsync, callBack, sendReason, cbTimeout) {
2427
- var waiting = 1;
2428
- var doneIterating = false;
2429
- var cbTimer = null;
2430
- cbTimeout = cbTimeout || 5000;
2431
- function doCallback() {
2432
- waiting--;
2433
- if (doneIterating && waiting === 0) {
2434
- if (cbTimer) {
2435
- clearTimeout(cbTimer);
2436
- cbTimer = null;
2437
- }
2438
- callBack && callBack(doneIterating);
2439
- callBack = null;
2106
+ if (_self.config.enablePerfMgr) {
2107
+ setValue(_self.config, "createPerfMgr", _createPerfManager);
2440
2108
  }
2441
- }
2442
- _processChannelQueue(channelQueue, _getTelCtx(), function (chainCtx) {
2443
- chainCtx.iterate(function (plugin) {
2444
- if (plugin.flush) {
2445
- waiting++;
2446
- var handled_1 = false;
2447
- if (!plugin.flush(isAsync, function () {
2448
- handled_1 = true;
2449
- doCallback();
2450
- }, sendReason)) {
2451
- if (!handled_1) {
2452
- if (isAsync && cbTimer == null) {
2453
- cbTimer = setTimeout(function () {
2454
- cbTimer = null;
2455
- doCallback();
2456
- }, cbTimeout);
2457
- }
2458
- else {
2459
- doCallback();
2460
- }
2461
- }
2109
+ config.extensions = isNullOrUndefined(config.extensions) ? [] : config.extensions;
2110
+ var extConfig = getSetValue(config, strExtensionConfig);
2111
+ extConfig.NotificationManager = notificationManager;
2112
+ if (logger) {
2113
+ _self.logger = logger;
2114
+ }
2115
+ var allExtensions = [];
2116
+ allExtensions.push.apply(allExtensions, __spreadArrayFn(__spreadArrayFn([], extensions, false), config.extensions));
2117
+ allExtensions = sortPlugins(allExtensions);
2118
+ var coreExtensions = [];
2119
+ var extPriorities = {};
2120
+ arrForEach(allExtensions, function (ext) {
2121
+ if (isNullOrUndefined(ext) || isNullOrUndefined(ext.initialize)) {
2122
+ throwError(validationError);
2123
+ }
2124
+ var extPriority = ext.priority;
2125
+ var identifier = ext.identifier;
2126
+ if (ext && extPriority) {
2127
+ if (!isNullOrUndefined(extPriorities[extPriority])) {
2128
+ logger.warnToConsole("Two extensions have same priority #" + extPriority + " - " + extPriorities[extPriority] + ", " + identifier);
2129
+ }
2130
+ else {
2131
+ extPriorities[extPriority] = identifier;
2462
2132
  }
2463
2133
  }
2134
+ if (!extPriority || extPriority < _channelController.priority) {
2135
+ coreExtensions.push(ext);
2136
+ }
2464
2137
  });
2465
- }, function () {
2466
- doneIterating = true;
2467
- doCallback();
2468
- });
2469
- return true;
2470
- },
2471
- _a._setQueue = function (queue) {
2472
- channelQueue = queue;
2473
- },
2474
- _a);
2475
- return channelController;
2476
- }
2477
- function createChannelQueues(channels, extensions, config, core) {
2478
- var channelQueue = [];
2479
- if (channels) {
2480
- arrForEach(channels, function (queue) { return _addChannelQueue(channelQueue, queue, config, core); });
2481
- }
2482
- if (extensions) {
2483
- var extensionQueue_1 = [];
2484
- arrForEach(extensions, function (plugin) {
2485
- if (plugin.priority > ChannelControllerPriority) {
2486
- extensionQueue_1.push(plugin);
2487
- }
2488
- });
2489
- _addChannelQueue(channelQueue, extensionQueue_1, config, core);
2490
- }
2491
- return channelQueue;
2492
- }
2493
-
2494
- function createUnloadHandlerContainer() {
2495
- var handlers = [];
2496
- function _addHandler(handler) {
2497
- if (handler) {
2498
- handlers.push(handler);
2499
- }
2500
- }
2501
- function _runHandlers(unloadCtx, unloadState) {
2502
- arrForEach(handlers, function (handler) {
2503
- try {
2504
- handler(unloadCtx, unloadState);
2505
- }
2506
- catch (e) {
2507
- _throwInternal(unloadCtx.diagLog(), 2 , 73 , "Unexpected error calling unload handler - " + dumpObj(e));
2508
- }
2509
- });
2510
- handlers = [];
2511
- }
2512
- return {
2513
- add: _addHandler,
2514
- run: _runHandlers
2515
- };
2516
- }
2517
-
2518
- var strGetPlugin = "getPlugin";
2519
- var BaseTelemetryPlugin = /** @class */ (function () {
2520
- function BaseTelemetryPlugin() {
2521
- var _self = this;
2522
- var _isinitialized;
2523
- var _rootCtx;
2524
- var _nextPlugin;
2525
- var _unloadHandlerContainer;
2526
- var _hooks;
2527
- _initDefaults();
2528
- dynamicProto(BaseTelemetryPlugin, _self, function (_self) {
2529
- _self.initialize = function (config, core, extensions, pluginChain) {
2530
- _setDefaults(config, core, pluginChain);
2531
- _isinitialized = true;
2532
- };
2533
- _self.teardown = function (unloadCtx, unloadState) {
2534
- if (!_self.core || (unloadCtx && _self.core !== unloadCtx.core())) {
2535
- return;
2536
- }
2537
- var result;
2538
- var unloadDone = false;
2539
- var theUnloadCtx = unloadCtx || createProcessTelemetryUnloadContext(null, {}, _self.core, _nextPlugin && _nextPlugin[strGetPlugin] ? _nextPlugin[strGetPlugin]() : _nextPlugin);
2540
- var theUnloadState = unloadState || {
2541
- reason: 0 ,
2542
- isAsync: false
2543
- };
2544
- function _unloadCallback() {
2545
- if (!unloadDone) {
2546
- unloadDone = true;
2547
- _unloadHandlerContainer.run(theUnloadCtx, unloadState);
2548
- arrForEach(_hooks, function (fn) {
2549
- fn.rm();
2550
- });
2551
- _hooks = [];
2552
- if (result === true) {
2553
- theUnloadCtx.processNext(theUnloadState);
2554
- }
2555
- _initDefaults();
2556
- }
2557
- }
2558
- if (!_self[strDoTeardown] || _self[strDoTeardown](theUnloadCtx, theUnloadState, _unloadCallback) !== true) {
2559
- _unloadCallback();
2560
- }
2561
- else {
2562
- result = true;
2563
- }
2564
- return result;
2565
- };
2566
- _self.update = function (updateCtx, updateState) {
2567
- if (!_self.core || (updateCtx && _self.core !== updateCtx.core())) {
2568
- return;
2569
- }
2570
- var result;
2571
- var updateDone = false;
2572
- var theUpdateCtx = updateCtx || createProcessTelemetryUpdateContext(null, {}, _self.core, _nextPlugin && _nextPlugin[strGetPlugin] ? _nextPlugin[strGetPlugin]() : _nextPlugin);
2573
- var theUpdateState = updateState || {
2574
- reason: 0
2575
- };
2576
- function _updateCallback() {
2577
- if (!updateDone) {
2578
- updateDone = true;
2579
- _setDefaults(theUpdateCtx.getCfg(), theUpdateCtx.core(), theUpdateCtx.getNext());
2580
- }
2581
- }
2582
- if (!_self._doUpdate || _self._doUpdate(theUpdateCtx, theUpdateState, _updateCallback) !== true) {
2583
- _updateCallback();
2584
- }
2585
- else {
2586
- result = true;
2587
- }
2588
- return result;
2589
- };
2590
- _self._addHook = function (hooks) {
2591
- if (hooks) {
2592
- if (isArray(hooks)) {
2593
- _hooks = _hooks.concat(hooks);
2594
- }
2595
- else {
2596
- _hooks.push(hooks);
2597
- }
2598
- }
2599
- };
2600
- proxyFunctionAs(_self, "_addUnloadCb", function () { return _unloadHandlerContainer; }, "add");
2601
- });
2602
- _self.diagLog = function (itemCtx) {
2603
- return _getTelCtx(itemCtx).diagLog();
2604
- };
2605
- _self[strIsInitialized] = function () {
2606
- return _isinitialized;
2607
- };
2608
- _self.setInitialized = function (isInitialized) {
2609
- _isinitialized = isInitialized;
2610
- };
2611
- _self[strSetNextPlugin] = function (next) {
2612
- _nextPlugin = next;
2613
- };
2614
- _self.processNext = function (env, itemCtx) {
2615
- if (itemCtx) {
2616
- itemCtx.processNext(env);
2617
- }
2618
- else if (_nextPlugin && isFunction(_nextPlugin.processTelemetry)) {
2619
- _nextPlugin.processTelemetry(env, null);
2620
- }
2621
- };
2622
- _self._getTelCtx = _getTelCtx;
2623
- function _getTelCtx(currentCtx) {
2624
- if (currentCtx === void 0) { currentCtx = null; }
2625
- var itemCtx = currentCtx;
2626
- if (!itemCtx) {
2627
- var rootCtx = _rootCtx || createProcessTelemetryContext(null, {}, _self.core);
2628
- if (_nextPlugin && _nextPlugin[strGetPlugin]) {
2629
- itemCtx = rootCtx.createNew(null, _nextPlugin[strGetPlugin]);
2630
- }
2631
- else {
2632
- itemCtx = rootCtx.createNew(null, _nextPlugin);
2633
- }
2634
- }
2635
- return itemCtx;
2636
- }
2637
- function _setDefaults(config, core, pluginChain) {
2638
- if (config) {
2639
- setValue(config, strExtensionConfig, [], null, isNullOrUndefined);
2640
- }
2641
- if (!pluginChain && core) {
2642
- pluginChain = core.getProcessTelContext().getNext();
2643
- }
2644
- var nextPlugin = _nextPlugin;
2645
- if (_nextPlugin && _nextPlugin[strGetPlugin]) {
2646
- nextPlugin = _nextPlugin[strGetPlugin]();
2647
- }
2648
- _self.core = core;
2649
- _rootCtx = createProcessTelemetryContext(pluginChain, config, core, nextPlugin);
2650
- }
2651
- function _initDefaults() {
2652
- _isinitialized = false;
2653
- _self.core = null;
2654
- _rootCtx = null;
2655
- _nextPlugin = null;
2656
- _hooks = [];
2657
- _unloadHandlerContainer = createUnloadHandlerContainer();
2658
- }
2659
- }
2660
- return BaseTelemetryPlugin;
2661
- }());
2662
-
2663
- var TelemetryInitializerPlugin = /** @class */ (function (_super) {
2664
- __extendsFn(TelemetryInitializerPlugin, _super);
2665
- function TelemetryInitializerPlugin() {
2666
- var _this = _super.call(this) || this;
2667
- _this.identifier = "TelemetryInitializerPlugin";
2668
- _this.priority = 199;
2669
- var _id;
2670
- var _initializers;
2671
- _initDefaults();
2672
- dynamicProto(TelemetryInitializerPlugin, _this, function (_self, _base) {
2673
- _self.addTelemetryInitializer = function (telemetryInitializer) {
2674
- var theInitializer = {
2675
- id: _id++,
2676
- fn: telemetryInitializer
2677
- };
2678
- _initializers.push(theInitializer);
2679
- var handler = {
2680
- remove: function () {
2681
- arrForEach(_initializers, function (initializer, idx) {
2682
- if (initializer.id === theInitializer.id) {
2683
- _initializers.splice(idx, 1);
2684
- return -1;
2685
- }
2686
- });
2687
- }
2688
- };
2689
- return handler;
2690
- };
2691
- _self.processTelemetry = function (item, itemCtx) {
2692
- var doNotSendItem = false;
2693
- var telemetryInitializersCount = _initializers.length;
2694
- for (var i = 0; i < telemetryInitializersCount; ++i) {
2695
- var telemetryInitializer = _initializers[i];
2696
- if (telemetryInitializer) {
2697
- try {
2698
- if (telemetryInitializer.fn.apply(null, [item]) === false) {
2699
- doNotSendItem = true;
2700
- break;
2701
- }
2702
- }
2703
- catch (e) {
2704
- _throwInternal(itemCtx.diagLog(), 1 , 64 , "One of telemetry initializers failed, telemetry item will not be sent: " + getExceptionName(e), { exception: dumpObj(e) }, true);
2705
- }
2706
- }
2707
- }
2708
- if (!doNotSendItem) {
2709
- _self.processNext(item, itemCtx);
2710
- }
2711
- };
2712
- _self[strDoTeardown] = function () {
2713
- _initDefaults();
2714
- };
2715
- });
2716
- function _initDefaults() {
2717
- _id = 0;
2718
- _initializers = [];
2719
- }
2720
- return _this;
2721
- }
2722
- return TelemetryInitializerPlugin;
2723
- }(BaseTelemetryPlugin));
2724
-
2725
- var strValidationError = "Plugins must provide initialize method";
2726
- var strNotificationManager = "_notificationManager";
2727
- var strSdkUnloadingError = "SDK is still unloading...";
2728
- var strSdkNotInitialized = "SDK is not initialized";
2729
- function _createPerfManager(core, notificationMgr) {
2730
- return new PerfManager(notificationMgr);
2731
- }
2732
- function _validateExtensions(logger, channelPriority, allExtensions) {
2733
- var coreExtensions = [];
2734
- var extPriorities = {};
2735
- arrForEach(allExtensions, function (ext) {
2736
- if (isNullOrUndefined(ext) || isNullOrUndefined(ext.initialize)) {
2737
- throwError(strValidationError);
2738
- }
2739
- var extPriority = ext.priority;
2740
- var identifier = ext.identifier;
2741
- if (ext && extPriority) {
2742
- if (!isNullOrUndefined(extPriorities[extPriority])) {
2743
- logger.warnToConsole("Two extensions have same priority #" + extPriority + " - " + extPriorities[extPriority] + ", " + identifier);
2744
- }
2745
- else {
2746
- extPriorities[extPriority] = identifier;
2747
- }
2748
- }
2749
- if (!extPriority || extPriority < channelPriority) {
2750
- coreExtensions.push(ext);
2751
- }
2752
- });
2753
- return {
2754
- all: allExtensions,
2755
- core: coreExtensions
2756
- };
2757
- }
2758
- function _isPluginPresent(thePlugin, plugins) {
2759
- var exists = false;
2760
- arrForEach(plugins, function (plugin) {
2761
- if (plugin === thePlugin) {
2762
- exists = true;
2763
- return -1;
2764
- }
2765
- });
2766
- return exists;
2767
- }
2768
- function _createDummyNotificationManager() {
2769
- var _a;
2770
- return objCreateFn((_a = {},
2771
- _a[strAddNotificationListener] = function (listener) { },
2772
- _a[strRemoveNotificationListener] = function (listener) { },
2773
- _a[strEventsSent] = function (events) { },
2774
- _a[strEventsDiscarded] = function (events, reason) { },
2775
- _a[strEventsSendRequest] = function (sendReason, isAsync) { },
2776
- _a));
2777
- }
2778
- var BaseCore = /** @class */ (function () {
2779
- function BaseCore() {
2780
- var _isInitialized;
2781
- var _eventQueue;
2782
- var _notificationManager;
2783
- var _perfManager;
2784
- var _cfgPerfManager;
2785
- var _cookieManager;
2786
- var _pluginChain;
2787
- var _configExtensions;
2788
- var _coreExtensions;
2789
- var _channelControl;
2790
- var _channelConfig;
2791
- var _channelQueue;
2792
- var _isUnloading;
2793
- var _telemetryInitializerPlugin;
2794
- var _internalLogsEventName;
2795
- var _evtNamespace;
2796
- var _unloadHandlers;
2797
- var _debugListener;
2798
- var _internalLogPoller = 0;
2799
- dynamicProto(BaseCore, this, function (_self) {
2800
- _initDefaults();
2801
- _self.isInitialized = function () { return _isInitialized; };
2802
- _self.initialize = function (config, extensions, logger, notificationManager) {
2803
- if (_isUnloading) {
2804
- throwError(strSdkUnloadingError);
2805
- }
2806
- if (_self.isInitialized()) {
2807
- throwError("Core should not be initialized more than once");
2808
- }
2809
- if (!config || isNullOrUndefined(config.instrumentationKey)) {
2810
- throwError("Please provide instrumentation key");
2811
- }
2812
- _notificationManager = notificationManager;
2813
- _self[strNotificationManager] = notificationManager;
2814
- _self.config = config || {};
2815
- _initDebugListener(config);
2816
- _initPerfManager(config);
2817
- config.extensions = isNullOrUndefined(config.extensions) ? [] : config.extensions;
2818
- _initExtConfig(config);
2819
- if (logger) {
2820
- _self.logger = logger;
2821
- }
2822
- _configExtensions = [];
2823
- _configExtensions.push.apply(_configExtensions, __spreadArrayFn(__spreadArrayFn([], extensions, false), config.extensions));
2824
- _channelConfig = (config || {}).channels;
2825
- _initPluginChain(config, null);
2826
- if (!_channelQueue || _channelQueue.length === 0) {
2138
+ allExtensions.push(_channelController);
2139
+ coreExtensions.push(_channelController);
2140
+ allExtensions = sortPlugins(allExtensions);
2141
+ _self._extensions = allExtensions;
2142
+ initializePlugins(new ProcessTelemetryContext([_channelController], config, _self), allExtensions);
2143
+ initializePlugins(new ProcessTelemetryContext(coreExtensions, config, _self), allExtensions);
2144
+ _self._extensions = coreExtensions;
2145
+ if (_self.getTransmissionControls().length === 0) {
2827
2146
  throwError("No channels available");
2828
2147
  }
2829
2148
  _isInitialized = true;
2830
2149
  _self.releaseQueue();
2831
2150
  };
2832
2151
  _self.getTransmissionControls = function () {
2833
- var controls = [];
2834
- if (_channelQueue) {
2835
- arrForEach(_channelQueue, function (channels) {
2836
- controls.push(channels.queue);
2837
- });
2838
- }
2839
- return objFreeze(controls);
2152
+ return _channelController.getChannelControls();
2840
2153
  };
2841
2154
  _self.track = function (telemetryItem) {
2842
2155
  setValue(telemetryItem, strIKey, _self.config.instrumentationKey, null, isNotTruthy);
2843
2156
  setValue(telemetryItem, "time", toISOString(new Date()), null, isNotTruthy);
2844
2157
  setValue(telemetryItem, "ver", "4.0", null, isNullOrUndefined);
2845
- if (!_isUnloading && _self.isInitialized()) {
2846
- _createTelCtx().processNext(telemetryItem);
2158
+ if (_self.isInitialized()) {
2159
+ _self.getProcessTelContext().processNext(telemetryItem);
2847
2160
  }
2848
2161
  else {
2849
2162
  _eventQueue.push(telemetryItem);
2850
2163
  }
2851
2164
  };
2852
- _self.getProcessTelContext = _createTelCtx;
2165
+ _self.getProcessTelContext = function () {
2166
+ var extensions = _self._extensions;
2167
+ var thePlugins = extensions;
2168
+ if (!extensions || extensions.length === 0) {
2169
+ thePlugins = [_channelController];
2170
+ }
2171
+ return new ProcessTelemetryContext(thePlugins, _self.config, _self);
2172
+ };
2853
2173
  _self.getNotifyMgr = function () {
2854
2174
  if (!_notificationManager) {
2855
- _notificationManager = _createDummyNotificationManager();
2175
+ _notificationManager = objCreateFn({
2176
+ addNotificationListener: function (listener) { },
2177
+ removeNotificationListener: function (listener) { },
2178
+ eventsSent: function (events) { },
2179
+ eventsDiscarded: function (events, reason) { },
2180
+ eventsSendRequest: function (sendReason, isAsync) { }
2181
+ });
2856
2182
  _self[strNotificationManager] = _notificationManager;
2857
2183
  }
2858
2184
  return _notificationManager;
2859
2185
  };
2860
- _self[strAddNotificationListener] = function (listener) {
2861
- if (_notificationManager) {
2862
- _notificationManager[strAddNotificationListener](listener);
2863
- }
2864
- };
2865
- _self[strRemoveNotificationListener] = function (listener) {
2866
- if (_notificationManager) {
2867
- _notificationManager[strRemoveNotificationListener](listener);
2868
- }
2869
- };
2870
2186
  _self.getCookieMgr = function () {
2871
2187
  if (!_cookieManager) {
2872
2188
  _cookieManager = createCookieMgr(_self.config, _self.logger);
@@ -2877,12 +2193,12 @@
2877
2193
  _cookieManager = cookieMgr;
2878
2194
  };
2879
2195
  _self.getPerfMgr = function () {
2880
- if (!_perfManager && !_cfgPerfManager) {
2196
+ if (!_perfManager) {
2881
2197
  if (_self.config && _self.config.enablePerfMgr && isFunction(_self.config.createPerfMgr)) {
2882
- _cfgPerfManager = _self.config.createPerfMgr(_self, _self.getNotifyMgr());
2198
+ _perfManager = _self.config.createPerfMgr(_self, _self.getNotifyMgr());
2883
2199
  }
2884
2200
  }
2885
- return _perfManager || _cfgPerfManager || getGblPerfMgr();
2201
+ return _perfManager || getGblPerfMgr();
2886
2202
  };
2887
2203
  _self.setPerfMgr = function (perfMgr) {
2888
2204
  _perfManager = perfMgr;
@@ -2891,381 +2207,78 @@
2891
2207
  return _eventQueue.length;
2892
2208
  };
2893
2209
  _self.releaseQueue = function () {
2894
- if (_isInitialized && _eventQueue.length > 0) {
2895
- var eventQueue = _eventQueue;
2896
- _eventQueue = [];
2897
- arrForEach(eventQueue, function (event) {
2898
- _createTelCtx().processNext(event);
2899
- });
2900
- }
2901
- };
2902
- _self.pollInternalLogs = function (eventName) {
2903
- _internalLogsEventName = eventName || null;
2904
- var interval = _self.config.diagnosticLogInterval;
2905
- if (!interval || !(interval > 0)) {
2906
- interval = 10000;
2907
- }
2908
- if (_internalLogPoller) {
2909
- clearInterval(_internalLogPoller);
2910
- }
2911
- _internalLogPoller = setInterval(function () {
2912
- _flushInternalLogs();
2913
- }, interval);
2914
- return _internalLogPoller;
2915
- };
2916
- _self.stopPollingInternalLogs = function () {
2917
- if (_internalLogPoller) {
2918
- clearInterval(_internalLogPoller);
2919
- _internalLogPoller = 0;
2920
- _flushInternalLogs();
2921
- }
2922
- };
2923
- proxyFunctions(_self, function () { return _telemetryInitializerPlugin; }, ["addTelemetryInitializer"]);
2924
- _self.unload = function (isAsync, unloadComplete, cbTimeout) {
2925
- if (isAsync === void 0) { isAsync = true; }
2926
- if (!_isInitialized) {
2927
- throwError(strSdkNotInitialized);
2928
- }
2929
- if (_isUnloading) {
2930
- throwError(strSdkUnloadingError);
2931
- }
2932
- var unloadState = {
2933
- reason: 50 ,
2934
- isAsync: isAsync,
2935
- flushComplete: false
2936
- };
2937
- var processUnloadCtx = createProcessTelemetryUnloadContext(_getPluginChain(), _self.config, _self);
2938
- processUnloadCtx.onComplete(function () {
2939
- _initDefaults();
2940
- unloadComplete && unloadComplete(unloadState);
2941
- }, _self);
2942
- function _doUnload(flushComplete) {
2943
- unloadState.flushComplete = flushComplete;
2944
- _isUnloading = true;
2945
- _unloadHandlers.run(processUnloadCtx, unloadState);
2946
- _self.stopPollingInternalLogs();
2947
- processUnloadCtx.processNext(unloadState);
2948
- }
2949
- if (!_flushChannels(isAsync, _doUnload, 6 , cbTimeout)) {
2950
- _doUnload(false);
2951
- }
2952
- };
2953
- _self.getPlugin = _getPlugin;
2954
- _self.addPlugin = function (plugin, replaceExisting, isAsync, addCb) {
2955
- if (!plugin) {
2956
- addCb && addCb(false);
2957
- _logOrThrowError(strValidationError);
2958
- return;
2959
- }
2960
- var existingPlugin = _getPlugin(plugin.identifier);
2961
- if (existingPlugin && !replaceExisting) {
2962
- addCb && addCb(false);
2963
- _logOrThrowError("Plugin [" + plugin.identifier + "] is already loaded!");
2964
- return;
2965
- }
2966
- var updateState = {
2967
- reason: 16
2968
- };
2969
- function _addPlugin(removed) {
2970
- _configExtensions.push(plugin);
2971
- updateState.added = [plugin];
2972
- _initPluginChain(_self.config, updateState);
2973
- addCb && addCb(true);
2974
- }
2975
- if (existingPlugin) {
2976
- var removedPlugins_1 = [existingPlugin.plugin];
2977
- var unloadState = {
2978
- reason: 2 ,
2979
- isAsync: !!isAsync
2980
- };
2981
- _removePlugins(removedPlugins_1, unloadState, function (removed) {
2982
- if (!removed) {
2983
- addCb && addCb(false);
2984
- }
2985
- else {
2986
- updateState.removed = removedPlugins_1;
2987
- updateState.reason |= 32 ;
2988
- _addPlugin();
2989
- }
2210
+ if (_eventQueue.length > 0) {
2211
+ arrForEach(_eventQueue, function (event) {
2212
+ _self.getProcessTelContext().processNext(event);
2990
2213
  });
2991
- }
2992
- else {
2993
- _addPlugin();
2214
+ _eventQueue = [];
2994
2215
  }
2995
2216
  };
2996
- _self.evtNamespace = function () {
2997
- return _evtNamespace;
2998
- };
2999
- _self.flush = _flushChannels;
3000
- proxyFunctionAs(_self, "addUnloadCb", function () { return _unloadHandlers; }, "add");
3001
- function _initDefaults() {
3002
- _isInitialized = false;
3003
- _self.logger = new DiagnosticLogger({ loggingLevelConsole: 1 });
3004
- _self.config = {};
3005
- _self._extensions = [];
3006
- _telemetryInitializerPlugin = new TelemetryInitializerPlugin();
3007
- _eventQueue = [];
3008
- _notificationManager = null;
3009
- _perfManager = null;
3010
- _cfgPerfManager = null;
3011
- _cookieManager = null;
3012
- _pluginChain = null;
3013
- _coreExtensions = null;
3014
- _configExtensions = [];
3015
- _channelControl = null;
3016
- _channelConfig = null;
3017
- _channelQueue = null;
3018
- _isUnloading = false;
3019
- _internalLogsEventName = null;
3020
- _evtNamespace = createUniqueNamespace("AIBaseCore", true);
3021
- _unloadHandlers = createUnloadHandlerContainer();
3022
- }
3023
- function _createTelCtx() {
3024
- return createProcessTelemetryContext(_getPluginChain(), _self.config, _self);
3025
- }
3026
- function _initPluginChain(config, updateState) {
3027
- var theExtensions = _validateExtensions(_self.logger, ChannelControllerPriority, _configExtensions);
3028
- _coreExtensions = theExtensions.core;
3029
- _pluginChain = null;
3030
- var allExtensions = theExtensions.all;
3031
- _channelQueue = objFreeze(createChannelQueues(_channelConfig, allExtensions, config, _self));
3032
- if (_channelControl) {
3033
- var idx = allExtensions.indexOf(_channelControl);
3034
- if (idx !== -1) {
3035
- allExtensions.splice(idx, 1);
3036
- }
3037
- idx = _coreExtensions.indexOf(_channelControl);
3038
- if (idx !== -1) {
3039
- _coreExtensions.splice(idx, 1);
3040
- }
3041
- _channelControl._setQueue(_channelQueue);
3042
- }
3043
- else {
3044
- _channelControl = createChannelControllerPlugin(_channelQueue, _self);
3045
- }
3046
- allExtensions.push(_channelControl);
3047
- _coreExtensions.push(_channelControl);
3048
- _self._extensions = sortPlugins(allExtensions);
3049
- _channelControl.initialize(config, _self, allExtensions);
3050
- initializePlugins(_createTelCtx(), allExtensions);
3051
- _self._extensions = objFreeze(sortPlugins(_coreExtensions || [])).slice();
3052
- if (updateState) {
3053
- _doUpdate(updateState);
3054
- }
3055
- }
3056
- function _getPlugin(pluginIdentifier) {
3057
- var theExt = null;
3058
- var thePlugin = null;
3059
- arrForEach(_self._extensions, function (ext) {
3060
- if (ext.identifier === pluginIdentifier && ext !== _channelControl && ext !== _telemetryInitializerPlugin) {
3061
- thePlugin = ext;
3062
- return -1;
3063
- }
3064
- });
3065
- if (!thePlugin && _channelControl) {
3066
- thePlugin = _channelControl.getChannel(pluginIdentifier);
3067
- }
3068
- if (thePlugin) {
3069
- theExt = {
3070
- plugin: thePlugin,
3071
- setEnabled: function (enabled) {
3072
- _getPluginState(thePlugin)[strDisabled] = !enabled;
3073
- },
3074
- isEnabled: function () {
3075
- var pluginState = _getPluginState(thePlugin);
3076
- return !pluginState[strTeardown] && !pluginState[strDisabled];
3077
- },
3078
- remove: function (isAsync, removeCb) {
3079
- if (isAsync === void 0) { isAsync = true; }
3080
- var pluginsToRemove = [thePlugin];
3081
- var unloadState = {
3082
- reason: 1 ,
3083
- isAsync: isAsync
3084
- };
3085
- _removePlugins(pluginsToRemove, unloadState, function (removed) {
3086
- if (removed) {
3087
- _initPluginChain(_self.config, {
3088
- reason: 32 ,
3089
- removed: pluginsToRemove
3090
- });
3091
- }
3092
- removeCb && removeCb(removed);
3093
- });
3094
- }
3095
- };
3096
- }
3097
- return theExt;
3098
- }
3099
- function _getPluginChain() {
3100
- if (!_pluginChain) {
3101
- var extensions = (_coreExtensions || []).slice();
3102
- if (extensions.indexOf(_telemetryInitializerPlugin) === -1) {
3103
- extensions.push(_telemetryInitializerPlugin);
3104
- }
3105
- _pluginChain = createTelemetryProxyChain(sortPlugins(extensions), _self.config, _self);
3106
- }
3107
- return _pluginChain;
3108
- }
3109
- function _removePlugins(thePlugins, unloadState, removeComplete) {
3110
- if (thePlugins && thePlugins.length > 0) {
3111
- var unloadChain = createTelemetryProxyChain(thePlugins, _self.config, _self);
3112
- var unloadCtx = createProcessTelemetryUnloadContext(unloadChain, _self.config, _self);
3113
- unloadCtx.onComplete(function () {
3114
- var removed = false;
3115
- var newConfigExtensions = [];
3116
- arrForEach(_configExtensions, function (plugin, idx) {
3117
- if (!_isPluginPresent(plugin, thePlugins)) {
3118
- newConfigExtensions.push(plugin);
3119
- }
3120
- else {
3121
- removed = true;
3122
- }
3123
- });
3124
- _configExtensions = newConfigExtensions;
3125
- var newChannelConfig = [];
3126
- if (_channelConfig) {
3127
- arrForEach(_channelConfig, function (queue, idx) {
3128
- var newQueue = [];
3129
- arrForEach(queue, function (channel) {
3130
- if (!_isPluginPresent(channel, thePlugins)) {
3131
- newQueue.push(channel);
3132
- }
3133
- else {
3134
- removed = true;
3135
- }
3136
- });
3137
- newChannelConfig.push(newQueue);
3138
- });
3139
- _channelConfig = newChannelConfig;
3140
- }
3141
- removeComplete && removeComplete(removed);
3142
- });
3143
- unloadCtx.processNext(unloadState);
3144
- }
3145
- else {
3146
- removeComplete(false);
3147
- }
3148
- }
3149
- function _flushInternalLogs() {
3150
- var queue = _self.logger ? _self.logger.queue : [];
3151
- if (queue) {
3152
- arrForEach(queue, function (logMessage) {
3153
- var item = {
3154
- name: _internalLogsEventName ? _internalLogsEventName : "InternalMessageId: " + logMessage.messageId,
3155
- iKey: _self.config.instrumentationKey,
3156
- time: toISOString(new Date()),
3157
- baseType: _InternalLogMessage.dataType,
3158
- baseData: { message: logMessage.message }
3159
- };
3160
- _self.track(item);
3161
- });
3162
- queue.length = 0;
3163
- }
3164
- }
3165
- function _flushChannels(isAsync, callBack, sendReason, cbTimeout) {
3166
- if (_channelControl) {
3167
- return _channelControl.flush(isAsync, callBack, sendReason || 6 , cbTimeout);
3168
- }
3169
- callBack && callBack(false);
3170
- return true;
3171
- }
3172
- function _initDebugListener(config) {
3173
- if (config.disableDbgExt === true && _debugListener) {
3174
- _notificationManager[strRemoveNotificationListener](_debugListener);
3175
- _debugListener = null;
3176
- }
3177
- if (_notificationManager && !_debugListener && config.disableDbgExt !== true) {
3178
- _debugListener = getDebugListener(config);
3179
- _notificationManager[strAddNotificationListener](_debugListener);
3180
- }
3181
- }
3182
- function _initPerfManager(config) {
3183
- if (!config.enablePerfMgr && _cfgPerfManager) {
3184
- _cfgPerfManager = null;
3185
- }
3186
- if (config.enablePerfMgr) {
3187
- setValue(_self.config, "createPerfMgr", _createPerfManager);
3188
- }
3189
- }
3190
- function _initExtConfig(config) {
3191
- var extConfig = getSetValue(config, strExtensionConfig);
3192
- extConfig.NotificationManager = _notificationManager;
3193
- }
3194
- function _doUpdate(updateState) {
3195
- var updateCtx = createProcessTelemetryUpdateContext(_getPluginChain(), _self.config, _self);
3196
- if (!_self._updateHook || _self._updateHook(updateCtx, updateState) !== true) {
3197
- updateCtx.processNext(updateState);
3198
- }
3199
- }
3200
- function _logOrThrowError(message) {
3201
- var logger = _self.logger;
3202
- if (logger) {
3203
- _throwInternal(logger, 2 , 73 , message);
3204
- }
3205
- else {
3206
- throwError(message);
3207
- }
3208
- }
3209
2217
  });
3210
2218
  }
3211
2219
  return BaseCore;
3212
2220
  }());
3213
2221
 
3214
- function _runListeners(listeners, name, isAsync, callback) {
3215
- arrForEach(listeners, function (listener) {
3216
- if (listener && listener[name]) {
3217
- if (isAsync) {
3218
- setTimeout(function () { return callback(listener); }, 0);
3219
- }
3220
- else {
3221
- try {
3222
- callback(listener);
3223
- }
3224
- catch (e) {
3225
- }
3226
- }
3227
- }
3228
- });
3229
- }
3230
2222
  var NotificationManager = /** @class */ (function () {
3231
2223
  function NotificationManager(config) {
3232
2224
  this.listeners = [];
3233
2225
  var perfEvtsSendAll = !!(config || {}).perfEvtsSendAll;
3234
2226
  dynamicProto(NotificationManager, this, function (_self) {
3235
- _self[strAddNotificationListener] = function (listener) {
2227
+ _self.addNotificationListener = function (listener) {
3236
2228
  _self.listeners.push(listener);
3237
2229
  };
3238
- _self[strRemoveNotificationListener] = function (listener) {
2230
+ _self.removeNotificationListener = function (listener) {
3239
2231
  var index = arrIndexOf(_self.listeners, listener);
3240
2232
  while (index > -1) {
3241
2233
  _self.listeners.splice(index, 1);
3242
2234
  index = arrIndexOf(_self.listeners, listener);
3243
2235
  }
3244
2236
  };
3245
- _self[strEventsSent] = function (events) {
3246
- _runListeners(_self.listeners, strEventsSent, true, function (listener) {
3247
- listener[strEventsSent](events);
2237
+ _self.eventsSent = function (events) {
2238
+ arrForEach(_self.listeners, function (listener) {
2239
+ if (listener && listener.eventsSent) {
2240
+ setTimeout(function () { return listener.eventsSent(events); }, 0);
2241
+ }
3248
2242
  });
3249
2243
  };
3250
- _self[strEventsDiscarded] = function (events, reason) {
3251
- _runListeners(_self.listeners, strEventsDiscarded, true, function (listener) {
3252
- listener[strEventsDiscarded](events, reason);
2244
+ _self.eventsDiscarded = function (events, reason) {
2245
+ arrForEach(_self.listeners, function (listener) {
2246
+ if (listener && listener.eventsDiscarded) {
2247
+ setTimeout(function () { return listener.eventsDiscarded(events, reason); }, 0);
2248
+ }
3253
2249
  });
3254
2250
  };
3255
- _self[strEventsSendRequest] = function (sendReason, isAsync) {
3256
- _runListeners(_self.listeners, strEventsSendRequest, isAsync, function (listener) {
3257
- listener[strEventsSendRequest](sendReason, isAsync);
2251
+ _self.eventsSendRequest = function (sendReason, isAsync) {
2252
+ arrForEach(_self.listeners, function (listener) {
2253
+ if (listener && listener.eventsSendRequest) {
2254
+ if (isAsync) {
2255
+ setTimeout(function () { return listener.eventsSendRequest(sendReason, isAsync); }, 0);
2256
+ }
2257
+ else {
2258
+ try {
2259
+ listener.eventsSendRequest(sendReason, isAsync);
2260
+ }
2261
+ catch (e) {
2262
+ }
2263
+ }
2264
+ }
3258
2265
  });
3259
2266
  };
3260
- _self[strPerfEvent] = function (perfEvent) {
2267
+ _self.perfEvent = function (perfEvent) {
3261
2268
  if (perfEvent) {
3262
2269
  if (perfEvtsSendAll || !perfEvent.isChildEvt()) {
3263
- _runListeners(_self.listeners, strPerfEvent, false, function (listener) {
3264
- if (perfEvent.isAsync) {
3265
- setTimeout(function () { return listener[strPerfEvent](perfEvent); }, 0);
3266
- }
3267
- else {
3268
- listener[strPerfEvent](perfEvent);
2270
+ arrForEach(_self.listeners, function (listener) {
2271
+ if (listener && listener.perfEvent) {
2272
+ if (perfEvent.isAsync) {
2273
+ setTimeout(function () { return listener.perfEvent(perfEvent); }, 0);
2274
+ }
2275
+ else {
2276
+ try {
2277
+ listener.perfEvent(perfEvent);
2278
+ }
2279
+ catch (e) {
2280
+ }
2281
+ }
3269
2282
  }
3270
2283
  });
3271
2284
  }
@@ -3280,6 +2293,7 @@
3280
2293
  __extendsFn(AppInsightsCore, _super);
3281
2294
  function AppInsightsCore() {
3282
2295
  var _this = _super.call(this) || this;
2296
+ var _internalLogPoller = 0;
3283
2297
  dynamicProto(AppInsightsCore, _this, function (_self, _base) {
3284
2298
  _self.initialize = function (config, extensions, logger, notificationManager) {
3285
2299
  _base.initialize(config, extensions, logger || new DiagnosticLogger(config), notificationManager || new NotificationManager(config));
@@ -3294,6 +2308,48 @@
3294
2308
  _base.track(telemetryItem);
3295
2309
  }, function () { return ({ item: telemetryItem }); }, !(telemetryItem.sync));
3296
2310
  };
2311
+ _self.addNotificationListener = function (listener) {
2312
+ var manager = _self.getNotifyMgr();
2313
+ if (manager) {
2314
+ manager.addNotificationListener(listener);
2315
+ }
2316
+ };
2317
+ _self.removeNotificationListener = function (listener) {
2318
+ var manager = _self.getNotifyMgr();
2319
+ if (manager) {
2320
+ manager.removeNotificationListener(listener);
2321
+ }
2322
+ };
2323
+ _self.pollInternalLogs = function (eventName) {
2324
+ var interval = _self.config.diagnosticLogInterval;
2325
+ if (!interval || !(interval > 0)) {
2326
+ interval = 10000;
2327
+ }
2328
+ if (_internalLogPoller) {
2329
+ _self.stopPollingInternalLogs();
2330
+ }
2331
+ _internalLogPoller = setInterval(function () {
2332
+ var queue = _self.logger ? _self.logger.queue : [];
2333
+ arrForEach(queue, function (logMessage) {
2334
+ var item = {
2335
+ name: eventName ? eventName : "InternalMessageId: " + logMessage.messageId,
2336
+ iKey: _self.config.instrumentationKey,
2337
+ time: toISOString(new Date()),
2338
+ baseType: _InternalLogMessage.dataType,
2339
+ baseData: { message: logMessage.message }
2340
+ };
2341
+ _self.track(item);
2342
+ });
2343
+ queue.length = 0;
2344
+ }, interval);
2345
+ return _internalLogPoller;
2346
+ };
2347
+ _self.stopPollingInternalLogs = function () {
2348
+ if (!_internalLogPoller)
2349
+ return;
2350
+ clearInterval(_internalLogPoller);
2351
+ _internalLogPoller = 0;
2352
+ };
3297
2353
  function _validateTelemetryItem(telemetryItem) {
3298
2354
  if (isNullOrUndefined(telemetryItem.name)) {
3299
2355
  _notifyInvalidEvent(telemetryItem);
@@ -3312,315 +2368,151 @@
3312
2368
  return AppInsightsCore;
3313
2369
  }(BaseCore));
3314
2370
 
3315
- var strOnPrefix = "on";
3316
- var strAttachEvent = "attachEvent";
3317
- var strAddEventHelper = "addEventListener";
3318
- var strDetachEvent = "detachEvent";
3319
- var strRemoveEventListener = "removeEventListener";
3320
- var strEvents = "events";
3321
- var strVisibilityChangeEvt = "visibilitychange";
3322
- var strPageHide = "pagehide";
3323
- var strPageShow = "pageshow";
3324
- var strUnload = "unload";
3325
- var strBeforeUnload = "beforeunload";
3326
- var strPageHideNamespace = createUniqueNamespace("aiEvtPageHide");
3327
- var strPageShowNamespace = createUniqueNamespace("aiEvtPageShow");
3328
- var rRemoveEmptyNs = /\.[\.]+/g;
3329
- var rRemoveTrailingEmptyNs = /[\.]+$/;
3330
- var _guid = 1;
3331
- var elmNodeData = createElmNodeData("events");
3332
- var eventNamespace = /^([^.]*)(?:\.(.+)|)/;
3333
- function _normalizeNamespace(name) {
3334
- if (name && name.replace) {
3335
- return name.replace(/^\s*\.*|\.*\s*$/g, "");
3336
- }
3337
- return name;
3338
- }
3339
- function _getEvtNamespace(eventName, evtNamespace) {
3340
- if (evtNamespace) {
3341
- var theNamespace_1 = "";
3342
- if (isArray(evtNamespace)) {
3343
- theNamespace_1 = "";
3344
- arrForEach(evtNamespace, function (name) {
3345
- name = _normalizeNamespace(name);
3346
- if (name) {
3347
- if (name[0] !== ".") {
3348
- name = "." + name;
3349
- }
3350
- theNamespace_1 += name;
3351
- }
3352
- });
3353
- }
3354
- else {
3355
- theNamespace_1 = _normalizeNamespace(evtNamespace);
3356
- }
3357
- if (theNamespace_1) {
3358
- if (theNamespace_1[0] !== ".") {
3359
- theNamespace_1 = "." + theNamespace_1;
3360
- }
3361
- eventName = (eventName || "") + theNamespace_1;
3362
- }
2371
+ var UInt32Mask = 0x100000000;
2372
+ var MaxUInt32 = 0xffffffff;
2373
+ var _mwcSeeded = false;
2374
+ var _mwcW = 123456789;
2375
+ var _mwcZ = 987654321;
2376
+ function _mwcSeed(seedValue) {
2377
+ if (seedValue < 0) {
2378
+ seedValue >>>= 0;
3363
2379
  }
3364
- var parsedEvent = (eventNamespace.exec(eventName || "") || []);
3365
- return {
3366
- type: parsedEvent[1],
3367
- ns: ((parsedEvent[2] || "").replace(rRemoveEmptyNs, ".").replace(rRemoveTrailingEmptyNs, "").split(".").sort()).join(".")
3368
- };
3369
- }
3370
- function __getRegisteredEvents(target, eventName, evtNamespace) {
3371
- var theEvents = [];
3372
- var eventCache = elmNodeData.get(target, strEvents, {}, false);
3373
- var evtName = _getEvtNamespace(eventName, evtNamespace);
3374
- objForEachKey(eventCache, function (evtType, registeredEvents) {
3375
- arrForEach(registeredEvents, function (value) {
3376
- if (!evtName.type || evtName.type === value.evtName.type) {
3377
- if (!evtName.ns || evtName.ns === evtName.ns) {
3378
- theEvents.push({
3379
- name: value.evtName.type + (value.evtName.ns ? "." + value.evtName.ns : ""),
3380
- handler: value.handler
3381
- });
3382
- }
3383
- }
3384
- });
3385
- });
3386
- return theEvents;
2380
+ _mwcW = (123456789 + seedValue) & MaxUInt32;
2381
+ _mwcZ = (987654321 - seedValue) & MaxUInt32;
2382
+ _mwcSeeded = true;
3387
2383
  }
3388
- function _getRegisteredEvents(target, evtName, addDefault) {
3389
- if (addDefault === void 0) { addDefault = true; }
3390
- var aiEvts = elmNodeData.get(target, strEvents, {}, addDefault);
3391
- var registeredEvents = aiEvts[evtName];
3392
- if (!registeredEvents) {
3393
- registeredEvents = aiEvts[evtName] = [];
2384
+ function _autoSeedMwc() {
2385
+ try {
2386
+ var now = dateNow() & 0x7fffffff;
2387
+ _mwcSeed(((Math.random() * UInt32Mask) ^ now) + now);
3394
2388
  }
3395
- return registeredEvents;
3396
- }
3397
- function _doDetach(obj, evtName, handlerRef, useCapture) {
3398
- if (obj && evtName && evtName.type) {
3399
- if (obj[strRemoveEventListener]) {
3400
- obj[strRemoveEventListener](evtName.type, handlerRef, useCapture);
3401
- }
3402
- else if (obj[strDetachEvent]) {
3403
- obj[strDetachEvent](strOnPrefix + evtName.type, handlerRef);
3404
- }
2389
+ catch (e) {
3405
2390
  }
3406
2391
  }
3407
- function _doAttach(obj, evtName, handlerRef, useCapture) {
3408
- var result = false;
3409
- if (obj && evtName && evtName.type && handlerRef) {
3410
- if (obj[strAddEventHelper]) {
3411
- obj[strAddEventHelper](evtName.type, handlerRef, useCapture);
3412
- result = true;
3413
- }
3414
- else if (obj[strAttachEvent]) {
3415
- obj[strAttachEvent](strOnPrefix + evtName.type, handlerRef);
3416
- result = true;
3417
- }
2392
+ function randomValue(maxValue) {
2393
+ if (maxValue > 0) {
2394
+ return Math.floor((random32() / MaxUInt32) * (maxValue + 1)) >>> 0;
3418
2395
  }
3419
- return result;
2396
+ return 0;
3420
2397
  }
3421
- function _doUnregister(target, events, evtName, unRegFn) {
3422
- var idx = events.length;
3423
- while (idx--) {
3424
- var theEvent = events[idx];
3425
- if (theEvent) {
3426
- if (!evtName.ns || evtName.ns === theEvent.evtName.ns) {
3427
- if (!unRegFn || unRegFn(theEvent)) {
3428
- _doDetach(target, theEvent.evtName, theEvent.handler, theEvent.capture);
3429
- events.splice(idx, 1);
3430
- }
3431
- }
3432
- }
2398
+ function random32(signed) {
2399
+ var value;
2400
+ var c = getCrypto() || getMsCrypto();
2401
+ if (c && c.getRandomValues) {
2402
+ value = c.getRandomValues(new Uint32Array(1))[0] & MaxUInt32;
3433
2403
  }
3434
- }
3435
- function _unregisterEvents(target, evtName, unRegFn) {
3436
- if (evtName.type) {
3437
- _doUnregister(target, _getRegisteredEvents(target, evtName.type), evtName, unRegFn);
2404
+ else if (isIE()) {
2405
+ if (!_mwcSeeded) {
2406
+ _autoSeedMwc();
2407
+ }
2408
+ value = mwcRandom32() & MaxUInt32;
3438
2409
  }
3439
2410
  else {
3440
- var eventCache = elmNodeData.get(target, strEvents, {});
3441
- objForEachKey(eventCache, function (evtType, events) {
3442
- _doUnregister(target, events, evtName, unRegFn);
3443
- });
3444
- if (objKeys(eventCache).length === 0) {
3445
- elmNodeData.kill(target, strEvents);
3446
- }
2411
+ value = Math.floor((UInt32Mask * Math.random()) | 0);
2412
+ }
2413
+ if (!signed) {
2414
+ value >>>= 0;
3447
2415
  }
2416
+ return value;
3448
2417
  }
3449
- function mergeEvtNamespace(theNamespace, namespaces) {
3450
- var newNamespaces;
3451
- if (namespaces) {
3452
- if (isArray(namespaces)) {
3453
- newNamespaces = [theNamespace].concat(namespaces);
3454
- }
3455
- else {
3456
- newNamespaces = [theNamespace, namespaces];
3457
- }
3458
- newNamespaces = (_getEvtNamespace("xx", newNamespaces).ns).split(".");
2418
+ function mwcRandomSeed(value) {
2419
+ if (!value) {
2420
+ _autoSeedMwc();
3459
2421
  }
3460
2422
  else {
3461
- newNamespaces = theNamespace;
3462
- }
3463
- return newNamespaces;
3464
- }
3465
- function eventOn(target, eventName, handlerRef, evtNamespace, useCapture) {
3466
- if (useCapture === void 0) { useCapture = false; }
3467
- var result = false;
3468
- if (target) {
3469
- try {
3470
- var evtName = _getEvtNamespace(eventName, evtNamespace);
3471
- result = _doAttach(target, evtName, handlerRef, useCapture);
3472
- if (result && elmNodeData.accept(target)) {
3473
- var registeredEvent = {
3474
- guid: _guid++,
3475
- evtName: evtName,
3476
- handler: handlerRef,
3477
- capture: useCapture
3478
- };
3479
- _getRegisteredEvents(target, evtName.type).push(registeredEvent);
3480
- }
3481
- }
3482
- catch (e) {
3483
- }
2423
+ _mwcSeed(value);
3484
2424
  }
3485
- return result;
3486
2425
  }
3487
- function eventOff(target, eventName, handlerRef, evtNamespace, useCapture) {
3488
- if (useCapture === void 0) { useCapture = false; }
3489
- if (target) {
3490
- try {
3491
- var evtName_1 = _getEvtNamespace(eventName, evtNamespace);
3492
- var found_1 = false;
3493
- _unregisterEvents(target, evtName_1, function (regEvent) {
3494
- if ((evtName_1.ns && !handlerRef) || regEvent.handler === handlerRef) {
3495
- found_1 = true;
3496
- return true;
3497
- }
3498
- return false;
3499
- });
3500
- if (!found_1) {
3501
- _doDetach(target, evtName_1, handlerRef, useCapture);
3502
- }
3503
- }
3504
- catch (e) {
3505
- }
2426
+ function mwcRandom32(signed) {
2427
+ _mwcZ = (36969 * (_mwcZ & 0xFFFF) + (_mwcZ >> 16)) & MaxUInt32;
2428
+ _mwcW = (18000 * (_mwcW & 0xFFFF) + (_mwcW >> 16)) & MaxUInt32;
2429
+ var value = (((_mwcZ << 16) + (_mwcW & 0xFFFF)) >>> 0) & MaxUInt32 | 0;
2430
+ if (!signed) {
2431
+ value >>>= 0;
3506
2432
  }
2433
+ return value;
3507
2434
  }
3508
- function attachEvent(obj, eventNameWithoutOn, handlerRef, useCapture) {
3509
- if (useCapture === void 0) { useCapture = false; }
3510
- return eventOn(obj, eventNameWithoutOn, handlerRef, null, useCapture);
3511
- }
3512
- function detachEvent(obj, eventNameWithoutOn, handlerRef, useCapture) {
3513
- if (useCapture === void 0) { useCapture = false; }
3514
- eventOff(obj, eventNameWithoutOn, handlerRef, null, useCapture);
3515
- }
3516
- function addEventHandler(eventName, callback, evtNamespace) {
2435
+
2436
+ var strVisibilityChangeEvt = "visibilitychange";
2437
+ var strPageHide = "pagehide";
2438
+ var strPageShow = "pageshow";
2439
+ var _cookieMgrs = null;
2440
+ var _canUseCookies;
2441
+ var Undefined = strShimUndefined;
2442
+ function addEventHandler(eventName, callback) {
3517
2443
  var result = false;
3518
2444
  var w = getWindow();
3519
2445
  if (w) {
3520
- result = eventOn(w, eventName, callback, evtNamespace);
3521
- result = eventOn(w["body"], eventName, callback, evtNamespace) || result;
2446
+ result = attachEvent(w, eventName, callback);
2447
+ result = attachEvent(w["body"], eventName, callback) || result;
3522
2448
  }
3523
2449
  var doc = getDocument();
3524
2450
  if (doc) {
3525
- result = eventOn(doc, eventName, callback, evtNamespace) || result;
2451
+ result = attachEvent(doc, eventName, callback) || result;
3526
2452
  }
3527
2453
  return result;
3528
2454
  }
3529
- function removeEventHandler(eventName, callback, evtNamespace) {
3530
- var w = getWindow();
3531
- if (w) {
3532
- eventOff(w, eventName, callback, evtNamespace);
3533
- eventOff(w["body"], eventName, callback, evtNamespace);
3534
- }
3535
- var doc = getDocument();
3536
- if (doc) {
3537
- eventOff(doc, eventName, callback, evtNamespace);
3538
- }
3539
- }
3540
- function _addEventListeners(events, listener, excludeEvents, evtNamespace) {
2455
+ function addEventListeners(events, listener, excludeEvents) {
3541
2456
  var added = false;
3542
- if (listener && events && events.length > 0) {
2457
+ if (listener && events && isArray(events)) {
2458
+ var excluded_1 = [];
3543
2459
  arrForEach(events, function (name) {
3544
- if (name) {
2460
+ if (isString(name)) {
3545
2461
  if (!excludeEvents || arrIndexOf(excludeEvents, name) === -1) {
3546
- added = addEventHandler(name, listener, evtNamespace) || added;
2462
+ added = addEventHandler(name, listener) || added;
2463
+ }
2464
+ else {
2465
+ excluded_1.push(name);
3547
2466
  }
3548
2467
  }
3549
2468
  });
3550
- }
3551
- return added;
3552
- }
3553
- function addEventListeners(events, listener, excludeEvents, evtNamespace) {
3554
- var added = false;
3555
- if (listener && events && isArray(events)) {
3556
- added = _addEventListeners(events, listener, excludeEvents, evtNamespace);
3557
- if (!added && excludeEvents && excludeEvents.length > 0) {
3558
- added = _addEventListeners(events, listener, null, evtNamespace);
2469
+ if (!added && excluded_1.length > 0) {
2470
+ added = addEventListeners(excluded_1, listener);
3559
2471
  }
3560
2472
  }
3561
2473
  return added;
3562
2474
  }
3563
- function removeEventListeners(events, listener, evtNamespace) {
3564
- if (events && isArray(events)) {
3565
- arrForEach(events, function (name) {
3566
- if (name) {
3567
- removeEventHandler(name, listener, evtNamespace);
3568
- }
3569
- });
3570
- }
3571
- }
3572
- function addPageUnloadEventListener(listener, excludeEvents, evtNamespace) {
3573
- return addEventListeners([strBeforeUnload, strUnload, strPageHide], listener, excludeEvents, evtNamespace);
2475
+ function addPageUnloadEventListener(listener, excludeEvents) {
2476
+ return addEventListeners(["beforeunload", "unload", "pagehide"], listener, excludeEvents);
3574
2477
  }
3575
- function removePageUnloadEventListener(listener, evtNamespace) {
3576
- removeEventListeners([strBeforeUnload, strUnload, strPageHide], listener, evtNamespace);
3577
- }
3578
- function addPageHideEventListener(listener, excludeEvents, evtNamespace) {
2478
+ function addPageHideEventListener(listener, excludeEvents) {
3579
2479
  function _handlePageVisibility(evt) {
3580
2480
  var doc = getDocument();
3581
2481
  if (listener && doc && doc.visibilityState === "hidden") {
3582
2482
  listener(evt);
3583
2483
  }
3584
2484
  }
3585
- var newNamespaces = mergeEvtNamespace(strPageHideNamespace, evtNamespace);
3586
- var pageUnloadAdded = _addEventListeners([strPageHide], listener, excludeEvents, newNamespaces);
2485
+ var pageUnloadAdded = false;
2486
+ if (!excludeEvents || arrIndexOf(excludeEvents, strPageHide) === -1) {
2487
+ pageUnloadAdded = addEventHandler(strPageHide, listener);
2488
+ }
3587
2489
  if (!excludeEvents || arrIndexOf(excludeEvents, strVisibilityChangeEvt) === -1) {
3588
- pageUnloadAdded = _addEventListeners([strVisibilityChangeEvt], _handlePageVisibility, excludeEvents, newNamespaces) || pageUnloadAdded;
2490
+ pageUnloadAdded = addEventHandler(strVisibilityChangeEvt, _handlePageVisibility) || pageUnloadAdded;
3589
2491
  }
3590
2492
  if (!pageUnloadAdded && excludeEvents) {
3591
- pageUnloadAdded = addPageHideEventListener(listener, null, evtNamespace);
2493
+ pageUnloadAdded = addPageHideEventListener(listener);
3592
2494
  }
3593
2495
  return pageUnloadAdded;
3594
2496
  }
3595
- function removePageHideEventListener(listener, evtNamespace) {
3596
- var newNamespaces = mergeEvtNamespace(strPageHideNamespace, evtNamespace);
3597
- removeEventListeners([strPageHide], listener, newNamespaces);
3598
- removeEventListeners([strVisibilityChangeEvt], null, newNamespaces);
3599
- }
3600
- function addPageShowEventListener(listener, excludeEvents, evtNamespace) {
2497
+ function addPageShowEventListener(listener, excludeEvents) {
3601
2498
  function _handlePageVisibility(evt) {
3602
2499
  var doc = getDocument();
3603
2500
  if (listener && doc && doc.visibilityState === "visible") {
3604
2501
  listener(evt);
3605
2502
  }
3606
2503
  }
3607
- var newNamespaces = mergeEvtNamespace(strPageShowNamespace, evtNamespace);
3608
- var pageShowAdded = _addEventListeners([strPageShow], listener, excludeEvents, newNamespaces);
3609
- pageShowAdded = _addEventListeners([strVisibilityChangeEvt], _handlePageVisibility, excludeEvents, newNamespaces) || pageShowAdded;
2504
+ var pageShowAdded = false;
2505
+ if (!excludeEvents || arrIndexOf(excludeEvents, strPageShow) === -1) {
2506
+ pageShowAdded = addEventHandler(strPageShow, listener);
2507
+ }
2508
+ if (!excludeEvents || arrIndexOf(excludeEvents, strVisibilityChangeEvt) === -1) {
2509
+ pageShowAdded = addEventHandler(strVisibilityChangeEvt, _handlePageVisibility) || pageShowAdded;
2510
+ }
3610
2511
  if (!pageShowAdded && excludeEvents) {
3611
- pageShowAdded = addPageShowEventListener(listener, null, evtNamespace);
2512
+ pageShowAdded = addPageShowEventListener(listener);
3612
2513
  }
3613
2514
  return pageShowAdded;
3614
2515
  }
3615
- function removePageShowEventListener(listener, evtNamespace) {
3616
- var newNamespaces = mergeEvtNamespace(strPageShowNamespace, evtNamespace);
3617
- removeEventListeners([strPageShow], listener, newNamespaces);
3618
- removeEventListeners([strVisibilityChangeEvt], null, newNamespaces);
3619
- }
3620
-
3621
- var _cookieMgrs = null;
3622
- var _canUseCookies;
3623
- var Undefined = strShimUndefined;
3624
2516
  function newGuid() {
3625
2517
  function randomHexDigit() {
3626
2518
  return randomValue(15);
@@ -3637,9 +2529,26 @@
3637
2529
  }
3638
2530
  return dateNow();
3639
2531
  }
2532
+ function newId(maxLength) {
2533
+ if (maxLength === void 0) { maxLength = 22; }
2534
+ var base64chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
2535
+ var number = random32() >>> 0;
2536
+ var chars = 0;
2537
+ var result = "";
2538
+ while (result.length < maxLength) {
2539
+ chars++;
2540
+ result += base64chars.charAt(number & 0x3F);
2541
+ number >>>= 6;
2542
+ if (chars === 5) {
2543
+ number = (((random32() << 2) & 0xFFFFFFFF) | (number & 0x03)) >>> 0;
2544
+ chars = 0;
2545
+ }
2546
+ }
2547
+ return result;
2548
+ }
3640
2549
  function generateW3CId() {
3641
2550
  var hexValues = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f"];
3642
- var oct = strEmpty, tmp;
2551
+ var oct = "", tmp;
3643
2552
  for (var a = 0; a < 4; a++) {
3644
2553
  tmp = random32();
3645
2554
  oct +=
@@ -3740,95 +2649,6 @@
3740
2649
  return _legacyCookieMgr(null, logger).del(name);
3741
2650
  }
3742
2651
 
3743
- var LoggingSeverity = createEnumStyle({
3744
- CRITICAL: 1 ,
3745
- WARNING: 2
3746
- });
3747
- var _InternalMessageId = createEnumStyle({
3748
- BrowserDoesNotSupportLocalStorage: 0 ,
3749
- BrowserCannotReadLocalStorage: 1 ,
3750
- BrowserCannotReadSessionStorage: 2 ,
3751
- BrowserCannotWriteLocalStorage: 3 ,
3752
- BrowserCannotWriteSessionStorage: 4 ,
3753
- BrowserFailedRemovalFromLocalStorage: 5 ,
3754
- BrowserFailedRemovalFromSessionStorage: 6 ,
3755
- CannotSendEmptyTelemetry: 7 ,
3756
- ClientPerformanceMathError: 8 ,
3757
- ErrorParsingAISessionCookie: 9 ,
3758
- ErrorPVCalc: 10 ,
3759
- ExceptionWhileLoggingError: 11 ,
3760
- FailedAddingTelemetryToBuffer: 12 ,
3761
- FailedMonitorAjaxAbort: 13 ,
3762
- FailedMonitorAjaxDur: 14 ,
3763
- FailedMonitorAjaxOpen: 15 ,
3764
- FailedMonitorAjaxRSC: 16 ,
3765
- FailedMonitorAjaxSend: 17 ,
3766
- FailedMonitorAjaxGetCorrelationHeader: 18 ,
3767
- FailedToAddHandlerForOnBeforeUnload: 19 ,
3768
- FailedToSendQueuedTelemetry: 20 ,
3769
- FailedToReportDataLoss: 21 ,
3770
- FlushFailed: 22 ,
3771
- MessageLimitPerPVExceeded: 23 ,
3772
- MissingRequiredFieldSpecification: 24 ,
3773
- NavigationTimingNotSupported: 25 ,
3774
- OnError: 26 ,
3775
- SessionRenewalDateIsZero: 27 ,
3776
- SenderNotInitialized: 28 ,
3777
- StartTrackEventFailed: 29 ,
3778
- StopTrackEventFailed: 30 ,
3779
- StartTrackFailed: 31 ,
3780
- StopTrackFailed: 32 ,
3781
- TelemetrySampledAndNotSent: 33 ,
3782
- TrackEventFailed: 34 ,
3783
- TrackExceptionFailed: 35 ,
3784
- TrackMetricFailed: 36 ,
3785
- TrackPVFailed: 37 ,
3786
- TrackPVFailedCalc: 38 ,
3787
- TrackTraceFailed: 39 ,
3788
- TransmissionFailed: 40 ,
3789
- FailedToSetStorageBuffer: 41 ,
3790
- FailedToRestoreStorageBuffer: 42 ,
3791
- InvalidBackendResponse: 43 ,
3792
- FailedToFixDepricatedValues: 44 ,
3793
- InvalidDurationValue: 45 ,
3794
- TelemetryEnvelopeInvalid: 46 ,
3795
- CreateEnvelopeError: 47 ,
3796
- CannotSerializeObject: 48 ,
3797
- CannotSerializeObjectNonSerializable: 49 ,
3798
- CircularReferenceDetected: 50 ,
3799
- ClearAuthContextFailed: 51 ,
3800
- ExceptionTruncated: 52 ,
3801
- IllegalCharsInName: 53 ,
3802
- ItemNotInArray: 54 ,
3803
- MaxAjaxPerPVExceeded: 55 ,
3804
- MessageTruncated: 56 ,
3805
- NameTooLong: 57 ,
3806
- SampleRateOutOfRange: 58 ,
3807
- SetAuthContextFailed: 59 ,
3808
- SetAuthContextFailedAccountName: 60 ,
3809
- StringValueTooLong: 61 ,
3810
- StartCalledMoreThanOnce: 62 ,
3811
- StopCalledWithoutStart: 63 ,
3812
- TelemetryInitializerFailed: 64 ,
3813
- TrackArgumentsNotSpecified: 65 ,
3814
- UrlTooLong: 66 ,
3815
- SessionStorageBufferFull: 67 ,
3816
- CannotAccessCookie: 68 ,
3817
- IdTooLong: 69 ,
3818
- InvalidEvent: 70 ,
3819
- FailedMonitorAjaxSetRequestHeader: 71 ,
3820
- SendBrowserInfoOnUserInit: 72 ,
3821
- PluginException: 73 ,
3822
- NotificationException: 74 ,
3823
- SnippetScriptLoadFailure: 99 ,
3824
- InvalidInstrumentationKey: 100 ,
3825
- CannotParseAiBlobValue: 101 ,
3826
- InvalidContentBlob: 102 ,
3827
- TrackPageActionEventFailed: 103 ,
3828
- FailedAddingCustomDefinedRequestContext: 104 ,
3829
- InMemoryStorageBufferFull: 105
3830
- });
3831
-
3832
2652
  var aiInstrumentHooks = "_aiHooks";
3833
2653
  var cbNames = [
3834
2654
  "req", "rsp", "hkErr", "fnErr"
@@ -3887,7 +2707,6 @@
3887
2707
  };
3888
2708
  var hookCtx = [];
3889
2709
  var cbArgs = _createArgs([funcArgs], orgArgs);
3890
- funcArgs.evt = getGlobalInst("event");
3891
2710
  function _createArgs(target, theArgs) {
3892
2711
  _arrLoop(theArgs, function (arg) {
3893
2712
  target.push(arg);
@@ -4003,7 +2822,6 @@
4003
2822
  exports.InstrumentFuncs = InstrumentFuncs;
4004
2823
  exports.InstrumentProto = InstrumentProto;
4005
2824
  exports.InstrumentProtos = InstrumentProtos;
4006
- exports.LoggingSeverity = LoggingSeverity;
4007
2825
  exports.MinChannelPriorty = MinChannelPriorty;
4008
2826
  exports.NotificationManager = NotificationManager;
4009
2827
  exports.PerfEvent = PerfEvent;
@@ -4012,9 +2830,7 @@
4012
2830
  exports.Undefined = Undefined;
4013
2831
  exports._InternalLogMessage = _InternalLogMessage;
4014
2832
  exports._InternalMessageId = _InternalMessageId;
4015
- exports.__getRegisteredEvents = __getRegisteredEvents;
4016
2833
  exports._legacyCookieMgr = _legacyCookieMgr;
4017
- exports._throwInternal = _throwInternal;
4018
2834
  exports.addEventHandler = addEventHandler;
4019
2835
  exports.addEventListeners = addEventListeners;
4020
2836
  exports.addPageHideEventListener = addPageHideEventListener;
@@ -4029,18 +2845,12 @@
4029
2845
  exports.canUseCookies = canUseCookies;
4030
2846
  exports.createClassFromInterface = createClassFromInterface;
4031
2847
  exports.createCookieMgr = createCookieMgr;
4032
- exports.createEnumStyle = createEnumStyle;
4033
- exports.createProcessTelemetryContext = createProcessTelemetryContext;
4034
- exports.createUniqueNamespace = createUniqueNamespace;
4035
- exports.createUnloadHandlerContainer = createUnloadHandlerContainer;
4036
2848
  exports.dateNow = dateNow;
4037
2849
  exports.deleteCookie = deleteCookie;
4038
2850
  exports.detachEvent = detachEvent;
4039
2851
  exports.disableCookies = disableCookies;
4040
2852
  exports.doPerf = doPerf;
4041
2853
  exports.dumpObj = dumpObj;
4042
- exports.eventOff = eventOff;
4043
- exports.eventOn = eventOn;
4044
2854
  exports.generateW3CId = generateW3CId;
4045
2855
  exports.getConsole = getConsole;
4046
2856
  exports.getCookie = getCookie;
@@ -4090,7 +2900,6 @@
4090
2900
  exports.isTypeof = isTypeof;
4091
2901
  exports.isUndefined = isUndefined;
4092
2902
  exports.isXhrSupported = isXhrSupported;
4093
- exports.mergeEvtNamespace = mergeEvtNamespace;
4094
2903
  exports.mwcRandom32 = mwcRandom32;
4095
2904
  exports.mwcRandomSeed = mwcRandomSeed;
4096
2905
  exports.newGuid = newGuid;
@@ -4098,24 +2907,15 @@
4098
2907
  exports.normalizeJsName = normalizeJsName;
4099
2908
  exports.objCreate = objCreateFn;
4100
2909
  exports.objDefineAccessors = objDefineAccessors;
4101
- exports.objExtend = objExtend;
4102
2910
  exports.objForEachKey = objForEachKey;
4103
2911
  exports.objFreeze = objFreeze;
4104
2912
  exports.objKeys = objKeys;
4105
2913
  exports.objSeal = objSeal;
4106
- exports.objToString = objToString;
4107
2914
  exports.optimizeObject = optimizeObject;
4108
2915
  exports.perfNow = perfNow;
4109
2916
  exports.proxyAssign = proxyAssign;
4110
- exports.proxyFunctionAs = proxyFunctionAs;
4111
- exports.proxyFunctions = proxyFunctions;
4112
2917
  exports.random32 = random32;
4113
2918
  exports.randomValue = randomValue;
4114
- exports.removeEventHandler = removeEventHandler;
4115
- exports.removeEventListeners = removeEventListeners;
4116
- exports.removePageHideEventListener = removePageHideEventListener;
4117
- exports.removePageShowEventListener = removePageShowEventListener;
4118
- exports.removePageUnloadEventListener = removePageUnloadEventListener;
4119
2919
  exports.safeGetCookieMgr = safeGetCookieMgr;
4120
2920
  exports.safeGetLogger = safeGetLogger;
4121
2921
  exports.setCookie = setCookie;
@@ -4136,7 +2936,6 @@
4136
2936
  exports.throwError = throwError;
4137
2937
  exports.toISOString = toISOString;
4138
2938
  exports.uaDisallowsSameSiteNone = uaDisallowsSameSiteNone;
4139
- exports.unloadComponents = unloadComponents;
4140
2939
  exports.useXDomainRequest = useXDomainRequest;
4141
2940
 
4142
2941
  (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 });