@microsoft/applicationinsights-properties-js 2.8.0-nightly.2202-06 → 2.8.0-nightly.2204-06

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/browser/applicationinsights-properties-js.integrity.json +9 -9
  2. package/browser/applicationinsights-properties-js.js +879 -480
  3. package/browser/applicationinsights-properties-js.js.map +1 -1
  4. package/browser/applicationinsights-properties-js.min.js +2 -2
  5. package/browser/applicationinsights-properties-js.min.js.map +1 -1
  6. package/dist/applicationinsights-properties-js.api.json +110 -56
  7. package/dist/applicationinsights-properties-js.d.ts +1 -1
  8. package/dist/applicationinsights-properties-js.js +879 -480
  9. package/dist/applicationinsights-properties-js.js.map +1 -1
  10. package/dist/applicationinsights-properties-js.min.js +2 -2
  11. package/dist/applicationinsights-properties-js.min.js.map +1 -1
  12. package/dist/applicationinsights-properties-js.rollup.d.ts +1 -1
  13. package/dist-esm/Context/Application.js +1 -1
  14. package/dist-esm/Context/Device.js +1 -1
  15. package/dist-esm/Context/Internal.js +2 -2
  16. package/dist-esm/Context/Internal.js.map +1 -1
  17. package/dist-esm/Context/Location.js +1 -1
  18. package/dist-esm/Context/Session.js +6 -6
  19. package/dist-esm/Context/Session.js.map +1 -1
  20. package/dist-esm/Context/TelemetryTrace.js +1 -1
  21. package/dist-esm/Context/User.js +3 -3
  22. package/dist-esm/Context/User.js.map +1 -1
  23. package/dist-esm/Interfaces/IPropTelemetryContext.js +1 -1
  24. package/dist-esm/Interfaces/ITelemetryConfig.js +1 -1
  25. package/dist-esm/PropertiesPlugin.js +4 -4
  26. package/dist-esm/PropertiesPlugin.js.map +1 -1
  27. package/dist-esm/TelemetryContext.js +1 -1
  28. package/dist-esm/applicationinsights-properties-js.js +1 -1
  29. package/package.json +4 -4
  30. package/src/Context/Internal.ts +1 -1
  31. package/src/Context/Session.ts +16 -12
  32. package/src/Context/User.ts +5 -5
  33. package/src/PropertiesPlugin.ts +6 -6
  34. package/src/TelemetryContext.ts +3 -3
  35. package/types/Context/User.d.ts +5 -5
  36. package/types/tsdoc-metadata.json +1 -1
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * Application Insights JavaScript SDK - Properties Plugin, 2.8.0-nightly.2202-06
2
+ * Application Insights JavaScript SDK - Properties Plugin, 2.8.0-nightly.2204-06
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  */
5
5
  (function (global, factory) {
@@ -62,7 +62,9 @@
62
62
  (getGlobal() || {})["Reflect"];
63
63
  var extendStaticsFn = function (d, b) {
64
64
  extendStaticsFn = ObjClass["setPrototypeOf"] ||
65
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
65
+ ({ __proto__: [] } instanceof Array && function (d, b) {
66
+ d.__proto__ = b;
67
+ }) ||
66
68
  function (d, b) {
67
69
  for (var p in b) {
68
70
  if (b[strShimHasOwnProperty](p)) {
@@ -77,7 +79,9 @@
77
79
  throwTypeError("Class extends value " + String(b) + " is not a constructor or null");
78
80
  }
79
81
  extendStaticsFn(d, b);
80
- function __() { this.constructor = d; }
82
+ function __() {
83
+ this.constructor = d;
84
+ }
81
85
  d[strShimPrototype] = b === null ? objCreateFn(b) : (__[strShimPrototype] = b[strShimPrototype], new __());
82
86
  }
83
87
 
@@ -96,11 +100,11 @@
96
100
  var DynAllowInstChkTag = DynInstChkTag;
97
101
  var DynProtoDefaultOptions = '_dfOpts';
98
102
  var UnknownValue = '_unknown_';
99
- var str__Proto = "__proto__";
103
+ var str__Proto$1 = "__proto__";
100
104
  var strUseBaseInst = 'useBaseInst';
101
105
  var strSetInstFuncs = 'setInstFuncs';
102
106
  var Obj = Object;
103
- var _objGetPrototypeOf = Obj["getPrototypeOf"];
107
+ var _objGetPrototypeOf$1 = Obj["getPrototypeOf"];
104
108
  var _dynamicNames = 0;
105
109
  function _hasOwnProperty(obj, prop) {
106
110
  return obj && Obj[Prototype].hasOwnProperty.call(obj, prop);
@@ -111,12 +115,12 @@
111
115
  function _isObjectArrayOrFunctionPrototype(target) {
112
116
  return _isObjectOrArrayPrototype(target) || target === Function[Prototype];
113
117
  }
114
- function _getObjProto(target) {
118
+ function _getObjProto$1(target) {
115
119
  if (target) {
116
- if (_objGetPrototypeOf) {
117
- return _objGetPrototypeOf(target);
120
+ if (_objGetPrototypeOf$1) {
121
+ return _objGetPrototypeOf$1(target);
118
122
  }
119
- var newProto = target[str__Proto] || target[Prototype] || (target[Constructor] ? target[Constructor][Prototype] : null);
123
+ var newProto = target[str__Proto$1] || target[Prototype] || (target[Constructor] ? target[Constructor][Prototype] : null);
120
124
  if (newProto) {
121
125
  return newProto;
122
126
  }
@@ -182,16 +186,16 @@
182
186
  _forEachProp(instFuncs, function (name) {
183
187
  baseFuncs[name] = _instFuncProxy(thisTarget, instFuncs, name);
184
188
  });
185
- var baseProto = _getObjProto(classProto);
189
+ var baseProto = _getObjProto$1(classProto);
186
190
  var visited = [];
187
191
  while (baseProto && !_isObjectArrayOrFunctionPrototype(baseProto) && !_hasVisited(visited, baseProto)) {
188
192
  _forEachProp(baseProto, function (name) {
189
- if (!baseFuncs[name] && _isDynamicCandidate(baseProto, name, !_objGetPrototypeOf)) {
193
+ if (!baseFuncs[name] && _isDynamicCandidate(baseProto, name, !_objGetPrototypeOf$1)) {
190
194
  baseFuncs[name] = _instFuncProxy(thisTarget, baseProto, name);
191
195
  }
192
196
  });
193
197
  visited.push(baseProto);
194
- baseProto = _getObjProto(baseProto);
198
+ baseProto = _getObjProto$1(baseProto);
195
199
  }
196
200
  return baseFuncs;
197
201
  }
@@ -205,7 +209,7 @@
205
209
  }
206
210
  if (!instFunc[DynInstChkTag] && instFuncTable[DynAllowInstChkTag] !== false) {
207
211
  var canAddInst = !_hasOwnProperty(target, funcName);
208
- var objProto = _getObjProto(target);
212
+ var objProto = _getObjProto$1(target);
209
213
  var visited = [];
210
214
  while (canAddInst && objProto && !_isObjectArrayOrFunctionPrototype(objProto) && !_hasVisited(visited, objProto)) {
211
215
  var protoFunc = objProto[funcName];
@@ -214,7 +218,7 @@
214
218
  break;
215
219
  }
216
220
  visited.push(objProto);
217
- objProto = _getObjProto(objProto);
221
+ objProto = _getObjProto$1(objProto);
218
222
  }
219
223
  try {
220
224
  if (canAddInst) {
@@ -232,7 +236,7 @@
232
236
  function _getProtoFunc(funcName, proto, currentDynProtoProxy) {
233
237
  var protoFunc = proto[funcName];
234
238
  if (protoFunc === currentDynProtoProxy) {
235
- protoFunc = _getObjProto(proto)[funcName];
239
+ protoFunc = _getObjProto$1(proto)[funcName];
236
240
  }
237
241
  if (typeof protoFunc !== strFunction) {
238
242
  _throwTypeError("[" + funcName + "] is not a " + strFunction);
@@ -266,15 +270,15 @@
266
270
  }
267
271
  }
268
272
  function _checkPrototype(classProto, thisTarget) {
269
- if (_objGetPrototypeOf) {
273
+ if (_objGetPrototypeOf$1) {
270
274
  var visited = [];
271
- var thisProto = _getObjProto(thisTarget);
275
+ var thisProto = _getObjProto$1(thisTarget);
272
276
  while (thisProto && !_isObjectArrayOrFunctionPrototype(thisProto) && !_hasVisited(visited, thisProto)) {
273
277
  if (thisProto === classProto) {
274
278
  return true;
275
279
  }
276
280
  visited.push(thisProto);
277
- thisProto = _getObjProto(thisProto);
281
+ thisProto = _getObjProto$1(thisProto);
278
282
  }
279
283
  }
280
284
  return false;
@@ -310,7 +314,7 @@
310
314
  var instFuncs = _getInstanceFuncs(target);
311
315
  var baseFuncs = _getBaseFuncs(classProto, target, instFuncs, useBaseInst);
312
316
  delegateFunc(target, baseFuncs);
313
- var setInstanceFunc = !!_objGetPrototypeOf && !!perfOptions[strSetInstFuncs];
317
+ var setInstanceFunc = !!_objGetPrototypeOf$1 && !!perfOptions[strSetInstFuncs];
314
318
  if (setInstanceFunc && options) {
315
319
  setInstanceFunc = !!options[strSetInstFuncs];
316
320
  }
@@ -322,101 +326,23 @@
322
326
  };
323
327
  dynamicProto[DynProtoDefaultOptions] = perfDefaults;
324
328
 
325
- var LoggingSeverity;
326
- (function (LoggingSeverity) {
327
- LoggingSeverity[LoggingSeverity["CRITICAL"] = 1] = "CRITICAL";
328
- LoggingSeverity[LoggingSeverity["WARNING"] = 2] = "WARNING";
329
- })(LoggingSeverity || (LoggingSeverity = {}));
330
- var _InternalMessageId = {
331
- BrowserDoesNotSupportLocalStorage: 0,
332
- BrowserCannotReadLocalStorage: 1,
333
- BrowserCannotReadSessionStorage: 2,
334
- BrowserCannotWriteLocalStorage: 3,
335
- BrowserCannotWriteSessionStorage: 4,
336
- BrowserFailedRemovalFromLocalStorage: 5,
337
- BrowserFailedRemovalFromSessionStorage: 6,
338
- CannotSendEmptyTelemetry: 7,
339
- ClientPerformanceMathError: 8,
340
- ErrorParsingAISessionCookie: 9,
341
- ErrorPVCalc: 10,
342
- ExceptionWhileLoggingError: 11,
343
- FailedAddingTelemetryToBuffer: 12,
344
- FailedMonitorAjaxAbort: 13,
345
- FailedMonitorAjaxDur: 14,
346
- FailedMonitorAjaxOpen: 15,
347
- FailedMonitorAjaxRSC: 16,
348
- FailedMonitorAjaxSend: 17,
349
- FailedMonitorAjaxGetCorrelationHeader: 18,
350
- FailedToAddHandlerForOnBeforeUnload: 19,
351
- FailedToSendQueuedTelemetry: 20,
352
- FailedToReportDataLoss: 21,
353
- FlushFailed: 22,
354
- MessageLimitPerPVExceeded: 23,
355
- MissingRequiredFieldSpecification: 24,
356
- NavigationTimingNotSupported: 25,
357
- OnError: 26,
358
- SessionRenewalDateIsZero: 27,
359
- SenderNotInitialized: 28,
360
- StartTrackEventFailed: 29,
361
- StopTrackEventFailed: 30,
362
- StartTrackFailed: 31,
363
- StopTrackFailed: 32,
364
- TelemetrySampledAndNotSent: 33,
365
- TrackEventFailed: 34,
366
- TrackExceptionFailed: 35,
367
- TrackMetricFailed: 36,
368
- TrackPVFailed: 37,
369
- TrackPVFailedCalc: 38,
370
- TrackTraceFailed: 39,
371
- TransmissionFailed: 40,
372
- FailedToSetStorageBuffer: 41,
373
- FailedToRestoreStorageBuffer: 42,
374
- InvalidBackendResponse: 43,
375
- FailedToFixDepricatedValues: 44,
376
- InvalidDurationValue: 45,
377
- TelemetryEnvelopeInvalid: 46,
378
- CreateEnvelopeError: 47,
379
- CannotSerializeObject: 48,
380
- CannotSerializeObjectNonSerializable: 49,
381
- CircularReferenceDetected: 50,
382
- ClearAuthContextFailed: 51,
383
- ExceptionTruncated: 52,
384
- IllegalCharsInName: 53,
385
- ItemNotInArray: 54,
386
- MaxAjaxPerPVExceeded: 55,
387
- MessageTruncated: 56,
388
- NameTooLong: 57,
389
- SampleRateOutOfRange: 58,
390
- SetAuthContextFailed: 59,
391
- SetAuthContextFailedAccountName: 60,
392
- StringValueTooLong: 61,
393
- StartCalledMoreThanOnce: 62,
394
- StopCalledWithoutStart: 63,
395
- TelemetryInitializerFailed: 64,
396
- TrackArgumentsNotSpecified: 65,
397
- UrlTooLong: 66,
398
- SessionStorageBufferFull: 67,
399
- CannotAccessCookie: 68,
400
- IdTooLong: 69,
401
- InvalidEvent: 70,
402
- FailedMonitorAjaxSetRequestHeader: 71,
403
- SendBrowserInfoOnUserInit: 72,
404
- PluginException: 73,
405
- NotificationException: 74,
406
- SnippetScriptLoadFailure: 99,
407
- InvalidInstrumentationKey: 100,
408
- CannotParseAiBlobValue: 101,
409
- InvalidContentBlob: 102,
410
- TrackPageActionEventFailed: 103,
411
- FailedAddingCustomDefinedRequestContext: 104,
412
- InMemoryStorageBufferFull: 105
413
- };
329
+ var strEmpty$1 = "";
330
+ var strSetNextPlugin = "setNextPlugin";
331
+ var strIsInitialized = "isInitialized";
332
+ var strTeardown = "teardown";
333
+ var strCore = "core";
334
+ var strUpdate = "update";
335
+ var strDisabled = "disabled";
336
+ var strDoTeardown = "_doTeardown";
414
337
 
415
338
  var strToISOString = "toISOString";
416
339
  var cStrEndsWith = "endsWith";
417
340
  var cStrTrim = "trim";
418
341
  var strToString = "toString";
419
- var _objDefineProperty = ObjDefineProperty;
342
+ var str__Proto = "__proto__";
343
+ var strConstructor = "constructor";
344
+ var _objDefineProperty$1 = ObjDefineProperty;
345
+ var _objFreeze = ObjClass.freeze;
420
346
  var _objKeys = ObjClass.keys;
421
347
  var StringProto = String[strShimPrototype];
422
348
  var _strTrim = StringProto[cStrTrim];
@@ -426,7 +352,23 @@
426
352
  var _isArray = Array.isArray;
427
353
  var _objToString = ObjProto[strToString];
428
354
  var _fnToString = ObjHasOwnProperty[strToString];
429
- _fnToString.call(ObjClass);
355
+ var _objFunctionString = _fnToString.call(ObjClass);
356
+ var rCamelCase = /-([a-z])/g;
357
+ var rNormalizeInvalid = /([^\w\d_$])/g;
358
+ var rLeadingNumeric = /^(\d+[\w\d_$])/;
359
+ var _objGetPrototypeOf = Object["getPrototypeOf"];
360
+ function _getObjProto(target) {
361
+ if (target) {
362
+ if (_objGetPrototypeOf) {
363
+ return _objGetPrototypeOf(target);
364
+ }
365
+ var newProto = target[str__Proto] || target[strShimPrototype] || target[strConstructor];
366
+ if (newProto) {
367
+ return newProto;
368
+ }
369
+ }
370
+ return null;
371
+ }
430
372
  function isUndefined(value) {
431
373
  return value === undefined || typeof value === strShimUndefined;
432
374
  }
@@ -442,6 +384,19 @@
442
384
  function isFunction(value) {
443
385
  return !!(value && typeof value === strShimFunction);
444
386
  }
387
+ function normalizeJsName(name) {
388
+ var value = name;
389
+ if (value && isString(value)) {
390
+ value = value.replace(rCamelCase, function (_all, letter) {
391
+ return letter.toUpperCase();
392
+ });
393
+ value = value.replace(rNormalizeInvalid, "_");
394
+ value = value.replace(rLeadingNumeric, function (_all, match) {
395
+ return "_" + match;
396
+ });
397
+ }
398
+ return value;
399
+ }
445
400
  function objForEachKey(target, callbackfn) {
446
401
  if (target) {
447
402
  for (var prop in target) {
@@ -490,6 +445,25 @@
490
445
  function isString(value) {
491
446
  return typeof value === "string";
492
447
  }
448
+ function isBoolean(value) {
449
+ return typeof value === "boolean";
450
+ }
451
+ function isPlainObject(value) {
452
+ var result = false;
453
+ if (value && typeof value === "object") {
454
+ var proto = _objGetPrototypeOf ? _objGetPrototypeOf(value) : _getObjProto(value);
455
+ if (!proto) {
456
+ result = true;
457
+ }
458
+ else {
459
+ if (proto[strConstructor] && ObjHasOwnProperty.call(proto, strConstructor)) {
460
+ proto = proto[strConstructor];
461
+ }
462
+ result = typeof proto === strShimFunction && _fnToString.call(proto) === _objFunctionString;
463
+ }
464
+ }
465
+ return result;
466
+ }
493
467
  function toISOString(date) {
494
468
  if (date) {
495
469
  return _dataToISOString ? date[strToISOString]() : _toISOStringPoly(date);
@@ -569,7 +543,7 @@
569
543
  return result;
570
544
  }
571
545
  function objDefineAccessors(target, prop, getProp, setProp) {
572
- if (_objDefineProperty) {
546
+ if (_objDefineProperty$1) {
573
547
  try {
574
548
  var descriptor = {
575
549
  enumerable: true,
@@ -581,7 +555,7 @@
581
555
  if (setProp) {
582
556
  descriptor.set = setProp;
583
557
  }
584
- _objDefineProperty(target, prop, descriptor);
558
+ _objDefineProperty$1(target, prop, descriptor);
585
559
  return true;
586
560
  }
587
561
  catch (e) {
@@ -589,6 +563,20 @@
589
563
  }
590
564
  return false;
591
565
  }
566
+ function _doNothing(value) {
567
+ return value;
568
+ }
569
+ function deepFreeze(obj) {
570
+ if (_objFreeze) {
571
+ objForEachKey(obj, function (name, value) {
572
+ if (isArray(value) || isObject(value)) {
573
+ _objFreeze(value);
574
+ }
575
+ });
576
+ }
577
+ return objFreeze(obj);
578
+ }
579
+ var objFreeze = _objFreeze || _doNothing;
592
580
  function dateNow() {
593
581
  var dt = Date;
594
582
  return dt.now ? dt.now() : new dt().getTime();
@@ -597,7 +585,7 @@
597
585
  if (isError(object)) {
598
586
  return object.name;
599
587
  }
600
- return "";
588
+ return strEmpty$1;
601
589
  }
602
590
  function setValue(target, field, value, valChk, srcChk) {
603
591
  var theValue = value;
@@ -627,6 +615,32 @@
627
615
  function isTruthy(value) {
628
616
  return !!value;
629
617
  }
618
+ function _createProxyFunction(source, funcName) {
619
+ var srcFunc = null;
620
+ var src = null;
621
+ if (isFunction(source)) {
622
+ srcFunc = source;
623
+ }
624
+ else {
625
+ src = source;
626
+ }
627
+ return function () {
628
+ var originalArguments = arguments;
629
+ if (srcFunc) {
630
+ src = srcFunc();
631
+ }
632
+ if (src) {
633
+ return src[funcName].apply(src, originalArguments);
634
+ }
635
+ };
636
+ }
637
+ function proxyFunctionAs(target, name, source, theFunc, overwriteTarget) {
638
+ if (target && name && source) {
639
+ if (overwriteTarget !== false || isUndefined(target[name])) {
640
+ target[name] = _createProxyFunction(source, theFunc);
641
+ }
642
+ }
643
+ }
630
644
  function createClassFromInterface(defaults) {
631
645
  return /** @class */ (function () {
632
646
  function class_1() {
@@ -640,6 +654,59 @@
640
654
  return class_1;
641
655
  }());
642
656
  }
657
+ function objExtend(obj1, obj2, obj3, obj4, obj5, obj6) {
658
+ var theArgs = arguments;
659
+ var extended = theArgs[0] || {};
660
+ var argLen = theArgs.length;
661
+ var deep = false;
662
+ var idx = 1;
663
+ if (argLen > 0 && isBoolean(extended)) {
664
+ deep = extended;
665
+ extended = theArgs[idx] || {};
666
+ idx++;
667
+ }
668
+ if (!isObject(extended)) {
669
+ extended = {};
670
+ }
671
+ for (; idx < argLen; idx++) {
672
+ var arg = theArgs[idx];
673
+ var isArgArray = isArray(arg);
674
+ var isArgObj = isObject(arg);
675
+ for (var prop in arg) {
676
+ var propOk = (isArgArray && (prop in arg)) || (isArgObj && (ObjHasOwnProperty.call(arg, prop)));
677
+ if (!propOk) {
678
+ continue;
679
+ }
680
+ var newValue = arg[prop];
681
+ var isNewArray = void 0;
682
+ if (deep && newValue && ((isNewArray = isArray(newValue)) || isPlainObject(newValue))) {
683
+ var clone = extended[prop];
684
+ if (isNewArray) {
685
+ if (!isArray(clone)) {
686
+ clone = [];
687
+ }
688
+ }
689
+ else if (!isPlainObject(clone)) {
690
+ clone = {};
691
+ }
692
+ newValue = objExtend(deep, clone, newValue);
693
+ }
694
+ if (newValue !== undefined) {
695
+ extended[prop] = newValue;
696
+ }
697
+ }
698
+ }
699
+ return extended;
700
+ }
701
+
702
+ function createEnumStyle(values) {
703
+ var enumClass = {};
704
+ objForEachKey(values, function (field, value) {
705
+ enumClass[field] = value;
706
+ enumClass[value] = field;
707
+ });
708
+ return deepFreeze(enumClass);
709
+ }
643
710
 
644
711
  var strWindow = "window";
645
712
  var strDocument = "document";
@@ -722,14 +789,14 @@
722
789
  var nav = getNavigator();
723
790
  if (nav && (nav.userAgent !== _navUserAgentCheck || _isTrident === null)) {
724
791
  _navUserAgentCheck = nav.userAgent;
725
- var userAgent = (_navUserAgentCheck || "").toLowerCase();
792
+ var userAgent = (_navUserAgentCheck || strEmpty$1).toLowerCase();
726
793
  _isTrident = (strContains(userAgent, strMsie) || strContains(userAgent, strTrident));
727
794
  }
728
795
  return _isTrident;
729
796
  }
730
797
  function dumpObj(object) {
731
798
  var objectTypeDump = Object[strShimPrototype].toString.call(object);
732
- var propertyValueDump = "";
799
+ var propertyValueDump = strEmpty$1;
733
800
  if (objectTypeDump === "[object Error]") {
734
801
  propertyValueDump = "{ stack: '" + object.stack + "', message: '" + object.message + "', name: '" + object.name + "'";
735
802
  }
@@ -762,9 +829,9 @@
762
829
  var strWarnToConsole = "warnToConsole";
763
830
  function _sanitizeDiagnosticText(text) {
764
831
  if (text) {
765
- return "\"" + text.replace(/\"/g, "") + "\"";
832
+ return "\"" + text.replace(/\"/g, strEmpty$1) + "\"";
766
833
  }
767
- return "";
834
+ return strEmpty$1;
768
835
  }
769
836
  function _logToConsole(func, message) {
770
837
  var theConsole = getConsole();
@@ -786,12 +853,12 @@
786
853
  _self.message =
787
854
  (isUserAct ? AiUserActionablePrefix : AiNonUserActionablePrefix) +
788
855
  msgId;
789
- var strProps = "";
856
+ var strProps = strEmpty$1;
790
857
  if (hasJSON()) {
791
858
  strProps = getJSON().stringify(properties);
792
859
  }
793
- var diagnosticText = (msg ? " message:" + _sanitizeDiagnosticText(msg) : "") +
794
- (properties ? " props:" + _sanitizeDiagnosticText(strProps) : "");
860
+ var diagnosticText = (msg ? " message:" + _sanitizeDiagnosticText(msg) : strEmpty$1) +
861
+ (properties ? " props:" + _sanitizeDiagnosticText(strProps) : strEmpty$1);
795
862
  _self.message += diagnosticText;
796
863
  }
797
864
  _InternalLogMessage.dataType = "MessageData";
@@ -821,7 +888,7 @@
821
888
  throw message;
822
889
  }
823
890
  else {
824
- var logFunc = severity === LoggingSeverity.CRITICAL ? strErrorToConsole : strWarnToConsole;
891
+ var logFunc = severity === 1 ? strErrorToConsole : strWarnToConsole;
825
892
  if (!isUndefined(message.message)) {
826
893
  var logLevel = _self.consoleLoggingLevel();
827
894
  if (isUserAct) {
@@ -839,7 +906,7 @@
839
906
  _self.logInternalMessage(severity, message);
840
907
  }
841
908
  else {
842
- _debugExtMsg("throw" + (severity === LoggingSeverity.CRITICAL ? "Critical" : "Warning"), message);
909
+ _debugExtMsg("throw" + (severity === 1 ? "Critical" : "Warning"), message);
843
910
  }
844
911
  }
845
912
  };
@@ -871,13 +938,13 @@
871
938
  if (severity <= _self.telemetryLoggingLevel()) {
872
939
  _self.queue.push(message);
873
940
  _messageCount++;
874
- _debugExtMsg((severity === LoggingSeverity.CRITICAL ? "error" : "warn"), message);
941
+ _debugExtMsg((severity === 1 ? "error" : "warn"), message);
875
942
  }
876
943
  if (_messageCount === _self.maxInternalMessageLimit()) {
877
944
  var throttleLimitMessage = "Internal events throttle limit per PageView reached for this app.";
878
- var throttleMessage = new _InternalLogMessage(_InternalMessageId.MessageLimitPerPVExceeded, throttleLimitMessage, false);
945
+ var throttleMessage = new _InternalLogMessage(23 , throttleLimitMessage, false);
879
946
  _self.queue.push(throttleMessage);
880
- if (severity === LoggingSeverity.CRITICAL) {
947
+ if (severity === 1 ) {
881
948
  _self.errorToConsole(throttleLimitMessage);
882
949
  }
883
950
  else {
@@ -906,6 +973,16 @@
906
973
  }
907
974
  return DiagnosticLogger;
908
975
  }());
976
+ function _getLogger(logger) {
977
+ return (logger || new DiagnosticLogger());
978
+ }
979
+ function _throwInternal(logger, severity, msgId, msg, properties, isUserAct) {
980
+ if (isUserAct === void 0) { isUserAct = false; }
981
+ (logger || new DiagnosticLogger()).throwInternal(severity, msgId, msg, properties, isUserAct);
982
+ }
983
+ function _logInternalMessage(logger, severity, message) {
984
+ _getLogger(logger).logInternalMessage(severity, message);
985
+ }
909
986
 
910
987
  var strExecutionContextKey = "ctx";
911
988
  var PerfEvent = /** @class */ (function () {
@@ -1019,252 +1096,495 @@
1019
1096
  return func();
1020
1097
  }
1021
1098
 
1022
- var TelemetryPluginChain = /** @class */ (function () {
1023
- function TelemetryPluginChain(plugin, defItemCtx) {
1024
- var _self = this;
1025
- var _nextProxy = null;
1026
- var _hasProcessTelemetry = isFunction(plugin.processTelemetry);
1027
- var _hasSetNext = isFunction(plugin.setNextPlugin);
1028
- _self._hasRun = false;
1029
- _self.getPlugin = function () {
1030
- return plugin;
1031
- };
1032
- _self.getNext = function () {
1033
- return _nextProxy;
1034
- };
1035
- _self.setNext = function (nextPlugin) {
1036
- _nextProxy = nextPlugin;
1037
- };
1038
- _self.processTelemetry = function (env, itemCtx) {
1039
- if (!itemCtx) {
1040
- itemCtx = defItemCtx;
1099
+ var UInt32Mask = 0x100000000;
1100
+ var MaxUInt32 = 0xffffffff;
1101
+ var _mwcSeeded = false;
1102
+ var _mwcW = 123456789;
1103
+ var _mwcZ = 987654321;
1104
+ function _mwcSeed(seedValue) {
1105
+ if (seedValue < 0) {
1106
+ seedValue >>>= 0;
1107
+ }
1108
+ _mwcW = (123456789 + seedValue) & MaxUInt32;
1109
+ _mwcZ = (987654321 - seedValue) & MaxUInt32;
1110
+ _mwcSeeded = true;
1111
+ }
1112
+ function _autoSeedMwc() {
1113
+ try {
1114
+ var now = dateNow() & 0x7fffffff;
1115
+ _mwcSeed(((Math.random() * UInt32Mask) ^ now) + now);
1116
+ }
1117
+ catch (e) {
1118
+ }
1119
+ }
1120
+ function random32(signed) {
1121
+ var value = 0;
1122
+ var c = getCrypto() || getMsCrypto();
1123
+ if (c && c.getRandomValues) {
1124
+ value = c.getRandomValues(new Uint32Array(1))[0] & MaxUInt32;
1125
+ }
1126
+ if (value === 0 && isIE()) {
1127
+ if (!_mwcSeeded) {
1128
+ _autoSeedMwc();
1129
+ }
1130
+ value = mwcRandom32() & MaxUInt32;
1131
+ }
1132
+ if (value === 0) {
1133
+ value = Math.floor((UInt32Mask * Math.random()) | 0);
1134
+ }
1135
+ if (!signed) {
1136
+ value >>>= 0;
1137
+ }
1138
+ return value;
1139
+ }
1140
+ function mwcRandom32(signed) {
1141
+ _mwcZ = (36969 * (_mwcZ & 0xFFFF) + (_mwcZ >> 16)) & MaxUInt32;
1142
+ _mwcW = (18000 * (_mwcW & 0xFFFF) + (_mwcW >> 16)) & MaxUInt32;
1143
+ var value = (((_mwcZ << 16) + (_mwcW & 0xFFFF)) >>> 0) & MaxUInt32 | 0;
1144
+ if (!signed) {
1145
+ value >>>= 0;
1146
+ }
1147
+ return value;
1148
+ }
1149
+ function newId(maxLength) {
1150
+ if (maxLength === void 0) { maxLength = 22; }
1151
+ var base64chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
1152
+ var number = random32() >>> 0;
1153
+ var chars = 0;
1154
+ var result = strEmpty$1;
1155
+ while (result.length < maxLength) {
1156
+ chars++;
1157
+ result += base64chars.charAt(number & 0x3F);
1158
+ number >>>= 6;
1159
+ if (chars === 5) {
1160
+ number = (((random32() << 2) & 0xFFFFFFFF) | (number & 0x03)) >>> 0;
1161
+ chars = 0;
1162
+ }
1163
+ }
1164
+ return result;
1165
+ }
1166
+
1167
+ var _objDefineProperty = ObjDefineProperty;
1168
+ var version = "2.8.0-nightly.2204-06";
1169
+ var instanceName = "." + newId(6);
1170
+ var _dataUid = 0;
1171
+ function _createAccessor(target, prop, value) {
1172
+ if (_objDefineProperty) {
1173
+ try {
1174
+ _objDefineProperty(target, prop, {
1175
+ value: value,
1176
+ enumerable: false,
1177
+ configurable: true
1178
+ });
1179
+ return true;
1180
+ }
1181
+ catch (e) {
1182
+ }
1183
+ }
1184
+ return false;
1185
+ }
1186
+ function _canAcceptData(target) {
1187
+ return target.nodeType === 1 || target.nodeType === 9 || !(+target.nodeType);
1188
+ }
1189
+ function _getCache(data, target) {
1190
+ var theCache = target[data.id];
1191
+ if (!theCache) {
1192
+ theCache = {};
1193
+ try {
1194
+ if (_canAcceptData(target)) {
1195
+ if (!_createAccessor(target, data.id, theCache)) {
1196
+ target[data.id] = theCache;
1197
+ }
1198
+ }
1199
+ }
1200
+ catch (e) {
1201
+ }
1202
+ }
1203
+ return theCache;
1204
+ }
1205
+ function createUniqueNamespace(name, includeVersion) {
1206
+ if (includeVersion === void 0) { includeVersion = false; }
1207
+ return normalizeJsName(name + (_dataUid++) + (includeVersion ? "." + version : "") + instanceName);
1208
+ }
1209
+ function createElmNodeData(name) {
1210
+ var data = {
1211
+ id: createUniqueNamespace("_aiData-" + (name || "") + "." + version),
1212
+ accept: function (target) {
1213
+ return _canAcceptData(target);
1214
+ },
1215
+ get: function (target, name, defValue, addDefault) {
1216
+ var theCache = target[data.id];
1217
+ if (!theCache) {
1218
+ if (addDefault) {
1219
+ theCache = _getCache(data, target);
1220
+ theCache[normalizeJsName(name)] = defValue;
1221
+ }
1222
+ return defValue;
1223
+ }
1224
+ return theCache[normalizeJsName(name)];
1225
+ },
1226
+ kill: function (target, name) {
1227
+ if (target && target[name]) {
1228
+ try {
1229
+ delete target[name];
1230
+ }
1231
+ catch (e) {
1232
+ }
1041
1233
  }
1042
- var identifier = plugin ? plugin.identifier : "TelemetryPluginChain";
1043
- doPerf(itemCtx ? itemCtx.core() : null, function () { return identifier + ":processTelemetry"; }, function () {
1044
- if (plugin && _hasProcessTelemetry) {
1045
- _self._hasRun = true;
1234
+ }
1235
+ };
1236
+ return data;
1237
+ }
1238
+
1239
+ var pluginStateData = createElmNodeData("plugin");
1240
+ function _getPluginState(plugin) {
1241
+ return pluginStateData.get(plugin, "state", {}, true);
1242
+ }
1243
+
1244
+ var strTelemetryPluginChain = "TelemetryPluginChain";
1245
+ var strHasRunFlags = "_hasRun";
1246
+ var strGetTelCtx = "_getTelCtx";
1247
+ var _chainId = 0;
1248
+ function _getNextProxyStart(proxy, config, core, startAt) {
1249
+ while (proxy) {
1250
+ if (proxy.getPlugin() === startAt) {
1251
+ return proxy;
1252
+ }
1253
+ proxy = proxy.getNext();
1254
+ }
1255
+ return createTelemetryProxyChain([startAt], config, core);
1256
+ }
1257
+ function _createInternalContext(telemetryChain, config, core, startAt) {
1258
+ var _nextProxy = null;
1259
+ var _onComplete = [];
1260
+ if (startAt !== null) {
1261
+ _nextProxy = startAt ? _getNextProxyStart(telemetryChain, config, core, startAt) : telemetryChain;
1262
+ }
1263
+ var context = {
1264
+ _next: _moveNext,
1265
+ ctx: {
1266
+ core: function () {
1267
+ return core;
1268
+ },
1269
+ diagLog: function () {
1270
+ return safeGetLogger(core, config);
1271
+ },
1272
+ getCfg: function () {
1273
+ return config;
1274
+ },
1275
+ getExtCfg: _getExtCfg,
1276
+ getConfig: _getConfig,
1277
+ hasNext: function () {
1278
+ return !!_nextProxy;
1279
+ },
1280
+ getNext: function () {
1281
+ return _nextProxy;
1282
+ },
1283
+ setNext: function (nextPlugin) {
1284
+ _nextProxy = nextPlugin;
1285
+ },
1286
+ iterate: _iterateChain,
1287
+ onComplete: _addOnComplete
1288
+ }
1289
+ };
1290
+ function _addOnComplete(onComplete, that) {
1291
+ var args = [];
1292
+ for (var _i = 2; _i < arguments.length; _i++) {
1293
+ args[_i - 2] = arguments[_i];
1294
+ }
1295
+ if (onComplete) {
1296
+ _onComplete.push({
1297
+ func: onComplete,
1298
+ self: !isUndefined(that) ? that : context.ctx,
1299
+ args: args
1300
+ });
1301
+ }
1302
+ }
1303
+ function _moveNext() {
1304
+ var nextProxy = _nextProxy;
1305
+ _nextProxy = nextProxy ? nextProxy.getNext() : null;
1306
+ if (!nextProxy) {
1307
+ var onComplete = _onComplete;
1308
+ if (onComplete && onComplete.length > 0) {
1309
+ arrForEach(onComplete, function (completeDetails) {
1046
1310
  try {
1047
- itemCtx.setNext(_nextProxy);
1048
- if (_hasSetNext) {
1049
- plugin.setNextPlugin(_nextProxy);
1050
- }
1051
- _nextProxy && (_nextProxy._hasRun = false);
1052
- plugin.processTelemetry(env, itemCtx);
1311
+ completeDetails.func.call(completeDetails.self, completeDetails.args);
1053
1312
  }
1054
- catch (error) {
1055
- var hasRun = _nextProxy && _nextProxy._hasRun;
1056
- if (!_nextProxy || !hasRun) {
1057
- itemCtx.diagLog().throwInternal(LoggingSeverity.CRITICAL, _InternalMessageId.PluginException, "Plugin [" + plugin.identifier + "] failed during processTelemetry - " + dumpObj(error));
1058
- }
1059
- if (_nextProxy && !hasRun) {
1060
- _nextProxy.processTelemetry(env, itemCtx);
1061
- }
1313
+ catch (e) {
1314
+ _throwInternal(core.logger, 2 , 73 , "Unexpected Exception during onComplete - " + dumpObj(e));
1062
1315
  }
1063
- }
1064
- else if (_nextProxy) {
1065
- _self._hasRun = true;
1066
- _nextProxy.processTelemetry(env, itemCtx);
1067
- }
1068
- }, function () { return ({ item: env }); }, !(env.sync));
1069
- };
1316
+ });
1317
+ _onComplete = [];
1318
+ }
1319
+ }
1320
+ return nextProxy;
1070
1321
  }
1071
- return TelemetryPluginChain;
1072
- }());
1073
-
1074
- function _createProxyChain(plugins, itemCtx) {
1075
- var proxies = [];
1076
- if (plugins && plugins.length > 0) {
1077
- var lastProxy = null;
1078
- for (var idx = 0; idx < plugins.length; idx++) {
1079
- var thePlugin = plugins[idx];
1080
- if (thePlugin && isFunction(thePlugin.processTelemetry)) {
1081
- var newProxy = new TelemetryPluginChain(thePlugin, itemCtx);
1082
- proxies.push(newProxy);
1083
- if (lastProxy) {
1084
- lastProxy.setNext(newProxy);
1322
+ function _getExtCfg(identifier, defaultValue, mergeDefault) {
1323
+ if (defaultValue === void 0) { defaultValue = {}; }
1324
+ if (mergeDefault === void 0) { mergeDefault = 0 ; }
1325
+ var theConfig;
1326
+ if (config) {
1327
+ var extConfig = config.extensionConfig;
1328
+ if (extConfig && identifier) {
1329
+ theConfig = extConfig[identifier];
1330
+ }
1331
+ }
1332
+ if (!theConfig) {
1333
+ theConfig = defaultValue;
1334
+ }
1335
+ else if (isObject(defaultValue)) {
1336
+ if (mergeDefault !== 0 ) {
1337
+ var newConfig_1 = objExtend(true, defaultValue, theConfig);
1338
+ if (config && mergeDefault === 2 ) {
1339
+ objForEachKey(defaultValue, function (field) {
1340
+ if (isNullOrUndefined(newConfig_1[field])) {
1341
+ var cfgValue = config[field];
1342
+ if (!isNullOrUndefined(cfgValue)) {
1343
+ newConfig_1[field] = cfgValue;
1344
+ }
1345
+ }
1346
+ });
1085
1347
  }
1086
- lastProxy = newProxy;
1087
1348
  }
1088
1349
  }
1350
+ return theConfig;
1351
+ }
1352
+ function _getConfig(identifier, field, defaultValue) {
1353
+ if (defaultValue === void 0) { defaultValue = false; }
1354
+ var theValue;
1355
+ var extConfig = _getExtCfg(identifier, null);
1356
+ if (extConfig && !isNullOrUndefined(extConfig[field])) {
1357
+ theValue = extConfig[field];
1358
+ }
1359
+ else if (config && !isNullOrUndefined(config[field])) {
1360
+ theValue = config[field];
1361
+ }
1362
+ return !isNullOrUndefined(theValue) ? theValue : defaultValue;
1089
1363
  }
1090
- return proxies.length > 0 ? proxies[0] : null;
1091
- }
1092
- function _copyProxyChain(proxy, itemCtx, startAt) {
1093
- var plugins = [];
1094
- var add = startAt ? false : true;
1095
- if (proxy) {
1096
- while (proxy) {
1097
- var thePlugin = proxy.getPlugin();
1098
- if (add || thePlugin === startAt) {
1099
- add = true;
1100
- plugins.push(thePlugin);
1364
+ function _iterateChain(cb) {
1365
+ var nextPlugin;
1366
+ while (!!(nextPlugin = context._next())) {
1367
+ var plugin = nextPlugin.getPlugin();
1368
+ if (plugin) {
1369
+ cb(plugin);
1101
1370
  }
1102
- proxy = proxy.getNext();
1103
1371
  }
1104
1372
  }
1105
- if (!add) {
1106
- plugins.push(startAt);
1373
+ return context;
1374
+ }
1375
+ function createProcessTelemetryContext(telemetryChain, config, core, startAt) {
1376
+ var internalContext = _createInternalContext(telemetryChain, config, core, startAt);
1377
+ var context = internalContext.ctx;
1378
+ function _processNext(env) {
1379
+ var nextPlugin = internalContext._next();
1380
+ nextPlugin && nextPlugin.processTelemetry(env, context);
1381
+ return !nextPlugin;
1382
+ }
1383
+ function _createNew(plugins, startAt) {
1384
+ if (plugins === void 0) { plugins = null; }
1385
+ if (isArray(plugins)) {
1386
+ plugins = createTelemetryProxyChain(plugins, config, core, startAt);
1387
+ }
1388
+ return createProcessTelemetryContext(plugins || context.getNext(), config, core, startAt);
1389
+ }
1390
+ context.processNext = _processNext;
1391
+ context.createNew = _createNew;
1392
+ return context;
1393
+ }
1394
+ function createProcessTelemetryUnloadContext(telemetryChain, config, core, startAt) {
1395
+ var internalContext = _createInternalContext(telemetryChain, config, core, startAt);
1396
+ var context = internalContext.ctx;
1397
+ function _processNext(unloadState) {
1398
+ var nextPlugin = internalContext._next();
1399
+ nextPlugin && nextPlugin.unload(context, unloadState);
1400
+ return !nextPlugin;
1401
+ }
1402
+ function _createNew(plugins, startAt) {
1403
+ if (plugins === void 0) { plugins = null; }
1404
+ if (isArray(plugins)) {
1405
+ plugins = createTelemetryProxyChain(plugins, config, core, startAt);
1406
+ }
1407
+ return createProcessTelemetryUnloadContext(plugins || context.getNext(), config, core, startAt);
1107
1408
  }
1108
- return _createProxyChain(plugins, itemCtx);
1409
+ context.processNext = _processNext;
1410
+ context.createNew = _createNew;
1411
+ return context;
1109
1412
  }
1110
- function _copyPluginChain(srcPlugins, itemCtx, startAt) {
1111
- var plugins = srcPlugins;
1112
- var add = false;
1113
- if (startAt && srcPlugins) {
1114
- plugins = [];
1115
- arrForEach(srcPlugins, function (thePlugin) {
1116
- if (add || thePlugin === startAt) {
1117
- add = true;
1118
- plugins.push(thePlugin);
1413
+ function createProcessTelemetryUpdateContext(telemetryChain, config, core, startAt) {
1414
+ var internalContext = _createInternalContext(telemetryChain, config, core, startAt);
1415
+ var context = internalContext.ctx;
1416
+ function _processNext(updateState) {
1417
+ return context.iterate(function (plugin) {
1418
+ if (isFunction(plugin[strUpdate])) {
1419
+ plugin[strUpdate](context, updateState);
1119
1420
  }
1120
1421
  });
1121
1422
  }
1122
- if (startAt && !add) {
1123
- if (!plugins) {
1124
- plugins = [];
1423
+ function _createNew(plugins, startAt) {
1424
+ if (plugins === void 0) { plugins = null; }
1425
+ if (isArray(plugins)) {
1426
+ plugins = createTelemetryProxyChain(plugins, config, core, startAt);
1125
1427
  }
1126
- plugins.push(startAt);
1428
+ return createProcessTelemetryUpdateContext(plugins || context.getNext(), config, core, startAt);
1127
1429
  }
1128
- return _createProxyChain(plugins, itemCtx);
1430
+ context.processNext = _processNext;
1431
+ context.createNew = _createNew;
1432
+ return context;
1129
1433
  }
1130
- var ProcessTelemetryContext = /** @class */ (function () {
1131
- function ProcessTelemetryContext(plugins, config, core, startAt) {
1132
- var _self = this;
1133
- var _nextProxy = null;
1134
- if (startAt !== null) {
1135
- if (plugins && isFunction(plugins.getPlugin)) {
1136
- _nextProxy = _copyProxyChain(plugins, _self, startAt || plugins.getPlugin());
1434
+ function createTelemetryProxyChain(plugins, config, core, startAt) {
1435
+ var firstProxy = null;
1436
+ var add = startAt ? false : true;
1437
+ if (isArray(plugins) && plugins.length > 0) {
1438
+ var lastProxy_1 = null;
1439
+ arrForEach(plugins, function (thePlugin) {
1440
+ if (!add && startAt === thePlugin) {
1441
+ add = true;
1137
1442
  }
1138
- else {
1139
- if (startAt) {
1140
- _nextProxy = _copyPluginChain(plugins, _self, startAt);
1443
+ if (add && thePlugin && isFunction(thePlugin.processTelemetry)) {
1444
+ var newProxy = createTelemetryPluginProxy(thePlugin, config, core);
1445
+ if (!firstProxy) {
1446
+ firstProxy = newProxy;
1141
1447
  }
1142
- else if (isUndefined(startAt)) {
1143
- _nextProxy = _createProxyChain(plugins, _self);
1448
+ if (lastProxy_1) {
1449
+ lastProxy_1._setNext(newProxy);
1144
1450
  }
1451
+ lastProxy_1 = newProxy;
1145
1452
  }
1453
+ });
1454
+ }
1455
+ if (startAt && !firstProxy) {
1456
+ return createTelemetryProxyChain([startAt], config, core);
1457
+ }
1458
+ return firstProxy;
1459
+ }
1460
+ function createTelemetryPluginProxy(plugin, config, core) {
1461
+ var nextProxy = null;
1462
+ var hasProcessTelemetry = isFunction(plugin.processTelemetry);
1463
+ var hasSetNext = isFunction(plugin.setNextPlugin);
1464
+ var chainId;
1465
+ if (plugin) {
1466
+ chainId = plugin.identifier + "-" + plugin.priority + "-" + _chainId++;
1467
+ }
1468
+ else {
1469
+ chainId = "Unknown-0-" + _chainId++;
1470
+ }
1471
+ var proxyChain = {
1472
+ getPlugin: function () {
1473
+ return plugin;
1474
+ },
1475
+ getNext: function () {
1476
+ return nextProxy;
1477
+ },
1478
+ processTelemetry: _processTelemetry,
1479
+ unload: _unloadPlugin,
1480
+ update: _updatePlugin,
1481
+ _id: chainId,
1482
+ _setNext: function (nextPlugin) {
1483
+ nextProxy = nextPlugin;
1146
1484
  }
1147
- _self.core = function () {
1148
- return core;
1149
- };
1150
- _self.diagLog = function () {
1151
- return safeGetLogger(core, config);
1152
- };
1153
- _self.getCfg = function () {
1154
- return config;
1155
- };
1156
- _self.getExtCfg = function (identifier, defaultValue) {
1157
- if (defaultValue === void 0) { defaultValue = {}; }
1158
- var theConfig;
1159
- if (config) {
1160
- var extConfig = config.extensionConfig;
1161
- if (extConfig && identifier) {
1162
- theConfig = extConfig[identifier];
1485
+ };
1486
+ function _getTelCtx() {
1487
+ var itemCtx;
1488
+ if (plugin && isFunction(plugin[strGetTelCtx])) {
1489
+ itemCtx = plugin[strGetTelCtx]();
1490
+ }
1491
+ if (!itemCtx) {
1492
+ itemCtx = createProcessTelemetryContext(proxyChain, config, core);
1493
+ }
1494
+ return itemCtx;
1495
+ }
1496
+ function _processChain(itemCtx, processPluginFn, name, details, isAsync) {
1497
+ var hasRun = false;
1498
+ var identifier = plugin ? plugin.identifier : strTelemetryPluginChain;
1499
+ var hasRunContext = itemCtx[strHasRunFlags];
1500
+ if (!hasRunContext) {
1501
+ hasRunContext = itemCtx[strHasRunFlags] = {};
1502
+ }
1503
+ itemCtx.setNext(nextProxy);
1504
+ if (plugin) {
1505
+ doPerf(itemCtx[strCore](), function () { return identifier + ":" + name; }, function () {
1506
+ hasRunContext[chainId] = true;
1507
+ try {
1508
+ var nextId = nextProxy ? nextProxy._id : strEmpty$1;
1509
+ if (nextId) {
1510
+ hasRunContext[nextId] = false;
1511
+ }
1512
+ hasRun = processPluginFn(itemCtx);
1163
1513
  }
1514
+ catch (error) {
1515
+ var hasNextRun = nextProxy ? hasRunContext[nextProxy._id] : true;
1516
+ if (hasNextRun) {
1517
+ hasRun = true;
1518
+ }
1519
+ if (!nextProxy || !hasNextRun) {
1520
+ _throwInternal(itemCtx.diagLog(), 1 , 73 , "Plugin [" + plugin.identifier + "] failed during " + name + " - " + dumpObj(error) + ", run flags: " + dumpObj(hasRunContext));
1521
+ }
1522
+ }
1523
+ }, details, isAsync);
1524
+ }
1525
+ return hasRun;
1526
+ }
1527
+ function _processTelemetry(env, itemCtx) {
1528
+ itemCtx = itemCtx || _getTelCtx();
1529
+ function _callProcessTelemetry(itemCtx) {
1530
+ if (!plugin || !hasProcessTelemetry) {
1531
+ return false;
1164
1532
  }
1165
- return (theConfig ? theConfig : defaultValue);
1166
- };
1167
- _self.getConfig = function (identifier, field, defaultValue) {
1168
- if (defaultValue === void 0) { defaultValue = false; }
1169
- var theValue;
1170
- var extConfig = _self.getExtCfg(identifier, null);
1171
- if (extConfig && !isNullOrUndefined(extConfig[field])) {
1172
- theValue = extConfig[field];
1173
- }
1174
- else if (config && !isNullOrUndefined(config[field])) {
1175
- theValue = config[field];
1533
+ var pluginState = _getPluginState(plugin);
1534
+ if (pluginState[strTeardown] || pluginState[strDisabled]) {
1535
+ return false;
1176
1536
  }
1177
- return !isNullOrUndefined(theValue) ? theValue : defaultValue;
1178
- };
1179
- _self.hasNext = function () {
1180
- return _nextProxy != null;
1181
- };
1182
- _self.getNext = function () {
1183
- return _nextProxy;
1184
- };
1185
- _self.setNext = function (nextPlugin) {
1186
- _nextProxy = nextPlugin;
1187
- };
1188
- _self.processNext = function (env) {
1189
- var nextPlugin = _nextProxy;
1190
- if (nextPlugin) {
1191
- _nextProxy = nextPlugin.getNext();
1192
- nextPlugin.processTelemetry(env, _self);
1537
+ if (hasSetNext) {
1538
+ plugin.setNextPlugin(nextProxy);
1193
1539
  }
1194
- };
1195
- _self.createNew = function (plugins, startAt) {
1196
- if (plugins === void 0) { plugins = null; }
1197
- return new ProcessTelemetryContext(plugins || _nextProxy, config, core, startAt);
1198
- };
1540
+ plugin.processTelemetry(env, itemCtx);
1541
+ return true;
1542
+ }
1543
+ if (!_processChain(itemCtx, _callProcessTelemetry, "processTelemetry", function () { return ({ item: env }); }, !(env.sync))) {
1544
+ itemCtx.processNext(env);
1545
+ }
1199
1546
  }
1200
- return ProcessTelemetryContext;
1201
- }());
1202
-
1203
- var strExtensionConfig = "extensionConfig";
1204
-
1205
- var strGetPlugin = "getPlugin";
1206
- var BaseTelemetryPlugin = /** @class */ (function () {
1207
- function BaseTelemetryPlugin() {
1208
- var _self = this;
1209
- var _isinitialized = false;
1210
- var _rootCtx = null;
1211
- var _nextPlugin = null;
1212
- _self.core = null;
1213
- _self.diagLog = function (itemCtx) {
1214
- return _self._getTelCtx(itemCtx).diagLog();
1215
- };
1216
- _self.isInitialized = function () {
1217
- return _isinitialized;
1218
- };
1219
- _self.setInitialized = function (isInitialized) {
1220
- _isinitialized = isInitialized;
1221
- };
1222
- _self.setNextPlugin = function (next) {
1223
- _nextPlugin = next;
1224
- };
1225
- _self.processNext = function (env, itemCtx) {
1226
- if (itemCtx) {
1227
- itemCtx.processNext(env);
1228
- }
1229
- else if (_nextPlugin && isFunction(_nextPlugin.processTelemetry)) {
1230
- _nextPlugin.processTelemetry(env, null);
1231
- }
1232
- };
1233
- _self._getTelCtx = function (currentCtx) {
1234
- if (currentCtx === void 0) { currentCtx = null; }
1235
- var itemCtx = currentCtx;
1236
- if (!itemCtx) {
1237
- var rootCtx = _rootCtx || new ProcessTelemetryContext(null, {}, _self.core);
1238
- if (_nextPlugin && _nextPlugin[strGetPlugin]) {
1239
- itemCtx = rootCtx.createNew(null, _nextPlugin[strGetPlugin]);
1240
- }
1241
- else {
1242
- itemCtx = rootCtx.createNew(null, _nextPlugin);
1547
+ function _unloadPlugin(unloadCtx, unloadState) {
1548
+ function _callTeardown() {
1549
+ var hasRun = false;
1550
+ if (plugin) {
1551
+ var pluginState = _getPluginState(plugin);
1552
+ var pluginCore = plugin[strCore] || pluginState.core;
1553
+ if (plugin && (!pluginCore || pluginCore === unloadCtx[strCore]()) && !pluginState[strTeardown]) {
1554
+ pluginState[strCore] = null;
1555
+ pluginState[strTeardown] = true;
1556
+ pluginState[strIsInitialized] = false;
1557
+ if (plugin[strTeardown] && plugin[strTeardown](unloadCtx, unloadState) === true) {
1558
+ hasRun = true;
1559
+ }
1243
1560
  }
1244
1561
  }
1245
- return itemCtx;
1246
- };
1247
- _self._baseTelInit = function (config, core, extensions, pluginChain) {
1248
- if (config) {
1249
- setValue(config, strExtensionConfig, [], null, isNullOrUndefined);
1250
- }
1251
- if (!pluginChain && core) {
1252
- pluginChain = core.getProcessTelContext().getNext();
1253
- }
1254
- var nextPlugin = _nextPlugin;
1255
- if (_nextPlugin && _nextPlugin[strGetPlugin]) {
1256
- nextPlugin = _nextPlugin[strGetPlugin]();
1562
+ return hasRun;
1563
+ }
1564
+ if (!_processChain(unloadCtx, _callTeardown, "unload", function () { }, unloadState.isAsync)) {
1565
+ unloadCtx.processNext(unloadState);
1566
+ }
1567
+ }
1568
+ function _updatePlugin(updateCtx, updateState) {
1569
+ function _callUpdate() {
1570
+ var hasRun = false;
1571
+ if (plugin) {
1572
+ var pluginState = _getPluginState(plugin);
1573
+ var pluginCore = plugin[strCore] || pluginState.core;
1574
+ if (plugin && (!pluginCore || pluginCore === updateCtx[strCore]()) && !pluginState[strTeardown]) {
1575
+ if (plugin[strUpdate] && plugin[strUpdate](updateCtx, updateState) === true) {
1576
+ hasRun = true;
1577
+ }
1578
+ }
1257
1579
  }
1258
- _self.core = core;
1259
- _rootCtx = new ProcessTelemetryContext(pluginChain, config, core, nextPlugin);
1260
- _isinitialized = true;
1261
- };
1580
+ return hasRun;
1581
+ }
1582
+ if (!_processChain(updateCtx, _callUpdate, "update", function () { }, false)) {
1583
+ updateCtx.processNext(updateState);
1584
+ }
1262
1585
  }
1263
- BaseTelemetryPlugin.prototype.initialize = function (config, core, extensions, pluginChain) {
1264
- this._baseTelInit(config, core, extensions, pluginChain);
1265
- };
1266
- return BaseTelemetryPlugin;
1267
- }());
1586
+ return objFreeze(proxyChain);
1587
+ }
1268
1588
 
1269
1589
  var strToGMTString = "toGMTString";
1270
1590
  var strToUTCString = "toUTCString";
@@ -1274,7 +1594,6 @@
1274
1594
  var strIsCookieUseDisabled = "isCookieUseDisabled";
1275
1595
  var strDisableCookiesUsage = "disableCookiesUsage";
1276
1596
  var strConfigCookieMgr = "_ckMgr";
1277
- var strEmpty = "";
1278
1597
  var _supportsCookies = null;
1279
1598
  var _allowUaSameSite = null;
1280
1599
  var _parsedCookieValue = null;
@@ -1351,7 +1670,7 @@
1351
1670
  var result = false;
1352
1671
  if (_isMgrEnabled(cookieMgr)) {
1353
1672
  var values = {};
1354
- var theValue = strTrim(value || strEmpty);
1673
+ var theValue = strTrim(value || strEmpty$1);
1355
1674
  var idx = theValue.indexOf(";");
1356
1675
  if (idx !== -1) {
1357
1676
  theValue = strTrim(value.substring(0, idx));
@@ -1366,11 +1685,11 @@
1366
1685
  if (expireMs > 0) {
1367
1686
  var expiry = new Date();
1368
1687
  expiry.setTime(expireMs);
1369
- setValue(values, strExpires, _formatDate(expiry, !_isIE ? strToUTCString : strToGMTString) || _formatDate(expiry, _isIE ? strToGMTString : strToUTCString) || strEmpty, isTruthy);
1688
+ setValue(values, strExpires, _formatDate(expiry, !_isIE ? strToUTCString : strToGMTString) || _formatDate(expiry, _isIE ? strToGMTString : strToUTCString) || strEmpty$1, isTruthy);
1370
1689
  }
1371
1690
  }
1372
1691
  if (!_isIE) {
1373
- setValue(values, "max-age", strEmpty + maxAgeSec, null, isUndefined);
1692
+ setValue(values, "max-age", strEmpty$1 + maxAgeSec, null, isUndefined);
1374
1693
  }
1375
1694
  }
1376
1695
  var location_1 = getLocation();
@@ -1391,7 +1710,7 @@
1391
1710
  return result;
1392
1711
  },
1393
1712
  get: function (name) {
1394
- var value = strEmpty;
1713
+ var value = strEmpty$1;
1395
1714
  if (_isMgrEnabled(cookieMgr)) {
1396
1715
  value = (cookieMgrConfig.getCookie || _getCookieValue)(name);
1397
1716
  }
@@ -1416,7 +1735,7 @@
1416
1735
  values["max-age"] = "0";
1417
1736
  }
1418
1737
  var delCookie = cookieMgrConfig.delCookie || _setCookieValue;
1419
- delCookie(name, _formatCookieValue(strEmpty, values));
1738
+ delCookie(name, _formatCookieValue(strEmpty$1, values));
1420
1739
  result = true;
1421
1740
  }
1422
1741
  return result;
@@ -1433,7 +1752,7 @@
1433
1752
  _supportsCookies = doc[strCookie] !== undefined;
1434
1753
  }
1435
1754
  catch (e) {
1436
- logger && logger.throwInternal(LoggingSeverity.WARNING, _InternalMessageId.CannotAccessCookie, "Cannot access document.cookie - " + getExceptionName(e), { exception: dumpObj(e) });
1755
+ _throwInternal(logger, 2 , 68 , "Cannot access document.cookie - " + getExceptionName(e), { exception: dumpObj(e) });
1437
1756
  }
1438
1757
  }
1439
1758
  return _supportsCookies;
@@ -1443,7 +1762,7 @@
1443
1762
  if (theValue && theValue.length) {
1444
1763
  var parts = strTrim(theValue).split(";");
1445
1764
  arrForEach(parts, function (thePart) {
1446
- thePart = strTrim(thePart || strEmpty);
1765
+ thePart = strTrim(thePart || strEmpty$1);
1447
1766
  if (thePart) {
1448
1767
  var idx = thePart.indexOf("=");
1449
1768
  if (idx === -1) {
@@ -1464,21 +1783,21 @@
1464
1783
  return null;
1465
1784
  }
1466
1785
  function _formatCookieValue(value, values) {
1467
- var cookieValue = value || strEmpty;
1786
+ var cookieValue = value || strEmpty$1;
1468
1787
  objForEachKey(values, function (name, theValue) {
1469
- cookieValue += "; " + name + (!isNullOrUndefined(theValue) ? "=" + theValue : strEmpty);
1788
+ cookieValue += "; " + name + (!isNullOrUndefined(theValue) ? "=" + theValue : strEmpty$1);
1470
1789
  });
1471
1790
  return cookieValue;
1472
1791
  }
1473
1792
  function _getCookieValue(name) {
1474
- var cookieValue = strEmpty;
1793
+ var cookieValue = strEmpty$1;
1475
1794
  if (_doc) {
1476
- var theCookie = _doc[strCookie] || strEmpty;
1795
+ var theCookie = _doc[strCookie] || strEmpty$1;
1477
1796
  if (_parsedCookieValue !== theCookie) {
1478
1797
  _cookieCache = _extractParts(theCookie);
1479
1798
  _parsedCookieValue = theCookie;
1480
1799
  }
1481
- cookieValue = strTrim(_cookieCache[name] || strEmpty);
1800
+ cookieValue = strTrim(_cookieCache[name] || strEmpty$1);
1482
1801
  }
1483
1802
  return cookieValue;
1484
1803
  }
@@ -1512,77 +1831,180 @@
1512
1831
  return false;
1513
1832
  }
1514
1833
 
1515
- var UInt32Mask = 0x100000000;
1516
- var MaxUInt32 = 0xffffffff;
1517
- var _mwcSeeded = false;
1518
- var _mwcW = 123456789;
1519
- var _mwcZ = 987654321;
1520
- function _mwcSeed(seedValue) {
1521
- if (seedValue < 0) {
1522
- seedValue >>>= 0;
1523
- }
1524
- _mwcW = (123456789 + seedValue) & MaxUInt32;
1525
- _mwcZ = (987654321 - seedValue) & MaxUInt32;
1526
- _mwcSeeded = true;
1527
- }
1528
- function _autoSeedMwc() {
1529
- try {
1530
- var now = dateNow() & 0x7fffffff;
1531
- _mwcSeed(((Math.random() * UInt32Mask) ^ now) + now);
1532
- }
1533
- catch (e) {
1534
- }
1535
- }
1536
- function random32(signed) {
1537
- var value;
1538
- var c = getCrypto() || getMsCrypto();
1539
- if (c && c.getRandomValues) {
1540
- value = c.getRandomValues(new Uint32Array(1))[0] & MaxUInt32;
1541
- }
1542
- else if (isIE()) {
1543
- if (!_mwcSeeded) {
1544
- _autoSeedMwc();
1834
+ var strExtensionConfig = "extensionConfig";
1835
+
1836
+ function createUnloadHandlerContainer() {
1837
+ var handlers = [];
1838
+ function _addHandler(handler) {
1839
+ if (handler) {
1840
+ handlers.push(handler);
1545
1841
  }
1546
- value = mwcRandom32() & MaxUInt32;
1547
- }
1548
- else {
1549
- value = Math.floor((UInt32Mask * Math.random()) | 0);
1550
- }
1551
- if (!signed) {
1552
- value >>>= 0;
1553
1842
  }
1554
- return value;
1555
- }
1556
- function mwcRandom32(signed) {
1557
- _mwcZ = (36969 * (_mwcZ & 0xFFFF) + (_mwcZ >> 16)) & MaxUInt32;
1558
- _mwcW = (18000 * (_mwcW & 0xFFFF) + (_mwcW >> 16)) & MaxUInt32;
1559
- var value = (((_mwcZ << 16) + (_mwcW & 0xFFFF)) >>> 0) & MaxUInt32 | 0;
1560
- if (!signed) {
1561
- value >>>= 0;
1843
+ function _runHandlers(unloadCtx, unloadState) {
1844
+ arrForEach(handlers, function (handler) {
1845
+ try {
1846
+ handler(unloadCtx, unloadState);
1847
+ }
1848
+ catch (e) {
1849
+ _throwInternal(unloadCtx.diagLog(), 2 , 73 , "Unexpected error calling unload handler - " + dumpObj(e));
1850
+ }
1851
+ });
1852
+ handlers = [];
1562
1853
  }
1563
- return value;
1854
+ return {
1855
+ add: _addHandler,
1856
+ run: _runHandlers
1857
+ };
1564
1858
  }
1565
1859
 
1566
- function newId(maxLength) {
1567
- if (maxLength === void 0) { maxLength = 22; }
1568
- var base64chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
1569
- var number = random32() >>> 0;
1570
- var chars = 0;
1571
- var result = "";
1572
- while (result.length < maxLength) {
1573
- chars++;
1574
- result += base64chars.charAt(number & 0x3F);
1575
- number >>>= 6;
1576
- if (chars === 5) {
1577
- number = (((random32() << 2) & 0xFFFFFFFF) | (number & 0x03)) >>> 0;
1578
- chars = 0;
1860
+ var strGetPlugin = "getPlugin";
1861
+ var BaseTelemetryPlugin = /** @class */ (function () {
1862
+ function BaseTelemetryPlugin() {
1863
+ var _self = this;
1864
+ var _isinitialized;
1865
+ var _rootCtx;
1866
+ var _nextPlugin;
1867
+ var _unloadHandlerContainer;
1868
+ var _hooks;
1869
+ _initDefaults();
1870
+ dynamicProto(BaseTelemetryPlugin, _self, function (_self) {
1871
+ _self.initialize = function (config, core, extensions, pluginChain) {
1872
+ _setDefaults(config, core, pluginChain);
1873
+ _isinitialized = true;
1874
+ };
1875
+ _self.teardown = function (unloadCtx, unloadState) {
1876
+ if (!_self.core || (unloadCtx && _self.core !== unloadCtx.core())) {
1877
+ return;
1878
+ }
1879
+ var result;
1880
+ var unloadDone = false;
1881
+ var theUnloadCtx = unloadCtx || createProcessTelemetryUnloadContext(null, {}, _self.core, _nextPlugin && _nextPlugin[strGetPlugin] ? _nextPlugin[strGetPlugin]() : _nextPlugin);
1882
+ var theUnloadState = unloadState || {
1883
+ reason: 0 ,
1884
+ isAsync: false
1885
+ };
1886
+ function _unloadCallback() {
1887
+ if (!unloadDone) {
1888
+ unloadDone = true;
1889
+ _unloadHandlerContainer.run(theUnloadCtx, unloadState);
1890
+ arrForEach(_hooks, function (fn) {
1891
+ fn.rm();
1892
+ });
1893
+ _hooks = [];
1894
+ if (result === true) {
1895
+ theUnloadCtx.processNext(theUnloadState);
1896
+ }
1897
+ _initDefaults();
1898
+ }
1899
+ }
1900
+ if (!_self[strDoTeardown] || _self[strDoTeardown](theUnloadCtx, theUnloadState, _unloadCallback) !== true) {
1901
+ _unloadCallback();
1902
+ }
1903
+ else {
1904
+ result = true;
1905
+ }
1906
+ return result;
1907
+ };
1908
+ _self.update = function (updateCtx, updateState) {
1909
+ if (!_self.core || (updateCtx && _self.core !== updateCtx.core())) {
1910
+ return;
1911
+ }
1912
+ var result;
1913
+ var updateDone = false;
1914
+ var theUpdateCtx = updateCtx || createProcessTelemetryUpdateContext(null, {}, _self.core, _nextPlugin && _nextPlugin[strGetPlugin] ? _nextPlugin[strGetPlugin]() : _nextPlugin);
1915
+ var theUpdateState = updateState || {
1916
+ reason: 0
1917
+ };
1918
+ function _updateCallback() {
1919
+ if (!updateDone) {
1920
+ updateDone = true;
1921
+ _setDefaults(theUpdateCtx.getCfg(), theUpdateCtx.core(), theUpdateCtx.getNext());
1922
+ }
1923
+ }
1924
+ if (!_self._doUpdate || _self._doUpdate(theUpdateCtx, theUpdateState, _updateCallback) !== true) {
1925
+ _updateCallback();
1926
+ }
1927
+ else {
1928
+ result = true;
1929
+ }
1930
+ return result;
1931
+ };
1932
+ _self._addHook = function (hooks) {
1933
+ if (hooks) {
1934
+ if (isArray(hooks)) {
1935
+ _hooks = _hooks.concat(hooks);
1936
+ }
1937
+ else {
1938
+ _hooks.push(hooks);
1939
+ }
1940
+ }
1941
+ };
1942
+ proxyFunctionAs(_self, "_addUnloadCb", function () { return _unloadHandlerContainer; }, "add");
1943
+ });
1944
+ _self.diagLog = function (itemCtx) {
1945
+ return _getTelCtx(itemCtx).diagLog();
1946
+ };
1947
+ _self[strIsInitialized] = function () {
1948
+ return _isinitialized;
1949
+ };
1950
+ _self.setInitialized = function (isInitialized) {
1951
+ _isinitialized = isInitialized;
1952
+ };
1953
+ _self[strSetNextPlugin] = function (next) {
1954
+ _nextPlugin = next;
1955
+ };
1956
+ _self.processNext = function (env, itemCtx) {
1957
+ if (itemCtx) {
1958
+ itemCtx.processNext(env);
1959
+ }
1960
+ else if (_nextPlugin && isFunction(_nextPlugin.processTelemetry)) {
1961
+ _nextPlugin.processTelemetry(env, null);
1962
+ }
1963
+ };
1964
+ _self._getTelCtx = _getTelCtx;
1965
+ function _getTelCtx(currentCtx) {
1966
+ if (currentCtx === void 0) { currentCtx = null; }
1967
+ var itemCtx = currentCtx;
1968
+ if (!itemCtx) {
1969
+ var rootCtx = _rootCtx || createProcessTelemetryContext(null, {}, _self.core);
1970
+ if (_nextPlugin && _nextPlugin[strGetPlugin]) {
1971
+ itemCtx = rootCtx.createNew(null, _nextPlugin[strGetPlugin]);
1972
+ }
1973
+ else {
1974
+ itemCtx = rootCtx.createNew(null, _nextPlugin);
1975
+ }
1976
+ }
1977
+ return itemCtx;
1978
+ }
1979
+ function _setDefaults(config, core, pluginChain) {
1980
+ if (config) {
1981
+ setValue(config, strExtensionConfig, [], null, isNullOrUndefined);
1982
+ }
1983
+ if (!pluginChain && core) {
1984
+ pluginChain = core.getProcessTelContext().getNext();
1985
+ }
1986
+ var nextPlugin = _nextPlugin;
1987
+ if (_nextPlugin && _nextPlugin[strGetPlugin]) {
1988
+ nextPlugin = _nextPlugin[strGetPlugin]();
1989
+ }
1990
+ _self.core = core;
1991
+ _rootCtx = createProcessTelemetryContext(pluginChain, config, core, nextPlugin);
1992
+ }
1993
+ function _initDefaults() {
1994
+ _isinitialized = false;
1995
+ _self.core = null;
1996
+ _rootCtx = null;
1997
+ _nextPlugin = null;
1998
+ _hooks = [];
1999
+ _unloadHandlerContainer = createUnloadHandlerContainer();
1579
2000
  }
1580
2001
  }
1581
- return result;
1582
- }
2002
+ return BaseTelemetryPlugin;
2003
+ }());
2004
+
1583
2005
  function generateW3CId() {
1584
2006
  var hexValues = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f"];
1585
- var oct = "", tmp;
2007
+ var oct = strEmpty$1, tmp;
1586
2008
  for (var a = 0; a < 4; a++) {
1587
2009
  tmp = random32();
1588
2010
  oct +=
@@ -1619,7 +2041,7 @@
1619
2041
  name = strTrim(name.toString());
1620
2042
  if (name.length > 150 ) {
1621
2043
  nameTrunc = name.substring(0, 150 );
1622
- logger && logger.throwInternal(LoggingSeverity.WARNING, _InternalMessageId.NameTooLong, "name is too long. It has been truncated to " + 150 + " characters.", { name: name }, true);
2044
+ _throwInternal(logger, 2 , 57 , "name is too long. It has been truncated to " + 150 + " characters.", { name: name }, true);
1623
2045
  }
1624
2046
  }
1625
2047
  return nameTrunc || name;
@@ -1632,13 +2054,13 @@
1632
2054
  value = strTrim(value);
1633
2055
  if (value.toString().length > maxLength) {
1634
2056
  valueTrunc = value.toString().substring(0, maxLength);
1635
- logger && logger.throwInternal(LoggingSeverity.WARNING, _InternalMessageId.StringValueTooLong, "string value is too long. It has been truncated to " + maxLength + " characters.", { value: value }, true);
2057
+ _throwInternal(logger, 2 , 61 , "string value is too long. It has been truncated to " + maxLength + " characters.", { value: value }, true);
1636
2058
  }
1637
2059
  }
1638
2060
  return valueTrunc || value;
1639
2061
  }
1640
2062
  function dataSanitizeUrl(logger, url) {
1641
- return dataSanitizeInput(logger, url, 2048 , _InternalMessageId.UrlTooLong);
2063
+ return dataSanitizeInput(logger, url, 2048 , 66 );
1642
2064
  }
1643
2065
  function dataSanitizeProperties(logger, properties) {
1644
2066
  if (properties) {
@@ -1649,7 +2071,7 @@
1649
2071
  value = getJSON().stringify(value);
1650
2072
  }
1651
2073
  catch (e) {
1652
- logger && logger.throwInternal(LoggingSeverity.WARNING, _InternalMessageId.CannotSerializeObjectNonSerializable, "custom property is not valid", { exception: e }, true);
2074
+ _throwInternal(logger, 2 , 49 , "custom property is not valid", { exception: e }, true);
1653
2075
  }
1654
2076
  }
1655
2077
  value = dataSanitizeString(logger, value, 8192 );
@@ -1672,7 +2094,7 @@
1672
2094
  return measurements;
1673
2095
  }
1674
2096
  function dataSanitizeId(logger, id) {
1675
- return id ? dataSanitizeInput(logger, id, 128 , _InternalMessageId.IdTooLong).toString() : id;
2097
+ return id ? dataSanitizeInput(logger, id, 128 , 69 ).toString() : id;
1676
2098
  }
1677
2099
  function dataSanitizeInput(logger, input, maxLength, _msgId) {
1678
2100
  var inputTrunc;
@@ -1680,7 +2102,7 @@
1680
2102
  input = strTrim(input);
1681
2103
  if (input.length > maxLength) {
1682
2104
  inputTrunc = input.substring(0, maxLength);
1683
- logger && logger.throwInternal(LoggingSeverity.WARNING, _msgId, "input is too long, it has been truncated to " + maxLength + " characters.", { data: input }, true);
2105
+ _throwInternal(logger, 2 , _msgId, "input is too long, it has been truncated to " + maxLength + " characters.", { data: input }, true);
1684
2106
  }
1685
2107
  }
1686
2108
  return inputTrunc || input;
@@ -1690,21 +2112,22 @@
1690
2112
  return s.substr(s.length - 3);
1691
2113
  }
1692
2114
 
2115
+ var strEmpty = "";
1693
2116
  function msToTimeSpan(totalms) {
1694
2117
  if (isNaN(totalms) || totalms < 0) {
1695
2118
  totalms = 0;
1696
2119
  }
1697
2120
  totalms = Math.round(totalms);
1698
- var ms = "" + totalms % 1000;
1699
- var sec = "" + Math.floor(totalms / 1000) % 60;
1700
- var min = "" + Math.floor(totalms / (1000 * 60)) % 60;
1701
- var hour = "" + Math.floor(totalms / (1000 * 60 * 60)) % 24;
2121
+ var ms = strEmpty + totalms % 1000;
2122
+ var sec = strEmpty + Math.floor(totalms / 1000) % 60;
2123
+ var min = strEmpty + Math.floor(totalms / (1000 * 60)) % 60;
2124
+ var hour = strEmpty + Math.floor(totalms / (1000 * 60 * 60)) % 24;
1702
2125
  var days = Math.floor(totalms / (1000 * 60 * 60 * 24));
1703
2126
  ms = ms.length === 1 ? "00" + ms : ms.length === 2 ? "0" + ms : ms;
1704
2127
  sec = sec.length < 2 ? "0" + sec : sec;
1705
2128
  min = min.length < 2 ? "0" + min : min;
1706
2129
  hour = hour.length < 2 ? "0" + hour : hour;
1707
- return (days > 0 ? days + "." : "") + hour + ":" + min + ":" + sec + "." + ms;
2130
+ return (days > 0 ? days + "." : strEmpty) + hour + ":" + min + ":" + sec + "." + ms;
1708
2131
  }
1709
2132
  function getExtensionByName(extensions, identifier) {
1710
2133
  var extension = null;
@@ -1719,17 +2142,15 @@
1719
2142
 
1720
2143
  var strNotSpecified = "not_specified";
1721
2144
 
1722
- var StorageType;
1723
- (function (StorageType) {
1724
- StorageType[StorageType["LocalStorage"] = 0] = "LocalStorage";
1725
- StorageType[StorageType["SessionStorage"] = 1] = "SessionStorage";
1726
- })(StorageType || (StorageType = {}));
1727
- var DistributedTracingModes;
1728
- (function (DistributedTracingModes) {
1729
- DistributedTracingModes[DistributedTracingModes["AI"] = 0] = "AI";
1730
- DistributedTracingModes[DistributedTracingModes["AI_AND_W3C"] = 1] = "AI_AND_W3C";
1731
- DistributedTracingModes[DistributedTracingModes["W3C"] = 2] = "W3C";
1732
- })(DistributedTracingModes || (DistributedTracingModes = {}));
2145
+ var StorageType = createEnumStyle({
2146
+ LocalStorage: 0 ,
2147
+ SessionStorage: 1
2148
+ });
2149
+ createEnumStyle({
2150
+ AI: 0 ,
2151
+ AI_AND_W3C: 1 ,
2152
+ W3C: 2
2153
+ });
1733
2154
 
1734
2155
  var _canUseLocalStorage = undefined;
1735
2156
  function _getLocalStorageObject() {
@@ -1756,8 +2177,8 @@
1756
2177
  }
1757
2178
  return null;
1758
2179
  }
1759
- function utlCanUseLocalStorage() {
1760
- if (_canUseLocalStorage === undefined) {
2180
+ function utlCanUseLocalStorage(reset) {
2181
+ if (reset || _canUseLocalStorage === undefined) {
1761
2182
  _canUseLocalStorage = !!_getVerifiedStorageObject(StorageType.LocalStorage);
1762
2183
  }
1763
2184
  return _canUseLocalStorage;
@@ -1770,7 +2191,7 @@
1770
2191
  }
1771
2192
  catch (e) {
1772
2193
  _canUseLocalStorage = false;
1773
- logger.throwInternal(LoggingSeverity.WARNING, _InternalMessageId.BrowserCannotReadLocalStorage, "Browser failed read of local storage. " + getExceptionName(e), { exception: dumpObj(e) });
2194
+ _throwInternal(logger, 2 , 1 , "Browser failed read of local storage. " + getExceptionName(e), { exception: dumpObj(e) });
1774
2195
  }
1775
2196
  }
1776
2197
  return null;
@@ -1784,7 +2205,7 @@
1784
2205
  }
1785
2206
  catch (e) {
1786
2207
  _canUseLocalStorage = false;
1787
- logger.throwInternal(LoggingSeverity.WARNING, _InternalMessageId.BrowserCannotWriteLocalStorage, "Browser failed write to local storage. " + getExceptionName(e), { exception: dumpObj(e) });
2208
+ _throwInternal(logger, 2 , 3 , "Browser failed write to local storage. " + getExceptionName(e), { exception: dumpObj(e) });
1788
2209
  }
1789
2210
  }
1790
2211
  return false;
@@ -1798,38 +2219,15 @@
1798
2219
  }
1799
2220
  catch (e) {
1800
2221
  _canUseLocalStorage = false;
1801
- logger.throwInternal(LoggingSeverity.WARNING, _InternalMessageId.BrowserFailedRemovalFromLocalStorage, "Browser failed removal of local storage item. " + getExceptionName(e), { exception: dumpObj(e) });
2222
+ _throwInternal(logger, 2 , 5 , "Browser failed removal of local storage item. " + getExceptionName(e), { exception: dumpObj(e) });
1802
2223
  }
1803
2224
  }
1804
2225
  return false;
1805
2226
  }
1806
2227
 
1807
- var EventData = /** @class */ (function () {
1808
- function EventData() {
1809
- this.ver = 2;
1810
- this.properties = {};
1811
- this.measurements = {};
1812
- }
1813
- return EventData;
1814
- }());
1815
-
1816
- var PageViewData = /** @class */ (function (_super) {
1817
- __extendsFn(PageViewData, _super);
1818
- function PageViewData() {
1819
- var _this = _super.call(this) || this;
1820
- _this.ver = 2;
1821
- _this.properties = {};
1822
- _this.measurements = {};
1823
- return _this;
1824
- }
1825
- return PageViewData;
1826
- }(EventData));
1827
-
1828
- var PageView = /** @class */ (function (_super) {
1829
- __extendsFn(PageView, _super);
2228
+ var PageView = /** @class */ (function () {
1830
2229
  function PageView(logger, name, url, durationMs, properties, measurements, id) {
1831
- var _this = _super.call(this) || this;
1832
- _this.aiDataContract = {
2230
+ this.aiDataContract = {
1833
2231
  ver: 1 ,
1834
2232
  name: 0 ,
1835
2233
  url: 0 ,
@@ -1838,20 +2236,21 @@
1838
2236
  measurements: 0 ,
1839
2237
  id: 0
1840
2238
  };
1841
- _this.id = dataSanitizeId(logger, id);
1842
- _this.url = dataSanitizeUrl(logger, url);
1843
- _this.name = dataSanitizeString(logger, name) || strNotSpecified;
2239
+ var _self = this;
2240
+ _self.ver = 2;
2241
+ _self.id = dataSanitizeId(logger, id);
2242
+ _self.url = dataSanitizeUrl(logger, url);
2243
+ _self.name = dataSanitizeString(logger, name) || strNotSpecified;
1844
2244
  if (!isNaN(durationMs)) {
1845
- _this.duration = msToTimeSpan(durationMs);
2245
+ _self.duration = msToTimeSpan(durationMs);
1846
2246
  }
1847
- _this.properties = dataSanitizeProperties(logger, properties);
1848
- _this.measurements = dataSanitizeMeasurements(logger, measurements);
1849
- return _this;
2247
+ _self.properties = dataSanitizeProperties(logger, properties);
2248
+ _self.measurements = dataSanitizeMeasurements(logger, measurements);
1850
2249
  }
1851
2250
  PageView.envelopeType = "Microsoft.ApplicationInsights.{0}.Pageview";
1852
2251
  PageView.dataType = "PageviewData";
1853
2252
  return PageView;
1854
- }(PageViewData));
2253
+ }());
1855
2254
 
1856
2255
  function _aiNameFunc(baseName) {
1857
2256
  var aiName = "ai." + baseName + ".";
@@ -2029,10 +2428,10 @@
2029
2428
  var acqMs = +tokens[1] || 0;
2030
2429
  var renewalMs = +tokens[2] || 0;
2031
2430
  if (isNaN(acqMs) || acqMs <= 0) {
2032
- _logger.throwInternal(LoggingSeverity.WARNING, _InternalMessageId.SessionRenewalDateIsZero, "AI session acquisition date is 0" + sessionReset);
2431
+ _throwInternal(_logger, 2 , 27 , "AI session acquisition date is 0" + sessionReset);
2033
2432
  }
2034
2433
  else if (isNaN(renewalMs) || renewalMs <= 0) {
2035
- _logger.throwInternal(LoggingSeverity.WARNING, _InternalMessageId.SessionRenewalDateIsZero, "AI session renewal date is 0" + sessionReset);
2434
+ _throwInternal(_logger, 2 , 27 , "AI session renewal date is 0" + sessionReset);
2036
2435
  }
2037
2436
  else if (tokens[0]) {
2038
2437
  session.id = tokens[0];
@@ -2042,7 +2441,7 @@
2042
2441
  }
2043
2442
  }
2044
2443
  catch (e) {
2045
- _logger.throwInternal(LoggingSeverity.CRITICAL, _InternalMessageId.ErrorParsingAISessionCookie, "Error parsing ai_session value [" + (sessionData || "") + "]" + sessionReset + " - " + getExceptionName(e), { exception: dumpObj(e) });
2444
+ _throwInternal(_logger, 1 , 9 , "Error parsing ai_session value [" + (sessionData || "") + "]" + sessionReset + " - " + getExceptionName(e), { exception: dumpObj(e) });
2046
2445
  }
2047
2446
  }
2048
2447
  return isValid;
@@ -2054,7 +2453,7 @@
2054
2453
  _self.automaticSession.acquisitionDate = nowMs;
2055
2454
  _setCookie(_self.automaticSession, nowMs);
2056
2455
  if (!utlCanUseLocalStorage()) {
2057
- _logger.throwInternal(LoggingSeverity.WARNING, _InternalMessageId.BrowserDoesNotSupportLocalStorage, "Browser does not support local storage. Session durations will be inaccurate.");
2456
+ _throwInternal(_logger, 2 , 0 , "Browser does not support local storage. Session durations will be inaccurate.");
2058
2457
  }
2059
2458
  }
2060
2459
  function _setCookie(session, nowMs) {
@@ -2100,7 +2499,7 @@
2100
2499
  return Device;
2101
2500
  }());
2102
2501
 
2103
- var Version = "2.8.0-nightly.2202-06";
2502
+ var Version = "2.8.0-nightly.2204-06";
2104
2503
  var Internal = /** @class */ (function () {
2105
2504
  function Internal(config) {
2106
2505
  this.sdkVersion = (config.sdkExtension && config.sdkExtension() ? config.sdkExtension() + "_" : "") + "javascript:" + Version;
@@ -2176,7 +2575,7 @@
2176
2575
  if (storeInCookie === void 0) { storeInCookie = false; }
2177
2576
  var isInvalidInput = !_validateUserInput(authenticatedUserId) || (accountId && !_validateUserInput(accountId));
2178
2577
  if (isInvalidInput) {
2179
- _logger.throwInternal(LoggingSeverity.WARNING, _InternalMessageId.SetAuthContextFailedAccountName, "Setting auth user context failed. " +
2578
+ _throwInternal(_logger, 2 , 60 , "Setting auth user context failed. " +
2180
2579
  "User auth/account id should be of type string, and not contain commas, semi-colons, equal signs, spaces, or vertical-bars.", true);
2181
2580
  return;
2182
2581
  }
@@ -2393,8 +2792,8 @@
2393
2792
  _processTelemetryInternal(event, itemCtx);
2394
2793
  if (userCtx && userCtx.isNewUser) {
2395
2794
  userCtx.isNewUser = false;
2396
- var message = new _InternalLogMessage(_InternalMessageId.SendBrowserInfoOnUserInit, ((getNavigator() || {}).userAgent || ""));
2397
- itemCtx.diagLog().logInternalMessage(LoggingSeverity.CRITICAL, message);
2795
+ var message = new _InternalLogMessage(72 , ((getNavigator() || {}).userAgent || ""));
2796
+ _logInternalMessage(itemCtx.diagLog(), 1 , message);
2398
2797
  }
2399
2798
  _self.processNext(event, itemCtx);
2400
2799
  }