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

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-04
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,102 @@
755
708
  function isTruthy(value) {
756
709
  return !!value;
757
710
  }
711
+ function throwError(message) {
712
+ throw new Error(message);
713
+ }
714
+ function _createProxyFunction(source, funcName) {
715
+ var srcFunc = null;
716
+ var src = null;
717
+ if (isFunction(source)) {
718
+ srcFunc = source;
719
+ }
720
+ else {
721
+ src = source;
722
+ }
723
+ return function () {
724
+ var originalArguments = arguments;
725
+ if (srcFunc) {
726
+ src = srcFunc();
727
+ }
728
+ if (src) {
729
+ return src[funcName].apply(src, originalArguments);
730
+ }
731
+ };
732
+ }
733
+ function proxyFunctionAs(target, name, source, theFunc, overwriteTarget) {
734
+ if (overwriteTarget === void 0) { overwriteTarget = true; }
735
+ if (target && name && source) {
736
+ if (overwriteTarget || isUndefined(target[name])) {
737
+ target[name] = _createProxyFunction(source, theFunc);
738
+ }
739
+ }
740
+ }
741
+ function proxyFunctions(target, source, functionsToProxy, overwriteTarget) {
742
+ if (overwriteTarget === void 0) { overwriteTarget = true; }
743
+ if (target && source && isObject(target) && isArray(functionsToProxy)) {
744
+ arrForEach(functionsToProxy, function (theFuncName) {
745
+ if (isString(theFuncName)) {
746
+ proxyFunctionAs(target, theFuncName, source, theFuncName, overwriteTarget);
747
+ }
748
+ });
749
+ }
750
+ return target;
751
+ }
752
+ function createEnumStyle(values) {
753
+ var enumClass = {};
754
+ objForEachKey(values, function (field, value) {
755
+ enumClass[field] = value;
756
+ if (!isUndefined(enumClass[value])) {
757
+ throwError("[" + value + "] exists for " + field);
758
+ }
759
+ enumClass[value] = field;
760
+ });
761
+ return objFreeze(enumClass);
762
+ }
763
+ function objExtend(obj1, obj2, obj3, obj4, obj5, obj6) {
764
+ var theArgs = arguments;
765
+ var extended = theArgs[0] || {};
766
+ var argLen = theArgs.length;
767
+ var deep = false;
768
+ var idx = 1;
769
+ if (argLen > 0 && isBoolean(extended)) {
770
+ deep = extended;
771
+ extended = theArgs[idx] || {};
772
+ idx++;
773
+ }
774
+ if (!isObject(extended)) {
775
+ extended = {};
776
+ }
777
+ for (; idx < argLen; idx++) {
778
+ var arg = theArgs[idx];
779
+ var isArgArray = isArray(arg);
780
+ var isArgObj = isObject(arg);
781
+ for (var prop in arg) {
782
+ var propOk = (isArgArray && (prop in arg)) || (isArgObj && (ObjHasOwnProperty.call(arg, prop)));
783
+ if (!propOk) {
784
+ continue;
785
+ }
786
+ var newValue = arg[prop];
787
+ var isNewArray = void 0;
788
+ if (deep && newValue && ((isNewArray = isArray(newValue)) || isPlainObject(newValue))) {
789
+ var clone = extended[prop];
790
+ if (isNewArray) {
791
+ if (!isArray(clone)) {
792
+ clone = [];
793
+ }
794
+ }
795
+ else if (!isPlainObject(clone)) {
796
+ clone = {};
797
+ }
798
+ newValue = objExtend(deep, clone, newValue);
799
+ }
800
+ if (newValue !== undefined) {
801
+ extended[prop] = newValue;
802
+ }
803
+ }
804
+ }
805
+ return extended;
806
+ }
758
807
 
759
808
  var strWindow = "window";
760
809
  var strDocument = "document";
@@ -847,14 +896,14 @@
847
896
  var nav = getNavigator();
848
897
  if (nav && (nav.userAgent !== _navUserAgentCheck || _isTrident === null)) {
849
898
  _navUserAgentCheck = nav.userAgent;
850
- var userAgent = (_navUserAgentCheck || "").toLowerCase();
899
+ var userAgent = (_navUserAgentCheck || strEmpty).toLowerCase();
851
900
  _isTrident = (strContains(userAgent, strMsie) || strContains(userAgent, strTrident));
852
901
  }
853
902
  return _isTrident;
854
903
  }
855
904
  function dumpObj(object) {
856
905
  var objectTypeDump = Object[strShimPrototype].toString.call(object);
857
- var propertyValueDump = "";
906
+ var propertyValueDump = strEmpty;
858
907
  if (objectTypeDump === "[object Error]") {
859
908
  propertyValueDump = "{ stack: '" + object.stack + "', message: '" + object.message + "', name: '" + object.name + "'";
860
909
  }
@@ -887,9 +936,9 @@
887
936
  var strWarnToConsole = "warnToConsole";
888
937
  function _sanitizeDiagnosticText(text) {
889
938
  if (text) {
890
- return "\"" + text.replace(/\"/g, "") + "\"";
939
+ return "\"" + text.replace(/\"/g, strEmpty) + "\"";
891
940
  }
892
- return "";
941
+ return strEmpty;
893
942
  }
894
943
  function _logToConsole(func, message) {
895
944
  var theConsole = getConsole();
@@ -911,12 +960,12 @@
911
960
  _self.message =
912
961
  (isUserAct ? AiUserActionablePrefix : AiNonUserActionablePrefix) +
913
962
  msgId;
914
- var strProps = "";
963
+ var strProps = strEmpty;
915
964
  if (hasJSON()) {
916
965
  strProps = getJSON().stringify(properties);
917
966
  }
918
- var diagnosticText = (msg ? " message:" + _sanitizeDiagnosticText(msg) : "") +
919
- (properties ? " props:" + _sanitizeDiagnosticText(strProps) : "");
967
+ var diagnosticText = (msg ? " message:" + _sanitizeDiagnosticText(msg) : strEmpty) +
968
+ (properties ? " props:" + _sanitizeDiagnosticText(strProps) : strEmpty);
920
969
  _self.message += diagnosticText;
921
970
  }
922
971
  _InternalLogMessage.dataType = "MessageData";
@@ -946,7 +995,7 @@
946
995
  throw message;
947
996
  }
948
997
  else {
949
- var logFunc = severity === LoggingSeverity.CRITICAL ? strErrorToConsole : strWarnToConsole;
998
+ var logFunc = severity === 1 ? strErrorToConsole : strWarnToConsole;
950
999
  if (!isUndefined(message.message)) {
951
1000
  var logLevel = _self.consoleLoggingLevel();
952
1001
  if (isUserAct) {
@@ -964,7 +1013,7 @@
964
1013
  _self.logInternalMessage(severity, message);
965
1014
  }
966
1015
  else {
967
- _debugExtMsg("throw" + (severity === LoggingSeverity.CRITICAL ? "Critical" : "Warning"), message);
1016
+ _debugExtMsg("throw" + (severity === 1 ? "Critical" : "Warning"), message);
968
1017
  }
969
1018
  }
970
1019
  };
@@ -996,13 +1045,13 @@
996
1045
  if (severity <= _self.telemetryLoggingLevel()) {
997
1046
  _self.queue.push(message);
998
1047
  _messageCount++;
999
- _debugExtMsg((severity === LoggingSeverity.CRITICAL ? "error" : "warn"), message);
1048
+ _debugExtMsg((severity === 1 ? "error" : "warn"), message);
1000
1049
  }
1001
1050
  if (_messageCount === _self.maxInternalMessageLimit()) {
1002
1051
  var throttleLimitMessage = "Internal events throttle limit per PageView reached for this app.";
1003
- var throttleMessage = new _InternalLogMessage(_InternalMessageId.MessageLimitPerPVExceeded, throttleLimitMessage, false);
1052
+ var throttleMessage = new _InternalLogMessage(23 , throttleLimitMessage, false);
1004
1053
  _self.queue.push(throttleMessage);
1005
- if (severity === LoggingSeverity.CRITICAL) {
1054
+ if (severity === 1 ) {
1006
1055
  _self.errorToConsole(throttleLimitMessage);
1007
1056
  }
1008
1057
  else {
@@ -1031,6 +1080,10 @@
1031
1080
  }
1032
1081
  return DiagnosticLogger;
1033
1082
  }());
1083
+ function _throwInternal(logger, severity, msgId, msg, properties, isUserAct) {
1084
+ if (isUserAct === void 0) { isUserAct = false; }
1085
+ (logger || new DiagnosticLogger()).throwInternal(severity, msgId, msg, properties, isUserAct);
1086
+ }
1034
1087
 
1035
1088
  var strExecutionContextKey = "ctx";
1036
1089
  var PerfEvent = /** @class */ (function () {
@@ -1144,252 +1197,509 @@
1144
1197
  return func();
1145
1198
  }
1146
1199
 
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;
1200
+ var UInt32Mask = 0x100000000;
1201
+ var MaxUInt32 = 0xffffffff;
1202
+ var _mwcSeeded = false;
1203
+ var _mwcW = 123456789;
1204
+ var _mwcZ = 987654321;
1205
+ function _mwcSeed(seedValue) {
1206
+ if (seedValue < 0) {
1207
+ seedValue >>>= 0;
1208
+ }
1209
+ _mwcW = (123456789 + seedValue) & MaxUInt32;
1210
+ _mwcZ = (987654321 - seedValue) & MaxUInt32;
1211
+ _mwcSeeded = true;
1212
+ }
1213
+ function _autoSeedMwc() {
1214
+ try {
1215
+ var now = dateNow() & 0x7fffffff;
1216
+ _mwcSeed(((Math.random() * UInt32Mask) ^ now) + now);
1217
+ }
1218
+ catch (e) {
1219
+ }
1220
+ }
1221
+ function randomValue(maxValue) {
1222
+ if (maxValue > 0) {
1223
+ return Math.floor((random32() / MaxUInt32) * (maxValue + 1)) >>> 0;
1224
+ }
1225
+ return 0;
1226
+ }
1227
+ function random32(signed) {
1228
+ var value = 0;
1229
+ var c = getCrypto() || getMsCrypto();
1230
+ if (c && c.getRandomValues) {
1231
+ value = c.getRandomValues(new Uint32Array(1))[0] & MaxUInt32;
1232
+ }
1233
+ if (value === 0 && isIE()) {
1234
+ if (!_mwcSeeded) {
1235
+ _autoSeedMwc();
1236
+ }
1237
+ value = mwcRandom32() & MaxUInt32;
1238
+ }
1239
+ if (value === 0) {
1240
+ value = Math.floor((UInt32Mask * Math.random()) | 0);
1241
+ }
1242
+ if (!signed) {
1243
+ value >>>= 0;
1244
+ }
1245
+ return value;
1246
+ }
1247
+ function mwcRandomSeed(value) {
1248
+ if (!value) {
1249
+ _autoSeedMwc();
1250
+ }
1251
+ else {
1252
+ _mwcSeed(value);
1253
+ }
1254
+ }
1255
+ function mwcRandom32(signed) {
1256
+ _mwcZ = (36969 * (_mwcZ & 0xFFFF) + (_mwcZ >> 16)) & MaxUInt32;
1257
+ _mwcW = (18000 * (_mwcW & 0xFFFF) + (_mwcW >> 16)) & MaxUInt32;
1258
+ var value = (((_mwcZ << 16) + (_mwcW & 0xFFFF)) >>> 0) & MaxUInt32 | 0;
1259
+ if (!signed) {
1260
+ value >>>= 0;
1261
+ }
1262
+ return value;
1263
+ }
1264
+ function newId(maxLength) {
1265
+ if (maxLength === void 0) { maxLength = 22; }
1266
+ var base64chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
1267
+ var number = random32() >>> 0;
1268
+ var chars = 0;
1269
+ var result = strEmpty;
1270
+ while (result.length < maxLength) {
1271
+ chars++;
1272
+ result += base64chars.charAt(number & 0x3F);
1273
+ number >>>= 6;
1274
+ if (chars === 5) {
1275
+ number = (((random32() << 2) & 0xFFFFFFFF) | (number & 0x03)) >>> 0;
1276
+ chars = 0;
1277
+ }
1278
+ }
1279
+ return result;
1280
+ }
1281
+
1282
+ var _objDefineProperty = ObjDefineProperty;
1283
+ var version = "2.8.0-nightly.2204-04";
1284
+ var instanceName = "." + newId(6);
1285
+ var _dataUid = 0;
1286
+ function _createAccessor(target, prop, value) {
1287
+ if (_objDefineProperty) {
1288
+ try {
1289
+ _objDefineProperty(target, prop, {
1290
+ value: value,
1291
+ enumerable: false,
1292
+ configurable: true
1293
+ });
1294
+ return true;
1295
+ }
1296
+ catch (e) {
1297
+ }
1298
+ }
1299
+ return false;
1300
+ }
1301
+ function _canAcceptData(target) {
1302
+ return target.nodeType === 1 || target.nodeType === 9 || !(+target.nodeType);
1303
+ }
1304
+ function _getCache(data, target) {
1305
+ var theCache = target[data.id];
1306
+ if (!theCache) {
1307
+ theCache = {};
1308
+ try {
1309
+ if (_canAcceptData(target)) {
1310
+ if (!_createAccessor(target, data.id, theCache)) {
1311
+ target[data.id] = theCache;
1312
+ }
1313
+ }
1314
+ }
1315
+ catch (e) {
1316
+ }
1317
+ }
1318
+ return theCache;
1319
+ }
1320
+ function createUniqueNamespace(name, includeVersion) {
1321
+ if (includeVersion === void 0) { includeVersion = false; }
1322
+ return normalizeJsName(name + (_dataUid++) + (includeVersion ? "." + version : "") + instanceName);
1323
+ }
1324
+ function createElmNodeData(name) {
1325
+ var data = {
1326
+ id: createUniqueNamespace("_aiData-" + (name || "") + "." + version),
1327
+ accept: function (target) {
1328
+ return _canAcceptData(target);
1329
+ },
1330
+ get: function (target, name, defValue, addDefault) {
1331
+ var theCache = target[data.id];
1332
+ if (!theCache) {
1333
+ if (addDefault) {
1334
+ theCache = _getCache(data, target);
1335
+ theCache[normalizeJsName(name)] = defValue;
1336
+ }
1337
+ return defValue;
1166
1338
  }
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;
1339
+ return theCache[normalizeJsName(name)];
1340
+ },
1341
+ kill: function (target, name) {
1342
+ if (target && target[name]) {
1343
+ try {
1344
+ delete target[name];
1345
+ }
1346
+ catch (e) {
1347
+ }
1348
+ }
1349
+ }
1350
+ };
1351
+ return data;
1352
+ }
1353
+
1354
+ var pluginStateData = createElmNodeData("plugin");
1355
+ function _getPluginState(plugin) {
1356
+ return pluginStateData.get(plugin, "state", {}, true);
1357
+ }
1358
+
1359
+ var strTelemetryPluginChain = "TelemetryPluginChain";
1360
+ var strHasRunFlags = "_hasRun";
1361
+ var strGetTelCtx = "_getTelCtx";
1362
+ var _chainId = 0;
1363
+ function _getNextProxyStart(proxy, config, core, startAt) {
1364
+ while (proxy) {
1365
+ if (proxy.getPlugin() === startAt) {
1366
+ return proxy;
1367
+ }
1368
+ proxy = proxy.getNext();
1369
+ }
1370
+ return createTelemetryProxyChain([startAt], config, core);
1371
+ }
1372
+ function _createInternalContext(telemetryChain, config, core, startAt) {
1373
+ var _nextProxy = null;
1374
+ var _onComplete = [];
1375
+ if (startAt !== null) {
1376
+ _nextProxy = startAt ? _getNextProxyStart(telemetryChain, config, core, startAt) : telemetryChain;
1377
+ }
1378
+ var context = {
1379
+ _next: _moveNext,
1380
+ ctx: {
1381
+ core: function () {
1382
+ return core;
1383
+ },
1384
+ diagLog: function () {
1385
+ return safeGetLogger(core, config);
1386
+ },
1387
+ getCfg: function () {
1388
+ return config;
1389
+ },
1390
+ getExtCfg: _getExtCfg,
1391
+ getConfig: _getConfig,
1392
+ hasNext: function () {
1393
+ return !!_nextProxy;
1394
+ },
1395
+ getNext: function () {
1396
+ return _nextProxy;
1397
+ },
1398
+ setNext: function (nextPlugin) {
1399
+ _nextProxy = nextPlugin;
1400
+ },
1401
+ iterate: _iterateChain,
1402
+ onComplete: _addOnComplete
1403
+ }
1404
+ };
1405
+ function _addOnComplete(onComplete, that) {
1406
+ var args = [];
1407
+ for (var _i = 2; _i < arguments.length; _i++) {
1408
+ args[_i - 2] = arguments[_i];
1409
+ }
1410
+ if (onComplete) {
1411
+ _onComplete.push({
1412
+ func: onComplete,
1413
+ self: !isUndefined(that) ? that : context.ctx,
1414
+ args: args
1415
+ });
1416
+ }
1417
+ }
1418
+ function _moveNext() {
1419
+ var nextProxy = _nextProxy;
1420
+ _nextProxy = nextProxy ? nextProxy.getNext() : null;
1421
+ if (!nextProxy) {
1422
+ var onComplete = _onComplete;
1423
+ if (onComplete && onComplete.length > 0) {
1424
+ arrForEach(onComplete, function (completeDetails) {
1171
1425
  try {
1172
- itemCtx.setNext(_nextProxy);
1173
- if (_hasSetNext) {
1174
- plugin.setNextPlugin(_nextProxy);
1175
- }
1176
- _nextProxy && (_nextProxy._hasRun = false);
1177
- plugin.processTelemetry(env, itemCtx);
1426
+ completeDetails.func.call(completeDetails.self, completeDetails.args);
1178
1427
  }
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
- }
1428
+ catch (e) {
1429
+ _throwInternal(core.logger, 2 , 73 , "Unexpected Exception during onComplete - " + dumpObj(e));
1187
1430
  }
1188
- }
1189
- else if (_nextProxy) {
1190
- _self._hasRun = true;
1191
- _nextProxy.processTelemetry(env, itemCtx);
1192
- }
1193
- }, function () { return ({ item: env }); }, !(env.sync));
1194
- };
1431
+ });
1432
+ _onComplete = [];
1433
+ }
1434
+ }
1435
+ return nextProxy;
1195
1436
  }
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);
1437
+ function _getExtCfg(identifier, defaultValue, mergeDefault) {
1438
+ if (defaultValue === void 0) { defaultValue = {}; }
1439
+ if (mergeDefault === void 0) { mergeDefault = 0 ; }
1440
+ var theConfig;
1441
+ if (config) {
1442
+ var extConfig = config.extensionConfig;
1443
+ if (extConfig && identifier) {
1444
+ theConfig = extConfig[identifier];
1445
+ }
1446
+ }
1447
+ if (!theConfig) {
1448
+ theConfig = defaultValue;
1449
+ }
1450
+ else if (isObject(defaultValue)) {
1451
+ if (mergeDefault !== 0 ) {
1452
+ var newConfig_1 = objExtend(true, defaultValue, theConfig);
1453
+ if (config && mergeDefault === 2 ) {
1454
+ objForEachKey(defaultValue, function (field) {
1455
+ if (isNullOrUndefined(newConfig_1[field])) {
1456
+ var cfgValue = config[field];
1457
+ if (!isNullOrUndefined(cfgValue)) {
1458
+ newConfig_1[field] = cfgValue;
1459
+ }
1460
+ }
1461
+ });
1210
1462
  }
1211
- lastProxy = newProxy;
1212
1463
  }
1213
1464
  }
1465
+ return theConfig;
1214
1466
  }
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);
1467
+ function _getConfig(identifier, field, defaultValue) {
1468
+ if (defaultValue === void 0) { defaultValue = false; }
1469
+ var theValue;
1470
+ var extConfig = _getExtCfg(identifier, null);
1471
+ if (extConfig && !isNullOrUndefined(extConfig[field])) {
1472
+ theValue = extConfig[field];
1473
+ }
1474
+ else if (config && !isNullOrUndefined(config[field])) {
1475
+ theValue = config[field];
1476
+ }
1477
+ return !isNullOrUndefined(theValue) ? theValue : defaultValue;
1478
+ }
1479
+ function _iterateChain(cb) {
1480
+ var nextPlugin;
1481
+ while (!!(nextPlugin = context._next())) {
1482
+ var plugin = nextPlugin.getPlugin();
1483
+ if (plugin) {
1484
+ cb(plugin);
1226
1485
  }
1227
- proxy = proxy.getNext();
1228
1486
  }
1229
1487
  }
1230
- if (!add) {
1231
- plugins.push(startAt);
1488
+ return context;
1489
+ }
1490
+ function createProcessTelemetryContext(telemetryChain, config, core, startAt) {
1491
+ var internalContext = _createInternalContext(telemetryChain, config, core, startAt);
1492
+ var context = internalContext.ctx;
1493
+ function _processNext(env) {
1494
+ var nextPlugin = internalContext._next();
1495
+ nextPlugin && nextPlugin.processTelemetry(env, context);
1496
+ return !nextPlugin;
1497
+ }
1498
+ function _createNew(plugins, startAt) {
1499
+ if (plugins === void 0) { plugins = null; }
1500
+ if (isArray(plugins)) {
1501
+ plugins = createTelemetryProxyChain(plugins, config, core, startAt);
1502
+ }
1503
+ return createProcessTelemetryContext(plugins || context.getNext(), config, core, startAt);
1504
+ }
1505
+ context.processNext = _processNext;
1506
+ context.createNew = _createNew;
1507
+ return context;
1508
+ }
1509
+ function createProcessTelemetryUnloadContext(telemetryChain, config, core, startAt) {
1510
+ var internalContext = _createInternalContext(telemetryChain, config, core, startAt);
1511
+ var context = internalContext.ctx;
1512
+ function _processNext(unloadState) {
1513
+ var nextPlugin = internalContext._next();
1514
+ nextPlugin && nextPlugin.unload(context, unloadState);
1515
+ return !nextPlugin;
1516
+ }
1517
+ function _createNew(plugins, startAt) {
1518
+ if (plugins === void 0) { plugins = null; }
1519
+ if (isArray(plugins)) {
1520
+ plugins = createTelemetryProxyChain(plugins, config, core, startAt);
1521
+ }
1522
+ return createProcessTelemetryUnloadContext(plugins || context.getNext(), config, core, startAt);
1232
1523
  }
1233
- return _createProxyChain(plugins, itemCtx);
1524
+ context.processNext = _processNext;
1525
+ context.createNew = _createNew;
1526
+ return context;
1234
1527
  }
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);
1528
+ function createProcessTelemetryUpdateContext(telemetryChain, config, core, startAt) {
1529
+ var internalContext = _createInternalContext(telemetryChain, config, core, startAt);
1530
+ var context = internalContext.ctx;
1531
+ function _processNext(updateState) {
1532
+ return context.iterate(function (plugin) {
1533
+ if (isFunction(plugin[strUpdate])) {
1534
+ plugin[strUpdate](context, updateState);
1244
1535
  }
1245
1536
  });
1246
1537
  }
1247
- if (startAt && !add) {
1248
- if (!plugins) {
1249
- plugins = [];
1538
+ function _createNew(plugins, startAt) {
1539
+ if (plugins === void 0) { plugins = null; }
1540
+ if (isArray(plugins)) {
1541
+ plugins = createTelemetryProxyChain(plugins, config, core, startAt);
1250
1542
  }
1251
- plugins.push(startAt);
1543
+ return createProcessTelemetryUpdateContext(plugins || context.getNext(), config, core, startAt);
1252
1544
  }
1253
- return _createProxyChain(plugins, itemCtx);
1545
+ context.processNext = _processNext;
1546
+ context.createNew = _createNew;
1547
+ return context;
1254
1548
  }
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);
1549
+ function createTelemetryProxyChain(plugins, config, core, startAt) {
1550
+ var firstProxy = null;
1551
+ var add = startAt ? false : true;
1552
+ if (isArray(plugins) && plugins.length > 0) {
1553
+ var lastProxy_1 = null;
1554
+ arrForEach(plugins, function (thePlugin) {
1555
+ if (!add && startAt === thePlugin) {
1556
+ add = true;
1557
+ }
1558
+ if (add && thePlugin && isFunction(thePlugin.processTelemetry)) {
1559
+ var newProxy = createTelemetryPluginProxy(thePlugin, config, core);
1560
+ if (!firstProxy) {
1561
+ firstProxy = newProxy;
1266
1562
  }
1267
- else if (isUndefined(startAt)) {
1268
- _nextProxy = _createProxyChain(plugins, _self);
1563
+ if (lastProxy_1) {
1564
+ lastProxy_1._setNext(newProxy);
1269
1565
  }
1566
+ lastProxy_1 = newProxy;
1270
1567
  }
1568
+ });
1569
+ }
1570
+ if (startAt && !firstProxy) {
1571
+ return createTelemetryProxyChain([startAt], config, core);
1572
+ }
1573
+ return firstProxy;
1574
+ }
1575
+ function createTelemetryPluginProxy(plugin, config, core) {
1576
+ var nextProxy = null;
1577
+ var hasProcessTelemetry = isFunction(plugin.processTelemetry);
1578
+ var hasSetNext = isFunction(plugin.setNextPlugin);
1579
+ var chainId;
1580
+ if (plugin) {
1581
+ chainId = plugin.identifier + "-" + plugin.priority + "-" + _chainId++;
1582
+ }
1583
+ else {
1584
+ chainId = "Unknown-0-" + _chainId++;
1585
+ }
1586
+ var proxyChain = {
1587
+ getPlugin: function () {
1588
+ return plugin;
1589
+ },
1590
+ getNext: function () {
1591
+ return nextProxy;
1592
+ },
1593
+ processTelemetry: _processTelemetry,
1594
+ unload: _unloadPlugin,
1595
+ update: _updatePlugin,
1596
+ _id: chainId,
1597
+ _setNext: function (nextPlugin) {
1598
+ nextProxy = nextPlugin;
1271
1599
  }
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];
1600
+ };
1601
+ function _getTelCtx() {
1602
+ var itemCtx;
1603
+ if (plugin && isFunction(plugin[strGetTelCtx])) {
1604
+ itemCtx = plugin[strGetTelCtx]();
1605
+ }
1606
+ if (!itemCtx) {
1607
+ itemCtx = createProcessTelemetryContext(proxyChain, config, core);
1608
+ }
1609
+ return itemCtx;
1610
+ }
1611
+ function _processChain(itemCtx, processPluginFn, name, details, isAsync) {
1612
+ var hasRun = false;
1613
+ var identifier = plugin ? plugin.identifier : strTelemetryPluginChain;
1614
+ var hasRunContext = itemCtx[strHasRunFlags];
1615
+ if (!hasRunContext) {
1616
+ hasRunContext = itemCtx[strHasRunFlags] = {};
1617
+ }
1618
+ itemCtx.setNext(nextProxy);
1619
+ if (plugin) {
1620
+ doPerf(itemCtx[strCore](), function () { return identifier + ":" + name; }, function () {
1621
+ hasRunContext[chainId] = true;
1622
+ try {
1623
+ var nextId = nextProxy ? nextProxy._id : strEmpty;
1624
+ if (nextId) {
1625
+ hasRunContext[nextId] = false;
1626
+ }
1627
+ hasRun = processPluginFn(itemCtx);
1628
+ }
1629
+ catch (error) {
1630
+ var hasNextRun = nextProxy ? hasRunContext[nextProxy._id] : true;
1631
+ if (hasNextRun) {
1632
+ hasRun = true;
1633
+ }
1634
+ if (!nextProxy || !hasNextRun) {
1635
+ _throwInternal(itemCtx.diagLog(), 1 , 73 , "Plugin [" + plugin.identifier + "] failed during " + name + " - " + dumpObj(error) + ", run flags: " + dumpObj(hasRunContext));
1636
+ }
1288
1637
  }
1638
+ }, details, isAsync);
1639
+ }
1640
+ return hasRun;
1641
+ }
1642
+ function _processTelemetry(env, itemCtx) {
1643
+ itemCtx = itemCtx || _getTelCtx();
1644
+ function _callProcessTelemetry(itemCtx) {
1645
+ if (!plugin || !hasProcessTelemetry) {
1646
+ return false;
1289
1647
  }
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];
1648
+ var pluginState = _getPluginState(plugin);
1649
+ if (pluginState[strTeardown] || pluginState[strDisabled]) {
1650
+ return false;
1298
1651
  }
1299
- else if (config && !isNullOrUndefined(config[field])) {
1300
- theValue = config[field];
1652
+ if (hasSetNext) {
1653
+ plugin.setNextPlugin(nextProxy);
1301
1654
  }
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);
1655
+ plugin.processTelemetry(env, itemCtx);
1656
+ return true;
1657
+ }
1658
+ if (!_processChain(itemCtx, _callProcessTelemetry, "processTelemetry", function () { return ({ item: env }); }, !(env.sync))) {
1659
+ itemCtx.processNext(env);
1660
+ }
1661
+ }
1662
+ function _unloadPlugin(unloadCtx, unloadState) {
1663
+ function _callTeardown() {
1664
+ var hasRun = false;
1665
+ if (plugin) {
1666
+ var pluginState = _getPluginState(plugin);
1667
+ var pluginCore = plugin[strCore] || pluginState.core;
1668
+ if (plugin && (!pluginCore || pluginCore === unloadCtx[strCore]()) && !pluginState[strTeardown]) {
1669
+ pluginState[strCore] = null;
1670
+ pluginState[strTeardown] = true;
1671
+ pluginState[strIsInitialized] = false;
1672
+ if (plugin[strTeardown] && plugin[strTeardown](unloadCtx, unloadState) === true) {
1673
+ hasRun = true;
1674
+ }
1675
+ }
1318
1676
  }
1319
- };
1320
- _self.createNew = function (plugins, startAt) {
1321
- if (plugins === void 0) { plugins = null; }
1322
- return new ProcessTelemetryContext(plugins || _nextProxy, config, core, startAt);
1323
- };
1677
+ return hasRun;
1678
+ }
1679
+ if (!_processChain(unloadCtx, _callTeardown, "unload", function () { }, unloadState.isAsync)) {
1680
+ unloadCtx.processNext(unloadState);
1681
+ }
1324
1682
  }
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);
1683
+ function _updatePlugin(updateCtx, updateState) {
1684
+ function _callUpdate() {
1685
+ var hasRun = false;
1686
+ if (plugin) {
1687
+ var pluginState = _getPluginState(plugin);
1688
+ var pluginCore = plugin[strCore] || pluginState.core;
1689
+ if (plugin && (!pluginCore || pluginCore === updateCtx[strCore]()) && !pluginState[strTeardown]) {
1690
+ if (plugin[strUpdate] && plugin[strUpdate](updateCtx, updateState) === true) {
1691
+ hasRun = true;
1692
+ }
1368
1693
  }
1369
1694
  }
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
- };
1695
+ return hasRun;
1696
+ }
1697
+ if (!_processChain(updateCtx, _callUpdate, "update", function () { }, false)) {
1698
+ updateCtx.processNext(updateState);
1699
+ }
1387
1700
  }
1388
- BaseTelemetryPlugin.prototype.initialize = function (config, core, extensions, pluginChain) {
1389
- this._baseTelInit(config, core, extensions, pluginChain);
1390
- };
1391
- return BaseTelemetryPlugin;
1392
- }());
1701
+ return objFreeze(proxyChain);
1702
+ }
1393
1703
 
1394
1704
  var strToGMTString = "toGMTString";
1395
1705
  var strToUTCString = "toUTCString";
@@ -1399,7 +1709,6 @@
1399
1709
  var strIsCookieUseDisabled = "isCookieUseDisabled";
1400
1710
  var strDisableCookiesUsage = "disableCookiesUsage";
1401
1711
  var strConfigCookieMgr = "_ckMgr";
1402
- var strEmpty = "";
1403
1712
  var _supportsCookies = null;
1404
1713
  var _allowUaSameSite = null;
1405
1714
  var _parsedCookieValue = null;
@@ -1558,7 +1867,7 @@
1558
1867
  _supportsCookies = doc[strCookie] !== undefined;
1559
1868
  }
1560
1869
  catch (e) {
1561
- logger && logger.throwInternal(LoggingSeverity.WARNING, _InternalMessageId.CannotAccessCookie, "Cannot access document.cookie - " + getExceptionName(e), { exception: dumpObj(e) });
1870
+ _throwInternal(logger, 2 , 68 , "Cannot access document.cookie - " + getExceptionName(e), { exception: dumpObj(e) });
1562
1871
  }
1563
1872
  }
1564
1873
  return _supportsCookies;
@@ -1637,86 +1946,286 @@
1637
1946
  return false;
1638
1947
  }
1639
1948
 
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) {
1949
+ var strExtensionConfig = "extensionConfig";
1950
+
1951
+ function createUnloadHandlerContainer() {
1952
+ var handlers = [];
1953
+ function _addHandler(handler) {
1954
+ if (handler) {
1955
+ handlers.push(handler);
1956
+ }
1659
1957
  }
1660
- }
1661
- function randomValue(maxValue) {
1662
- if (maxValue > 0) {
1663
- return Math.floor((random32() / MaxUInt32) * (maxValue + 1)) >>> 0;
1958
+ function _runHandlers(unloadCtx, unloadState) {
1959
+ arrForEach(handlers, function (handler) {
1960
+ try {
1961
+ handler(unloadCtx, unloadState);
1962
+ }
1963
+ catch (e) {
1964
+ _throwInternal(unloadCtx.diagLog(), 2 , 73 , "Unexpected error calling unload handler - " + dumpObj(e));
1965
+ }
1966
+ });
1967
+ handlers = [];
1664
1968
  }
1665
- return 0;
1969
+ return {
1970
+ add: _addHandler,
1971
+ run: _runHandlers
1972
+ };
1666
1973
  }
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();
1974
+
1975
+ var strGetPlugin = "getPlugin";
1976
+ var BaseTelemetryPlugin = /** @class */ (function () {
1977
+ function BaseTelemetryPlugin() {
1978
+ var _self = this;
1979
+ var _isinitialized;
1980
+ var _rootCtx;
1981
+ var _nextPlugin;
1982
+ var _unloadHandlerContainer;
1983
+ var _hooks;
1984
+ _initDefaults();
1985
+ dynamicProto(BaseTelemetryPlugin, _self, function (_self) {
1986
+ _self.initialize = function (config, core, extensions, pluginChain) {
1987
+ _setDefaults(config, core, pluginChain);
1988
+ _isinitialized = true;
1989
+ };
1990
+ _self.teardown = function (unloadCtx, unloadState) {
1991
+ if (!_self.core || (unloadCtx && _self.core !== unloadCtx.core())) {
1992
+ return;
1993
+ }
1994
+ var result;
1995
+ var unloadDone = false;
1996
+ var theUnloadCtx = unloadCtx || createProcessTelemetryUnloadContext(null, {}, _self.core, _nextPlugin && _nextPlugin[strGetPlugin] ? _nextPlugin[strGetPlugin]() : _nextPlugin);
1997
+ var theUnloadState = unloadState || {
1998
+ reason: 0 ,
1999
+ isAsync: false
2000
+ };
2001
+ function _unloadCallback() {
2002
+ if (!unloadDone) {
2003
+ unloadDone = true;
2004
+ _unloadHandlerContainer.run(theUnloadCtx, unloadState);
2005
+ arrForEach(_hooks, function (fn) {
2006
+ fn.rm();
2007
+ });
2008
+ _hooks = [];
2009
+ if (result === true) {
2010
+ theUnloadCtx.processNext(theUnloadState);
2011
+ }
2012
+ _initDefaults();
2013
+ }
2014
+ }
2015
+ if (!_self[strDoTeardown] || _self[strDoTeardown](theUnloadCtx, theUnloadState, _unloadCallback) !== true) {
2016
+ _unloadCallback();
2017
+ }
2018
+ else {
2019
+ result = true;
2020
+ }
2021
+ return result;
2022
+ };
2023
+ _self.update = function (updateCtx, updateState) {
2024
+ if (!_self.core || (updateCtx && _self.core !== updateCtx.core())) {
2025
+ return;
2026
+ }
2027
+ var result;
2028
+ var updateDone = false;
2029
+ var theUpdateCtx = updateCtx || createProcessTelemetryUpdateContext(null, {}, _self.core, _nextPlugin && _nextPlugin[strGetPlugin] ? _nextPlugin[strGetPlugin]() : _nextPlugin);
2030
+ var theUpdateState = updateState || {
2031
+ reason: 0
2032
+ };
2033
+ function _updateCallback() {
2034
+ if (!updateDone) {
2035
+ updateDone = true;
2036
+ _setDefaults(theUpdateCtx.getCfg(), theUpdateCtx.core(), theUpdateCtx.getNext());
2037
+ }
2038
+ }
2039
+ if (!_self._doUpdate || _self._doUpdate(theUpdateCtx, theUpdateState, _updateCallback) !== true) {
2040
+ _updateCallback();
2041
+ }
2042
+ else {
2043
+ result = true;
2044
+ }
2045
+ return result;
2046
+ };
2047
+ _self._addHook = function (hooks) {
2048
+ if (hooks) {
2049
+ if (isArray(hooks)) {
2050
+ _hooks = _hooks.concat(hooks);
2051
+ }
2052
+ else {
2053
+ _hooks.push(hooks);
2054
+ }
2055
+ }
2056
+ };
2057
+ proxyFunctionAs(_self, "_addUnloadCb", function () { return _unloadHandlerContainer; }, "add");
2058
+ });
2059
+ _self.diagLog = function (itemCtx) {
2060
+ return _getTelCtx(itemCtx).diagLog();
2061
+ };
2062
+ _self[strIsInitialized] = function () {
2063
+ return _isinitialized;
2064
+ };
2065
+ _self.setInitialized = function (isInitialized) {
2066
+ _isinitialized = isInitialized;
2067
+ };
2068
+ _self[strSetNextPlugin] = function (next) {
2069
+ _nextPlugin = next;
2070
+ };
2071
+ _self.processNext = function (env, itemCtx) {
2072
+ if (itemCtx) {
2073
+ itemCtx.processNext(env);
2074
+ }
2075
+ else if (_nextPlugin && isFunction(_nextPlugin.processTelemetry)) {
2076
+ _nextPlugin.processTelemetry(env, null);
2077
+ }
2078
+ };
2079
+ _self._getTelCtx = _getTelCtx;
2080
+ function _getTelCtx(currentCtx) {
2081
+ if (currentCtx === void 0) { currentCtx = null; }
2082
+ var itemCtx = currentCtx;
2083
+ if (!itemCtx) {
2084
+ var rootCtx = _rootCtx || createProcessTelemetryContext(null, {}, _self.core);
2085
+ if (_nextPlugin && _nextPlugin[strGetPlugin]) {
2086
+ itemCtx = rootCtx.createNew(null, _nextPlugin[strGetPlugin]);
2087
+ }
2088
+ else {
2089
+ itemCtx = rootCtx.createNew(null, _nextPlugin);
2090
+ }
2091
+ }
2092
+ return itemCtx;
2093
+ }
2094
+ function _setDefaults(config, core, pluginChain) {
2095
+ if (config) {
2096
+ setValue(config, strExtensionConfig, [], null, isNullOrUndefined);
2097
+ }
2098
+ if (!pluginChain && core) {
2099
+ pluginChain = core.getProcessTelContext().getNext();
2100
+ }
2101
+ var nextPlugin = _nextPlugin;
2102
+ if (_nextPlugin && _nextPlugin[strGetPlugin]) {
2103
+ nextPlugin = _nextPlugin[strGetPlugin]();
2104
+ }
2105
+ _self.core = core;
2106
+ _rootCtx = createProcessTelemetryContext(pluginChain, config, core, nextPlugin);
2107
+ }
2108
+ function _initDefaults() {
2109
+ _isinitialized = false;
2110
+ _self.core = null;
2111
+ _rootCtx = null;
2112
+ _nextPlugin = null;
2113
+ _hooks = [];
2114
+ _unloadHandlerContainer = createUnloadHandlerContainer();
1676
2115
  }
1677
- value = mwcRandom32() & MaxUInt32;
1678
- }
1679
- else {
1680
- value = Math.floor((UInt32Mask * Math.random()) | 0);
1681
2116
  }
1682
- if (!signed) {
1683
- value >>>= 0;
2117
+ return BaseTelemetryPlugin;
2118
+ }());
2119
+
2120
+ var strOnPrefix = "on";
2121
+ var strAttachEvent = "attachEvent";
2122
+ var strAddEventHelper = "addEventListener";
2123
+ var strEvents = "events";
2124
+ createUniqueNamespace("aiEvtPageHide");
2125
+ createUniqueNamespace("aiEvtPageShow");
2126
+ var rRemoveEmptyNs = /\.[\.]+/g;
2127
+ var rRemoveTrailingEmptyNs = /[\.]+$/;
2128
+ var _guid = 1;
2129
+ var elmNodeData = createElmNodeData("events");
2130
+ var eventNamespace = /^([^.]*)(?:\.(.+)|)/;
2131
+ function _normalizeNamespace(name) {
2132
+ if (name && name.replace) {
2133
+ return name.replace(/^\s*\.*|\.*\s*$/g, "");
2134
+ }
2135
+ return name;
2136
+ }
2137
+ function _getEvtNamespace(eventName, evtNamespace) {
2138
+ if (evtNamespace) {
2139
+ var theNamespace_1 = "";
2140
+ if (isArray(evtNamespace)) {
2141
+ theNamespace_1 = "";
2142
+ arrForEach(evtNamespace, function (name) {
2143
+ name = _normalizeNamespace(name);
2144
+ if (name) {
2145
+ if (name[0] !== ".") {
2146
+ name = "." + name;
2147
+ }
2148
+ theNamespace_1 += name;
2149
+ }
2150
+ });
2151
+ }
2152
+ else {
2153
+ theNamespace_1 = _normalizeNamespace(evtNamespace);
2154
+ }
2155
+ if (theNamespace_1) {
2156
+ if (theNamespace_1[0] !== ".") {
2157
+ theNamespace_1 = "." + theNamespace_1;
2158
+ }
2159
+ eventName = (eventName || "") + theNamespace_1;
2160
+ }
1684
2161
  }
1685
- return value;
2162
+ var parsedEvent = (eventNamespace.exec(eventName || "") || []);
2163
+ return {
2164
+ type: parsedEvent[1],
2165
+ ns: ((parsedEvent[2] || "").replace(rRemoveEmptyNs, ".").replace(rRemoveTrailingEmptyNs, "").split(".").sort()).join(".")
2166
+ };
1686
2167
  }
1687
- function mwcRandomSeed(value) {
1688
- if (!value) {
1689
- _autoSeedMwc();
2168
+ function _getRegisteredEvents(target, evtName, addDefault) {
2169
+ if (addDefault === void 0) { addDefault = true; }
2170
+ var aiEvts = elmNodeData.get(target, strEvents, {}, addDefault);
2171
+ var registeredEvents = aiEvts[evtName];
2172
+ if (!registeredEvents) {
2173
+ registeredEvents = aiEvts[evtName] = [];
1690
2174
  }
1691
- else {
1692
- _mwcSeed(value);
2175
+ return registeredEvents;
2176
+ }
2177
+ function _doAttach(obj, evtName, handlerRef, useCapture) {
2178
+ var result = false;
2179
+ if (obj && evtName && evtName.type && handlerRef) {
2180
+ if (obj[strAddEventHelper]) {
2181
+ obj[strAddEventHelper](evtName.type, handlerRef, useCapture);
2182
+ result = true;
2183
+ }
2184
+ else if (obj[strAttachEvent]) {
2185
+ obj[strAttachEvent](strOnPrefix + evtName.type, handlerRef);
2186
+ result = true;
2187
+ }
1693
2188
  }
2189
+ return result;
1694
2190
  }
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;
2191
+ function eventOn(target, eventName, handlerRef, evtNamespace, useCapture) {
2192
+ if (useCapture === void 0) { useCapture = false; }
2193
+ var result = false;
2194
+ if (target) {
2195
+ try {
2196
+ var evtName = _getEvtNamespace(eventName, evtNamespace);
2197
+ result = _doAttach(target, evtName, handlerRef, useCapture);
2198
+ if (result && elmNodeData.accept(target)) {
2199
+ var registeredEvent = {
2200
+ guid: _guid++,
2201
+ evtName: evtName,
2202
+ handler: handlerRef,
2203
+ capture: useCapture
2204
+ };
2205
+ _getRegisteredEvents(target, evtName.type).push(registeredEvent);
2206
+ }
2207
+ }
2208
+ catch (e) {
2209
+ }
1701
2210
  }
1702
- return value;
2211
+ return result;
1703
2212
  }
1704
-
1705
- var _cookieMgrs = null;
1706
- var _canUseCookies;
1707
- function addEventHandler(eventName, callback) {
2213
+ function addEventHandler(eventName, callback, evtNamespace) {
1708
2214
  var result = false;
1709
2215
  var w = getWindow();
1710
2216
  if (w) {
1711
- result = attachEvent(w, eventName, callback);
1712
- result = attachEvent(w["body"], eventName, callback) || result;
2217
+ result = eventOn(w, eventName, callback, evtNamespace);
2218
+ result = eventOn(w["body"], eventName, callback, evtNamespace) || result;
1713
2219
  }
1714
2220
  var doc = getDocument();
1715
2221
  if (doc) {
1716
- result = attachEvent(doc, eventName, callback) || result;
2222
+ result = eventOn(doc, eventName, callback, evtNamespace) || result;
1717
2223
  }
1718
2224
  return result;
1719
2225
  }
2226
+
2227
+ var _cookieMgrs = null;
2228
+ var _canUseCookies;
1720
2229
  function newGuid() {
1721
2230
  function randomHexDigit() {
1722
2231
  return randomValue(15);
@@ -1733,26 +2242,9 @@
1733
2242
  }
1734
2243
  return dateNow();
1735
2244
  }
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
2245
  function generateW3CId() {
1754
2246
  var hexValues = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f"];
1755
- var oct = "", tmp;
2247
+ var oct = strEmpty, tmp;
1756
2248
  for (var a = 0; a < 4; a++) {
1757
2249
  tmp = random32();
1758
2250
  oct +=
@@ -1835,101 +2327,183 @@
1835
2327
  _legacyCookieMgr().setEnabled(false);
1836
2328
  }
1837
2329
 
2330
+ var LoggingSeverity = createEnumStyle({
2331
+ CRITICAL: 1 ,
2332
+ WARNING: 2
2333
+ });
2334
+ var _InternalMessageId = createEnumStyle({
2335
+ BrowserDoesNotSupportLocalStorage: 0 ,
2336
+ BrowserCannotReadLocalStorage: 1 ,
2337
+ BrowserCannotReadSessionStorage: 2 ,
2338
+ BrowserCannotWriteLocalStorage: 3 ,
2339
+ BrowserCannotWriteSessionStorage: 4 ,
2340
+ BrowserFailedRemovalFromLocalStorage: 5 ,
2341
+ BrowserFailedRemovalFromSessionStorage: 6 ,
2342
+ CannotSendEmptyTelemetry: 7 ,
2343
+ ClientPerformanceMathError: 8 ,
2344
+ ErrorParsingAISessionCookie: 9 ,
2345
+ ErrorPVCalc: 10 ,
2346
+ ExceptionWhileLoggingError: 11 ,
2347
+ FailedAddingTelemetryToBuffer: 12 ,
2348
+ FailedMonitorAjaxAbort: 13 ,
2349
+ FailedMonitorAjaxDur: 14 ,
2350
+ FailedMonitorAjaxOpen: 15 ,
2351
+ FailedMonitorAjaxRSC: 16 ,
2352
+ FailedMonitorAjaxSend: 17 ,
2353
+ FailedMonitorAjaxGetCorrelationHeader: 18 ,
2354
+ FailedToAddHandlerForOnBeforeUnload: 19 ,
2355
+ FailedToSendQueuedTelemetry: 20 ,
2356
+ FailedToReportDataLoss: 21 ,
2357
+ FlushFailed: 22 ,
2358
+ MessageLimitPerPVExceeded: 23 ,
2359
+ MissingRequiredFieldSpecification: 24 ,
2360
+ NavigationTimingNotSupported: 25 ,
2361
+ OnError: 26 ,
2362
+ SessionRenewalDateIsZero: 27 ,
2363
+ SenderNotInitialized: 28 ,
2364
+ StartTrackEventFailed: 29 ,
2365
+ StopTrackEventFailed: 30 ,
2366
+ StartTrackFailed: 31 ,
2367
+ StopTrackFailed: 32 ,
2368
+ TelemetrySampledAndNotSent: 33 ,
2369
+ TrackEventFailed: 34 ,
2370
+ TrackExceptionFailed: 35 ,
2371
+ TrackMetricFailed: 36 ,
2372
+ TrackPVFailed: 37 ,
2373
+ TrackPVFailedCalc: 38 ,
2374
+ TrackTraceFailed: 39 ,
2375
+ TransmissionFailed: 40 ,
2376
+ FailedToSetStorageBuffer: 41 ,
2377
+ FailedToRestoreStorageBuffer: 42 ,
2378
+ InvalidBackendResponse: 43 ,
2379
+ FailedToFixDepricatedValues: 44 ,
2380
+ InvalidDurationValue: 45 ,
2381
+ TelemetryEnvelopeInvalid: 46 ,
2382
+ CreateEnvelopeError: 47 ,
2383
+ CannotSerializeObject: 48 ,
2384
+ CannotSerializeObjectNonSerializable: 49 ,
2385
+ CircularReferenceDetected: 50 ,
2386
+ ClearAuthContextFailed: 51 ,
2387
+ ExceptionTruncated: 52 ,
2388
+ IllegalCharsInName: 53 ,
2389
+ ItemNotInArray: 54 ,
2390
+ MaxAjaxPerPVExceeded: 55 ,
2391
+ MessageTruncated: 56 ,
2392
+ NameTooLong: 57 ,
2393
+ SampleRateOutOfRange: 58 ,
2394
+ SetAuthContextFailed: 59 ,
2395
+ SetAuthContextFailedAccountName: 60 ,
2396
+ StringValueTooLong: 61 ,
2397
+ StartCalledMoreThanOnce: 62 ,
2398
+ StopCalledWithoutStart: 63 ,
2399
+ TelemetryInitializerFailed: 64 ,
2400
+ TrackArgumentsNotSpecified: 65 ,
2401
+ UrlTooLong: 66 ,
2402
+ SessionStorageBufferFull: 67 ,
2403
+ CannotAccessCookie: 68 ,
2404
+ IdTooLong: 69 ,
2405
+ InvalidEvent: 70 ,
2406
+ FailedMonitorAjaxSetRequestHeader: 71 ,
2407
+ SendBrowserInfoOnUserInit: 72 ,
2408
+ PluginException: 73 ,
2409
+ NotificationException: 74 ,
2410
+ SnippetScriptLoadFailure: 99 ,
2411
+ InvalidInstrumentationKey: 100 ,
2412
+ CannotParseAiBlobValue: 101 ,
2413
+ InvalidContentBlob: 102 ,
2414
+ TrackPageActionEventFailed: 103 ,
2415
+ FailedAddingCustomDefinedRequestContext: 104 ,
2416
+ InMemoryStorageBufferFull: 105
2417
+ });
2418
+
1838
2419
  var ReactPlugin = /** @class */ (function (_super) {
1839
2420
  __extendsFn(ReactPlugin, _super);
1840
2421
  function ReactPlugin() {
1841
- var _this = _super !== null && _super.apply(this, arguments) || this;
2422
+ var _this = _super.call(this) || this;
1842
2423
  _this.priority = 185;
1843
2424
  _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;
2425
+ var _analyticsPlugin;
2426
+ var _extensionConfig;
2427
+ var _unlisten;
2428
+ var _pageViewTimer;
2429
+ dynamicProto(ReactPlugin, _this, function (_self, _base) {
2430
+ _initDefaults();
2431
+ _self.initialize = function (config, core, extensions, pluginChain) {
2432
+ _super.prototype.initialize.call(_this, config, core, extensions, pluginChain);
2433
+ _extensionConfig =
2434
+ config.extensionConfig && config.extensionConfig[_self.identifier]
2435
+ ? config.extensionConfig[_self.identifier]
2436
+ : { history: null };
2437
+ arrForEach(extensions, function (ext) {
2438
+ var identifier = ext.identifier;
2439
+ if (identifier === 'ApplicationInsightsAnalytics') {
2440
+ _analyticsPlugin = ext;
2441
+ }
2442
+ });
2443
+ if (_extensionConfig.history) {
2444
+ _addHistoryListener(_extensionConfig.history);
2445
+ var pageViewTelemetry = {
2446
+ uri: _extensionConfig.history.location.pathname
2447
+ };
2448
+ _self.trackPageView(pageViewTelemetry);
2449
+ }
2450
+ };
2451
+ _self.getCookieMgr = function () {
2452
+ return safeGetCookieMgr(_self.core);
2453
+ };
2454
+ _self.getAppInsights = _getAnalytics;
2455
+ _self.processTelemetry = function (event, itemCtx) {
2456
+ _self.processNext(event, itemCtx);
2457
+ };
2458
+ _self._doTeardown = function (unloadCtx, unloadState, asyncCallback) {
2459
+ if (isFunction(_unlisten)) {
2460
+ _unlisten();
2461
+ }
2462
+ if (_pageViewTimer) {
2463
+ clearTimeout(_pageViewTimer);
2464
+ }
2465
+ _initDefaults();
2466
+ };
2467
+ proxyFunctions(_self, _getAnalytics, [
2468
+ "trackMetric",
2469
+ "trackPageView",
2470
+ "trackEvent",
2471
+ "trackException",
2472
+ "trackTrace",
2473
+ ]);
2474
+ function _initDefaults() {
2475
+ _analyticsPlugin = null;
2476
+ _extensionConfig = null;
2477
+ _unlisten = null;
2478
+ _pageViewTimer = null;
2479
+ }
2480
+ function _getAnalytics() {
2481
+ if (!_analyticsPlugin) {
2482
+ _self.diagLog().throwInternal(LoggingSeverity.CRITICAL, _InternalMessageId.TelemetryInitializerFailed, "Analytics plugin is not available, React plugin telemetry will not be sent: ");
2483
+ }
2484
+ return _analyticsPlugin;
1857
2485
  }
2486
+ function _addHistoryListener(history) {
2487
+ var locationListener = function (arg) {
2488
+ var locn = null;
2489
+ if ("location" in arg) {
2490
+ locn = arg["location"];
2491
+ }
2492
+ else {
2493
+ locn = arg;
2494
+ }
2495
+ _pageViewTimer = setTimeout(function () {
2496
+ _pageViewTimer = null;
2497
+ var pageViewTelemetry = { uri: locn.pathname };
2498
+ _self.trackPageView(pageViewTelemetry);
2499
+ }, 500);
2500
+ };
2501
+ _unlisten = history.listen(locationListener);
2502
+ }
2503
+ objDefineAccessors(_self, "_extensionConfig", function () { return _extensionConfig; });
1858
2504
  });
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
- };
2505
+ return _this;
2506
+ }
1933
2507
  return ReactPlugin;
1934
2508
  }(BaseTelemetryPlugin));
1935
2509
  var ReactPlugin$1 = ReactPlugin;
@@ -2076,7 +2650,7 @@
2076
2650
  trackedData.idleCount * trackedData.idleTimeout) /
2077
2651
  1000);
2078
2652
  }
2079
- var useComponentTracking = function (reactPlugin, componentName) {
2653
+ var useComponentTracking = function (reactPlugin, componentName, customProperties) {
2080
2654
  var tracking = React.useRef({
2081
2655
  hookTimestamp: dateNow(),
2082
2656
  firstActiveTimestamp: 0,
@@ -2115,7 +2689,7 @@
2115
2689
  name: "React Component Engaged Time (seconds)",
2116
2690
  sampleCount: 1
2117
2691
  };
2118
- var additionalProperties = { "Component Name": componentName };
2692
+ var additionalProperties = __assignFn({ "Component Name": componentName }, customProperties);
2119
2693
  reactPlugin.trackMetric(metricData, additionalProperties);
2120
2694
  };
2121
2695
  }, []);