@microsoft/applicationinsights-react-js 3.3.0-nightly.2202-06 → 3.3.0-nightly.2204-06

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.
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * Application Insights JavaScript SDK - React Plugin, 3.3.0-nightly.2202-06
2
+ * Application Insights JavaScript SDK - React Plugin, 3.3.0-nightly.2204-06
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  */
5
5
  (function (global, factory) {
@@ -98,7 +98,9 @@
98
98
  var __assignFn = ObjAssign || __objAssignFnImpl;
99
99
  var extendStaticsFn = function (d, b) {
100
100
  extendStaticsFn = ObjClass["setPrototypeOf"] ||
101
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
101
+ ({ __proto__: [] } instanceof Array && function (d, b) {
102
+ d.__proto__ = b;
103
+ }) ||
102
104
  function (d, b) {
103
105
  for (var p in b) {
104
106
  if (b[strShimHasOwnProperty](p)) {
@@ -113,7 +115,9 @@
113
115
  throwTypeError("Class extends value " + String(b) + " is not a constructor or null");
114
116
  }
115
117
  extendStaticsFn(d, b);
116
- function __() { this.constructor = d; }
118
+ function __() {
119
+ this.constructor = d;
120
+ }
117
121
  d[strShimPrototype] = b === null ? objCreateFn(b) : (__[strShimPrototype] = b[strShimPrototype], new __());
118
122
  }
119
123
 
@@ -132,11 +136,11 @@
132
136
  var DynAllowInstChkTag = DynInstChkTag;
133
137
  var DynProtoDefaultOptions = '_dfOpts';
134
138
  var UnknownValue = '_unknown_';
135
- var str__Proto = "__proto__";
139
+ var str__Proto$1 = "__proto__";
136
140
  var strUseBaseInst = 'useBaseInst';
137
141
  var strSetInstFuncs = 'setInstFuncs';
138
142
  var Obj = Object;
139
- var _objGetPrototypeOf = Obj["getPrototypeOf"];
143
+ var _objGetPrototypeOf$1 = Obj["getPrototypeOf"];
140
144
  var _dynamicNames = 0;
141
145
  function _hasOwnProperty(obj, prop) {
142
146
  return obj && Obj[Prototype].hasOwnProperty.call(obj, prop);
@@ -147,12 +151,12 @@
147
151
  function _isObjectArrayOrFunctionPrototype(target) {
148
152
  return _isObjectOrArrayPrototype(target) || target === Function[Prototype];
149
153
  }
150
- function _getObjProto(target) {
154
+ function _getObjProto$1(target) {
151
155
  if (target) {
152
- if (_objGetPrototypeOf) {
153
- return _objGetPrototypeOf(target);
156
+ if (_objGetPrototypeOf$1) {
157
+ return _objGetPrototypeOf$1(target);
154
158
  }
155
- var newProto = target[str__Proto] || target[Prototype] || (target[Constructor] ? target[Constructor][Prototype] : null);
159
+ var newProto = target[str__Proto$1] || target[Prototype] || (target[Constructor] ? target[Constructor][Prototype] : null);
156
160
  if (newProto) {
157
161
  return newProto;
158
162
  }
@@ -218,16 +222,16 @@
218
222
  _forEachProp(instFuncs, function (name) {
219
223
  baseFuncs[name] = _instFuncProxy(thisTarget, instFuncs, name);
220
224
  });
221
- var baseProto = _getObjProto(classProto);
225
+ var baseProto = _getObjProto$1(classProto);
222
226
  var visited = [];
223
227
  while (baseProto && !_isObjectArrayOrFunctionPrototype(baseProto) && !_hasVisited(visited, baseProto)) {
224
228
  _forEachProp(baseProto, function (name) {
225
- if (!baseFuncs[name] && _isDynamicCandidate(baseProto, name, !_objGetPrototypeOf)) {
229
+ if (!baseFuncs[name] && _isDynamicCandidate(baseProto, name, !_objGetPrototypeOf$1)) {
226
230
  baseFuncs[name] = _instFuncProxy(thisTarget, baseProto, name);
227
231
  }
228
232
  });
229
233
  visited.push(baseProto);
230
- baseProto = _getObjProto(baseProto);
234
+ baseProto = _getObjProto$1(baseProto);
231
235
  }
232
236
  return baseFuncs;
233
237
  }
@@ -241,7 +245,7 @@
241
245
  }
242
246
  if (!instFunc[DynInstChkTag] && instFuncTable[DynAllowInstChkTag] !== false) {
243
247
  var canAddInst = !_hasOwnProperty(target, funcName);
244
- var objProto = _getObjProto(target);
248
+ var objProto = _getObjProto$1(target);
245
249
  var visited = [];
246
250
  while (canAddInst && objProto && !_isObjectArrayOrFunctionPrototype(objProto) && !_hasVisited(visited, objProto)) {
247
251
  var protoFunc = objProto[funcName];
@@ -250,7 +254,7 @@
250
254
  break;
251
255
  }
252
256
  visited.push(objProto);
253
- objProto = _getObjProto(objProto);
257
+ objProto = _getObjProto$1(objProto);
254
258
  }
255
259
  try {
256
260
  if (canAddInst) {
@@ -268,7 +272,7 @@
268
272
  function _getProtoFunc(funcName, proto, currentDynProtoProxy) {
269
273
  var protoFunc = proto[funcName];
270
274
  if (protoFunc === currentDynProtoProxy) {
271
- protoFunc = _getObjProto(proto)[funcName];
275
+ protoFunc = _getObjProto$1(proto)[funcName];
272
276
  }
273
277
  if (typeof protoFunc !== strFunction) {
274
278
  _throwTypeError("[" + funcName + "] is not a " + strFunction);
@@ -302,15 +306,15 @@
302
306
  }
303
307
  }
304
308
  function _checkPrototype(classProto, thisTarget) {
305
- if (_objGetPrototypeOf) {
309
+ if (_objGetPrototypeOf$1) {
306
310
  var visited = [];
307
- var thisProto = _getObjProto(thisTarget);
311
+ var thisProto = _getObjProto$1(thisTarget);
308
312
  while (thisProto && !_isObjectArrayOrFunctionPrototype(thisProto) && !_hasVisited(visited, thisProto)) {
309
313
  if (thisProto === classProto) {
310
314
  return true;
311
315
  }
312
316
  visited.push(thisProto);
313
- thisProto = _getObjProto(thisProto);
317
+ thisProto = _getObjProto$1(thisProto);
314
318
  }
315
319
  }
316
320
  return false;
@@ -346,7 +350,7 @@
346
350
  var instFuncs = _getInstanceFuncs(target);
347
351
  var baseFuncs = _getBaseFuncs(classProto, target, instFuncs, useBaseInst);
348
352
  delegateFunc(target, baseFuncs);
349
- var setInstanceFunc = !!_objGetPrototypeOf && !!perfOptions[strSetInstFuncs];
353
+ var setInstanceFunc = !!_objGetPrototypeOf$1 && !!perfOptions[strSetInstFuncs];
350
354
  if (setInstanceFunc && options) {
351
355
  setInstanceFunc = !!options[strSetInstFuncs];
352
356
  }
@@ -358,99 +362,15 @@
358
362
  };
359
363
  dynamicProto[DynProtoDefaultOptions] = perfDefaults;
360
364
 
361
- var LoggingSeverity;
362
- (function (LoggingSeverity) {
363
- LoggingSeverity[LoggingSeverity["CRITICAL"] = 1] = "CRITICAL";
364
- LoggingSeverity[LoggingSeverity["WARNING"] = 2] = "WARNING";
365
- })(LoggingSeverity || (LoggingSeverity = {}));
366
- var _InternalMessageId = {
367
- BrowserDoesNotSupportLocalStorage: 0,
368
- BrowserCannotReadLocalStorage: 1,
369
- BrowserCannotReadSessionStorage: 2,
370
- BrowserCannotWriteLocalStorage: 3,
371
- BrowserCannotWriteSessionStorage: 4,
372
- BrowserFailedRemovalFromLocalStorage: 5,
373
- BrowserFailedRemovalFromSessionStorage: 6,
374
- CannotSendEmptyTelemetry: 7,
375
- ClientPerformanceMathError: 8,
376
- ErrorParsingAISessionCookie: 9,
377
- ErrorPVCalc: 10,
378
- ExceptionWhileLoggingError: 11,
379
- FailedAddingTelemetryToBuffer: 12,
380
- FailedMonitorAjaxAbort: 13,
381
- FailedMonitorAjaxDur: 14,
382
- FailedMonitorAjaxOpen: 15,
383
- FailedMonitorAjaxRSC: 16,
384
- FailedMonitorAjaxSend: 17,
385
- FailedMonitorAjaxGetCorrelationHeader: 18,
386
- FailedToAddHandlerForOnBeforeUnload: 19,
387
- FailedToSendQueuedTelemetry: 20,
388
- FailedToReportDataLoss: 21,
389
- FlushFailed: 22,
390
- MessageLimitPerPVExceeded: 23,
391
- MissingRequiredFieldSpecification: 24,
392
- NavigationTimingNotSupported: 25,
393
- OnError: 26,
394
- SessionRenewalDateIsZero: 27,
395
- SenderNotInitialized: 28,
396
- StartTrackEventFailed: 29,
397
- StopTrackEventFailed: 30,
398
- StartTrackFailed: 31,
399
- StopTrackFailed: 32,
400
- TelemetrySampledAndNotSent: 33,
401
- TrackEventFailed: 34,
402
- TrackExceptionFailed: 35,
403
- TrackMetricFailed: 36,
404
- TrackPVFailed: 37,
405
- TrackPVFailedCalc: 38,
406
- TrackTraceFailed: 39,
407
- TransmissionFailed: 40,
408
- FailedToSetStorageBuffer: 41,
409
- FailedToRestoreStorageBuffer: 42,
410
- InvalidBackendResponse: 43,
411
- FailedToFixDepricatedValues: 44,
412
- InvalidDurationValue: 45,
413
- TelemetryEnvelopeInvalid: 46,
414
- CreateEnvelopeError: 47,
415
- CannotSerializeObject: 48,
416
- CannotSerializeObjectNonSerializable: 49,
417
- CircularReferenceDetected: 50,
418
- ClearAuthContextFailed: 51,
419
- ExceptionTruncated: 52,
420
- IllegalCharsInName: 53,
421
- ItemNotInArray: 54,
422
- MaxAjaxPerPVExceeded: 55,
423
- MessageTruncated: 56,
424
- NameTooLong: 57,
425
- SampleRateOutOfRange: 58,
426
- SetAuthContextFailed: 59,
427
- SetAuthContextFailedAccountName: 60,
428
- StringValueTooLong: 61,
429
- StartCalledMoreThanOnce: 62,
430
- StopCalledWithoutStart: 63,
431
- TelemetryInitializerFailed: 64,
432
- TrackArgumentsNotSpecified: 65,
433
- UrlTooLong: 66,
434
- SessionStorageBufferFull: 67,
435
- CannotAccessCookie: 68,
436
- IdTooLong: 69,
437
- InvalidEvent: 70,
438
- FailedMonitorAjaxSetRequestHeader: 71,
439
- SendBrowserInfoOnUserInit: 72,
440
- PluginException: 73,
441
- NotificationException: 74,
442
- SnippetScriptLoadFailure: 99,
443
- InvalidInstrumentationKey: 100,
444
- CannotParseAiBlobValue: 101,
445
- InvalidContentBlob: 102,
446
- TrackPageActionEventFailed: 103,
447
- FailedAddingCustomDefinedRequestContext: 104,
448
- InMemoryStorageBufferFull: 105
449
- };
365
+ var strEmpty = "";
366
+ var strSetNextPlugin = "setNextPlugin";
367
+ var strIsInitialized = "isInitialized";
368
+ var strTeardown = "teardown";
369
+ var strCore = "core";
370
+ var strUpdate = "update";
371
+ var strDisabled = "disabled";
372
+ var strDoTeardown = "_doTeardown";
450
373
 
451
- var strOnPrefix = "on";
452
- var strAttachEvent = "attachEvent";
453
- var strAddEventHelper = "addEventListener";
454
374
  var strToISOString = "toISOString";
455
375
  var cStrEndsWith = "endsWith";
456
376
  var strIndexOf = "indexOf";
@@ -458,7 +378,10 @@
458
378
  var strReduce = "reduce";
459
379
  var cStrTrim = "trim";
460
380
  var strToString = "toString";
461
- var _objDefineProperty = ObjDefineProperty;
381
+ var str__Proto = "__proto__";
382
+ var strConstructor = "constructor";
383
+ var _objDefineProperty$1 = ObjDefineProperty;
384
+ var _objFreeze = ObjClass.freeze;
462
385
  var _objKeys = ObjClass.keys;
463
386
  var StringProto = String[strShimPrototype];
464
387
  var _strTrim = StringProto[cStrTrim];
@@ -468,7 +391,23 @@
468
391
  var _isArray = Array.isArray;
469
392
  var _objToString = ObjProto[strToString];
470
393
  var _fnToString = ObjHasOwnProperty[strToString];
471
- _fnToString.call(ObjClass);
394
+ var _objFunctionString = _fnToString.call(ObjClass);
395
+ var rCamelCase = /-([a-z])/g;
396
+ var rNormalizeInvalid = /([^\w\d_$])/g;
397
+ var rLeadingNumeric = /^(\d+[\w\d_$])/;
398
+ var _objGetPrototypeOf = Object["getPrototypeOf"];
399
+ function _getObjProto(target) {
400
+ if (target) {
401
+ if (_objGetPrototypeOf) {
402
+ return _objGetPrototypeOf(target);
403
+ }
404
+ var newProto = target[str__Proto] || target[strShimPrototype] || target[strConstructor];
405
+ if (newProto) {
406
+ return newProto;
407
+ }
408
+ }
409
+ return null;
410
+ }
472
411
  function isTypeof(value, theType) {
473
412
  return typeof value === theType;
474
413
  }
@@ -490,24 +429,18 @@
490
429
  function isFunction(value) {
491
430
  return !!(value && typeof value === strShimFunction);
492
431
  }
493
- function attachEvent(obj, eventNameWithoutOn, handlerRef, useCapture) {
494
- if (useCapture === void 0) { useCapture = false; }
495
- var result = false;
496
- if (!isNullOrUndefined(obj)) {
497
- try {
498
- if (!isNullOrUndefined(obj[strAddEventHelper])) {
499
- obj[strAddEventHelper](eventNameWithoutOn, handlerRef, useCapture);
500
- result = true;
501
- }
502
- else if (!isNullOrUndefined(obj[strAttachEvent])) {
503
- obj[strAttachEvent](strOnPrefix + eventNameWithoutOn, handlerRef);
504
- result = true;
505
- }
506
- }
507
- catch (e) {
508
- }
432
+ function normalizeJsName(name) {
433
+ var value = name;
434
+ if (value && isString(value)) {
435
+ value = value.replace(rCamelCase, function (_all, letter) {
436
+ return letter.toUpperCase();
437
+ });
438
+ value = value.replace(rNormalizeInvalid, "_");
439
+ value = value.replace(rLeadingNumeric, function (_all, match) {
440
+ return "_" + match;
441
+ });
509
442
  }
510
- return result;
443
+ return value;
511
444
  }
512
445
  function objForEachKey(target, callbackfn) {
513
446
  if (target) {
@@ -566,6 +499,22 @@
566
499
  function isBoolean(value) {
567
500
  return typeof value === "boolean";
568
501
  }
502
+ function isPlainObject(value) {
503
+ var result = false;
504
+ if (value && typeof value === "object") {
505
+ var proto = _objGetPrototypeOf ? _objGetPrototypeOf(value) : _getObjProto(value);
506
+ if (!proto) {
507
+ result = true;
508
+ }
509
+ else {
510
+ if (proto[strConstructor] && ObjHasOwnProperty.call(proto, strConstructor)) {
511
+ proto = proto[strConstructor];
512
+ }
513
+ result = typeof proto === strShimFunction && _fnToString.call(proto) === _objFunctionString;
514
+ }
515
+ }
516
+ return result;
517
+ }
569
518
  function toISOString(date) {
570
519
  if (date) {
571
520
  return _dataToISOString ? date[strToISOString]() : _toISOStringPoly(date);
@@ -711,7 +660,7 @@
711
660
  return result;
712
661
  }
713
662
  function objDefineAccessors(target, prop, getProp, setProp) {
714
- if (_objDefineProperty) {
663
+ if (_objDefineProperty$1) {
715
664
  try {
716
665
  var descriptor = {
717
666
  enumerable: true,
@@ -723,7 +672,7 @@
723
672
  if (setProp) {
724
673
  descriptor.set = setProp;
725
674
  }
726
- _objDefineProperty(target, prop, descriptor);
675
+ _objDefineProperty$1(target, prop, descriptor);
727
676
  return true;
728
677
  }
729
678
  catch (e) {
@@ -731,6 +680,10 @@
731
680
  }
732
681
  return false;
733
682
  }
683
+ function _doNothing(value) {
684
+ return value;
685
+ }
686
+ var objFreeze = _objFreeze || _doNothing;
734
687
  function dateNow() {
735
688
  var dt = Date;
736
689
  return dt.now ? dt.now() : new dt().getTime();
@@ -739,7 +692,7 @@
739
692
  if (isError(object)) {
740
693
  return object.name;
741
694
  }
742
- return "";
695
+ return strEmpty;
743
696
  }
744
697
  function setValue(target, field, value, valChk, srcChk) {
745
698
  var theValue = value;
@@ -755,6 +708,86 @@
755
708
  function isTruthy(value) {
756
709
  return !!value;
757
710
  }
711
+ function _createProxyFunction(source, funcName) {
712
+ var srcFunc = null;
713
+ var src = null;
714
+ if (isFunction(source)) {
715
+ srcFunc = source;
716
+ }
717
+ else {
718
+ src = source;
719
+ }
720
+ return function () {
721
+ var originalArguments = arguments;
722
+ if (srcFunc) {
723
+ src = srcFunc();
724
+ }
725
+ if (src) {
726
+ return src[funcName].apply(src, originalArguments);
727
+ }
728
+ };
729
+ }
730
+ function proxyFunctionAs(target, name, source, theFunc, overwriteTarget) {
731
+ if (target && name && source) {
732
+ if (overwriteTarget !== false || isUndefined(target[name])) {
733
+ target[name] = _createProxyFunction(source, theFunc);
734
+ }
735
+ }
736
+ }
737
+ function proxyFunctions(target, source, functionsToProxy, overwriteTarget) {
738
+ if (target && source && isObject(target) && isArray(functionsToProxy)) {
739
+ arrForEach(functionsToProxy, function (theFuncName) {
740
+ if (isString(theFuncName)) {
741
+ proxyFunctionAs(target, theFuncName, source, theFuncName, overwriteTarget);
742
+ }
743
+ });
744
+ }
745
+ return target;
746
+ }
747
+ function objExtend(obj1, obj2, obj3, obj4, obj5, obj6) {
748
+ var theArgs = arguments;
749
+ var extended = theArgs[0] || {};
750
+ var argLen = theArgs.length;
751
+ var deep = false;
752
+ var idx = 1;
753
+ if (argLen > 0 && isBoolean(extended)) {
754
+ deep = extended;
755
+ extended = theArgs[idx] || {};
756
+ idx++;
757
+ }
758
+ if (!isObject(extended)) {
759
+ extended = {};
760
+ }
761
+ for (; idx < argLen; idx++) {
762
+ var arg = theArgs[idx];
763
+ var isArgArray = isArray(arg);
764
+ var isArgObj = isObject(arg);
765
+ for (var prop in arg) {
766
+ var propOk = (isArgArray && (prop in arg)) || (isArgObj && (ObjHasOwnProperty.call(arg, prop)));
767
+ if (!propOk) {
768
+ continue;
769
+ }
770
+ var newValue = arg[prop];
771
+ var isNewArray = void 0;
772
+ if (deep && newValue && ((isNewArray = isArray(newValue)) || isPlainObject(newValue))) {
773
+ var clone = extended[prop];
774
+ if (isNewArray) {
775
+ if (!isArray(clone)) {
776
+ clone = [];
777
+ }
778
+ }
779
+ else if (!isPlainObject(clone)) {
780
+ clone = {};
781
+ }
782
+ newValue = objExtend(deep, clone, newValue);
783
+ }
784
+ if (newValue !== undefined) {
785
+ extended[prop] = newValue;
786
+ }
787
+ }
788
+ }
789
+ return extended;
790
+ }
758
791
 
759
792
  var strWindow = "window";
760
793
  var strDocument = "document";
@@ -847,14 +880,14 @@
847
880
  var nav = getNavigator();
848
881
  if (nav && (nav.userAgent !== _navUserAgentCheck || _isTrident === null)) {
849
882
  _navUserAgentCheck = nav.userAgent;
850
- var userAgent = (_navUserAgentCheck || "").toLowerCase();
883
+ var userAgent = (_navUserAgentCheck || strEmpty).toLowerCase();
851
884
  _isTrident = (strContains(userAgent, strMsie) || strContains(userAgent, strTrident));
852
885
  }
853
886
  return _isTrident;
854
887
  }
855
888
  function dumpObj(object) {
856
889
  var objectTypeDump = Object[strShimPrototype].toString.call(object);
857
- var propertyValueDump = "";
890
+ var propertyValueDump = strEmpty;
858
891
  if (objectTypeDump === "[object Error]") {
859
892
  propertyValueDump = "{ stack: '" + object.stack + "', message: '" + object.message + "', name: '" + object.name + "'";
860
893
  }
@@ -887,9 +920,9 @@
887
920
  var strWarnToConsole = "warnToConsole";
888
921
  function _sanitizeDiagnosticText(text) {
889
922
  if (text) {
890
- return "\"" + text.replace(/\"/g, "") + "\"";
923
+ return "\"" + text.replace(/\"/g, strEmpty) + "\"";
891
924
  }
892
- return "";
925
+ return strEmpty;
893
926
  }
894
927
  function _logToConsole(func, message) {
895
928
  var theConsole = getConsole();
@@ -911,12 +944,12 @@
911
944
  _self.message =
912
945
  (isUserAct ? AiUserActionablePrefix : AiNonUserActionablePrefix) +
913
946
  msgId;
914
- var strProps = "";
947
+ var strProps = strEmpty;
915
948
  if (hasJSON()) {
916
949
  strProps = getJSON().stringify(properties);
917
950
  }
918
- var diagnosticText = (msg ? " message:" + _sanitizeDiagnosticText(msg) : "") +
919
- (properties ? " props:" + _sanitizeDiagnosticText(strProps) : "");
951
+ var diagnosticText = (msg ? " message:" + _sanitizeDiagnosticText(msg) : strEmpty) +
952
+ (properties ? " props:" + _sanitizeDiagnosticText(strProps) : strEmpty);
920
953
  _self.message += diagnosticText;
921
954
  }
922
955
  _InternalLogMessage.dataType = "MessageData";
@@ -946,7 +979,7 @@
946
979
  throw message;
947
980
  }
948
981
  else {
949
- var logFunc = severity === LoggingSeverity.CRITICAL ? strErrorToConsole : strWarnToConsole;
982
+ var logFunc = severity === 1 ? strErrorToConsole : strWarnToConsole;
950
983
  if (!isUndefined(message.message)) {
951
984
  var logLevel = _self.consoleLoggingLevel();
952
985
  if (isUserAct) {
@@ -964,7 +997,7 @@
964
997
  _self.logInternalMessage(severity, message);
965
998
  }
966
999
  else {
967
- _debugExtMsg("throw" + (severity === LoggingSeverity.CRITICAL ? "Critical" : "Warning"), message);
1000
+ _debugExtMsg("throw" + (severity === 1 ? "Critical" : "Warning"), message);
968
1001
  }
969
1002
  }
970
1003
  };
@@ -996,13 +1029,13 @@
996
1029
  if (severity <= _self.telemetryLoggingLevel()) {
997
1030
  _self.queue.push(message);
998
1031
  _messageCount++;
999
- _debugExtMsg((severity === LoggingSeverity.CRITICAL ? "error" : "warn"), message);
1032
+ _debugExtMsg((severity === 1 ? "error" : "warn"), message);
1000
1033
  }
1001
1034
  if (_messageCount === _self.maxInternalMessageLimit()) {
1002
1035
  var throttleLimitMessage = "Internal events throttle limit per PageView reached for this app.";
1003
- var throttleMessage = new _InternalLogMessage(_InternalMessageId.MessageLimitPerPVExceeded, throttleLimitMessage, false);
1036
+ var throttleMessage = new _InternalLogMessage(23 , throttleLimitMessage, false);
1004
1037
  _self.queue.push(throttleMessage);
1005
- if (severity === LoggingSeverity.CRITICAL) {
1038
+ if (severity === 1 ) {
1006
1039
  _self.errorToConsole(throttleLimitMessage);
1007
1040
  }
1008
1041
  else {
@@ -1031,6 +1064,10 @@
1031
1064
  }
1032
1065
  return DiagnosticLogger;
1033
1066
  }());
1067
+ function _throwInternal(logger, severity, msgId, msg, properties, isUserAct) {
1068
+ if (isUserAct === void 0) { isUserAct = false; }
1069
+ (logger || new DiagnosticLogger()).throwInternal(severity, msgId, msg, properties, isUserAct);
1070
+ }
1034
1071
 
1035
1072
  var strExecutionContextKey = "ctx";
1036
1073
  var PerfEvent = /** @class */ (function () {
@@ -1144,252 +1181,509 @@
1144
1181
  return func();
1145
1182
  }
1146
1183
 
1147
- var TelemetryPluginChain = /** @class */ (function () {
1148
- function TelemetryPluginChain(plugin, defItemCtx) {
1149
- var _self = this;
1150
- var _nextProxy = null;
1151
- var _hasProcessTelemetry = isFunction(plugin.processTelemetry);
1152
- var _hasSetNext = isFunction(plugin.setNextPlugin);
1153
- _self._hasRun = false;
1154
- _self.getPlugin = function () {
1155
- return plugin;
1156
- };
1157
- _self.getNext = function () {
1158
- return _nextProxy;
1159
- };
1160
- _self.setNext = function (nextPlugin) {
1161
- _nextProxy = nextPlugin;
1162
- };
1163
- _self.processTelemetry = function (env, itemCtx) {
1164
- if (!itemCtx) {
1165
- itemCtx = defItemCtx;
1184
+ var UInt32Mask = 0x100000000;
1185
+ var MaxUInt32 = 0xffffffff;
1186
+ var _mwcSeeded = false;
1187
+ var _mwcW = 123456789;
1188
+ var _mwcZ = 987654321;
1189
+ function _mwcSeed(seedValue) {
1190
+ if (seedValue < 0) {
1191
+ seedValue >>>= 0;
1192
+ }
1193
+ _mwcW = (123456789 + seedValue) & MaxUInt32;
1194
+ _mwcZ = (987654321 - seedValue) & MaxUInt32;
1195
+ _mwcSeeded = true;
1196
+ }
1197
+ function _autoSeedMwc() {
1198
+ try {
1199
+ var now = dateNow() & 0x7fffffff;
1200
+ _mwcSeed(((Math.random() * UInt32Mask) ^ now) + now);
1201
+ }
1202
+ catch (e) {
1203
+ }
1204
+ }
1205
+ function randomValue(maxValue) {
1206
+ if (maxValue > 0) {
1207
+ return Math.floor((random32() / MaxUInt32) * (maxValue + 1)) >>> 0;
1208
+ }
1209
+ return 0;
1210
+ }
1211
+ function random32(signed) {
1212
+ var value = 0;
1213
+ var c = getCrypto() || getMsCrypto();
1214
+ if (c && c.getRandomValues) {
1215
+ value = c.getRandomValues(new Uint32Array(1))[0] & MaxUInt32;
1216
+ }
1217
+ if (value === 0 && isIE()) {
1218
+ if (!_mwcSeeded) {
1219
+ _autoSeedMwc();
1220
+ }
1221
+ value = mwcRandom32() & MaxUInt32;
1222
+ }
1223
+ if (value === 0) {
1224
+ value = Math.floor((UInt32Mask * Math.random()) | 0);
1225
+ }
1226
+ if (!signed) {
1227
+ value >>>= 0;
1228
+ }
1229
+ return value;
1230
+ }
1231
+ function mwcRandomSeed(value) {
1232
+ if (!value) {
1233
+ _autoSeedMwc();
1234
+ }
1235
+ else {
1236
+ _mwcSeed(value);
1237
+ }
1238
+ }
1239
+ function mwcRandom32(signed) {
1240
+ _mwcZ = (36969 * (_mwcZ & 0xFFFF) + (_mwcZ >> 16)) & MaxUInt32;
1241
+ _mwcW = (18000 * (_mwcW & 0xFFFF) + (_mwcW >> 16)) & MaxUInt32;
1242
+ var value = (((_mwcZ << 16) + (_mwcW & 0xFFFF)) >>> 0) & MaxUInt32 | 0;
1243
+ if (!signed) {
1244
+ value >>>= 0;
1245
+ }
1246
+ return value;
1247
+ }
1248
+ function newId(maxLength) {
1249
+ if (maxLength === void 0) { maxLength = 22; }
1250
+ var base64chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
1251
+ var number = random32() >>> 0;
1252
+ var chars = 0;
1253
+ var result = strEmpty;
1254
+ while (result.length < maxLength) {
1255
+ chars++;
1256
+ result += base64chars.charAt(number & 0x3F);
1257
+ number >>>= 6;
1258
+ if (chars === 5) {
1259
+ number = (((random32() << 2) & 0xFFFFFFFF) | (number & 0x03)) >>> 0;
1260
+ chars = 0;
1261
+ }
1262
+ }
1263
+ return result;
1264
+ }
1265
+
1266
+ var _objDefineProperty = ObjDefineProperty;
1267
+ var version = "2.8.0-nightly.2204-06";
1268
+ var instanceName = "." + newId(6);
1269
+ var _dataUid = 0;
1270
+ function _createAccessor(target, prop, value) {
1271
+ if (_objDefineProperty) {
1272
+ try {
1273
+ _objDefineProperty(target, prop, {
1274
+ value: value,
1275
+ enumerable: false,
1276
+ configurable: true
1277
+ });
1278
+ return true;
1279
+ }
1280
+ catch (e) {
1281
+ }
1282
+ }
1283
+ return false;
1284
+ }
1285
+ function _canAcceptData(target) {
1286
+ return target.nodeType === 1 || target.nodeType === 9 || !(+target.nodeType);
1287
+ }
1288
+ function _getCache(data, target) {
1289
+ var theCache = target[data.id];
1290
+ if (!theCache) {
1291
+ theCache = {};
1292
+ try {
1293
+ if (_canAcceptData(target)) {
1294
+ if (!_createAccessor(target, data.id, theCache)) {
1295
+ target[data.id] = theCache;
1296
+ }
1297
+ }
1298
+ }
1299
+ catch (e) {
1300
+ }
1301
+ }
1302
+ return theCache;
1303
+ }
1304
+ function createUniqueNamespace(name, includeVersion) {
1305
+ if (includeVersion === void 0) { includeVersion = false; }
1306
+ return normalizeJsName(name + (_dataUid++) + (includeVersion ? "." + version : "") + instanceName);
1307
+ }
1308
+ function createElmNodeData(name) {
1309
+ var data = {
1310
+ id: createUniqueNamespace("_aiData-" + (name || "") + "." + version),
1311
+ accept: function (target) {
1312
+ return _canAcceptData(target);
1313
+ },
1314
+ get: function (target, name, defValue, addDefault) {
1315
+ var theCache = target[data.id];
1316
+ if (!theCache) {
1317
+ if (addDefault) {
1318
+ theCache = _getCache(data, target);
1319
+ theCache[normalizeJsName(name)] = defValue;
1320
+ }
1321
+ return defValue;
1322
+ }
1323
+ return theCache[normalizeJsName(name)];
1324
+ },
1325
+ kill: function (target, name) {
1326
+ if (target && target[name]) {
1327
+ try {
1328
+ delete target[name];
1329
+ }
1330
+ catch (e) {
1331
+ }
1166
1332
  }
1167
- var identifier = plugin ? plugin.identifier : "TelemetryPluginChain";
1168
- doPerf(itemCtx ? itemCtx.core() : null, function () { return identifier + ":processTelemetry"; }, function () {
1169
- if (plugin && _hasProcessTelemetry) {
1170
- _self._hasRun = true;
1333
+ }
1334
+ };
1335
+ return data;
1336
+ }
1337
+
1338
+ var pluginStateData = createElmNodeData("plugin");
1339
+ function _getPluginState(plugin) {
1340
+ return pluginStateData.get(plugin, "state", {}, true);
1341
+ }
1342
+
1343
+ var strTelemetryPluginChain = "TelemetryPluginChain";
1344
+ var strHasRunFlags = "_hasRun";
1345
+ var strGetTelCtx = "_getTelCtx";
1346
+ var _chainId = 0;
1347
+ function _getNextProxyStart(proxy, config, core, startAt) {
1348
+ while (proxy) {
1349
+ if (proxy.getPlugin() === startAt) {
1350
+ return proxy;
1351
+ }
1352
+ proxy = proxy.getNext();
1353
+ }
1354
+ return createTelemetryProxyChain([startAt], config, core);
1355
+ }
1356
+ function _createInternalContext(telemetryChain, config, core, startAt) {
1357
+ var _nextProxy = null;
1358
+ var _onComplete = [];
1359
+ if (startAt !== null) {
1360
+ _nextProxy = startAt ? _getNextProxyStart(telemetryChain, config, core, startAt) : telemetryChain;
1361
+ }
1362
+ var context = {
1363
+ _next: _moveNext,
1364
+ ctx: {
1365
+ core: function () {
1366
+ return core;
1367
+ },
1368
+ diagLog: function () {
1369
+ return safeGetLogger(core, config);
1370
+ },
1371
+ getCfg: function () {
1372
+ return config;
1373
+ },
1374
+ getExtCfg: _getExtCfg,
1375
+ getConfig: _getConfig,
1376
+ hasNext: function () {
1377
+ return !!_nextProxy;
1378
+ },
1379
+ getNext: function () {
1380
+ return _nextProxy;
1381
+ },
1382
+ setNext: function (nextPlugin) {
1383
+ _nextProxy = nextPlugin;
1384
+ },
1385
+ iterate: _iterateChain,
1386
+ onComplete: _addOnComplete
1387
+ }
1388
+ };
1389
+ function _addOnComplete(onComplete, that) {
1390
+ var args = [];
1391
+ for (var _i = 2; _i < arguments.length; _i++) {
1392
+ args[_i - 2] = arguments[_i];
1393
+ }
1394
+ if (onComplete) {
1395
+ _onComplete.push({
1396
+ func: onComplete,
1397
+ self: !isUndefined(that) ? that : context.ctx,
1398
+ args: args
1399
+ });
1400
+ }
1401
+ }
1402
+ function _moveNext() {
1403
+ var nextProxy = _nextProxy;
1404
+ _nextProxy = nextProxy ? nextProxy.getNext() : null;
1405
+ if (!nextProxy) {
1406
+ var onComplete = _onComplete;
1407
+ if (onComplete && onComplete.length > 0) {
1408
+ arrForEach(onComplete, function (completeDetails) {
1171
1409
  try {
1172
- itemCtx.setNext(_nextProxy);
1173
- if (_hasSetNext) {
1174
- plugin.setNextPlugin(_nextProxy);
1175
- }
1176
- _nextProxy && (_nextProxy._hasRun = false);
1177
- plugin.processTelemetry(env, itemCtx);
1410
+ completeDetails.func.call(completeDetails.self, completeDetails.args);
1178
1411
  }
1179
- catch (error) {
1180
- var hasRun = _nextProxy && _nextProxy._hasRun;
1181
- if (!_nextProxy || !hasRun) {
1182
- itemCtx.diagLog().throwInternal(LoggingSeverity.CRITICAL, _InternalMessageId.PluginException, "Plugin [" + plugin.identifier + "] failed during processTelemetry - " + dumpObj(error));
1183
- }
1184
- if (_nextProxy && !hasRun) {
1185
- _nextProxy.processTelemetry(env, itemCtx);
1186
- }
1412
+ catch (e) {
1413
+ _throwInternal(core.logger, 2 , 73 , "Unexpected Exception during onComplete - " + dumpObj(e));
1187
1414
  }
1188
- }
1189
- else if (_nextProxy) {
1190
- _self._hasRun = true;
1191
- _nextProxy.processTelemetry(env, itemCtx);
1192
- }
1193
- }, function () { return ({ item: env }); }, !(env.sync));
1194
- };
1415
+ });
1416
+ _onComplete = [];
1417
+ }
1418
+ }
1419
+ return nextProxy;
1195
1420
  }
1196
- return TelemetryPluginChain;
1197
- }());
1198
-
1199
- function _createProxyChain(plugins, itemCtx) {
1200
- var proxies = [];
1201
- if (plugins && plugins.length > 0) {
1202
- var lastProxy = null;
1203
- for (var idx = 0; idx < plugins.length; idx++) {
1204
- var thePlugin = plugins[idx];
1205
- if (thePlugin && isFunction(thePlugin.processTelemetry)) {
1206
- var newProxy = new TelemetryPluginChain(thePlugin, itemCtx);
1207
- proxies.push(newProxy);
1208
- if (lastProxy) {
1209
- lastProxy.setNext(newProxy);
1421
+ function _getExtCfg(identifier, defaultValue, mergeDefault) {
1422
+ if (defaultValue === void 0) { defaultValue = {}; }
1423
+ if (mergeDefault === void 0) { mergeDefault = 0 ; }
1424
+ var theConfig;
1425
+ if (config) {
1426
+ var extConfig = config.extensionConfig;
1427
+ if (extConfig && identifier) {
1428
+ theConfig = extConfig[identifier];
1429
+ }
1430
+ }
1431
+ if (!theConfig) {
1432
+ theConfig = defaultValue;
1433
+ }
1434
+ else if (isObject(defaultValue)) {
1435
+ if (mergeDefault !== 0 ) {
1436
+ var newConfig_1 = objExtend(true, defaultValue, theConfig);
1437
+ if (config && mergeDefault === 2 ) {
1438
+ objForEachKey(defaultValue, function (field) {
1439
+ if (isNullOrUndefined(newConfig_1[field])) {
1440
+ var cfgValue = config[field];
1441
+ if (!isNullOrUndefined(cfgValue)) {
1442
+ newConfig_1[field] = cfgValue;
1443
+ }
1444
+ }
1445
+ });
1210
1446
  }
1211
- lastProxy = newProxy;
1212
1447
  }
1213
1448
  }
1449
+ return theConfig;
1214
1450
  }
1215
- return proxies.length > 0 ? proxies[0] : null;
1216
- }
1217
- function _copyProxyChain(proxy, itemCtx, startAt) {
1218
- var plugins = [];
1219
- var add = startAt ? false : true;
1220
- if (proxy) {
1221
- while (proxy) {
1222
- var thePlugin = proxy.getPlugin();
1223
- if (add || thePlugin === startAt) {
1224
- add = true;
1225
- plugins.push(thePlugin);
1451
+ function _getConfig(identifier, field, defaultValue) {
1452
+ if (defaultValue === void 0) { defaultValue = false; }
1453
+ var theValue;
1454
+ var extConfig = _getExtCfg(identifier, null);
1455
+ if (extConfig && !isNullOrUndefined(extConfig[field])) {
1456
+ theValue = extConfig[field];
1457
+ }
1458
+ else if (config && !isNullOrUndefined(config[field])) {
1459
+ theValue = config[field];
1460
+ }
1461
+ return !isNullOrUndefined(theValue) ? theValue : defaultValue;
1462
+ }
1463
+ function _iterateChain(cb) {
1464
+ var nextPlugin;
1465
+ while (!!(nextPlugin = context._next())) {
1466
+ var plugin = nextPlugin.getPlugin();
1467
+ if (plugin) {
1468
+ cb(plugin);
1226
1469
  }
1227
- proxy = proxy.getNext();
1228
1470
  }
1229
1471
  }
1230
- if (!add) {
1231
- plugins.push(startAt);
1472
+ return context;
1473
+ }
1474
+ function createProcessTelemetryContext(telemetryChain, config, core, startAt) {
1475
+ var internalContext = _createInternalContext(telemetryChain, config, core, startAt);
1476
+ var context = internalContext.ctx;
1477
+ function _processNext(env) {
1478
+ var nextPlugin = internalContext._next();
1479
+ nextPlugin && nextPlugin.processTelemetry(env, context);
1480
+ return !nextPlugin;
1481
+ }
1482
+ function _createNew(plugins, startAt) {
1483
+ if (plugins === void 0) { plugins = null; }
1484
+ if (isArray(plugins)) {
1485
+ plugins = createTelemetryProxyChain(plugins, config, core, startAt);
1486
+ }
1487
+ return createProcessTelemetryContext(plugins || context.getNext(), config, core, startAt);
1232
1488
  }
1233
- return _createProxyChain(plugins, itemCtx);
1489
+ context.processNext = _processNext;
1490
+ context.createNew = _createNew;
1491
+ return context;
1234
1492
  }
1235
- function _copyPluginChain(srcPlugins, itemCtx, startAt) {
1236
- var plugins = srcPlugins;
1237
- var add = false;
1238
- if (startAt && srcPlugins) {
1239
- plugins = [];
1240
- arrForEach(srcPlugins, function (thePlugin) {
1241
- if (add || thePlugin === startAt) {
1242
- add = true;
1243
- plugins.push(thePlugin);
1493
+ function createProcessTelemetryUnloadContext(telemetryChain, config, core, startAt) {
1494
+ var internalContext = _createInternalContext(telemetryChain, config, core, startAt);
1495
+ var context = internalContext.ctx;
1496
+ function _processNext(unloadState) {
1497
+ var nextPlugin = internalContext._next();
1498
+ nextPlugin && nextPlugin.unload(context, unloadState);
1499
+ return !nextPlugin;
1500
+ }
1501
+ function _createNew(plugins, startAt) {
1502
+ if (plugins === void 0) { plugins = null; }
1503
+ if (isArray(plugins)) {
1504
+ plugins = createTelemetryProxyChain(plugins, config, core, startAt);
1505
+ }
1506
+ return createProcessTelemetryUnloadContext(plugins || context.getNext(), config, core, startAt);
1507
+ }
1508
+ context.processNext = _processNext;
1509
+ context.createNew = _createNew;
1510
+ return context;
1511
+ }
1512
+ function createProcessTelemetryUpdateContext(telemetryChain, config, core, startAt) {
1513
+ var internalContext = _createInternalContext(telemetryChain, config, core, startAt);
1514
+ var context = internalContext.ctx;
1515
+ function _processNext(updateState) {
1516
+ return context.iterate(function (plugin) {
1517
+ if (isFunction(plugin[strUpdate])) {
1518
+ plugin[strUpdate](context, updateState);
1244
1519
  }
1245
1520
  });
1246
1521
  }
1247
- if (startAt && !add) {
1248
- if (!plugins) {
1249
- plugins = [];
1522
+ function _createNew(plugins, startAt) {
1523
+ if (plugins === void 0) { plugins = null; }
1524
+ if (isArray(plugins)) {
1525
+ plugins = createTelemetryProxyChain(plugins, config, core, startAt);
1250
1526
  }
1251
- plugins.push(startAt);
1527
+ return createProcessTelemetryUpdateContext(plugins || context.getNext(), config, core, startAt);
1252
1528
  }
1253
- return _createProxyChain(plugins, itemCtx);
1529
+ context.processNext = _processNext;
1530
+ context.createNew = _createNew;
1531
+ return context;
1254
1532
  }
1255
- var ProcessTelemetryContext = /** @class */ (function () {
1256
- function ProcessTelemetryContext(plugins, config, core, startAt) {
1257
- var _self = this;
1258
- var _nextProxy = null;
1259
- if (startAt !== null) {
1260
- if (plugins && isFunction(plugins.getPlugin)) {
1261
- _nextProxy = _copyProxyChain(plugins, _self, startAt || plugins.getPlugin());
1262
- }
1263
- else {
1264
- if (startAt) {
1265
- _nextProxy = _copyPluginChain(plugins, _self, startAt);
1533
+ function createTelemetryProxyChain(plugins, config, core, startAt) {
1534
+ var firstProxy = null;
1535
+ var add = startAt ? false : true;
1536
+ if (isArray(plugins) && plugins.length > 0) {
1537
+ var lastProxy_1 = null;
1538
+ arrForEach(plugins, function (thePlugin) {
1539
+ if (!add && startAt === thePlugin) {
1540
+ add = true;
1541
+ }
1542
+ if (add && thePlugin && isFunction(thePlugin.processTelemetry)) {
1543
+ var newProxy = createTelemetryPluginProxy(thePlugin, config, core);
1544
+ if (!firstProxy) {
1545
+ firstProxy = newProxy;
1266
1546
  }
1267
- else if (isUndefined(startAt)) {
1268
- _nextProxy = _createProxyChain(plugins, _self);
1547
+ if (lastProxy_1) {
1548
+ lastProxy_1._setNext(newProxy);
1269
1549
  }
1550
+ lastProxy_1 = newProxy;
1270
1551
  }
1552
+ });
1553
+ }
1554
+ if (startAt && !firstProxy) {
1555
+ return createTelemetryProxyChain([startAt], config, core);
1556
+ }
1557
+ return firstProxy;
1558
+ }
1559
+ function createTelemetryPluginProxy(plugin, config, core) {
1560
+ var nextProxy = null;
1561
+ var hasProcessTelemetry = isFunction(plugin.processTelemetry);
1562
+ var hasSetNext = isFunction(plugin.setNextPlugin);
1563
+ var chainId;
1564
+ if (plugin) {
1565
+ chainId = plugin.identifier + "-" + plugin.priority + "-" + _chainId++;
1566
+ }
1567
+ else {
1568
+ chainId = "Unknown-0-" + _chainId++;
1569
+ }
1570
+ var proxyChain = {
1571
+ getPlugin: function () {
1572
+ return plugin;
1573
+ },
1574
+ getNext: function () {
1575
+ return nextProxy;
1576
+ },
1577
+ processTelemetry: _processTelemetry,
1578
+ unload: _unloadPlugin,
1579
+ update: _updatePlugin,
1580
+ _id: chainId,
1581
+ _setNext: function (nextPlugin) {
1582
+ nextProxy = nextPlugin;
1271
1583
  }
1272
- _self.core = function () {
1273
- return core;
1274
- };
1275
- _self.diagLog = function () {
1276
- return safeGetLogger(core, config);
1277
- };
1278
- _self.getCfg = function () {
1279
- return config;
1280
- };
1281
- _self.getExtCfg = function (identifier, defaultValue) {
1282
- if (defaultValue === void 0) { defaultValue = {}; }
1283
- var theConfig;
1284
- if (config) {
1285
- var extConfig = config.extensionConfig;
1286
- if (extConfig && identifier) {
1287
- theConfig = extConfig[identifier];
1584
+ };
1585
+ function _getTelCtx() {
1586
+ var itemCtx;
1587
+ if (plugin && isFunction(plugin[strGetTelCtx])) {
1588
+ itemCtx = plugin[strGetTelCtx]();
1589
+ }
1590
+ if (!itemCtx) {
1591
+ itemCtx = createProcessTelemetryContext(proxyChain, config, core);
1592
+ }
1593
+ return itemCtx;
1594
+ }
1595
+ function _processChain(itemCtx, processPluginFn, name, details, isAsync) {
1596
+ var hasRun = false;
1597
+ var identifier = plugin ? plugin.identifier : strTelemetryPluginChain;
1598
+ var hasRunContext = itemCtx[strHasRunFlags];
1599
+ if (!hasRunContext) {
1600
+ hasRunContext = itemCtx[strHasRunFlags] = {};
1601
+ }
1602
+ itemCtx.setNext(nextProxy);
1603
+ if (plugin) {
1604
+ doPerf(itemCtx[strCore](), function () { return identifier + ":" + name; }, function () {
1605
+ hasRunContext[chainId] = true;
1606
+ try {
1607
+ var nextId = nextProxy ? nextProxy._id : strEmpty;
1608
+ if (nextId) {
1609
+ hasRunContext[nextId] = false;
1610
+ }
1611
+ hasRun = processPluginFn(itemCtx);
1288
1612
  }
1613
+ catch (error) {
1614
+ var hasNextRun = nextProxy ? hasRunContext[nextProxy._id] : true;
1615
+ if (hasNextRun) {
1616
+ hasRun = true;
1617
+ }
1618
+ if (!nextProxy || !hasNextRun) {
1619
+ _throwInternal(itemCtx.diagLog(), 1 , 73 , "Plugin [" + plugin.identifier + "] failed during " + name + " - " + dumpObj(error) + ", run flags: " + dumpObj(hasRunContext));
1620
+ }
1621
+ }
1622
+ }, details, isAsync);
1623
+ }
1624
+ return hasRun;
1625
+ }
1626
+ function _processTelemetry(env, itemCtx) {
1627
+ itemCtx = itemCtx || _getTelCtx();
1628
+ function _callProcessTelemetry(itemCtx) {
1629
+ if (!plugin || !hasProcessTelemetry) {
1630
+ return false;
1289
1631
  }
1290
- return (theConfig ? theConfig : defaultValue);
1291
- };
1292
- _self.getConfig = function (identifier, field, defaultValue) {
1293
- if (defaultValue === void 0) { defaultValue = false; }
1294
- var theValue;
1295
- var extConfig = _self.getExtCfg(identifier, null);
1296
- if (extConfig && !isNullOrUndefined(extConfig[field])) {
1297
- theValue = extConfig[field];
1632
+ var pluginState = _getPluginState(plugin);
1633
+ if (pluginState[strTeardown] || pluginState[strDisabled]) {
1634
+ return false;
1298
1635
  }
1299
- else if (config && !isNullOrUndefined(config[field])) {
1300
- theValue = config[field];
1636
+ if (hasSetNext) {
1637
+ plugin.setNextPlugin(nextProxy);
1301
1638
  }
1302
- return !isNullOrUndefined(theValue) ? theValue : defaultValue;
1303
- };
1304
- _self.hasNext = function () {
1305
- return _nextProxy != null;
1306
- };
1307
- _self.getNext = function () {
1308
- return _nextProxy;
1309
- };
1310
- _self.setNext = function (nextPlugin) {
1311
- _nextProxy = nextPlugin;
1312
- };
1313
- _self.processNext = function (env) {
1314
- var nextPlugin = _nextProxy;
1315
- if (nextPlugin) {
1316
- _nextProxy = nextPlugin.getNext();
1317
- nextPlugin.processTelemetry(env, _self);
1639
+ plugin.processTelemetry(env, itemCtx);
1640
+ return true;
1641
+ }
1642
+ if (!_processChain(itemCtx, _callProcessTelemetry, "processTelemetry", function () { return ({ item: env }); }, !(env.sync))) {
1643
+ itemCtx.processNext(env);
1644
+ }
1645
+ }
1646
+ function _unloadPlugin(unloadCtx, unloadState) {
1647
+ function _callTeardown() {
1648
+ var hasRun = false;
1649
+ if (plugin) {
1650
+ var pluginState = _getPluginState(plugin);
1651
+ var pluginCore = plugin[strCore] || pluginState.core;
1652
+ if (plugin && (!pluginCore || pluginCore === unloadCtx[strCore]()) && !pluginState[strTeardown]) {
1653
+ pluginState[strCore] = null;
1654
+ pluginState[strTeardown] = true;
1655
+ pluginState[strIsInitialized] = false;
1656
+ if (plugin[strTeardown] && plugin[strTeardown](unloadCtx, unloadState) === true) {
1657
+ hasRun = true;
1658
+ }
1659
+ }
1318
1660
  }
1319
- };
1320
- _self.createNew = function (plugins, startAt) {
1321
- if (plugins === void 0) { plugins = null; }
1322
- return new ProcessTelemetryContext(plugins || _nextProxy, config, core, startAt);
1323
- };
1661
+ return hasRun;
1662
+ }
1663
+ if (!_processChain(unloadCtx, _callTeardown, "unload", function () { }, unloadState.isAsync)) {
1664
+ unloadCtx.processNext(unloadState);
1665
+ }
1324
1666
  }
1325
- return ProcessTelemetryContext;
1326
- }());
1327
-
1328
- var strExtensionConfig = "extensionConfig";
1329
-
1330
- var strGetPlugin = "getPlugin";
1331
- var BaseTelemetryPlugin = /** @class */ (function () {
1332
- function BaseTelemetryPlugin() {
1333
- var _self = this;
1334
- var _isinitialized = false;
1335
- var _rootCtx = null;
1336
- var _nextPlugin = null;
1337
- _self.core = null;
1338
- _self.diagLog = function (itemCtx) {
1339
- return _self._getTelCtx(itemCtx).diagLog();
1340
- };
1341
- _self.isInitialized = function () {
1342
- return _isinitialized;
1343
- };
1344
- _self.setInitialized = function (isInitialized) {
1345
- _isinitialized = isInitialized;
1346
- };
1347
- _self.setNextPlugin = function (next) {
1348
- _nextPlugin = next;
1349
- };
1350
- _self.processNext = function (env, itemCtx) {
1351
- if (itemCtx) {
1352
- itemCtx.processNext(env);
1353
- }
1354
- else if (_nextPlugin && isFunction(_nextPlugin.processTelemetry)) {
1355
- _nextPlugin.processTelemetry(env, null);
1356
- }
1357
- };
1358
- _self._getTelCtx = function (currentCtx) {
1359
- if (currentCtx === void 0) { currentCtx = null; }
1360
- var itemCtx = currentCtx;
1361
- if (!itemCtx) {
1362
- var rootCtx = _rootCtx || new ProcessTelemetryContext(null, {}, _self.core);
1363
- if (_nextPlugin && _nextPlugin[strGetPlugin]) {
1364
- itemCtx = rootCtx.createNew(null, _nextPlugin[strGetPlugin]);
1365
- }
1366
- else {
1367
- itemCtx = rootCtx.createNew(null, _nextPlugin);
1667
+ function _updatePlugin(updateCtx, updateState) {
1668
+ function _callUpdate() {
1669
+ var hasRun = false;
1670
+ if (plugin) {
1671
+ var pluginState = _getPluginState(plugin);
1672
+ var pluginCore = plugin[strCore] || pluginState.core;
1673
+ if (plugin && (!pluginCore || pluginCore === updateCtx[strCore]()) && !pluginState[strTeardown]) {
1674
+ if (plugin[strUpdate] && plugin[strUpdate](updateCtx, updateState) === true) {
1675
+ hasRun = true;
1676
+ }
1368
1677
  }
1369
1678
  }
1370
- return itemCtx;
1371
- };
1372
- _self._baseTelInit = function (config, core, extensions, pluginChain) {
1373
- if (config) {
1374
- setValue(config, strExtensionConfig, [], null, isNullOrUndefined);
1375
- }
1376
- if (!pluginChain && core) {
1377
- pluginChain = core.getProcessTelContext().getNext();
1378
- }
1379
- var nextPlugin = _nextPlugin;
1380
- if (_nextPlugin && _nextPlugin[strGetPlugin]) {
1381
- nextPlugin = _nextPlugin[strGetPlugin]();
1382
- }
1383
- _self.core = core;
1384
- _rootCtx = new ProcessTelemetryContext(pluginChain, config, core, nextPlugin);
1385
- _isinitialized = true;
1386
- };
1679
+ return hasRun;
1680
+ }
1681
+ if (!_processChain(updateCtx, _callUpdate, "update", function () { }, false)) {
1682
+ updateCtx.processNext(updateState);
1683
+ }
1387
1684
  }
1388
- BaseTelemetryPlugin.prototype.initialize = function (config, core, extensions, pluginChain) {
1389
- this._baseTelInit(config, core, extensions, pluginChain);
1390
- };
1391
- return BaseTelemetryPlugin;
1392
- }());
1685
+ return objFreeze(proxyChain);
1686
+ }
1393
1687
 
1394
1688
  var strToGMTString = "toGMTString";
1395
1689
  var strToUTCString = "toUTCString";
@@ -1399,7 +1693,6 @@
1399
1693
  var strIsCookieUseDisabled = "isCookieUseDisabled";
1400
1694
  var strDisableCookiesUsage = "disableCookiesUsage";
1401
1695
  var strConfigCookieMgr = "_ckMgr";
1402
- var strEmpty = "";
1403
1696
  var _supportsCookies = null;
1404
1697
  var _allowUaSameSite = null;
1405
1698
  var _parsedCookieValue = null;
@@ -1558,7 +1851,7 @@
1558
1851
  _supportsCookies = doc[strCookie] !== undefined;
1559
1852
  }
1560
1853
  catch (e) {
1561
- logger && logger.throwInternal(LoggingSeverity.WARNING, _InternalMessageId.CannotAccessCookie, "Cannot access document.cookie - " + getExceptionName(e), { exception: dumpObj(e) });
1854
+ _throwInternal(logger, 2 , 68 , "Cannot access document.cookie - " + getExceptionName(e), { exception: dumpObj(e) });
1562
1855
  }
1563
1856
  }
1564
1857
  return _supportsCookies;
@@ -1637,86 +1930,286 @@
1637
1930
  return false;
1638
1931
  }
1639
1932
 
1640
- var UInt32Mask = 0x100000000;
1641
- var MaxUInt32 = 0xffffffff;
1642
- var _mwcSeeded = false;
1643
- var _mwcW = 123456789;
1644
- var _mwcZ = 987654321;
1645
- function _mwcSeed(seedValue) {
1646
- if (seedValue < 0) {
1647
- seedValue >>>= 0;
1648
- }
1649
- _mwcW = (123456789 + seedValue) & MaxUInt32;
1650
- _mwcZ = (987654321 - seedValue) & MaxUInt32;
1651
- _mwcSeeded = true;
1652
- }
1653
- function _autoSeedMwc() {
1654
- try {
1655
- var now = dateNow() & 0x7fffffff;
1656
- _mwcSeed(((Math.random() * UInt32Mask) ^ now) + now);
1657
- }
1658
- catch (e) {
1933
+ var strExtensionConfig = "extensionConfig";
1934
+
1935
+ function createUnloadHandlerContainer() {
1936
+ var handlers = [];
1937
+ function _addHandler(handler) {
1938
+ if (handler) {
1939
+ handlers.push(handler);
1940
+ }
1659
1941
  }
1660
- }
1661
- function randomValue(maxValue) {
1662
- if (maxValue > 0) {
1663
- return Math.floor((random32() / MaxUInt32) * (maxValue + 1)) >>> 0;
1942
+ function _runHandlers(unloadCtx, unloadState) {
1943
+ arrForEach(handlers, function (handler) {
1944
+ try {
1945
+ handler(unloadCtx, unloadState);
1946
+ }
1947
+ catch (e) {
1948
+ _throwInternal(unloadCtx.diagLog(), 2 , 73 , "Unexpected error calling unload handler - " + dumpObj(e));
1949
+ }
1950
+ });
1951
+ handlers = [];
1664
1952
  }
1665
- return 0;
1953
+ return {
1954
+ add: _addHandler,
1955
+ run: _runHandlers
1956
+ };
1666
1957
  }
1667
- function random32(signed) {
1668
- var value;
1669
- var c = getCrypto() || getMsCrypto();
1670
- if (c && c.getRandomValues) {
1671
- value = c.getRandomValues(new Uint32Array(1))[0] & MaxUInt32;
1672
- }
1673
- else if (isIE()) {
1674
- if (!_mwcSeeded) {
1675
- _autoSeedMwc();
1958
+
1959
+ var strGetPlugin = "getPlugin";
1960
+ var BaseTelemetryPlugin = /** @class */ (function () {
1961
+ function BaseTelemetryPlugin() {
1962
+ var _self = this;
1963
+ var _isinitialized;
1964
+ var _rootCtx;
1965
+ var _nextPlugin;
1966
+ var _unloadHandlerContainer;
1967
+ var _hooks;
1968
+ _initDefaults();
1969
+ dynamicProto(BaseTelemetryPlugin, _self, function (_self) {
1970
+ _self.initialize = function (config, core, extensions, pluginChain) {
1971
+ _setDefaults(config, core, pluginChain);
1972
+ _isinitialized = true;
1973
+ };
1974
+ _self.teardown = function (unloadCtx, unloadState) {
1975
+ if (!_self.core || (unloadCtx && _self.core !== unloadCtx.core())) {
1976
+ return;
1977
+ }
1978
+ var result;
1979
+ var unloadDone = false;
1980
+ var theUnloadCtx = unloadCtx || createProcessTelemetryUnloadContext(null, {}, _self.core, _nextPlugin && _nextPlugin[strGetPlugin] ? _nextPlugin[strGetPlugin]() : _nextPlugin);
1981
+ var theUnloadState = unloadState || {
1982
+ reason: 0 ,
1983
+ isAsync: false
1984
+ };
1985
+ function _unloadCallback() {
1986
+ if (!unloadDone) {
1987
+ unloadDone = true;
1988
+ _unloadHandlerContainer.run(theUnloadCtx, unloadState);
1989
+ arrForEach(_hooks, function (fn) {
1990
+ fn.rm();
1991
+ });
1992
+ _hooks = [];
1993
+ if (result === true) {
1994
+ theUnloadCtx.processNext(theUnloadState);
1995
+ }
1996
+ _initDefaults();
1997
+ }
1998
+ }
1999
+ if (!_self[strDoTeardown] || _self[strDoTeardown](theUnloadCtx, theUnloadState, _unloadCallback) !== true) {
2000
+ _unloadCallback();
2001
+ }
2002
+ else {
2003
+ result = true;
2004
+ }
2005
+ return result;
2006
+ };
2007
+ _self.update = function (updateCtx, updateState) {
2008
+ if (!_self.core || (updateCtx && _self.core !== updateCtx.core())) {
2009
+ return;
2010
+ }
2011
+ var result;
2012
+ var updateDone = false;
2013
+ var theUpdateCtx = updateCtx || createProcessTelemetryUpdateContext(null, {}, _self.core, _nextPlugin && _nextPlugin[strGetPlugin] ? _nextPlugin[strGetPlugin]() : _nextPlugin);
2014
+ var theUpdateState = updateState || {
2015
+ reason: 0
2016
+ };
2017
+ function _updateCallback() {
2018
+ if (!updateDone) {
2019
+ updateDone = true;
2020
+ _setDefaults(theUpdateCtx.getCfg(), theUpdateCtx.core(), theUpdateCtx.getNext());
2021
+ }
2022
+ }
2023
+ if (!_self._doUpdate || _self._doUpdate(theUpdateCtx, theUpdateState, _updateCallback) !== true) {
2024
+ _updateCallback();
2025
+ }
2026
+ else {
2027
+ result = true;
2028
+ }
2029
+ return result;
2030
+ };
2031
+ _self._addHook = function (hooks) {
2032
+ if (hooks) {
2033
+ if (isArray(hooks)) {
2034
+ _hooks = _hooks.concat(hooks);
2035
+ }
2036
+ else {
2037
+ _hooks.push(hooks);
2038
+ }
2039
+ }
2040
+ };
2041
+ proxyFunctionAs(_self, "_addUnloadCb", function () { return _unloadHandlerContainer; }, "add");
2042
+ });
2043
+ _self.diagLog = function (itemCtx) {
2044
+ return _getTelCtx(itemCtx).diagLog();
2045
+ };
2046
+ _self[strIsInitialized] = function () {
2047
+ return _isinitialized;
2048
+ };
2049
+ _self.setInitialized = function (isInitialized) {
2050
+ _isinitialized = isInitialized;
2051
+ };
2052
+ _self[strSetNextPlugin] = function (next) {
2053
+ _nextPlugin = next;
2054
+ };
2055
+ _self.processNext = function (env, itemCtx) {
2056
+ if (itemCtx) {
2057
+ itemCtx.processNext(env);
2058
+ }
2059
+ else if (_nextPlugin && isFunction(_nextPlugin.processTelemetry)) {
2060
+ _nextPlugin.processTelemetry(env, null);
2061
+ }
2062
+ };
2063
+ _self._getTelCtx = _getTelCtx;
2064
+ function _getTelCtx(currentCtx) {
2065
+ if (currentCtx === void 0) { currentCtx = null; }
2066
+ var itemCtx = currentCtx;
2067
+ if (!itemCtx) {
2068
+ var rootCtx = _rootCtx || createProcessTelemetryContext(null, {}, _self.core);
2069
+ if (_nextPlugin && _nextPlugin[strGetPlugin]) {
2070
+ itemCtx = rootCtx.createNew(null, _nextPlugin[strGetPlugin]);
2071
+ }
2072
+ else {
2073
+ itemCtx = rootCtx.createNew(null, _nextPlugin);
2074
+ }
2075
+ }
2076
+ return itemCtx;
2077
+ }
2078
+ function _setDefaults(config, core, pluginChain) {
2079
+ if (config) {
2080
+ setValue(config, strExtensionConfig, [], null, isNullOrUndefined);
2081
+ }
2082
+ if (!pluginChain && core) {
2083
+ pluginChain = core.getProcessTelContext().getNext();
2084
+ }
2085
+ var nextPlugin = _nextPlugin;
2086
+ if (_nextPlugin && _nextPlugin[strGetPlugin]) {
2087
+ nextPlugin = _nextPlugin[strGetPlugin]();
2088
+ }
2089
+ _self.core = core;
2090
+ _rootCtx = createProcessTelemetryContext(pluginChain, config, core, nextPlugin);
2091
+ }
2092
+ function _initDefaults() {
2093
+ _isinitialized = false;
2094
+ _self.core = null;
2095
+ _rootCtx = null;
2096
+ _nextPlugin = null;
2097
+ _hooks = [];
2098
+ _unloadHandlerContainer = createUnloadHandlerContainer();
1676
2099
  }
1677
- value = mwcRandom32() & MaxUInt32;
1678
- }
1679
- else {
1680
- value = Math.floor((UInt32Mask * Math.random()) | 0);
1681
2100
  }
1682
- if (!signed) {
1683
- value >>>= 0;
2101
+ return BaseTelemetryPlugin;
2102
+ }());
2103
+
2104
+ var strOnPrefix = "on";
2105
+ var strAttachEvent = "attachEvent";
2106
+ var strAddEventHelper = "addEventListener";
2107
+ var strEvents = "events";
2108
+ createUniqueNamespace("aiEvtPageHide");
2109
+ createUniqueNamespace("aiEvtPageShow");
2110
+ var rRemoveEmptyNs = /\.[\.]+/g;
2111
+ var rRemoveTrailingEmptyNs = /[\.]+$/;
2112
+ var _guid = 1;
2113
+ var elmNodeData = createElmNodeData("events");
2114
+ var eventNamespace = /^([^.]*)(?:\.(.+)|)/;
2115
+ function _normalizeNamespace(name) {
2116
+ if (name && name.replace) {
2117
+ return name.replace(/^\s*\.*|\.*\s*$/g, "");
2118
+ }
2119
+ return name;
2120
+ }
2121
+ function _getEvtNamespace(eventName, evtNamespace) {
2122
+ if (evtNamespace) {
2123
+ var theNamespace_1 = "";
2124
+ if (isArray(evtNamespace)) {
2125
+ theNamespace_1 = "";
2126
+ arrForEach(evtNamespace, function (name) {
2127
+ name = _normalizeNamespace(name);
2128
+ if (name) {
2129
+ if (name[0] !== ".") {
2130
+ name = "." + name;
2131
+ }
2132
+ theNamespace_1 += name;
2133
+ }
2134
+ });
2135
+ }
2136
+ else {
2137
+ theNamespace_1 = _normalizeNamespace(evtNamespace);
2138
+ }
2139
+ if (theNamespace_1) {
2140
+ if (theNamespace_1[0] !== ".") {
2141
+ theNamespace_1 = "." + theNamespace_1;
2142
+ }
2143
+ eventName = (eventName || "") + theNamespace_1;
2144
+ }
1684
2145
  }
1685
- return value;
2146
+ var parsedEvent = (eventNamespace.exec(eventName || "") || []);
2147
+ return {
2148
+ type: parsedEvent[1],
2149
+ ns: ((parsedEvent[2] || "").replace(rRemoveEmptyNs, ".").replace(rRemoveTrailingEmptyNs, "").split(".").sort()).join(".")
2150
+ };
1686
2151
  }
1687
- function mwcRandomSeed(value) {
1688
- if (!value) {
1689
- _autoSeedMwc();
2152
+ function _getRegisteredEvents(target, evtName, addDefault) {
2153
+ if (addDefault === void 0) { addDefault = true; }
2154
+ var aiEvts = elmNodeData.get(target, strEvents, {}, addDefault);
2155
+ var registeredEvents = aiEvts[evtName];
2156
+ if (!registeredEvents) {
2157
+ registeredEvents = aiEvts[evtName] = [];
1690
2158
  }
1691
- else {
1692
- _mwcSeed(value);
2159
+ return registeredEvents;
2160
+ }
2161
+ function _doAttach(obj, evtName, handlerRef, useCapture) {
2162
+ var result = false;
2163
+ if (obj && evtName && evtName.type && handlerRef) {
2164
+ if (obj[strAddEventHelper]) {
2165
+ obj[strAddEventHelper](evtName.type, handlerRef, useCapture);
2166
+ result = true;
2167
+ }
2168
+ else if (obj[strAttachEvent]) {
2169
+ obj[strAttachEvent](strOnPrefix + evtName.type, handlerRef);
2170
+ result = true;
2171
+ }
1693
2172
  }
2173
+ return result;
1694
2174
  }
1695
- function mwcRandom32(signed) {
1696
- _mwcZ = (36969 * (_mwcZ & 0xFFFF) + (_mwcZ >> 16)) & MaxUInt32;
1697
- _mwcW = (18000 * (_mwcW & 0xFFFF) + (_mwcW >> 16)) & MaxUInt32;
1698
- var value = (((_mwcZ << 16) + (_mwcW & 0xFFFF)) >>> 0) & MaxUInt32 | 0;
1699
- if (!signed) {
1700
- value >>>= 0;
2175
+ function eventOn(target, eventName, handlerRef, evtNamespace, useCapture) {
2176
+ if (useCapture === void 0) { useCapture = false; }
2177
+ var result = false;
2178
+ if (target) {
2179
+ try {
2180
+ var evtName = _getEvtNamespace(eventName, evtNamespace);
2181
+ result = _doAttach(target, evtName, handlerRef, useCapture);
2182
+ if (result && elmNodeData.accept(target)) {
2183
+ var registeredEvent = {
2184
+ guid: _guid++,
2185
+ evtName: evtName,
2186
+ handler: handlerRef,
2187
+ capture: useCapture
2188
+ };
2189
+ _getRegisteredEvents(target, evtName.type).push(registeredEvent);
2190
+ }
2191
+ }
2192
+ catch (e) {
2193
+ }
1701
2194
  }
1702
- return value;
2195
+ return result;
1703
2196
  }
1704
-
1705
- var _cookieMgrs = null;
1706
- var _canUseCookies;
1707
- function addEventHandler(eventName, callback) {
2197
+ function addEventHandler(eventName, callback, evtNamespace) {
1708
2198
  var result = false;
1709
2199
  var w = getWindow();
1710
2200
  if (w) {
1711
- result = attachEvent(w, eventName, callback);
1712
- result = attachEvent(w["body"], eventName, callback) || result;
2201
+ result = eventOn(w, eventName, callback, evtNamespace);
2202
+ result = eventOn(w["body"], eventName, callback, evtNamespace) || result;
1713
2203
  }
1714
2204
  var doc = getDocument();
1715
2205
  if (doc) {
1716
- result = attachEvent(doc, eventName, callback) || result;
2206
+ result = eventOn(doc, eventName, callback, evtNamespace) || result;
1717
2207
  }
1718
2208
  return result;
1719
2209
  }
2210
+
2211
+ var _cookieMgrs = null;
2212
+ var _canUseCookies;
1720
2213
  function newGuid() {
1721
2214
  function randomHexDigit() {
1722
2215
  return randomValue(15);
@@ -1733,26 +2226,9 @@
1733
2226
  }
1734
2227
  return dateNow();
1735
2228
  }
1736
- function newId(maxLength) {
1737
- if (maxLength === void 0) { maxLength = 22; }
1738
- var base64chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
1739
- var number = random32() >>> 0;
1740
- var chars = 0;
1741
- var result = "";
1742
- while (result.length < maxLength) {
1743
- chars++;
1744
- result += base64chars.charAt(number & 0x3F);
1745
- number >>>= 6;
1746
- if (chars === 5) {
1747
- number = (((random32() << 2) & 0xFFFFFFFF) | (number & 0x03)) >>> 0;
1748
- chars = 0;
1749
- }
1750
- }
1751
- return result;
1752
- }
1753
2229
  function generateW3CId() {
1754
2230
  var hexValues = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f"];
1755
- var oct = "", tmp;
2231
+ var oct = strEmpty, tmp;
1756
2232
  for (var a = 0; a < 4; a++) {
1757
2233
  tmp = random32();
1758
2234
  oct +=
@@ -1838,98 +2314,91 @@
1838
2314
  var ReactPlugin = /** @class */ (function (_super) {
1839
2315
  __extendsFn(ReactPlugin, _super);
1840
2316
  function ReactPlugin() {
1841
- var _this = _super !== null && _super.apply(this, arguments) || this;
2317
+ var _this = _super.call(this) || this;
1842
2318
  _this.priority = 185;
1843
2319
  _this.identifier = 'ReactPlugin';
1844
- return _this;
1845
- }
1846
- ReactPlugin.prototype.initialize = function (config, core, extensions, pluginChain) {
1847
- var _this = this;
1848
- _super.prototype.initialize.call(this, config, core, extensions, pluginChain);
1849
- this._extensionConfig =
1850
- config.extensionConfig && config.extensionConfig[this.identifier]
1851
- ? config.extensionConfig[this.identifier]
1852
- : { history: null };
1853
- arrForEach(extensions, function (ext) {
1854
- var identifier = ext.identifier;
1855
- if (identifier === 'ApplicationInsightsAnalytics') {
1856
- _this._analyticsPlugin = ext;
2320
+ var _analyticsPlugin;
2321
+ var _extensionConfig;
2322
+ var _unlisten;
2323
+ var _pageViewTimer;
2324
+ dynamicProto(ReactPlugin, _this, function (_self, _base) {
2325
+ _initDefaults();
2326
+ _self.initialize = function (config, core, extensions, pluginChain) {
2327
+ _super.prototype.initialize.call(_this, config, core, extensions, pluginChain);
2328
+ _extensionConfig =
2329
+ config.extensionConfig && config.extensionConfig[_self.identifier]
2330
+ ? config.extensionConfig[_self.identifier]
2331
+ : { history: null };
2332
+ arrForEach(extensions, function (ext) {
2333
+ var identifier = ext.identifier;
2334
+ if (identifier === 'ApplicationInsightsAnalytics') {
2335
+ _analyticsPlugin = ext;
2336
+ }
2337
+ });
2338
+ if (_extensionConfig.history) {
2339
+ _addHistoryListener(_extensionConfig.history);
2340
+ var pageViewTelemetry = {
2341
+ uri: _extensionConfig.history.location.pathname
2342
+ };
2343
+ _self.trackPageView(pageViewTelemetry);
2344
+ }
2345
+ };
2346
+ _self.getCookieMgr = function () {
2347
+ return safeGetCookieMgr(_self.core);
2348
+ };
2349
+ _self.getAppInsights = _getAnalytics;
2350
+ _self.processTelemetry = function (event, itemCtx) {
2351
+ _self.processNext(event, itemCtx);
2352
+ };
2353
+ _self._doTeardown = function (unloadCtx, unloadState, asyncCallback) {
2354
+ if (isFunction(_unlisten)) {
2355
+ _unlisten();
2356
+ }
2357
+ if (_pageViewTimer) {
2358
+ clearTimeout(_pageViewTimer);
2359
+ }
2360
+ _initDefaults();
2361
+ };
2362
+ proxyFunctions(_self, _getAnalytics, [
2363
+ "trackMetric",
2364
+ "trackPageView",
2365
+ "trackEvent",
2366
+ "trackException",
2367
+ "trackTrace",
2368
+ ]);
2369
+ function _initDefaults() {
2370
+ _analyticsPlugin = null;
2371
+ _extensionConfig = null;
2372
+ _unlisten = null;
2373
+ _pageViewTimer = null;
2374
+ }
2375
+ function _getAnalytics() {
2376
+ if (!_analyticsPlugin) {
2377
+ _throwInternal(_self.diagLog(), 1 , 64 , "Analytics plugin is not available, React plugin telemetry will not be sent: ");
2378
+ }
2379
+ return _analyticsPlugin;
1857
2380
  }
2381
+ function _addHistoryListener(history) {
2382
+ var locationListener = function (arg) {
2383
+ var locn = null;
2384
+ if ("location" in arg) {
2385
+ locn = arg["location"];
2386
+ }
2387
+ else {
2388
+ locn = arg;
2389
+ }
2390
+ _pageViewTimer = setTimeout(function () {
2391
+ _pageViewTimer = null;
2392
+ var pageViewTelemetry = { uri: locn.pathname };
2393
+ _self.trackPageView(pageViewTelemetry);
2394
+ }, 500);
2395
+ };
2396
+ _unlisten = history.listen(locationListener);
2397
+ }
2398
+ objDefineAccessors(_self, "_extensionConfig", function () { return _extensionConfig; });
1858
2399
  });
1859
- if (this._extensionConfig.history) {
1860
- this.addHistoryListener(this._extensionConfig.history);
1861
- var pageViewTelemetry = {
1862
- uri: this._extensionConfig.history.location.pathname
1863
- };
1864
- this.trackPageView(pageViewTelemetry);
1865
- }
1866
- };
1867
- ReactPlugin.prototype.getCookieMgr = function () {
1868
- return safeGetCookieMgr(this.core);
1869
- };
1870
- ReactPlugin.prototype.getAppInsights = function () {
1871
- return this._analyticsPlugin;
1872
- };
1873
- ReactPlugin.prototype.processTelemetry = function (event, itemCtx) {
1874
- this.processNext(event, itemCtx);
1875
- };
1876
- ReactPlugin.prototype.trackMetric = function (metric, customProperties) {
1877
- if (this._analyticsPlugin) {
1878
- this._analyticsPlugin.trackMetric(metric, customProperties);
1879
- }
1880
- else {
1881
- this.diagLog().throwInternal(LoggingSeverity.CRITICAL, _InternalMessageId.TelemetryInitializerFailed, "Analytics plugin is not available, React plugin telemetry will not be sent: ");
1882
- }
1883
- };
1884
- ReactPlugin.prototype.trackPageView = function (pageView) {
1885
- if (this._analyticsPlugin) {
1886
- this._analyticsPlugin.trackPageView(pageView);
1887
- }
1888
- else {
1889
- this.diagLog().throwInternal(LoggingSeverity.CRITICAL, _InternalMessageId.TelemetryInitializerFailed, "Analytics plugin is not available, React plugin telemetry will not be sent: ");
1890
- }
1891
- };
1892
- ReactPlugin.prototype.trackEvent = function (event, customProperties) {
1893
- if (this._analyticsPlugin) {
1894
- this._analyticsPlugin.trackEvent(event, customProperties);
1895
- }
1896
- else {
1897
- this.diagLog().throwInternal(LoggingSeverity.CRITICAL, _InternalMessageId.TelemetryInitializerFailed, "Analytics plugin is not available, React plugin telemetry will not be sent: ");
1898
- }
1899
- };
1900
- ReactPlugin.prototype.trackException = function (exception, customProperties) {
1901
- if (this._analyticsPlugin) {
1902
- this._analyticsPlugin.trackException(exception, customProperties);
1903
- }
1904
- else {
1905
- this.diagLog().throwInternal(LoggingSeverity.CRITICAL, _InternalMessageId.TelemetryInitializerFailed, "Analytics plugin is not available, React plugin telemetry will not be sent: ");
1906
- }
1907
- };
1908
- ReactPlugin.prototype.trackTrace = function (trace, customProperties) {
1909
- if (this._analyticsPlugin) {
1910
- this._analyticsPlugin.trackTrace(trace, customProperties);
1911
- }
1912
- else {
1913
- this.diagLog().throwInternal(LoggingSeverity.CRITICAL, _InternalMessageId.TelemetryInitializerFailed, "Analytics plugin is not available, React plugin telemetry will not be sent: ");
1914
- }
1915
- };
1916
- ReactPlugin.prototype.addHistoryListener = function (history) {
1917
- var _this = this;
1918
- var locationListener = function (arg) {
1919
- var locn = null;
1920
- if ("location" in arg) {
1921
- locn = arg["location"];
1922
- }
1923
- else {
1924
- locn = arg;
1925
- }
1926
- setTimeout(function () {
1927
- var pageViewTelemetry = { uri: locn.pathname };
1928
- _this.trackPageView(pageViewTelemetry);
1929
- }, 500);
1930
- };
1931
- history.listen(locationListener);
1932
- };
2400
+ return _this;
2401
+ }
1933
2402
  return ReactPlugin;
1934
2403
  }(BaseTelemetryPlugin));
1935
2404
  var ReactPlugin$1 = ReactPlugin;
@@ -2076,7 +2545,7 @@
2076
2545
  trackedData.idleCount * trackedData.idleTimeout) /
2077
2546
  1000);
2078
2547
  }
2079
- var useComponentTracking = function (reactPlugin, componentName) {
2548
+ var useComponentTracking = function (reactPlugin, componentName, customProperties) {
2080
2549
  var tracking = React.useRef({
2081
2550
  hookTimestamp: dateNow(),
2082
2551
  firstActiveTimestamp: 0,
@@ -2115,7 +2584,7 @@
2115
2584
  name: "React Component Engaged Time (seconds)",
2116
2585
  sampleCount: 1
2117
2586
  };
2118
- var additionalProperties = { "Component Name": componentName };
2587
+ var additionalProperties = __assignFn({ "Component Name": componentName }, customProperties);
2119
2588
  reactPlugin.trackMetric(metricData, additionalProperties);
2120
2589
  };
2121
2590
  }, []);