@microsoft/applicationinsights-analytics-js 2.8.0-beta.2202-07 → 2.8.0-beta.2203-03

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.2202-07
2
+ * Application Insights JavaScript SDK - Web Analytics, 2.8.0-beta.2203-03
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,44 @@
655
589
  function throwError(message) {
656
590
  throw new Error(message);
657
591
  }
592
+ function _createProxyFunction(source, funcName) {
593
+ var srcFunc = null;
594
+ var src = null;
595
+ if (isFunction(source)) {
596
+ srcFunc = source;
597
+ }
598
+ else {
599
+ src = source;
600
+ }
601
+ return function () {
602
+ var originalArguments = arguments;
603
+ if (srcFunc) {
604
+ src = srcFunc();
605
+ }
606
+ if (src) {
607
+ return src[funcName].apply(src, originalArguments);
608
+ }
609
+ };
610
+ }
611
+ function proxyFunctionAs(target, name, source, theFunc, overwriteTarget) {
612
+ if (overwriteTarget === void 0) { overwriteTarget = true; }
613
+ if (target && name && source) {
614
+ if (overwriteTarget || isUndefined(target[name])) {
615
+ target[name] = _createProxyFunction(source, theFunc);
616
+ }
617
+ }
618
+ }
619
+ function createEnumStyle(values) {
620
+ var enumClass = {};
621
+ objForEachKey(values, function (field, value) {
622
+ enumClass[field] = value;
623
+ if (!isUndefined(enumClass[value])) {
624
+ throwError("[" + value + "] exists for " + field);
625
+ }
626
+ enumClass[value] = field;
627
+ });
628
+ return objFreeze(enumClass);
629
+ }
658
630
  function objExtend(obj, obj2, obj3, obj4, obj5, obj6) {
659
631
  var theArgs = arguments;
660
632
  var extended = theArgs[0] || {};
@@ -801,14 +773,14 @@
801
773
  var nav = getNavigator();
802
774
  if (nav && (nav.userAgent !== _navUserAgentCheck || _isTrident === null)) {
803
775
  _navUserAgentCheck = nav.userAgent;
804
- var userAgent = (_navUserAgentCheck || "").toLowerCase();
776
+ var userAgent = (_navUserAgentCheck || strEmpty$1).toLowerCase();
805
777
  _isTrident = (strContains(userAgent, strMsie) || strContains(userAgent, strTrident));
806
778
  }
807
779
  return _isTrident;
808
780
  }
809
781
  function dumpObj(object) {
810
782
  var objectTypeDump = Object[strShimPrototype].toString.call(object);
811
- var propertyValueDump = "";
783
+ var propertyValueDump = strEmpty$1;
812
784
  if (objectTypeDump === "[object Error]") {
813
785
  propertyValueDump = "{ stack: '" + object.stack + "', message: '" + object.message + "', name: '" + object.name + "'";
814
786
  }
@@ -841,9 +813,9 @@
841
813
  var strWarnToConsole = "warnToConsole";
842
814
  function _sanitizeDiagnosticText(text) {
843
815
  if (text) {
844
- return "\"" + text.replace(/\"/g, "") + "\"";
816
+ return "\"" + text.replace(/\"/g, strEmpty$1) + "\"";
845
817
  }
846
- return "";
818
+ return strEmpty$1;
847
819
  }
848
820
  function _logToConsole(func, message) {
849
821
  var theConsole = getConsole();
@@ -865,12 +837,12 @@
865
837
  _self.message =
866
838
  (isUserAct ? AiUserActionablePrefix : AiNonUserActionablePrefix) +
867
839
  msgId;
868
- var strProps = "";
840
+ var strProps = strEmpty$1;
869
841
  if (hasJSON()) {
870
842
  strProps = getJSON().stringify(properties);
871
843
  }
872
- var diagnosticText = (msg ? " message:" + _sanitizeDiagnosticText(msg) : "") +
873
- (properties ? " props:" + _sanitizeDiagnosticText(strProps) : "");
844
+ var diagnosticText = (msg ? " message:" + _sanitizeDiagnosticText(msg) : strEmpty$1) +
845
+ (properties ? " props:" + _sanitizeDiagnosticText(strProps) : strEmpty$1);
874
846
  _self.message += diagnosticText;
875
847
  }
876
848
  _InternalLogMessage.dataType = "MessageData";
@@ -900,7 +872,7 @@
900
872
  throw message;
901
873
  }
902
874
  else {
903
- var logFunc = severity === LoggingSeverity.CRITICAL ? strErrorToConsole : strWarnToConsole;
875
+ var logFunc = severity === 1 ? strErrorToConsole : strWarnToConsole;
904
876
  if (!isUndefined(message.message)) {
905
877
  var logLevel = _self.consoleLoggingLevel();
906
878
  if (isUserAct) {
@@ -918,7 +890,7 @@
918
890
  _self.logInternalMessage(severity, message);
919
891
  }
920
892
  else {
921
- _debugExtMsg("throw" + (severity === LoggingSeverity.CRITICAL ? "Critical" : "Warning"), message);
893
+ _debugExtMsg("throw" + (severity === 1 ? "Critical" : "Warning"), message);
922
894
  }
923
895
  }
924
896
  };
@@ -950,13 +922,13 @@
950
922
  if (severity <= _self.telemetryLoggingLevel()) {
951
923
  _self.queue.push(message);
952
924
  _messageCount++;
953
- _debugExtMsg((severity === LoggingSeverity.CRITICAL ? "error" : "warn"), message);
925
+ _debugExtMsg((severity === 1 ? "error" : "warn"), message);
954
926
  }
955
927
  if (_messageCount === _self.maxInternalMessageLimit()) {
956
928
  var throttleLimitMessage = "Internal events throttle limit per PageView reached for this app.";
957
- var throttleMessage = new _InternalLogMessage(_InternalMessageId.MessageLimitPerPVExceeded, throttleLimitMessage, false);
929
+ var throttleMessage = new _InternalLogMessage(23 , throttleLimitMessage, false);
958
930
  _self.queue.push(throttleMessage);
959
- if (severity === LoggingSeverity.CRITICAL) {
931
+ if (severity === 1 ) {
960
932
  _self.errorToConsole(throttleLimitMessage);
961
933
  }
962
934
  else {
@@ -1098,6 +1070,151 @@
1098
1070
  return func();
1099
1071
  }
1100
1072
 
1073
+ var UInt32Mask = 0x100000000;
1074
+ var MaxUInt32 = 0xffffffff;
1075
+ var _mwcSeeded = false;
1076
+ var _mwcW = 123456789;
1077
+ var _mwcZ = 987654321;
1078
+ function _mwcSeed(seedValue) {
1079
+ if (seedValue < 0) {
1080
+ seedValue >>>= 0;
1081
+ }
1082
+ _mwcW = (123456789 + seedValue) & MaxUInt32;
1083
+ _mwcZ = (987654321 - seedValue) & MaxUInt32;
1084
+ _mwcSeeded = true;
1085
+ }
1086
+ function _autoSeedMwc() {
1087
+ try {
1088
+ var now = dateNow() & 0x7fffffff;
1089
+ _mwcSeed(((Math.random() * UInt32Mask) ^ now) + now);
1090
+ }
1091
+ catch (e) {
1092
+ }
1093
+ }
1094
+ function random32(signed) {
1095
+ var value = 0;
1096
+ var c = getCrypto() || getMsCrypto();
1097
+ if (c && c.getRandomValues) {
1098
+ value = c.getRandomValues(new Uint32Array(1))[0] & MaxUInt32;
1099
+ }
1100
+ if (value === 0 && isIE()) {
1101
+ if (!_mwcSeeded) {
1102
+ _autoSeedMwc();
1103
+ }
1104
+ value = mwcRandom32() & MaxUInt32;
1105
+ }
1106
+ if (value === 0) {
1107
+ value = Math.floor((UInt32Mask * Math.random()) | 0);
1108
+ }
1109
+ if (!signed) {
1110
+ value >>>= 0;
1111
+ }
1112
+ return value;
1113
+ }
1114
+ function mwcRandom32(signed) {
1115
+ _mwcZ = (36969 * (_mwcZ & 0xFFFF) + (_mwcZ >> 16)) & MaxUInt32;
1116
+ _mwcW = (18000 * (_mwcW & 0xFFFF) + (_mwcW >> 16)) & MaxUInt32;
1117
+ var value = (((_mwcZ << 16) + (_mwcW & 0xFFFF)) >>> 0) & MaxUInt32 | 0;
1118
+ if (!signed) {
1119
+ value >>>= 0;
1120
+ }
1121
+ return value;
1122
+ }
1123
+ function newId(maxLength) {
1124
+ if (maxLength === void 0) { maxLength = 22; }
1125
+ var base64chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
1126
+ var number = random32() >>> 0;
1127
+ var chars = 0;
1128
+ var result = strEmpty$1;
1129
+ while (result.length < maxLength) {
1130
+ chars++;
1131
+ result += base64chars.charAt(number & 0x3F);
1132
+ number >>>= 6;
1133
+ if (chars === 5) {
1134
+ number = (((random32() << 2) & 0xFFFFFFFF) | (number & 0x03)) >>> 0;
1135
+ chars = 0;
1136
+ }
1137
+ }
1138
+ return result;
1139
+ }
1140
+
1141
+ var _objDefineProperty = ObjDefineProperty;
1142
+ var version = "2.7.3";
1143
+ var instanceName = "." + newId(6);
1144
+ var _dataUid = 0;
1145
+ function _createAccessor(target, prop, value) {
1146
+ if (_objDefineProperty) {
1147
+ try {
1148
+ _objDefineProperty(target, prop, {
1149
+ value: value,
1150
+ enumerable: false,
1151
+ configurable: true
1152
+ });
1153
+ return true;
1154
+ }
1155
+ catch (e) {
1156
+ }
1157
+ }
1158
+ return false;
1159
+ }
1160
+ function _canAcceptData(target) {
1161
+ return target.nodeType === 1 || target.nodeType === 9 || !(+target.nodeType);
1162
+ }
1163
+ function _getCache(data, target) {
1164
+ var theCache = target[data.id];
1165
+ if (!theCache) {
1166
+ theCache = {};
1167
+ try {
1168
+ if (_canAcceptData(target)) {
1169
+ if (!_createAccessor(target, data.id, theCache)) {
1170
+ target[data.id] = theCache;
1171
+ }
1172
+ }
1173
+ }
1174
+ catch (e) {
1175
+ }
1176
+ }
1177
+ return theCache;
1178
+ }
1179
+ function createUniqueNamespace(name, includeVersion) {
1180
+ if (includeVersion === void 0) { includeVersion = false; }
1181
+ return normalizeJsName(name + (_dataUid++) + (includeVersion ? "." + version : "") + instanceName);
1182
+ }
1183
+ function createElmNodeData(name) {
1184
+ var data = {
1185
+ id: createUniqueNamespace("_aiData-" + (name || "") + "." + version),
1186
+ accept: function (target) {
1187
+ return _canAcceptData(target);
1188
+ },
1189
+ get: function (target, name, defValue, addDefault) {
1190
+ var theCache = target[data.id];
1191
+ if (!theCache) {
1192
+ if (addDefault) {
1193
+ theCache = _getCache(data, target);
1194
+ theCache[normalizeJsName(name)] = defValue;
1195
+ }
1196
+ return defValue;
1197
+ }
1198
+ return theCache[normalizeJsName(name)];
1199
+ },
1200
+ kill: function (target, name) {
1201
+ if (target && target[name]) {
1202
+ try {
1203
+ delete target[name];
1204
+ }
1205
+ catch (e) {
1206
+ }
1207
+ }
1208
+ }
1209
+ };
1210
+ return data;
1211
+ }
1212
+
1213
+ var pluginStateData = createElmNodeData("plugin");
1214
+ function _getPluginState(plugin) {
1215
+ return pluginStateData.get(plugin, "state", {}, true);
1216
+ }
1217
+
1101
1218
  var strTelemetryPluginChain = "TelemetryPluginChain";
1102
1219
  var strHasRunFlags = "_hasRun";
1103
1220
  var strGetTelCtx = "_getTelCtx";
@@ -1111,53 +1228,69 @@
1111
1228
  }
1112
1229
  return createTelemetryProxyChain([startAt], config, core);
1113
1230
  }
1114
- function createProcessTelemetryContext(telemetryChain, config, core, startAt) {
1231
+ function _createInternalContext(telemetryChain, config, core, startAt) {
1115
1232
  var _nextProxy = null;
1116
- var _onComplete = null;
1117
- if (startAt) {
1118
- _nextProxy = _getNextProxyStart(telemetryChain, config, core, startAt);
1119
- }
1120
- else {
1121
- _nextProxy = telemetryChain;
1233
+ var _onComplete = [];
1234
+ if (startAt !== null) {
1235
+ _nextProxy = startAt ? _getNextProxyStart(telemetryChain, config, core, startAt) : telemetryChain;
1122
1236
  }
1123
1237
  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);
1238
+ _next: _moveNext,
1239
+ ctx: {
1240
+ core: function () { return core; },
1241
+ diagLog: function () {
1242
+ return safeGetLogger(core, config);
1243
+ },
1244
+ getCfg: function () {
1245
+ return config;
1246
+ },
1247
+ getExtCfg: _getExtCfg,
1248
+ getConfig: _getConfig,
1249
+ hasNext: function () {
1250
+ return !!_nextProxy;
1251
+ },
1252
+ getNext: function () {
1253
+ return _nextProxy;
1254
+ },
1255
+ setNext: function (nextPlugin) {
1256
+ _nextProxy = nextPlugin;
1257
+ },
1258
+ iterate: _iterateChain,
1259
+ onComplete: _addOnComplete
1260
+ }
1261
+ };
1262
+ function _addOnComplete(onComplete, that) {
1263
+ var args = [];
1264
+ for (var _i = 2; _i < arguments.length; _i++) {
1265
+ args[_i - 2] = arguments[_i];
1266
+ }
1267
+ if (onComplete) {
1268
+ _onComplete.push({
1269
+ func: onComplete,
1270
+ self: !isUndefined(that) ? that : context.ctx,
1271
+ args: args
1147
1272
  });
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);
1273
+ }
1274
+ }
1275
+ function _moveNext() {
1276
+ var nextProxy = _nextProxy;
1277
+ _nextProxy = nextProxy ? nextProxy.getNext() : null;
1278
+ if (!nextProxy) {
1279
+ var onComplete = _onComplete;
1280
+ if (onComplete && onComplete.length > 0) {
1281
+ arrForEach(onComplete, function (completeDetails) {
1282
+ try {
1283
+ completeDetails.func.call(completeDetails.self, completeDetails.args);
1284
+ }
1285
+ catch (e) {
1286
+ core.logger.throwInternal(2 , 73 , "Unexpected Exception during onComplete - " + dumpObj(e));
1287
+ }
1288
+ });
1289
+ _onComplete = [];
1154
1290
  }
1155
- return createProcessTelemetryContext(plugins || _nextProxy, config, core, startAt);
1156
- },
1157
- onComplete: function (onComplete) {
1158
- _onComplete = onComplete;
1159
1291
  }
1160
- };
1292
+ return nextProxy;
1293
+ }
1161
1294
  function _getExtCfg(identifier, defaultValue, mergeDefault) {
1162
1295
  if (defaultValue === void 0) { defaultValue = {}; }
1163
1296
  if (mergeDefault === void 0) { mergeDefault = 0 ; }
@@ -1200,29 +1333,53 @@
1200
1333
  }
1201
1334
  return !isNullOrUndefined(theValue) ? theValue : defaultValue;
1202
1335
  }
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;
1336
+ function _iterateChain(cb) {
1337
+ var nextPlugin;
1338
+ while (!!(nextPlugin = context._next())) {
1339
+ var plugin = nextPlugin.getPlugin();
1340
+ if (plugin) {
1341
+ cb(plugin);
1213
1342
  }
1214
1343
  }
1215
1344
  }
1216
- function _iterateChain(cb) {
1217
- while (_nextProxy) {
1218
- _processChain(function (nextPlugin) {
1219
- var plugin = nextPlugin.getPlugin();
1220
- if (plugin) {
1221
- cb(plugin);
1222
- }
1223
- });
1345
+ return context;
1346
+ }
1347
+ function createProcessTelemetryContext(telemetryChain, config, core, startAt) {
1348
+ var internalContext = _createInternalContext(telemetryChain, config, core, startAt);
1349
+ var context = internalContext.ctx;
1350
+ function _processNext(env) {
1351
+ var nextPlugin = internalContext._next();
1352
+ nextPlugin && nextPlugin.processTelemetry(env, context);
1353
+ return !nextPlugin;
1354
+ }
1355
+ function _createNew(plugins, startAt) {
1356
+ if (plugins === void 0) { plugins = null; }
1357
+ if (isArray(plugins)) {
1358
+ plugins = createTelemetryProxyChain(plugins, config, core, startAt);
1359
+ }
1360
+ return createProcessTelemetryContext(plugins || context.getNext(), config, core, startAt);
1361
+ }
1362
+ context.processNext = _processNext;
1363
+ context.createNew = _createNew;
1364
+ return context;
1365
+ }
1366
+ function createProcessTelemetryUnloadContext(telemetryChain, config, core, startAt) {
1367
+ var internalContext = _createInternalContext(telemetryChain, config, core, startAt);
1368
+ var context = internalContext.ctx;
1369
+ function _processNext(unloadState) {
1370
+ var nextPlugin = internalContext._next();
1371
+ nextPlugin && nextPlugin.unload(context, unloadState);
1372
+ return !nextPlugin;
1373
+ }
1374
+ function _createNew(plugins, startAt) {
1375
+ if (plugins === void 0) { plugins = null; }
1376
+ if (isArray(plugins)) {
1377
+ plugins = createTelemetryProxyChain(plugins, config, core, startAt);
1224
1378
  }
1379
+ return createProcessTelemetryUnloadContext(plugins || context.getNext(), config, core, startAt);
1225
1380
  }
1381
+ context.processNext = _processNext;
1382
+ context.createNew = _createNew;
1226
1383
  return context;
1227
1384
  }
1228
1385
  function createTelemetryProxyChain(plugins, config, core, startAt) {
@@ -1270,32 +1427,35 @@
1270
1427
  return nextProxy;
1271
1428
  },
1272
1429
  processTelemetry: _processTelemetry,
1430
+ unload: _unloadPlugin,
1273
1431
  _id: chainId,
1274
1432
  _setNext: function (nextPlugin) {
1275
1433
  nextProxy = nextPlugin;
1276
1434
  }
1277
1435
  };
1278
- function _processChain(itemCtx, processPluginFn, processProxyFn, name, details, isAsync) {
1436
+ function _getTelCtx() {
1437
+ var itemCtx;
1438
+ if (plugin && isFunction(plugin[strGetTelCtx])) {
1439
+ itemCtx = plugin[strGetTelCtx]();
1440
+ }
1279
1441
  if (!itemCtx) {
1280
- if (plugin && isFunction(plugin[strGetTelCtx])) {
1281
- itemCtx = plugin[strGetTelCtx]();
1282
- }
1283
- if (!itemCtx) {
1284
- itemCtx = createProcessTelemetryContext(proxyChain, config, core);
1285
- }
1442
+ itemCtx = createProcessTelemetryContext(proxyChain, config, core);
1286
1443
  }
1444
+ return itemCtx;
1445
+ }
1446
+ function _processChain(itemCtx, processPluginFn, name, details, isAsync) {
1447
+ var hasRun = false;
1287
1448
  var identifier = plugin ? plugin.identifier : strTelemetryPluginChain;
1288
1449
  var hasRunContext = itemCtx[strHasRunFlags];
1289
1450
  if (!hasRunContext) {
1290
1451
  hasRunContext = itemCtx[strHasRunFlags] = {};
1291
1452
  }
1292
- doPerf(itemCtx.core(), function () { return identifier + ":" + name; }, function () {
1293
- hasRunContext[chainId] = true;
1294
- var hasRun = false;
1295
- itemCtx.setNext(nextProxy);
1296
- if (plugin) {
1453
+ itemCtx.setNext(nextProxy);
1454
+ if (plugin) {
1455
+ doPerf(itemCtx[strCore](), function () { return identifier + ":" + name; }, function () {
1456
+ hasRunContext[chainId] = true;
1297
1457
  try {
1298
- var nextId = nextProxy ? nextProxy._id : "";
1458
+ var nextId = nextProxy ? nextProxy._id : strEmpty$1;
1299
1459
  if (nextId) {
1300
1460
  hasRunContext[nextId] = false;
1301
1461
  }
@@ -1307,18 +1467,21 @@
1307
1467
  hasRun = true;
1308
1468
  }
1309
1469
  if (!nextProxy || !hasNextRun) {
1310
- itemCtx.diagLog().throwInternal(LoggingSeverity.CRITICAL, _InternalMessageId.PluginException, "Plugin [" + plugin.identifier + "] failed during " + name + " - " + dumpObj(error) + ", run flags: " + dumpObj(hasRunContext));
1470
+ itemCtx.diagLog().throwInternal(1 , 73 , "Plugin [" + plugin.identifier + "] failed during " + name + " - " + dumpObj(error) + ", run flags: " + dumpObj(hasRunContext));
1311
1471
  }
1312
1472
  }
1313
- }
1314
- if (nextProxy && !hasRun) {
1315
- processProxyFn(itemCtx);
1316
- }
1317
- }, details, isAsync);
1473
+ }, details, isAsync);
1474
+ }
1475
+ return hasRun;
1318
1476
  }
1319
1477
  function _processTelemetry(env, itemCtx) {
1320
- _processChain(itemCtx, function (itemCtx) {
1321
- if (!hasProcessTelemetry) {
1478
+ itemCtx = itemCtx || _getTelCtx();
1479
+ function _callProcessTelemetry(itemCtx) {
1480
+ if (!plugin || !hasProcessTelemetry) {
1481
+ return false;
1482
+ }
1483
+ var pluginState = _getPluginState(plugin);
1484
+ if (pluginState[strTeardown] || pluginState[strDisabled]) {
1322
1485
  return false;
1323
1486
  }
1324
1487
  if (hasSetNext) {
@@ -1326,9 +1489,31 @@
1326
1489
  }
1327
1490
  plugin.processTelemetry(env, itemCtx);
1328
1491
  return true;
1329
- }, function (itemCtx) {
1330
- nextProxy.processTelemetry(env, itemCtx);
1331
- }, "processTelemetry", function () { return ({ item: env }); }, !(env.sync));
1492
+ }
1493
+ if (!_processChain(itemCtx, _callProcessTelemetry, "processTelemetry", function () { return ({ item: env }); }, !(env.sync))) {
1494
+ itemCtx.processNext(env);
1495
+ }
1496
+ }
1497
+ function _unloadPlugin(unloadCtx, unloadState) {
1498
+ function _callTeardown() {
1499
+ var hasRun = false;
1500
+ if (plugin) {
1501
+ var pluginState = _getPluginState(plugin);
1502
+ var pluginCore = plugin[strCore] || pluginState.core;
1503
+ if (plugin && (!pluginCore || pluginCore === unloadCtx[strCore]()) && !pluginState[strTeardown]) {
1504
+ pluginState[strCore] = null;
1505
+ pluginState[strTeardown] = true;
1506
+ pluginState[strIsInitialized] = false;
1507
+ if (plugin[strTeardown] && plugin[strTeardown](unloadCtx, unloadState) === true) {
1508
+ hasRun = true;
1509
+ }
1510
+ }
1511
+ }
1512
+ return hasRun;
1513
+ }
1514
+ if (!_processChain(unloadCtx, _callTeardown, "unload", function () { }, unloadState.isAsync)) {
1515
+ unloadCtx.processNext(unloadState);
1516
+ }
1332
1517
  }
1333
1518
  return objFreeze(proxyChain);
1334
1519
  }
@@ -1341,7 +1526,6 @@
1341
1526
  var strIsCookieUseDisabled = "isCookieUseDisabled";
1342
1527
  var strDisableCookiesUsage = "disableCookiesUsage";
1343
1528
  var strConfigCookieMgr = "_ckMgr";
1344
- var strEmpty = "";
1345
1529
  var _supportsCookies = null;
1346
1530
  var _allowUaSameSite = null;
1347
1531
  var _parsedCookieValue = null;
@@ -1418,7 +1602,7 @@
1418
1602
  var result = false;
1419
1603
  if (_isMgrEnabled(cookieMgr)) {
1420
1604
  var values = {};
1421
- var theValue = strTrim(value || strEmpty);
1605
+ var theValue = strTrim(value || strEmpty$1);
1422
1606
  var idx = theValue.indexOf(";");
1423
1607
  if (idx !== -1) {
1424
1608
  theValue = strTrim(value.substring(0, idx));
@@ -1433,11 +1617,11 @@
1433
1617
  if (expireMs > 0) {
1434
1618
  var expiry = new Date();
1435
1619
  expiry.setTime(expireMs);
1436
- setValue(values, strExpires, _formatDate(expiry, !_isIE ? strToUTCString : strToGMTString) || _formatDate(expiry, _isIE ? strToGMTString : strToUTCString) || strEmpty, isTruthy);
1620
+ setValue(values, strExpires, _formatDate(expiry, !_isIE ? strToUTCString : strToGMTString) || _formatDate(expiry, _isIE ? strToGMTString : strToUTCString) || strEmpty$1, isTruthy);
1437
1621
  }
1438
1622
  }
1439
1623
  if (!_isIE) {
1440
- setValue(values, "max-age", strEmpty + maxAgeSec, null, isUndefined);
1624
+ setValue(values, "max-age", strEmpty$1 + maxAgeSec, null, isUndefined);
1441
1625
  }
1442
1626
  }
1443
1627
  var location_1 = getLocation();
@@ -1458,7 +1642,7 @@
1458
1642
  return result;
1459
1643
  },
1460
1644
  get: function (name) {
1461
- var value = strEmpty;
1645
+ var value = strEmpty$1;
1462
1646
  if (_isMgrEnabled(cookieMgr)) {
1463
1647
  value = (cookieMgrConfig.getCookie || _getCookieValue)(name);
1464
1648
  }
@@ -1483,7 +1667,7 @@
1483
1667
  values["max-age"] = "0";
1484
1668
  }
1485
1669
  var delCookie = cookieMgrConfig.delCookie || _setCookieValue;
1486
- delCookie(name, _formatCookieValue(strEmpty, values));
1670
+ delCookie(name, _formatCookieValue(strEmpty$1, values));
1487
1671
  result = true;
1488
1672
  }
1489
1673
  return result;
@@ -1500,7 +1684,7 @@
1500
1684
  _supportsCookies = doc[strCookie] !== undefined;
1501
1685
  }
1502
1686
  catch (e) {
1503
- logger && logger.throwInternal(LoggingSeverity.WARNING, _InternalMessageId.CannotAccessCookie, "Cannot access document.cookie - " + getExceptionName(e), { exception: dumpObj(e) });
1687
+ logger && logger.throwInternal(2 , 68 , "Cannot access document.cookie - " + getExceptionName(e), { exception: dumpObj(e) });
1504
1688
  }
1505
1689
  }
1506
1690
  return _supportsCookies;
@@ -1510,7 +1694,7 @@
1510
1694
  if (theValue && theValue.length) {
1511
1695
  var parts = strTrim(theValue).split(";");
1512
1696
  arrForEach(parts, function (thePart) {
1513
- thePart = strTrim(thePart || strEmpty);
1697
+ thePart = strTrim(thePart || strEmpty$1);
1514
1698
  if (thePart) {
1515
1699
  var idx = thePart.indexOf("=");
1516
1700
  if (idx === -1) {
@@ -1531,21 +1715,21 @@
1531
1715
  return null;
1532
1716
  }
1533
1717
  function _formatCookieValue(value, values) {
1534
- var cookieValue = value || strEmpty;
1718
+ var cookieValue = value || strEmpty$1;
1535
1719
  objForEachKey(values, function (name, theValue) {
1536
- cookieValue += "; " + name + (!isNullOrUndefined(theValue) ? "=" + theValue : strEmpty);
1720
+ cookieValue += "; " + name + (!isNullOrUndefined(theValue) ? "=" + theValue : strEmpty$1);
1537
1721
  });
1538
1722
  return cookieValue;
1539
1723
  }
1540
1724
  function _getCookieValue(name) {
1541
- var cookieValue = strEmpty;
1725
+ var cookieValue = strEmpty$1;
1542
1726
  if (_doc) {
1543
- var theCookie = _doc[strCookie] || strEmpty;
1727
+ var theCookie = _doc[strCookie] || strEmpty$1;
1544
1728
  if (_parsedCookieValue !== theCookie) {
1545
1729
  _cookieCache = _extractParts(theCookie);
1546
1730
  _parsedCookieValue = theCookie;
1547
1731
  }
1548
- cookieValue = strTrim(_cookieCache[name] || strEmpty);
1732
+ cookieValue = strTrim(_cookieCache[name] || strEmpty$1);
1549
1733
  }
1550
1734
  return cookieValue;
1551
1735
  }
@@ -1581,6 +1765,30 @@
1581
1765
 
1582
1766
  var strExtensionConfig = "extensionConfig";
1583
1767
 
1768
+ function createUnloadHandlerContainer() {
1769
+ var handlers = [];
1770
+ function _addHandler(handler) {
1771
+ if (handler) {
1772
+ handlers.push(handler);
1773
+ }
1774
+ }
1775
+ function _runHandlers(unloadCtx, unloadState) {
1776
+ arrForEach(handlers, function (handler) {
1777
+ try {
1778
+ handler(unloadCtx, unloadState);
1779
+ }
1780
+ catch (e) {
1781
+ unloadCtx.diagLog().throwInternal(2 , 73 , "Unexpected error calling unload handler - " + dumpObj(e));
1782
+ }
1783
+ });
1784
+ handlers = [];
1785
+ }
1786
+ return {
1787
+ add: _addHandler,
1788
+ run: _runHandlers
1789
+ };
1790
+ }
1791
+
1584
1792
  var strGetPlugin = "getPlugin";
1585
1793
  var BaseTelemetryPlugin = /** @class */ (function () {
1586
1794
  function BaseTelemetryPlugin() {
@@ -1588,6 +1796,7 @@
1588
1796
  var _isinitialized;
1589
1797
  var _rootCtx;
1590
1798
  var _nextPlugin;
1799
+ var _unloadHandlerContainer;
1591
1800
  var _hooks;
1592
1801
  _initDefaults();
1593
1802
  dynamicProto(BaseTelemetryPlugin, _self, function (_self) {
@@ -1595,6 +1804,39 @@
1595
1804
  _setDefaults(config, core, pluginChain);
1596
1805
  _isinitialized = true;
1597
1806
  };
1807
+ _self.teardown = function (unloadCtx, unloadState) {
1808
+ if (!_self.core || (unloadCtx && _self.core !== unloadCtx.core())) {
1809
+ return;
1810
+ }
1811
+ var result;
1812
+ var unloadDone = false;
1813
+ var theUnloadCtx = unloadCtx || createProcessTelemetryUnloadContext(null, {}, _self.core, _nextPlugin && _nextPlugin[strGetPlugin] ? _nextPlugin[strGetPlugin]() : _nextPlugin);
1814
+ var theUnloadState = unloadState || {
1815
+ reason: 0 ,
1816
+ isAsync: false
1817
+ };
1818
+ function _unloadCallback() {
1819
+ if (!unloadDone) {
1820
+ unloadDone = true;
1821
+ _unloadHandlerContainer.run(theUnloadCtx, unloadState);
1822
+ arrForEach(_hooks, function (fn) {
1823
+ fn.rm();
1824
+ });
1825
+ _hooks = [];
1826
+ if (result === true) {
1827
+ theUnloadCtx.processNext(theUnloadState);
1828
+ }
1829
+ _initDefaults();
1830
+ }
1831
+ }
1832
+ if (!_self[strDoTeardown] || _self[strDoTeardown](theUnloadCtx, theUnloadState, _unloadCallback) !== true) {
1833
+ _unloadCallback();
1834
+ }
1835
+ else {
1836
+ result = true;
1837
+ }
1838
+ return result;
1839
+ };
1598
1840
  _self._addHook = function (hooks) {
1599
1841
  if (hooks) {
1600
1842
  if (isArray(hooks)) {
@@ -1605,17 +1847,18 @@
1605
1847
  }
1606
1848
  }
1607
1849
  };
1850
+ proxyFunctionAs(_self, "_addUnloadCb", function () { return _unloadHandlerContainer; }, "add");
1608
1851
  });
1609
1852
  _self.diagLog = function (itemCtx) {
1610
1853
  return _getTelCtx(itemCtx).diagLog();
1611
1854
  };
1612
- _self.isInitialized = function () {
1855
+ _self[strIsInitialized] = function () {
1613
1856
  return _isinitialized;
1614
1857
  };
1615
1858
  _self.setInitialized = function (isInitialized) {
1616
1859
  _isinitialized = isInitialized;
1617
1860
  };
1618
- _self.setNextPlugin = function (next) {
1861
+ _self[strSetNextPlugin] = function (next) {
1619
1862
  _nextPlugin = next;
1620
1863
  };
1621
1864
  _self.processNext = function (env, itemCtx) {
@@ -1661,65 +1904,15 @@
1661
1904
  _rootCtx = null;
1662
1905
  _nextPlugin = null;
1663
1906
  _hooks = [];
1907
+ _unloadHandlerContainer = createUnloadHandlerContainer();
1664
1908
  }
1665
1909
  }
1666
1910
  return BaseTelemetryPlugin;
1667
1911
  }());
1668
1912
 
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
1913
  function generateW3CId() {
1721
1914
  var hexValues = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f"];
1722
- var oct = "", tmp;
1915
+ var oct = strEmpty$1, tmp;
1723
1916
  for (var a = 0; a < 4; a++) {
1724
1917
  tmp = random32();
1725
1918
  oct +=
@@ -1736,6 +1929,95 @@
1736
1929
  return oct.substr(0, 8) + oct.substr(9, 4) + "4" + oct.substr(13, 3) + clockSequenceHi + oct.substr(16, 3) + oct.substr(19, 12);
1737
1930
  }
1738
1931
 
1932
+ var LoggingSeverity = createEnumStyle({
1933
+ CRITICAL: 1 ,
1934
+ WARNING: 2
1935
+ });
1936
+ var _InternalMessageId = createEnumStyle({
1937
+ BrowserDoesNotSupportLocalStorage: 0 ,
1938
+ BrowserCannotReadLocalStorage: 1 ,
1939
+ BrowserCannotReadSessionStorage: 2 ,
1940
+ BrowserCannotWriteLocalStorage: 3 ,
1941
+ BrowserCannotWriteSessionStorage: 4 ,
1942
+ BrowserFailedRemovalFromLocalStorage: 5 ,
1943
+ BrowserFailedRemovalFromSessionStorage: 6 ,
1944
+ CannotSendEmptyTelemetry: 7 ,
1945
+ ClientPerformanceMathError: 8 ,
1946
+ ErrorParsingAISessionCookie: 9 ,
1947
+ ErrorPVCalc: 10 ,
1948
+ ExceptionWhileLoggingError: 11 ,
1949
+ FailedAddingTelemetryToBuffer: 12 ,
1950
+ FailedMonitorAjaxAbort: 13 ,
1951
+ FailedMonitorAjaxDur: 14 ,
1952
+ FailedMonitorAjaxOpen: 15 ,
1953
+ FailedMonitorAjaxRSC: 16 ,
1954
+ FailedMonitorAjaxSend: 17 ,
1955
+ FailedMonitorAjaxGetCorrelationHeader: 18 ,
1956
+ FailedToAddHandlerForOnBeforeUnload: 19 ,
1957
+ FailedToSendQueuedTelemetry: 20 ,
1958
+ FailedToReportDataLoss: 21 ,
1959
+ FlushFailed: 22 ,
1960
+ MessageLimitPerPVExceeded: 23 ,
1961
+ MissingRequiredFieldSpecification: 24 ,
1962
+ NavigationTimingNotSupported: 25 ,
1963
+ OnError: 26 ,
1964
+ SessionRenewalDateIsZero: 27 ,
1965
+ SenderNotInitialized: 28 ,
1966
+ StartTrackEventFailed: 29 ,
1967
+ StopTrackEventFailed: 30 ,
1968
+ StartTrackFailed: 31 ,
1969
+ StopTrackFailed: 32 ,
1970
+ TelemetrySampledAndNotSent: 33 ,
1971
+ TrackEventFailed: 34 ,
1972
+ TrackExceptionFailed: 35 ,
1973
+ TrackMetricFailed: 36 ,
1974
+ TrackPVFailed: 37 ,
1975
+ TrackPVFailedCalc: 38 ,
1976
+ TrackTraceFailed: 39 ,
1977
+ TransmissionFailed: 40 ,
1978
+ FailedToSetStorageBuffer: 41 ,
1979
+ FailedToRestoreStorageBuffer: 42 ,
1980
+ InvalidBackendResponse: 43 ,
1981
+ FailedToFixDepricatedValues: 44 ,
1982
+ InvalidDurationValue: 45 ,
1983
+ TelemetryEnvelopeInvalid: 46 ,
1984
+ CreateEnvelopeError: 47 ,
1985
+ CannotSerializeObject: 48 ,
1986
+ CannotSerializeObjectNonSerializable: 49 ,
1987
+ CircularReferenceDetected: 50 ,
1988
+ ClearAuthContextFailed: 51 ,
1989
+ ExceptionTruncated: 52 ,
1990
+ IllegalCharsInName: 53 ,
1991
+ ItemNotInArray: 54 ,
1992
+ MaxAjaxPerPVExceeded: 55 ,
1993
+ MessageTruncated: 56 ,
1994
+ NameTooLong: 57 ,
1995
+ SampleRateOutOfRange: 58 ,
1996
+ SetAuthContextFailed: 59 ,
1997
+ SetAuthContextFailedAccountName: 60 ,
1998
+ StringValueTooLong: 61 ,
1999
+ StartCalledMoreThanOnce: 62 ,
2000
+ StopCalledWithoutStart: 63 ,
2001
+ TelemetryInitializerFailed: 64 ,
2002
+ TrackArgumentsNotSpecified: 65 ,
2003
+ UrlTooLong: 66 ,
2004
+ SessionStorageBufferFull: 67 ,
2005
+ CannotAccessCookie: 68 ,
2006
+ IdTooLong: 69 ,
2007
+ InvalidEvent: 70 ,
2008
+ FailedMonitorAjaxSetRequestHeader: 71 ,
2009
+ SendBrowserInfoOnUserInit: 72 ,
2010
+ PluginException: 73 ,
2011
+ NotificationException: 74 ,
2012
+ SnippetScriptLoadFailure: 99 ,
2013
+ InvalidInstrumentationKey: 100 ,
2014
+ CannotParseAiBlobValue: 101 ,
2015
+ InvalidContentBlob: 102 ,
2016
+ TrackPageActionEventFailed: 103 ,
2017
+ FailedAddingCustomDefinedRequestContext: 104 ,
2018
+ InMemoryStorageBufferFull: 105
2019
+ });
2020
+
1739
2021
  function dataSanitizeKeyAndAddUniqueness(logger, key, map) {
1740
2022
  var origLength = key.length;
1741
2023
  var field = dataSanitizeKey(logger, key);
@@ -1756,7 +2038,7 @@
1756
2038
  name = strTrim(name.toString());
1757
2039
  if (name.length > 150 ) {
1758
2040
  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);
2041
+ logger && logger.throwInternal(2 , _InternalMessageId.NameTooLong, "name is too long. It has been truncated to " + 150 + " characters.", { name: name }, true);
1760
2042
  }
1761
2043
  }
1762
2044
  return nameTrunc || name;
@@ -1769,7 +2051,7 @@
1769
2051
  value = strTrim(value);
1770
2052
  if (value.toString().length > maxLength) {
1771
2053
  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);
2054
+ logger && logger.throwInternal(2 , _InternalMessageId.StringValueTooLong, "string value is too long. It has been truncated to " + maxLength + " characters.", { value: value }, true);
1773
2055
  }
1774
2056
  }
1775
2057
  return valueTrunc || value;
@@ -1782,7 +2064,7 @@
1782
2064
  if (message) {
1783
2065
  if (message.length > 32768 ) {
1784
2066
  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);
2067
+ logger && logger.throwInternal(2 , _InternalMessageId.MessageTruncated, "message is too long, it has been truncated to " + 32768 + " characters.", { message: message }, true);
1786
2068
  }
1787
2069
  }
1788
2070
  return messageTrunc || message;
@@ -1793,7 +2075,7 @@
1793
2075
  var value = "" + exception;
1794
2076
  if (value.length > 32768 ) {
1795
2077
  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);
2078
+ logger && logger.throwInternal(2 , _InternalMessageId.ExceptionTruncated, "exception is too long, it has been truncated to " + 32768 + " characters.", { exception: exception }, true);
1797
2079
  }
1798
2080
  }
1799
2081
  return exceptionTrunc || exception;
@@ -1807,7 +2089,7 @@
1807
2089
  value = getJSON().stringify(value);
1808
2090
  }
1809
2091
  catch (e) {
1810
- logger && logger.throwInternal(LoggingSeverity.WARNING, _InternalMessageId.CannotSerializeObjectNonSerializable, "custom property is not valid", { exception: e }, true);
2092
+ logger && logger.throwInternal(2 , _InternalMessageId.CannotSerializeObjectNonSerializable, "custom property is not valid", { exception: e }, true);
1811
2093
  }
1812
2094
  }
1813
2095
  value = dataSanitizeString(logger, value, 8192 );
@@ -1838,7 +2120,7 @@
1838
2120
  input = strTrim(input);
1839
2121
  if (input.length > maxLength) {
1840
2122
  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);
2123
+ logger && logger.throwInternal(2 , _msgId, "input is too long, it has been truncated to " + maxLength + " characters.", { data: input }, true);
1842
2124
  }
1843
2125
  }
1844
2126
  return inputTrunc || input;
@@ -1863,6 +2145,7 @@
1863
2145
  return event;
1864
2146
  }
1865
2147
 
2148
+ var strEmpty = "";
1866
2149
  function stringToBoolOrDefault(str, defaultValue) {
1867
2150
  if (defaultValue === void 0) { defaultValue = false; }
1868
2151
  if (str === undefined || str === null) {
@@ -1875,16 +2158,16 @@
1875
2158
  totalms = 0;
1876
2159
  }
1877
2160
  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;
2161
+ var ms = strEmpty + totalms % 1000;
2162
+ var sec = strEmpty + Math.floor(totalms / 1000) % 60;
2163
+ var min = strEmpty + Math.floor(totalms / (1000 * 60)) % 60;
2164
+ var hour = strEmpty + Math.floor(totalms / (1000 * 60 * 60)) % 24;
1882
2165
  var days = Math.floor(totalms / (1000 * 60 * 60 * 24));
1883
2166
  ms = ms.length === 1 ? "00" + ms : ms.length === 2 ? "0" + ms : ms;
1884
2167
  sec = sec.length < 2 ? "0" + sec : sec;
1885
2168
  min = min.length < 2 ? "0" + min : min;
1886
2169
  hour = hour.length < 2 ? "0" + hour : hour;
1887
- return (days > 0 ? days + "." : "") + hour + ":" + min + ":" + sec + "." + ms;
2170
+ return (days > 0 ? days + "." : strEmpty) + hour + ":" + min + ":" + sec + "." + ms;
1888
2171
  }
1889
2172
  function isCrossOriginError(message, url, lineNumber, columnNumber, error) {
1890
2173
  return !error && isString(message) && (message === "Script error." || message === "Script error");
@@ -1893,17 +2176,15 @@
1893
2176
  var strNotSpecified = "not_specified";
1894
2177
  var strIkey = "iKey";
1895
2178
 
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 = {}));
2179
+ var StorageType = createEnumStyle({
2180
+ LocalStorage: 0 ,
2181
+ SessionStorage: 1
2182
+ });
2183
+ createEnumStyle({
2184
+ AI: 0 ,
2185
+ AI_AND_W3C: 1 ,
2186
+ W3C: 2
2187
+ });
1907
2188
 
1908
2189
  var _canUseSessionStorage = undefined;
1909
2190
  function _getVerifiedStorageObject(storageType) {
@@ -1947,7 +2228,7 @@
1947
2228
  }
1948
2229
  catch (e) {
1949
2230
  _canUseSessionStorage = false;
1950
- logger.throwInternal(LoggingSeverity.WARNING, _InternalMessageId.BrowserCannotReadSessionStorage, "Browser failed read of session storage. " + getExceptionName(e), { exception: dumpObj(e) });
2231
+ logger.throwInternal(2 , _InternalMessageId.BrowserCannotReadSessionStorage, "Browser failed read of session storage. " + getExceptionName(e), { exception: dumpObj(e) });
1951
2232
  }
1952
2233
  }
1953
2234
  return null;
@@ -1961,7 +2242,7 @@
1961
2242
  }
1962
2243
  catch (e) {
1963
2244
  _canUseSessionStorage = false;
1964
- logger.throwInternal(LoggingSeverity.WARNING, _InternalMessageId.BrowserCannotWriteSessionStorage, "Browser failed write to session storage. " + getExceptionName(e), { exception: dumpObj(e) });
2245
+ logger.throwInternal(2 , _InternalMessageId.BrowserCannotWriteSessionStorage, "Browser failed write to session storage. " + getExceptionName(e), { exception: dumpObj(e) });
1965
2246
  }
1966
2247
  }
1967
2248
  return false;
@@ -1975,7 +2256,7 @@
1975
2256
  }
1976
2257
  catch (e) {
1977
2258
  _canUseSessionStorage = false;
1978
- logger.throwInternal(LoggingSeverity.WARNING, _InternalMessageId.BrowserFailedRemovalFromSessionStorage, "Browser failed removal of session storage item. " + getExceptionName(e), { exception: dumpObj(e) });
2259
+ logger.throwInternal(2 , _InternalMessageId.BrowserFailedRemovalFromSessionStorage, "Browser failed removal of session storage item. " + getExceptionName(e), { exception: dumpObj(e) });
1979
2260
  }
1980
2261
  }
1981
2262
  return false;
@@ -3622,7 +3903,7 @@
3622
3903
  config.disableFlushOnUnload = stringToBoolOrDefault(config.disableFlushOnUnload, config.disableFlushOnBeforeUnload);
3623
3904
  return config;
3624
3905
  };
3625
- ApplicationInsights.Version = "2.8.0-beta.2202-07";
3906
+ ApplicationInsights.Version = "2.8.0-beta.2203-03";
3626
3907
  return ApplicationInsights;
3627
3908
  }(BaseTelemetryPlugin));
3628
3909
  var Timing = /** @class */ (function () {