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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * Application Insights JavaScript SDK - Channel, 2.8.0-beta.2203-01
2
+ * Application Insights JavaScript SDK - Channel, 2.8.0-beta.2203-04
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  */
5
5
  (function (global, factory) {
@@ -335,99 +335,14 @@
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
- var strOnPrefix = "on";
429
- var strAttachEvent = "attachEvent";
430
- var strAddEventHelper = "addEventListener";
431
346
  var strToISOString = "toISOString";
432
347
  var strIndexOf = "indexOf";
433
348
  var strMap = "map";
@@ -435,7 +350,7 @@
435
350
  var strToString = "toString";
436
351
  var str__Proto = "__proto__";
437
352
  var strConstructor = "constructor";
438
- var _objDefineProperty = ObjDefineProperty;
353
+ var _objDefineProperty$1 = ObjDefineProperty;
439
354
  var _objFreeze = ObjClass.freeze;
440
355
  var _objKeys = ObjClass.keys;
441
356
  var StringProto = String[strShimPrototype];
@@ -446,6 +361,9 @@
446
361
  var _objToString = ObjProto[strToString];
447
362
  var _fnToString = ObjHasOwnProperty[strToString];
448
363
  var _objFunctionString = _fnToString.call(ObjClass);
364
+ var rCamelCase = /-([a-z])/g;
365
+ var rNormalizeInvalid = /([^\w\d_$])/g;
366
+ var rLeadingNumeric = /^(\d+[\w\d_$])/;
449
367
  var _objGetPrototypeOf = Object["getPrototypeOf"];
450
368
  function _getObjProto(target) {
451
369
  if (target) {
@@ -471,24 +389,18 @@
471
389
  function isFunction(value) {
472
390
  return !!(value && typeof value === strShimFunction);
473
391
  }
474
- function attachEvent(obj, eventNameWithoutOn, handlerRef, useCapture) {
475
- if (useCapture === void 0) { useCapture = false; }
476
- var result = false;
477
- if (!isNullOrUndefined(obj)) {
478
- try {
479
- if (!isNullOrUndefined(obj[strAddEventHelper])) {
480
- obj[strAddEventHelper](eventNameWithoutOn, handlerRef, useCapture);
481
- result = true;
482
- }
483
- else if (!isNullOrUndefined(obj[strAttachEvent])) {
484
- obj[strAttachEvent](strOnPrefix + eventNameWithoutOn, handlerRef);
485
- result = true;
486
- }
487
- }
488
- catch (e) {
489
- }
392
+ function normalizeJsName(name) {
393
+ var value = name;
394
+ if (value && isString(value)) {
395
+ value = value.replace(rCamelCase, function (_all, letter) {
396
+ return letter.toUpperCase();
397
+ });
398
+ value = value.replace(rNormalizeInvalid, "_");
399
+ value = value.replace(rLeadingNumeric, function (_all, match) {
400
+ return "_" + match;
401
+ });
490
402
  }
491
- return result;
403
+ return value;
492
404
  }
493
405
  function objForEachKey(target, callbackfn) {
494
406
  if (target) {
@@ -656,7 +568,7 @@
656
568
  return result;
657
569
  }
658
570
  function objDefineAccessors(target, prop, getProp, setProp) {
659
- if (_objDefineProperty) {
571
+ if (_objDefineProperty$1) {
660
572
  try {
661
573
  var descriptor = {
662
574
  enumerable: true,
@@ -668,7 +580,7 @@
668
580
  if (setProp) {
669
581
  descriptor.set = setProp;
670
582
  }
671
- _objDefineProperty(target, prop, descriptor);
583
+ _objDefineProperty$1(target, prop, descriptor);
672
584
  return true;
673
585
  }
674
586
  catch (e) {
@@ -688,7 +600,7 @@
688
600
  if (isError(object)) {
689
601
  return object.name;
690
602
  }
691
- return "";
603
+ return strEmpty$1;
692
604
  }
693
605
  function setValue(target, field, value, valChk, srcChk) {
694
606
  var theValue = value;
@@ -707,6 +619,33 @@
707
619
  function throwError(message) {
708
620
  throw new Error(message);
709
621
  }
622
+ function _createProxyFunction(source, funcName) {
623
+ var srcFunc = null;
624
+ var src = null;
625
+ if (isFunction(source)) {
626
+ srcFunc = source;
627
+ }
628
+ else {
629
+ src = source;
630
+ }
631
+ return function () {
632
+ var originalArguments = arguments;
633
+ if (srcFunc) {
634
+ src = srcFunc();
635
+ }
636
+ if (src) {
637
+ return src[funcName].apply(src, originalArguments);
638
+ }
639
+ };
640
+ }
641
+ function proxyFunctionAs(target, name, source, theFunc, overwriteTarget) {
642
+ if (overwriteTarget === void 0) { overwriteTarget = true; }
643
+ if (target && name && source) {
644
+ if (overwriteTarget || isUndefined(target[name])) {
645
+ target[name] = _createProxyFunction(source, theFunc);
646
+ }
647
+ }
648
+ }
710
649
  function createClassFromInterface(defaults) {
711
650
  return /** @class */ (function () {
712
651
  function class_1() {
@@ -720,6 +659,17 @@
720
659
  return class_1;
721
660
  }());
722
661
  }
662
+ function createEnumStyle(values) {
663
+ var enumClass = {};
664
+ objForEachKey(values, function (field, value) {
665
+ enumClass[field] = value;
666
+ if (!isUndefined(enumClass[value])) {
667
+ throwError("[" + value + "] exists for " + field);
668
+ }
669
+ enumClass[value] = field;
670
+ });
671
+ return objFreeze(enumClass);
672
+ }
723
673
  function optimizeObject(theObject) {
724
674
  if (theObject && ObjAssign) {
725
675
  theObject = ObjClass(ObjAssign({}, theObject));
@@ -777,9 +727,13 @@
777
727
  var strNavigator = "navigator";
778
728
  var strConsole = "console";
779
729
  var strJSON = "JSON";
730
+ var strCrypto = "crypto";
731
+ var strMsCrypto = "msCrypto";
780
732
  var strMsie = "msie";
781
733
  var strTrident = "trident/";
782
734
  var strXMLHttpRequest = "XMLHttpRequest";
735
+ var _isTrident = null;
736
+ var _navUserAgentCheck = null;
783
737
  var _useXDomainRequest = null;
784
738
  var _beaconsSupported = null;
785
739
  function _hasProperty(theClass, property) {
@@ -859,13 +813,28 @@
859
813
  }
860
814
  return null;
861
815
  }
816
+ function getCrypto() {
817
+ return getGlobalInst(strCrypto);
818
+ }
819
+ function getMsCrypto() {
820
+ return getGlobalInst(strMsCrypto);
821
+ }
822
+ function isIE() {
823
+ var nav = getNavigator();
824
+ if (nav && (nav.userAgent !== _navUserAgentCheck || _isTrident === null)) {
825
+ _navUserAgentCheck = nav.userAgent;
826
+ var userAgent = (_navUserAgentCheck || strEmpty$1).toLowerCase();
827
+ _isTrident = (strContains(userAgent, strMsie) || strContains(userAgent, strTrident));
828
+ }
829
+ return _isTrident;
830
+ }
862
831
  function getIEVersion(userAgentStr) {
863
832
  if (userAgentStr === void 0) { userAgentStr = null; }
864
833
  if (!userAgentStr) {
865
834
  var navigator_1 = getNavigator() || {};
866
- userAgentStr = navigator_1 ? (navigator_1.userAgent || "").toLowerCase() : "";
835
+ userAgentStr = navigator_1 ? (navigator_1.userAgent || strEmpty$1).toLowerCase() : strEmpty$1;
867
836
  }
868
- var ua = (userAgentStr || "").toLowerCase();
837
+ var ua = (userAgentStr || strEmpty$1).toLowerCase();
869
838
  if (strContains(ua, strMsie)) {
870
839
  var doc = getDocument() || {};
871
840
  return Math.max(parseInt(ua.split(strMsie)[1]), (doc[strDocumentMode] || 0));
@@ -880,7 +849,7 @@
880
849
  }
881
850
  function dumpObj(object) {
882
851
  var objectTypeDump = Object[strShimPrototype].toString.call(object);
883
- var propertyValueDump = "";
852
+ var propertyValueDump = strEmpty$1;
884
853
  if (objectTypeDump === "[object Error]") {
885
854
  propertyValueDump = "{ stack: '" + object.stack + "', message: '" + object.message + "', name: '" + object.name + "'";
886
855
  }
@@ -951,9 +920,9 @@
951
920
  var strWarnToConsole = "warnToConsole";
952
921
  function _sanitizeDiagnosticText(text) {
953
922
  if (text) {
954
- return "\"" + text.replace(/\"/g, "") + "\"";
923
+ return "\"" + text.replace(/\"/g, strEmpty$1) + "\"";
955
924
  }
956
- return "";
925
+ return strEmpty$1;
957
926
  }
958
927
  function _logToConsole(func, message) {
959
928
  var theConsole = getConsole();
@@ -975,12 +944,12 @@
975
944
  _self.message =
976
945
  (isUserAct ? AiUserActionablePrefix : AiNonUserActionablePrefix) +
977
946
  msgId;
978
- var strProps = "";
947
+ var strProps = strEmpty$1;
979
948
  if (hasJSON()) {
980
949
  strProps = getJSON().stringify(properties);
981
950
  }
982
- var diagnosticText = (msg ? " message:" + _sanitizeDiagnosticText(msg) : "") +
983
- (properties ? " props:" + _sanitizeDiagnosticText(strProps) : "");
951
+ var diagnosticText = (msg ? " message:" + _sanitizeDiagnosticText(msg) : strEmpty$1) +
952
+ (properties ? " props:" + _sanitizeDiagnosticText(strProps) : strEmpty$1);
984
953
  _self.message += diagnosticText;
985
954
  }
986
955
  _InternalLogMessage.dataType = "MessageData";
@@ -1010,7 +979,7 @@
1010
979
  throw message;
1011
980
  }
1012
981
  else {
1013
- var logFunc = severity === LoggingSeverity.CRITICAL ? strErrorToConsole : strWarnToConsole;
982
+ var logFunc = severity === 1 ? strErrorToConsole : strWarnToConsole;
1014
983
  if (!isUndefined(message.message)) {
1015
984
  var logLevel = _self.consoleLoggingLevel();
1016
985
  if (isUserAct) {
@@ -1028,7 +997,7 @@
1028
997
  _self.logInternalMessage(severity, message);
1029
998
  }
1030
999
  else {
1031
- _debugExtMsg("throw" + (severity === LoggingSeverity.CRITICAL ? "Critical" : "Warning"), message);
1000
+ _debugExtMsg("throw" + (severity === 1 ? "Critical" : "Warning"), message);
1032
1001
  }
1033
1002
  }
1034
1003
  };
@@ -1060,13 +1029,13 @@
1060
1029
  if (severity <= _self.telemetryLoggingLevel()) {
1061
1030
  _self.queue.push(message);
1062
1031
  _messageCount++;
1063
- _debugExtMsg((severity === LoggingSeverity.CRITICAL ? "error" : "warn"), message);
1032
+ _debugExtMsg((severity === 1 ? "error" : "warn"), message);
1064
1033
  }
1065
1034
  if (_messageCount === _self.maxInternalMessageLimit()) {
1066
1035
  var throttleLimitMessage = "Internal events throttle limit per PageView reached for this app.";
1067
- var throttleMessage = new _InternalLogMessage(_InternalMessageId.MessageLimitPerPVExceeded, throttleLimitMessage, false);
1036
+ var throttleMessage = new _InternalLogMessage(23 , throttleLimitMessage, false);
1068
1037
  _self.queue.push(throttleMessage);
1069
- if (severity === LoggingSeverity.CRITICAL) {
1038
+ if (severity === 1 ) {
1070
1039
  _self.errorToConsole(throttleLimitMessage);
1071
1040
  }
1072
1041
  else {
@@ -1208,6 +1177,151 @@
1208
1177
  return func();
1209
1178
  }
1210
1179
 
1180
+ var UInt32Mask = 0x100000000;
1181
+ var MaxUInt32 = 0xffffffff;
1182
+ var _mwcSeeded = false;
1183
+ var _mwcW = 123456789;
1184
+ var _mwcZ = 987654321;
1185
+ function _mwcSeed(seedValue) {
1186
+ if (seedValue < 0) {
1187
+ seedValue >>>= 0;
1188
+ }
1189
+ _mwcW = (123456789 + seedValue) & MaxUInt32;
1190
+ _mwcZ = (987654321 - seedValue) & MaxUInt32;
1191
+ _mwcSeeded = true;
1192
+ }
1193
+ function _autoSeedMwc() {
1194
+ try {
1195
+ var now = dateNow() & 0x7fffffff;
1196
+ _mwcSeed(((Math.random() * UInt32Mask) ^ now) + now);
1197
+ }
1198
+ catch (e) {
1199
+ }
1200
+ }
1201
+ function random32(signed) {
1202
+ var value = 0;
1203
+ var c = getCrypto() || getMsCrypto();
1204
+ if (c && c.getRandomValues) {
1205
+ value = c.getRandomValues(new Uint32Array(1))[0] & MaxUInt32;
1206
+ }
1207
+ if (value === 0 && isIE()) {
1208
+ if (!_mwcSeeded) {
1209
+ _autoSeedMwc();
1210
+ }
1211
+ value = mwcRandom32() & MaxUInt32;
1212
+ }
1213
+ if (value === 0) {
1214
+ value = Math.floor((UInt32Mask * Math.random()) | 0);
1215
+ }
1216
+ if (!signed) {
1217
+ value >>>= 0;
1218
+ }
1219
+ return value;
1220
+ }
1221
+ function mwcRandom32(signed) {
1222
+ _mwcZ = (36969 * (_mwcZ & 0xFFFF) + (_mwcZ >> 16)) & MaxUInt32;
1223
+ _mwcW = (18000 * (_mwcW & 0xFFFF) + (_mwcW >> 16)) & MaxUInt32;
1224
+ var value = (((_mwcZ << 16) + (_mwcW & 0xFFFF)) >>> 0) & MaxUInt32 | 0;
1225
+ if (!signed) {
1226
+ value >>>= 0;
1227
+ }
1228
+ return value;
1229
+ }
1230
+ function newId(maxLength) {
1231
+ if (maxLength === void 0) { maxLength = 22; }
1232
+ var base64chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
1233
+ var number = random32() >>> 0;
1234
+ var chars = 0;
1235
+ var result = strEmpty$1;
1236
+ while (result.length < maxLength) {
1237
+ chars++;
1238
+ result += base64chars.charAt(number & 0x3F);
1239
+ number >>>= 6;
1240
+ if (chars === 5) {
1241
+ number = (((random32() << 2) & 0xFFFFFFFF) | (number & 0x03)) >>> 0;
1242
+ chars = 0;
1243
+ }
1244
+ }
1245
+ return result;
1246
+ }
1247
+
1248
+ var _objDefineProperty = ObjDefineProperty;
1249
+ var version = "2.7.3";
1250
+ var instanceName = "." + newId(6);
1251
+ var _dataUid = 0;
1252
+ function _createAccessor(target, prop, value) {
1253
+ if (_objDefineProperty) {
1254
+ try {
1255
+ _objDefineProperty(target, prop, {
1256
+ value: value,
1257
+ enumerable: false,
1258
+ configurable: true
1259
+ });
1260
+ return true;
1261
+ }
1262
+ catch (e) {
1263
+ }
1264
+ }
1265
+ return false;
1266
+ }
1267
+ function _canAcceptData(target) {
1268
+ return target.nodeType === 1 || target.nodeType === 9 || !(+target.nodeType);
1269
+ }
1270
+ function _getCache(data, target) {
1271
+ var theCache = target[data.id];
1272
+ if (!theCache) {
1273
+ theCache = {};
1274
+ try {
1275
+ if (_canAcceptData(target)) {
1276
+ if (!_createAccessor(target, data.id, theCache)) {
1277
+ target[data.id] = theCache;
1278
+ }
1279
+ }
1280
+ }
1281
+ catch (e) {
1282
+ }
1283
+ }
1284
+ return theCache;
1285
+ }
1286
+ function createUniqueNamespace(name, includeVersion) {
1287
+ if (includeVersion === void 0) { includeVersion = false; }
1288
+ return normalizeJsName(name + (_dataUid++) + (includeVersion ? "." + version : "") + instanceName);
1289
+ }
1290
+ function createElmNodeData(name) {
1291
+ var data = {
1292
+ id: createUniqueNamespace("_aiData-" + (name || "") + "." + version),
1293
+ accept: function (target) {
1294
+ return _canAcceptData(target);
1295
+ },
1296
+ get: function (target, name, defValue, addDefault) {
1297
+ var theCache = target[data.id];
1298
+ if (!theCache) {
1299
+ if (addDefault) {
1300
+ theCache = _getCache(data, target);
1301
+ theCache[normalizeJsName(name)] = defValue;
1302
+ }
1303
+ return defValue;
1304
+ }
1305
+ return theCache[normalizeJsName(name)];
1306
+ },
1307
+ kill: function (target, name) {
1308
+ if (target && target[name]) {
1309
+ try {
1310
+ delete target[name];
1311
+ }
1312
+ catch (e) {
1313
+ }
1314
+ }
1315
+ }
1316
+ };
1317
+ return data;
1318
+ }
1319
+
1320
+ var pluginStateData = createElmNodeData("plugin");
1321
+ function _getPluginState(plugin) {
1322
+ return pluginStateData.get(plugin, "state", {}, true);
1323
+ }
1324
+
1211
1325
  var strTelemetryPluginChain = "TelemetryPluginChain";
1212
1326
  var strHasRunFlags = "_hasRun";
1213
1327
  var strGetTelCtx = "_getTelCtx";
@@ -1221,53 +1335,69 @@
1221
1335
  }
1222
1336
  return createTelemetryProxyChain([startAt], config, core);
1223
1337
  }
1224
- function createProcessTelemetryContext(telemetryChain, config, core, startAt) {
1338
+ function _createInternalContext(telemetryChain, config, core, startAt) {
1225
1339
  var _nextProxy = null;
1226
- var _onComplete = null;
1227
- if (startAt) {
1228
- _nextProxy = _getNextProxyStart(telemetryChain, config, core, startAt);
1229
- }
1230
- else {
1231
- _nextProxy = telemetryChain;
1340
+ var _onComplete = [];
1341
+ if (startAt !== null) {
1342
+ _nextProxy = startAt ? _getNextProxyStart(telemetryChain, config, core, startAt) : telemetryChain;
1232
1343
  }
1233
1344
  var context = {
1234
- core: function () {
1235
- return core;
1236
- },
1237
- diagLog: function () {
1238
- return safeGetLogger(core, config);
1239
- },
1240
- getCfg: function () {
1241
- return config;
1242
- },
1243
- getExtCfg: _getExtCfg,
1244
- getConfig: _getConfig,
1245
- hasNext: function () {
1246
- return _nextProxy != null;
1247
- },
1248
- getNext: function () {
1249
- return _nextProxy;
1250
- },
1251
- setNext: function (nextPlugin) {
1252
- _nextProxy = nextPlugin;
1253
- },
1254
- processNext: function (env) {
1255
- _processChain(function (nextPlugin) {
1256
- nextPlugin.processTelemetry(env, context);
1345
+ _next: _moveNext,
1346
+ ctx: {
1347
+ core: function () { return core; },
1348
+ diagLog: function () {
1349
+ return safeGetLogger(core, config);
1350
+ },
1351
+ getCfg: function () {
1352
+ return config;
1353
+ },
1354
+ getExtCfg: _getExtCfg,
1355
+ getConfig: _getConfig,
1356
+ hasNext: function () {
1357
+ return !!_nextProxy;
1358
+ },
1359
+ getNext: function () {
1360
+ return _nextProxy;
1361
+ },
1362
+ setNext: function (nextPlugin) {
1363
+ _nextProxy = nextPlugin;
1364
+ },
1365
+ iterate: _iterateChain,
1366
+ onComplete: _addOnComplete
1367
+ }
1368
+ };
1369
+ function _addOnComplete(onComplete, that) {
1370
+ var args = [];
1371
+ for (var _i = 2; _i < arguments.length; _i++) {
1372
+ args[_i - 2] = arguments[_i];
1373
+ }
1374
+ if (onComplete) {
1375
+ _onComplete.push({
1376
+ func: onComplete,
1377
+ self: !isUndefined(that) ? that : context.ctx,
1378
+ args: args
1257
1379
  });
1258
- },
1259
- iterate: _iterateChain,
1260
- createNew: function (plugins, startAt) {
1261
- if (plugins === void 0) { plugins = null; }
1262
- if (isArray(plugins)) {
1263
- plugins = createTelemetryProxyChain(plugins, config, core, startAt);
1380
+ }
1381
+ }
1382
+ function _moveNext() {
1383
+ var nextProxy = _nextProxy;
1384
+ _nextProxy = nextProxy ? nextProxy.getNext() : null;
1385
+ if (!nextProxy) {
1386
+ var onComplete = _onComplete;
1387
+ if (onComplete && onComplete.length > 0) {
1388
+ arrForEach(onComplete, function (completeDetails) {
1389
+ try {
1390
+ completeDetails.func.call(completeDetails.self, completeDetails.args);
1391
+ }
1392
+ catch (e) {
1393
+ core.logger.throwInternal(2 , 73 , "Unexpected Exception during onComplete - " + dumpObj(e));
1394
+ }
1395
+ });
1396
+ _onComplete = [];
1264
1397
  }
1265
- return createProcessTelemetryContext(plugins || _nextProxy, config, core, startAt);
1266
- },
1267
- onComplete: function (onComplete) {
1268
- _onComplete = onComplete;
1269
1398
  }
1270
- };
1399
+ return nextProxy;
1400
+ }
1271
1401
  function _getExtCfg(identifier, defaultValue, mergeDefault) {
1272
1402
  if (defaultValue === void 0) { defaultValue = {}; }
1273
1403
  if (mergeDefault === void 0) { mergeDefault = 0 ; }
@@ -1310,29 +1440,53 @@
1310
1440
  }
1311
1441
  return !isNullOrUndefined(theValue) ? theValue : defaultValue;
1312
1442
  }
1313
- function _processChain(cb) {
1314
- var nextPlugin = _nextProxy;
1315
- if (nextPlugin) {
1316
- _nextProxy = nextPlugin.getNext();
1317
- cb(nextPlugin);
1318
- }
1319
- else {
1320
- if (_onComplete) {
1321
- _onComplete();
1322
- _onComplete = null;
1443
+ function _iterateChain(cb) {
1444
+ var nextPlugin;
1445
+ while (!!(nextPlugin = context._next())) {
1446
+ var plugin = nextPlugin.getPlugin();
1447
+ if (plugin) {
1448
+ cb(plugin);
1323
1449
  }
1324
1450
  }
1325
1451
  }
1326
- function _iterateChain(cb) {
1327
- while (_nextProxy) {
1328
- _processChain(function (nextPlugin) {
1329
- var plugin = nextPlugin.getPlugin();
1330
- if (plugin) {
1331
- cb(plugin);
1332
- }
1333
- });
1452
+ return context;
1453
+ }
1454
+ function createProcessTelemetryContext(telemetryChain, config, core, startAt) {
1455
+ var internalContext = _createInternalContext(telemetryChain, config, core, startAt);
1456
+ var context = internalContext.ctx;
1457
+ function _processNext(env) {
1458
+ var nextPlugin = internalContext._next();
1459
+ nextPlugin && nextPlugin.processTelemetry(env, context);
1460
+ return !nextPlugin;
1461
+ }
1462
+ function _createNew(plugins, startAt) {
1463
+ if (plugins === void 0) { plugins = null; }
1464
+ if (isArray(plugins)) {
1465
+ plugins = createTelemetryProxyChain(plugins, config, core, startAt);
1466
+ }
1467
+ return createProcessTelemetryContext(plugins || context.getNext(), config, core, startAt);
1468
+ }
1469
+ context.processNext = _processNext;
1470
+ context.createNew = _createNew;
1471
+ return context;
1472
+ }
1473
+ function createProcessTelemetryUnloadContext(telemetryChain, config, core, startAt) {
1474
+ var internalContext = _createInternalContext(telemetryChain, config, core, startAt);
1475
+ var context = internalContext.ctx;
1476
+ function _processNext(unloadState) {
1477
+ var nextPlugin = internalContext._next();
1478
+ nextPlugin && nextPlugin.unload(context, unloadState);
1479
+ return !nextPlugin;
1480
+ }
1481
+ function _createNew(plugins, startAt) {
1482
+ if (plugins === void 0) { plugins = null; }
1483
+ if (isArray(plugins)) {
1484
+ plugins = createTelemetryProxyChain(plugins, config, core, startAt);
1334
1485
  }
1486
+ return createProcessTelemetryUnloadContext(plugins || context.getNext(), config, core, startAt);
1335
1487
  }
1488
+ context.processNext = _processNext;
1489
+ context.createNew = _createNew;
1336
1490
  return context;
1337
1491
  }
1338
1492
  function createTelemetryProxyChain(plugins, config, core, startAt) {
@@ -1380,32 +1534,35 @@
1380
1534
  return nextProxy;
1381
1535
  },
1382
1536
  processTelemetry: _processTelemetry,
1537
+ unload: _unloadPlugin,
1383
1538
  _id: chainId,
1384
1539
  _setNext: function (nextPlugin) {
1385
1540
  nextProxy = nextPlugin;
1386
1541
  }
1387
1542
  };
1388
- function _processChain(itemCtx, processPluginFn, processProxyFn, name, details, isAsync) {
1543
+ function _getTelCtx() {
1544
+ var itemCtx;
1545
+ if (plugin && isFunction(plugin[strGetTelCtx])) {
1546
+ itemCtx = plugin[strGetTelCtx]();
1547
+ }
1389
1548
  if (!itemCtx) {
1390
- if (plugin && isFunction(plugin[strGetTelCtx])) {
1391
- itemCtx = plugin[strGetTelCtx]();
1392
- }
1393
- if (!itemCtx) {
1394
- itemCtx = createProcessTelemetryContext(proxyChain, config, core);
1395
- }
1549
+ itemCtx = createProcessTelemetryContext(proxyChain, config, core);
1396
1550
  }
1551
+ return itemCtx;
1552
+ }
1553
+ function _processChain(itemCtx, processPluginFn, name, details, isAsync) {
1554
+ var hasRun = false;
1397
1555
  var identifier = plugin ? plugin.identifier : strTelemetryPluginChain;
1398
1556
  var hasRunContext = itemCtx[strHasRunFlags];
1399
1557
  if (!hasRunContext) {
1400
1558
  hasRunContext = itemCtx[strHasRunFlags] = {};
1401
1559
  }
1402
- doPerf(itemCtx.core(), function () { return identifier + ":" + name; }, function () {
1403
- hasRunContext[chainId] = true;
1404
- var hasRun = false;
1405
- itemCtx.setNext(nextProxy);
1406
- if (plugin) {
1560
+ itemCtx.setNext(nextProxy);
1561
+ if (plugin) {
1562
+ doPerf(itemCtx[strCore](), function () { return identifier + ":" + name; }, function () {
1563
+ hasRunContext[chainId] = true;
1407
1564
  try {
1408
- var nextId = nextProxy ? nextProxy._id : "";
1565
+ var nextId = nextProxy ? nextProxy._id : strEmpty$1;
1409
1566
  if (nextId) {
1410
1567
  hasRunContext[nextId] = false;
1411
1568
  }
@@ -1417,18 +1574,21 @@
1417
1574
  hasRun = true;
1418
1575
  }
1419
1576
  if (!nextProxy || !hasNextRun) {
1420
- itemCtx.diagLog().throwInternal(LoggingSeverity.CRITICAL, _InternalMessageId.PluginException, "Plugin [" + plugin.identifier + "] failed during " + name + " - " + dumpObj(error) + ", run flags: " + dumpObj(hasRunContext));
1577
+ itemCtx.diagLog().throwInternal(1 , 73 , "Plugin [" + plugin.identifier + "] failed during " + name + " - " + dumpObj(error) + ", run flags: " + dumpObj(hasRunContext));
1421
1578
  }
1422
1579
  }
1423
- }
1424
- if (nextProxy && !hasRun) {
1425
- processProxyFn(itemCtx);
1426
- }
1427
- }, details, isAsync);
1580
+ }, details, isAsync);
1581
+ }
1582
+ return hasRun;
1428
1583
  }
1429
1584
  function _processTelemetry(env, itemCtx) {
1430
- _processChain(itemCtx, function (itemCtx) {
1431
- if (!hasProcessTelemetry) {
1585
+ itemCtx = itemCtx || _getTelCtx();
1586
+ function _callProcessTelemetry(itemCtx) {
1587
+ if (!plugin || !hasProcessTelemetry) {
1588
+ return false;
1589
+ }
1590
+ var pluginState = _getPluginState(plugin);
1591
+ if (pluginState[strTeardown] || pluginState[strDisabled]) {
1432
1592
  return false;
1433
1593
  }
1434
1594
  if (hasSetNext) {
@@ -1436,15 +1596,61 @@
1436
1596
  }
1437
1597
  plugin.processTelemetry(env, itemCtx);
1438
1598
  return true;
1439
- }, function (itemCtx) {
1440
- nextProxy.processTelemetry(env, itemCtx);
1441
- }, "processTelemetry", function () { return ({ item: env }); }, !(env.sync));
1599
+ }
1600
+ if (!_processChain(itemCtx, _callProcessTelemetry, "processTelemetry", function () { return ({ item: env }); }, !(env.sync))) {
1601
+ itemCtx.processNext(env);
1602
+ }
1603
+ }
1604
+ function _unloadPlugin(unloadCtx, unloadState) {
1605
+ function _callTeardown() {
1606
+ var hasRun = false;
1607
+ if (plugin) {
1608
+ var pluginState = _getPluginState(plugin);
1609
+ var pluginCore = plugin[strCore] || pluginState.core;
1610
+ if (plugin && (!pluginCore || pluginCore === unloadCtx[strCore]()) && !pluginState[strTeardown]) {
1611
+ pluginState[strCore] = null;
1612
+ pluginState[strTeardown] = true;
1613
+ pluginState[strIsInitialized] = false;
1614
+ if (plugin[strTeardown] && plugin[strTeardown](unloadCtx, unloadState) === true) {
1615
+ hasRun = true;
1616
+ }
1617
+ }
1618
+ }
1619
+ return hasRun;
1620
+ }
1621
+ if (!_processChain(unloadCtx, _callTeardown, "unload", function () { }, unloadState.isAsync)) {
1622
+ unloadCtx.processNext(unloadState);
1623
+ }
1442
1624
  }
1443
1625
  return objFreeze(proxyChain);
1444
1626
  }
1445
1627
 
1446
1628
  var strExtensionConfig = "extensionConfig";
1447
1629
 
1630
+ function createUnloadHandlerContainer() {
1631
+ var handlers = [];
1632
+ function _addHandler(handler) {
1633
+ if (handler) {
1634
+ handlers.push(handler);
1635
+ }
1636
+ }
1637
+ function _runHandlers(unloadCtx, unloadState) {
1638
+ arrForEach(handlers, function (handler) {
1639
+ try {
1640
+ handler(unloadCtx, unloadState);
1641
+ }
1642
+ catch (e) {
1643
+ unloadCtx.diagLog().throwInternal(2 , 73 , "Unexpected error calling unload handler - " + dumpObj(e));
1644
+ }
1645
+ });
1646
+ handlers = [];
1647
+ }
1648
+ return {
1649
+ add: _addHandler,
1650
+ run: _runHandlers
1651
+ };
1652
+ }
1653
+
1448
1654
  var strGetPlugin = "getPlugin";
1449
1655
  var BaseTelemetryPlugin = /** @class */ (function () {
1450
1656
  function BaseTelemetryPlugin() {
@@ -1452,6 +1658,7 @@
1452
1658
  var _isinitialized;
1453
1659
  var _rootCtx;
1454
1660
  var _nextPlugin;
1661
+ var _unloadHandlerContainer;
1455
1662
  var _hooks;
1456
1663
  _initDefaults();
1457
1664
  dynamicProto(BaseTelemetryPlugin, _self, function (_self) {
@@ -1459,6 +1666,39 @@
1459
1666
  _setDefaults(config, core, pluginChain);
1460
1667
  _isinitialized = true;
1461
1668
  };
1669
+ _self.teardown = function (unloadCtx, unloadState) {
1670
+ if (!_self.core || (unloadCtx && _self.core !== unloadCtx.core())) {
1671
+ return;
1672
+ }
1673
+ var result;
1674
+ var unloadDone = false;
1675
+ var theUnloadCtx = unloadCtx || createProcessTelemetryUnloadContext(null, {}, _self.core, _nextPlugin && _nextPlugin[strGetPlugin] ? _nextPlugin[strGetPlugin]() : _nextPlugin);
1676
+ var theUnloadState = unloadState || {
1677
+ reason: 0 ,
1678
+ isAsync: false
1679
+ };
1680
+ function _unloadCallback() {
1681
+ if (!unloadDone) {
1682
+ unloadDone = true;
1683
+ _unloadHandlerContainer.run(theUnloadCtx, unloadState);
1684
+ arrForEach(_hooks, function (fn) {
1685
+ fn.rm();
1686
+ });
1687
+ _hooks = [];
1688
+ if (result === true) {
1689
+ theUnloadCtx.processNext(theUnloadState);
1690
+ }
1691
+ _initDefaults();
1692
+ }
1693
+ }
1694
+ if (!_self[strDoTeardown] || _self[strDoTeardown](theUnloadCtx, theUnloadState, _unloadCallback) !== true) {
1695
+ _unloadCallback();
1696
+ }
1697
+ else {
1698
+ result = true;
1699
+ }
1700
+ return result;
1701
+ };
1462
1702
  _self._addHook = function (hooks) {
1463
1703
  if (hooks) {
1464
1704
  if (isArray(hooks)) {
@@ -1469,17 +1709,18 @@
1469
1709
  }
1470
1710
  }
1471
1711
  };
1712
+ proxyFunctionAs(_self, "_addUnloadCb", function () { return _unloadHandlerContainer; }, "add");
1472
1713
  });
1473
1714
  _self.diagLog = function (itemCtx) {
1474
1715
  return _getTelCtx(itemCtx).diagLog();
1475
1716
  };
1476
- _self.isInitialized = function () {
1717
+ _self[strIsInitialized] = function () {
1477
1718
  return _isinitialized;
1478
1719
  };
1479
1720
  _self.setInitialized = function (isInitialized) {
1480
1721
  _isinitialized = isInitialized;
1481
1722
  };
1482
- _self.setNextPlugin = function (next) {
1723
+ _self[strSetNextPlugin] = function (next) {
1483
1724
  _nextPlugin = next;
1484
1725
  };
1485
1726
  _self.processNext = function (env, itemCtx) {
@@ -1525,11 +1766,197 @@
1525
1766
  _rootCtx = null;
1526
1767
  _nextPlugin = null;
1527
1768
  _hooks = [];
1769
+ _unloadHandlerContainer = createUnloadHandlerContainer();
1528
1770
  }
1529
1771
  }
1530
1772
  return BaseTelemetryPlugin;
1531
1773
  }());
1532
1774
 
1775
+ var strOnPrefix = "on";
1776
+ var strAttachEvent = "attachEvent";
1777
+ var strAddEventHelper = "addEventListener";
1778
+ var strEvents = "events";
1779
+ createUniqueNamespace("aiEvtPageHide");
1780
+ createUniqueNamespace("aiEvtPageShow");
1781
+ var _guid = 1;
1782
+ var elmNodeData = createElmNodeData("events");
1783
+ var eventNamespace = /^([^.]*)(?:\.(.+)|)/;
1784
+ function _normalizeNamespace(name) {
1785
+ if (name && name.replace) {
1786
+ return name.replace(/^\s*\.*|\.*\s*$/g, "");
1787
+ }
1788
+ return name;
1789
+ }
1790
+ function _getEvtNamespace(eventName, namespaces) {
1791
+ if (namespaces) {
1792
+ var theNamespace_1 = "";
1793
+ if (isArray(namespaces)) {
1794
+ theNamespace_1 = "";
1795
+ arrForEach(namespaces, function (name) {
1796
+ name = _normalizeNamespace(name);
1797
+ if (name) {
1798
+ if (name[0] !== ".") {
1799
+ name = "." + name;
1800
+ }
1801
+ theNamespace_1 += name;
1802
+ }
1803
+ });
1804
+ }
1805
+ else {
1806
+ theNamespace_1 = _normalizeNamespace(namespaces);
1807
+ }
1808
+ if (theNamespace_1) {
1809
+ if (theNamespace_1[0] !== ".") {
1810
+ theNamespace_1 = "." + theNamespace_1;
1811
+ }
1812
+ eventName = (eventName || "") + theNamespace_1;
1813
+ }
1814
+ }
1815
+ var parsedEvent = (eventNamespace.exec(eventName) || []);
1816
+ return {
1817
+ type: parsedEvent[1],
1818
+ ns: ((parsedEvent[2] || "").split(".").sort()).join(".")
1819
+ };
1820
+ }
1821
+ function _getRegisteredEvents(target, evtName, addDefault) {
1822
+ if (addDefault === void 0) { addDefault = true; }
1823
+ var aiEvts = elmNodeData.get(target, strEvents, {}, addDefault);
1824
+ var registeredEvents = aiEvts[evtName];
1825
+ if (!registeredEvents) {
1826
+ registeredEvents = aiEvts[evtName] = [];
1827
+ }
1828
+ return registeredEvents;
1829
+ }
1830
+ function _doAttach(obj, evtName, handlerRef, useCapture) {
1831
+ var result = false;
1832
+ if (obj && evtName && evtName.type && handlerRef) {
1833
+ if (obj[strAddEventHelper]) {
1834
+ obj[strAddEventHelper](evtName.type, handlerRef, useCapture);
1835
+ result = true;
1836
+ }
1837
+ else if (obj[strAttachEvent]) {
1838
+ obj[strAttachEvent](strOnPrefix + evtName.type, handlerRef);
1839
+ result = true;
1840
+ }
1841
+ }
1842
+ return result;
1843
+ }
1844
+ function eventOn(target, eventName, handlerRef, evtNamespace, useCapture) {
1845
+ if (useCapture === void 0) { useCapture = false; }
1846
+ var result = false;
1847
+ if (target) {
1848
+ try {
1849
+ var evtName = _getEvtNamespace(eventName, evtNamespace);
1850
+ result = _doAttach(target, evtName, handlerRef, useCapture);
1851
+ if (result && elmNodeData.accept(target)) {
1852
+ var registeredEvent = {
1853
+ guid: _guid++,
1854
+ evtName: evtName,
1855
+ handler: handlerRef,
1856
+ capture: useCapture
1857
+ };
1858
+ _getRegisteredEvents(target, evtName.type).push(registeredEvent);
1859
+ }
1860
+ }
1861
+ catch (e) {
1862
+ }
1863
+ }
1864
+ return result;
1865
+ }
1866
+ function attachEvent(obj, eventNameWithoutOn, handlerRef, useCapture) {
1867
+ if (useCapture === void 0) { useCapture = false; }
1868
+ return eventOn(obj, eventNameWithoutOn, handlerRef, null, useCapture);
1869
+ }
1870
+
1871
+ var LoggingSeverity = createEnumStyle({
1872
+ CRITICAL: 1 ,
1873
+ WARNING: 2
1874
+ });
1875
+ var _InternalMessageId = createEnumStyle({
1876
+ BrowserDoesNotSupportLocalStorage: 0 ,
1877
+ BrowserCannotReadLocalStorage: 1 ,
1878
+ BrowserCannotReadSessionStorage: 2 ,
1879
+ BrowserCannotWriteLocalStorage: 3 ,
1880
+ BrowserCannotWriteSessionStorage: 4 ,
1881
+ BrowserFailedRemovalFromLocalStorage: 5 ,
1882
+ BrowserFailedRemovalFromSessionStorage: 6 ,
1883
+ CannotSendEmptyTelemetry: 7 ,
1884
+ ClientPerformanceMathError: 8 ,
1885
+ ErrorParsingAISessionCookie: 9 ,
1886
+ ErrorPVCalc: 10 ,
1887
+ ExceptionWhileLoggingError: 11 ,
1888
+ FailedAddingTelemetryToBuffer: 12 ,
1889
+ FailedMonitorAjaxAbort: 13 ,
1890
+ FailedMonitorAjaxDur: 14 ,
1891
+ FailedMonitorAjaxOpen: 15 ,
1892
+ FailedMonitorAjaxRSC: 16 ,
1893
+ FailedMonitorAjaxSend: 17 ,
1894
+ FailedMonitorAjaxGetCorrelationHeader: 18 ,
1895
+ FailedToAddHandlerForOnBeforeUnload: 19 ,
1896
+ FailedToSendQueuedTelemetry: 20 ,
1897
+ FailedToReportDataLoss: 21 ,
1898
+ FlushFailed: 22 ,
1899
+ MessageLimitPerPVExceeded: 23 ,
1900
+ MissingRequiredFieldSpecification: 24 ,
1901
+ NavigationTimingNotSupported: 25 ,
1902
+ OnError: 26 ,
1903
+ SessionRenewalDateIsZero: 27 ,
1904
+ SenderNotInitialized: 28 ,
1905
+ StartTrackEventFailed: 29 ,
1906
+ StopTrackEventFailed: 30 ,
1907
+ StartTrackFailed: 31 ,
1908
+ StopTrackFailed: 32 ,
1909
+ TelemetrySampledAndNotSent: 33 ,
1910
+ TrackEventFailed: 34 ,
1911
+ TrackExceptionFailed: 35 ,
1912
+ TrackMetricFailed: 36 ,
1913
+ TrackPVFailed: 37 ,
1914
+ TrackPVFailedCalc: 38 ,
1915
+ TrackTraceFailed: 39 ,
1916
+ TransmissionFailed: 40 ,
1917
+ FailedToSetStorageBuffer: 41 ,
1918
+ FailedToRestoreStorageBuffer: 42 ,
1919
+ InvalidBackendResponse: 43 ,
1920
+ FailedToFixDepricatedValues: 44 ,
1921
+ InvalidDurationValue: 45 ,
1922
+ TelemetryEnvelopeInvalid: 46 ,
1923
+ CreateEnvelopeError: 47 ,
1924
+ CannotSerializeObject: 48 ,
1925
+ CannotSerializeObjectNonSerializable: 49 ,
1926
+ CircularReferenceDetected: 50 ,
1927
+ ClearAuthContextFailed: 51 ,
1928
+ ExceptionTruncated: 52 ,
1929
+ IllegalCharsInName: 53 ,
1930
+ ItemNotInArray: 54 ,
1931
+ MaxAjaxPerPVExceeded: 55 ,
1932
+ MessageTruncated: 56 ,
1933
+ NameTooLong: 57 ,
1934
+ SampleRateOutOfRange: 58 ,
1935
+ SetAuthContextFailed: 59 ,
1936
+ SetAuthContextFailedAccountName: 60 ,
1937
+ StringValueTooLong: 61 ,
1938
+ StartCalledMoreThanOnce: 62 ,
1939
+ StopCalledWithoutStart: 63 ,
1940
+ TelemetryInitializerFailed: 64 ,
1941
+ TrackArgumentsNotSpecified: 65 ,
1942
+ UrlTooLong: 66 ,
1943
+ SessionStorageBufferFull: 67 ,
1944
+ CannotAccessCookie: 68 ,
1945
+ IdTooLong: 69 ,
1946
+ InvalidEvent: 70 ,
1947
+ FailedMonitorAjaxSetRequestHeader: 71 ,
1948
+ SendBrowserInfoOnUserInit: 72 ,
1949
+ PluginException: 73 ,
1950
+ NotificationException: 74 ,
1951
+ SnippetScriptLoadFailure: 99 ,
1952
+ InvalidInstrumentationKey: 100 ,
1953
+ CannotParseAiBlobValue: 101 ,
1954
+ InvalidContentBlob: 102 ,
1955
+ TrackPageActionEventFailed: 103 ,
1956
+ FailedAddingCustomDefinedRequestContext: 104 ,
1957
+ InMemoryStorageBufferFull: 105
1958
+ });
1959
+
1533
1960
  var RequestHeaders = {
1534
1961
  requestContextHeader: "Request-Context",
1535
1962
  requestContextTargetKey: "appId",
@@ -1562,7 +1989,7 @@
1562
1989
  name = strTrim(name.toString());
1563
1990
  if (name.length > 150 ) {
1564
1991
  nameTrunc = name.substring(0, 150 );
1565
- logger && logger.throwInternal(LoggingSeverity.WARNING, _InternalMessageId.NameTooLong, "name is too long. It has been truncated to " + 150 + " characters.", { name: name }, true);
1992
+ logger && logger.throwInternal(2 , _InternalMessageId.NameTooLong, "name is too long. It has been truncated to " + 150 + " characters.", { name: name }, true);
1566
1993
  }
1567
1994
  }
1568
1995
  return nameTrunc || name;
@@ -1575,7 +2002,7 @@
1575
2002
  value = strTrim(value);
1576
2003
  if (value.toString().length > maxLength) {
1577
2004
  valueTrunc = value.toString().substring(0, maxLength);
1578
- logger && logger.throwInternal(LoggingSeverity.WARNING, _InternalMessageId.StringValueTooLong, "string value is too long. It has been truncated to " + maxLength + " characters.", { value: value }, true);
2005
+ logger && logger.throwInternal(2 , _InternalMessageId.StringValueTooLong, "string value is too long. It has been truncated to " + maxLength + " characters.", { value: value }, true);
1579
2006
  }
1580
2007
  }
1581
2008
  return valueTrunc || value;
@@ -1588,7 +2015,7 @@
1588
2015
  if (message) {
1589
2016
  if (message.length > 32768 ) {
1590
2017
  messageTrunc = message.substring(0, 32768 );
1591
- logger && logger.throwInternal(LoggingSeverity.WARNING, _InternalMessageId.MessageTruncated, "message is too long, it has been truncated to " + 32768 + " characters.", { message: message }, true);
2018
+ logger && logger.throwInternal(2 , _InternalMessageId.MessageTruncated, "message is too long, it has been truncated to " + 32768 + " characters.", { message: message }, true);
1592
2019
  }
1593
2020
  }
1594
2021
  return messageTrunc || message;
@@ -1599,7 +2026,7 @@
1599
2026
  var value = "" + exception;
1600
2027
  if (value.length > 32768 ) {
1601
2028
  exceptionTrunc = value.substring(0, 32768 );
1602
- logger && logger.throwInternal(LoggingSeverity.WARNING, _InternalMessageId.ExceptionTruncated, "exception is too long, it has been truncated to " + 32768 + " characters.", { exception: exception }, true);
2029
+ logger && logger.throwInternal(2 , _InternalMessageId.ExceptionTruncated, "exception is too long, it has been truncated to " + 32768 + " characters.", { exception: exception }, true);
1603
2030
  }
1604
2031
  }
1605
2032
  return exceptionTrunc || exception;
@@ -1613,7 +2040,7 @@
1613
2040
  value = getJSON().stringify(value);
1614
2041
  }
1615
2042
  catch (e) {
1616
- logger && logger.throwInternal(LoggingSeverity.WARNING, _InternalMessageId.CannotSerializeObjectNonSerializable, "custom property is not valid", { exception: e }, true);
2043
+ logger && logger.throwInternal(2 , _InternalMessageId.CannotSerializeObjectNonSerializable, "custom property is not valid", { exception: e }, true);
1617
2044
  }
1618
2045
  }
1619
2046
  value = dataSanitizeString(logger, value, 8192 );
@@ -1644,7 +2071,7 @@
1644
2071
  input = strTrim(input);
1645
2072
  if (input.length > maxLength) {
1646
2073
  inputTrunc = input.substring(0, maxLength);
1647
- logger && logger.throwInternal(LoggingSeverity.WARNING, _msgId, "input is too long, it has been truncated to " + maxLength + " characters.", { data: input }, true);
2074
+ logger && logger.throwInternal(2 , _msgId, "input is too long, it has been truncated to " + maxLength + " characters.", { data: input }, true);
1648
2075
  }
1649
2076
  }
1650
2077
  return inputTrunc || input;
@@ -1654,21 +2081,22 @@
1654
2081
  return s.substr(s.length - 3);
1655
2082
  }
1656
2083
 
2084
+ var strEmpty = "";
1657
2085
  function msToTimeSpan(totalms) {
1658
2086
  if (isNaN(totalms) || totalms < 0) {
1659
2087
  totalms = 0;
1660
2088
  }
1661
2089
  totalms = Math.round(totalms);
1662
- var ms = "" + totalms % 1000;
1663
- var sec = "" + Math.floor(totalms / 1000) % 60;
1664
- var min = "" + Math.floor(totalms / (1000 * 60)) % 60;
1665
- var hour = "" + Math.floor(totalms / (1000 * 60 * 60)) % 24;
2090
+ var ms = strEmpty + totalms % 1000;
2091
+ var sec = strEmpty + Math.floor(totalms / 1000) % 60;
2092
+ var min = strEmpty + Math.floor(totalms / (1000 * 60)) % 60;
2093
+ var hour = strEmpty + Math.floor(totalms / (1000 * 60 * 60)) % 24;
1666
2094
  var days = Math.floor(totalms / (1000 * 60 * 60 * 24));
1667
2095
  ms = ms.length === 1 ? "00" + ms : ms.length === 2 ? "0" + ms : ms;
1668
2096
  sec = sec.length < 2 ? "0" + sec : sec;
1669
2097
  min = min.length < 2 ? "0" + min : min;
1670
2098
  hour = hour.length < 2 ? "0" + hour : hour;
1671
- return (days > 0 ? days + "." : "") + hour + ":" + min + ":" + sec + "." + ms;
2099
+ return (days > 0 ? days + "." : strEmpty) + hour + ":" + min + ":" + sec + "." + ms;
1672
2100
  }
1673
2101
 
1674
2102
  var DisabledPropertyName = "Microsoft_ApplicationInsights_BypassAjaxInstrumentation";
@@ -1677,17 +2105,15 @@
1677
2105
  var HttpMethod = "http.method";
1678
2106
  var strNotSpecified = "not_specified";
1679
2107
 
1680
- var StorageType;
1681
- (function (StorageType) {
1682
- StorageType[StorageType["LocalStorage"] = 0] = "LocalStorage";
1683
- StorageType[StorageType["SessionStorage"] = 1] = "SessionStorage";
1684
- })(StorageType || (StorageType = {}));
1685
- var DistributedTracingModes;
1686
- (function (DistributedTracingModes) {
1687
- DistributedTracingModes[DistributedTracingModes["AI"] = 0] = "AI";
1688
- DistributedTracingModes[DistributedTracingModes["AI_AND_W3C"] = 1] = "AI_AND_W3C";
1689
- DistributedTracingModes[DistributedTracingModes["W3C"] = 2] = "W3C";
1690
- })(DistributedTracingModes || (DistributedTracingModes = {}));
2108
+ var StorageType = createEnumStyle({
2109
+ LocalStorage: 0 ,
2110
+ SessionStorage: 1
2111
+ });
2112
+ createEnumStyle({
2113
+ AI: 0 ,
2114
+ AI_AND_W3C: 1 ,
2115
+ W3C: 2
2116
+ });
1691
2117
 
1692
2118
  var _canUseSessionStorage = undefined;
1693
2119
  function _getVerifiedStorageObject(storageType) {
@@ -1728,7 +2154,7 @@
1728
2154
  }
1729
2155
  catch (e) {
1730
2156
  _canUseSessionStorage = false;
1731
- logger.throwInternal(LoggingSeverity.WARNING, _InternalMessageId.BrowserCannotReadSessionStorage, "Browser failed read of session storage. " + getExceptionName(e), { exception: dumpObj(e) });
2157
+ logger.throwInternal(2 , _InternalMessageId.BrowserCannotReadSessionStorage, "Browser failed read of session storage. " + getExceptionName(e), { exception: dumpObj(e) });
1732
2158
  }
1733
2159
  }
1734
2160
  return null;
@@ -1742,7 +2168,7 @@
1742
2168
  }
1743
2169
  catch (e) {
1744
2170
  _canUseSessionStorage = false;
1745
- logger.throwInternal(LoggingSeverity.WARNING, _InternalMessageId.BrowserCannotWriteSessionStorage, "Browser failed write to session storage. " + getExceptionName(e), { exception: dumpObj(e) });
2171
+ logger.throwInternal(2 , _InternalMessageId.BrowserCannotWriteSessionStorage, "Browser failed write to session storage. " + getExceptionName(e), { exception: dumpObj(e) });
1746
2172
  }
1747
2173
  }
1748
2174
  return false;
@@ -3019,7 +3445,7 @@
3019
3445
  }
3020
3446
  }
3021
3447
  var EnvelopeCreator = {
3022
- Version: "2.8.0-beta.2203-01"
3448
+ Version: "2.8.0-beta.2203-04"
3023
3449
  };
3024
3450
  function DependencyEnvelopeCreator(logger, telemetryItem, customUndefinedValue) {
3025
3451
  EnvelopeCreatorInit(logger, telemetryItem);