@microsoft/applicationinsights-common 2.8.0-nightly.2204-04 → 2.8.0-nightly.2204-07

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (118) hide show
  1. package/browser/applicationinsights-common.integrity.json +9 -9
  2. package/browser/applicationinsights-common.js +566 -504
  3. package/browser/applicationinsights-common.js.map +1 -1
  4. package/browser/applicationinsights-common.min.js +2 -2
  5. package/browser/applicationinsights-common.min.js.map +1 -1
  6. package/dist/applicationinsights-common.api.json +1206 -399
  7. package/dist/applicationinsights-common.api.md +105 -28
  8. package/dist/applicationinsights-common.d.ts +169 -31
  9. package/dist/applicationinsights-common.js +566 -504
  10. package/dist/applicationinsights-common.js.map +1 -1
  11. package/dist/applicationinsights-common.min.js +2 -2
  12. package/dist/applicationinsights-common.min.js.map +1 -1
  13. package/dist/applicationinsights-common.rollup.d.ts +169 -31
  14. package/dist-esm/ConnectionStringParser.js +1 -1
  15. package/dist-esm/Constants.js +1 -1
  16. package/dist-esm/DomHelperFuncs.js +1 -1
  17. package/dist-esm/Enums.js +1 -1
  18. package/dist-esm/HelperFuncs.js +1 -1
  19. package/dist-esm/Interfaces/ConnectionString.js +1 -1
  20. package/dist-esm/Interfaces/Context/IApplication.js +1 -1
  21. package/dist-esm/Interfaces/Context/IDevice.js +1 -1
  22. package/dist-esm/Interfaces/Context/IInternal.js +1 -1
  23. package/dist-esm/Interfaces/Context/ILocation.js +1 -1
  24. package/dist-esm/Interfaces/Context/IOperatingSystem.js +1 -1
  25. package/dist-esm/Interfaces/Context/ISample.js +1 -1
  26. package/dist-esm/Interfaces/Context/ISession.js +1 -1
  27. package/dist-esm/Interfaces/Context/ITelemetryTrace.js +1 -1
  28. package/dist-esm/Interfaces/Context/IUser.js +1 -1
  29. package/dist-esm/Interfaces/Context/IWeb.js +1 -1
  30. package/dist-esm/Interfaces/Contracts/AvailabilityData.js +1 -1
  31. package/dist-esm/Interfaces/Contracts/ContextTagKeys.js +1 -1
  32. package/dist-esm/Interfaces/Contracts/DataPointType.js +1 -1
  33. package/dist-esm/Interfaces/Contracts/DependencyKind.js +1 -1
  34. package/dist-esm/Interfaces/Contracts/DependencySourceType.js +1 -1
  35. package/dist-esm/Interfaces/Contracts/IBase.js +1 -1
  36. package/dist-esm/Interfaces/Contracts/IData.js +1 -1
  37. package/dist-esm/Interfaces/Contracts/IDataPoint.js +1 -1
  38. package/dist-esm/Interfaces/Contracts/IDomain.js +1 -1
  39. package/dist-esm/Interfaces/Contracts/IEnvelope.js +1 -1
  40. package/dist-esm/Interfaces/Contracts/IEventData.js +1 -1
  41. package/dist-esm/Interfaces/Contracts/IExceptionData.js +1 -1
  42. package/dist-esm/Interfaces/Contracts/IExceptionDetails.js +1 -1
  43. package/dist-esm/Interfaces/Contracts/IMessageData.js +1 -1
  44. package/dist-esm/Interfaces/Contracts/IMetricData.js +1 -1
  45. package/dist-esm/Interfaces/Contracts/IPageViewData.js +1 -1
  46. package/dist-esm/Interfaces/Contracts/IPageViewPerfData.js +1 -1
  47. package/dist-esm/Interfaces/Contracts/IRemoteDependencyData.js +1 -1
  48. package/dist-esm/Interfaces/Contracts/IStackFrame.js +1 -1
  49. package/dist-esm/Interfaces/Contracts/RequestData.js +1 -1
  50. package/dist-esm/Interfaces/Contracts/SeverityLevel.js +9 -10
  51. package/dist-esm/Interfaces/Contracts/SeverityLevel.js.map +1 -1
  52. package/dist-esm/Interfaces/IAppInsights.js +1 -1
  53. package/dist-esm/Interfaces/IChannelControlsAI.js +1 -1
  54. package/dist-esm/Interfaces/IConfig.js +1 -1
  55. package/dist-esm/Interfaces/ICorrelationConfig.js +1 -1
  56. package/dist-esm/Interfaces/IDependencyTelemetry.js +1 -1
  57. package/dist-esm/Interfaces/IEventTelemetry.js +1 -1
  58. package/dist-esm/Interfaces/IExceptionTelemetry.js +1 -1
  59. package/dist-esm/Interfaces/IMetricTelemetry.js +1 -1
  60. package/dist-esm/Interfaces/IPageViewPerformanceTelemetry.js +1 -1
  61. package/dist-esm/Interfaces/IPageViewTelemetry.js +1 -1
  62. package/dist-esm/Interfaces/IPartC.js +1 -1
  63. package/dist-esm/Interfaces/IPropertiesPlugin.js +1 -1
  64. package/dist-esm/Interfaces/IRequestContext.js +1 -1
  65. package/dist-esm/Interfaces/ITelemetryContext.js +1 -1
  66. package/dist-esm/Interfaces/ITraceParent.js +8 -0
  67. package/dist-esm/Interfaces/ITraceParent.js.map +1 -0
  68. package/dist-esm/Interfaces/ITraceTelemetry.js +1 -1
  69. package/dist-esm/Interfaces/PartAExtensions.js +1 -1
  70. package/dist-esm/Interfaces/Telemetry/IEnvelope.js +1 -1
  71. package/dist-esm/Interfaces/Telemetry/ISerializable.js +1 -1
  72. package/dist-esm/RequestResponseHeaders.js +13 -12
  73. package/dist-esm/RequestResponseHeaders.js.map +1 -1
  74. package/dist-esm/StorageHelperFuncs.js +12 -12
  75. package/dist-esm/StorageHelperFuncs.js.map +1 -1
  76. package/dist-esm/Telemetry/Common/Data.js +1 -1
  77. package/dist-esm/Telemetry/Common/DataPoint.js +1 -1
  78. package/dist-esm/Telemetry/Common/DataSanitizer.js +9 -9
  79. package/dist-esm/Telemetry/Common/DataSanitizer.js.map +1 -1
  80. package/dist-esm/Telemetry/Common/Envelope.js +1 -1
  81. package/dist-esm/Telemetry/Event.js +1 -1
  82. package/dist-esm/Telemetry/Exception.js +1 -1
  83. package/dist-esm/Telemetry/Metric.js +1 -1
  84. package/dist-esm/Telemetry/PageView.js +1 -1
  85. package/dist-esm/Telemetry/PageViewPerformance.js +1 -1
  86. package/dist-esm/Telemetry/RemoteDependencyData.js +1 -1
  87. package/dist-esm/Telemetry/Trace.js +1 -1
  88. package/dist-esm/TelemetryItemCreator.js +42 -32
  89. package/dist-esm/TelemetryItemCreator.js.map +1 -1
  90. package/dist-esm/UrlHelperFuncs.js +1 -1
  91. package/dist-esm/Util.js +2 -2
  92. package/dist-esm/Util.js.map +1 -1
  93. package/dist-esm/W3cTraceParent.js +192 -0
  94. package/dist-esm/W3cTraceParent.js.map +1 -0
  95. package/dist-esm/applicationinsights-common.js +3 -2
  96. package/dist-esm/applicationinsights-common.js.map +1 -1
  97. package/package.json +2 -2
  98. package/src/Enums.ts +2 -3
  99. package/src/Interfaces/Contracts/SeverityLevel.ts +15 -2
  100. package/src/Interfaces/IConfig.ts +2 -9
  101. package/src/Interfaces/ITraceParent.ts +38 -0
  102. package/src/RequestResponseHeaders.ts +38 -2
  103. package/src/StorageHelperFuncs.ts +11 -11
  104. package/src/Telemetry/Common/DataSanitizer.ts +10 -10
  105. package/src/Telemetry/PageViewPerformance.ts +1 -1
  106. package/src/TelemetryItemCreator.ts +56 -44
  107. package/src/Util.ts +3 -3
  108. package/src/W3cTraceParent.ts +219 -0
  109. package/src/applicationinsights-common.ts +8 -3
  110. package/types/Enums.d.ts +2 -9
  111. package/types/Interfaces/Contracts/SeverityLevel.d.ts +6 -1
  112. package/types/Interfaces/IConfig.d.ts +3 -9
  113. package/types/Interfaces/ITraceParent.d.ts +32 -0
  114. package/types/RequestResponseHeaders.d.ts +31 -1
  115. package/types/Telemetry/Common/DataSanitizer.d.ts +3 -3
  116. package/types/TelemetryItemCreator.d.ts +15 -5
  117. package/types/W3cTraceParent.d.ts +59 -0
  118. package/types/applicationinsights-common.d.ts +5 -3
@@ -1 +1 @@
1
- {"version":3,"file":"TelemetryItemCreator.js.map","sources":["TelemetryItemCreator.js"],"sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT License.\r\nimport { dataSanitizeString } from \"./Telemetry/Common/DataSanitizer\";\r\nimport { objForEachKey, isNullOrUndefined, toISOString } from \"@microsoft/applicationinsights-core-js\";\r\nimport { strNotSpecified, strIkey } from \"./Constants\";\r\nvar TelemetryItemCreator = /** @class */ (function () {\r\n function TelemetryItemCreator() {\r\n }\r\n /**\r\n * Create a telemetry item that the 1DS channel understands\r\n * @param item domain specific properties; part B\r\n * @param baseType telemetry item type. ie PageViewData\r\n * @param envelopeName name of the envelope. ie Microsoft.ApplicationInsights.<instrumentation key>.PageView\r\n * @param customProperties user defined custom properties; part C\r\n * @param systemProperties system properties that are added to the context; part A\r\n * @returns ITelemetryItem that is sent to channel\r\n */\r\n TelemetryItemCreator.create = function (item, baseType, envelopeName, logger, customProperties, systemProperties) {\r\n envelopeName = dataSanitizeString(logger, envelopeName) || strNotSpecified;\r\n if (isNullOrUndefined(item) ||\r\n isNullOrUndefined(baseType) ||\r\n isNullOrUndefined(envelopeName)) {\r\n throw Error(\"Input doesn't contain all required fields\");\r\n }\r\n var iKey = \"\";\r\n if (item[strIkey]) {\r\n iKey = item[strIkey];\r\n delete item[strIkey];\r\n }\r\n var telemetryItem = {\r\n name: envelopeName,\r\n time: toISOString(new Date()),\r\n iKey: iKey,\r\n ext: systemProperties ? systemProperties : {},\r\n tags: [],\r\n data: {},\r\n baseType: baseType,\r\n baseData: item // Part B\r\n };\r\n // Part C\r\n if (!isNullOrUndefined(customProperties)) {\r\n objForEachKey(customProperties, function (prop, value) {\r\n telemetryItem.data[prop] = value;\r\n });\r\n }\r\n return telemetryItem;\r\n };\r\n return TelemetryItemCreator;\r\n}());\r\nexport { TelemetryItemCreator };\r\n//# sourceMappingURL=TelemetryItemCreator.js.map"],"names":[],"mappings":";;;;AAA4D;AAC1B;AAClC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA"}
1
+ {"version":3,"file":"TelemetryItemCreator.js.map","sources":["TelemetryItemCreator.js"],"sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT License.\r\nimport { dataSanitizeString } from \"./Telemetry/Common/DataSanitizer\";\r\nimport { objForEachKey, isNullOrUndefined, toISOString, throwError } from \"@microsoft/applicationinsights-core-js\";\r\nimport { strNotSpecified, strIkey } from \"./Constants\";\r\n/**\r\n * Create a telemetry item that the 1DS channel understands\r\n * @param item domain specific properties; part B\r\n * @param baseType telemetry item type. ie PageViewData\r\n * @param envelopeName name of the envelope. ie Microsoft.ApplicationInsights.<instrumentation key>.PageView\r\n * @param customProperties user defined custom properties; part C\r\n * @param systemProperties system properties that are added to the context; part A\r\n * @returns ITelemetryItem that is sent to channel\r\n */\r\nexport function createTelemetryItem(item, baseType, envelopeName, logger, customProperties, systemProperties) {\r\n envelopeName = dataSanitizeString(logger, envelopeName) || strNotSpecified;\r\n if (isNullOrUndefined(item) ||\r\n isNullOrUndefined(baseType) ||\r\n isNullOrUndefined(envelopeName)) {\r\n throwError(\"Input doesn't contain all required fields\");\r\n }\r\n var iKey = \"\";\r\n if (item[strIkey]) {\r\n iKey = item[strIkey];\r\n delete item[strIkey];\r\n }\r\n var telemetryItem = {\r\n name: envelopeName,\r\n time: toISOString(new Date()),\r\n iKey: iKey,\r\n ext: systemProperties ? systemProperties : {},\r\n tags: [],\r\n data: {},\r\n baseType: baseType,\r\n baseData: item // Part B\r\n };\r\n // Part C\r\n if (!isNullOrUndefined(customProperties)) {\r\n objForEachKey(customProperties, function (prop, value) {\r\n telemetryItem.data[prop] = value;\r\n });\r\n }\r\n return telemetryItem;\r\n}\r\nvar TelemetryItemCreator = /** @class */ (function () {\r\n function TelemetryItemCreator() {\r\n }\r\n /**\r\n * Create a telemetry item that the 1DS channel understands\r\n * @param item domain specific properties; part B\r\n * @param baseType telemetry item type. ie PageViewData\r\n * @param envelopeName name of the envelope. ie Microsoft.ApplicationInsights.<instrumentation key>.PageView\r\n * @param customProperties user defined custom properties; part C\r\n * @param systemProperties system properties that are added to the context; part A\r\n * @returns ITelemetryItem that is sent to channel\r\n */\r\n TelemetryItemCreator.create = createTelemetryItem;\r\n return TelemetryItemCreator;\r\n}());\r\nexport { TelemetryItemCreator };\r\n//# sourceMappingURL=TelemetryItemCreator.js.map"],"names":[],"mappings":";;;;AAA4D;AAC1B;AAClC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA"}
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Application Insights JavaScript SDK - Common, 2.8.0-nightly.2204-04
2
+ * Application Insights JavaScript SDK - Common, 2.8.0-nightly.2204-07
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  */
5
5
 
package/dist-esm/Util.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Application Insights JavaScript SDK - Common, 2.8.0-nightly.2204-04
2
+ * Application Insights JavaScript SDK - Common, 2.8.0-nightly.2204-07
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  */
5
5
 
@@ -128,7 +128,7 @@ export var CorrelationIdHelper = {
128
128
  */
129
129
  getCorrelationContext: function (responseHeader) {
130
130
  if (responseHeader) {
131
- var correlationId = CorrelationIdHelper.getCorrelationContextValue(responseHeader, RequestHeaders.requestContextTargetKey);
131
+ var correlationId = CorrelationIdHelper.getCorrelationContextValue(responseHeader, RequestHeaders[1 /* requestContextTargetKey */]);
132
132
  if (correlationId && correlationId !== CorrelationIdHelper.correlationIdPrefix) {
133
133
  return correlationId;
134
134
  }
@@ -1 +1 @@
1
- {"version":3,"file":"Util.js.map","sources":["Util.js"],"sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT License.\r\nimport { getPerformance, getExceptionName as coreGetExceptionName, dumpObj, isNullOrUndefined, strTrim, random32, isArray, isError, isDate, newId, generateW3CId, toISOString, arrForEach, getIEVersion, attachEvent, dateNow, uaDisallowsSameSiteNone, disableCookies as coreDisableCookies, canUseCookies as coreCanUseCookies, getCookie as coreGetCookie, setCookie as coreSetCookie, deleteCookie as coreDeleteCookie, isBeaconsSupported } from \"@microsoft/applicationinsights-core-js\";\r\nimport { RequestHeaders } from \"./RequestResponseHeaders\";\r\nimport { dataSanitizeString } from \"./Telemetry/Common/DataSanitizer\";\r\nimport { createDomEvent } from \"./DomHelperFuncs\";\r\nimport { stringToBoolOrDefault, msToTimeSpan, isCrossOriginError, getExtensionByName } from \"./HelperFuncs\";\r\nimport { strNotSpecified } from \"./Constants\";\r\nimport { utlCanUseLocalStorage, utlCanUseSessionStorage, utlDisableStorage, utlGetSessionStorage, utlGetSessionStorageKeys, utlGetLocalStorage, utlRemoveSessionStorage, utlRemoveStorage, utlSetSessionStorage, utlSetLocalStorage } from \"./StorageHelperFuncs\";\r\nimport { urlGetAbsoluteUrl, urlGetCompleteUrl, urlGetPathName, urlParseFullHost, urlParseHost, urlParseUrl } from \"./UrlHelperFuncs\";\r\n// listing only non-geo specific locations\r\nvar _internalEndpoints = [\r\n \"https://dc.services.visualstudio.com/v2/track\",\r\n \"https://breeze.aimon.applicationinsights.io/v2/track\",\r\n \"https://dc-int.services.visualstudio.com/v2/track\"\r\n];\r\nexport function isInternalApplicationInsightsEndpoint(endpointUrl) {\r\n return _internalEndpoints.indexOf(endpointUrl.toLowerCase()) !== -1;\r\n}\r\nexport var Util = {\r\n NotSpecified: strNotSpecified,\r\n createDomEvent: createDomEvent,\r\n disableStorage: utlDisableStorage,\r\n isInternalApplicationInsightsEndpoint: isInternalApplicationInsightsEndpoint,\r\n canUseLocalStorage: utlCanUseLocalStorage,\r\n getStorage: utlGetLocalStorage,\r\n setStorage: utlSetLocalStorage,\r\n removeStorage: utlRemoveStorage,\r\n canUseSessionStorage: utlCanUseSessionStorage,\r\n getSessionStorageKeys: utlGetSessionStorageKeys,\r\n getSessionStorage: utlGetSessionStorage,\r\n setSessionStorage: utlSetSessionStorage,\r\n removeSessionStorage: utlRemoveSessionStorage,\r\n disableCookies: coreDisableCookies,\r\n canUseCookies: coreCanUseCookies,\r\n disallowsSameSiteNone: uaDisallowsSameSiteNone,\r\n setCookie: coreSetCookie,\r\n stringToBoolOrDefault: stringToBoolOrDefault,\r\n getCookie: coreGetCookie,\r\n deleteCookie: coreDeleteCookie,\r\n trim: strTrim,\r\n newId: newId,\r\n random32: function () {\r\n return random32(true);\r\n },\r\n generateW3CId: generateW3CId,\r\n isArray: isArray,\r\n isError: isError,\r\n isDate: isDate,\r\n toISOStringForIE8: toISOString,\r\n getIEVersion: getIEVersion,\r\n msToTimeSpan: msToTimeSpan,\r\n isCrossOriginError: isCrossOriginError,\r\n dump: dumpObj,\r\n getExceptionName: coreGetExceptionName,\r\n addEventHandler: attachEvent,\r\n IsBeaconApiSupported: isBeaconsSupported,\r\n getExtension: getExtensionByName\r\n};\r\nexport var UrlHelper = {\r\n parseUrl: urlParseUrl,\r\n getAbsoluteUrl: urlGetAbsoluteUrl,\r\n getPathName: urlGetPathName,\r\n getCompleteUrl: urlGetCompleteUrl,\r\n parseHost: urlParseHost,\r\n parseFullHost: urlParseFullHost\r\n};\r\nexport var CorrelationIdHelper = {\r\n correlationIdPrefix: \"cid-v1:\",\r\n /**\r\n * Checks if a request url is not on a excluded domain list and if it is safe to add correlation headers.\r\n * Headers are always included if the current domain matches the request domain. If they do not match (CORS),\r\n * they are regex-ed across correlationHeaderDomains and correlationHeaderExcludedDomains to determine if headers are included.\r\n * Some environments don't give information on currentHost via window.location.host (e.g. Cordova). In these cases, the user must\r\n * manually supply domains to include correlation headers on. Else, no headers will be included at all.\r\n */\r\n canIncludeCorrelationHeader: function (config, requestUrl, currentHost) {\r\n if (!requestUrl || (config && config.disableCorrelationHeaders)) {\r\n return false;\r\n }\r\n if (config && config.correlationHeaderExcludePatterns) {\r\n for (var i = 0; i < config.correlationHeaderExcludePatterns.length; i++) {\r\n if (config.correlationHeaderExcludePatterns[i].test(requestUrl)) {\r\n return false;\r\n }\r\n }\r\n }\r\n var requestHost = urlParseUrl(requestUrl).host.toLowerCase();\r\n if (requestHost && (requestHost.indexOf(\":443\") !== -1 || requestHost.indexOf(\":80\") !== -1)) {\r\n // [Bug #1260] IE can include the port even for http and https URLs so if present\r\n // try and parse it to remove if it matches the default protocol port\r\n requestHost = (urlParseFullHost(requestUrl, true) || \"\").toLowerCase();\r\n }\r\n if ((!config || !config.enableCorsCorrelation) && (requestHost && requestHost !== currentHost)) {\r\n return false;\r\n }\r\n var includedDomains = config && config.correlationHeaderDomains;\r\n if (includedDomains) {\r\n var matchExists_1;\r\n arrForEach(includedDomains, function (domain) {\r\n var regex = new RegExp(domain.toLowerCase().replace(/\\\\/g, \"\\\\\\\\\").replace(/\\./g, \"\\\\.\").replace(/\\*/g, \".*\"));\r\n matchExists_1 = matchExists_1 || regex.test(requestHost);\r\n });\r\n if (!matchExists_1) {\r\n return false;\r\n }\r\n }\r\n var excludedDomains = config && config.correlationHeaderExcludedDomains;\r\n if (!excludedDomains || excludedDomains.length === 0) {\r\n return true;\r\n }\r\n for (var i = 0; i < excludedDomains.length; i++) {\r\n var regex = new RegExp(excludedDomains[i].toLowerCase().replace(/\\\\/g, \"\\\\\\\\\").replace(/\\./g, \"\\\\.\").replace(/\\*/g, \".*\"));\r\n if (regex.test(requestHost)) {\r\n return false;\r\n }\r\n }\r\n // if we don't know anything about the requestHost, require the user to use included/excludedDomains.\r\n // Previously we always returned false for a falsy requestHost\r\n return requestHost && requestHost.length > 0;\r\n },\r\n /**\r\n * Combines target appId and target role name from response header.\r\n */\r\n getCorrelationContext: function (responseHeader) {\r\n if (responseHeader) {\r\n var correlationId = CorrelationIdHelper.getCorrelationContextValue(responseHeader, RequestHeaders.requestContextTargetKey);\r\n if (correlationId && correlationId !== CorrelationIdHelper.correlationIdPrefix) {\r\n return correlationId;\r\n }\r\n }\r\n },\r\n /**\r\n * Gets key from correlation response header\r\n */\r\n getCorrelationContextValue: function (responseHeader, key) {\r\n if (responseHeader) {\r\n var keyValues = responseHeader.split(\",\");\r\n for (var i = 0; i < keyValues.length; ++i) {\r\n var keyValue = keyValues[i].split(\"=\");\r\n if (keyValue.length === 2 && keyValue[0] === key) {\r\n return keyValue[1];\r\n }\r\n }\r\n }\r\n }\r\n};\r\nexport function AjaxHelperParseDependencyPath(logger, absoluteUrl, method, commandName) {\r\n var target, name = commandName, data = commandName;\r\n if (absoluteUrl && absoluteUrl.length > 0) {\r\n var parsedUrl = urlParseUrl(absoluteUrl);\r\n target = parsedUrl.host;\r\n if (!name) {\r\n if (parsedUrl.pathname != null) {\r\n var pathName = (parsedUrl.pathname.length === 0) ? \"/\" : parsedUrl.pathname;\r\n if (pathName.charAt(0) !== \"/\") {\r\n pathName = \"/\" + pathName;\r\n }\r\n data = parsedUrl.pathname;\r\n name = dataSanitizeString(logger, method ? method + \" \" + pathName : pathName);\r\n }\r\n else {\r\n name = dataSanitizeString(logger, absoluteUrl);\r\n }\r\n }\r\n }\r\n else {\r\n target = commandName;\r\n name = commandName;\r\n }\r\n return {\r\n target: target,\r\n name: name,\r\n data: data\r\n };\r\n}\r\nexport function dateTimeUtilsNow() {\r\n // returns the window or webworker performance object\r\n var perf = getPerformance();\r\n if (perf && perf.now && perf.timing) {\r\n var now = perf.now() + perf.timing.navigationStart;\r\n // Known issue with IE where this calculation can be negative, so if it is then ignore and fallback\r\n if (now > 0) {\r\n return now;\r\n }\r\n }\r\n return dateNow();\r\n}\r\nexport function dateTimeUtilsDuration(start, end) {\r\n var result = null;\r\n if (start !== 0 && end !== 0 && !isNullOrUndefined(start) && !isNullOrUndefined(end)) {\r\n result = end - start;\r\n }\r\n return result;\r\n}\r\n/**\r\n * A utility class that helps getting time related parameters\r\n */\r\nexport var DateTimeUtils = {\r\n Now: dateTimeUtilsNow,\r\n GetDuration: dateTimeUtilsDuration\r\n};\r\n//# sourceMappingURL=Util.js.map"],"names":[],"mappings":";;;;AAA4D;AAC1B;AAClC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA"}
1
+ {"version":3,"file":"Util.js.map","sources":["Util.js"],"sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT License.\r\nimport { getPerformance, getExceptionName as coreGetExceptionName, dumpObj, isNullOrUndefined, strTrim, random32, isArray, isError, isDate, newId, generateW3CId, toISOString, arrForEach, getIEVersion, attachEvent, dateNow, uaDisallowsSameSiteNone, disableCookies as coreDisableCookies, canUseCookies as coreCanUseCookies, getCookie as coreGetCookie, setCookie as coreSetCookie, deleteCookie as coreDeleteCookie, isBeaconsSupported } from \"@microsoft/applicationinsights-core-js\";\r\nimport { RequestHeaders } from \"./RequestResponseHeaders\";\r\nimport { dataSanitizeString } from \"./Telemetry/Common/DataSanitizer\";\r\nimport { createDomEvent } from \"./DomHelperFuncs\";\r\nimport { stringToBoolOrDefault, msToTimeSpan, isCrossOriginError, getExtensionByName } from \"./HelperFuncs\";\r\nimport { strNotSpecified } from \"./Constants\";\r\nimport { utlCanUseLocalStorage, utlCanUseSessionStorage, utlDisableStorage, utlGetSessionStorage, utlGetSessionStorageKeys, utlGetLocalStorage, utlRemoveSessionStorage, utlRemoveStorage, utlSetSessionStorage, utlSetLocalStorage } from \"./StorageHelperFuncs\";\r\nimport { urlGetAbsoluteUrl, urlGetCompleteUrl, urlGetPathName, urlParseFullHost, urlParseHost, urlParseUrl } from \"./UrlHelperFuncs\";\r\n// listing only non-geo specific locations\r\nvar _internalEndpoints = [\r\n \"https://dc.services.visualstudio.com/v2/track\",\r\n \"https://breeze.aimon.applicationinsights.io/v2/track\",\r\n \"https://dc-int.services.visualstudio.com/v2/track\"\r\n];\r\nexport function isInternalApplicationInsightsEndpoint(endpointUrl) {\r\n return _internalEndpoints.indexOf(endpointUrl.toLowerCase()) !== -1;\r\n}\r\nexport var Util = {\r\n NotSpecified: strNotSpecified,\r\n createDomEvent: createDomEvent,\r\n disableStorage: utlDisableStorage,\r\n isInternalApplicationInsightsEndpoint: isInternalApplicationInsightsEndpoint,\r\n canUseLocalStorage: utlCanUseLocalStorage,\r\n getStorage: utlGetLocalStorage,\r\n setStorage: utlSetLocalStorage,\r\n removeStorage: utlRemoveStorage,\r\n canUseSessionStorage: utlCanUseSessionStorage,\r\n getSessionStorageKeys: utlGetSessionStorageKeys,\r\n getSessionStorage: utlGetSessionStorage,\r\n setSessionStorage: utlSetSessionStorage,\r\n removeSessionStorage: utlRemoveSessionStorage,\r\n disableCookies: coreDisableCookies,\r\n canUseCookies: coreCanUseCookies,\r\n disallowsSameSiteNone: uaDisallowsSameSiteNone,\r\n setCookie: coreSetCookie,\r\n stringToBoolOrDefault: stringToBoolOrDefault,\r\n getCookie: coreGetCookie,\r\n deleteCookie: coreDeleteCookie,\r\n trim: strTrim,\r\n newId: newId,\r\n random32: function () {\r\n return random32(true);\r\n },\r\n generateW3CId: generateW3CId,\r\n isArray: isArray,\r\n isError: isError,\r\n isDate: isDate,\r\n toISOStringForIE8: toISOString,\r\n getIEVersion: getIEVersion,\r\n msToTimeSpan: msToTimeSpan,\r\n isCrossOriginError: isCrossOriginError,\r\n dump: dumpObj,\r\n getExceptionName: coreGetExceptionName,\r\n addEventHandler: attachEvent,\r\n IsBeaconApiSupported: isBeaconsSupported,\r\n getExtension: getExtensionByName\r\n};\r\nexport var UrlHelper = {\r\n parseUrl: urlParseUrl,\r\n getAbsoluteUrl: urlGetAbsoluteUrl,\r\n getPathName: urlGetPathName,\r\n getCompleteUrl: urlGetCompleteUrl,\r\n parseHost: urlParseHost,\r\n parseFullHost: urlParseFullHost\r\n};\r\nexport var CorrelationIdHelper = {\r\n correlationIdPrefix: \"cid-v1:\",\r\n /**\r\n * Checks if a request url is not on a excluded domain list and if it is safe to add correlation headers.\r\n * Headers are always included if the current domain matches the request domain. If they do not match (CORS),\r\n * they are regex-ed across correlationHeaderDomains and correlationHeaderExcludedDomains to determine if headers are included.\r\n * Some environments don't give information on currentHost via window.location.host (e.g. Cordova). In these cases, the user must\r\n * manually supply domains to include correlation headers on. Else, no headers will be included at all.\r\n */\r\n canIncludeCorrelationHeader: function (config, requestUrl, currentHost) {\r\n if (!requestUrl || (config && config.disableCorrelationHeaders)) {\r\n return false;\r\n }\r\n if (config && config.correlationHeaderExcludePatterns) {\r\n for (var i = 0; i < config.correlationHeaderExcludePatterns.length; i++) {\r\n if (config.correlationHeaderExcludePatterns[i].test(requestUrl)) {\r\n return false;\r\n }\r\n }\r\n }\r\n var requestHost = urlParseUrl(requestUrl).host.toLowerCase();\r\n if (requestHost && (requestHost.indexOf(\":443\") !== -1 || requestHost.indexOf(\":80\") !== -1)) {\r\n // [Bug #1260] IE can include the port even for http and https URLs so if present\r\n // try and parse it to remove if it matches the default protocol port\r\n requestHost = (urlParseFullHost(requestUrl, true) || \"\").toLowerCase();\r\n }\r\n if ((!config || !config.enableCorsCorrelation) && (requestHost && requestHost !== currentHost)) {\r\n return false;\r\n }\r\n var includedDomains = config && config.correlationHeaderDomains;\r\n if (includedDomains) {\r\n var matchExists_1;\r\n arrForEach(includedDomains, function (domain) {\r\n var regex = new RegExp(domain.toLowerCase().replace(/\\\\/g, \"\\\\\\\\\").replace(/\\./g, \"\\\\.\").replace(/\\*/g, \".*\"));\r\n matchExists_1 = matchExists_1 || regex.test(requestHost);\r\n });\r\n if (!matchExists_1) {\r\n return false;\r\n }\r\n }\r\n var excludedDomains = config && config.correlationHeaderExcludedDomains;\r\n if (!excludedDomains || excludedDomains.length === 0) {\r\n return true;\r\n }\r\n for (var i = 0; i < excludedDomains.length; i++) {\r\n var regex = new RegExp(excludedDomains[i].toLowerCase().replace(/\\\\/g, \"\\\\\\\\\").replace(/\\./g, \"\\\\.\").replace(/\\*/g, \".*\"));\r\n if (regex.test(requestHost)) {\r\n return false;\r\n }\r\n }\r\n // if we don't know anything about the requestHost, require the user to use included/excludedDomains.\r\n // Previously we always returned false for a falsy requestHost\r\n return requestHost && requestHost.length > 0;\r\n },\r\n /**\r\n * Combines target appId and target role name from response header.\r\n */\r\n getCorrelationContext: function (responseHeader) {\r\n if (responseHeader) {\r\n var correlationId = CorrelationIdHelper.getCorrelationContextValue(responseHeader, RequestHeaders[1 /* requestContextTargetKey */]);\r\n if (correlationId && correlationId !== CorrelationIdHelper.correlationIdPrefix) {\r\n return correlationId;\r\n }\r\n }\r\n },\r\n /**\r\n * Gets key from correlation response header\r\n */\r\n getCorrelationContextValue: function (responseHeader, key) {\r\n if (responseHeader) {\r\n var keyValues = responseHeader.split(\",\");\r\n for (var i = 0; i < keyValues.length; ++i) {\r\n var keyValue = keyValues[i].split(\"=\");\r\n if (keyValue.length === 2 && keyValue[0] === key) {\r\n return keyValue[1];\r\n }\r\n }\r\n }\r\n }\r\n};\r\nexport function AjaxHelperParseDependencyPath(logger, absoluteUrl, method, commandName) {\r\n var target, name = commandName, data = commandName;\r\n if (absoluteUrl && absoluteUrl.length > 0) {\r\n var parsedUrl = urlParseUrl(absoluteUrl);\r\n target = parsedUrl.host;\r\n if (!name) {\r\n if (parsedUrl.pathname != null) {\r\n var pathName = (parsedUrl.pathname.length === 0) ? \"/\" : parsedUrl.pathname;\r\n if (pathName.charAt(0) !== \"/\") {\r\n pathName = \"/\" + pathName;\r\n }\r\n data = parsedUrl.pathname;\r\n name = dataSanitizeString(logger, method ? method + \" \" + pathName : pathName);\r\n }\r\n else {\r\n name = dataSanitizeString(logger, absoluteUrl);\r\n }\r\n }\r\n }\r\n else {\r\n target = commandName;\r\n name = commandName;\r\n }\r\n return {\r\n target: target,\r\n name: name,\r\n data: data\r\n };\r\n}\r\nexport function dateTimeUtilsNow() {\r\n // returns the window or webworker performance object\r\n var perf = getPerformance();\r\n if (perf && perf.now && perf.timing) {\r\n var now = perf.now() + perf.timing.navigationStart;\r\n // Known issue with IE where this calculation can be negative, so if it is then ignore and fallback\r\n if (now > 0) {\r\n return now;\r\n }\r\n }\r\n return dateNow();\r\n}\r\nexport function dateTimeUtilsDuration(start, end) {\r\n var result = null;\r\n if (start !== 0 && end !== 0 && !isNullOrUndefined(start) && !isNullOrUndefined(end)) {\r\n result = end - start;\r\n }\r\n return result;\r\n}\r\n/**\r\n * A utility class that helps getting time related parameters\r\n */\r\nexport var DateTimeUtils = {\r\n Now: dateTimeUtilsNow,\r\n GetDuration: dateTimeUtilsDuration\r\n};\r\n//# sourceMappingURL=Util.js.map"],"names":[],"mappings":";;;;AAA4D;AAC1B;AAClC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA"}
@@ -0,0 +1,192 @@
1
+ /*
2
+ * Application Insights JavaScript SDK - Common, 2.8.0-nightly.2204-07
3
+ * Copyright (c) Microsoft and contributors. All rights reserved.
4
+ */
5
+ import { generateW3CId, getDocument, getPerformance, isArray, isString, strTrim } from "@microsoft/applicationinsights-core-js";
6
+ // using {0,16} for leading and trailing whitespace just to constrain the possible runtime of a random string
7
+ var TRACE_PARENT_REGEX = /^([\da-f]{2})-([\da-f]{32})-([\da-f]{16})-([\da-f]{2})(-[^\s]*)?$/;
8
+ var DEFAULT_VERSION = "00";
9
+ var INVALID_VERSION = "ff";
10
+ var INVALID_TRACE_ID = "00000000000000000000000000000000";
11
+ var INVALID_SPAN_ID = "0000000000000000";
12
+ var SAMPLED_FLAG = 0x01;
13
+ function _isValid(value, len, invalidValue) {
14
+ if (value && value.length === len && value !== invalidValue) {
15
+ return !!value.match(/^[\da-f]*$/);
16
+ }
17
+ return false;
18
+ }
19
+ function _formatValue(value, len, defValue) {
20
+ if (_isValid(value, len)) {
21
+ return value;
22
+ }
23
+ return defValue;
24
+ }
25
+ function _formatFlags(value) {
26
+ if (isNaN(value) || value < 0 || value > 255) {
27
+ value = 0x01;
28
+ }
29
+ var result = value.toString(16);
30
+ while (result.length < 2) {
31
+ result = "0" + result;
32
+ }
33
+ return result;
34
+ }
35
+ function _getTraceParentValue(values) {
36
+ if (values) {
37
+ for (var i = 0; i < values.length; i++) {
38
+ var value = values[i];
39
+ if (value.name) {
40
+ if (value.name === "traceparent") {
41
+ return value;
42
+ }
43
+ }
44
+ }
45
+ }
46
+ return {};
47
+ }
48
+ /**
49
+ * Create a new ITraceParent instance using the provided values.
50
+ * @param traceId - The traceId to use, when invalid a new random W3C id will be generated.
51
+ * @param spanId - The parent/span id to use, a new random value will be generated if it is invalid.
52
+ * @param flags - The traceFlags to use, defaults to zero (0) if not supplied or invalid
53
+ * @param version - The version to used, defaults to version "01" if not supplied or invalid.
54
+ * @returns
55
+ */
56
+ export function createTraceParent(traceId, spanId, flags, version) {
57
+ return {
58
+ version: _isValid(version, 2, INVALID_VERSION) ? version : DEFAULT_VERSION,
59
+ traceId: isValidTraceId(traceId) ? traceId : generateW3CId(),
60
+ spanId: isValidSpanId(spanId) ? spanId : generateW3CId().substr(0, 16),
61
+ traceFlags: flags >= 0 && flags <= 0xFF ? flags : 1
62
+ };
63
+ }
64
+ /**
65
+ * Attempt to parse the provided string as a W3C TraceParent header value (https://www.w3.org/TR/trace-context/#traceparent-header)
66
+ *
67
+ * @param value
68
+ * @returns
69
+ */
70
+ export function parseTraceParent(value) {
71
+ if (!value) {
72
+ // Don't pass a null/undefined or empty string
73
+ return null;
74
+ }
75
+ if (isArray(value)) {
76
+ // The value may have been encoded on the page into an array so handle this automatically
77
+ value = value[0] || "";
78
+ }
79
+ if (!value || !isString(value) || value.length > 8192) {
80
+ // limit potential processing based on total length
81
+ return null;
82
+ }
83
+ // See https://www.w3.org/TR/trace-context/#versioning-of-traceparent
84
+ var match = TRACE_PARENT_REGEX.exec(strTrim(value));
85
+ if (!match || // No match
86
+ match[1] === INVALID_VERSION || // version ff is forbidden
87
+ match[2] === INVALID_TRACE_ID || // All zeros is considered to be invalid
88
+ match[3] === INVALID_SPAN_ID) { // All zeros is considered to be invalid
89
+ return null;
90
+ }
91
+ return {
92
+ version: match[1],
93
+ traceId: match[2],
94
+ spanId: match[3],
95
+ traceFlags: parseInt(match[4], 16)
96
+ };
97
+ }
98
+ /**
99
+ * Is the provided W3c Trace Id a valid string representation, it must be a 32-character string
100
+ * of lowercase hexadecimal characters for example, 4bf92f3577b34da6a3ce929d0e0e4736.
101
+ * If all characters as zero (00000000000000000000000000000000) it will be considered an invalid value.
102
+ * @param value - The W3c trace Id to be validated
103
+ * @returns true if valid otherwise false
104
+ */
105
+ export function isValidTraceId(value) {
106
+ return _isValid(value, 32, INVALID_TRACE_ID);
107
+ }
108
+ /**
109
+ * Is the provided W3c span id (aka. parent id) a valid string representation, it must be a 16-character
110
+ * string of lowercase hexadecimal characters, for example, 00f067aa0ba902b7.
111
+ * If all characters are zero (0000000000000000) this is considered an invalid value.
112
+ * @param value - The W3c span id to be validated
113
+ * @returns true if valid otherwise false
114
+ */
115
+ export function isValidSpanId(value) {
116
+ return _isValid(value, 16, INVALID_SPAN_ID);
117
+ }
118
+ /**
119
+ * Validates that the provided ITraceParent instance conforms to the currently supported specifications
120
+ * @param value
121
+ * @returns
122
+ */
123
+ export function isValidTraceParent(value) {
124
+ if (!value ||
125
+ !_isValid(value.version, 2, INVALID_VERSION) ||
126
+ !_isValid(value.traceId, 32, INVALID_TRACE_ID) ||
127
+ !_isValid(value.spanId, 16, INVALID_SPAN_ID) ||
128
+ !_isValid(_formatFlags(value.traceFlags), 2)) {
129
+ // Each known field must contain a valid value
130
+ return false;
131
+ }
132
+ return true;
133
+ }
134
+ /**
135
+ * Is the parsed traceParent indicating that the trace is currently sampled.
136
+ * @param value - The parsed traceParent value
137
+ * @returns
138
+ */
139
+ export function isSampledFlag(value) {
140
+ if (isValidTraceParent(value)) {
141
+ return (value.traceFlags & SAMPLED_FLAG) === SAMPLED_FLAG;
142
+ }
143
+ return false;
144
+ }
145
+ /**
146
+ * Format the ITraceParent value as a string using the supported and know version formats.
147
+ * So even if the passed traceParent is a later version the string value returned from this
148
+ * function will convert it to only the known version formats.
149
+ * This currently only supports version "00" and invalid "ff"
150
+ * @param value - The parsed traceParent value
151
+ * @returns
152
+ */
153
+ export function formatTraceParent(value) {
154
+ if (value) {
155
+ // Special Note: This only supports formatting as version 00, future versions should encode any known supported version
156
+ // So parsing a future version will populate the correct version value but reformatting will reduce it to version 00.
157
+ var flags = _formatFlags(value.traceFlags);
158
+ if (!_isValid(flags, 2)) {
159
+ flags = "01";
160
+ }
161
+ var version = value.version || DEFAULT_VERSION;
162
+ if (version !== "00" && version !== "ff") {
163
+ // Reduce version to "00"
164
+ version = DEFAULT_VERSION;
165
+ }
166
+ // Format as version 00
167
+ return "".concat(version, "-").concat(_formatValue(value.traceId, 32, INVALID_TRACE_ID), "-").concat(_formatValue(value.spanId, 16, INVALID_SPAN_ID), "-").concat(flags);
168
+ }
169
+ return "";
170
+ }
171
+ /**
172
+ * Helper function to fetch the passed traceparent from the page, looking for it as a meta-tag or a Server-Timing header.
173
+ * @returns
174
+ */
175
+ export function findW3cTraceParent() {
176
+ var traceParent;
177
+ var doc = getDocument();
178
+ if (doc) {
179
+ // Look for a meta-tag called "traceparent"
180
+ traceParent = parseTraceParent(_getTraceParentValue(doc.querySelectorAll("meta")).content);
181
+ }
182
+ if (!traceParent) {
183
+ var perf = getPerformance();
184
+ if (perf) {
185
+ // Try looking for a server-timing header
186
+ var navPerf = perf.getEntriesByType("navigation") || [];
187
+ traceParent = parseTraceParent(_getTraceParentValue((navPerf.length > 0 ? navPerf[0] : {}).serverTiming).description);
188
+ }
189
+ }
190
+ return traceParent;
191
+ }
192
+ //# sourceMappingURL=W3cTraceParent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"W3cTraceParent.js.map","sources":["W3cTraceParent.js"],"sourcesContent":["import { generateW3CId, getDocument, getPerformance, isArray, isString, strTrim } from \"@microsoft/applicationinsights-core-js\";\r\n// using {0,16} for leading and trailing whitespace just to constrain the possible runtime of a random string\r\nvar TRACE_PARENT_REGEX = /^([\\da-f]{2})-([\\da-f]{32})-([\\da-f]{16})-([\\da-f]{2})(-[^\\s]*)?$/;\r\nvar DEFAULT_VERSION = \"00\";\r\nvar INVALID_VERSION = \"ff\";\r\nvar INVALID_TRACE_ID = \"00000000000000000000000000000000\";\r\nvar INVALID_SPAN_ID = \"0000000000000000\";\r\nvar SAMPLED_FLAG = 0x01;\r\nfunction _isValid(value, len, invalidValue) {\r\n if (value && value.length === len && value !== invalidValue) {\r\n return !!value.match(/^[\\da-f]*$/);\r\n }\r\n return false;\r\n}\r\nfunction _formatValue(value, len, defValue) {\r\n if (_isValid(value, len)) {\r\n return value;\r\n }\r\n return defValue;\r\n}\r\nfunction _formatFlags(value) {\r\n if (isNaN(value) || value < 0 || value > 255) {\r\n value = 0x01;\r\n }\r\n var result = value.toString(16);\r\n while (result.length < 2) {\r\n result = \"0\" + result;\r\n }\r\n return result;\r\n}\r\nfunction _getTraceParentValue(values) {\r\n if (values) {\r\n for (var i = 0; i < values.length; i++) {\r\n var value = values[i];\r\n if (value.name) {\r\n if (value.name === \"traceparent\") {\r\n return value;\r\n }\r\n }\r\n }\r\n }\r\n return {};\r\n}\r\n/**\r\n * Create a new ITraceParent instance using the provided values.\r\n * @param traceId - The traceId to use, when invalid a new random W3C id will be generated.\r\n * @param spanId - The parent/span id to use, a new random value will be generated if it is invalid.\r\n * @param flags - The traceFlags to use, defaults to zero (0) if not supplied or invalid\r\n * @param version - The version to used, defaults to version \"01\" if not supplied or invalid.\r\n * @returns\r\n */\r\nexport function createTraceParent(traceId, spanId, flags, version) {\r\n return {\r\n version: _isValid(version, 2, INVALID_VERSION) ? version : DEFAULT_VERSION,\r\n traceId: isValidTraceId(traceId) ? traceId : generateW3CId(),\r\n spanId: isValidSpanId(spanId) ? spanId : generateW3CId().substr(0, 16),\r\n traceFlags: flags >= 0 && flags <= 0xFF ? flags : 1\r\n };\r\n}\r\n/**\r\n * Attempt to parse the provided string as a W3C TraceParent header value (https://www.w3.org/TR/trace-context/#traceparent-header)\r\n *\r\n * @param value\r\n * @returns\r\n */\r\nexport function parseTraceParent(value) {\r\n if (!value) {\r\n // Don't pass a null/undefined or empty string\r\n return null;\r\n }\r\n if (isArray(value)) {\r\n // The value may have been encoded on the page into an array so handle this automatically\r\n value = value[0] || \"\";\r\n }\r\n if (!value || !isString(value) || value.length > 8192) {\r\n // limit potential processing based on total length\r\n return null;\r\n }\r\n // See https://www.w3.org/TR/trace-context/#versioning-of-traceparent\r\n var match = TRACE_PARENT_REGEX.exec(strTrim(value));\r\n if (!match || // No match\r\n match[1] === INVALID_VERSION || // version ff is forbidden\r\n match[2] === INVALID_TRACE_ID || // All zeros is considered to be invalid\r\n match[3] === INVALID_SPAN_ID) { // All zeros is considered to be invalid\r\n return null;\r\n }\r\n return {\r\n version: match[1],\r\n traceId: match[2],\r\n spanId: match[3],\r\n traceFlags: parseInt(match[4], 16)\r\n };\r\n}\r\n/**\r\n * Is the provided W3c Trace Id a valid string representation, it must be a 32-character string\r\n * of lowercase hexadecimal characters for example, 4bf92f3577b34da6a3ce929d0e0e4736.\r\n * If all characters as zero (00000000000000000000000000000000) it will be considered an invalid value.\r\n * @param value - The W3c trace Id to be validated\r\n * @returns true if valid otherwise false\r\n */\r\nexport function isValidTraceId(value) {\r\n return _isValid(value, 32, INVALID_TRACE_ID);\r\n}\r\n/**\r\n * Is the provided W3c span id (aka. parent id) a valid string representation, it must be a 16-character\r\n * string of lowercase hexadecimal characters, for example, 00f067aa0ba902b7.\r\n * If all characters are zero (0000000000000000) this is considered an invalid value.\r\n * @param value - The W3c span id to be validated\r\n * @returns true if valid otherwise false\r\n */\r\nexport function isValidSpanId(value) {\r\n return _isValid(value, 16, INVALID_SPAN_ID);\r\n}\r\n/**\r\n * Validates that the provided ITraceParent instance conforms to the currently supported specifications\r\n * @param value\r\n * @returns\r\n */\r\nexport function isValidTraceParent(value) {\r\n if (!value ||\r\n !_isValid(value.version, 2, INVALID_VERSION) ||\r\n !_isValid(value.traceId, 32, INVALID_TRACE_ID) ||\r\n !_isValid(value.spanId, 16, INVALID_SPAN_ID) ||\r\n !_isValid(_formatFlags(value.traceFlags), 2)) {\r\n // Each known field must contain a valid value\r\n return false;\r\n }\r\n return true;\r\n}\r\n/**\r\n * Is the parsed traceParent indicating that the trace is currently sampled.\r\n * @param value - The parsed traceParent value\r\n * @returns\r\n */\r\nexport function isSampledFlag(value) {\r\n if (isValidTraceParent(value)) {\r\n return (value.traceFlags & SAMPLED_FLAG) === SAMPLED_FLAG;\r\n }\r\n return false;\r\n}\r\n/**\r\n * Format the ITraceParent value as a string using the supported and know version formats.\r\n * So even if the passed traceParent is a later version the string value returned from this\r\n * function will convert it to only the known version formats.\r\n * This currently only supports version \"00\" and invalid \"ff\"\r\n * @param value - The parsed traceParent value\r\n * @returns\r\n */\r\nexport function formatTraceParent(value) {\r\n if (value) {\r\n // Special Note: This only supports formatting as version 00, future versions should encode any known supported version\r\n // So parsing a future version will populate the correct version value but reformatting will reduce it to version 00.\r\n var flags = _formatFlags(value.traceFlags);\r\n if (!_isValid(flags, 2)) {\r\n flags = \"01\";\r\n }\r\n var version = value.version || DEFAULT_VERSION;\r\n if (version !== \"00\" && version !== \"ff\") {\r\n // Reduce version to \"00\"\r\n version = DEFAULT_VERSION;\r\n }\r\n // Format as version 00\r\n return \"\".concat(version, \"-\").concat(_formatValue(value.traceId, 32, INVALID_TRACE_ID), \"-\").concat(_formatValue(value.spanId, 16, INVALID_SPAN_ID), \"-\").concat(flags);\r\n }\r\n return \"\";\r\n}\r\n/**\r\n * Helper function to fetch the passed traceparent from the page, looking for it as a meta-tag or a Server-Timing header.\r\n * @returns\r\n */\r\nexport function findW3cTraceParent() {\r\n var traceParent;\r\n var doc = getDocument();\r\n if (doc) {\r\n // Look for a meta-tag called \"traceparent\"\r\n traceParent = parseTraceParent(_getTraceParentValue(doc.querySelectorAll(\"meta\")).content);\r\n }\r\n if (!traceParent) {\r\n var perf = getPerformance();\r\n if (perf) {\r\n // Try looking for a server-timing header\r\n var navPerf = perf.getEntriesByType(\"navigation\") || [];\r\n traceParent = parseTraceParent(_getTraceParentValue((navPerf.length > 0 ? navPerf[0] : {}).serverTiming).description);\r\n }\r\n }\r\n return traceParent;\r\n}\r\n//# sourceMappingURL=W3cTraceParent.js.map"],"names":[],"mappings":";;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA"}
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Application Insights JavaScript SDK - Common, 2.8.0-nightly.2204-04
2
+ * Application Insights JavaScript SDK - Common, 2.8.0-nightly.2204-07
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  */
5
5
 
@@ -21,7 +21,7 @@ export { SeverityLevel } from "./Interfaces/Contracts/SeverityLevel";
21
21
  export { ConfigurationManager } from "./Interfaces/IConfig";
22
22
  export { ContextTagKeys } from "./Interfaces/Contracts/ContextTagKeys";
23
23
  export { DataSanitizer, dataSanitizeKeyAndAddUniqueness, dataSanitizeKey, dataSanitizeString, dataSanitizeUrl, dataSanitizeMessage, dataSanitizeException, dataSanitizeProperties, dataSanitizeMeasurements, dataSanitizeId, dataSanitizeInput, dsPadNumber } from "./Telemetry/Common/DataSanitizer";
24
- export { TelemetryItemCreator } from "./TelemetryItemCreator";
24
+ export { TelemetryItemCreator, createTelemetryItem } from "./TelemetryItemCreator";
25
25
  export { CtxTagKeys, Extensions } from "./Interfaces/PartAExtensions";
26
26
  export { DistributedTracingModes } from "./Enums";
27
27
  export { stringToBoolOrDefault, msToTimeSpan, getExtensionByName, isCrossOriginError } from "./HelperFuncs";
@@ -29,6 +29,7 @@ export { isBeaconsSupported as isBeaconApiSupported } from "@microsoft/applicati
29
29
  export { createDomEvent } from "./DomHelperFuncs";
30
30
  export { utlDisableStorage, utlEnableStorage, utlCanUseLocalStorage, utlGetLocalStorage, utlSetLocalStorage, utlRemoveStorage, utlCanUseSessionStorage, utlGetSessionStorageKeys, utlGetSessionStorage, utlSetSessionStorage, utlRemoveSessionStorage } from "./StorageHelperFuncs";
31
31
  export { urlParseUrl, urlGetAbsoluteUrl, urlGetPathName, urlGetCompleteUrl, urlParseHost, urlParseFullHost } from "./UrlHelperFuncs";
32
+ export { createTraceParent, parseTraceParent, isValidTraceId, isValidSpanId, isValidTraceParent, isSampledFlag, formatTraceParent, findW3cTraceParent } from "./W3cTraceParent";
32
33
  export var PropertiesPluginIdentifier = "AppInsightsPropertiesPlugin";
33
34
  export var BreezeChannelIdentifier = "AppInsightsChannelPlugin";
34
35
  export var AnalyticsPluginIdentifier = "ApplicationInsightsAnalytics";
@@ -1 +1 @@
1
- {"version":3,"file":"applicationinsights-common.js.map","sources":["applicationinsights-common.js"],"sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the\r\nexport { Util, CorrelationIdHelper, DateTimeUtils, dateTimeUtilsNow, dateTimeUtilsDuration, UrlHelper, isInternalApplicationInsightsEndpoint } from \"./Util\";\r\nexport { parseConnectionString, ConnectionStringParser } from \"./ConnectionStringParser\";\r\nexport { RequestHeaders } from \"./RequestResponseHeaders\";\r\nexport { DisabledPropertyName, ProcessLegacy, SampleRate, HttpMethod, DEFAULT_BREEZE_ENDPOINT, strNotSpecified } from \"./Constants\";\r\nexport { Envelope } from \"./Telemetry/Common/Envelope\";\r\nexport { Event } from \"./Telemetry/Event\";\r\nexport { Exception } from \"./Telemetry/Exception\";\r\nexport { Metric } from \"./Telemetry/Metric\";\r\nexport { PageView } from \"./Telemetry/PageView\";\r\nexport { RemoteDependencyData } from \"./Telemetry/RemoteDependencyData\";\r\nexport { Trace } from \"./Telemetry/Trace\";\r\nexport { PageViewPerformance } from \"./Telemetry/PageViewPerformance\";\r\nexport { Data } from \"./Telemetry/Common/Data\";\r\nexport { SeverityLevel } from \"./Interfaces/Contracts/SeverityLevel\";\r\nexport { ConfigurationManager } from \"./Interfaces/IConfig\";\r\nexport { ContextTagKeys } from \"./Interfaces/Contracts/ContextTagKeys\";\r\nexport { DataSanitizer, dataSanitizeKeyAndAddUniqueness, dataSanitizeKey, dataSanitizeString, dataSanitizeUrl, dataSanitizeMessage, dataSanitizeException, dataSanitizeProperties, dataSanitizeMeasurements, dataSanitizeId, dataSanitizeInput, dsPadNumber } from \"./Telemetry/Common/DataSanitizer\";\r\nexport { TelemetryItemCreator } from \"./TelemetryItemCreator\";\r\nexport { CtxTagKeys, Extensions } from \"./Interfaces/PartAExtensions\";\r\nexport { DistributedTracingModes } from \"./Enums\";\r\nexport { stringToBoolOrDefault, msToTimeSpan, getExtensionByName, isCrossOriginError } from \"./HelperFuncs\";\r\nexport { isBeaconsSupported as isBeaconApiSupported } from \"@microsoft/applicationinsights-core-js\";\r\nexport { createDomEvent } from \"./DomHelperFuncs\";\r\nexport { utlDisableStorage, utlEnableStorage, utlCanUseLocalStorage, utlGetLocalStorage, utlSetLocalStorage, utlRemoveStorage, utlCanUseSessionStorage, utlGetSessionStorageKeys, utlGetSessionStorage, utlSetSessionStorage, utlRemoveSessionStorage } from \"./StorageHelperFuncs\";\r\nexport { urlParseUrl, urlGetAbsoluteUrl, urlGetPathName, urlGetCompleteUrl, urlParseHost, urlParseFullHost } from \"./UrlHelperFuncs\";\r\nexport var PropertiesPluginIdentifier = \"AppInsightsPropertiesPlugin\";\r\nexport var BreezeChannelIdentifier = \"AppInsightsChannelPlugin\";\r\nexport var AnalyticsPluginIdentifier = \"ApplicationInsightsAnalytics\";\r\n//# sourceMappingURL=applicationinsights-common.js.map"],"names":[],"mappings":";;;;AAA4D;AAC5D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA"}
1
+ {"version":3,"file":"applicationinsights-common.js.map","sources":["applicationinsights-common.js"],"sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the\r\nexport { Util, CorrelationIdHelper, DateTimeUtils, dateTimeUtilsNow, dateTimeUtilsDuration, UrlHelper, isInternalApplicationInsightsEndpoint } from \"./Util\";\r\nexport { parseConnectionString, ConnectionStringParser } from \"./ConnectionStringParser\";\r\nexport { RequestHeaders } from \"./RequestResponseHeaders\";\r\nexport { DisabledPropertyName, ProcessLegacy, SampleRate, HttpMethod, DEFAULT_BREEZE_ENDPOINT, strNotSpecified } from \"./Constants\";\r\nexport { Envelope } from \"./Telemetry/Common/Envelope\";\r\nexport { Event } from \"./Telemetry/Event\";\r\nexport { Exception } from \"./Telemetry/Exception\";\r\nexport { Metric } from \"./Telemetry/Metric\";\r\nexport { PageView } from \"./Telemetry/PageView\";\r\nexport { RemoteDependencyData } from \"./Telemetry/RemoteDependencyData\";\r\nexport { Trace } from \"./Telemetry/Trace\";\r\nexport { PageViewPerformance } from \"./Telemetry/PageViewPerformance\";\r\nexport { Data } from \"./Telemetry/Common/Data\";\r\nexport { SeverityLevel } from \"./Interfaces/Contracts/SeverityLevel\";\r\nexport { ConfigurationManager } from \"./Interfaces/IConfig\";\r\nexport { ContextTagKeys } from \"./Interfaces/Contracts/ContextTagKeys\";\r\nexport { DataSanitizer, dataSanitizeKeyAndAddUniqueness, dataSanitizeKey, dataSanitizeString, dataSanitizeUrl, dataSanitizeMessage, dataSanitizeException, dataSanitizeProperties, dataSanitizeMeasurements, dataSanitizeId, dataSanitizeInput, dsPadNumber } from \"./Telemetry/Common/DataSanitizer\";\r\nexport { TelemetryItemCreator, createTelemetryItem } from \"./TelemetryItemCreator\";\r\nexport { CtxTagKeys, Extensions } from \"./Interfaces/PartAExtensions\";\r\nexport { DistributedTracingModes } from \"./Enums\";\r\nexport { stringToBoolOrDefault, msToTimeSpan, getExtensionByName, isCrossOriginError } from \"./HelperFuncs\";\r\nexport { isBeaconsSupported as isBeaconApiSupported } from \"@microsoft/applicationinsights-core-js\";\r\nexport { createDomEvent } from \"./DomHelperFuncs\";\r\nexport { utlDisableStorage, utlEnableStorage, utlCanUseLocalStorage, utlGetLocalStorage, utlSetLocalStorage, utlRemoveStorage, utlCanUseSessionStorage, utlGetSessionStorageKeys, utlGetSessionStorage, utlSetSessionStorage, utlRemoveSessionStorage } from \"./StorageHelperFuncs\";\r\nexport { urlParseUrl, urlGetAbsoluteUrl, urlGetPathName, urlGetCompleteUrl, urlParseHost, urlParseFullHost } from \"./UrlHelperFuncs\";\r\nexport { createTraceParent, parseTraceParent, isValidTraceId, isValidSpanId, isValidTraceParent, isSampledFlag, formatTraceParent, findW3cTraceParent } from \"./W3cTraceParent\";\r\nexport var PropertiesPluginIdentifier = \"AppInsightsPropertiesPlugin\";\r\nexport var BreezeChannelIdentifier = \"AppInsightsChannelPlugin\";\r\nexport var AnalyticsPluginIdentifier = \"ApplicationInsightsAnalytics\";\r\n//# sourceMappingURL=applicationinsights-common.js.map"],"names":[],"mappings":";;;;AAA4D;AAC5D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@microsoft/applicationinsights-common",
3
- "version": "2.8.0-nightly.2204-04",
3
+ "version": "2.8.0-nightly.2204-07",
4
4
  "description": "Microsoft Application Insights Common JavaScript Library",
5
5
  "homepage": "https://github.com/microsoft/ApplicationInsights-JS#readme",
6
6
  "author": "Microsoft Application Insights Team",
@@ -47,7 +47,7 @@
47
47
  },
48
48
  "dependencies": {
49
49
  "@microsoft/applicationinsights-shims": "2.0.1",
50
- "@microsoft/applicationinsights-core-js": "2.8.0-nightly.2204-04",
50
+ "@microsoft/applicationinsights-core-js": "2.8.0-nightly.2204-07",
51
51
  "@microsoft/dynamicproto-js": "^1.1.4"
52
52
  },
53
53
  "license": "MIT",
package/src/Enums.ts CHANGED
@@ -11,13 +11,12 @@ export const enum eStorageType {
11
11
  SessionStorage
12
12
  }
13
13
 
14
- export const StorageType = createEnumStyle<{ [key in (keyof typeof eStorageType)]: number; }>({
14
+ export const StorageType = createEnumStyle<typeof eStorageType>({
15
15
  LocalStorage: eStorageType.LocalStorage,
16
16
  SessionStorage: eStorageType.SessionStorage
17
17
  });
18
18
  export type StorageType = eStorageType | typeof StorageType;
19
19
 
20
-
21
20
  /**
22
21
  * Enum is used in aiDataContract to describe how fields are serialized.
23
22
  * For instance: (Fieldtype.Required | FieldType.Array) will mark the field as required and indicate it's an array
@@ -42,7 +41,7 @@ export const enum eDistributedTracingModes {
42
41
  W3C
43
42
  }
44
43
 
45
- export const DistributedTracingModes = createEnumStyle<{ [key in (keyof typeof eDistributedTracingModes)]: number; }>({
44
+ export const DistributedTracingModes = createEnumStyle<typeof eDistributedTracingModes>({
46
45
  AI: eDistributedTracingModes.AI,
47
46
  AI_AND_W3C: eDistributedTracingModes.AI_AND_W3C,
48
47
  W3C: eDistributedTracingModes.W3C
@@ -1,15 +1,28 @@
1
1
  // Copyright (c) Microsoft Corporation. All rights reserved.
2
2
  // Licensed under the MIT License.
3
3
 
4
- // THIS FILE WAS AUTOGENERATED
4
+ import { createEnumStyle } from "@microsoft/applicationinsights-core-js";
5
5
 
6
6
  /**
7
7
  * Defines the level of severity for the event.
8
8
  */
9
- export enum SeverityLevel {
9
+ export const enum eSeverityLevel {
10
10
  Verbose = 0,
11
11
  Information = 1,
12
12
  Warning = 2,
13
13
  Error = 3,
14
14
  Critical = 4,
15
15
  }
16
+
17
+ /**
18
+ * Defines the level of severity for the event.
19
+ */
20
+ export const SeverityLevel = createEnumStyle<typeof eSeverityLevel>({
21
+ Verbose: eSeverityLevel.Verbose,
22
+ Information: eSeverityLevel.Information,
23
+ Warning: eSeverityLevel.Warning,
24
+ Error: eSeverityLevel.Error,
25
+ Critical: eSeverityLevel.Critical
26
+ });
27
+
28
+ export type SeverityLevel = number | eSeverityLevel;
@@ -171,7 +171,7 @@ export interface IConfig {
171
171
  enableSessionStorageBuffer?: boolean;
172
172
 
173
173
  /**
174
- * @deprecated Use either disableCookiesUsage or specify a cookieMgrCfg with the enabled value set.
174
+ * @deprecated Use either disableCookiesUsage or specify a cookieCfg with the enabled value set.
175
175
  * If true, the SDK will not store or read any data from cookies. Default is false. As this field is being deprecated, when both
176
176
  * isCookieUseDisabled and disableCookiesUsage are used disableCookiesUsage will take precedent.
177
177
  * @defaultValue false
@@ -180,7 +180,7 @@ export interface IConfig {
180
180
 
181
181
  /**
182
182
  * If true, the SDK will not store or read any data from cookies. Default is false.
183
- * If you have also specified a cookieMgrCfg then enabled property (if specified) will take precedent over this value.
183
+ * If you have also specified a cookieCfg then enabled property (if specified) will take precedent over this value.
184
184
  * @defaultValue false
185
185
  */
186
186
  disableCookiesUsage?: boolean;
@@ -197,13 +197,6 @@ export interface IConfig {
197
197
  */
198
198
  cookiePath?: string;
199
199
 
200
- /**
201
- * [Optional] A Cookie Manager configuration which includes hooks to allow interception of the get, set and delete cookie
202
- * operations. If this configuration is specified any specified enabled and domain properties will take precedence over the
203
- * cookieDomain and disableCookiesUsage values.
204
- */
205
- cookieMgrCfg?: ICookieMgrConfig;
206
-
207
200
  /**
208
201
  * Default false. If false, retry on 206 (partial success), 408 (timeout), 429 (too many requests), 500 (internal server error), 503 (service unavailable), and 0 (offline, only if detected)
209
202
  * @description
@@ -0,0 +1,38 @@
1
+ // Copyright (c) Microsoft Corporation. All rights reserved.
2
+ // Licensed under the MIT License.
3
+
4
+ /**
5
+ * This interface represents the components of a W3C traceparent header
6
+ */
7
+ export interface ITraceParent {
8
+ /**
9
+ * The version of the definition, this MUST be a string with a length of 2 and only contain lowercase
10
+ * hexadecimal characters. A value of 'ff' is considered to be an invalid version.
11
+ */
12
+ version: string;
13
+
14
+ /**
15
+ * This is the ID of the whole trace forest and is used to uniquely identify a distributed trace
16
+ * through a system. It is represented as a 32-character string of lowercase hexadecimal characters,
17
+ * for example, 4bf92f3577b34da6a3ce929d0e0e4736.
18
+ * All characters as zero (00000000000000000000000000000000) is considered an invalid value.
19
+ */
20
+ traceId: string;
21
+
22
+ /**
23
+ * This is the ID of the current request as known by the caller (in some tracing systems, this is also
24
+ * known as the parent-id, where a span is the execution of a client request). It is represented as an
25
+ * 16-character string of lowercase hexadecimal characters, for example, 00f067aa0ba902b7.
26
+ * All bytes as zero (0000000000000000) is considered an invalid value.
27
+ */
28
+ spanId: string;
29
+
30
+ /**
31
+ * An 8-bit value of flags that controls tracing such as sampling, trace level, etc. These flags are
32
+ * recommendations given by the caller rather than strict rules to follow.
33
+ * As this is a bit field, you cannot interpret flags by decoding the hex value and looking at the resulting
34
+ * number. For example, a flag 00000001 could be encoded as 01 in hex, or 09 in hex if present with the flag
35
+ * 00001000. A common mistake in bit fields is forgetting to mask when interpreting flags.
36
+ */
37
+ traceFlags: number;
38
+ }
@@ -1,6 +1,8 @@
1
1
  // Copyright (c) Microsoft Corporation. All rights reserved.
2
2
  // Licensed under the MIT License.
3
3
 
4
+ import { createValueMap } from "@microsoft/applicationinsights-core-js";
5
+
4
6
  export interface IRequestHeaders {
5
7
  /**
6
8
  * Request-Context header
@@ -47,7 +49,30 @@ export interface IRequestHeaders {
47
49
  requestContextHeaderLowerCase: string
48
50
  }
49
51
 
50
- export const RequestHeaders: IRequestHeaders = {
52
+ export const enum eRequestHeaders {
53
+ requestContextHeader = 0,
54
+ requestContextTargetKey = 1,
55
+ requestContextAppIdFormat = 2,
56
+ requestIdHeader = 3,
57
+ traceParentHeader = 4,
58
+ traceStateHeader = 5, // currently not used
59
+ sdkContextHeader = 6,
60
+ sdkContextHeaderAppIdRequest = 7,
61
+ requestContextHeaderLowerCase = 8
62
+ }
63
+
64
+ export const RequestHeaders = createValueMap<typeof eRequestHeaders, IRequestHeaders & {
65
+ // Defined the enum lookups
66
+ [eRequestHeaders.requestContextHeader]: "Request-Context",
67
+ [eRequestHeaders.requestContextTargetKey]: "appId",
68
+ [eRequestHeaders.requestContextAppIdFormat]: "appId=cid-v1:",
69
+ [eRequestHeaders.requestIdHeader]: "Request-Id",
70
+ [eRequestHeaders.traceParentHeader]: "traceparent",
71
+ [eRequestHeaders.traceStateHeader]: "tracestate", // currently not used
72
+ [eRequestHeaders.sdkContextHeader]: "Sdk-Context",
73
+ [eRequestHeaders.sdkContextHeaderAppIdRequest]: "appId",
74
+ [eRequestHeaders.requestContextHeaderLowerCase]: "request-context",
75
+ // Defined Named reference
51
76
  requestContextHeader: "Request-Context",
52
77
  requestContextTargetKey: "appId",
53
78
  requestContextAppIdFormat: "appId=cid-v1:",
@@ -57,4 +82,15 @@ export const RequestHeaders: IRequestHeaders = {
57
82
  sdkContextHeader: "Sdk-Context",
58
83
  sdkContextHeaderAppIdRequest: "appId",
59
84
  requestContextHeaderLowerCase: "request-context"
60
- };
85
+ }>({
86
+ requestContextHeader: [ eRequestHeaders.requestContextHeader, "Request-Context" ],
87
+ requestContextTargetKey: [ eRequestHeaders.requestContextTargetKey, "appId"],
88
+ requestContextAppIdFormat: [ eRequestHeaders.requestContextAppIdFormat, "appId=cid-v1:"],
89
+ requestIdHeader: [ eRequestHeaders.requestIdHeader, "Request-Id"],
90
+ traceParentHeader: [ eRequestHeaders.traceParentHeader, "traceparent"],
91
+ traceStateHeader: [ eRequestHeaders.traceStateHeader, "tracestate"], // currently not used
92
+ sdkContextHeader: [ eRequestHeaders.sdkContextHeader, "Sdk-Context"],
93
+ sdkContextHeaderAppIdRequest: [ eRequestHeaders.sdkContextHeaderAppIdRequest, "appId"],
94
+ requestContextHeaderLowerCase: [ eRequestHeaders.requestContextHeaderLowerCase, "request-context"]
95
+ });
96
+
@@ -1,7 +1,7 @@
1
1
  // Copyright (c) Microsoft Corporation. All rights reserved.
2
2
  // Licensed under the MIT License.
3
3
 
4
- import { dumpObj, getExceptionName, getGlobal, getGlobalInst, IDiagnosticLogger, isNullOrUndefined, eLoggingSeverity, objForEachKey, _InternalMessageId, _throwInternal } from "@microsoft/applicationinsights-core-js";
4
+ import { dumpObj, getExceptionName, getGlobal, getGlobalInst, IDiagnosticLogger, isNullOrUndefined, eLoggingSeverity, objForEachKey, _eInternalMessageId, _throwInternal } from "@microsoft/applicationinsights-core-js";
5
5
  import { StorageType } from "./Enums";
6
6
 
7
7
  let _canUseLocalStorage: boolean = undefined;
@@ -30,11 +30,11 @@ function _getVerifiedStorageObject(storageType: StorageType): Storage {
30
30
  if (isNullOrUndefined(getGlobal())) {
31
31
  return null;
32
32
  }
33
- let uid = new Date;
33
+ let uid = (new Date).toString();
34
34
  let storage: Storage = getGlobalInst(storageType === StorageType.LocalStorage ? "localStorage" : "sessionStorage");
35
- storage.setItem(uid.toString(), uid.toString());
36
- let fail = storage.getItem(uid.toString()) !== uid.toString();
37
- storage.removeItem(uid.toString());
35
+ storage.setItem(uid, uid);
36
+ let fail = storage.getItem(uid) !== uid;
37
+ storage.removeItem(uid);
38
38
  if (!fail) {
39
39
  return storage;
40
40
  }
@@ -96,7 +96,7 @@ export function utlGetLocalStorage(logger: IDiagnosticLogger, name: string): str
96
96
 
97
97
  _throwInternal(logger,
98
98
  eLoggingSeverity.WARNING,
99
- _InternalMessageId.BrowserCannotReadLocalStorage,
99
+ _eInternalMessageId.BrowserCannotReadLocalStorage,
100
100
  "Browser failed read of local storage. " + getExceptionName(e),
101
101
  { exception: dumpObj(e) });
102
102
  }
@@ -115,7 +115,7 @@ export function utlSetLocalStorage(logger: IDiagnosticLogger, name: string, data
115
115
 
116
116
  _throwInternal(logger,
117
117
  eLoggingSeverity.WARNING,
118
- _InternalMessageId.BrowserCannotWriteLocalStorage,
118
+ _eInternalMessageId.BrowserCannotWriteLocalStorage,
119
119
  "Browser failed write to local storage. " + getExceptionName(e),
120
120
  { exception: dumpObj(e) });
121
121
  }
@@ -134,7 +134,7 @@ export function utlRemoveStorage(logger: IDiagnosticLogger, name: string): boole
134
134
 
135
135
  _throwInternal(logger,
136
136
  eLoggingSeverity.WARNING,
137
- _InternalMessageId.BrowserFailedRemovalFromLocalStorage,
137
+ _eInternalMessageId.BrowserFailedRemovalFromLocalStorage,
138
138
  "Browser failed removal of local storage item. " + getExceptionName(e),
139
139
  { exception: dumpObj(e) });
140
140
  }
@@ -172,7 +172,7 @@ export function utlGetSessionStorage(logger: IDiagnosticLogger, name: string): s
172
172
 
173
173
  _throwInternal(logger,
174
174
  eLoggingSeverity.WARNING,
175
- _InternalMessageId.BrowserCannotReadSessionStorage,
175
+ _eInternalMessageId.BrowserCannotReadSessionStorage,
176
176
  "Browser failed read of session storage. " + getExceptionName(e),
177
177
  { exception: dumpObj(e) });
178
178
  }
@@ -191,7 +191,7 @@ export function utlSetSessionStorage(logger: IDiagnosticLogger, name: string, da
191
191
 
192
192
  _throwInternal(logger,
193
193
  eLoggingSeverity.WARNING,
194
- _InternalMessageId.BrowserCannotWriteSessionStorage,
194
+ _eInternalMessageId.BrowserCannotWriteSessionStorage,
195
195
  "Browser failed write to session storage. " + getExceptionName(e),
196
196
  { exception: dumpObj(e) });
197
197
  }
@@ -210,7 +210,7 @@ export function utlRemoveSessionStorage(logger: IDiagnosticLogger, name: string)
210
210
 
211
211
  _throwInternal(logger,
212
212
  eLoggingSeverity.WARNING,
213
- _InternalMessageId.BrowserFailedRemovalFromSessionStorage,
213
+ _eInternalMessageId.BrowserFailedRemovalFromSessionStorage,
214
214
  "Browser failed removal of session storage item. " + getExceptionName(e),
215
215
  { exception: dumpObj(e) });
216
216
  }