@microsoft/applicationinsights-react-js 3.2.5-nightly.2204-03 → 3.2.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * Application Insights JavaScript SDK - React Plugin, 3.2.5-nightly.2204-03
2
+ * Application Insights JavaScript SDK - React Plugin, 3.2.6
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  */
5
5
  (function (global, factory) {
@@ -98,9 +98,7 @@
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) {
102
- d.__proto__ = b;
103
- }) ||
101
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
104
102
  function (d, b) {
105
103
  for (var p in b) {
106
104
  if (b[strShimHasOwnProperty](p)) {
@@ -115,14 +113,12 @@
115
113
  throwTypeError("Class extends value " + String(b) + " is not a constructor or null");
116
114
  }
117
115
  extendStaticsFn(d, b);
118
- function __() {
119
- this.constructor = d;
120
- }
116
+ function __() { this.constructor = d; }
121
117
  d[strShimPrototype] = b === null ? objCreateFn(b) : (__[strShimPrototype] = b[strShimPrototype], new __());
122
118
  }
123
119
 
124
120
  /*!
125
- * Microsoft Dynamic Proto Utility, 1.1.4
121
+ * Microsoft Dynamic Proto Utility, 1.1.6
126
122
  * Copyright (c) Microsoft and contributors. All rights reserved.
127
123
  */
128
124
  var Constructor = 'constructor';
@@ -136,11 +132,14 @@
136
132
  var DynAllowInstChkTag = DynInstChkTag;
137
133
  var DynProtoDefaultOptions = '_dfOpts';
138
134
  var UnknownValue = '_unknown_';
139
- var str__Proto$1 = "__proto__";
135
+ var str__Proto = "__proto__";
136
+ var DynProtoBaseProto = "_dyn" + str__Proto;
137
+ var DynProtoCurrent = "_dynInstProto";
140
138
  var strUseBaseInst = 'useBaseInst';
141
139
  var strSetInstFuncs = 'setInstFuncs';
142
140
  var Obj = Object;
143
- var _objGetPrototypeOf$1 = Obj["getPrototypeOf"];
141
+ var _objGetPrototypeOf = Obj["getPrototypeOf"];
142
+ var _objGetOwnProps = Obj["getOwnPropertyNames"];
144
143
  var _dynamicNames = 0;
145
144
  function _hasOwnProperty(obj, prop) {
146
145
  return obj && Obj[Prototype].hasOwnProperty.call(obj, prop);
@@ -151,23 +150,26 @@
151
150
  function _isObjectArrayOrFunctionPrototype(target) {
152
151
  return _isObjectOrArrayPrototype(target) || target === Function[Prototype];
153
152
  }
154
- function _getObjProto$1(target) {
153
+ function _getObjProto(target) {
154
+ var newProto;
155
155
  if (target) {
156
- if (_objGetPrototypeOf$1) {
157
- return _objGetPrototypeOf$1(target);
156
+ if (_objGetPrototypeOf) {
157
+ return _objGetPrototypeOf(target);
158
158
  }
159
- var newProto = target[str__Proto$1] || target[Prototype] || (target[Constructor] ? target[Constructor][Prototype] : null);
160
- if (newProto) {
161
- return newProto;
159
+ var curProto = target[str__Proto] || target[Prototype] || (target[Constructor] ? target[Constructor][Prototype] : null);
160
+ newProto = target[DynProtoBaseProto] || curProto;
161
+ if (!_hasOwnProperty(target, DynProtoBaseProto)) {
162
+ delete target[DynProtoCurrent];
163
+ newProto = target[DynProtoBaseProto] = target[DynProtoCurrent] || target[DynProtoBaseProto];
164
+ target[DynProtoCurrent] = curProto;
162
165
  }
163
166
  }
164
- return null;
167
+ return newProto;
165
168
  }
166
169
  function _forEachProp(target, func) {
167
170
  var props = [];
168
- var getOwnProps = Obj["getOwnPropertyNames"];
169
- if (getOwnProps) {
170
- props = getOwnProps(target);
171
+ if (_objGetOwnProps) {
172
+ props = _objGetOwnProps(target);
171
173
  }
172
174
  else {
173
175
  for (var name_1 in target) {
@@ -222,16 +224,16 @@
222
224
  _forEachProp(instFuncs, function (name) {
223
225
  baseFuncs[name] = _instFuncProxy(thisTarget, instFuncs, name);
224
226
  });
225
- var baseProto = _getObjProto$1(classProto);
227
+ var baseProto = _getObjProto(classProto);
226
228
  var visited = [];
227
229
  while (baseProto && !_isObjectArrayOrFunctionPrototype(baseProto) && !_hasVisited(visited, baseProto)) {
228
230
  _forEachProp(baseProto, function (name) {
229
- if (!baseFuncs[name] && _isDynamicCandidate(baseProto, name, !_objGetPrototypeOf$1)) {
231
+ if (!baseFuncs[name] && _isDynamicCandidate(baseProto, name, !_objGetPrototypeOf)) {
230
232
  baseFuncs[name] = _instFuncProxy(thisTarget, baseProto, name);
231
233
  }
232
234
  });
233
235
  visited.push(baseProto);
234
- baseProto = _getObjProto$1(baseProto);
236
+ baseProto = _getObjProto(baseProto);
235
237
  }
236
238
  return baseFuncs;
237
239
  }
@@ -245,7 +247,7 @@
245
247
  }
246
248
  if (!instFunc[DynInstChkTag] && instFuncTable[DynAllowInstChkTag] !== false) {
247
249
  var canAddInst = !_hasOwnProperty(target, funcName);
248
- var objProto = _getObjProto$1(target);
250
+ var objProto = _getObjProto(target);
249
251
  var visited = [];
250
252
  while (canAddInst && objProto && !_isObjectArrayOrFunctionPrototype(objProto) && !_hasVisited(visited, objProto)) {
251
253
  var protoFunc = objProto[funcName];
@@ -254,7 +256,7 @@
254
256
  break;
255
257
  }
256
258
  visited.push(objProto);
257
- objProto = _getObjProto$1(objProto);
259
+ objProto = _getObjProto(objProto);
258
260
  }
259
261
  try {
260
262
  if (canAddInst) {
@@ -272,7 +274,7 @@
272
274
  function _getProtoFunc(funcName, proto, currentDynProtoProxy) {
273
275
  var protoFunc = proto[funcName];
274
276
  if (protoFunc === currentDynProtoProxy) {
275
- protoFunc = _getObjProto$1(proto)[funcName];
277
+ protoFunc = _getObjProto(proto)[funcName];
276
278
  }
277
279
  if (typeof protoFunc !== strFunction) {
278
280
  _throwTypeError("[" + funcName + "] is not a " + strFunction);
@@ -306,18 +308,19 @@
306
308
  }
307
309
  }
308
310
  function _checkPrototype(classProto, thisTarget) {
309
- if (_objGetPrototypeOf$1) {
311
+ if (_objGetPrototypeOf) {
310
312
  var visited = [];
311
- var thisProto = _getObjProto$1(thisTarget);
313
+ var thisProto = _getObjProto(thisTarget);
312
314
  while (thisProto && !_isObjectArrayOrFunctionPrototype(thisProto) && !_hasVisited(visited, thisProto)) {
313
315
  if (thisProto === classProto) {
314
316
  return true;
315
317
  }
316
318
  visited.push(thisProto);
317
- thisProto = _getObjProto$1(thisProto);
319
+ thisProto = _getObjProto(thisProto);
318
320
  }
321
+ return false;
319
322
  }
320
- return false;
323
+ return true;
321
324
  }
322
325
  function _getObjName(target, unknownValue) {
323
326
  if (_hasOwnProperty(target, Prototype)) {
@@ -350,7 +353,7 @@
350
353
  var instFuncs = _getInstanceFuncs(target);
351
354
  var baseFuncs = _getBaseFuncs(classProto, target, instFuncs, useBaseInst);
352
355
  delegateFunc(target, baseFuncs);
353
- var setInstanceFunc = !!_objGetPrototypeOf$1 && !!perfOptions[strSetInstFuncs];
356
+ var setInstanceFunc = !!_objGetPrototypeOf && !!perfOptions[strSetInstFuncs];
354
357
  if (setInstanceFunc && options) {
355
358
  setInstanceFunc = !!options[strSetInstFuncs];
356
359
  }
@@ -362,15 +365,99 @@
362
365
  };
363
366
  dynamicProto[DynProtoDefaultOptions] = perfDefaults;
364
367
 
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";
368
+ var LoggingSeverity;
369
+ (function (LoggingSeverity) {
370
+ LoggingSeverity[LoggingSeverity["CRITICAL"] = 1] = "CRITICAL";
371
+ LoggingSeverity[LoggingSeverity["WARNING"] = 2] = "WARNING";
372
+ })(LoggingSeverity || (LoggingSeverity = {}));
373
+ var _InternalMessageId = {
374
+ BrowserDoesNotSupportLocalStorage: 0,
375
+ BrowserCannotReadLocalStorage: 1,
376
+ BrowserCannotReadSessionStorage: 2,
377
+ BrowserCannotWriteLocalStorage: 3,
378
+ BrowserCannotWriteSessionStorage: 4,
379
+ BrowserFailedRemovalFromLocalStorage: 5,
380
+ BrowserFailedRemovalFromSessionStorage: 6,
381
+ CannotSendEmptyTelemetry: 7,
382
+ ClientPerformanceMathError: 8,
383
+ ErrorParsingAISessionCookie: 9,
384
+ ErrorPVCalc: 10,
385
+ ExceptionWhileLoggingError: 11,
386
+ FailedAddingTelemetryToBuffer: 12,
387
+ FailedMonitorAjaxAbort: 13,
388
+ FailedMonitorAjaxDur: 14,
389
+ FailedMonitorAjaxOpen: 15,
390
+ FailedMonitorAjaxRSC: 16,
391
+ FailedMonitorAjaxSend: 17,
392
+ FailedMonitorAjaxGetCorrelationHeader: 18,
393
+ FailedToAddHandlerForOnBeforeUnload: 19,
394
+ FailedToSendQueuedTelemetry: 20,
395
+ FailedToReportDataLoss: 21,
396
+ FlushFailed: 22,
397
+ MessageLimitPerPVExceeded: 23,
398
+ MissingRequiredFieldSpecification: 24,
399
+ NavigationTimingNotSupported: 25,
400
+ OnError: 26,
401
+ SessionRenewalDateIsZero: 27,
402
+ SenderNotInitialized: 28,
403
+ StartTrackEventFailed: 29,
404
+ StopTrackEventFailed: 30,
405
+ StartTrackFailed: 31,
406
+ StopTrackFailed: 32,
407
+ TelemetrySampledAndNotSent: 33,
408
+ TrackEventFailed: 34,
409
+ TrackExceptionFailed: 35,
410
+ TrackMetricFailed: 36,
411
+ TrackPVFailed: 37,
412
+ TrackPVFailedCalc: 38,
413
+ TrackTraceFailed: 39,
414
+ TransmissionFailed: 40,
415
+ FailedToSetStorageBuffer: 41,
416
+ FailedToRestoreStorageBuffer: 42,
417
+ InvalidBackendResponse: 43,
418
+ FailedToFixDepricatedValues: 44,
419
+ InvalidDurationValue: 45,
420
+ TelemetryEnvelopeInvalid: 46,
421
+ CreateEnvelopeError: 47,
422
+ CannotSerializeObject: 48,
423
+ CannotSerializeObjectNonSerializable: 49,
424
+ CircularReferenceDetected: 50,
425
+ ClearAuthContextFailed: 51,
426
+ ExceptionTruncated: 52,
427
+ IllegalCharsInName: 53,
428
+ ItemNotInArray: 54,
429
+ MaxAjaxPerPVExceeded: 55,
430
+ MessageTruncated: 56,
431
+ NameTooLong: 57,
432
+ SampleRateOutOfRange: 58,
433
+ SetAuthContextFailed: 59,
434
+ SetAuthContextFailedAccountName: 60,
435
+ StringValueTooLong: 61,
436
+ StartCalledMoreThanOnce: 62,
437
+ StopCalledWithoutStart: 63,
438
+ TelemetryInitializerFailed: 64,
439
+ TrackArgumentsNotSpecified: 65,
440
+ UrlTooLong: 66,
441
+ SessionStorageBufferFull: 67,
442
+ CannotAccessCookie: 68,
443
+ IdTooLong: 69,
444
+ InvalidEvent: 70,
445
+ FailedMonitorAjaxSetRequestHeader: 71,
446
+ SendBrowserInfoOnUserInit: 72,
447
+ PluginException: 73,
448
+ NotificationException: 74,
449
+ SnippetScriptLoadFailure: 99,
450
+ InvalidInstrumentationKey: 100,
451
+ CannotParseAiBlobValue: 101,
452
+ InvalidContentBlob: 102,
453
+ TrackPageActionEventFailed: 103,
454
+ FailedAddingCustomDefinedRequestContext: 104,
455
+ InMemoryStorageBufferFull: 105
456
+ };
373
457
 
458
+ var strOnPrefix = "on";
459
+ var strAttachEvent = "attachEvent";
460
+ var strAddEventHelper = "addEventListener";
374
461
  var strToISOString = "toISOString";
375
462
  var cStrEndsWith = "endsWith";
376
463
  var strIndexOf = "indexOf";
@@ -378,10 +465,7 @@
378
465
  var strReduce = "reduce";
379
466
  var cStrTrim = "trim";
380
467
  var strToString = "toString";
381
- var str__Proto = "__proto__";
382
- var strConstructor = "constructor";
383
- var _objDefineProperty$1 = ObjDefineProperty;
384
- var _objFreeze = ObjClass.freeze;
468
+ var _objDefineProperty = ObjDefineProperty;
385
469
  var _objKeys = ObjClass.keys;
386
470
  var StringProto = String[strShimPrototype];
387
471
  var _strTrim = StringProto[cStrTrim];
@@ -391,23 +475,7 @@
391
475
  var _isArray = Array.isArray;
392
476
  var _objToString = ObjProto[strToString];
393
477
  var _fnToString = ObjHasOwnProperty[strToString];
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
- }
478
+ _fnToString.call(ObjClass);
411
479
  function isTypeof(value, theType) {
412
480
  return typeof value === theType;
413
481
  }
@@ -429,18 +497,24 @@
429
497
  function isFunction(value) {
430
498
  return !!(value && typeof value === strShimFunction);
431
499
  }
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
- });
500
+ function attachEvent(obj, eventNameWithoutOn, handlerRef, useCapture) {
501
+ if (useCapture === void 0) { useCapture = false; }
502
+ var result = false;
503
+ if (!isNullOrUndefined(obj)) {
504
+ try {
505
+ if (!isNullOrUndefined(obj[strAddEventHelper])) {
506
+ obj[strAddEventHelper](eventNameWithoutOn, handlerRef, useCapture);
507
+ result = true;
508
+ }
509
+ else if (!isNullOrUndefined(obj[strAttachEvent])) {
510
+ obj[strAttachEvent](strOnPrefix + eventNameWithoutOn, handlerRef);
511
+ result = true;
512
+ }
513
+ }
514
+ catch (e) {
515
+ }
442
516
  }
443
- return value;
517
+ return result;
444
518
  }
445
519
  function objForEachKey(target, callbackfn) {
446
520
  if (target) {
@@ -499,22 +573,6 @@
499
573
  function isBoolean(value) {
500
574
  return typeof value === "boolean";
501
575
  }
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
- }
518
576
  function toISOString(date) {
519
577
  if (date) {
520
578
  return _dataToISOString ? date[strToISOString]() : _toISOStringPoly(date);
@@ -660,7 +718,7 @@
660
718
  return result;
661
719
  }
662
720
  function objDefineAccessors(target, prop, getProp, setProp) {
663
- if (_objDefineProperty$1) {
721
+ if (_objDefineProperty) {
664
722
  try {
665
723
  var descriptor = {
666
724
  enumerable: true,
@@ -672,7 +730,7 @@
672
730
  if (setProp) {
673
731
  descriptor.set = setProp;
674
732
  }
675
- _objDefineProperty$1(target, prop, descriptor);
733
+ _objDefineProperty(target, prop, descriptor);
676
734
  return true;
677
735
  }
678
736
  catch (e) {
@@ -680,10 +738,6 @@
680
738
  }
681
739
  return false;
682
740
  }
683
- function _doNothing(value) {
684
- return value;
685
- }
686
- var objFreeze = _objFreeze || _doNothing;
687
741
  function dateNow() {
688
742
  var dt = Date;
689
743
  return dt.now ? dt.now() : new dt().getTime();
@@ -692,7 +746,7 @@
692
746
  if (isError(object)) {
693
747
  return object.name;
694
748
  }
695
- return strEmpty;
749
+ return "";
696
750
  }
697
751
  function setValue(target, field, value, valChk, srcChk) {
698
752
  var theValue = value;
@@ -708,102 +762,6 @@
708
762
  function isTruthy(value) {
709
763
  return !!value;
710
764
  }
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
- }
807
765
 
808
766
  var strWindow = "window";
809
767
  var strDocument = "document";
@@ -896,14 +854,14 @@
896
854
  var nav = getNavigator();
897
855
  if (nav && (nav.userAgent !== _navUserAgentCheck || _isTrident === null)) {
898
856
  _navUserAgentCheck = nav.userAgent;
899
- var userAgent = (_navUserAgentCheck || strEmpty).toLowerCase();
857
+ var userAgent = (_navUserAgentCheck || "").toLowerCase();
900
858
  _isTrident = (strContains(userAgent, strMsie) || strContains(userAgent, strTrident));
901
859
  }
902
860
  return _isTrident;
903
861
  }
904
862
  function dumpObj(object) {
905
863
  var objectTypeDump = Object[strShimPrototype].toString.call(object);
906
- var propertyValueDump = strEmpty;
864
+ var propertyValueDump = "";
907
865
  if (objectTypeDump === "[object Error]") {
908
866
  propertyValueDump = "{ stack: '" + object.stack + "', message: '" + object.message + "', name: '" + object.name + "'";
909
867
  }
@@ -936,9 +894,9 @@
936
894
  var strWarnToConsole = "warnToConsole";
937
895
  function _sanitizeDiagnosticText(text) {
938
896
  if (text) {
939
- return "\"" + text.replace(/\"/g, strEmpty) + "\"";
897
+ return "\"" + text.replace(/\"/g, "") + "\"";
940
898
  }
941
- return strEmpty;
899
+ return "";
942
900
  }
943
901
  function _logToConsole(func, message) {
944
902
  var theConsole = getConsole();
@@ -960,12 +918,12 @@
960
918
  _self.message =
961
919
  (isUserAct ? AiUserActionablePrefix : AiNonUserActionablePrefix) +
962
920
  msgId;
963
- var strProps = strEmpty;
921
+ var strProps = "";
964
922
  if (hasJSON()) {
965
923
  strProps = getJSON().stringify(properties);
966
924
  }
967
- var diagnosticText = (msg ? " message:" + _sanitizeDiagnosticText(msg) : strEmpty) +
968
- (properties ? " props:" + _sanitizeDiagnosticText(strProps) : strEmpty);
925
+ var diagnosticText = (msg ? " message:" + _sanitizeDiagnosticText(msg) : "") +
926
+ (properties ? " props:" + _sanitizeDiagnosticText(strProps) : "");
969
927
  _self.message += diagnosticText;
970
928
  }
971
929
  _InternalLogMessage.dataType = "MessageData";
@@ -992,10 +950,10 @@
992
950
  if (isUserAct === void 0) { isUserAct = false; }
993
951
  var message = new _InternalLogMessage(msgId, msg, isUserAct, properties);
994
952
  if (_self.enableDebugExceptions()) {
995
- throw message;
953
+ throw dumpObj(message);
996
954
  }
997
955
  else {
998
- var logFunc = severity === 1 ? strErrorToConsole : strWarnToConsole;
956
+ var logFunc = severity === LoggingSeverity.CRITICAL ? strErrorToConsole : strWarnToConsole;
999
957
  if (!isUndefined(message.message)) {
1000
958
  var logLevel = _self.consoleLoggingLevel();
1001
959
  if (isUserAct) {
@@ -1013,7 +971,7 @@
1013
971
  _self.logInternalMessage(severity, message);
1014
972
  }
1015
973
  else {
1016
- _debugExtMsg("throw" + (severity === 1 ? "Critical" : "Warning"), message);
974
+ _debugExtMsg("throw" + (severity === LoggingSeverity.CRITICAL ? "Critical" : "Warning"), message);
1017
975
  }
1018
976
  }
1019
977
  };
@@ -1045,13 +1003,13 @@
1045
1003
  if (severity <= _self.telemetryLoggingLevel()) {
1046
1004
  _self.queue.push(message);
1047
1005
  _messageCount++;
1048
- _debugExtMsg((severity === 1 ? "error" : "warn"), message);
1006
+ _debugExtMsg((severity === LoggingSeverity.CRITICAL ? "error" : "warn"), message);
1049
1007
  }
1050
1008
  if (_messageCount === _self.maxInternalMessageLimit()) {
1051
1009
  var throttleLimitMessage = "Internal events throttle limit per PageView reached for this app.";
1052
- var throttleMessage = new _InternalLogMessage(23 , throttleLimitMessage, false);
1010
+ var throttleMessage = new _InternalLogMessage(_InternalMessageId.MessageLimitPerPVExceeded, throttleLimitMessage, false);
1053
1011
  _self.queue.push(throttleMessage);
1054
- if (severity === 1 ) {
1012
+ if (severity === LoggingSeverity.CRITICAL) {
1055
1013
  _self.errorToConsole(throttleLimitMessage);
1056
1014
  }
1057
1015
  else {
@@ -1080,10 +1038,6 @@
1080
1038
  }
1081
1039
  return DiagnosticLogger;
1082
1040
  }());
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
- }
1087
1041
 
1088
1042
  var strExecutionContextKey = "ctx";
1089
1043
  var PerfEvent = /** @class */ (function () {
@@ -1197,509 +1151,252 @@
1197
1151
  return func();
1198
1152
  }
1199
1153
 
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.7.5-nightly.2204-03";
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;
1338
- }
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
- }
1154
+ var TelemetryPluginChain = /** @class */ (function () {
1155
+ function TelemetryPluginChain(plugin, defItemCtx) {
1156
+ var _self = this;
1157
+ var _nextProxy = null;
1158
+ var _hasProcessTelemetry = isFunction(plugin.processTelemetry);
1159
+ var _hasSetNext = isFunction(plugin.setNextPlugin);
1160
+ _self._hasRun = false;
1161
+ _self.getPlugin = function () {
1162
+ return plugin;
1163
+ };
1164
+ _self.getNext = function () {
1165
+ return _nextProxy;
1166
+ };
1167
+ _self.setNext = function (nextPlugin) {
1168
+ _nextProxy = nextPlugin;
1169
+ };
1170
+ _self.processTelemetry = function (env, itemCtx) {
1171
+ if (!itemCtx) {
1172
+ itemCtx = defItemCtx;
1348
1173
  }
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) {
1174
+ var identifier = plugin ? plugin.identifier : "TelemetryPluginChain";
1175
+ doPerf(itemCtx ? itemCtx.core() : null, function () { return identifier + ":processTelemetry"; }, function () {
1176
+ if (plugin && _hasProcessTelemetry) {
1177
+ _self._hasRun = true;
1425
1178
  try {
1426
- completeDetails.func.call(completeDetails.self, completeDetails.args);
1427
- }
1428
- catch (e) {
1429
- _throwInternal(core.logger, 2 , 73 , "Unexpected Exception during onComplete - " + dumpObj(e));
1179
+ itemCtx.setNext(_nextProxy);
1180
+ if (_hasSetNext) {
1181
+ plugin.setNextPlugin(_nextProxy);
1182
+ }
1183
+ _nextProxy && (_nextProxy._hasRun = false);
1184
+ plugin.processTelemetry(env, itemCtx);
1430
1185
  }
1431
- });
1432
- _onComplete = [];
1433
- }
1434
- }
1435
- return nextProxy;
1436
- }
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
- }
1186
+ catch (error) {
1187
+ var hasRun = _nextProxy && _nextProxy._hasRun;
1188
+ if (!_nextProxy || !hasRun) {
1189
+ itemCtx.diagLog().throwInternal(LoggingSeverity.CRITICAL, _InternalMessageId.PluginException, "Plugin [" + plugin.identifier + "] failed during processTelemetry - " + dumpObj(error));
1190
+ }
1191
+ if (_nextProxy && !hasRun) {
1192
+ _nextProxy.processTelemetry(env, itemCtx);
1460
1193
  }
1461
- });
1194
+ }
1462
1195
  }
1463
- }
1464
- }
1465
- return theConfig;
1466
- }
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;
1196
+ else if (_nextProxy) {
1197
+ _self._hasRun = true;
1198
+ _nextProxy.processTelemetry(env, itemCtx);
1199
+ }
1200
+ }, function () { return ({ item: env }); }, !(env.sync));
1201
+ };
1478
1202
  }
1479
- function _iterateChain(cb) {
1480
- var nextPlugin;
1481
- while (!!(nextPlugin = context._next())) {
1482
- var plugin = nextPlugin.getPlugin();
1483
- if (plugin) {
1484
- cb(plugin);
1203
+ return TelemetryPluginChain;
1204
+ }());
1205
+
1206
+ function _createProxyChain(plugins, itemCtx) {
1207
+ var proxies = [];
1208
+ if (plugins && plugins.length > 0) {
1209
+ var lastProxy = null;
1210
+ for (var idx = 0; idx < plugins.length; idx++) {
1211
+ var thePlugin = plugins[idx];
1212
+ if (thePlugin && isFunction(thePlugin.processTelemetry)) {
1213
+ var newProxy = new TelemetryPluginChain(thePlugin, itemCtx);
1214
+ proxies.push(newProxy);
1215
+ if (lastProxy) {
1216
+ lastProxy.setNext(newProxy);
1217
+ }
1218
+ lastProxy = newProxy;
1485
1219
  }
1486
1220
  }
1487
1221
  }
1488
- return context;
1222
+ return proxies.length > 0 ? proxies[0] : null;
1489
1223
  }
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);
1224
+ function _copyProxyChain(proxy, itemCtx, startAt) {
1225
+ var plugins = [];
1226
+ var add = startAt ? false : true;
1227
+ if (proxy) {
1228
+ while (proxy) {
1229
+ var thePlugin = proxy.getPlugin();
1230
+ if (add || thePlugin === startAt) {
1231
+ add = true;
1232
+ plugins.push(thePlugin);
1233
+ }
1234
+ proxy = proxy.getNext();
1502
1235
  }
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
1236
  }
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);
1237
+ if (!add) {
1238
+ plugins.push(startAt);
1523
1239
  }
1524
- context.processNext = _processNext;
1525
- context.createNew = _createNew;
1526
- return context;
1240
+ return _createProxyChain(plugins, itemCtx);
1527
1241
  }
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);
1242
+ function _copyPluginChain(srcPlugins, itemCtx, startAt) {
1243
+ var plugins = srcPlugins;
1244
+ var add = false;
1245
+ if (startAt && srcPlugins) {
1246
+ plugins = [];
1247
+ arrForEach(srcPlugins, function (thePlugin) {
1248
+ if (add || thePlugin === startAt) {
1249
+ add = true;
1250
+ plugins.push(thePlugin);
1535
1251
  }
1536
1252
  });
1537
1253
  }
1538
- function _createNew(plugins, startAt) {
1539
- if (plugins === void 0) { plugins = null; }
1540
- if (isArray(plugins)) {
1541
- plugins = createTelemetryProxyChain(plugins, config, core, startAt);
1254
+ if (startAt && !add) {
1255
+ if (!plugins) {
1256
+ plugins = [];
1542
1257
  }
1543
- return createProcessTelemetryUpdateContext(plugins || context.getNext(), config, core, startAt);
1258
+ plugins.push(startAt);
1544
1259
  }
1545
- context.processNext = _processNext;
1546
- context.createNew = _createNew;
1547
- return context;
1260
+ return _createProxyChain(plugins, itemCtx);
1548
1261
  }
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;
1262
+ var ProcessTelemetryContext = /** @class */ (function () {
1263
+ function ProcessTelemetryContext(plugins, config, core, startAt) {
1264
+ var _self = this;
1265
+ var _nextProxy = null;
1266
+ if (startAt !== null) {
1267
+ if (plugins && isFunction(plugins.getPlugin)) {
1268
+ _nextProxy = _copyProxyChain(plugins, _self, startAt || plugins.getPlugin());
1269
+ }
1270
+ else {
1271
+ if (startAt) {
1272
+ _nextProxy = _copyPluginChain(plugins, _self, startAt);
1562
1273
  }
1563
- if (lastProxy_1) {
1564
- lastProxy_1._setNext(newProxy);
1274
+ else if (isUndefined(startAt)) {
1275
+ _nextProxy = _createProxyChain(plugins, _self);
1565
1276
  }
1566
- lastProxy_1 = newProxy;
1567
1277
  }
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;
1599
1278
  }
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
- }
1279
+ _self.core = function () {
1280
+ return core;
1281
+ };
1282
+ _self.diagLog = function () {
1283
+ return safeGetLogger(core, config);
1284
+ };
1285
+ _self.getCfg = function () {
1286
+ return config;
1287
+ };
1288
+ _self.getExtCfg = function (identifier, defaultValue) {
1289
+ if (defaultValue === void 0) { defaultValue = {}; }
1290
+ var theConfig;
1291
+ if (config) {
1292
+ var extConfig = config.extensionConfig;
1293
+ if (extConfig && identifier) {
1294
+ theConfig = extConfig[identifier];
1637
1295
  }
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;
1647
1296
  }
1648
- var pluginState = _getPluginState(plugin);
1649
- if (pluginState[strTeardown] || pluginState[strDisabled]) {
1650
- return false;
1297
+ return (theConfig ? theConfig : defaultValue);
1298
+ };
1299
+ _self.getConfig = function (identifier, field, defaultValue) {
1300
+ if (defaultValue === void 0) { defaultValue = false; }
1301
+ var theValue;
1302
+ var extConfig = _self.getExtCfg(identifier, null);
1303
+ if (extConfig && !isNullOrUndefined(extConfig[field])) {
1304
+ theValue = extConfig[field];
1651
1305
  }
1652
- if (hasSetNext) {
1653
- plugin.setNextPlugin(nextProxy);
1306
+ else if (config && !isNullOrUndefined(config[field])) {
1307
+ theValue = config[field];
1654
1308
  }
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
- }
1309
+ return !isNullOrUndefined(theValue) ? theValue : defaultValue;
1310
+ };
1311
+ _self.hasNext = function () {
1312
+ return _nextProxy != null;
1313
+ };
1314
+ _self.getNext = function () {
1315
+ return _nextProxy;
1316
+ };
1317
+ _self.setNext = function (nextPlugin) {
1318
+ _nextProxy = nextPlugin;
1319
+ };
1320
+ _self.processNext = function (env) {
1321
+ var nextPlugin = _nextProxy;
1322
+ if (nextPlugin) {
1323
+ _nextProxy = nextPlugin.getNext();
1324
+ nextPlugin.processTelemetry(env, _self);
1676
1325
  }
1677
- return hasRun;
1678
- }
1679
- if (!_processChain(unloadCtx, _callTeardown, "unload", function () { }, unloadState.isAsync)) {
1680
- unloadCtx.processNext(unloadState);
1681
- }
1326
+ };
1327
+ _self.createNew = function (plugins, startAt) {
1328
+ if (plugins === void 0) { plugins = null; }
1329
+ return new ProcessTelemetryContext(plugins || _nextProxy, config, core, startAt);
1330
+ };
1682
1331
  }
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
- }
1332
+ return ProcessTelemetryContext;
1333
+ }());
1334
+
1335
+ var strExtensionConfig = "extensionConfig";
1336
+
1337
+ var strGetPlugin = "getPlugin";
1338
+ var BaseTelemetryPlugin = /** @class */ (function () {
1339
+ function BaseTelemetryPlugin() {
1340
+ var _self = this;
1341
+ var _isinitialized = false;
1342
+ var _rootCtx = null;
1343
+ var _nextPlugin = null;
1344
+ _self.core = null;
1345
+ _self.diagLog = function (itemCtx) {
1346
+ return _self._getTelCtx(itemCtx).diagLog();
1347
+ };
1348
+ _self.isInitialized = function () {
1349
+ return _isinitialized;
1350
+ };
1351
+ _self.setInitialized = function (isInitialized) {
1352
+ _isinitialized = isInitialized;
1353
+ };
1354
+ _self.setNextPlugin = function (next) {
1355
+ _nextPlugin = next;
1356
+ };
1357
+ _self.processNext = function (env, itemCtx) {
1358
+ if (itemCtx) {
1359
+ itemCtx.processNext(env);
1360
+ }
1361
+ else if (_nextPlugin && isFunction(_nextPlugin.processTelemetry)) {
1362
+ _nextPlugin.processTelemetry(env, null);
1363
+ }
1364
+ };
1365
+ _self._getTelCtx = function (currentCtx) {
1366
+ if (currentCtx === void 0) { currentCtx = null; }
1367
+ var itemCtx = currentCtx;
1368
+ if (!itemCtx) {
1369
+ var rootCtx = _rootCtx || new ProcessTelemetryContext(null, {}, _self.core);
1370
+ if (_nextPlugin && _nextPlugin[strGetPlugin]) {
1371
+ itemCtx = rootCtx.createNew(null, _nextPlugin[strGetPlugin]);
1372
+ }
1373
+ else {
1374
+ itemCtx = rootCtx.createNew(null, _nextPlugin);
1693
1375
  }
1694
1376
  }
1695
- return hasRun;
1696
- }
1697
- if (!_processChain(updateCtx, _callUpdate, "update", function () { }, false)) {
1698
- updateCtx.processNext(updateState);
1699
- }
1377
+ return itemCtx;
1378
+ };
1379
+ _self._baseTelInit = function (config, core, extensions, pluginChain) {
1380
+ if (config) {
1381
+ setValue(config, strExtensionConfig, [], null, isNullOrUndefined);
1382
+ }
1383
+ if (!pluginChain && core) {
1384
+ pluginChain = core.getProcessTelContext().getNext();
1385
+ }
1386
+ var nextPlugin = _nextPlugin;
1387
+ if (_nextPlugin && _nextPlugin[strGetPlugin]) {
1388
+ nextPlugin = _nextPlugin[strGetPlugin]();
1389
+ }
1390
+ _self.core = core;
1391
+ _rootCtx = new ProcessTelemetryContext(pluginChain, config, core, nextPlugin);
1392
+ _isinitialized = true;
1393
+ };
1700
1394
  }
1701
- return objFreeze(proxyChain);
1702
- }
1395
+ BaseTelemetryPlugin.prototype.initialize = function (config, core, extensions, pluginChain) {
1396
+ this._baseTelInit(config, core, extensions, pluginChain);
1397
+ };
1398
+ return BaseTelemetryPlugin;
1399
+ }());
1703
1400
 
1704
1401
  var strToGMTString = "toGMTString";
1705
1402
  var strToUTCString = "toUTCString";
@@ -1709,6 +1406,7 @@
1709
1406
  var strIsCookieUseDisabled = "isCookieUseDisabled";
1710
1407
  var strDisableCookiesUsage = "disableCookiesUsage";
1711
1408
  var strConfigCookieMgr = "_ckMgr";
1409
+ var strEmpty = "";
1712
1410
  var _supportsCookies = null;
1713
1411
  var _allowUaSameSite = null;
1714
1412
  var _parsedCookieValue = null;
@@ -1867,7 +1565,7 @@
1867
1565
  _supportsCookies = doc[strCookie] !== undefined;
1868
1566
  }
1869
1567
  catch (e) {
1870
- _throwInternal(logger, 2 , 68 , "Cannot access document.cookie - " + getExceptionName(e), { exception: dumpObj(e) });
1568
+ logger && logger.throwInternal(LoggingSeverity.WARNING, _InternalMessageId.CannotAccessCookie, "Cannot access document.cookie - " + getExceptionName(e), { exception: dumpObj(e) });
1871
1569
  }
1872
1570
  }
1873
1571
  return _supportsCookies;
@@ -1946,286 +1644,86 @@
1946
1644
  return false;
1947
1645
  }
1948
1646
 
1949
- var strExtensionConfig = "extensionConfig";
1950
-
1951
- function createUnloadHandlerContainer() {
1952
- var handlers = [];
1953
- function _addHandler(handler) {
1954
- if (handler) {
1955
- handlers.push(handler);
1956
- }
1957
- }
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 = [];
1647
+ var UInt32Mask = 0x100000000;
1648
+ var MaxUInt32 = 0xffffffff;
1649
+ var _mwcSeeded = false;
1650
+ var _mwcW = 123456789;
1651
+ var _mwcZ = 987654321;
1652
+ function _mwcSeed(seedValue) {
1653
+ if (seedValue < 0) {
1654
+ seedValue >>>= 0;
1968
1655
  }
1969
- return {
1970
- add: _addHandler,
1971
- run: _runHandlers
1972
- };
1656
+ _mwcW = (123456789 + seedValue) & MaxUInt32;
1657
+ _mwcZ = (987654321 - seedValue) & MaxUInt32;
1658
+ _mwcSeeded = true;
1973
1659
  }
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();
2115
- }
1660
+ function _autoSeedMwc() {
1661
+ try {
1662
+ var now = dateNow() & 0x7fffffff;
1663
+ _mwcSeed(((Math.random() * UInt32Mask) ^ now) + now);
2116
1664
  }
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
- }
1665
+ catch (e) {
2161
1666
  }
2162
- var parsedEvent = (eventNamespace.exec(eventName || "") || []);
2163
- return {
2164
- type: parsedEvent[1],
2165
- ns: ((parsedEvent[2] || "").replace(rRemoveEmptyNs, ".").replace(rRemoveTrailingEmptyNs, "").split(".").sort()).join(".")
2166
- };
2167
1667
  }
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] = [];
1668
+ function randomValue(maxValue) {
1669
+ if (maxValue > 0) {
1670
+ return Math.floor((random32() / MaxUInt32) * (maxValue + 1)) >>> 0;
2174
1671
  }
2175
- return registeredEvents;
1672
+ return 0;
2176
1673
  }
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;
1674
+ function random32(signed) {
1675
+ var value;
1676
+ var c = getCrypto() || getMsCrypto();
1677
+ if (c && c.getRandomValues) {
1678
+ value = c.getRandomValues(new Uint32Array(1))[0] & MaxUInt32;
1679
+ }
1680
+ else if (isIE()) {
1681
+ if (!_mwcSeeded) {
1682
+ _autoSeedMwc();
2187
1683
  }
1684
+ value = mwcRandom32() & MaxUInt32;
2188
1685
  }
2189
- return result;
1686
+ else {
1687
+ value = Math.floor((UInt32Mask * Math.random()) | 0);
1688
+ }
1689
+ if (!signed) {
1690
+ value >>>= 0;
1691
+ }
1692
+ return value;
2190
1693
  }
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
- }
1694
+ function mwcRandomSeed(value) {
1695
+ if (!value) {
1696
+ _autoSeedMwc();
1697
+ }
1698
+ else {
1699
+ _mwcSeed(value);
2210
1700
  }
2211
- return result;
2212
1701
  }
2213
- function addEventHandler(eventName, callback, evtNamespace) {
1702
+ function mwcRandom32(signed) {
1703
+ _mwcZ = (36969 * (_mwcZ & 0xFFFF) + (_mwcZ >> 16)) & MaxUInt32;
1704
+ _mwcW = (18000 * (_mwcW & 0xFFFF) + (_mwcW >> 16)) & MaxUInt32;
1705
+ var value = (((_mwcZ << 16) + (_mwcW & 0xFFFF)) >>> 0) & MaxUInt32 | 0;
1706
+ if (!signed) {
1707
+ value >>>= 0;
1708
+ }
1709
+ return value;
1710
+ }
1711
+
1712
+ var _cookieMgrs = null;
1713
+ var _canUseCookies;
1714
+ function addEventHandler(eventName, callback) {
2214
1715
  var result = false;
2215
1716
  var w = getWindow();
2216
1717
  if (w) {
2217
- result = eventOn(w, eventName, callback, evtNamespace);
2218
- result = eventOn(w["body"], eventName, callback, evtNamespace) || result;
1718
+ result = attachEvent(w, eventName, callback);
1719
+ result = attachEvent(w["body"], eventName, callback) || result;
2219
1720
  }
2220
1721
  var doc = getDocument();
2221
1722
  if (doc) {
2222
- result = eventOn(doc, eventName, callback, evtNamespace) || result;
1723
+ result = attachEvent(doc, eventName, callback) || result;
2223
1724
  }
2224
1725
  return result;
2225
1726
  }
2226
-
2227
- var _cookieMgrs = null;
2228
- var _canUseCookies;
2229
1727
  function newGuid() {
2230
1728
  function randomHexDigit() {
2231
1729
  return randomValue(15);
@@ -2242,9 +1740,26 @@
2242
1740
  }
2243
1741
  return dateNow();
2244
1742
  }
1743
+ function newId(maxLength) {
1744
+ if (maxLength === void 0) { maxLength = 22; }
1745
+ var base64chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
1746
+ var number = random32() >>> 0;
1747
+ var chars = 0;
1748
+ var result = "";
1749
+ while (result.length < maxLength) {
1750
+ chars++;
1751
+ result += base64chars.charAt(number & 0x3F);
1752
+ number >>>= 6;
1753
+ if (chars === 5) {
1754
+ number = (((random32() << 2) & 0xFFFFFFFF) | (number & 0x03)) >>> 0;
1755
+ chars = 0;
1756
+ }
1757
+ }
1758
+ return result;
1759
+ }
2245
1760
  function generateW3CId() {
2246
1761
  var hexValues = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f"];
2247
- var oct = strEmpty, tmp;
1762
+ var oct = "", tmp;
2248
1763
  for (var a = 0; a < 4; a++) {
2249
1764
  tmp = random32();
2250
1765
  oct +=
@@ -2327,183 +1842,101 @@
2327
1842
  _legacyCookieMgr().setEnabled(false);
2328
1843
  }
2329
1844
 
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
-
2419
1845
  var ReactPlugin = /** @class */ (function (_super) {
2420
1846
  __extendsFn(ReactPlugin, _super);
2421
1847
  function ReactPlugin() {
2422
- var _this = _super.call(this) || this;
1848
+ var _this = _super !== null && _super.apply(this, arguments) || this;
2423
1849
  _this.priority = 185;
2424
1850
  _this.identifier = 'ReactPlugin';
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;
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; });
2504
- });
2505
1851
  return _this;
2506
1852
  }
1853
+ ReactPlugin.prototype.initialize = function (config, core, extensions, pluginChain) {
1854
+ var _this = this;
1855
+ _super.prototype.initialize.call(this, config, core, extensions, pluginChain);
1856
+ this._extensionConfig =
1857
+ config.extensionConfig && config.extensionConfig[this.identifier]
1858
+ ? config.extensionConfig[this.identifier]
1859
+ : { history: null };
1860
+ arrForEach(extensions, function (ext) {
1861
+ var identifier = ext.identifier;
1862
+ if (identifier === 'ApplicationInsightsAnalytics') {
1863
+ _this._analyticsPlugin = ext;
1864
+ }
1865
+ });
1866
+ if (this._extensionConfig.history) {
1867
+ this.addHistoryListener(this._extensionConfig.history);
1868
+ var pageViewTelemetry = {
1869
+ uri: this._extensionConfig.history.location.pathname
1870
+ };
1871
+ this.trackPageView(pageViewTelemetry);
1872
+ }
1873
+ };
1874
+ ReactPlugin.prototype.getCookieMgr = function () {
1875
+ return safeGetCookieMgr(this.core);
1876
+ };
1877
+ ReactPlugin.prototype.getAppInsights = function () {
1878
+ return this._analyticsPlugin;
1879
+ };
1880
+ ReactPlugin.prototype.processTelemetry = function (event, itemCtx) {
1881
+ this.processNext(event, itemCtx);
1882
+ };
1883
+ ReactPlugin.prototype.trackMetric = function (metric, customProperties) {
1884
+ if (this._analyticsPlugin) {
1885
+ this._analyticsPlugin.trackMetric(metric, customProperties);
1886
+ }
1887
+ else {
1888
+ this.diagLog().throwInternal(LoggingSeverity.CRITICAL, _InternalMessageId.TelemetryInitializerFailed, "Analytics plugin is not available, React plugin telemetry will not be sent: ");
1889
+ }
1890
+ };
1891
+ ReactPlugin.prototype.trackPageView = function (pageView) {
1892
+ if (this._analyticsPlugin) {
1893
+ this._analyticsPlugin.trackPageView(pageView);
1894
+ }
1895
+ else {
1896
+ this.diagLog().throwInternal(LoggingSeverity.CRITICAL, _InternalMessageId.TelemetryInitializerFailed, "Analytics plugin is not available, React plugin telemetry will not be sent: ");
1897
+ }
1898
+ };
1899
+ ReactPlugin.prototype.trackEvent = function (event, customProperties) {
1900
+ if (this._analyticsPlugin) {
1901
+ this._analyticsPlugin.trackEvent(event, customProperties);
1902
+ }
1903
+ else {
1904
+ this.diagLog().throwInternal(LoggingSeverity.CRITICAL, _InternalMessageId.TelemetryInitializerFailed, "Analytics plugin is not available, React plugin telemetry will not be sent: ");
1905
+ }
1906
+ };
1907
+ ReactPlugin.prototype.trackException = function (exception, customProperties) {
1908
+ if (this._analyticsPlugin) {
1909
+ this._analyticsPlugin.trackException(exception, customProperties);
1910
+ }
1911
+ else {
1912
+ this.diagLog().throwInternal(LoggingSeverity.CRITICAL, _InternalMessageId.TelemetryInitializerFailed, "Analytics plugin is not available, React plugin telemetry will not be sent: ");
1913
+ }
1914
+ };
1915
+ ReactPlugin.prototype.trackTrace = function (trace, customProperties) {
1916
+ if (this._analyticsPlugin) {
1917
+ this._analyticsPlugin.trackTrace(trace, customProperties);
1918
+ }
1919
+ else {
1920
+ this.diagLog().throwInternal(LoggingSeverity.CRITICAL, _InternalMessageId.TelemetryInitializerFailed, "Analytics plugin is not available, React plugin telemetry will not be sent: ");
1921
+ }
1922
+ };
1923
+ ReactPlugin.prototype.addHistoryListener = function (history) {
1924
+ var _this = this;
1925
+ var locationListener = function (arg) {
1926
+ var locn = null;
1927
+ if ("location" in arg) {
1928
+ locn = arg["location"];
1929
+ }
1930
+ else {
1931
+ locn = arg;
1932
+ }
1933
+ setTimeout(function () {
1934
+ var pageViewTelemetry = { uri: locn.pathname };
1935
+ _this.trackPageView(pageViewTelemetry);
1936
+ }, 500);
1937
+ };
1938
+ history.listen(locationListener);
1939
+ };
2507
1940
  return ReactPlugin;
2508
1941
  }(BaseTelemetryPlugin));
2509
1942
  var ReactPlugin$1 = ReactPlugin;
@@ -2650,7 +2083,7 @@
2650
2083
  trackedData.idleCount * trackedData.idleTimeout) /
2651
2084
  1000);
2652
2085
  }
2653
- var useComponentTracking = function (reactPlugin, componentName, customProperties) {
2086
+ var useComponentTracking = function (reactPlugin, componentName) {
2654
2087
  var tracking = React.useRef({
2655
2088
  hookTimestamp: dateNow(),
2656
2089
  firstActiveTimestamp: 0,
@@ -2689,7 +2122,7 @@
2689
2122
  name: "React Component Engaged Time (seconds)",
2690
2123
  sampleCount: 1
2691
2124
  };
2692
- var additionalProperties = __assignFn({ "Component Name": componentName }, customProperties);
2125
+ var additionalProperties = { "Component Name": componentName };
2693
2126
  reactPlugin.trackMetric(metricData, additionalProperties);
2694
2127
  };
2695
2128
  }, []);