@microsoft/applicationinsights-properties-js 2.8.0-beta.2203-01 → 2.8.0-beta.2203-04

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * Application Insights JavaScript SDK - Properties Plugin, 2.8.0-beta.2203-01
2
+ * Application Insights JavaScript SDK - Properties Plugin, 2.8.0-beta.2203-04
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  */
5
5
  (function (global, factory) {
@@ -322,95 +322,13 @@
322
322
  };
323
323
  dynamicProto[DynProtoDefaultOptions] = perfDefaults;
324
324
 
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
- };
325
+ var strEmpty$1 = "";
326
+ var strSetNextPlugin = "setNextPlugin";
327
+ var strIsInitialized = "isInitialized";
328
+ var strTeardown = "teardown";
329
+ var strCore = "core";
330
+ var strDisabled = "disabled";
331
+ var strDoTeardown = "_doTeardown";
414
332
 
415
333
  var strToISOString = "toISOString";
416
334
  var cStrEndsWith = "endsWith";
@@ -418,7 +336,7 @@
418
336
  var strToString = "toString";
419
337
  var str__Proto = "__proto__";
420
338
  var strConstructor = "constructor";
421
- var _objDefineProperty = ObjDefineProperty;
339
+ var _objDefineProperty$1 = ObjDefineProperty;
422
340
  var _objFreeze = ObjClass.freeze;
423
341
  var _objKeys = ObjClass.keys;
424
342
  var StringProto = String[strShimPrototype];
@@ -430,6 +348,9 @@
430
348
  var _objToString = ObjProto[strToString];
431
349
  var _fnToString = ObjHasOwnProperty[strToString];
432
350
  var _objFunctionString = _fnToString.call(ObjClass);
351
+ var rCamelCase = /-([a-z])/g;
352
+ var rNormalizeInvalid = /([^\w\d_$])/g;
353
+ var rLeadingNumeric = /^(\d+[\w\d_$])/;
433
354
  var _objGetPrototypeOf = Object["getPrototypeOf"];
434
355
  function _getObjProto(target) {
435
356
  if (target) {
@@ -458,6 +379,19 @@
458
379
  function isFunction(value) {
459
380
  return !!(value && typeof value === strShimFunction);
460
381
  }
382
+ function normalizeJsName(name) {
383
+ var value = name;
384
+ if (value && isString(value)) {
385
+ value = value.replace(rCamelCase, function (_all, letter) {
386
+ return letter.toUpperCase();
387
+ });
388
+ value = value.replace(rNormalizeInvalid, "_");
389
+ value = value.replace(rLeadingNumeric, function (_all, match) {
390
+ return "_" + match;
391
+ });
392
+ }
393
+ return value;
394
+ }
461
395
  function objForEachKey(target, callbackfn) {
462
396
  if (target) {
463
397
  for (var prop in target) {
@@ -604,7 +538,7 @@
604
538
  return result;
605
539
  }
606
540
  function objDefineAccessors(target, prop, getProp, setProp) {
607
- if (_objDefineProperty) {
541
+ if (_objDefineProperty$1) {
608
542
  try {
609
543
  var descriptor = {
610
544
  enumerable: true,
@@ -616,7 +550,7 @@
616
550
  if (setProp) {
617
551
  descriptor.set = setProp;
618
552
  }
619
- _objDefineProperty(target, prop, descriptor);
553
+ _objDefineProperty$1(target, prop, descriptor);
620
554
  return true;
621
555
  }
622
556
  catch (e) {
@@ -636,7 +570,7 @@
636
570
  if (isError(object)) {
637
571
  return object.name;
638
572
  }
639
- return "";
573
+ return strEmpty$1;
640
574
  }
641
575
  function setValue(target, field, value, valChk, srcChk) {
642
576
  var theValue = value;
@@ -666,6 +600,36 @@
666
600
  function isTruthy(value) {
667
601
  return !!value;
668
602
  }
603
+ function throwError(message) {
604
+ throw new Error(message);
605
+ }
606
+ function _createProxyFunction(source, funcName) {
607
+ var srcFunc = null;
608
+ var src = null;
609
+ if (isFunction(source)) {
610
+ srcFunc = source;
611
+ }
612
+ else {
613
+ src = source;
614
+ }
615
+ return function () {
616
+ var originalArguments = arguments;
617
+ if (srcFunc) {
618
+ src = srcFunc();
619
+ }
620
+ if (src) {
621
+ return src[funcName].apply(src, originalArguments);
622
+ }
623
+ };
624
+ }
625
+ function proxyFunctionAs(target, name, source, theFunc, overwriteTarget) {
626
+ if (overwriteTarget === void 0) { overwriteTarget = true; }
627
+ if (target && name && source) {
628
+ if (overwriteTarget || isUndefined(target[name])) {
629
+ target[name] = _createProxyFunction(source, theFunc);
630
+ }
631
+ }
632
+ }
669
633
  function createClassFromInterface(defaults) {
670
634
  return /** @class */ (function () {
671
635
  function class_1() {
@@ -679,6 +643,17 @@
679
643
  return class_1;
680
644
  }());
681
645
  }
646
+ function createEnumStyle(values) {
647
+ var enumClass = {};
648
+ objForEachKey(values, function (field, value) {
649
+ enumClass[field] = value;
650
+ if (!isUndefined(enumClass[value])) {
651
+ throwError("[" + value + "] exists for " + field);
652
+ }
653
+ enumClass[value] = field;
654
+ });
655
+ return objFreeze(enumClass);
656
+ }
682
657
  function objExtend(obj, obj2, obj3, obj4, obj5, obj6) {
683
658
  var theArgs = arguments;
684
659
  var extended = theArgs[0] || {};
@@ -805,14 +780,14 @@
805
780
  var nav = getNavigator();
806
781
  if (nav && (nav.userAgent !== _navUserAgentCheck || _isTrident === null)) {
807
782
  _navUserAgentCheck = nav.userAgent;
808
- var userAgent = (_navUserAgentCheck || "").toLowerCase();
783
+ var userAgent = (_navUserAgentCheck || strEmpty$1).toLowerCase();
809
784
  _isTrident = (strContains(userAgent, strMsie) || strContains(userAgent, strTrident));
810
785
  }
811
786
  return _isTrident;
812
787
  }
813
788
  function dumpObj(object) {
814
789
  var objectTypeDump = Object[strShimPrototype].toString.call(object);
815
- var propertyValueDump = "";
790
+ var propertyValueDump = strEmpty$1;
816
791
  if (objectTypeDump === "[object Error]") {
817
792
  propertyValueDump = "{ stack: '" + object.stack + "', message: '" + object.message + "', name: '" + object.name + "'";
818
793
  }
@@ -845,9 +820,9 @@
845
820
  var strWarnToConsole = "warnToConsole";
846
821
  function _sanitizeDiagnosticText(text) {
847
822
  if (text) {
848
- return "\"" + text.replace(/\"/g, "") + "\"";
823
+ return "\"" + text.replace(/\"/g, strEmpty$1) + "\"";
849
824
  }
850
- return "";
825
+ return strEmpty$1;
851
826
  }
852
827
  function _logToConsole(func, message) {
853
828
  var theConsole = getConsole();
@@ -869,12 +844,12 @@
869
844
  _self.message =
870
845
  (isUserAct ? AiUserActionablePrefix : AiNonUserActionablePrefix) +
871
846
  msgId;
872
- var strProps = "";
847
+ var strProps = strEmpty$1;
873
848
  if (hasJSON()) {
874
849
  strProps = getJSON().stringify(properties);
875
850
  }
876
- var diagnosticText = (msg ? " message:" + _sanitizeDiagnosticText(msg) : "") +
877
- (properties ? " props:" + _sanitizeDiagnosticText(strProps) : "");
851
+ var diagnosticText = (msg ? " message:" + _sanitizeDiagnosticText(msg) : strEmpty$1) +
852
+ (properties ? " props:" + _sanitizeDiagnosticText(strProps) : strEmpty$1);
878
853
  _self.message += diagnosticText;
879
854
  }
880
855
  _InternalLogMessage.dataType = "MessageData";
@@ -904,7 +879,7 @@
904
879
  throw message;
905
880
  }
906
881
  else {
907
- var logFunc = severity === LoggingSeverity.CRITICAL ? strErrorToConsole : strWarnToConsole;
882
+ var logFunc = severity === 1 ? strErrorToConsole : strWarnToConsole;
908
883
  if (!isUndefined(message.message)) {
909
884
  var logLevel = _self.consoleLoggingLevel();
910
885
  if (isUserAct) {
@@ -922,7 +897,7 @@
922
897
  _self.logInternalMessage(severity, message);
923
898
  }
924
899
  else {
925
- _debugExtMsg("throw" + (severity === LoggingSeverity.CRITICAL ? "Critical" : "Warning"), message);
900
+ _debugExtMsg("throw" + (severity === 1 ? "Critical" : "Warning"), message);
926
901
  }
927
902
  }
928
903
  };
@@ -954,13 +929,13 @@
954
929
  if (severity <= _self.telemetryLoggingLevel()) {
955
930
  _self.queue.push(message);
956
931
  _messageCount++;
957
- _debugExtMsg((severity === LoggingSeverity.CRITICAL ? "error" : "warn"), message);
932
+ _debugExtMsg((severity === 1 ? "error" : "warn"), message);
958
933
  }
959
934
  if (_messageCount === _self.maxInternalMessageLimit()) {
960
935
  var throttleLimitMessage = "Internal events throttle limit per PageView reached for this app.";
961
- var throttleMessage = new _InternalLogMessage(_InternalMessageId.MessageLimitPerPVExceeded, throttleLimitMessage, false);
936
+ var throttleMessage = new _InternalLogMessage(23 , throttleLimitMessage, false);
962
937
  _self.queue.push(throttleMessage);
963
- if (severity === LoggingSeverity.CRITICAL) {
938
+ if (severity === 1 ) {
964
939
  _self.errorToConsole(throttleLimitMessage);
965
940
  }
966
941
  else {
@@ -1102,6 +1077,151 @@
1102
1077
  return func();
1103
1078
  }
1104
1079
 
1080
+ var UInt32Mask = 0x100000000;
1081
+ var MaxUInt32 = 0xffffffff;
1082
+ var _mwcSeeded = false;
1083
+ var _mwcW = 123456789;
1084
+ var _mwcZ = 987654321;
1085
+ function _mwcSeed(seedValue) {
1086
+ if (seedValue < 0) {
1087
+ seedValue >>>= 0;
1088
+ }
1089
+ _mwcW = (123456789 + seedValue) & MaxUInt32;
1090
+ _mwcZ = (987654321 - seedValue) & MaxUInt32;
1091
+ _mwcSeeded = true;
1092
+ }
1093
+ function _autoSeedMwc() {
1094
+ try {
1095
+ var now = dateNow() & 0x7fffffff;
1096
+ _mwcSeed(((Math.random() * UInt32Mask) ^ now) + now);
1097
+ }
1098
+ catch (e) {
1099
+ }
1100
+ }
1101
+ function random32(signed) {
1102
+ var value = 0;
1103
+ var c = getCrypto() || getMsCrypto();
1104
+ if (c && c.getRandomValues) {
1105
+ value = c.getRandomValues(new Uint32Array(1))[0] & MaxUInt32;
1106
+ }
1107
+ if (value === 0 && isIE()) {
1108
+ if (!_mwcSeeded) {
1109
+ _autoSeedMwc();
1110
+ }
1111
+ value = mwcRandom32() & MaxUInt32;
1112
+ }
1113
+ if (value === 0) {
1114
+ value = Math.floor((UInt32Mask * Math.random()) | 0);
1115
+ }
1116
+ if (!signed) {
1117
+ value >>>= 0;
1118
+ }
1119
+ return value;
1120
+ }
1121
+ function mwcRandom32(signed) {
1122
+ _mwcZ = (36969 * (_mwcZ & 0xFFFF) + (_mwcZ >> 16)) & MaxUInt32;
1123
+ _mwcW = (18000 * (_mwcW & 0xFFFF) + (_mwcW >> 16)) & MaxUInt32;
1124
+ var value = (((_mwcZ << 16) + (_mwcW & 0xFFFF)) >>> 0) & MaxUInt32 | 0;
1125
+ if (!signed) {
1126
+ value >>>= 0;
1127
+ }
1128
+ return value;
1129
+ }
1130
+ function newId(maxLength) {
1131
+ if (maxLength === void 0) { maxLength = 22; }
1132
+ var base64chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
1133
+ var number = random32() >>> 0;
1134
+ var chars = 0;
1135
+ var result = strEmpty$1;
1136
+ while (result.length < maxLength) {
1137
+ chars++;
1138
+ result += base64chars.charAt(number & 0x3F);
1139
+ number >>>= 6;
1140
+ if (chars === 5) {
1141
+ number = (((random32() << 2) & 0xFFFFFFFF) | (number & 0x03)) >>> 0;
1142
+ chars = 0;
1143
+ }
1144
+ }
1145
+ return result;
1146
+ }
1147
+
1148
+ var _objDefineProperty = ObjDefineProperty;
1149
+ var version = "2.7.3";
1150
+ var instanceName = "." + newId(6);
1151
+ var _dataUid = 0;
1152
+ function _createAccessor(target, prop, value) {
1153
+ if (_objDefineProperty) {
1154
+ try {
1155
+ _objDefineProperty(target, prop, {
1156
+ value: value,
1157
+ enumerable: false,
1158
+ configurable: true
1159
+ });
1160
+ return true;
1161
+ }
1162
+ catch (e) {
1163
+ }
1164
+ }
1165
+ return false;
1166
+ }
1167
+ function _canAcceptData(target) {
1168
+ return target.nodeType === 1 || target.nodeType === 9 || !(+target.nodeType);
1169
+ }
1170
+ function _getCache(data, target) {
1171
+ var theCache = target[data.id];
1172
+ if (!theCache) {
1173
+ theCache = {};
1174
+ try {
1175
+ if (_canAcceptData(target)) {
1176
+ if (!_createAccessor(target, data.id, theCache)) {
1177
+ target[data.id] = theCache;
1178
+ }
1179
+ }
1180
+ }
1181
+ catch (e) {
1182
+ }
1183
+ }
1184
+ return theCache;
1185
+ }
1186
+ function createUniqueNamespace(name, includeVersion) {
1187
+ if (includeVersion === void 0) { includeVersion = false; }
1188
+ return normalizeJsName(name + (_dataUid++) + (includeVersion ? "." + version : "") + instanceName);
1189
+ }
1190
+ function createElmNodeData(name) {
1191
+ var data = {
1192
+ id: createUniqueNamespace("_aiData-" + (name || "") + "." + version),
1193
+ accept: function (target) {
1194
+ return _canAcceptData(target);
1195
+ },
1196
+ get: function (target, name, defValue, addDefault) {
1197
+ var theCache = target[data.id];
1198
+ if (!theCache) {
1199
+ if (addDefault) {
1200
+ theCache = _getCache(data, target);
1201
+ theCache[normalizeJsName(name)] = defValue;
1202
+ }
1203
+ return defValue;
1204
+ }
1205
+ return theCache[normalizeJsName(name)];
1206
+ },
1207
+ kill: function (target, name) {
1208
+ if (target && target[name]) {
1209
+ try {
1210
+ delete target[name];
1211
+ }
1212
+ catch (e) {
1213
+ }
1214
+ }
1215
+ }
1216
+ };
1217
+ return data;
1218
+ }
1219
+
1220
+ var pluginStateData = createElmNodeData("plugin");
1221
+ function _getPluginState(plugin) {
1222
+ return pluginStateData.get(plugin, "state", {}, true);
1223
+ }
1224
+
1105
1225
  var strTelemetryPluginChain = "TelemetryPluginChain";
1106
1226
  var strHasRunFlags = "_hasRun";
1107
1227
  var strGetTelCtx = "_getTelCtx";
@@ -1115,53 +1235,69 @@
1115
1235
  }
1116
1236
  return createTelemetryProxyChain([startAt], config, core);
1117
1237
  }
1118
- function createProcessTelemetryContext(telemetryChain, config, core, startAt) {
1238
+ function _createInternalContext(telemetryChain, config, core, startAt) {
1119
1239
  var _nextProxy = null;
1120
- var _onComplete = null;
1121
- if (startAt) {
1122
- _nextProxy = _getNextProxyStart(telemetryChain, config, core, startAt);
1123
- }
1124
- else {
1125
- _nextProxy = telemetryChain;
1240
+ var _onComplete = [];
1241
+ if (startAt !== null) {
1242
+ _nextProxy = startAt ? _getNextProxyStart(telemetryChain, config, core, startAt) : telemetryChain;
1126
1243
  }
1127
1244
  var context = {
1128
- core: function () {
1129
- return core;
1130
- },
1131
- diagLog: function () {
1132
- return safeGetLogger(core, config);
1133
- },
1134
- getCfg: function () {
1135
- return config;
1136
- },
1137
- getExtCfg: _getExtCfg,
1138
- getConfig: _getConfig,
1139
- hasNext: function () {
1140
- return _nextProxy != null;
1141
- },
1142
- getNext: function () {
1143
- return _nextProxy;
1144
- },
1145
- setNext: function (nextPlugin) {
1146
- _nextProxy = nextPlugin;
1147
- },
1148
- processNext: function (env) {
1149
- _processChain(function (nextPlugin) {
1150
- nextPlugin.processTelemetry(env, context);
1245
+ _next: _moveNext,
1246
+ ctx: {
1247
+ core: function () { return core; },
1248
+ diagLog: function () {
1249
+ return safeGetLogger(core, config);
1250
+ },
1251
+ getCfg: function () {
1252
+ return config;
1253
+ },
1254
+ getExtCfg: _getExtCfg,
1255
+ getConfig: _getConfig,
1256
+ hasNext: function () {
1257
+ return !!_nextProxy;
1258
+ },
1259
+ getNext: function () {
1260
+ return _nextProxy;
1261
+ },
1262
+ setNext: function (nextPlugin) {
1263
+ _nextProxy = nextPlugin;
1264
+ },
1265
+ iterate: _iterateChain,
1266
+ onComplete: _addOnComplete
1267
+ }
1268
+ };
1269
+ function _addOnComplete(onComplete, that) {
1270
+ var args = [];
1271
+ for (var _i = 2; _i < arguments.length; _i++) {
1272
+ args[_i - 2] = arguments[_i];
1273
+ }
1274
+ if (onComplete) {
1275
+ _onComplete.push({
1276
+ func: onComplete,
1277
+ self: !isUndefined(that) ? that : context.ctx,
1278
+ args: args
1151
1279
  });
1152
- },
1153
- iterate: _iterateChain,
1154
- createNew: function (plugins, startAt) {
1155
- if (plugins === void 0) { plugins = null; }
1156
- if (isArray(plugins)) {
1157
- plugins = createTelemetryProxyChain(plugins, config, core, startAt);
1280
+ }
1281
+ }
1282
+ function _moveNext() {
1283
+ var nextProxy = _nextProxy;
1284
+ _nextProxy = nextProxy ? nextProxy.getNext() : null;
1285
+ if (!nextProxy) {
1286
+ var onComplete = _onComplete;
1287
+ if (onComplete && onComplete.length > 0) {
1288
+ arrForEach(onComplete, function (completeDetails) {
1289
+ try {
1290
+ completeDetails.func.call(completeDetails.self, completeDetails.args);
1291
+ }
1292
+ catch (e) {
1293
+ core.logger.throwInternal(2 , 73 , "Unexpected Exception during onComplete - " + dumpObj(e));
1294
+ }
1295
+ });
1296
+ _onComplete = [];
1158
1297
  }
1159
- return createProcessTelemetryContext(plugins || _nextProxy, config, core, startAt);
1160
- },
1161
- onComplete: function (onComplete) {
1162
- _onComplete = onComplete;
1163
1298
  }
1164
- };
1299
+ return nextProxy;
1300
+ }
1165
1301
  function _getExtCfg(identifier, defaultValue, mergeDefault) {
1166
1302
  if (defaultValue === void 0) { defaultValue = {}; }
1167
1303
  if (mergeDefault === void 0) { mergeDefault = 0 ; }
@@ -1204,29 +1340,53 @@
1204
1340
  }
1205
1341
  return !isNullOrUndefined(theValue) ? theValue : defaultValue;
1206
1342
  }
1207
- function _processChain(cb) {
1208
- var nextPlugin = _nextProxy;
1209
- if (nextPlugin) {
1210
- _nextProxy = nextPlugin.getNext();
1211
- cb(nextPlugin);
1212
- }
1213
- else {
1214
- if (_onComplete) {
1215
- _onComplete();
1216
- _onComplete = null;
1343
+ function _iterateChain(cb) {
1344
+ var nextPlugin;
1345
+ while (!!(nextPlugin = context._next())) {
1346
+ var plugin = nextPlugin.getPlugin();
1347
+ if (plugin) {
1348
+ cb(plugin);
1217
1349
  }
1218
1350
  }
1219
1351
  }
1220
- function _iterateChain(cb) {
1221
- while (_nextProxy) {
1222
- _processChain(function (nextPlugin) {
1223
- var plugin = nextPlugin.getPlugin();
1224
- if (plugin) {
1225
- cb(plugin);
1226
- }
1227
- });
1352
+ return context;
1353
+ }
1354
+ function createProcessTelemetryContext(telemetryChain, config, core, startAt) {
1355
+ var internalContext = _createInternalContext(telemetryChain, config, core, startAt);
1356
+ var context = internalContext.ctx;
1357
+ function _processNext(env) {
1358
+ var nextPlugin = internalContext._next();
1359
+ nextPlugin && nextPlugin.processTelemetry(env, context);
1360
+ return !nextPlugin;
1361
+ }
1362
+ function _createNew(plugins, startAt) {
1363
+ if (plugins === void 0) { plugins = null; }
1364
+ if (isArray(plugins)) {
1365
+ plugins = createTelemetryProxyChain(plugins, config, core, startAt);
1366
+ }
1367
+ return createProcessTelemetryContext(plugins || context.getNext(), config, core, startAt);
1368
+ }
1369
+ context.processNext = _processNext;
1370
+ context.createNew = _createNew;
1371
+ return context;
1372
+ }
1373
+ function createProcessTelemetryUnloadContext(telemetryChain, config, core, startAt) {
1374
+ var internalContext = _createInternalContext(telemetryChain, config, core, startAt);
1375
+ var context = internalContext.ctx;
1376
+ function _processNext(unloadState) {
1377
+ var nextPlugin = internalContext._next();
1378
+ nextPlugin && nextPlugin.unload(context, unloadState);
1379
+ return !nextPlugin;
1380
+ }
1381
+ function _createNew(plugins, startAt) {
1382
+ if (plugins === void 0) { plugins = null; }
1383
+ if (isArray(plugins)) {
1384
+ plugins = createTelemetryProxyChain(plugins, config, core, startAt);
1228
1385
  }
1386
+ return createProcessTelemetryUnloadContext(plugins || context.getNext(), config, core, startAt);
1229
1387
  }
1388
+ context.processNext = _processNext;
1389
+ context.createNew = _createNew;
1230
1390
  return context;
1231
1391
  }
1232
1392
  function createTelemetryProxyChain(plugins, config, core, startAt) {
@@ -1274,32 +1434,35 @@
1274
1434
  return nextProxy;
1275
1435
  },
1276
1436
  processTelemetry: _processTelemetry,
1437
+ unload: _unloadPlugin,
1277
1438
  _id: chainId,
1278
1439
  _setNext: function (nextPlugin) {
1279
1440
  nextProxy = nextPlugin;
1280
1441
  }
1281
1442
  };
1282
- function _processChain(itemCtx, processPluginFn, processProxyFn, name, details, isAsync) {
1443
+ function _getTelCtx() {
1444
+ var itemCtx;
1445
+ if (plugin && isFunction(plugin[strGetTelCtx])) {
1446
+ itemCtx = plugin[strGetTelCtx]();
1447
+ }
1283
1448
  if (!itemCtx) {
1284
- if (plugin && isFunction(plugin[strGetTelCtx])) {
1285
- itemCtx = plugin[strGetTelCtx]();
1286
- }
1287
- if (!itemCtx) {
1288
- itemCtx = createProcessTelemetryContext(proxyChain, config, core);
1289
- }
1449
+ itemCtx = createProcessTelemetryContext(proxyChain, config, core);
1290
1450
  }
1451
+ return itemCtx;
1452
+ }
1453
+ function _processChain(itemCtx, processPluginFn, name, details, isAsync) {
1454
+ var hasRun = false;
1291
1455
  var identifier = plugin ? plugin.identifier : strTelemetryPluginChain;
1292
1456
  var hasRunContext = itemCtx[strHasRunFlags];
1293
1457
  if (!hasRunContext) {
1294
1458
  hasRunContext = itemCtx[strHasRunFlags] = {};
1295
1459
  }
1296
- doPerf(itemCtx.core(), function () { return identifier + ":" + name; }, function () {
1297
- hasRunContext[chainId] = true;
1298
- var hasRun = false;
1299
- itemCtx.setNext(nextProxy);
1300
- if (plugin) {
1460
+ itemCtx.setNext(nextProxy);
1461
+ if (plugin) {
1462
+ doPerf(itemCtx[strCore](), function () { return identifier + ":" + name; }, function () {
1463
+ hasRunContext[chainId] = true;
1301
1464
  try {
1302
- var nextId = nextProxy ? nextProxy._id : "";
1465
+ var nextId = nextProxy ? nextProxy._id : strEmpty$1;
1303
1466
  if (nextId) {
1304
1467
  hasRunContext[nextId] = false;
1305
1468
  }
@@ -1311,18 +1474,21 @@
1311
1474
  hasRun = true;
1312
1475
  }
1313
1476
  if (!nextProxy || !hasNextRun) {
1314
- itemCtx.diagLog().throwInternal(LoggingSeverity.CRITICAL, _InternalMessageId.PluginException, "Plugin [" + plugin.identifier + "] failed during " + name + " - " + dumpObj(error) + ", run flags: " + dumpObj(hasRunContext));
1477
+ itemCtx.diagLog().throwInternal(1 , 73 , "Plugin [" + plugin.identifier + "] failed during " + name + " - " + dumpObj(error) + ", run flags: " + dumpObj(hasRunContext));
1315
1478
  }
1316
1479
  }
1317
- }
1318
- if (nextProxy && !hasRun) {
1319
- processProxyFn(itemCtx);
1320
- }
1321
- }, details, isAsync);
1480
+ }, details, isAsync);
1481
+ }
1482
+ return hasRun;
1322
1483
  }
1323
1484
  function _processTelemetry(env, itemCtx) {
1324
- _processChain(itemCtx, function (itemCtx) {
1325
- if (!hasProcessTelemetry) {
1485
+ itemCtx = itemCtx || _getTelCtx();
1486
+ function _callProcessTelemetry(itemCtx) {
1487
+ if (!plugin || !hasProcessTelemetry) {
1488
+ return false;
1489
+ }
1490
+ var pluginState = _getPluginState(plugin);
1491
+ if (pluginState[strTeardown] || pluginState[strDisabled]) {
1326
1492
  return false;
1327
1493
  }
1328
1494
  if (hasSetNext) {
@@ -1330,9 +1496,31 @@
1330
1496
  }
1331
1497
  plugin.processTelemetry(env, itemCtx);
1332
1498
  return true;
1333
- }, function (itemCtx) {
1334
- nextProxy.processTelemetry(env, itemCtx);
1335
- }, "processTelemetry", function () { return ({ item: env }); }, !(env.sync));
1499
+ }
1500
+ if (!_processChain(itemCtx, _callProcessTelemetry, "processTelemetry", function () { return ({ item: env }); }, !(env.sync))) {
1501
+ itemCtx.processNext(env);
1502
+ }
1503
+ }
1504
+ function _unloadPlugin(unloadCtx, unloadState) {
1505
+ function _callTeardown() {
1506
+ var hasRun = false;
1507
+ if (plugin) {
1508
+ var pluginState = _getPluginState(plugin);
1509
+ var pluginCore = plugin[strCore] || pluginState.core;
1510
+ if (plugin && (!pluginCore || pluginCore === unloadCtx[strCore]()) && !pluginState[strTeardown]) {
1511
+ pluginState[strCore] = null;
1512
+ pluginState[strTeardown] = true;
1513
+ pluginState[strIsInitialized] = false;
1514
+ if (plugin[strTeardown] && plugin[strTeardown](unloadCtx, unloadState) === true) {
1515
+ hasRun = true;
1516
+ }
1517
+ }
1518
+ }
1519
+ return hasRun;
1520
+ }
1521
+ if (!_processChain(unloadCtx, _callTeardown, "unload", function () { }, unloadState.isAsync)) {
1522
+ unloadCtx.processNext(unloadState);
1523
+ }
1336
1524
  }
1337
1525
  return objFreeze(proxyChain);
1338
1526
  }
@@ -1345,7 +1533,6 @@
1345
1533
  var strIsCookieUseDisabled = "isCookieUseDisabled";
1346
1534
  var strDisableCookiesUsage = "disableCookiesUsage";
1347
1535
  var strConfigCookieMgr = "_ckMgr";
1348
- var strEmpty = "";
1349
1536
  var _supportsCookies = null;
1350
1537
  var _allowUaSameSite = null;
1351
1538
  var _parsedCookieValue = null;
@@ -1422,7 +1609,7 @@
1422
1609
  var result = false;
1423
1610
  if (_isMgrEnabled(cookieMgr)) {
1424
1611
  var values = {};
1425
- var theValue = strTrim(value || strEmpty);
1612
+ var theValue = strTrim(value || strEmpty$1);
1426
1613
  var idx = theValue.indexOf(";");
1427
1614
  if (idx !== -1) {
1428
1615
  theValue = strTrim(value.substring(0, idx));
@@ -1437,11 +1624,11 @@
1437
1624
  if (expireMs > 0) {
1438
1625
  var expiry = new Date();
1439
1626
  expiry.setTime(expireMs);
1440
- setValue(values, strExpires, _formatDate(expiry, !_isIE ? strToUTCString : strToGMTString) || _formatDate(expiry, _isIE ? strToGMTString : strToUTCString) || strEmpty, isTruthy);
1627
+ setValue(values, strExpires, _formatDate(expiry, !_isIE ? strToUTCString : strToGMTString) || _formatDate(expiry, _isIE ? strToGMTString : strToUTCString) || strEmpty$1, isTruthy);
1441
1628
  }
1442
1629
  }
1443
1630
  if (!_isIE) {
1444
- setValue(values, "max-age", strEmpty + maxAgeSec, null, isUndefined);
1631
+ setValue(values, "max-age", strEmpty$1 + maxAgeSec, null, isUndefined);
1445
1632
  }
1446
1633
  }
1447
1634
  var location_1 = getLocation();
@@ -1462,7 +1649,7 @@
1462
1649
  return result;
1463
1650
  },
1464
1651
  get: function (name) {
1465
- var value = strEmpty;
1652
+ var value = strEmpty$1;
1466
1653
  if (_isMgrEnabled(cookieMgr)) {
1467
1654
  value = (cookieMgrConfig.getCookie || _getCookieValue)(name);
1468
1655
  }
@@ -1487,7 +1674,7 @@
1487
1674
  values["max-age"] = "0";
1488
1675
  }
1489
1676
  var delCookie = cookieMgrConfig.delCookie || _setCookieValue;
1490
- delCookie(name, _formatCookieValue(strEmpty, values));
1677
+ delCookie(name, _formatCookieValue(strEmpty$1, values));
1491
1678
  result = true;
1492
1679
  }
1493
1680
  return result;
@@ -1504,7 +1691,7 @@
1504
1691
  _supportsCookies = doc[strCookie] !== undefined;
1505
1692
  }
1506
1693
  catch (e) {
1507
- logger && logger.throwInternal(LoggingSeverity.WARNING, _InternalMessageId.CannotAccessCookie, "Cannot access document.cookie - " + getExceptionName(e), { exception: dumpObj(e) });
1694
+ logger && logger.throwInternal(2 , 68 , "Cannot access document.cookie - " + getExceptionName(e), { exception: dumpObj(e) });
1508
1695
  }
1509
1696
  }
1510
1697
  return _supportsCookies;
@@ -1514,7 +1701,7 @@
1514
1701
  if (theValue && theValue.length) {
1515
1702
  var parts = strTrim(theValue).split(";");
1516
1703
  arrForEach(parts, function (thePart) {
1517
- thePart = strTrim(thePart || strEmpty);
1704
+ thePart = strTrim(thePart || strEmpty$1);
1518
1705
  if (thePart) {
1519
1706
  var idx = thePart.indexOf("=");
1520
1707
  if (idx === -1) {
@@ -1535,21 +1722,21 @@
1535
1722
  return null;
1536
1723
  }
1537
1724
  function _formatCookieValue(value, values) {
1538
- var cookieValue = value || strEmpty;
1725
+ var cookieValue = value || strEmpty$1;
1539
1726
  objForEachKey(values, function (name, theValue) {
1540
- cookieValue += "; " + name + (!isNullOrUndefined(theValue) ? "=" + theValue : strEmpty);
1727
+ cookieValue += "; " + name + (!isNullOrUndefined(theValue) ? "=" + theValue : strEmpty$1);
1541
1728
  });
1542
1729
  return cookieValue;
1543
1730
  }
1544
1731
  function _getCookieValue(name) {
1545
- var cookieValue = strEmpty;
1732
+ var cookieValue = strEmpty$1;
1546
1733
  if (_doc) {
1547
- var theCookie = _doc[strCookie] || strEmpty;
1734
+ var theCookie = _doc[strCookie] || strEmpty$1;
1548
1735
  if (_parsedCookieValue !== theCookie) {
1549
1736
  _cookieCache = _extractParts(theCookie);
1550
1737
  _parsedCookieValue = theCookie;
1551
1738
  }
1552
- cookieValue = strTrim(_cookieCache[name] || strEmpty);
1739
+ cookieValue = strTrim(_cookieCache[name] || strEmpty$1);
1553
1740
  }
1554
1741
  return cookieValue;
1555
1742
  }
@@ -1585,6 +1772,30 @@
1585
1772
 
1586
1773
  var strExtensionConfig = "extensionConfig";
1587
1774
 
1775
+ function createUnloadHandlerContainer() {
1776
+ var handlers = [];
1777
+ function _addHandler(handler) {
1778
+ if (handler) {
1779
+ handlers.push(handler);
1780
+ }
1781
+ }
1782
+ function _runHandlers(unloadCtx, unloadState) {
1783
+ arrForEach(handlers, function (handler) {
1784
+ try {
1785
+ handler(unloadCtx, unloadState);
1786
+ }
1787
+ catch (e) {
1788
+ unloadCtx.diagLog().throwInternal(2 , 73 , "Unexpected error calling unload handler - " + dumpObj(e));
1789
+ }
1790
+ });
1791
+ handlers = [];
1792
+ }
1793
+ return {
1794
+ add: _addHandler,
1795
+ run: _runHandlers
1796
+ };
1797
+ }
1798
+
1588
1799
  var strGetPlugin = "getPlugin";
1589
1800
  var BaseTelemetryPlugin = /** @class */ (function () {
1590
1801
  function BaseTelemetryPlugin() {
@@ -1592,6 +1803,7 @@
1592
1803
  var _isinitialized;
1593
1804
  var _rootCtx;
1594
1805
  var _nextPlugin;
1806
+ var _unloadHandlerContainer;
1595
1807
  var _hooks;
1596
1808
  _initDefaults();
1597
1809
  dynamicProto(BaseTelemetryPlugin, _self, function (_self) {
@@ -1599,6 +1811,39 @@
1599
1811
  _setDefaults(config, core, pluginChain);
1600
1812
  _isinitialized = true;
1601
1813
  };
1814
+ _self.teardown = function (unloadCtx, unloadState) {
1815
+ if (!_self.core || (unloadCtx && _self.core !== unloadCtx.core())) {
1816
+ return;
1817
+ }
1818
+ var result;
1819
+ var unloadDone = false;
1820
+ var theUnloadCtx = unloadCtx || createProcessTelemetryUnloadContext(null, {}, _self.core, _nextPlugin && _nextPlugin[strGetPlugin] ? _nextPlugin[strGetPlugin]() : _nextPlugin);
1821
+ var theUnloadState = unloadState || {
1822
+ reason: 0 ,
1823
+ isAsync: false
1824
+ };
1825
+ function _unloadCallback() {
1826
+ if (!unloadDone) {
1827
+ unloadDone = true;
1828
+ _unloadHandlerContainer.run(theUnloadCtx, unloadState);
1829
+ arrForEach(_hooks, function (fn) {
1830
+ fn.rm();
1831
+ });
1832
+ _hooks = [];
1833
+ if (result === true) {
1834
+ theUnloadCtx.processNext(theUnloadState);
1835
+ }
1836
+ _initDefaults();
1837
+ }
1838
+ }
1839
+ if (!_self[strDoTeardown] || _self[strDoTeardown](theUnloadCtx, theUnloadState, _unloadCallback) !== true) {
1840
+ _unloadCallback();
1841
+ }
1842
+ else {
1843
+ result = true;
1844
+ }
1845
+ return result;
1846
+ };
1602
1847
  _self._addHook = function (hooks) {
1603
1848
  if (hooks) {
1604
1849
  if (isArray(hooks)) {
@@ -1609,17 +1854,18 @@
1609
1854
  }
1610
1855
  }
1611
1856
  };
1857
+ proxyFunctionAs(_self, "_addUnloadCb", function () { return _unloadHandlerContainer; }, "add");
1612
1858
  });
1613
1859
  _self.diagLog = function (itemCtx) {
1614
1860
  return _getTelCtx(itemCtx).diagLog();
1615
1861
  };
1616
- _self.isInitialized = function () {
1862
+ _self[strIsInitialized] = function () {
1617
1863
  return _isinitialized;
1618
1864
  };
1619
1865
  _self.setInitialized = function (isInitialized) {
1620
1866
  _isinitialized = isInitialized;
1621
1867
  };
1622
- _self.setNextPlugin = function (next) {
1868
+ _self[strSetNextPlugin] = function (next) {
1623
1869
  _nextPlugin = next;
1624
1870
  };
1625
1871
  _self.processNext = function (env, itemCtx) {
@@ -1665,82 +1911,15 @@
1665
1911
  _rootCtx = null;
1666
1912
  _nextPlugin = null;
1667
1913
  _hooks = [];
1914
+ _unloadHandlerContainer = createUnloadHandlerContainer();
1668
1915
  }
1669
1916
  }
1670
1917
  return BaseTelemetryPlugin;
1671
1918
  }());
1672
1919
 
1673
- var UInt32Mask = 0x100000000;
1674
- var MaxUInt32 = 0xffffffff;
1675
- var _mwcSeeded = false;
1676
- var _mwcW = 123456789;
1677
- var _mwcZ = 987654321;
1678
- function _mwcSeed(seedValue) {
1679
- if (seedValue < 0) {
1680
- seedValue >>>= 0;
1681
- }
1682
- _mwcW = (123456789 + seedValue) & MaxUInt32;
1683
- _mwcZ = (987654321 - seedValue) & MaxUInt32;
1684
- _mwcSeeded = true;
1685
- }
1686
- function _autoSeedMwc() {
1687
- try {
1688
- var now = dateNow() & 0x7fffffff;
1689
- _mwcSeed(((Math.random() * UInt32Mask) ^ now) + now);
1690
- }
1691
- catch (e) {
1692
- }
1693
- }
1694
- function random32(signed) {
1695
- var value = 0;
1696
- var c = getCrypto() || getMsCrypto();
1697
- if (c && c.getRandomValues) {
1698
- value = c.getRandomValues(new Uint32Array(1))[0] & MaxUInt32;
1699
- }
1700
- if (value === 0 && isIE()) {
1701
- if (!_mwcSeeded) {
1702
- _autoSeedMwc();
1703
- }
1704
- value = mwcRandom32() & MaxUInt32;
1705
- }
1706
- if (value === 0) {
1707
- value = Math.floor((UInt32Mask * Math.random()) | 0);
1708
- }
1709
- if (!signed) {
1710
- value >>>= 0;
1711
- }
1712
- return value;
1713
- }
1714
- function mwcRandom32(signed) {
1715
- _mwcZ = (36969 * (_mwcZ & 0xFFFF) + (_mwcZ >> 16)) & MaxUInt32;
1716
- _mwcW = (18000 * (_mwcW & 0xFFFF) + (_mwcW >> 16)) & MaxUInt32;
1717
- var value = (((_mwcZ << 16) + (_mwcW & 0xFFFF)) >>> 0) & MaxUInt32 | 0;
1718
- if (!signed) {
1719
- value >>>= 0;
1720
- }
1721
- return value;
1722
- }
1723
- function newId(maxLength) {
1724
- if (maxLength === void 0) { maxLength = 22; }
1725
- var base64chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
1726
- var number = random32() >>> 0;
1727
- var chars = 0;
1728
- var result = "";
1729
- while (result.length < maxLength) {
1730
- chars++;
1731
- result += base64chars.charAt(number & 0x3F);
1732
- number >>>= 6;
1733
- if (chars === 5) {
1734
- number = (((random32() << 2) & 0xFFFFFFFF) | (number & 0x03)) >>> 0;
1735
- chars = 0;
1736
- }
1737
- }
1738
- return result;
1739
- }
1740
-
1741
1920
  function generateW3CId() {
1742
1921
  var hexValues = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f"];
1743
- var oct = "", tmp;
1922
+ var oct = strEmpty$1, tmp;
1744
1923
  for (var a = 0; a < 4; a++) {
1745
1924
  tmp = random32();
1746
1925
  oct +=
@@ -1757,6 +1936,95 @@
1757
1936
  return oct.substr(0, 8) + oct.substr(9, 4) + "4" + oct.substr(13, 3) + clockSequenceHi + oct.substr(16, 3) + oct.substr(19, 12);
1758
1937
  }
1759
1938
 
1939
+ var LoggingSeverity = createEnumStyle({
1940
+ CRITICAL: 1 ,
1941
+ WARNING: 2
1942
+ });
1943
+ var _InternalMessageId = createEnumStyle({
1944
+ BrowserDoesNotSupportLocalStorage: 0 ,
1945
+ BrowserCannotReadLocalStorage: 1 ,
1946
+ BrowserCannotReadSessionStorage: 2 ,
1947
+ BrowserCannotWriteLocalStorage: 3 ,
1948
+ BrowserCannotWriteSessionStorage: 4 ,
1949
+ BrowserFailedRemovalFromLocalStorage: 5 ,
1950
+ BrowserFailedRemovalFromSessionStorage: 6 ,
1951
+ CannotSendEmptyTelemetry: 7 ,
1952
+ ClientPerformanceMathError: 8 ,
1953
+ ErrorParsingAISessionCookie: 9 ,
1954
+ ErrorPVCalc: 10 ,
1955
+ ExceptionWhileLoggingError: 11 ,
1956
+ FailedAddingTelemetryToBuffer: 12 ,
1957
+ FailedMonitorAjaxAbort: 13 ,
1958
+ FailedMonitorAjaxDur: 14 ,
1959
+ FailedMonitorAjaxOpen: 15 ,
1960
+ FailedMonitorAjaxRSC: 16 ,
1961
+ FailedMonitorAjaxSend: 17 ,
1962
+ FailedMonitorAjaxGetCorrelationHeader: 18 ,
1963
+ FailedToAddHandlerForOnBeforeUnload: 19 ,
1964
+ FailedToSendQueuedTelemetry: 20 ,
1965
+ FailedToReportDataLoss: 21 ,
1966
+ FlushFailed: 22 ,
1967
+ MessageLimitPerPVExceeded: 23 ,
1968
+ MissingRequiredFieldSpecification: 24 ,
1969
+ NavigationTimingNotSupported: 25 ,
1970
+ OnError: 26 ,
1971
+ SessionRenewalDateIsZero: 27 ,
1972
+ SenderNotInitialized: 28 ,
1973
+ StartTrackEventFailed: 29 ,
1974
+ StopTrackEventFailed: 30 ,
1975
+ StartTrackFailed: 31 ,
1976
+ StopTrackFailed: 32 ,
1977
+ TelemetrySampledAndNotSent: 33 ,
1978
+ TrackEventFailed: 34 ,
1979
+ TrackExceptionFailed: 35 ,
1980
+ TrackMetricFailed: 36 ,
1981
+ TrackPVFailed: 37 ,
1982
+ TrackPVFailedCalc: 38 ,
1983
+ TrackTraceFailed: 39 ,
1984
+ TransmissionFailed: 40 ,
1985
+ FailedToSetStorageBuffer: 41 ,
1986
+ FailedToRestoreStorageBuffer: 42 ,
1987
+ InvalidBackendResponse: 43 ,
1988
+ FailedToFixDepricatedValues: 44 ,
1989
+ InvalidDurationValue: 45 ,
1990
+ TelemetryEnvelopeInvalid: 46 ,
1991
+ CreateEnvelopeError: 47 ,
1992
+ CannotSerializeObject: 48 ,
1993
+ CannotSerializeObjectNonSerializable: 49 ,
1994
+ CircularReferenceDetected: 50 ,
1995
+ ClearAuthContextFailed: 51 ,
1996
+ ExceptionTruncated: 52 ,
1997
+ IllegalCharsInName: 53 ,
1998
+ ItemNotInArray: 54 ,
1999
+ MaxAjaxPerPVExceeded: 55 ,
2000
+ MessageTruncated: 56 ,
2001
+ NameTooLong: 57 ,
2002
+ SampleRateOutOfRange: 58 ,
2003
+ SetAuthContextFailed: 59 ,
2004
+ SetAuthContextFailedAccountName: 60 ,
2005
+ StringValueTooLong: 61 ,
2006
+ StartCalledMoreThanOnce: 62 ,
2007
+ StopCalledWithoutStart: 63 ,
2008
+ TelemetryInitializerFailed: 64 ,
2009
+ TrackArgumentsNotSpecified: 65 ,
2010
+ UrlTooLong: 66 ,
2011
+ SessionStorageBufferFull: 67 ,
2012
+ CannotAccessCookie: 68 ,
2013
+ IdTooLong: 69 ,
2014
+ InvalidEvent: 70 ,
2015
+ FailedMonitorAjaxSetRequestHeader: 71 ,
2016
+ SendBrowserInfoOnUserInit: 72 ,
2017
+ PluginException: 73 ,
2018
+ NotificationException: 74 ,
2019
+ SnippetScriptLoadFailure: 99 ,
2020
+ InvalidInstrumentationKey: 100 ,
2021
+ CannotParseAiBlobValue: 101 ,
2022
+ InvalidContentBlob: 102 ,
2023
+ TrackPageActionEventFailed: 103 ,
2024
+ FailedAddingCustomDefinedRequestContext: 104 ,
2025
+ InMemoryStorageBufferFull: 105
2026
+ });
2027
+
1760
2028
  function dataSanitizeKeyAndAddUniqueness(logger, key, map) {
1761
2029
  var origLength = key.length;
1762
2030
  var field = dataSanitizeKey(logger, key);
@@ -1777,7 +2045,7 @@
1777
2045
  name = strTrim(name.toString());
1778
2046
  if (name.length > 150 ) {
1779
2047
  nameTrunc = name.substring(0, 150 );
1780
- logger && logger.throwInternal(LoggingSeverity.WARNING, _InternalMessageId.NameTooLong, "name is too long. It has been truncated to " + 150 + " characters.", { name: name }, true);
2048
+ logger && logger.throwInternal(2 , _InternalMessageId.NameTooLong, "name is too long. It has been truncated to " + 150 + " characters.", { name: name }, true);
1781
2049
  }
1782
2050
  }
1783
2051
  return nameTrunc || name;
@@ -1790,7 +2058,7 @@
1790
2058
  value = strTrim(value);
1791
2059
  if (value.toString().length > maxLength) {
1792
2060
  valueTrunc = value.toString().substring(0, maxLength);
1793
- logger && logger.throwInternal(LoggingSeverity.WARNING, _InternalMessageId.StringValueTooLong, "string value is too long. It has been truncated to " + maxLength + " characters.", { value: value }, true);
2061
+ logger && logger.throwInternal(2 , _InternalMessageId.StringValueTooLong, "string value is too long. It has been truncated to " + maxLength + " characters.", { value: value }, true);
1794
2062
  }
1795
2063
  }
1796
2064
  return valueTrunc || value;
@@ -1807,7 +2075,7 @@
1807
2075
  value = getJSON().stringify(value);
1808
2076
  }
1809
2077
  catch (e) {
1810
- logger && logger.throwInternal(LoggingSeverity.WARNING, _InternalMessageId.CannotSerializeObjectNonSerializable, "custom property is not valid", { exception: e }, true);
2078
+ logger && logger.throwInternal(2 , _InternalMessageId.CannotSerializeObjectNonSerializable, "custom property is not valid", { exception: e }, true);
1811
2079
  }
1812
2080
  }
1813
2081
  value = dataSanitizeString(logger, value, 8192 );
@@ -1838,7 +2106,7 @@
1838
2106
  input = strTrim(input);
1839
2107
  if (input.length > maxLength) {
1840
2108
  inputTrunc = input.substring(0, maxLength);
1841
- logger && logger.throwInternal(LoggingSeverity.WARNING, _msgId, "input is too long, it has been truncated to " + maxLength + " characters.", { data: input }, true);
2109
+ logger && logger.throwInternal(2 , _msgId, "input is too long, it has been truncated to " + maxLength + " characters.", { data: input }, true);
1842
2110
  }
1843
2111
  }
1844
2112
  return inputTrunc || input;
@@ -1848,21 +2116,22 @@
1848
2116
  return s.substr(s.length - 3);
1849
2117
  }
1850
2118
 
2119
+ var strEmpty = "";
1851
2120
  function msToTimeSpan(totalms) {
1852
2121
  if (isNaN(totalms) || totalms < 0) {
1853
2122
  totalms = 0;
1854
2123
  }
1855
2124
  totalms = Math.round(totalms);
1856
- var ms = "" + totalms % 1000;
1857
- var sec = "" + Math.floor(totalms / 1000) % 60;
1858
- var min = "" + Math.floor(totalms / (1000 * 60)) % 60;
1859
- var hour = "" + Math.floor(totalms / (1000 * 60 * 60)) % 24;
2125
+ var ms = strEmpty + totalms % 1000;
2126
+ var sec = strEmpty + Math.floor(totalms / 1000) % 60;
2127
+ var min = strEmpty + Math.floor(totalms / (1000 * 60)) % 60;
2128
+ var hour = strEmpty + Math.floor(totalms / (1000 * 60 * 60)) % 24;
1860
2129
  var days = Math.floor(totalms / (1000 * 60 * 60 * 24));
1861
2130
  ms = ms.length === 1 ? "00" + ms : ms.length === 2 ? "0" + ms : ms;
1862
2131
  sec = sec.length < 2 ? "0" + sec : sec;
1863
2132
  min = min.length < 2 ? "0" + min : min;
1864
2133
  hour = hour.length < 2 ? "0" + hour : hour;
1865
- return (days > 0 ? days + "." : "") + hour + ":" + min + ":" + sec + "." + ms;
2134
+ return (days > 0 ? days + "." : strEmpty) + hour + ":" + min + ":" + sec + "." + ms;
1866
2135
  }
1867
2136
  function getExtensionByName(extensions, identifier) {
1868
2137
  var extension = null;
@@ -1877,17 +2146,15 @@
1877
2146
 
1878
2147
  var strNotSpecified = "not_specified";
1879
2148
 
1880
- var StorageType;
1881
- (function (StorageType) {
1882
- StorageType[StorageType["LocalStorage"] = 0] = "LocalStorage";
1883
- StorageType[StorageType["SessionStorage"] = 1] = "SessionStorage";
1884
- })(StorageType || (StorageType = {}));
1885
- var DistributedTracingModes;
1886
- (function (DistributedTracingModes) {
1887
- DistributedTracingModes[DistributedTracingModes["AI"] = 0] = "AI";
1888
- DistributedTracingModes[DistributedTracingModes["AI_AND_W3C"] = 1] = "AI_AND_W3C";
1889
- DistributedTracingModes[DistributedTracingModes["W3C"] = 2] = "W3C";
1890
- })(DistributedTracingModes || (DistributedTracingModes = {}));
2149
+ var StorageType = createEnumStyle({
2150
+ LocalStorage: 0 ,
2151
+ SessionStorage: 1
2152
+ });
2153
+ createEnumStyle({
2154
+ AI: 0 ,
2155
+ AI_AND_W3C: 1 ,
2156
+ W3C: 2
2157
+ });
1891
2158
 
1892
2159
  var _canUseLocalStorage = undefined;
1893
2160
  function _getLocalStorageObject() {
@@ -1928,7 +2195,7 @@
1928
2195
  }
1929
2196
  catch (e) {
1930
2197
  _canUseLocalStorage = false;
1931
- logger.throwInternal(LoggingSeverity.WARNING, _InternalMessageId.BrowserCannotReadLocalStorage, "Browser failed read of local storage. " + getExceptionName(e), { exception: dumpObj(e) });
2198
+ logger.throwInternal(2 , _InternalMessageId.BrowserCannotReadLocalStorage, "Browser failed read of local storage. " + getExceptionName(e), { exception: dumpObj(e) });
1932
2199
  }
1933
2200
  }
1934
2201
  return null;
@@ -1942,7 +2209,7 @@
1942
2209
  }
1943
2210
  catch (e) {
1944
2211
  _canUseLocalStorage = false;
1945
- logger.throwInternal(LoggingSeverity.WARNING, _InternalMessageId.BrowserCannotWriteLocalStorage, "Browser failed write to local storage. " + getExceptionName(e), { exception: dumpObj(e) });
2212
+ logger.throwInternal(2 , _InternalMessageId.BrowserCannotWriteLocalStorage, "Browser failed write to local storage. " + getExceptionName(e), { exception: dumpObj(e) });
1946
2213
  }
1947
2214
  }
1948
2215
  return false;
@@ -1956,7 +2223,7 @@
1956
2223
  }
1957
2224
  catch (e) {
1958
2225
  _canUseLocalStorage = false;
1959
- logger.throwInternal(LoggingSeverity.WARNING, _InternalMessageId.BrowserFailedRemovalFromLocalStorage, "Browser failed removal of local storage item. " + getExceptionName(e), { exception: dumpObj(e) });
2226
+ logger.throwInternal(2 , _InternalMessageId.BrowserFailedRemovalFromLocalStorage, "Browser failed removal of local storage item. " + getExceptionName(e), { exception: dumpObj(e) });
1960
2227
  }
1961
2228
  }
1962
2229
  return false;
@@ -2258,7 +2525,7 @@
2258
2525
  return Device;
2259
2526
  }());
2260
2527
 
2261
- var Version = "2.8.0-beta.2203-01";
2528
+ var Version = "2.8.0-beta.2203-04";
2262
2529
  var Internal = /** @class */ (function () {
2263
2530
  function Internal(config) {
2264
2531
  this.sdkVersion = (config.sdkExtension && config.sdkExtension() ? config.sdkExtension() + "_" : "") + "javascript:" + Version;