@microsoft/applicationinsights-analytics-js 2.8.0-beta.2203-01 → 2.8.0-beta.2203-02

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 - Web Analytics, 2.8.0-beta.2203-01
2
+ * Application Insights JavaScript SDK - Web Analytics, 2.8.0-beta.2203-02
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  */
5
5
  (function (global, factory) {
@@ -335,95 +335,13 @@
335
335
  };
336
336
  dynamicProto[DynProtoDefaultOptions] = perfDefaults;
337
337
 
338
- var LoggingSeverity;
339
- (function (LoggingSeverity) {
340
- LoggingSeverity[LoggingSeverity["CRITICAL"] = 1] = "CRITICAL";
341
- LoggingSeverity[LoggingSeverity["WARNING"] = 2] = "WARNING";
342
- })(LoggingSeverity || (LoggingSeverity = {}));
343
- var _InternalMessageId = {
344
- BrowserDoesNotSupportLocalStorage: 0,
345
- BrowserCannotReadLocalStorage: 1,
346
- BrowserCannotReadSessionStorage: 2,
347
- BrowserCannotWriteLocalStorage: 3,
348
- BrowserCannotWriteSessionStorage: 4,
349
- BrowserFailedRemovalFromLocalStorage: 5,
350
- BrowserFailedRemovalFromSessionStorage: 6,
351
- CannotSendEmptyTelemetry: 7,
352
- ClientPerformanceMathError: 8,
353
- ErrorParsingAISessionCookie: 9,
354
- ErrorPVCalc: 10,
355
- ExceptionWhileLoggingError: 11,
356
- FailedAddingTelemetryToBuffer: 12,
357
- FailedMonitorAjaxAbort: 13,
358
- FailedMonitorAjaxDur: 14,
359
- FailedMonitorAjaxOpen: 15,
360
- FailedMonitorAjaxRSC: 16,
361
- FailedMonitorAjaxSend: 17,
362
- FailedMonitorAjaxGetCorrelationHeader: 18,
363
- FailedToAddHandlerForOnBeforeUnload: 19,
364
- FailedToSendQueuedTelemetry: 20,
365
- FailedToReportDataLoss: 21,
366
- FlushFailed: 22,
367
- MessageLimitPerPVExceeded: 23,
368
- MissingRequiredFieldSpecification: 24,
369
- NavigationTimingNotSupported: 25,
370
- OnError: 26,
371
- SessionRenewalDateIsZero: 27,
372
- SenderNotInitialized: 28,
373
- StartTrackEventFailed: 29,
374
- StopTrackEventFailed: 30,
375
- StartTrackFailed: 31,
376
- StopTrackFailed: 32,
377
- TelemetrySampledAndNotSent: 33,
378
- TrackEventFailed: 34,
379
- TrackExceptionFailed: 35,
380
- TrackMetricFailed: 36,
381
- TrackPVFailed: 37,
382
- TrackPVFailedCalc: 38,
383
- TrackTraceFailed: 39,
384
- TransmissionFailed: 40,
385
- FailedToSetStorageBuffer: 41,
386
- FailedToRestoreStorageBuffer: 42,
387
- InvalidBackendResponse: 43,
388
- FailedToFixDepricatedValues: 44,
389
- InvalidDurationValue: 45,
390
- TelemetryEnvelopeInvalid: 46,
391
- CreateEnvelopeError: 47,
392
- CannotSerializeObject: 48,
393
- CannotSerializeObjectNonSerializable: 49,
394
- CircularReferenceDetected: 50,
395
- ClearAuthContextFailed: 51,
396
- ExceptionTruncated: 52,
397
- IllegalCharsInName: 53,
398
- ItemNotInArray: 54,
399
- MaxAjaxPerPVExceeded: 55,
400
- MessageTruncated: 56,
401
- NameTooLong: 57,
402
- SampleRateOutOfRange: 58,
403
- SetAuthContextFailed: 59,
404
- SetAuthContextFailedAccountName: 60,
405
- StringValueTooLong: 61,
406
- StartCalledMoreThanOnce: 62,
407
- StopCalledWithoutStart: 63,
408
- TelemetryInitializerFailed: 64,
409
- TrackArgumentsNotSpecified: 65,
410
- UrlTooLong: 66,
411
- SessionStorageBufferFull: 67,
412
- CannotAccessCookie: 68,
413
- IdTooLong: 69,
414
- InvalidEvent: 70,
415
- FailedMonitorAjaxSetRequestHeader: 71,
416
- SendBrowserInfoOnUserInit: 72,
417
- PluginException: 73,
418
- NotificationException: 74,
419
- SnippetScriptLoadFailure: 99,
420
- InvalidInstrumentationKey: 100,
421
- CannotParseAiBlobValue: 101,
422
- InvalidContentBlob: 102,
423
- TrackPageActionEventFailed: 103,
424
- FailedAddingCustomDefinedRequestContext: 104,
425
- InMemoryStorageBufferFull: 105
426
- };
338
+ var strEmpty$1 = "";
339
+ var strSetNextPlugin = "setNextPlugin";
340
+ var strIsInitialized = "isInitialized";
341
+ var strTeardown = "teardown";
342
+ var strCore = "core";
343
+ var strDisabled = "disabled";
344
+ var strDoTeardown = "_doTeardown";
427
345
 
428
346
  var strToISOString = "toISOString";
429
347
  var cStrEndsWith = "endsWith";
@@ -432,7 +350,7 @@
432
350
  var strToString = "toString";
433
351
  var str__Proto = "__proto__";
434
352
  var strConstructor = "constructor";
435
- var _objDefineProperty = ObjDefineProperty;
353
+ var _objDefineProperty$1 = ObjDefineProperty;
436
354
  var _objFreeze = ObjClass.freeze;
437
355
  var StringProto = String[strShimPrototype];
438
356
  var _strTrim = StringProto[cStrTrim];
@@ -443,6 +361,9 @@
443
361
  var _objToString = ObjProto[strToString];
444
362
  var _fnToString = ObjHasOwnProperty[strToString];
445
363
  var _objFunctionString = _fnToString.call(ObjClass);
364
+ var rCamelCase = /-([a-z])/g;
365
+ var rNormalizeInvalid = /([^\w\d_$])/g;
366
+ var rLeadingNumeric = /^(\d+[\w\d_$])/;
446
367
  var _objGetPrototypeOf = Object["getPrototypeOf"];
447
368
  function _getObjProto(target) {
448
369
  if (target) {
@@ -471,6 +392,19 @@
471
392
  function isFunction(value) {
472
393
  return !!(value && typeof value === strShimFunction);
473
394
  }
395
+ function normalizeJsName(name) {
396
+ var value = name;
397
+ if (value && isString(value)) {
398
+ value = value.replace(rCamelCase, function (_all, letter) {
399
+ return letter.toUpperCase();
400
+ });
401
+ value = value.replace(rNormalizeInvalid, "_");
402
+ value = value.replace(rLeadingNumeric, function (_all, match) {
403
+ return "_" + match;
404
+ });
405
+ }
406
+ return value;
407
+ }
474
408
  function objForEachKey(target, callbackfn) {
475
409
  if (target) {
476
410
  for (var prop in target) {
@@ -604,7 +538,7 @@
604
538
  return str;
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;
@@ -655,6 +589,17 @@
655
589
  function throwError(message) {
656
590
  throw new Error(message);
657
591
  }
592
+ function createEnumStyle(values) {
593
+ var enumClass = {};
594
+ objForEachKey(values, function (field, value) {
595
+ enumClass[field] = value;
596
+ if (!isUndefined(enumClass[value])) {
597
+ throwError("Value: [" + value + "] already exists for " + field);
598
+ }
599
+ enumClass[value] = field;
600
+ });
601
+ return objFreeze(enumClass);
602
+ }
658
603
  function objExtend(obj, obj2, obj3, obj4, obj5, obj6) {
659
604
  var theArgs = arguments;
660
605
  var extended = theArgs[0] || {};
@@ -801,14 +746,14 @@
801
746
  var nav = getNavigator();
802
747
  if (nav && (nav.userAgent !== _navUserAgentCheck || _isTrident === null)) {
803
748
  _navUserAgentCheck = nav.userAgent;
804
- var userAgent = (_navUserAgentCheck || "").toLowerCase();
749
+ var userAgent = (_navUserAgentCheck || strEmpty$1).toLowerCase();
805
750
  _isTrident = (strContains(userAgent, strMsie) || strContains(userAgent, strTrident));
806
751
  }
807
752
  return _isTrident;
808
753
  }
809
754
  function dumpObj(object) {
810
755
  var objectTypeDump = Object[strShimPrototype].toString.call(object);
811
- var propertyValueDump = "";
756
+ var propertyValueDump = strEmpty$1;
812
757
  if (objectTypeDump === "[object Error]") {
813
758
  propertyValueDump = "{ stack: '" + object.stack + "', message: '" + object.message + "', name: '" + object.name + "'";
814
759
  }
@@ -841,9 +786,9 @@
841
786
  var strWarnToConsole = "warnToConsole";
842
787
  function _sanitizeDiagnosticText(text) {
843
788
  if (text) {
844
- return "\"" + text.replace(/\"/g, "") + "\"";
789
+ return "\"" + text.replace(/\"/g, strEmpty$1) + "\"";
845
790
  }
846
- return "";
791
+ return strEmpty$1;
847
792
  }
848
793
  function _logToConsole(func, message) {
849
794
  var theConsole = getConsole();
@@ -865,12 +810,12 @@
865
810
  _self.message =
866
811
  (isUserAct ? AiUserActionablePrefix : AiNonUserActionablePrefix) +
867
812
  msgId;
868
- var strProps = "";
813
+ var strProps = strEmpty$1;
869
814
  if (hasJSON()) {
870
815
  strProps = getJSON().stringify(properties);
871
816
  }
872
- var diagnosticText = (msg ? " message:" + _sanitizeDiagnosticText(msg) : "") +
873
- (properties ? " props:" + _sanitizeDiagnosticText(strProps) : "");
817
+ var diagnosticText = (msg ? " message:" + _sanitizeDiagnosticText(msg) : strEmpty$1) +
818
+ (properties ? " props:" + _sanitizeDiagnosticText(strProps) : strEmpty$1);
874
819
  _self.message += diagnosticText;
875
820
  }
876
821
  _InternalLogMessage.dataType = "MessageData";
@@ -900,7 +845,7 @@
900
845
  throw message;
901
846
  }
902
847
  else {
903
- var logFunc = severity === LoggingSeverity.CRITICAL ? strErrorToConsole : strWarnToConsole;
848
+ var logFunc = severity === 1 ? strErrorToConsole : strWarnToConsole;
904
849
  if (!isUndefined(message.message)) {
905
850
  var logLevel = _self.consoleLoggingLevel();
906
851
  if (isUserAct) {
@@ -918,7 +863,7 @@
918
863
  _self.logInternalMessage(severity, message);
919
864
  }
920
865
  else {
921
- _debugExtMsg("throw" + (severity === LoggingSeverity.CRITICAL ? "Critical" : "Warning"), message);
866
+ _debugExtMsg("throw" + (severity === 1 ? "Critical" : "Warning"), message);
922
867
  }
923
868
  }
924
869
  };
@@ -950,13 +895,13 @@
950
895
  if (severity <= _self.telemetryLoggingLevel()) {
951
896
  _self.queue.push(message);
952
897
  _messageCount++;
953
- _debugExtMsg((severity === LoggingSeverity.CRITICAL ? "error" : "warn"), message);
898
+ _debugExtMsg((severity === 1 ? "error" : "warn"), message);
954
899
  }
955
900
  if (_messageCount === _self.maxInternalMessageLimit()) {
956
901
  var throttleLimitMessage = "Internal events throttle limit per PageView reached for this app.";
957
- var throttleMessage = new _InternalLogMessage(_InternalMessageId.MessageLimitPerPVExceeded, throttleLimitMessage, false);
902
+ var throttleMessage = new _InternalLogMessage(23 , throttleLimitMessage, false);
958
903
  _self.queue.push(throttleMessage);
959
- if (severity === LoggingSeverity.CRITICAL) {
904
+ if (severity === 1 ) {
960
905
  _self.errorToConsole(throttleLimitMessage);
961
906
  }
962
907
  else {
@@ -1098,6 +1043,151 @@
1098
1043
  return func();
1099
1044
  }
1100
1045
 
1046
+ var UInt32Mask = 0x100000000;
1047
+ var MaxUInt32 = 0xffffffff;
1048
+ var _mwcSeeded = false;
1049
+ var _mwcW = 123456789;
1050
+ var _mwcZ = 987654321;
1051
+ function _mwcSeed(seedValue) {
1052
+ if (seedValue < 0) {
1053
+ seedValue >>>= 0;
1054
+ }
1055
+ _mwcW = (123456789 + seedValue) & MaxUInt32;
1056
+ _mwcZ = (987654321 - seedValue) & MaxUInt32;
1057
+ _mwcSeeded = true;
1058
+ }
1059
+ function _autoSeedMwc() {
1060
+ try {
1061
+ var now = dateNow() & 0x7fffffff;
1062
+ _mwcSeed(((Math.random() * UInt32Mask) ^ now) + now);
1063
+ }
1064
+ catch (e) {
1065
+ }
1066
+ }
1067
+ function random32(signed) {
1068
+ var value = 0;
1069
+ var c = getCrypto() || getMsCrypto();
1070
+ if (c && c.getRandomValues) {
1071
+ value = c.getRandomValues(new Uint32Array(1))[0] & MaxUInt32;
1072
+ }
1073
+ if (value === 0 && isIE()) {
1074
+ if (!_mwcSeeded) {
1075
+ _autoSeedMwc();
1076
+ }
1077
+ value = mwcRandom32() & MaxUInt32;
1078
+ }
1079
+ if (value === 0) {
1080
+ value = Math.floor((UInt32Mask * Math.random()) | 0);
1081
+ }
1082
+ if (!signed) {
1083
+ value >>>= 0;
1084
+ }
1085
+ return value;
1086
+ }
1087
+ function mwcRandom32(signed) {
1088
+ _mwcZ = (36969 * (_mwcZ & 0xFFFF) + (_mwcZ >> 16)) & MaxUInt32;
1089
+ _mwcW = (18000 * (_mwcW & 0xFFFF) + (_mwcW >> 16)) & MaxUInt32;
1090
+ var value = (((_mwcZ << 16) + (_mwcW & 0xFFFF)) >>> 0) & MaxUInt32 | 0;
1091
+ if (!signed) {
1092
+ value >>>= 0;
1093
+ }
1094
+ return value;
1095
+ }
1096
+ function newId(maxLength) {
1097
+ if (maxLength === void 0) { maxLength = 22; }
1098
+ var base64chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
1099
+ var number = random32() >>> 0;
1100
+ var chars = 0;
1101
+ var result = strEmpty$1;
1102
+ while (result.length < maxLength) {
1103
+ chars++;
1104
+ result += base64chars.charAt(number & 0x3F);
1105
+ number >>>= 6;
1106
+ if (chars === 5) {
1107
+ number = (((random32() << 2) & 0xFFFFFFFF) | (number & 0x03)) >>> 0;
1108
+ chars = 0;
1109
+ }
1110
+ }
1111
+ return result;
1112
+ }
1113
+
1114
+ var _objDefineProperty = ObjDefineProperty;
1115
+ var version = "2.7.3";
1116
+ var instanceName = "." + newId(6);
1117
+ var _dataUid = 0;
1118
+ function _createAccessor(target, prop, value) {
1119
+ if (_objDefineProperty) {
1120
+ try {
1121
+ _objDefineProperty(target, prop, {
1122
+ value: value,
1123
+ enumerable: false,
1124
+ configurable: true
1125
+ });
1126
+ return true;
1127
+ }
1128
+ catch (e) {
1129
+ }
1130
+ }
1131
+ return false;
1132
+ }
1133
+ function _canAcceptData(target) {
1134
+ return target.nodeType === 1 || target.nodeType === 9 || !(+target.nodeType);
1135
+ }
1136
+ function _getCache(data, target) {
1137
+ var theCache = target[data.id];
1138
+ if (!theCache) {
1139
+ theCache = {};
1140
+ try {
1141
+ if (_canAcceptData(target)) {
1142
+ if (!_createAccessor(target, data.id, theCache)) {
1143
+ target[data.id] = theCache;
1144
+ }
1145
+ }
1146
+ }
1147
+ catch (e) {
1148
+ }
1149
+ }
1150
+ return theCache;
1151
+ }
1152
+ function createUniqueNamespace(name, includeVersion) {
1153
+ if (includeVersion === void 0) { includeVersion = false; }
1154
+ return normalizeJsName(name + (_dataUid++) + (includeVersion ? "." + version : "") + instanceName);
1155
+ }
1156
+ function createElmNodeData(name) {
1157
+ var data = {
1158
+ id: createUniqueNamespace("_aiData-" + (name || "") + "." + version),
1159
+ accept: function (target) {
1160
+ return _canAcceptData(target);
1161
+ },
1162
+ get: function (target, name, defValue, addDefault) {
1163
+ var theCache = target[data.id];
1164
+ if (!theCache) {
1165
+ if (addDefault) {
1166
+ theCache = _getCache(data, target);
1167
+ theCache[normalizeJsName(name)] = defValue;
1168
+ }
1169
+ return defValue;
1170
+ }
1171
+ return theCache[normalizeJsName(name)];
1172
+ },
1173
+ kill: function (target, name) {
1174
+ if (target && target[name]) {
1175
+ try {
1176
+ delete target[name];
1177
+ }
1178
+ catch (e) {
1179
+ }
1180
+ }
1181
+ }
1182
+ };
1183
+ return data;
1184
+ }
1185
+
1186
+ var pluginStateData = createElmNodeData("plugin");
1187
+ function _getPluginState(plugin) {
1188
+ return pluginStateData.get(plugin, "state", {}, true);
1189
+ }
1190
+
1101
1191
  var strTelemetryPluginChain = "TelemetryPluginChain";
1102
1192
  var strHasRunFlags = "_hasRun";
1103
1193
  var strGetTelCtx = "_getTelCtx";
@@ -1111,53 +1201,66 @@
1111
1201
  }
1112
1202
  return createTelemetryProxyChain([startAt], config, core);
1113
1203
  }
1114
- function createProcessTelemetryContext(telemetryChain, config, core, startAt) {
1115
- var _nextProxy = null;
1116
- var _onComplete = null;
1117
- if (startAt) {
1118
- _nextProxy = _getNextProxyStart(telemetryChain, config, core, startAt);
1119
- }
1120
- else {
1121
- _nextProxy = telemetryChain;
1122
- }
1204
+ function _createInternalContext(telemetryChain, config, core, startAt) {
1205
+ var _nextProxy = startAt ? _getNextProxyStart(telemetryChain, config, core, startAt) : telemetryChain;
1206
+ var _onComplete = [];
1123
1207
  var context = {
1124
- core: function () {
1125
- return core;
1126
- },
1127
- diagLog: function () {
1128
- return safeGetLogger(core, config);
1129
- },
1130
- getCfg: function () {
1131
- return config;
1132
- },
1133
- getExtCfg: _getExtCfg,
1134
- getConfig: _getConfig,
1135
- hasNext: function () {
1136
- return _nextProxy != null;
1137
- },
1138
- getNext: function () {
1139
- return _nextProxy;
1140
- },
1141
- setNext: function (nextPlugin) {
1142
- _nextProxy = nextPlugin;
1143
- },
1144
- processNext: function (env) {
1145
- _processChain(function (nextPlugin) {
1146
- nextPlugin.processTelemetry(env, context);
1208
+ _next: _moveNext,
1209
+ ctx: {
1210
+ core: function () { return core; },
1211
+ diagLog: function () {
1212
+ return safeGetLogger(core, config);
1213
+ },
1214
+ getCfg: function () {
1215
+ return config;
1216
+ },
1217
+ getExtCfg: _getExtCfg,
1218
+ getConfig: _getConfig,
1219
+ hasNext: function () {
1220
+ return !!_nextProxy;
1221
+ },
1222
+ getNext: function () {
1223
+ return _nextProxy;
1224
+ },
1225
+ setNext: function (nextPlugin) {
1226
+ _nextProxy = nextPlugin;
1227
+ },
1228
+ iterate: _iterateChain,
1229
+ onComplete: _addOnComplete
1230
+ }
1231
+ };
1232
+ function _addOnComplete(onComplete, that) {
1233
+ var args = [];
1234
+ for (var _i = 2; _i < arguments.length; _i++) {
1235
+ args[_i - 2] = arguments[_i];
1236
+ }
1237
+ if (onComplete) {
1238
+ _onComplete.push({
1239
+ func: onComplete,
1240
+ self: !isUndefined(that) ? that : context.ctx,
1241
+ args: args
1147
1242
  });
1148
- },
1149
- iterate: _iterateChain,
1150
- createNew: function (plugins, startAt) {
1151
- if (plugins === void 0) { plugins = null; }
1152
- if (isArray(plugins)) {
1153
- plugins = createTelemetryProxyChain(plugins, config, core, startAt);
1243
+ }
1244
+ }
1245
+ function _moveNext() {
1246
+ var nextProxy = _nextProxy;
1247
+ _nextProxy = nextProxy ? nextProxy.getNext() : null;
1248
+ if (!nextProxy) {
1249
+ var onComplete = _onComplete;
1250
+ if (onComplete && onComplete.length > 0) {
1251
+ arrForEach(onComplete, function (completeDetails) {
1252
+ try {
1253
+ completeDetails.func.call(completeDetails.self, completeDetails.args);
1254
+ }
1255
+ catch (e) {
1256
+ core.logger.throwInternal(2 , 73 , "Unexpected Exception during onComplete - " + dumpObj(e));
1257
+ }
1258
+ });
1259
+ _onComplete = [];
1154
1260
  }
1155
- return createProcessTelemetryContext(plugins || _nextProxy, config, core, startAt);
1156
- },
1157
- onComplete: function (onComplete) {
1158
- _onComplete = onComplete;
1159
1261
  }
1160
- };
1262
+ return nextProxy;
1263
+ }
1161
1264
  function _getExtCfg(identifier, defaultValue, mergeDefault) {
1162
1265
  if (defaultValue === void 0) { defaultValue = {}; }
1163
1266
  if (mergeDefault === void 0) { mergeDefault = 0 ; }
@@ -1200,29 +1303,53 @@
1200
1303
  }
1201
1304
  return !isNullOrUndefined(theValue) ? theValue : defaultValue;
1202
1305
  }
1203
- function _processChain(cb) {
1204
- var nextPlugin = _nextProxy;
1205
- if (nextPlugin) {
1206
- _nextProxy = nextPlugin.getNext();
1207
- cb(nextPlugin);
1208
- }
1209
- else {
1210
- if (_onComplete) {
1211
- _onComplete();
1212
- _onComplete = null;
1306
+ function _iterateChain(cb) {
1307
+ var nextPlugin;
1308
+ while (!!(nextPlugin = context._next())) {
1309
+ var plugin = nextPlugin.getPlugin();
1310
+ if (plugin) {
1311
+ cb(plugin);
1213
1312
  }
1214
1313
  }
1215
1314
  }
1216
- function _iterateChain(cb) {
1217
- while (_nextProxy) {
1218
- _processChain(function (nextPlugin) {
1219
- var plugin = nextPlugin.getPlugin();
1220
- if (plugin) {
1221
- cb(plugin);
1222
- }
1223
- });
1315
+ return context;
1316
+ }
1317
+ function createProcessTelemetryContext(telemetryChain, config, core, startAt) {
1318
+ var internalContext = _createInternalContext(telemetryChain, config, core, startAt);
1319
+ var context = internalContext.ctx;
1320
+ function _processNext(env) {
1321
+ var nextPlugin = internalContext._next();
1322
+ nextPlugin && nextPlugin.processTelemetry(env, context);
1323
+ return !nextPlugin;
1324
+ }
1325
+ function _createNew(plugins, startAt) {
1326
+ if (plugins === void 0) { plugins = null; }
1327
+ if (isArray(plugins)) {
1328
+ plugins = createTelemetryProxyChain(plugins, config, core, startAt);
1329
+ }
1330
+ return createProcessTelemetryContext(plugins || context.getNext(), config, core, startAt);
1331
+ }
1332
+ context.processNext = _processNext;
1333
+ context.createNew = _createNew;
1334
+ return context;
1335
+ }
1336
+ function createProcessTelemetryUnloadContext(telemetryChain, config, core, startAt) {
1337
+ var internalContext = _createInternalContext(telemetryChain, config, core, startAt);
1338
+ var context = internalContext.ctx;
1339
+ function _processNext(unloadState) {
1340
+ var nextPlugin = internalContext._next();
1341
+ nextPlugin && nextPlugin.unload(context, unloadState);
1342
+ return !nextPlugin;
1343
+ }
1344
+ function _createNew(plugins, startAt) {
1345
+ if (plugins === void 0) { plugins = null; }
1346
+ if (isArray(plugins)) {
1347
+ plugins = createTelemetryProxyChain(plugins, config, core, startAt);
1224
1348
  }
1349
+ return createProcessTelemetryUnloadContext(plugins || context.getNext(), config, core, startAt);
1225
1350
  }
1351
+ context.processNext = _processNext;
1352
+ context.createNew = _createNew;
1226
1353
  return context;
1227
1354
  }
1228
1355
  function createTelemetryProxyChain(plugins, config, core, startAt) {
@@ -1270,32 +1397,35 @@
1270
1397
  return nextProxy;
1271
1398
  },
1272
1399
  processTelemetry: _processTelemetry,
1400
+ unload: _unloadPlugin,
1273
1401
  _id: chainId,
1274
1402
  _setNext: function (nextPlugin) {
1275
1403
  nextProxy = nextPlugin;
1276
1404
  }
1277
1405
  };
1278
- function _processChain(itemCtx, processPluginFn, processProxyFn, name, details, isAsync) {
1406
+ function _getTelCtx() {
1407
+ var itemCtx;
1408
+ if (plugin && isFunction(plugin[strGetTelCtx])) {
1409
+ itemCtx = plugin[strGetTelCtx]();
1410
+ }
1279
1411
  if (!itemCtx) {
1280
- if (plugin && isFunction(plugin[strGetTelCtx])) {
1281
- itemCtx = plugin[strGetTelCtx]();
1282
- }
1283
- if (!itemCtx) {
1284
- itemCtx = createProcessTelemetryContext(proxyChain, config, core);
1285
- }
1412
+ itemCtx = createProcessTelemetryContext(proxyChain, config, core);
1286
1413
  }
1414
+ return itemCtx;
1415
+ }
1416
+ function _processChain(itemCtx, processPluginFn, name, details, isAsync) {
1417
+ var hasRun = false;
1287
1418
  var identifier = plugin ? plugin.identifier : strTelemetryPluginChain;
1288
1419
  var hasRunContext = itemCtx[strHasRunFlags];
1289
1420
  if (!hasRunContext) {
1290
1421
  hasRunContext = itemCtx[strHasRunFlags] = {};
1291
1422
  }
1292
- doPerf(itemCtx.core(), function () { return identifier + ":" + name; }, function () {
1293
- hasRunContext[chainId] = true;
1294
- var hasRun = false;
1295
- itemCtx.setNext(nextProxy);
1296
- if (plugin) {
1423
+ itemCtx.setNext(nextProxy);
1424
+ if (plugin) {
1425
+ doPerf(itemCtx[strCore](), function () { return identifier + ":" + name; }, function () {
1426
+ hasRunContext[chainId] = true;
1297
1427
  try {
1298
- var nextId = nextProxy ? nextProxy._id : "";
1428
+ var nextId = nextProxy ? nextProxy._id : strEmpty$1;
1299
1429
  if (nextId) {
1300
1430
  hasRunContext[nextId] = false;
1301
1431
  }
@@ -1307,18 +1437,21 @@
1307
1437
  hasRun = true;
1308
1438
  }
1309
1439
  if (!nextProxy || !hasNextRun) {
1310
- itemCtx.diagLog().throwInternal(LoggingSeverity.CRITICAL, _InternalMessageId.PluginException, "Plugin [" + plugin.identifier + "] failed during " + name + " - " + dumpObj(error) + ", run flags: " + dumpObj(hasRunContext));
1440
+ itemCtx.diagLog().throwInternal(1 , 73 , "Plugin [" + plugin.identifier + "] failed during " + name + " - " + dumpObj(error) + ", run flags: " + dumpObj(hasRunContext));
1311
1441
  }
1312
1442
  }
1313
- }
1314
- if (nextProxy && !hasRun) {
1315
- processProxyFn(itemCtx);
1316
- }
1317
- }, details, isAsync);
1443
+ }, details, isAsync);
1444
+ }
1445
+ return hasRun;
1318
1446
  }
1319
1447
  function _processTelemetry(env, itemCtx) {
1320
- _processChain(itemCtx, function (itemCtx) {
1321
- if (!hasProcessTelemetry) {
1448
+ itemCtx = itemCtx || _getTelCtx();
1449
+ function _callProcessTelemetry(itemCtx) {
1450
+ if (!plugin || !hasProcessTelemetry) {
1451
+ return false;
1452
+ }
1453
+ var pluginState = _getPluginState(plugin);
1454
+ if (pluginState[strTeardown] || pluginState[strDisabled]) {
1322
1455
  return false;
1323
1456
  }
1324
1457
  if (hasSetNext) {
@@ -1326,9 +1459,31 @@
1326
1459
  }
1327
1460
  plugin.processTelemetry(env, itemCtx);
1328
1461
  return true;
1329
- }, function (itemCtx) {
1330
- nextProxy.processTelemetry(env, itemCtx);
1331
- }, "processTelemetry", function () { return ({ item: env }); }, !(env.sync));
1462
+ }
1463
+ if (!_processChain(itemCtx, _callProcessTelemetry, "processTelemetry", function () { return ({ item: env }); }, !(env.sync))) {
1464
+ itemCtx.processNext(env);
1465
+ }
1466
+ }
1467
+ function _unloadPlugin(unloadCtx, unloadState) {
1468
+ function _callTeardown() {
1469
+ var hasRun = false;
1470
+ if (plugin) {
1471
+ var pluginState = _getPluginState(plugin);
1472
+ var pluginCore = plugin[strCore] || pluginState.core;
1473
+ if (plugin && (!pluginCore || pluginCore === unloadCtx[strCore]()) && !pluginState[strTeardown]) {
1474
+ pluginState[strCore] = null;
1475
+ pluginState[strTeardown] = true;
1476
+ pluginState[strIsInitialized] = false;
1477
+ if (plugin[strTeardown] && plugin[strTeardown](unloadCtx, unloadState) === true) {
1478
+ hasRun = true;
1479
+ }
1480
+ }
1481
+ }
1482
+ return hasRun;
1483
+ }
1484
+ if (!_processChain(unloadCtx, _callTeardown, "unload", function () { }, unloadState.isAsync)) {
1485
+ unloadCtx.processNext(unloadState);
1486
+ }
1332
1487
  }
1333
1488
  return objFreeze(proxyChain);
1334
1489
  }
@@ -1341,7 +1496,6 @@
1341
1496
  var strIsCookieUseDisabled = "isCookieUseDisabled";
1342
1497
  var strDisableCookiesUsage = "disableCookiesUsage";
1343
1498
  var strConfigCookieMgr = "_ckMgr";
1344
- var strEmpty = "";
1345
1499
  var _supportsCookies = null;
1346
1500
  var _allowUaSameSite = null;
1347
1501
  var _parsedCookieValue = null;
@@ -1418,7 +1572,7 @@
1418
1572
  var result = false;
1419
1573
  if (_isMgrEnabled(cookieMgr)) {
1420
1574
  var values = {};
1421
- var theValue = strTrim(value || strEmpty);
1575
+ var theValue = strTrim(value || strEmpty$1);
1422
1576
  var idx = theValue.indexOf(";");
1423
1577
  if (idx !== -1) {
1424
1578
  theValue = strTrim(value.substring(0, idx));
@@ -1433,11 +1587,11 @@
1433
1587
  if (expireMs > 0) {
1434
1588
  var expiry = new Date();
1435
1589
  expiry.setTime(expireMs);
1436
- setValue(values, strExpires, _formatDate(expiry, !_isIE ? strToUTCString : strToGMTString) || _formatDate(expiry, _isIE ? strToGMTString : strToUTCString) || strEmpty, isTruthy);
1590
+ setValue(values, strExpires, _formatDate(expiry, !_isIE ? strToUTCString : strToGMTString) || _formatDate(expiry, _isIE ? strToGMTString : strToUTCString) || strEmpty$1, isTruthy);
1437
1591
  }
1438
1592
  }
1439
1593
  if (!_isIE) {
1440
- setValue(values, "max-age", strEmpty + maxAgeSec, null, isUndefined);
1594
+ setValue(values, "max-age", strEmpty$1 + maxAgeSec, null, isUndefined);
1441
1595
  }
1442
1596
  }
1443
1597
  var location_1 = getLocation();
@@ -1458,7 +1612,7 @@
1458
1612
  return result;
1459
1613
  },
1460
1614
  get: function (name) {
1461
- var value = strEmpty;
1615
+ var value = strEmpty$1;
1462
1616
  if (_isMgrEnabled(cookieMgr)) {
1463
1617
  value = (cookieMgrConfig.getCookie || _getCookieValue)(name);
1464
1618
  }
@@ -1483,7 +1637,7 @@
1483
1637
  values["max-age"] = "0";
1484
1638
  }
1485
1639
  var delCookie = cookieMgrConfig.delCookie || _setCookieValue;
1486
- delCookie(name, _formatCookieValue(strEmpty, values));
1640
+ delCookie(name, _formatCookieValue(strEmpty$1, values));
1487
1641
  result = true;
1488
1642
  }
1489
1643
  return result;
@@ -1500,7 +1654,7 @@
1500
1654
  _supportsCookies = doc[strCookie] !== undefined;
1501
1655
  }
1502
1656
  catch (e) {
1503
- logger && logger.throwInternal(LoggingSeverity.WARNING, _InternalMessageId.CannotAccessCookie, "Cannot access document.cookie - " + getExceptionName(e), { exception: dumpObj(e) });
1657
+ logger && logger.throwInternal(2 , 68 , "Cannot access document.cookie - " + getExceptionName(e), { exception: dumpObj(e) });
1504
1658
  }
1505
1659
  }
1506
1660
  return _supportsCookies;
@@ -1510,7 +1664,7 @@
1510
1664
  if (theValue && theValue.length) {
1511
1665
  var parts = strTrim(theValue).split(";");
1512
1666
  arrForEach(parts, function (thePart) {
1513
- thePart = strTrim(thePart || strEmpty);
1667
+ thePart = strTrim(thePart || strEmpty$1);
1514
1668
  if (thePart) {
1515
1669
  var idx = thePart.indexOf("=");
1516
1670
  if (idx === -1) {
@@ -1531,21 +1685,21 @@
1531
1685
  return null;
1532
1686
  }
1533
1687
  function _formatCookieValue(value, values) {
1534
- var cookieValue = value || strEmpty;
1688
+ var cookieValue = value || strEmpty$1;
1535
1689
  objForEachKey(values, function (name, theValue) {
1536
- cookieValue += "; " + name + (!isNullOrUndefined(theValue) ? "=" + theValue : strEmpty);
1690
+ cookieValue += "; " + name + (!isNullOrUndefined(theValue) ? "=" + theValue : strEmpty$1);
1537
1691
  });
1538
1692
  return cookieValue;
1539
1693
  }
1540
1694
  function _getCookieValue(name) {
1541
- var cookieValue = strEmpty;
1695
+ var cookieValue = strEmpty$1;
1542
1696
  if (_doc) {
1543
- var theCookie = _doc[strCookie] || strEmpty;
1697
+ var theCookie = _doc[strCookie] || strEmpty$1;
1544
1698
  if (_parsedCookieValue !== theCookie) {
1545
1699
  _cookieCache = _extractParts(theCookie);
1546
1700
  _parsedCookieValue = theCookie;
1547
1701
  }
1548
- cookieValue = strTrim(_cookieCache[name] || strEmpty);
1702
+ cookieValue = strTrim(_cookieCache[name] || strEmpty$1);
1549
1703
  }
1550
1704
  return cookieValue;
1551
1705
  }
@@ -1595,6 +1749,38 @@
1595
1749
  _setDefaults(config, core, pluginChain);
1596
1750
  _isinitialized = true;
1597
1751
  };
1752
+ _self.teardown = function (unloadCtx, unloadState) {
1753
+ if (!_self.core || (unloadCtx && _self.core !== unloadCtx.core())) {
1754
+ return;
1755
+ }
1756
+ var result;
1757
+ var unloadDone = false;
1758
+ var theUnloadCtx = unloadCtx || createProcessTelemetryUnloadContext(null, {}, _self.core, _nextPlugin && _nextPlugin[strGetPlugin] ? _nextPlugin[strGetPlugin]() : _nextPlugin);
1759
+ var theUnloadState = unloadState || {
1760
+ reason: 0 ,
1761
+ isAsync: false
1762
+ };
1763
+ function _unloadCallback() {
1764
+ if (!unloadDone) {
1765
+ unloadDone = true;
1766
+ arrForEach(_hooks, function (fn) {
1767
+ fn.rm();
1768
+ });
1769
+ _hooks = [];
1770
+ if (result === true) {
1771
+ theUnloadCtx.processNext(theUnloadState);
1772
+ }
1773
+ _initDefaults();
1774
+ }
1775
+ }
1776
+ if (!_self[strDoTeardown] || _self[strDoTeardown](theUnloadCtx, theUnloadState, _unloadCallback) !== true) {
1777
+ _unloadCallback();
1778
+ }
1779
+ else {
1780
+ result = true;
1781
+ }
1782
+ return result;
1783
+ };
1598
1784
  _self._addHook = function (hooks) {
1599
1785
  if (hooks) {
1600
1786
  if (isArray(hooks)) {
@@ -1609,13 +1795,13 @@
1609
1795
  _self.diagLog = function (itemCtx) {
1610
1796
  return _getTelCtx(itemCtx).diagLog();
1611
1797
  };
1612
- _self.isInitialized = function () {
1798
+ _self[strIsInitialized] = function () {
1613
1799
  return _isinitialized;
1614
1800
  };
1615
1801
  _self.setInitialized = function (isInitialized) {
1616
1802
  _isinitialized = isInitialized;
1617
1803
  };
1618
- _self.setNextPlugin = function (next) {
1804
+ _self[strSetNextPlugin] = function (next) {
1619
1805
  _nextPlugin = next;
1620
1806
  };
1621
1807
  _self.processNext = function (env, itemCtx) {
@@ -1666,60 +1852,9 @@
1666
1852
  return BaseTelemetryPlugin;
1667
1853
  }());
1668
1854
 
1669
- var UInt32Mask = 0x100000000;
1670
- var MaxUInt32 = 0xffffffff;
1671
- var _mwcSeeded = false;
1672
- var _mwcW = 123456789;
1673
- var _mwcZ = 987654321;
1674
- function _mwcSeed(seedValue) {
1675
- if (seedValue < 0) {
1676
- seedValue >>>= 0;
1677
- }
1678
- _mwcW = (123456789 + seedValue) & MaxUInt32;
1679
- _mwcZ = (987654321 - seedValue) & MaxUInt32;
1680
- _mwcSeeded = true;
1681
- }
1682
- function _autoSeedMwc() {
1683
- try {
1684
- var now = dateNow() & 0x7fffffff;
1685
- _mwcSeed(((Math.random() * UInt32Mask) ^ now) + now);
1686
- }
1687
- catch (e) {
1688
- }
1689
- }
1690
- function random32(signed) {
1691
- var value = 0;
1692
- var c = getCrypto() || getMsCrypto();
1693
- if (c && c.getRandomValues) {
1694
- value = c.getRandomValues(new Uint32Array(1))[0] & MaxUInt32;
1695
- }
1696
- if (value === 0 && isIE()) {
1697
- if (!_mwcSeeded) {
1698
- _autoSeedMwc();
1699
- }
1700
- value = mwcRandom32() & MaxUInt32;
1701
- }
1702
- if (value === 0) {
1703
- value = Math.floor((UInt32Mask * Math.random()) | 0);
1704
- }
1705
- if (!signed) {
1706
- value >>>= 0;
1707
- }
1708
- return value;
1709
- }
1710
- function mwcRandom32(signed) {
1711
- _mwcZ = (36969 * (_mwcZ & 0xFFFF) + (_mwcZ >> 16)) & MaxUInt32;
1712
- _mwcW = (18000 * (_mwcW & 0xFFFF) + (_mwcW >> 16)) & MaxUInt32;
1713
- var value = (((_mwcZ << 16) + (_mwcW & 0xFFFF)) >>> 0) & MaxUInt32 | 0;
1714
- if (!signed) {
1715
- value >>>= 0;
1716
- }
1717
- return value;
1718
- }
1719
-
1720
1855
  function generateW3CId() {
1721
1856
  var hexValues = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f"];
1722
- var oct = "", tmp;
1857
+ var oct = strEmpty$1, tmp;
1723
1858
  for (var a = 0; a < 4; a++) {
1724
1859
  tmp = random32();
1725
1860
  oct +=
@@ -1736,6 +1871,95 @@
1736
1871
  return oct.substr(0, 8) + oct.substr(9, 4) + "4" + oct.substr(13, 3) + clockSequenceHi + oct.substr(16, 3) + oct.substr(19, 12);
1737
1872
  }
1738
1873
 
1874
+ var LoggingSeverity = createEnumStyle({
1875
+ CRITICAL: 1 ,
1876
+ WARNING: 2
1877
+ });
1878
+ var _InternalMessageId = createEnumStyle({
1879
+ BrowserDoesNotSupportLocalStorage: 0 ,
1880
+ BrowserCannotReadLocalStorage: 1 ,
1881
+ BrowserCannotReadSessionStorage: 2 ,
1882
+ BrowserCannotWriteLocalStorage: 3 ,
1883
+ BrowserCannotWriteSessionStorage: 4 ,
1884
+ BrowserFailedRemovalFromLocalStorage: 5 ,
1885
+ BrowserFailedRemovalFromSessionStorage: 6 ,
1886
+ CannotSendEmptyTelemetry: 7 ,
1887
+ ClientPerformanceMathError: 8 ,
1888
+ ErrorParsingAISessionCookie: 9 ,
1889
+ ErrorPVCalc: 10 ,
1890
+ ExceptionWhileLoggingError: 11 ,
1891
+ FailedAddingTelemetryToBuffer: 12 ,
1892
+ FailedMonitorAjaxAbort: 13 ,
1893
+ FailedMonitorAjaxDur: 14 ,
1894
+ FailedMonitorAjaxOpen: 15 ,
1895
+ FailedMonitorAjaxRSC: 16 ,
1896
+ FailedMonitorAjaxSend: 17 ,
1897
+ FailedMonitorAjaxGetCorrelationHeader: 18 ,
1898
+ FailedToAddHandlerForOnBeforeUnload: 19 ,
1899
+ FailedToSendQueuedTelemetry: 20 ,
1900
+ FailedToReportDataLoss: 21 ,
1901
+ FlushFailed: 22 ,
1902
+ MessageLimitPerPVExceeded: 23 ,
1903
+ MissingRequiredFieldSpecification: 24 ,
1904
+ NavigationTimingNotSupported: 25 ,
1905
+ OnError: 26 ,
1906
+ SessionRenewalDateIsZero: 27 ,
1907
+ SenderNotInitialized: 28 ,
1908
+ StartTrackEventFailed: 29 ,
1909
+ StopTrackEventFailed: 30 ,
1910
+ StartTrackFailed: 31 ,
1911
+ StopTrackFailed: 32 ,
1912
+ TelemetrySampledAndNotSent: 33 ,
1913
+ TrackEventFailed: 34 ,
1914
+ TrackExceptionFailed: 35 ,
1915
+ TrackMetricFailed: 36 ,
1916
+ TrackPVFailed: 37 ,
1917
+ TrackPVFailedCalc: 38 ,
1918
+ TrackTraceFailed: 39 ,
1919
+ TransmissionFailed: 40 ,
1920
+ FailedToSetStorageBuffer: 41 ,
1921
+ FailedToRestoreStorageBuffer: 42 ,
1922
+ InvalidBackendResponse: 43 ,
1923
+ FailedToFixDepricatedValues: 44 ,
1924
+ InvalidDurationValue: 45 ,
1925
+ TelemetryEnvelopeInvalid: 46 ,
1926
+ CreateEnvelopeError: 47 ,
1927
+ CannotSerializeObject: 48 ,
1928
+ CannotSerializeObjectNonSerializable: 49 ,
1929
+ CircularReferenceDetected: 50 ,
1930
+ ClearAuthContextFailed: 51 ,
1931
+ ExceptionTruncated: 52 ,
1932
+ IllegalCharsInName: 53 ,
1933
+ ItemNotInArray: 54 ,
1934
+ MaxAjaxPerPVExceeded: 55 ,
1935
+ MessageTruncated: 56 ,
1936
+ NameTooLong: 57 ,
1937
+ SampleRateOutOfRange: 58 ,
1938
+ SetAuthContextFailed: 59 ,
1939
+ SetAuthContextFailedAccountName: 60 ,
1940
+ StringValueTooLong: 61 ,
1941
+ StartCalledMoreThanOnce: 62 ,
1942
+ StopCalledWithoutStart: 63 ,
1943
+ TelemetryInitializerFailed: 64 ,
1944
+ TrackArgumentsNotSpecified: 65 ,
1945
+ UrlTooLong: 66 ,
1946
+ SessionStorageBufferFull: 67 ,
1947
+ CannotAccessCookie: 68 ,
1948
+ IdTooLong: 69 ,
1949
+ InvalidEvent: 70 ,
1950
+ FailedMonitorAjaxSetRequestHeader: 71 ,
1951
+ SendBrowserInfoOnUserInit: 72 ,
1952
+ PluginException: 73 ,
1953
+ NotificationException: 74 ,
1954
+ SnippetScriptLoadFailure: 99 ,
1955
+ InvalidInstrumentationKey: 100 ,
1956
+ CannotParseAiBlobValue: 101 ,
1957
+ InvalidContentBlob: 102 ,
1958
+ TrackPageActionEventFailed: 103 ,
1959
+ FailedAddingCustomDefinedRequestContext: 104 ,
1960
+ InMemoryStorageBufferFull: 105
1961
+ });
1962
+
1739
1963
  function dataSanitizeKeyAndAddUniqueness(logger, key, map) {
1740
1964
  var origLength = key.length;
1741
1965
  var field = dataSanitizeKey(logger, key);
@@ -1756,7 +1980,7 @@
1756
1980
  name = strTrim(name.toString());
1757
1981
  if (name.length > 150 ) {
1758
1982
  nameTrunc = name.substring(0, 150 );
1759
- logger && logger.throwInternal(LoggingSeverity.WARNING, _InternalMessageId.NameTooLong, "name is too long. It has been truncated to " + 150 + " characters.", { name: name }, true);
1983
+ logger && logger.throwInternal(2 , _InternalMessageId.NameTooLong, "name is too long. It has been truncated to " + 150 + " characters.", { name: name }, true);
1760
1984
  }
1761
1985
  }
1762
1986
  return nameTrunc || name;
@@ -1769,7 +1993,7 @@
1769
1993
  value = strTrim(value);
1770
1994
  if (value.toString().length > maxLength) {
1771
1995
  valueTrunc = value.toString().substring(0, maxLength);
1772
- logger && logger.throwInternal(LoggingSeverity.WARNING, _InternalMessageId.StringValueTooLong, "string value is too long. It has been truncated to " + maxLength + " characters.", { value: value }, true);
1996
+ logger && logger.throwInternal(2 , _InternalMessageId.StringValueTooLong, "string value is too long. It has been truncated to " + maxLength + " characters.", { value: value }, true);
1773
1997
  }
1774
1998
  }
1775
1999
  return valueTrunc || value;
@@ -1782,7 +2006,7 @@
1782
2006
  if (message) {
1783
2007
  if (message.length > 32768 ) {
1784
2008
  messageTrunc = message.substring(0, 32768 );
1785
- logger && logger.throwInternal(LoggingSeverity.WARNING, _InternalMessageId.MessageTruncated, "message is too long, it has been truncated to " + 32768 + " characters.", { message: message }, true);
2009
+ logger && logger.throwInternal(2 , _InternalMessageId.MessageTruncated, "message is too long, it has been truncated to " + 32768 + " characters.", { message: message }, true);
1786
2010
  }
1787
2011
  }
1788
2012
  return messageTrunc || message;
@@ -1793,7 +2017,7 @@
1793
2017
  var value = "" + exception;
1794
2018
  if (value.length > 32768 ) {
1795
2019
  exceptionTrunc = value.substring(0, 32768 );
1796
- logger && logger.throwInternal(LoggingSeverity.WARNING, _InternalMessageId.ExceptionTruncated, "exception is too long, it has been truncated to " + 32768 + " characters.", { exception: exception }, true);
2020
+ logger && logger.throwInternal(2 , _InternalMessageId.ExceptionTruncated, "exception is too long, it has been truncated to " + 32768 + " characters.", { exception: exception }, true);
1797
2021
  }
1798
2022
  }
1799
2023
  return exceptionTrunc || exception;
@@ -1807,7 +2031,7 @@
1807
2031
  value = getJSON().stringify(value);
1808
2032
  }
1809
2033
  catch (e) {
1810
- logger && logger.throwInternal(LoggingSeverity.WARNING, _InternalMessageId.CannotSerializeObjectNonSerializable, "custom property is not valid", { exception: e }, true);
2034
+ logger && logger.throwInternal(2 , _InternalMessageId.CannotSerializeObjectNonSerializable, "custom property is not valid", { exception: e }, true);
1811
2035
  }
1812
2036
  }
1813
2037
  value = dataSanitizeString(logger, value, 8192 );
@@ -1838,7 +2062,7 @@
1838
2062
  input = strTrim(input);
1839
2063
  if (input.length > maxLength) {
1840
2064
  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);
2065
+ logger && logger.throwInternal(2 , _msgId, "input is too long, it has been truncated to " + maxLength + " characters.", { data: input }, true);
1842
2066
  }
1843
2067
  }
1844
2068
  return inputTrunc || input;
@@ -1863,6 +2087,7 @@
1863
2087
  return event;
1864
2088
  }
1865
2089
 
2090
+ var strEmpty = "";
1866
2091
  function stringToBoolOrDefault(str, defaultValue) {
1867
2092
  if (defaultValue === void 0) { defaultValue = false; }
1868
2093
  if (str === undefined || str === null) {
@@ -1875,16 +2100,16 @@
1875
2100
  totalms = 0;
1876
2101
  }
1877
2102
  totalms = Math.round(totalms);
1878
- var ms = "" + totalms % 1000;
1879
- var sec = "" + Math.floor(totalms / 1000) % 60;
1880
- var min = "" + Math.floor(totalms / (1000 * 60)) % 60;
1881
- var hour = "" + Math.floor(totalms / (1000 * 60 * 60)) % 24;
2103
+ var ms = strEmpty + totalms % 1000;
2104
+ var sec = strEmpty + Math.floor(totalms / 1000) % 60;
2105
+ var min = strEmpty + Math.floor(totalms / (1000 * 60)) % 60;
2106
+ var hour = strEmpty + Math.floor(totalms / (1000 * 60 * 60)) % 24;
1882
2107
  var days = Math.floor(totalms / (1000 * 60 * 60 * 24));
1883
2108
  ms = ms.length === 1 ? "00" + ms : ms.length === 2 ? "0" + ms : ms;
1884
2109
  sec = sec.length < 2 ? "0" + sec : sec;
1885
2110
  min = min.length < 2 ? "0" + min : min;
1886
2111
  hour = hour.length < 2 ? "0" + hour : hour;
1887
- return (days > 0 ? days + "." : "") + hour + ":" + min + ":" + sec + "." + ms;
2112
+ return (days > 0 ? days + "." : strEmpty) + hour + ":" + min + ":" + sec + "." + ms;
1888
2113
  }
1889
2114
  function isCrossOriginError(message, url, lineNumber, columnNumber, error) {
1890
2115
  return !error && isString(message) && (message === "Script error." || message === "Script error");
@@ -1893,17 +2118,15 @@
1893
2118
  var strNotSpecified = "not_specified";
1894
2119
  var strIkey = "iKey";
1895
2120
 
1896
- var StorageType;
1897
- (function (StorageType) {
1898
- StorageType[StorageType["LocalStorage"] = 0] = "LocalStorage";
1899
- StorageType[StorageType["SessionStorage"] = 1] = "SessionStorage";
1900
- })(StorageType || (StorageType = {}));
1901
- var DistributedTracingModes;
1902
- (function (DistributedTracingModes) {
1903
- DistributedTracingModes[DistributedTracingModes["AI"] = 0] = "AI";
1904
- DistributedTracingModes[DistributedTracingModes["AI_AND_W3C"] = 1] = "AI_AND_W3C";
1905
- DistributedTracingModes[DistributedTracingModes["W3C"] = 2] = "W3C";
1906
- })(DistributedTracingModes || (DistributedTracingModes = {}));
2121
+ var StorageType = createEnumStyle({
2122
+ LocalStorage: 0 ,
2123
+ SessionStorage: 1
2124
+ });
2125
+ createEnumStyle({
2126
+ AI: 0 ,
2127
+ AI_AND_W3C: 1 ,
2128
+ W3C: 2
2129
+ });
1907
2130
 
1908
2131
  var _canUseSessionStorage = undefined;
1909
2132
  function _getVerifiedStorageObject(storageType) {
@@ -1947,7 +2170,7 @@
1947
2170
  }
1948
2171
  catch (e) {
1949
2172
  _canUseSessionStorage = false;
1950
- logger.throwInternal(LoggingSeverity.WARNING, _InternalMessageId.BrowserCannotReadSessionStorage, "Browser failed read of session storage. " + getExceptionName(e), { exception: dumpObj(e) });
2173
+ logger.throwInternal(2 , _InternalMessageId.BrowserCannotReadSessionStorage, "Browser failed read of session storage. " + getExceptionName(e), { exception: dumpObj(e) });
1951
2174
  }
1952
2175
  }
1953
2176
  return null;
@@ -1961,7 +2184,7 @@
1961
2184
  }
1962
2185
  catch (e) {
1963
2186
  _canUseSessionStorage = false;
1964
- logger.throwInternal(LoggingSeverity.WARNING, _InternalMessageId.BrowserCannotWriteSessionStorage, "Browser failed write to session storage. " + getExceptionName(e), { exception: dumpObj(e) });
2187
+ logger.throwInternal(2 , _InternalMessageId.BrowserCannotWriteSessionStorage, "Browser failed write to session storage. " + getExceptionName(e), { exception: dumpObj(e) });
1965
2188
  }
1966
2189
  }
1967
2190
  return false;
@@ -1975,7 +2198,7 @@
1975
2198
  }
1976
2199
  catch (e) {
1977
2200
  _canUseSessionStorage = false;
1978
- logger.throwInternal(LoggingSeverity.WARNING, _InternalMessageId.BrowserFailedRemovalFromSessionStorage, "Browser failed removal of session storage item. " + getExceptionName(e), { exception: dumpObj(e) });
2201
+ logger.throwInternal(2 , _InternalMessageId.BrowserFailedRemovalFromSessionStorage, "Browser failed removal of session storage item. " + getExceptionName(e), { exception: dumpObj(e) });
1979
2202
  }
1980
2203
  }
1981
2204
  return false;
@@ -3622,7 +3845,7 @@
3622
3845
  config.disableFlushOnUnload = stringToBoolOrDefault(config.disableFlushOnUnload, config.disableFlushOnBeforeUnload);
3623
3846
  return config;
3624
3847
  };
3625
- ApplicationInsights.Version = "2.8.0-beta.2203-01";
3848
+ ApplicationInsights.Version = "2.8.0-beta.2203-02";
3626
3849
  return ApplicationInsights;
3627
3850
  }(BaseTelemetryPlugin));
3628
3851
  var Timing = /** @class */ (function () {