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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (160) hide show
  1. package/browser/applicationinsights-core-js.integrity.json +9 -9
  2. package/browser/applicationinsights-core-js.js +774 -1973
  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 +774 -1973
  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.2204-03
2
+ * Application Insights JavaScript SDK - Core, 2.7.6
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.6
108
104
  * Copyright (c) Microsoft and contributors. All rights reserved.
109
105
  */
110
106
  var Constructor = 'constructor';
@@ -119,10 +115,13 @@
119
115
  var DynProtoDefaultOptions = '_dfOpts';
120
116
  var UnknownValue = '_unknown_';
121
117
  var str__Proto$1 = "__proto__";
118
+ var DynProtoBaseProto = "_dyn" + str__Proto$1;
119
+ var DynProtoCurrent = "_dynInstProto";
122
120
  var strUseBaseInst = 'useBaseInst';
123
121
  var strSetInstFuncs = 'setInstFuncs';
124
122
  var Obj = Object;
125
123
  var _objGetPrototypeOf$1 = Obj["getPrototypeOf"];
124
+ var _objGetOwnProps = Obj["getOwnPropertyNames"];
126
125
  var _dynamicNames = 0;
127
126
  function _hasOwnProperty(obj, prop) {
128
127
  return obj && Obj[Prototype].hasOwnProperty.call(obj, prop);
@@ -134,22 +133,25 @@
134
133
  return _isObjectOrArrayPrototype(target) || target === Function[Prototype];
135
134
  }
136
135
  function _getObjProto$1(target) {
136
+ var newProto;
137
137
  if (target) {
138
138
  if (_objGetPrototypeOf$1) {
139
139
  return _objGetPrototypeOf$1(target);
140
140
  }
141
- var newProto = target[str__Proto$1] || target[Prototype] || (target[Constructor] ? target[Constructor][Prototype] : null);
142
- if (newProto) {
143
- return newProto;
141
+ var curProto = target[str__Proto$1] || target[Prototype] || (target[Constructor] ? target[Constructor][Prototype] : null);
142
+ newProto = target[DynProtoBaseProto] || curProto;
143
+ if (!_hasOwnProperty(target, DynProtoBaseProto)) {
144
+ delete target[DynProtoCurrent];
145
+ newProto = target[DynProtoBaseProto] = target[DynProtoCurrent] || target[DynProtoBaseProto];
146
+ target[DynProtoCurrent] = curProto;
144
147
  }
145
148
  }
146
- return null;
149
+ return newProto;
147
150
  }
148
151
  function _forEachProp(target, func) {
149
152
  var props = [];
150
- var getOwnProps = Obj["getOwnPropertyNames"];
151
- if (getOwnProps) {
152
- props = getOwnProps(target);
153
+ if (_objGetOwnProps) {
154
+ props = _objGetOwnProps(target);
153
155
  }
154
156
  else {
155
157
  for (var name_1 in target) {
@@ -298,8 +300,9 @@
298
300
  visited.push(thisProto);
299
301
  thisProto = _getObjProto$1(thisProto);
300
302
  }
303
+ return false;
301
304
  }
302
- return false;
305
+ return true;
303
306
  }
304
307
  function _getObjName(target, unknownValue) {
305
308
  if (_hasOwnProperty(target, Prototype)) {
@@ -344,27 +347,101 @@
344
347
  };
345
348
  dynamicProto[DynProtoDefaultOptions] = perfDefaults;
346
349
 
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";
350
+ exports.LoggingSeverity = void 0;
351
+ (function (LoggingSeverity) {
352
+ LoggingSeverity[LoggingSeverity["CRITICAL"] = 1] = "CRITICAL";
353
+ LoggingSeverity[LoggingSeverity["WARNING"] = 2] = "WARNING";
354
+ })(exports.LoggingSeverity || (exports.LoggingSeverity = {}));
355
+ var _InternalMessageId = {
356
+ BrowserDoesNotSupportLocalStorage: 0,
357
+ BrowserCannotReadLocalStorage: 1,
358
+ BrowserCannotReadSessionStorage: 2,
359
+ BrowserCannotWriteLocalStorage: 3,
360
+ BrowserCannotWriteSessionStorage: 4,
361
+ BrowserFailedRemovalFromLocalStorage: 5,
362
+ BrowserFailedRemovalFromSessionStorage: 6,
363
+ CannotSendEmptyTelemetry: 7,
364
+ ClientPerformanceMathError: 8,
365
+ ErrorParsingAISessionCookie: 9,
366
+ ErrorPVCalc: 10,
367
+ ExceptionWhileLoggingError: 11,
368
+ FailedAddingTelemetryToBuffer: 12,
369
+ FailedMonitorAjaxAbort: 13,
370
+ FailedMonitorAjaxDur: 14,
371
+ FailedMonitorAjaxOpen: 15,
372
+ FailedMonitorAjaxRSC: 16,
373
+ FailedMonitorAjaxSend: 17,
374
+ FailedMonitorAjaxGetCorrelationHeader: 18,
375
+ FailedToAddHandlerForOnBeforeUnload: 19,
376
+ FailedToSendQueuedTelemetry: 20,
377
+ FailedToReportDataLoss: 21,
378
+ FlushFailed: 22,
379
+ MessageLimitPerPVExceeded: 23,
380
+ MissingRequiredFieldSpecification: 24,
381
+ NavigationTimingNotSupported: 25,
382
+ OnError: 26,
383
+ SessionRenewalDateIsZero: 27,
384
+ SenderNotInitialized: 28,
385
+ StartTrackEventFailed: 29,
386
+ StopTrackEventFailed: 30,
387
+ StartTrackFailed: 31,
388
+ StopTrackFailed: 32,
389
+ TelemetrySampledAndNotSent: 33,
390
+ TrackEventFailed: 34,
391
+ TrackExceptionFailed: 35,
392
+ TrackMetricFailed: 36,
393
+ TrackPVFailed: 37,
394
+ TrackPVFailedCalc: 38,
395
+ TrackTraceFailed: 39,
396
+ TransmissionFailed: 40,
397
+ FailedToSetStorageBuffer: 41,
398
+ FailedToRestoreStorageBuffer: 42,
399
+ InvalidBackendResponse: 43,
400
+ FailedToFixDepricatedValues: 44,
401
+ InvalidDurationValue: 45,
402
+ TelemetryEnvelopeInvalid: 46,
403
+ CreateEnvelopeError: 47,
404
+ CannotSerializeObject: 48,
405
+ CannotSerializeObjectNonSerializable: 49,
406
+ CircularReferenceDetected: 50,
407
+ ClearAuthContextFailed: 51,
408
+ ExceptionTruncated: 52,
409
+ IllegalCharsInName: 53,
410
+ ItemNotInArray: 54,
411
+ MaxAjaxPerPVExceeded: 55,
412
+ MessageTruncated: 56,
413
+ NameTooLong: 57,
414
+ SampleRateOutOfRange: 58,
415
+ SetAuthContextFailed: 59,
416
+ SetAuthContextFailedAccountName: 60,
417
+ StringValueTooLong: 61,
418
+ StartCalledMoreThanOnce: 62,
419
+ StopCalledWithoutStart: 63,
420
+ TelemetryInitializerFailed: 64,
421
+ TrackArgumentsNotSpecified: 65,
422
+ UrlTooLong: 66,
423
+ SessionStorageBufferFull: 67,
424
+ CannotAccessCookie: 68,
425
+ IdTooLong: 69,
426
+ InvalidEvent: 70,
427
+ FailedMonitorAjaxSetRequestHeader: 71,
428
+ SendBrowserInfoOnUserInit: 72,
429
+ PluginException: 73,
430
+ NotificationException: 74,
431
+ SnippetScriptLoadFailure: 99,
432
+ InvalidInstrumentationKey: 100,
433
+ CannotParseAiBlobValue: 101,
434
+ InvalidContentBlob: 102,
435
+ TrackPageActionEventFailed: 103,
436
+ FailedAddingCustomDefinedRequestContext: 104,
437
+ InMemoryStorageBufferFull: 105
438
+ };
367
439
 
440
+ var strOnPrefix = "on";
441
+ var strAttachEvent = "attachEvent";
442
+ var strAddEventHelper = "addEventListener";
443
+ var strDetachEvent = "detachEvent";
444
+ var strRemoveEventListener = "removeEventListener";
368
445
  var strToISOString = "toISOString";
369
446
  var cStrEndsWith = "endsWith";
370
447
  var cStrStartsWith = "startsWith";
@@ -375,7 +452,7 @@
375
452
  var strToString = "toString";
376
453
  var str__Proto = "__proto__";
377
454
  var strConstructor = "constructor";
378
- var _objDefineProperty$1 = ObjDefineProperty;
455
+ var _objDefineProperty = ObjDefineProperty;
379
456
  var _objFreeze = ObjClass.freeze;
380
457
  var _objSeal = ObjClass.seal;
381
458
  var _objKeys = ObjClass.keys;
@@ -388,7 +465,7 @@
388
465
  var _isArray = Array.isArray;
389
466
  var _objToString = ObjProto[strToString];
390
467
  var _fnToString = ObjHasOwnProperty[strToString];
391
- var _objFunctionString = _fnToString.call(ObjClass);
468
+ _fnToString.call(ObjClass);
392
469
  var rCamelCase = /-([a-z])/g;
393
470
  var rNormalizeInvalid = /([^\w\d_$])/g;
394
471
  var rLeadingNumeric = /^(\d+[\w\d_$])/;
@@ -405,9 +482,6 @@
405
482
  }
406
483
  return null;
407
484
  }
408
- function objToString(obj) {
409
- return _objToString.call(obj);
410
- }
411
485
  function isTypeof(value, theType) {
412
486
  return typeof value === theType;
413
487
  }
@@ -432,6 +506,40 @@
432
506
  function isFunction(value) {
433
507
  return !!(value && typeof value === strShimFunction);
434
508
  }
509
+ function attachEvent(obj, eventNameWithoutOn, handlerRef, useCapture) {
510
+ if (useCapture === void 0) { useCapture = false; }
511
+ var result = false;
512
+ if (!isNullOrUndefined(obj)) {
513
+ try {
514
+ if (!isNullOrUndefined(obj[strAddEventHelper])) {
515
+ obj[strAddEventHelper](eventNameWithoutOn, handlerRef, useCapture);
516
+ result = true;
517
+ }
518
+ else if (!isNullOrUndefined(obj[strAttachEvent])) {
519
+ obj[strAttachEvent](strOnPrefix + eventNameWithoutOn, handlerRef);
520
+ result = true;
521
+ }
522
+ }
523
+ catch (e) {
524
+ }
525
+ }
526
+ return result;
527
+ }
528
+ function detachEvent(obj, eventNameWithoutOn, handlerRef, useCapture) {
529
+ if (useCapture === void 0) { useCapture = false; }
530
+ if (!isNullOrUndefined(obj)) {
531
+ try {
532
+ if (!isNullOrUndefined(obj[strRemoveEventListener])) {
533
+ obj[strRemoveEventListener](eventNameWithoutOn, handlerRef, useCapture);
534
+ }
535
+ else if (!isNullOrUndefined(obj[strDetachEvent])) {
536
+ obj[strDetachEvent](strOnPrefix + eventNameWithoutOn, handlerRef);
537
+ }
538
+ }
539
+ catch (e) {
540
+ }
541
+ }
542
+ }
435
543
  function normalizeJsName(name) {
436
544
  var value = name;
437
545
  if (value && isString(value)) {
@@ -525,22 +633,6 @@
525
633
  function isSymbol(value) {
526
634
  return typeof value === "symbol";
527
635
  }
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
636
  function toISOString(date) {
545
637
  if (date) {
546
638
  return _dataToISOString ? date[strToISOString]() : _toISOStringPoly(date);
@@ -686,7 +778,7 @@
686
778
  return result;
687
779
  }
688
780
  function objDefineAccessors(target, prop, getProp, setProp) {
689
- if (_objDefineProperty$1) {
781
+ if (_objDefineProperty) {
690
782
  try {
691
783
  var descriptor = {
692
784
  enumerable: true,
@@ -698,7 +790,7 @@
698
790
  if (setProp) {
699
791
  descriptor.set = setProp;
700
792
  }
701
- _objDefineProperty$1(target, prop, descriptor);
793
+ _objDefineProperty(target, prop, descriptor);
702
794
  return true;
703
795
  }
704
796
  catch (e) {
@@ -719,7 +811,7 @@
719
811
  if (isError(object)) {
720
812
  return object.name;
721
813
  }
722
- return strEmpty;
814
+ return "";
723
815
  }
724
816
  function setValue(target, field, value, valChk, srcChk) {
725
817
  var theValue = value;
@@ -755,33 +847,19 @@
755
847
  function throwError(message) {
756
848
  throw new Error(message);
757
849
  }
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
850
  function proxyAssign(target, source, chkSet) {
778
- if (target && source && isObject(target) && isObject(source)) {
851
+ if (target && source && target !== source && isObject(target) && isObject(source)) {
779
852
  var _loop_1 = function (field) {
780
853
  if (isString(field)) {
781
854
  var value = source[field];
782
855
  if (isFunction(value)) {
783
856
  if (!chkSet || chkSet(field, true, source, target)) {
784
- target[field] = _createProxyFunction(source, field);
857
+ target[field] = (function (funcName) {
858
+ return function () {
859
+ var originalArguments = arguments;
860
+ return source[funcName].apply(source, originalArguments);
861
+ };
862
+ })(field);
785
863
  }
786
864
  }
787
865
  else if (!chkSet || chkSet(field, false, source, target)) {
@@ -804,25 +882,6 @@
804
882
  }
805
883
  return target;
806
884
  }
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
885
  function createClassFromInterface(defaults) {
827
886
  return /** @class */ (function () {
828
887
  function class_1() {
@@ -836,67 +895,12 @@
836
895
  return class_1;
837
896
  }());
838
897
  }
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
898
  function optimizeObject(theObject) {
851
899
  if (theObject && ObjAssign) {
852
900
  theObject = ObjClass(ObjAssign({}, theObject));
853
901
  }
854
902
  return theObject;
855
903
  }
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
904
 
901
905
  var strWindow = "window";
902
906
  var strDocument = "document";
@@ -912,7 +916,6 @@
912
916
  var strReactNative = "ReactNative";
913
917
  var strMsie = "msie";
914
918
  var strTrident = "trident/";
915
- var strXMLHttpRequest = "XMLHttpRequest";
916
919
  var _isTrident = null;
917
920
  var _navUserAgentCheck = null;
918
921
  var _enableMocks = false;
@@ -1039,7 +1042,7 @@
1039
1042
  var nav = getNavigator();
1040
1043
  if (nav && (nav.userAgent !== _navUserAgentCheck || _isTrident === null)) {
1041
1044
  _navUserAgentCheck = nav.userAgent;
1042
- var userAgent = (_navUserAgentCheck || strEmpty).toLowerCase();
1045
+ var userAgent = (_navUserAgentCheck || "").toLowerCase();
1043
1046
  _isTrident = (strContains(userAgent, strMsie) || strContains(userAgent, strTrident));
1044
1047
  }
1045
1048
  return _isTrident;
@@ -1048,9 +1051,9 @@
1048
1051
  if (userAgentStr === void 0) { userAgentStr = null; }
1049
1052
  if (!userAgentStr) {
1050
1053
  var navigator_1 = getNavigator() || {};
1051
- userAgentStr = navigator_1 ? (navigator_1.userAgent || strEmpty).toLowerCase() : strEmpty;
1054
+ userAgentStr = navigator_1 ? (navigator_1.userAgent || "").toLowerCase() : "";
1052
1055
  }
1053
- var ua = (userAgentStr || strEmpty).toLowerCase();
1056
+ var ua = (userAgentStr || "").toLowerCase();
1054
1057
  if (strContains(ua, strMsie)) {
1055
1058
  var doc = getDocument() || {};
1056
1059
  return Math.max(parseInt(ua.split(strMsie)[1]), (doc[strDocumentMode] || 0));
@@ -1065,7 +1068,7 @@
1065
1068
  }
1066
1069
  function dumpObj(object) {
1067
1070
  var objectTypeDump = Object[strShimPrototype].toString.call(object);
1068
- var propertyValueDump = strEmpty;
1071
+ var propertyValueDump = "";
1069
1072
  if (objectTypeDump === "[object Error]") {
1070
1073
  propertyValueDump = "{ stack: '" + object.stack + "', message: '" + object.message + "', name: '" + object.name + "'";
1071
1074
  }
@@ -1077,9 +1080,9 @@
1077
1080
  function isSafari(userAgentStr) {
1078
1081
  if (!userAgentStr || !isString(userAgentStr)) {
1079
1082
  var navigator_2 = getNavigator() || {};
1080
- userAgentStr = navigator_2 ? (navigator_2.userAgent || strEmpty).toLowerCase() : strEmpty;
1083
+ userAgentStr = navigator_2 ? (navigator_2.userAgent || "").toLowerCase() : "";
1081
1084
  }
1082
- var ua = (userAgentStr || strEmpty).toLowerCase();
1085
+ var ua = (userAgentStr || "").toLowerCase();
1083
1086
  return (ua.indexOf("safari") >= 0);
1084
1087
  }
1085
1088
  function isBeaconsSupported() {
@@ -1091,7 +1094,8 @@
1091
1094
  function isFetchSupported(withKeepAlive) {
1092
1095
  var isSupported = false;
1093
1096
  try {
1094
- isSupported = !!getGlobalInst("fetch");
1097
+ var fetchApi = getGlobalInst("fetch");
1098
+ isSupported = !!fetchApi;
1095
1099
  var request = getGlobalInst("Request");
1096
1100
  if (isSupported && withKeepAlive && request) {
1097
1101
  isSupported = _hasProperty(request, "keepalive");
@@ -1103,9 +1107,9 @@
1103
1107
  }
1104
1108
  function useXDomainRequest() {
1105
1109
  if (_useXDomainRequest === null) {
1106
- _useXDomainRequest = (typeof XDomainRequest !== strShimUndefined);
1110
+ _useXDomainRequest = (typeof XDomainRequest !== "undefined");
1107
1111
  if (_useXDomainRequest && isXhrSupported()) {
1108
- _useXDomainRequest = _useXDomainRequest && !_hasProperty(getGlobalInst(strXMLHttpRequest), "withCredentials");
1112
+ _useXDomainRequest = _useXDomainRequest && !_hasProperty(getGlobalInst("XMLHttpRequest"), "withCredentials");
1109
1113
  }
1110
1114
  }
1111
1115
  return _useXDomainRequest;
@@ -1113,7 +1117,7 @@
1113
1117
  function isXhrSupported() {
1114
1118
  var isSupported = false;
1115
1119
  try {
1116
- var xmlHttpRequest = getGlobalInst(strXMLHttpRequest);
1120
+ var xmlHttpRequest = getGlobalInst("XMLHttpRequest");
1117
1121
  isSupported = !!xmlHttpRequest;
1118
1122
  }
1119
1123
  catch (e) {
@@ -1167,9 +1171,9 @@
1167
1171
  var strWarnToConsole = "warnToConsole";
1168
1172
  function _sanitizeDiagnosticText(text) {
1169
1173
  if (text) {
1170
- return "\"" + text.replace(/\"/g, strEmpty) + "\"";
1174
+ return "\"" + text.replace(/\"/g, "") + "\"";
1171
1175
  }
1172
- return strEmpty;
1176
+ return "";
1173
1177
  }
1174
1178
  function _logToConsole(func, message) {
1175
1179
  var theConsole = getConsole();
@@ -1191,12 +1195,12 @@
1191
1195
  _self.message =
1192
1196
  (isUserAct ? AiUserActionablePrefix : AiNonUserActionablePrefix) +
1193
1197
  msgId;
1194
- var strProps = strEmpty;
1198
+ var strProps = "";
1195
1199
  if (hasJSON()) {
1196
1200
  strProps = getJSON().stringify(properties);
1197
1201
  }
1198
- var diagnosticText = (msg ? " message:" + _sanitizeDiagnosticText(msg) : strEmpty) +
1199
- (properties ? " props:" + _sanitizeDiagnosticText(strProps) : strEmpty);
1202
+ var diagnosticText = (msg ? " message:" + _sanitizeDiagnosticText(msg) : "") +
1203
+ (properties ? " props:" + _sanitizeDiagnosticText(strProps) : "");
1200
1204
  _self.message += diagnosticText;
1201
1205
  }
1202
1206
  _InternalLogMessage.dataType = "MessageData";
@@ -1223,10 +1227,10 @@
1223
1227
  if (isUserAct === void 0) { isUserAct = false; }
1224
1228
  var message = new _InternalLogMessage(msgId, msg, isUserAct, properties);
1225
1229
  if (_self.enableDebugExceptions()) {
1226
- throw message;
1230
+ throw dumpObj(message);
1227
1231
  }
1228
1232
  else {
1229
- var logFunc = severity === 1 ? strErrorToConsole : strWarnToConsole;
1233
+ var logFunc = severity === exports.LoggingSeverity.CRITICAL ? strErrorToConsole : strWarnToConsole;
1230
1234
  if (!isUndefined(message.message)) {
1231
1235
  var logLevel = _self.consoleLoggingLevel();
1232
1236
  if (isUserAct) {
@@ -1244,7 +1248,7 @@
1244
1248
  _self.logInternalMessage(severity, message);
1245
1249
  }
1246
1250
  else {
1247
- _debugExtMsg("throw" + (severity === 1 ? "Critical" : "Warning"), message);
1251
+ _debugExtMsg("throw" + (severity === exports.LoggingSeverity.CRITICAL ? "Critical" : "Warning"), message);
1248
1252
  }
1249
1253
  }
1250
1254
  };
@@ -1276,13 +1280,13 @@
1276
1280
  if (severity <= _self.telemetryLoggingLevel()) {
1277
1281
  _self.queue.push(message);
1278
1282
  _messageCount++;
1279
- _debugExtMsg((severity === 1 ? "error" : "warn"), message);
1283
+ _debugExtMsg((severity === exports.LoggingSeverity.CRITICAL ? "error" : "warn"), message);
1280
1284
  }
1281
1285
  if (_messageCount === _self.maxInternalMessageLimit()) {
1282
1286
  var throttleLimitMessage = "Internal events throttle limit per PageView reached for this app.";
1283
- var throttleMessage = new _InternalLogMessage(23 , throttleLimitMessage, false);
1287
+ var throttleMessage = new _InternalLogMessage(_InternalMessageId.MessageLimitPerPVExceeded, throttleLimitMessage, false);
1284
1288
  _self.queue.push(throttleMessage);
1285
- if (severity === 1 ) {
1289
+ if (severity === exports.LoggingSeverity.CRITICAL) {
1286
1290
  _self.errorToConsole(throttleLimitMessage);
1287
1291
  }
1288
1292
  else {
@@ -1311,10 +1315,6 @@
1311
1315
  }
1312
1316
  return DiagnosticLogger;
1313
1317
  }());
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
1318
 
1319
1319
  var strExecutionContextKey = "ctx";
1320
1320
  var _defaultPerfManager = null;
@@ -1463,587 +1463,369 @@
1463
1463
  return _defaultPerfManager;
1464
1464
  }
1465
1465
 
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;
1466
+ var TelemetryPluginChain = /** @class */ (function () {
1467
+ function TelemetryPluginChain(plugin, defItemCtx) {
1468
+ var _self = this;
1469
+ var _nextProxy = null;
1470
+ var _hasProcessTelemetry = isFunction(plugin.processTelemetry);
1471
+ var _hasSetNext = isFunction(plugin.setNextPlugin);
1472
+ _self._hasRun = false;
1473
+ _self.getPlugin = function () {
1474
+ return plugin;
1475
+ };
1476
+ _self.getNext = function () {
1477
+ return _nextProxy;
1478
+ };
1479
+ _self.setNext = function (nextPlugin) {
1480
+ _nextProxy = nextPlugin;
1481
+ };
1482
+ _self.processTelemetry = function (env, itemCtx) {
1483
+ if (!itemCtx) {
1484
+ itemCtx = defItemCtx;
1485
+ }
1486
+ var identifier = plugin ? plugin.identifier : "TelemetryPluginChain";
1487
+ doPerf(itemCtx ? itemCtx.core() : null, function () { return identifier + ":processTelemetry"; }, function () {
1488
+ if (plugin && _hasProcessTelemetry) {
1489
+ _self._hasRun = true;
1490
+ try {
1491
+ itemCtx.setNext(_nextProxy);
1492
+ if (_hasSetNext) {
1493
+ plugin.setNextPlugin(_nextProxy);
1494
+ }
1495
+ _nextProxy && (_nextProxy._hasRun = false);
1496
+ plugin.processTelemetry(env, itemCtx);
1497
+ }
1498
+ catch (error) {
1499
+ var hasRun = _nextProxy && _nextProxy._hasRun;
1500
+ if (!_nextProxy || !hasRun) {
1501
+ itemCtx.diagLog().throwInternal(exports.LoggingSeverity.CRITICAL, _InternalMessageId.PluginException, "Plugin [" + plugin.identifier + "] failed during processTelemetry - " + dumpObj(error));
1502
+ }
1503
+ if (_nextProxy && !hasRun) {
1504
+ _nextProxy.processTelemetry(env, itemCtx);
1505
+ }
1506
+ }
1507
+ }
1508
+ else if (_nextProxy) {
1509
+ _self._hasRun = true;
1510
+ _nextProxy.processTelemetry(env, itemCtx);
1511
+ }
1512
+ }, function () { return ({ item: env }); }, !(env.sync));
1513
+ };
1498
1514
  }
1499
- if (value === 0 && isIE()) {
1500
- if (!_mwcSeeded) {
1501
- _autoSeedMwc();
1515
+ return TelemetryPluginChain;
1516
+ }());
1517
+
1518
+ function _createProxyChain(plugins, itemCtx) {
1519
+ var proxies = [];
1520
+ if (plugins && plugins.length > 0) {
1521
+ var lastProxy = null;
1522
+ for (var idx = 0; idx < plugins.length; idx++) {
1523
+ var thePlugin = plugins[idx];
1524
+ if (thePlugin && isFunction(thePlugin.processTelemetry)) {
1525
+ var newProxy = new TelemetryPluginChain(thePlugin, itemCtx);
1526
+ proxies.push(newProxy);
1527
+ if (lastProxy) {
1528
+ lastProxy.setNext(newProxy);
1529
+ }
1530
+ lastProxy = newProxy;
1531
+ }
1502
1532
  }
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
1533
  }
1528
- return value;
1534
+ return proxies.length > 0 ? proxies[0] : null;
1529
1535
  }
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;
1536
+ function _copyProxyChain(proxy, itemCtx, startAt) {
1537
+ var plugins = [];
1538
+ var add = startAt ? false : true;
1539
+ if (proxy) {
1540
+ while (proxy) {
1541
+ var thePlugin = proxy.getPlugin();
1542
+ if (add || thePlugin === startAt) {
1543
+ add = true;
1544
+ plugins.push(thePlugin);
1545
+ }
1546
+ proxy = proxy.getNext();
1543
1547
  }
1544
1548
  }
1545
- return result;
1546
- }
1547
-
1548
- var _objDefineProperty = ObjDefineProperty;
1549
- var version = "2.7.5-nightly.2204-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
- }
1549
+ if (!add) {
1550
+ plugins.push(startAt);
1564
1551
  }
1565
- return false;
1552
+ return _createProxyChain(plugins, itemCtx);
1566
1553
  }
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
- }
1554
+ function _copyPluginChain(srcPlugins, itemCtx, startAt) {
1555
+ var plugins = srcPlugins;
1556
+ var add = false;
1557
+ if (startAt && srcPlugins) {
1558
+ plugins = [];
1559
+ arrForEach(srcPlugins, function (thePlugin) {
1560
+ if (add || thePlugin === startAt) {
1561
+ add = true;
1562
+ plugins.push(thePlugin);
1579
1563
  }
1564
+ });
1565
+ }
1566
+ if (startAt && !add) {
1567
+ if (!plugins) {
1568
+ plugins = [];
1580
1569
  }
1581
- catch (e) {
1582
- }
1570
+ plugins.push(startAt);
1583
1571
  }
1584
- return theCache;
1572
+ return _createProxyChain(plugins, itemCtx);
1585
1573
  }
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;
1574
+ var ProcessTelemetryContext = /** @class */ (function () {
1575
+ function ProcessTelemetryContext(plugins, config, core, startAt) {
1576
+ var _self = this;
1577
+ var _nextProxy = null;
1578
+ if (startAt !== null) {
1579
+ if (plugins && isFunction(plugins.getPlugin)) {
1580
+ _nextProxy = _copyProxyChain(plugins, _self, startAt || plugins.getPlugin());
1604
1581
  }
1605
- return theCache[normalizeJsName(name)];
1606
- },
1607
- kill: function (target, name) {
1608
- if (target && target[name]) {
1609
- try {
1610
- delete target[name];
1582
+ else {
1583
+ if (startAt) {
1584
+ _nextProxy = _copyPluginChain(plugins, _self, startAt);
1611
1585
  }
1612
- catch (e) {
1586
+ else if (isUndefined(startAt)) {
1587
+ _nextProxy = _createProxyChain(plugins, _self);
1613
1588
  }
1614
1589
  }
1615
1590
  }
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]();
1591
+ _self.core = function () {
1592
+ return core;
1593
+ };
1594
+ _self.diagLog = function () {
1595
+ return safeGetLogger(core, config);
1596
+ };
1597
+ _self.getCfg = function () {
1598
+ return config;
1599
+ };
1600
+ _self.getExtCfg = function (identifier, defaultValue) {
1601
+ if (defaultValue === void 0) { defaultValue = {}; }
1602
+ var theConfig;
1603
+ if (config) {
1604
+ var extConfig = config.extensionConfig;
1605
+ if (extConfig && identifier) {
1606
+ theConfig = extConfig[identifier];
1607
+ }
1641
1608
  }
1642
- else {
1643
- pluginState = _getPluginState(thePlugin);
1644
- isInitialized = pluginState[strIsInitialized];
1609
+ return (theConfig ? theConfig : defaultValue);
1610
+ };
1611
+ _self.getConfig = function (identifier, field, defaultValue) {
1612
+ if (defaultValue === void 0) { defaultValue = false; }
1613
+ var theValue;
1614
+ var extConfig = _self.getExtCfg(identifier, null);
1615
+ if (extConfig && !isNullOrUndefined(extConfig[field])) {
1616
+ theValue = extConfig[field];
1645
1617
  }
1646
- if (!isInitialized) {
1647
- initPlugins.push(thePlugin);
1618
+ else if (config && !isNullOrUndefined(config[field])) {
1619
+ theValue = config[field];
1648
1620
  }
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
- }
1621
+ return !isNullOrUndefined(theValue) ? theValue : defaultValue;
1622
+ };
1623
+ _self.hasNext = function () {
1624
+ return _nextProxy != null;
1625
+ };
1626
+ _self.getNext = function () {
1627
+ return _nextProxy;
1628
+ };
1629
+ _self.setNext = function (nextPlugin) {
1630
+ _nextProxy = nextPlugin;
1631
+ };
1632
+ _self.processNext = function (env) {
1633
+ var nextPlugin = _nextProxy;
1634
+ if (nextPlugin) {
1635
+ _nextProxy = nextPlugin.getNext();
1636
+ nextPlugin.processTelemetry(env, _self);
1689
1637
  }
1690
- }
1638
+ };
1639
+ _self.createNew = function (plugins, startAt) {
1640
+ if (plugins === void 0) { plugins = null; }
1641
+ return new ProcessTelemetryContext(plugins || _nextProxy, config, core, startAt);
1642
+ };
1691
1643
  }
1692
- return _doUnload();
1693
- }
1644
+ return ProcessTelemetryContext;
1645
+ }());
1694
1646
 
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 = [];
1647
+ var strIKey = "iKey";
1648
+ var strExtensionConfig = "extensionConfig";
1649
+
1650
+ var strGetPlugin = "getPlugin";
1651
+ var BaseTelemetryPlugin = /** @class */ (function () {
1652
+ function BaseTelemetryPlugin() {
1653
+ var _self = this;
1654
+ var _isinitialized = false;
1655
+ var _rootCtx = null;
1656
+ var _nextPlugin = null;
1657
+ _self.core = null;
1658
+ _self.diagLog = function (itemCtx) {
1659
+ return _self._getTelCtx(itemCtx).diagLog();
1660
+ };
1661
+ _self.isInitialized = function () {
1662
+ return _isinitialized;
1663
+ };
1664
+ _self.setInitialized = function (isInitialized) {
1665
+ _isinitialized = isInitialized;
1666
+ };
1667
+ _self.setNextPlugin = function (next) {
1668
+ _nextPlugin = next;
1669
+ };
1670
+ _self.processNext = function (env, itemCtx) {
1671
+ if (itemCtx) {
1672
+ itemCtx.processNext(env);
1769
1673
  }
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];
1674
+ else if (_nextPlugin && isFunction(_nextPlugin.processTelemetry)) {
1675
+ _nextPlugin.processTelemetry(env, null);
1781
1676
  }
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
- });
1677
+ };
1678
+ _self._getTelCtx = function (currentCtx) {
1679
+ if (currentCtx === void 0) { currentCtx = null; }
1680
+ var itemCtx = currentCtx;
1681
+ if (!itemCtx) {
1682
+ var rootCtx = _rootCtx || new ProcessTelemetryContext(null, {}, _self.core);
1683
+ if (_nextPlugin && _nextPlugin[strGetPlugin]) {
1684
+ itemCtx = rootCtx.createNew(null, _nextPlugin[strGetPlugin]);
1685
+ }
1686
+ else {
1687
+ itemCtx = rootCtx.createNew(null, _nextPlugin);
1798
1688
  }
1799
1689
  }
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);
1690
+ return itemCtx;
1691
+ };
1692
+ _self._baseTelInit = function (config, core, extensions, pluginChain) {
1693
+ if (config) {
1694
+ setValue(config, strExtensionConfig, [], null, isNullOrUndefined);
1821
1695
  }
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);
1696
+ if (!pluginChain && core) {
1697
+ pluginChain = core.getProcessTelContext().getNext();
1871
1698
  }
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);
1699
+ var nextPlugin = _nextPlugin;
1700
+ if (_nextPlugin && _nextPlugin[strGetPlugin]) {
1701
+ nextPlugin = _nextPlugin[strGetPlugin]();
1702
+ }
1703
+ _self.core = core;
1704
+ _rootCtx = new ProcessTelemetryContext(pluginChain, config, core, nextPlugin);
1705
+ _isinitialized = true;
1706
+ };
1880
1707
  }
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;
1708
+ BaseTelemetryPlugin.prototype.initialize = function (config, core, extensions, pluginChain) {
1709
+ this._baseTelInit(config, core, extensions, pluginChain);
1710
+ };
1711
+ return BaseTelemetryPlugin;
1712
+ }());
1713
+
1714
+ var processTelemetry = "processTelemetry";
1715
+ var priority = "priority";
1716
+ var setNextPlugin = "setNextPlugin";
1717
+ var isInitialized = "isInitialized";
1718
+ function initializePlugins(processContext, extensions) {
1719
+ var initPlugins = [];
1720
+ var lastPlugin = null;
1721
+ var proxy = processContext.getNext();
1722
+ while (proxy) {
1723
+ var thePlugin = proxy.getPlugin();
1724
+ if (thePlugin) {
1725
+ if (lastPlugin &&
1726
+ isFunction(lastPlugin[setNextPlugin]) &&
1727
+ isFunction(thePlugin[processTelemetry])) {
1728
+ lastPlugin[setNextPlugin](thePlugin);
1893
1729
  }
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;
1730
+ if (!isFunction(thePlugin[isInitialized]) || !thePlugin[isInitialized]()) {
1731
+ initPlugins.push(thePlugin);
1903
1732
  }
1904
- });
1905
- }
1906
- if (startAt && !firstProxy) {
1907
- return createTelemetryProxyChain([startAt], config, core);
1733
+ lastPlugin = thePlugin;
1734
+ proxy = proxy.getNext();
1735
+ }
1908
1736
  }
1909
- return firstProxy;
1737
+ arrForEach(initPlugins, function (thePlugin) {
1738
+ thePlugin.initialize(processContext.getCfg(), processContext.core(), extensions, processContext.getNext());
1739
+ });
1910
1740
  }
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);
1741
+ function sortPlugins(plugins) {
1742
+ return plugins.sort(function (extA, extB) {
1743
+ var result = 0;
1744
+ var bHasProcess = isFunction(extB[processTelemetry]);
1745
+ if (isFunction(extA[processTelemetry])) {
1746
+ result = bHasProcess ? extA[priority] - extB[priority] : 1;
1944
1747
  }
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] = {};
1748
+ else if (bHasProcess) {
1749
+ result = -1;
1953
1750
  }
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);
1751
+ return result;
1752
+ });
1753
+ }
1754
+
1755
+ var ChannelControllerPriority = 500;
1756
+ var ChannelValidationMessage = "Channel has invalid priority";
1757
+ var ChannelController = /** @class */ (function (_super) {
1758
+ __extendsFn(ChannelController, _super);
1759
+ function ChannelController() {
1760
+ var _this = _super.call(this) || this;
1761
+ _this.identifier = "ChannelControllerPlugin";
1762
+ _this.priority = ChannelControllerPriority;
1763
+ var _channelQueue;
1764
+ dynamicProto(ChannelController, _this, function (_self, _base) {
1765
+ _self.setNextPlugin = function (next) {
1766
+ };
1767
+ _self.processTelemetry = function (item, itemCtx) {
1768
+ if (_channelQueue) {
1769
+ arrForEach(_channelQueue, function (queues) {
1770
+ if (queues.length > 0) {
1771
+ var chainCtx = _this._getTelCtx(itemCtx).createNew(queues);
1772
+ chainCtx.processNext(item);
1773
+ }
1774
+ });
1964
1775
  }
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
- }
1776
+ };
1777
+ _self.getChannelControls = function () {
1778
+ return _channelQueue;
1779
+ };
1780
+ _self.initialize = function (config, core, extensions) {
1781
+ if (_self.isInitialized()) {
1782
+ return;
1783
+ }
1784
+ _base.initialize(config, core, extensions);
1785
+ _createChannelQueues((config || {}).channels, extensions);
1786
+ arrForEach(_channelQueue, function (queue) { return initializePlugins(new ProcessTelemetryContext(queue, config, core), extensions); });
1787
+ };
1788
+ });
1789
+ function _checkQueuePriority(queue) {
1790
+ arrForEach(queue, function (queueItem) {
1791
+ if (queueItem.priority < ChannelControllerPriority) {
1792
+ throwError(ChannelValidationMessage + queueItem.identifier);
1973
1793
  }
1974
- }, details, isAsync);
1794
+ });
1975
1795
  }
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);
1796
+ function _addChannelQueue(queue) {
1797
+ if (queue && queue.length > 0) {
1798
+ queue = queue.sort(function (a, b) {
1799
+ return a.priority - b.priority;
1800
+ });
1801
+ _checkQueuePriority(queue);
1802
+ _channelQueue.push(queue);
1990
1803
  }
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
1804
  }
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
- }
1805
+ function _createChannelQueues(channels, extensions) {
1806
+ _channelQueue = [];
1807
+ if (channels) {
1808
+ arrForEach(channels, function (queue) { return _addChannelQueue(queue); });
2012
1809
  }
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;
1810
+ if (extensions) {
1811
+ var extensionQueue_1 = [];
1812
+ arrForEach(extensions, function (plugin) {
1813
+ if (plugin.priority > ChannelControllerPriority) {
1814
+ extensionQueue_1.push(plugin);
2028
1815
  }
2029
- }
1816
+ });
1817
+ _addChannelQueue(extensionQueue_1);
2030
1818
  }
2031
- return hasRun;
2032
1819
  }
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));
1820
+ return _this;
2044
1821
  }
2045
- return ProcessTelemetryContext;
2046
- }());
1822
+ ChannelController._staticInit = (function () {
1823
+ var proto = ChannelController.prototype;
1824
+ objDefineAccessors(proto, "ChannelControls", proto.getChannelControls);
1825
+ objDefineAccessors(proto, "channelQueue", proto.getChannelControls);
1826
+ })();
1827
+ return ChannelController;
1828
+ }(BaseTelemetryPlugin));
2047
1829
 
2048
1830
  var strToGMTString = "toGMTString";
2049
1831
  var strToUTCString = "toUTCString";
@@ -2053,6 +1835,7 @@
2053
1835
  var strIsCookieUseDisabled = "isCookieUseDisabled";
2054
1836
  var strDisableCookiesUsage = "disableCookiesUsage";
2055
1837
  var strConfigCookieMgr = "_ckMgr";
1838
+ var strEmpty = "";
2056
1839
  var _supportsCookies = null;
2057
1840
  var _allowUaSameSite = null;
2058
1841
  var _parsedCookieValue = null;
@@ -2211,7 +1994,7 @@
2211
1994
  _supportsCookies = doc[strCookie] !== undefined;
2212
1995
  }
2213
1996
  catch (e) {
2214
- _throwInternal(logger, 2 , 68 , "Cannot access document.cookie - " + getExceptionName(e), { exception: dumpObj(e) });
1997
+ logger && logger.throwInternal(exports.LoggingSeverity.WARNING, _InternalMessageId.CannotAccessCookie, "Cannot access document.cookie - " + getExceptionName(e), { exception: dumpObj(e) });
2215
1998
  }
2216
1999
  }
2217
2000
  return _supportsCookies;
@@ -2290,583 +2073,118 @@
2290
2073
  return false;
2291
2074
  }
2292
2075
 
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
- }
2076
+ var validationError = "Extensions must provide callback to initialize";
2077
+ var strNotificationManager = "_notificationManager";
2078
+ function _createPerfManager(core, notificationMgr) {
2079
+ return new PerfManager(notificationMgr);
2313
2080
  }
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);
2081
+ var BaseCore = /** @class */ (function () {
2082
+ function BaseCore() {
2083
+ var _isInitialized = false;
2084
+ var _eventQueue;
2085
+ var _channelController;
2086
+ var _notificationManager;
2087
+ var _perfManager;
2088
+ var _cookieManager;
2089
+ dynamicProto(BaseCore, this, function (_self) {
2090
+ _self._extensions = new Array();
2091
+ _channelController = new ChannelController();
2092
+ _self.logger = new DiagnosticLogger({ loggingLevelConsole: exports.LoggingSeverity.CRITICAL });
2093
+ _eventQueue = [];
2094
+ _self.isInitialized = function () { return _isInitialized; };
2095
+ _self.initialize = function (config, extensions, logger, notificationManager) {
2096
+ if (_self.isInitialized()) {
2097
+ throwError("Core should not be initialized more than once");
2335
2098
  }
2336
- else {
2337
- waiting--;
2099
+ if (!config || isNullOrUndefined(config.instrumentationKey)) {
2100
+ throwError("Please provide instrumentation key");
2338
2101
  }
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
- }
2102
+ _notificationManager = notificationManager;
2103
+ _self[strNotificationManager] = notificationManager;
2104
+ _self.config = config || {};
2105
+ if (notificationManager && _self.config.disableDbgExt !== true) {
2106
+ notificationManager.addNotificationListener(getDebugListener(config));
2381
2107
  }
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;
2108
+ if (_self.config.enablePerfMgr) {
2109
+ setValue(_self.config, "createPerfMgr", _createPerfManager);
2440
2110
  }
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
- }
2111
+ config.extensions = isNullOrUndefined(config.extensions) ? [] : config.extensions;
2112
+ var extConfig = getSetValue(config, strExtensionConfig);
2113
+ extConfig.NotificationManager = notificationManager;
2114
+ if (logger) {
2115
+ _self.logger = logger;
2116
+ }
2117
+ var allExtensions = [];
2118
+ allExtensions.push.apply(allExtensions, __spreadArrayFn(__spreadArrayFn([], extensions, false), config.extensions));
2119
+ allExtensions = sortPlugins(allExtensions);
2120
+ var coreExtensions = [];
2121
+ var extPriorities = {};
2122
+ arrForEach(allExtensions, function (ext) {
2123
+ if (isNullOrUndefined(ext) || isNullOrUndefined(ext.initialize)) {
2124
+ throwError(validationError);
2125
+ }
2126
+ var extPriority = ext.priority;
2127
+ var identifier = ext.identifier;
2128
+ if (ext && extPriority) {
2129
+ if (!isNullOrUndefined(extPriorities[extPriority])) {
2130
+ logger.warnToConsole("Two extensions have same priority #" + extPriority + " - " + extPriorities[extPriority] + ", " + identifier);
2131
+ }
2132
+ else {
2133
+ extPriorities[extPriority] = identifier;
2462
2134
  }
2463
2135
  }
2136
+ if (!extPriority || extPriority < _channelController.priority) {
2137
+ coreExtensions.push(ext);
2138
+ }
2464
2139
  });
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) {
2140
+ allExtensions.push(_channelController);
2141
+ coreExtensions.push(_channelController);
2142
+ allExtensions = sortPlugins(allExtensions);
2143
+ _self._extensions = allExtensions;
2144
+ initializePlugins(new ProcessTelemetryContext([_channelController], config, _self), allExtensions);
2145
+ initializePlugins(new ProcessTelemetryContext(coreExtensions, config, _self), allExtensions);
2146
+ _self._extensions = coreExtensions;
2147
+ if (_self.getTransmissionControls().length === 0) {
2827
2148
  throwError("No channels available");
2828
2149
  }
2829
2150
  _isInitialized = true;
2830
2151
  _self.releaseQueue();
2831
2152
  };
2832
2153
  _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);
2154
+ return _channelController.getChannelControls();
2840
2155
  };
2841
2156
  _self.track = function (telemetryItem) {
2842
2157
  setValue(telemetryItem, strIKey, _self.config.instrumentationKey, null, isNotTruthy);
2843
2158
  setValue(telemetryItem, "time", toISOString(new Date()), null, isNotTruthy);
2844
2159
  setValue(telemetryItem, "ver", "4.0", null, isNullOrUndefined);
2845
- if (!_isUnloading && _self.isInitialized()) {
2846
- _createTelCtx().processNext(telemetryItem);
2160
+ if (_self.isInitialized()) {
2161
+ _self.getProcessTelContext().processNext(telemetryItem);
2847
2162
  }
2848
2163
  else {
2849
2164
  _eventQueue.push(telemetryItem);
2850
2165
  }
2851
2166
  };
2852
- _self.getProcessTelContext = _createTelCtx;
2167
+ _self.getProcessTelContext = function () {
2168
+ var extensions = _self._extensions;
2169
+ var thePlugins = extensions;
2170
+ if (!extensions || extensions.length === 0) {
2171
+ thePlugins = [_channelController];
2172
+ }
2173
+ return new ProcessTelemetryContext(thePlugins, _self.config, _self);
2174
+ };
2853
2175
  _self.getNotifyMgr = function () {
2854
2176
  if (!_notificationManager) {
2855
- _notificationManager = _createDummyNotificationManager();
2177
+ _notificationManager = objCreateFn({
2178
+ addNotificationListener: function (listener) { },
2179
+ removeNotificationListener: function (listener) { },
2180
+ eventsSent: function (events) { },
2181
+ eventsDiscarded: function (events, reason) { },
2182
+ eventsSendRequest: function (sendReason, isAsync) { }
2183
+ });
2856
2184
  _self[strNotificationManager] = _notificationManager;
2857
2185
  }
2858
2186
  return _notificationManager;
2859
2187
  };
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
2188
  _self.getCookieMgr = function () {
2871
2189
  if (!_cookieManager) {
2872
2190
  _cookieManager = createCookieMgr(_self.config, _self.logger);
@@ -2877,12 +2195,12 @@
2877
2195
  _cookieManager = cookieMgr;
2878
2196
  };
2879
2197
  _self.getPerfMgr = function () {
2880
- if (!_perfManager && !_cfgPerfManager) {
2198
+ if (!_perfManager) {
2881
2199
  if (_self.config && _self.config.enablePerfMgr && isFunction(_self.config.createPerfMgr)) {
2882
- _cfgPerfManager = _self.config.createPerfMgr(_self, _self.getNotifyMgr());
2200
+ _perfManager = _self.config.createPerfMgr(_self, _self.getNotifyMgr());
2883
2201
  }
2884
2202
  }
2885
- return _perfManager || _cfgPerfManager || getGblPerfMgr();
2203
+ return _perfManager || getGblPerfMgr();
2886
2204
  };
2887
2205
  _self.setPerfMgr = function (perfMgr) {
2888
2206
  _perfManager = perfMgr;
@@ -2891,381 +2209,78 @@
2891
2209
  return _eventQueue.length;
2892
2210
  };
2893
2211
  _self.releaseQueue = function () {
2894
- if (_isInitialized && _eventQueue.length > 0) {
2895
- var eventQueue = _eventQueue;
2896
- _eventQueue = [];
2897
- arrForEach(eventQueue, function (event) {
2898
- _createTelCtx().processNext(event);
2212
+ if (_eventQueue.length > 0) {
2213
+ arrForEach(_eventQueue, function (event) {
2214
+ _self.getProcessTelContext().processNext(event);
2899
2215
  });
2216
+ _eventQueue = [];
2900
2217
  }
2901
2218
  };
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
- }
2990
- });
2991
- }
2992
- else {
2993
- _addPlugin();
2994
- }
2995
- };
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
2219
  });
3210
2220
  }
3211
2221
  return BaseCore;
3212
2222
  }());
3213
2223
 
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
2224
  var NotificationManager = /** @class */ (function () {
3231
2225
  function NotificationManager(config) {
3232
2226
  this.listeners = [];
3233
2227
  var perfEvtsSendAll = !!(config || {}).perfEvtsSendAll;
3234
2228
  dynamicProto(NotificationManager, this, function (_self) {
3235
- _self[strAddNotificationListener] = function (listener) {
2229
+ _self.addNotificationListener = function (listener) {
3236
2230
  _self.listeners.push(listener);
3237
2231
  };
3238
- _self[strRemoveNotificationListener] = function (listener) {
2232
+ _self.removeNotificationListener = function (listener) {
3239
2233
  var index = arrIndexOf(_self.listeners, listener);
3240
2234
  while (index > -1) {
3241
2235
  _self.listeners.splice(index, 1);
3242
2236
  index = arrIndexOf(_self.listeners, listener);
3243
2237
  }
3244
2238
  };
3245
- _self[strEventsSent] = function (events) {
3246
- _runListeners(_self.listeners, strEventsSent, true, function (listener) {
3247
- listener[strEventsSent](events);
2239
+ _self.eventsSent = function (events) {
2240
+ arrForEach(_self.listeners, function (listener) {
2241
+ if (listener && listener.eventsSent) {
2242
+ setTimeout(function () { return listener.eventsSent(events); }, 0);
2243
+ }
3248
2244
  });
3249
2245
  };
3250
- _self[strEventsDiscarded] = function (events, reason) {
3251
- _runListeners(_self.listeners, strEventsDiscarded, true, function (listener) {
3252
- listener[strEventsDiscarded](events, reason);
2246
+ _self.eventsDiscarded = function (events, reason) {
2247
+ arrForEach(_self.listeners, function (listener) {
2248
+ if (listener && listener.eventsDiscarded) {
2249
+ setTimeout(function () { return listener.eventsDiscarded(events, reason); }, 0);
2250
+ }
3253
2251
  });
3254
2252
  };
3255
- _self[strEventsSendRequest] = function (sendReason, isAsync) {
3256
- _runListeners(_self.listeners, strEventsSendRequest, isAsync, function (listener) {
3257
- listener[strEventsSendRequest](sendReason, isAsync);
2253
+ _self.eventsSendRequest = function (sendReason, isAsync) {
2254
+ arrForEach(_self.listeners, function (listener) {
2255
+ if (listener && listener.eventsSendRequest) {
2256
+ if (isAsync) {
2257
+ setTimeout(function () { return listener.eventsSendRequest(sendReason, isAsync); }, 0);
2258
+ }
2259
+ else {
2260
+ try {
2261
+ listener.eventsSendRequest(sendReason, isAsync);
2262
+ }
2263
+ catch (e) {
2264
+ }
2265
+ }
2266
+ }
3258
2267
  });
3259
2268
  };
3260
- _self[strPerfEvent] = function (perfEvent) {
2269
+ _self.perfEvent = function (perfEvent) {
3261
2270
  if (perfEvent) {
3262
2271
  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);
2272
+ arrForEach(_self.listeners, function (listener) {
2273
+ if (listener && listener.perfEvent) {
2274
+ if (perfEvent.isAsync) {
2275
+ setTimeout(function () { return listener.perfEvent(perfEvent); }, 0);
2276
+ }
2277
+ else {
2278
+ try {
2279
+ listener.perfEvent(perfEvent);
2280
+ }
2281
+ catch (e) {
2282
+ }
2283
+ }
3269
2284
  }
3270
2285
  });
3271
2286
  }
@@ -3280,6 +2295,7 @@
3280
2295
  __extendsFn(AppInsightsCore, _super);
3281
2296
  function AppInsightsCore() {
3282
2297
  var _this = _super.call(this) || this;
2298
+ var _internalLogPoller = 0;
3283
2299
  dynamicProto(AppInsightsCore, _this, function (_self, _base) {
3284
2300
  _self.initialize = function (config, extensions, logger, notificationManager) {
3285
2301
  _base.initialize(config, extensions, logger || new DiagnosticLogger(config), notificationManager || new NotificationManager(config));
@@ -3294,6 +2310,48 @@
3294
2310
  _base.track(telemetryItem);
3295
2311
  }, function () { return ({ item: telemetryItem }); }, !(telemetryItem.sync));
3296
2312
  };
2313
+ _self.addNotificationListener = function (listener) {
2314
+ var manager = _self.getNotifyMgr();
2315
+ if (manager) {
2316
+ manager.addNotificationListener(listener);
2317
+ }
2318
+ };
2319
+ _self.removeNotificationListener = function (listener) {
2320
+ var manager = _self.getNotifyMgr();
2321
+ if (manager) {
2322
+ manager.removeNotificationListener(listener);
2323
+ }
2324
+ };
2325
+ _self.pollInternalLogs = function (eventName) {
2326
+ var interval = _self.config.diagnosticLogInterval;
2327
+ if (!interval || !(interval > 0)) {
2328
+ interval = 10000;
2329
+ }
2330
+ if (_internalLogPoller) {
2331
+ _self.stopPollingInternalLogs();
2332
+ }
2333
+ _internalLogPoller = setInterval(function () {
2334
+ var queue = _self.logger ? _self.logger.queue : [];
2335
+ arrForEach(queue, function (logMessage) {
2336
+ var item = {
2337
+ name: eventName ? eventName : "InternalMessageId: " + logMessage.messageId,
2338
+ iKey: _self.config.instrumentationKey,
2339
+ time: toISOString(new Date()),
2340
+ baseType: _InternalLogMessage.dataType,
2341
+ baseData: { message: logMessage.message }
2342
+ };
2343
+ _self.track(item);
2344
+ });
2345
+ queue.length = 0;
2346
+ }, interval);
2347
+ return _internalLogPoller;
2348
+ };
2349
+ _self.stopPollingInternalLogs = function () {
2350
+ if (!_internalLogPoller)
2351
+ return;
2352
+ clearInterval(_internalLogPoller);
2353
+ _internalLogPoller = 0;
2354
+ };
3297
2355
  function _validateTelemetryItem(telemetryItem) {
3298
2356
  if (isNullOrUndefined(telemetryItem.name)) {
3299
2357
  _notifyInvalidEvent(telemetryItem);
@@ -3312,315 +2370,151 @@
3312
2370
  return AppInsightsCore;
3313
2371
  }(BaseCore));
3314
2372
 
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
- }
2373
+ var UInt32Mask = 0x100000000;
2374
+ var MaxUInt32 = 0xffffffff;
2375
+ var _mwcSeeded = false;
2376
+ var _mwcW = 123456789;
2377
+ var _mwcZ = 987654321;
2378
+ function _mwcSeed(seedValue) {
2379
+ if (seedValue < 0) {
2380
+ seedValue >>>= 0;
3363
2381
  }
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;
2382
+ _mwcW = (123456789 + seedValue) & MaxUInt32;
2383
+ _mwcZ = (987654321 - seedValue) & MaxUInt32;
2384
+ _mwcSeeded = true;
3387
2385
  }
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] = [];
2386
+ function _autoSeedMwc() {
2387
+ try {
2388
+ var now = dateNow() & 0x7fffffff;
2389
+ _mwcSeed(((Math.random() * UInt32Mask) ^ now) + now);
3394
2390
  }
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
- }
2391
+ catch (e) {
3405
2392
  }
3406
2393
  }
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
- }
2394
+ function randomValue(maxValue) {
2395
+ if (maxValue > 0) {
2396
+ return Math.floor((random32() / MaxUInt32) * (maxValue + 1)) >>> 0;
3418
2397
  }
3419
- return result;
2398
+ return 0;
3420
2399
  }
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
- }
2400
+ function random32(signed) {
2401
+ var value;
2402
+ var c = getCrypto() || getMsCrypto();
2403
+ if (c && c.getRandomValues) {
2404
+ value = c.getRandomValues(new Uint32Array(1))[0] & MaxUInt32;
3433
2405
  }
3434
- }
3435
- function _unregisterEvents(target, evtName, unRegFn) {
3436
- if (evtName.type) {
3437
- _doUnregister(target, _getRegisteredEvents(target, evtName.type), evtName, unRegFn);
2406
+ else if (isIE()) {
2407
+ if (!_mwcSeeded) {
2408
+ _autoSeedMwc();
2409
+ }
2410
+ value = mwcRandom32() & MaxUInt32;
3438
2411
  }
3439
2412
  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
- }
2413
+ value = Math.floor((UInt32Mask * Math.random()) | 0);
2414
+ }
2415
+ if (!signed) {
2416
+ value >>>= 0;
3447
2417
  }
2418
+ return value;
3448
2419
  }
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(".");
2420
+ function mwcRandomSeed(value) {
2421
+ if (!value) {
2422
+ _autoSeedMwc();
3459
2423
  }
3460
2424
  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
- }
2425
+ _mwcSeed(value);
3484
2426
  }
3485
- return result;
3486
2427
  }
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
- }
2428
+ function mwcRandom32(signed) {
2429
+ _mwcZ = (36969 * (_mwcZ & 0xFFFF) + (_mwcZ >> 16)) & MaxUInt32;
2430
+ _mwcW = (18000 * (_mwcW & 0xFFFF) + (_mwcW >> 16)) & MaxUInt32;
2431
+ var value = (((_mwcZ << 16) + (_mwcW & 0xFFFF)) >>> 0) & MaxUInt32 | 0;
2432
+ if (!signed) {
2433
+ value >>>= 0;
3506
2434
  }
2435
+ return value;
3507
2436
  }
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) {
2437
+
2438
+ var strVisibilityChangeEvt = "visibilitychange";
2439
+ var strPageHide = "pagehide";
2440
+ var strPageShow = "pageshow";
2441
+ var _cookieMgrs = null;
2442
+ var _canUseCookies;
2443
+ var Undefined = strShimUndefined;
2444
+ function addEventHandler(eventName, callback) {
3517
2445
  var result = false;
3518
2446
  var w = getWindow();
3519
2447
  if (w) {
3520
- result = eventOn(w, eventName, callback, evtNamespace);
3521
- result = eventOn(w["body"], eventName, callback, evtNamespace) || result;
2448
+ result = attachEvent(w, eventName, callback);
2449
+ result = attachEvent(w["body"], eventName, callback) || result;
3522
2450
  }
3523
2451
  var doc = getDocument();
3524
2452
  if (doc) {
3525
- result = eventOn(doc, eventName, callback, evtNamespace) || result;
2453
+ result = attachEvent(doc, eventName, callback) || result;
3526
2454
  }
3527
2455
  return result;
3528
2456
  }
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) {
2457
+ function addEventListeners(events, listener, excludeEvents) {
3541
2458
  var added = false;
3542
- if (listener && events && events.length > 0) {
2459
+ if (listener && events && isArray(events)) {
2460
+ var excluded_1 = [];
3543
2461
  arrForEach(events, function (name) {
3544
- if (name) {
2462
+ if (isString(name)) {
3545
2463
  if (!excludeEvents || arrIndexOf(excludeEvents, name) === -1) {
3546
- added = addEventHandler(name, listener, evtNamespace) || added;
2464
+ added = addEventHandler(name, listener) || added;
2465
+ }
2466
+ else {
2467
+ excluded_1.push(name);
3547
2468
  }
3548
2469
  }
3549
2470
  });
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);
2471
+ if (!added && excluded_1.length > 0) {
2472
+ added = addEventListeners(excluded_1, listener);
3559
2473
  }
3560
2474
  }
3561
2475
  return added;
3562
2476
  }
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);
2477
+ function addPageUnloadEventListener(listener, excludeEvents) {
2478
+ return addEventListeners(["beforeunload", "unload", "pagehide"], listener, excludeEvents);
3574
2479
  }
3575
- function removePageUnloadEventListener(listener, evtNamespace) {
3576
- removeEventListeners([strBeforeUnload, strUnload, strPageHide], listener, evtNamespace);
3577
- }
3578
- function addPageHideEventListener(listener, excludeEvents, evtNamespace) {
2480
+ function addPageHideEventListener(listener, excludeEvents) {
3579
2481
  function _handlePageVisibility(evt) {
3580
2482
  var doc = getDocument();
3581
2483
  if (listener && doc && doc.visibilityState === "hidden") {
3582
2484
  listener(evt);
3583
2485
  }
3584
2486
  }
3585
- var newNamespaces = mergeEvtNamespace(strPageHideNamespace, evtNamespace);
3586
- var pageUnloadAdded = _addEventListeners([strPageHide], listener, excludeEvents, newNamespaces);
2487
+ var pageUnloadAdded = false;
2488
+ if (!excludeEvents || arrIndexOf(excludeEvents, strPageHide) === -1) {
2489
+ pageUnloadAdded = addEventHandler(strPageHide, listener);
2490
+ }
3587
2491
  if (!excludeEvents || arrIndexOf(excludeEvents, strVisibilityChangeEvt) === -1) {
3588
- pageUnloadAdded = _addEventListeners([strVisibilityChangeEvt], _handlePageVisibility, excludeEvents, newNamespaces) || pageUnloadAdded;
2492
+ pageUnloadAdded = addEventHandler(strVisibilityChangeEvt, _handlePageVisibility) || pageUnloadAdded;
3589
2493
  }
3590
2494
  if (!pageUnloadAdded && excludeEvents) {
3591
- pageUnloadAdded = addPageHideEventListener(listener, null, evtNamespace);
2495
+ pageUnloadAdded = addPageHideEventListener(listener);
3592
2496
  }
3593
2497
  return pageUnloadAdded;
3594
2498
  }
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) {
2499
+ function addPageShowEventListener(listener, excludeEvents) {
3601
2500
  function _handlePageVisibility(evt) {
3602
2501
  var doc = getDocument();
3603
2502
  if (listener && doc && doc.visibilityState === "visible") {
3604
2503
  listener(evt);
3605
2504
  }
3606
2505
  }
3607
- var newNamespaces = mergeEvtNamespace(strPageShowNamespace, evtNamespace);
3608
- var pageShowAdded = _addEventListeners([strPageShow], listener, excludeEvents, newNamespaces);
3609
- pageShowAdded = _addEventListeners([strVisibilityChangeEvt], _handlePageVisibility, excludeEvents, newNamespaces) || pageShowAdded;
2506
+ var pageShowAdded = false;
2507
+ if (!excludeEvents || arrIndexOf(excludeEvents, strPageShow) === -1) {
2508
+ pageShowAdded = addEventHandler(strPageShow, listener);
2509
+ }
2510
+ if (!excludeEvents || arrIndexOf(excludeEvents, strVisibilityChangeEvt) === -1) {
2511
+ pageShowAdded = addEventHandler(strVisibilityChangeEvt, _handlePageVisibility) || pageShowAdded;
2512
+ }
3610
2513
  if (!pageShowAdded && excludeEvents) {
3611
- pageShowAdded = addPageShowEventListener(listener, null, evtNamespace);
2514
+ pageShowAdded = addPageShowEventListener(listener);
3612
2515
  }
3613
2516
  return pageShowAdded;
3614
2517
  }
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
2518
  function newGuid() {
3625
2519
  function randomHexDigit() {
3626
2520
  return randomValue(15);
@@ -3637,9 +2531,26 @@
3637
2531
  }
3638
2532
  return dateNow();
3639
2533
  }
2534
+ function newId(maxLength) {
2535
+ if (maxLength === void 0) { maxLength = 22; }
2536
+ var base64chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
2537
+ var number = random32() >>> 0;
2538
+ var chars = 0;
2539
+ var result = "";
2540
+ while (result.length < maxLength) {
2541
+ chars++;
2542
+ result += base64chars.charAt(number & 0x3F);
2543
+ number >>>= 6;
2544
+ if (chars === 5) {
2545
+ number = (((random32() << 2) & 0xFFFFFFFF) | (number & 0x03)) >>> 0;
2546
+ chars = 0;
2547
+ }
2548
+ }
2549
+ return result;
2550
+ }
3640
2551
  function generateW3CId() {
3641
2552
  var hexValues = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f"];
3642
- var oct = strEmpty, tmp;
2553
+ var oct = "", tmp;
3643
2554
  for (var a = 0; a < 4; a++) {
3644
2555
  tmp = random32();
3645
2556
  oct +=
@@ -3740,95 +2651,6 @@
3740
2651
  return _legacyCookieMgr(null, logger).del(name);
3741
2652
  }
3742
2653
 
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
2654
  var aiInstrumentHooks = "_aiHooks";
3833
2655
  var cbNames = [
3834
2656
  "req", "rsp", "hkErr", "fnErr"
@@ -3887,7 +2709,6 @@
3887
2709
  };
3888
2710
  var hookCtx = [];
3889
2711
  var cbArgs = _createArgs([funcArgs], orgArgs);
3890
- funcArgs.evt = getGlobalInst("event");
3891
2712
  function _createArgs(target, theArgs) {
3892
2713
  _arrLoop(theArgs, function (arg) {
3893
2714
  target.push(arg);
@@ -4003,7 +2824,6 @@
4003
2824
  exports.InstrumentFuncs = InstrumentFuncs;
4004
2825
  exports.InstrumentProto = InstrumentProto;
4005
2826
  exports.InstrumentProtos = InstrumentProtos;
4006
- exports.LoggingSeverity = LoggingSeverity;
4007
2827
  exports.MinChannelPriorty = MinChannelPriorty;
4008
2828
  exports.NotificationManager = NotificationManager;
4009
2829
  exports.PerfEvent = PerfEvent;
@@ -4012,9 +2832,7 @@
4012
2832
  exports.Undefined = Undefined;
4013
2833
  exports._InternalLogMessage = _InternalLogMessage;
4014
2834
  exports._InternalMessageId = _InternalMessageId;
4015
- exports.__getRegisteredEvents = __getRegisteredEvents;
4016
2835
  exports._legacyCookieMgr = _legacyCookieMgr;
4017
- exports._throwInternal = _throwInternal;
4018
2836
  exports.addEventHandler = addEventHandler;
4019
2837
  exports.addEventListeners = addEventListeners;
4020
2838
  exports.addPageHideEventListener = addPageHideEventListener;
@@ -4029,18 +2847,12 @@
4029
2847
  exports.canUseCookies = canUseCookies;
4030
2848
  exports.createClassFromInterface = createClassFromInterface;
4031
2849
  exports.createCookieMgr = createCookieMgr;
4032
- exports.createEnumStyle = createEnumStyle;
4033
- exports.createProcessTelemetryContext = createProcessTelemetryContext;
4034
- exports.createUniqueNamespace = createUniqueNamespace;
4035
- exports.createUnloadHandlerContainer = createUnloadHandlerContainer;
4036
2850
  exports.dateNow = dateNow;
4037
2851
  exports.deleteCookie = deleteCookie;
4038
2852
  exports.detachEvent = detachEvent;
4039
2853
  exports.disableCookies = disableCookies;
4040
2854
  exports.doPerf = doPerf;
4041
2855
  exports.dumpObj = dumpObj;
4042
- exports.eventOff = eventOff;
4043
- exports.eventOn = eventOn;
4044
2856
  exports.generateW3CId = generateW3CId;
4045
2857
  exports.getConsole = getConsole;
4046
2858
  exports.getCookie = getCookie;
@@ -4090,7 +2902,6 @@
4090
2902
  exports.isTypeof = isTypeof;
4091
2903
  exports.isUndefined = isUndefined;
4092
2904
  exports.isXhrSupported = isXhrSupported;
4093
- exports.mergeEvtNamespace = mergeEvtNamespace;
4094
2905
  exports.mwcRandom32 = mwcRandom32;
4095
2906
  exports.mwcRandomSeed = mwcRandomSeed;
4096
2907
  exports.newGuid = newGuid;
@@ -4098,24 +2909,15 @@
4098
2909
  exports.normalizeJsName = normalizeJsName;
4099
2910
  exports.objCreate = objCreateFn;
4100
2911
  exports.objDefineAccessors = objDefineAccessors;
4101
- exports.objExtend = objExtend;
4102
2912
  exports.objForEachKey = objForEachKey;
4103
2913
  exports.objFreeze = objFreeze;
4104
2914
  exports.objKeys = objKeys;
4105
2915
  exports.objSeal = objSeal;
4106
- exports.objToString = objToString;
4107
2916
  exports.optimizeObject = optimizeObject;
4108
2917
  exports.perfNow = perfNow;
4109
2918
  exports.proxyAssign = proxyAssign;
4110
- exports.proxyFunctionAs = proxyFunctionAs;
4111
- exports.proxyFunctions = proxyFunctions;
4112
2919
  exports.random32 = random32;
4113
2920
  exports.randomValue = randomValue;
4114
- exports.removeEventHandler = removeEventHandler;
4115
- exports.removeEventListeners = removeEventListeners;
4116
- exports.removePageHideEventListener = removePageHideEventListener;
4117
- exports.removePageShowEventListener = removePageShowEventListener;
4118
- exports.removePageUnloadEventListener = removePageUnloadEventListener;
4119
2921
  exports.safeGetCookieMgr = safeGetCookieMgr;
4120
2922
  exports.safeGetLogger = safeGetLogger;
4121
2923
  exports.setCookie = setCookie;
@@ -4136,7 +2938,6 @@
4136
2938
  exports.throwError = throwError;
4137
2939
  exports.toISOString = toISOString;
4138
2940
  exports.uaDisallowsSameSiteNone = uaDisallowsSameSiteNone;
4139
- exports.unloadComponents = unloadComponents;
4140
2941
  exports.useXDomainRequest = useXDomainRequest;
4141
2942
 
4142
2943
  (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 });