@microsoft/applicationinsights-channel-js 3.4.0-nightlybeta3.2505-35 → 3.4.0-nightlybeta3.2507-23

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 (55) hide show
  1. package/browser/es5/{applicationinsights-channel-js.3.4.0-nightlybeta3.2505-35.js → applicationinsights-channel-js.3.4.0-nightlybeta3.2507-23.cjs.js} +138 -56
  2. package/browser/es5/applicationinsights-channel-js.3.4.0-nightlybeta3.2507-23.cjs.js.map +1 -0
  3. package/browser/es5/applicationinsights-channel-js.3.4.0-nightlybeta3.2507-23.cjs.min.js +6 -0
  4. package/browser/es5/applicationinsights-channel-js.3.4.0-nightlybeta3.2507-23.cjs.min.js.map +1 -0
  5. package/browser/es5/{applicationinsights-channel-js.3.4.0-nightlybeta3.2505-35.gbl.js → applicationinsights-channel-js.3.4.0-nightlybeta3.2507-23.gbl.js} +140 -31
  6. package/browser/es5/applicationinsights-channel-js.3.4.0-nightlybeta3.2507-23.gbl.js.map +1 -0
  7. package/browser/es5/applicationinsights-channel-js.3.4.0-nightlybeta3.2507-23.gbl.min.js +6 -0
  8. package/browser/es5/applicationinsights-channel-js.3.4.0-nightlybeta3.2507-23.gbl.min.js.map +1 -0
  9. package/browser/es5/applicationinsights-channel-js.3.4.0-nightlybeta3.2507-23.integrity.json +66 -0
  10. package/browser/es5/{applicationinsights-channel-js.3.4.0-nightlybeta3.2505-35.cjs.js → applicationinsights-channel-js.3.4.0-nightlybeta3.2507-23.js} +165 -29
  11. package/browser/es5/applicationinsights-channel-js.3.4.0-nightlybeta3.2507-23.js.map +1 -0
  12. package/browser/es5/applicationinsights-channel-js.3.4.0-nightlybeta3.2507-23.min.js +6 -0
  13. package/browser/es5/applicationinsights-channel-js.3.4.0-nightlybeta3.2507-23.min.js.map +1 -0
  14. package/browser/es5/applicationinsights-channel-js.3.cjs.js +137 -28
  15. package/browser/es5/applicationinsights-channel-js.3.cjs.js.map +1 -1
  16. package/browser/es5/applicationinsights-channel-js.3.cjs.min.js +2 -2
  17. package/browser/es5/applicationinsights-channel-js.3.cjs.min.js.map +1 -1
  18. package/browser/es5/applicationinsights-channel-js.3.gbl.js +139 -30
  19. package/browser/es5/applicationinsights-channel-js.3.gbl.js.map +1 -1
  20. package/browser/es5/applicationinsights-channel-js.3.gbl.min.js +2 -2
  21. package/browser/es5/applicationinsights-channel-js.3.gbl.min.js.map +1 -1
  22. package/browser/es5/applicationinsights-channel-js.3.integrity.json +25 -25
  23. package/browser/es5/applicationinsights-channel-js.3.js +139 -30
  24. package/browser/es5/applicationinsights-channel-js.3.js.map +1 -1
  25. package/browser/es5/applicationinsights-channel-js.3.min.js +2 -2
  26. package/browser/es5/applicationinsights-channel-js.3.min.js.map +1 -1
  27. package/dist/es5/applicationinsights-channel-js.js +137 -28
  28. package/dist/es5/applicationinsights-channel-js.js.map +1 -1
  29. package/dist/es5/applicationinsights-channel-js.min.js +2 -2
  30. package/dist/es5/applicationinsights-channel-js.min.js.map +1 -1
  31. package/dist-es5/EnvelopeCreator.js +2 -2
  32. package/dist-es5/EnvelopeCreator.js.map +1 -1
  33. package/dist-es5/Interfaces.js +1 -1
  34. package/dist-es5/InternalConstants.js +1 -1
  35. package/dist-es5/SendBuffer.js +1 -1
  36. package/dist-es5/Sender.js +1 -1
  37. package/dist-es5/Serializer.js +1 -1
  38. package/dist-es5/TelemetryProcessors/Sample.js +1 -1
  39. package/dist-es5/TelemetryProcessors/SamplingScoreGenerators/HashCodeScoreGenerator.js +1 -1
  40. package/dist-es5/TelemetryProcessors/SamplingScoreGenerators/SamplingScoreGenerator.js +1 -1
  41. package/dist-es5/__DynamicConstants.js +1 -1
  42. package/dist-es5/applicationinsights-channel-js.js +1 -1
  43. package/package.json +3 -3
  44. package/types/applicationinsights-channel-js.d.ts +1 -1
  45. package/types/applicationinsights-channel-js.namespaced.d.ts +283 -14
  46. package/browser/es5/applicationinsights-channel-js.3.4.0-nightlybeta3.2505-35.cjs.js.map +0 -1
  47. package/browser/es5/applicationinsights-channel-js.3.4.0-nightlybeta3.2505-35.cjs.min.js +0 -6
  48. package/browser/es5/applicationinsights-channel-js.3.4.0-nightlybeta3.2505-35.cjs.min.js.map +0 -1
  49. package/browser/es5/applicationinsights-channel-js.3.4.0-nightlybeta3.2505-35.gbl.js.map +0 -1
  50. package/browser/es5/applicationinsights-channel-js.3.4.0-nightlybeta3.2505-35.gbl.min.js +0 -6
  51. package/browser/es5/applicationinsights-channel-js.3.4.0-nightlybeta3.2505-35.gbl.min.js.map +0 -1
  52. package/browser/es5/applicationinsights-channel-js.3.4.0-nightlybeta3.2505-35.integrity.json +0 -66
  53. package/browser/es5/applicationinsights-channel-js.3.4.0-nightlybeta3.2505-35.js.map +0 -1
  54. package/browser/es5/applicationinsights-channel-js.3.4.0-nightlybeta3.2505-35.min.js +0 -6
  55. package/browser/es5/applicationinsights-channel-js.3.4.0-nightlybeta3.2505-35.min.js.map +0 -1
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Application Insights JavaScript SDK - Channel, 3.4.0-nightlybeta3.2505-35
2
+ * Application Insights JavaScript SDK - Channel, 3.4.0-nightlybeta3.2507-23
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  */
5
5
  import { __assignFn as __assign } from "@microsoft/applicationinsights-shims";
@@ -146,7 +146,7 @@ function EnvelopeCreatorInit(logger, telemetryItem) {
146
146
  }
147
147
  }
148
148
  export var EnvelopeCreator = {
149
- Version: '3.4.0-nightlybeta3.2505-35'
149
+ Version: '3.4.0-nightlybeta3.2507-23'
150
150
  };
151
151
  export function DependencyEnvelopeCreator(logger, telemetryItem, customUndefinedValue) {
152
152
  EnvelopeCreatorInit(logger, telemetryItem);
@@ -1 +1 @@
1
- {"version":3,"file":"EnvelopeCreator.js.map","sources":["EnvelopeCreator.js"],"sourcesContent":["import { __assign } from \"tslib\";\r\nimport { CtxTagKeys, Data, Envelope, Event, Exception, HttpMethod, Metric, PageView, PageViewPerformance, RemoteDependencyData, SampleRate, Trace, dataSanitizeString } from \"@microsoft/applicationinsights-common\";\r\nimport { _throwInternal, _warnToConsole, getJSON, hasJSON, isNullOrUndefined, isNumber, isString, isTruthy, objForEachKey, optimizeObject, setValue, toISOString } from \"@microsoft/applicationinsights-core-js\";\r\nimport { STR_DURATION } from \"./InternalConstants\";\r\nimport { _DYN_DATA, _DYN_DATA_TYPE, _DYN_DEVICE_TYPE, _DYN_ENVELOPE_TYPE, _DYN_LENGTH, _DYN_MEASUREMENTS, _DYN_NAME, _DYN_STRINGIFY, _DYN_TAGS, _DYN_TO_STRING, _DYN_TRACE_ID } from \"./__DynamicConstants\";\r\n// these two constants are used to filter out properties not needed when trying to extract custom properties and measurements from the incoming payload\r\nvar strBaseType = \"baseType\";\r\nvar strBaseData = \"baseData\";\r\nvar strProperties = \"properties\";\r\nvar strTrue = \"true\";\r\nfunction _setValueIf(target, field, value) {\r\n return setValue(target, field, value, isTruthy);\r\n}\r\n/*\r\n * Maps Part A data from CS 4.0\r\n */\r\nfunction _extractPartAExtensions(logger, item, env) {\r\n // todo: switch to keys from common in this method\r\n var envTags = env[_DYN_TAGS /* @min:%2etags */] = env[_DYN_TAGS /* @min:%2etags */] || {};\r\n var itmExt = item.ext = item.ext || {};\r\n var itmTags = item[_DYN_TAGS /* @min:%2etags */] = item[_DYN_TAGS /* @min:%2etags */] || [];\r\n var extUser = itmExt.user;\r\n if (extUser) {\r\n _setValueIf(envTags, CtxTagKeys.userAuthUserId, extUser.authId);\r\n _setValueIf(envTags, CtxTagKeys.userId, extUser.id || extUser.localId);\r\n }\r\n var extApp = itmExt.app;\r\n if (extApp) {\r\n _setValueIf(envTags, CtxTagKeys.sessionId, extApp.sesId);\r\n }\r\n var extDevice = itmExt.device;\r\n if (extDevice) {\r\n _setValueIf(envTags, CtxTagKeys.deviceId, extDevice.id || extDevice.localId);\r\n _setValueIf(envTags, CtxTagKeys[_DYN_DEVICE_TYPE /* @min:%2edeviceType */], extDevice.deviceClass);\r\n _setValueIf(envTags, CtxTagKeys.deviceIp, extDevice.ip);\r\n _setValueIf(envTags, CtxTagKeys.deviceModel, extDevice.model);\r\n _setValueIf(envTags, CtxTagKeys[_DYN_DEVICE_TYPE /* @min:%2edeviceType */], extDevice[_DYN_DEVICE_TYPE /* @min:%2edeviceType */]);\r\n }\r\n var web = item.ext.web;\r\n if (web) {\r\n _setValueIf(envTags, CtxTagKeys.deviceLanguage, web.browserLang);\r\n _setValueIf(envTags, CtxTagKeys.deviceBrowserVersion, web.browserVer);\r\n _setValueIf(envTags, CtxTagKeys.deviceBrowser, web.browser);\r\n var envData = env[_DYN_DATA /* @min:%2edata */] = env[_DYN_DATA /* @min:%2edata */] || {};\r\n var envBaseData = envData[strBaseData] = envData[strBaseData] || {};\r\n var envProps = envBaseData[strProperties] = envBaseData[strProperties] || {};\r\n _setValueIf(envProps, \"domain\", web.domain);\r\n _setValueIf(envProps, \"isManual\", web.isManual ? strTrue : null);\r\n _setValueIf(envProps, \"screenRes\", web.screenRes);\r\n _setValueIf(envProps, \"userConsent\", web.userConsent ? strTrue : null);\r\n }\r\n var extOs = itmExt.os;\r\n if (extOs) {\r\n _setValueIf(envTags, CtxTagKeys.deviceOS, extOs[_DYN_NAME /* @min:%2ename */]);\r\n _setValueIf(envTags, CtxTagKeys.deviceOSVersion, extOs.osVer);\r\n }\r\n // No support for mapping Trace.traceState to 2.0 as it is currently empty\r\n var extTrace = itmExt.trace;\r\n if (extTrace) {\r\n _setValueIf(envTags, CtxTagKeys.operationParentId, extTrace.parentID);\r\n _setValueIf(envTags, CtxTagKeys.operationName, dataSanitizeString(logger, extTrace[_DYN_NAME /* @min:%2ename */]));\r\n _setValueIf(envTags, CtxTagKeys.operationId, extTrace[_DYN_TRACE_ID /* @min:%2etraceID */]);\r\n }\r\n // Sample 4.0 schema\r\n // {\r\n // \"time\" : \"2018-09-05T22:51:22.4936Z\",\r\n // \"name\" : \"MetricWithNamespace\",\r\n // \"iKey\" : \"ABC-5a4cbd20-e601-4ef5-a3c6-5d6577e4398e\",\r\n // \"ext\": { \"cloud\": {\r\n // \"role\": \"WATSON3\",\r\n // \"roleInstance\": \"CO4AEAP00000260\"\r\n // },\r\n // \"device\": {}, \"correlation\": {} },\r\n // \"tags\": [\r\n // { \"amazon.region\" : \"east2\" },\r\n // { \"os.expid\" : \"wp:02df239\" }\r\n // ]\r\n // }\r\n var tgs = {};\r\n // deals with tags.push({object})\r\n for (var i = itmTags[_DYN_LENGTH /* @min:%2elength */] - 1; i >= 0; i--) {\r\n var tg = itmTags[i];\r\n objForEachKey(tg, function (key, value) {\r\n tgs[key] = value;\r\n });\r\n itmTags.splice(i, 1);\r\n }\r\n // deals with tags[key]=value (and handles hasOwnProperty)\r\n objForEachKey(itmTags, function (tg, value) {\r\n tgs[tg] = value;\r\n });\r\n var theTags = __assign(__assign({}, envTags), tgs);\r\n if (!theTags[CtxTagKeys.internalSdkVersion]) {\r\n // Append a version in case it is not already set\r\n theTags[CtxTagKeys.internalSdkVersion] = dataSanitizeString(logger, \"javascript:\".concat(EnvelopeCreator.Version), 64);\r\n }\r\n env[_DYN_TAGS /* @min:%2etags */] = optimizeObject(theTags);\r\n}\r\nfunction _extractPropsAndMeasurements(data, properties, measurements) {\r\n if (!isNullOrUndefined(data)) {\r\n objForEachKey(data, function (key, value) {\r\n if (isNumber(value)) {\r\n measurements[key] = value;\r\n }\r\n else if (isString(value)) {\r\n properties[key] = value;\r\n }\r\n else if (hasJSON()) {\r\n properties[key] = getJSON()[_DYN_STRINGIFY /* @min:%2estringify */](value);\r\n }\r\n });\r\n }\r\n}\r\nfunction _convertPropsUndefinedToCustomDefinedValue(properties, customUndefinedValue) {\r\n if (!isNullOrUndefined(properties)) {\r\n objForEachKey(properties, function (key, value) {\r\n properties[key] = value || customUndefinedValue;\r\n });\r\n }\r\n}\r\n// TODO: Do we want this to take logger as arg or use this._logger as nonstatic?\r\nfunction _createEnvelope(logger, envelopeType, telemetryItem, data) {\r\n var envelope = new Envelope(logger, data, envelopeType);\r\n _setValueIf(envelope, \"sampleRate\", telemetryItem[SampleRate]);\r\n if ((telemetryItem[strBaseData] || {}).startTime) {\r\n // Starting from Version 3.0.3, the time property will be assigned by the startTime value,\r\n // which records the loadEvent time for the pageView event.\r\n envelope.time = toISOString(telemetryItem[strBaseData].startTime);\r\n }\r\n envelope.iKey = telemetryItem.iKey;\r\n var iKeyNoDashes = telemetryItem.iKey.replace(/-/g, \"\");\r\n envelope[_DYN_NAME /* @min:%2ename */] = envelope[_DYN_NAME /* @min:%2ename */].replace(\"{0}\", iKeyNoDashes);\r\n // extract all extensions from ctx\r\n _extractPartAExtensions(logger, telemetryItem, envelope);\r\n // loop through the envelope tags (extension of Part A) and pick out the ones that should go in outgoing envelope tags\r\n telemetryItem[_DYN_TAGS /* @min:%2etags */] = telemetryItem[_DYN_TAGS /* @min:%2etags */] || [];\r\n return optimizeObject(envelope);\r\n}\r\nfunction EnvelopeCreatorInit(logger, telemetryItem) {\r\n if (isNullOrUndefined(telemetryItem[strBaseData])) {\r\n _throwInternal(logger, 1 /* eLoggingSeverity.CRITICAL */, 46 /* _eInternalMessageId.TelemetryEnvelopeInvalid */, \"telemetryItem.baseData cannot be null.\");\r\n }\r\n}\r\nexport var EnvelopeCreator = {\r\n Version: '3.4.0-nightlybeta3.2505-35'\r\n};\r\nexport function DependencyEnvelopeCreator(logger, telemetryItem, customUndefinedValue) {\r\n EnvelopeCreatorInit(logger, telemetryItem);\r\n var customMeasurements = telemetryItem[strBaseData][_DYN_MEASUREMENTS /* @min:%2emeasurements */] || {};\r\n var customProperties = telemetryItem[strBaseData][strProperties] || {};\r\n _extractPropsAndMeasurements(telemetryItem[_DYN_DATA /* @min:%2edata */], customProperties, customMeasurements);\r\n if (!isNullOrUndefined(customUndefinedValue)) {\r\n _convertPropsUndefinedToCustomDefinedValue(customProperties, customUndefinedValue);\r\n }\r\n var bd = telemetryItem[strBaseData];\r\n if (isNullOrUndefined(bd)) {\r\n _warnToConsole(logger, \"Invalid input for dependency data\");\r\n return null;\r\n }\r\n var method = bd[strProperties] && bd[strProperties][HttpMethod] ? bd[strProperties][HttpMethod] : \"GET\";\r\n var remoteDepData = new RemoteDependencyData(logger, bd.id, bd.target, bd[_DYN_NAME /* @min:%2ename */], bd[STR_DURATION /* @min:%2eduration */], bd.success, bd.responseCode, method, bd.type, bd.correlationContext, customProperties, customMeasurements);\r\n var data = new Data(RemoteDependencyData[_DYN_DATA_TYPE /* @min:%2edataType */], remoteDepData);\r\n return _createEnvelope(logger, RemoteDependencyData[_DYN_ENVELOPE_TYPE /* @min:%2eenvelopeType */], telemetryItem, data);\r\n}\r\nexport function EventEnvelopeCreator(logger, telemetryItem, customUndefinedValue) {\r\n EnvelopeCreatorInit(logger, telemetryItem);\r\n var customProperties = {};\r\n var customMeasurements = {};\r\n if (telemetryItem[strBaseType] !== Event[_DYN_DATA_TYPE /* @min:%2edataType */]) {\r\n customProperties[\"baseTypeSource\"] = telemetryItem[strBaseType]; // save the passed in base type as a property\r\n }\r\n if (telemetryItem[strBaseType] === Event[_DYN_DATA_TYPE /* @min:%2edataType */]) { // take collection\r\n customProperties = telemetryItem[strBaseData][strProperties] || {};\r\n customMeasurements = telemetryItem[strBaseData][_DYN_MEASUREMENTS /* @min:%2emeasurements */] || {};\r\n }\r\n else { // if its not a known type, convert to custom event\r\n if (telemetryItem[strBaseData]) {\r\n _extractPropsAndMeasurements(telemetryItem[strBaseData], customProperties, customMeasurements);\r\n }\r\n }\r\n // Extract root level properties from part C telemetryItem.data\r\n _extractPropsAndMeasurements(telemetryItem[_DYN_DATA /* @min:%2edata */], customProperties, customMeasurements);\r\n if (!isNullOrUndefined(customUndefinedValue)) {\r\n _convertPropsUndefinedToCustomDefinedValue(customProperties, customUndefinedValue);\r\n }\r\n var eventName = telemetryItem[strBaseData][_DYN_NAME /* @min:%2ename */];\r\n var eventData = new Event(logger, eventName, customProperties, customMeasurements);\r\n var data = new Data(Event[_DYN_DATA_TYPE /* @min:%2edataType */], eventData);\r\n return _createEnvelope(logger, Event[_DYN_ENVELOPE_TYPE /* @min:%2eenvelopeType */], telemetryItem, data);\r\n}\r\nexport function ExceptionEnvelopeCreator(logger, telemetryItem, customUndefinedValue) {\r\n EnvelopeCreatorInit(logger, telemetryItem);\r\n // Extract root level properties from part C telemetryItem.data\r\n var customMeasurements = telemetryItem[strBaseData][_DYN_MEASUREMENTS /* @min:%2emeasurements */] || {};\r\n var customProperties = telemetryItem[strBaseData][strProperties] || {};\r\n _extractPropsAndMeasurements(telemetryItem[_DYN_DATA /* @min:%2edata */], customProperties, customMeasurements);\r\n if (!isNullOrUndefined(customUndefinedValue)) {\r\n _convertPropsUndefinedToCustomDefinedValue(customProperties, customUndefinedValue);\r\n }\r\n var bd = telemetryItem[strBaseData];\r\n var exData = Exception.CreateFromInterface(logger, bd, customProperties, customMeasurements);\r\n var data = new Data(Exception[_DYN_DATA_TYPE /* @min:%2edataType */], exData);\r\n return _createEnvelope(logger, Exception[_DYN_ENVELOPE_TYPE /* @min:%2eenvelopeType */], telemetryItem, data);\r\n}\r\nexport function MetricEnvelopeCreator(logger, telemetryItem, customUndefinedValue) {\r\n EnvelopeCreatorInit(logger, telemetryItem);\r\n var baseData = telemetryItem[strBaseData];\r\n var props = baseData[strProperties] || {};\r\n var measurements = baseData[_DYN_MEASUREMENTS /* @min:%2emeasurements */] || {};\r\n _extractPropsAndMeasurements(telemetryItem[_DYN_DATA /* @min:%2edata */], props, measurements);\r\n if (!isNullOrUndefined(customUndefinedValue)) {\r\n _convertPropsUndefinedToCustomDefinedValue(props, customUndefinedValue);\r\n }\r\n var baseMetricData = new Metric(logger, baseData[_DYN_NAME /* @min:%2ename */], baseData.average, baseData.sampleCount, baseData.min, baseData.max, baseData.stdDev, props, measurements);\r\n var data = new Data(Metric[_DYN_DATA_TYPE /* @min:%2edataType */], baseMetricData);\r\n return _createEnvelope(logger, Metric[_DYN_ENVELOPE_TYPE /* @min:%2eenvelopeType */], telemetryItem, data);\r\n}\r\nexport function PageViewEnvelopeCreator(logger, telemetryItem, customUndefinedValue) {\r\n EnvelopeCreatorInit(logger, telemetryItem);\r\n // Since duration is not part of the domain properties in Common Schema, extract it from part C\r\n var duration;\r\n var baseData = telemetryItem[strBaseData];\r\n if (!isNullOrUndefined(baseData) &&\r\n !isNullOrUndefined(baseData[strProperties]) &&\r\n !isNullOrUndefined(baseData[strProperties][STR_DURATION])) { // from part B properties\r\n duration = baseData[strProperties][STR_DURATION];\r\n delete baseData[strProperties][STR_DURATION];\r\n }\r\n else if (!isNullOrUndefined(telemetryItem[_DYN_DATA /* @min:%2edata */]) &&\r\n !isNullOrUndefined(telemetryItem[_DYN_DATA /* @min:%2edata */][STR_DURATION])) { // from custom properties\r\n duration = telemetryItem[_DYN_DATA /* @min:%2edata */][STR_DURATION];\r\n delete telemetryItem[_DYN_DATA /* @min:%2edata */][STR_DURATION];\r\n }\r\n var bd = telemetryItem[strBaseData];\r\n // special case: pageview.id is grabbed from current operation id. Analytics plugin is decoupled from properties plugin, so this is done here instead. This can be made a default telemetry intializer instead if needed to be decoupled from channel\r\n var currentContextId;\r\n if (((telemetryItem.ext || {}).trace || {})[_DYN_TRACE_ID /* @min:%2etraceID */]) {\r\n currentContextId = telemetryItem.ext.trace[_DYN_TRACE_ID /* @min:%2etraceID */];\r\n }\r\n var id = bd.id || currentContextId;\r\n var name = bd[_DYN_NAME /* @min:%2ename */];\r\n var url = bd.uri;\r\n var properties = bd[strProperties] || {};\r\n var measurements = bd[_DYN_MEASUREMENTS /* @min:%2emeasurements */] || {};\r\n // refUri is a field that Breeze still does not recognize as part of Part B. For now, put it in Part C until it supports it as a domain property\r\n if (!isNullOrUndefined(bd.refUri)) {\r\n properties[\"refUri\"] = bd.refUri;\r\n }\r\n // pageType is a field that Breeze still does not recognize as part of Part B. For now, put it in Part C until it supports it as a domain property\r\n if (!isNullOrUndefined(bd.pageType)) {\r\n properties[\"pageType\"] = bd.pageType;\r\n }\r\n // isLoggedIn is a field that Breeze still does not recognize as part of Part B. For now, put it in Part C until it supports it as a domain property\r\n if (!isNullOrUndefined(bd.isLoggedIn)) {\r\n properties[\"isLoggedIn\"] = bd.isLoggedIn[_DYN_TO_STRING /* @min:%2etoString */]();\r\n }\r\n // pageTags is a field that Breeze still does not recognize as part of Part B. For now, put it in Part C until it supports it as a domain property\r\n if (!isNullOrUndefined(bd[strProperties])) {\r\n var pageTags = bd[strProperties];\r\n objForEachKey(pageTags, function (key, value) {\r\n properties[key] = value;\r\n });\r\n }\r\n _extractPropsAndMeasurements(telemetryItem[_DYN_DATA /* @min:%2edata */], properties, measurements);\r\n if (!isNullOrUndefined(customUndefinedValue)) {\r\n _convertPropsUndefinedToCustomDefinedValue(properties, customUndefinedValue);\r\n }\r\n var pageViewData = new PageView(logger, name, url, duration, properties, measurements, id);\r\n var data = new Data(PageView[_DYN_DATA_TYPE /* @min:%2edataType */], pageViewData);\r\n return _createEnvelope(logger, PageView[_DYN_ENVELOPE_TYPE /* @min:%2eenvelopeType */], telemetryItem, data);\r\n}\r\nexport function PageViewPerformanceEnvelopeCreator(logger, telemetryItem, customUndefinedValue) {\r\n EnvelopeCreatorInit(logger, telemetryItem);\r\n var bd = telemetryItem[strBaseData];\r\n var name = bd[_DYN_NAME /* @min:%2ename */];\r\n var url = bd.uri || bd.url;\r\n var properties = bd[strProperties] || {};\r\n var measurements = bd[_DYN_MEASUREMENTS /* @min:%2emeasurements */] || {};\r\n _extractPropsAndMeasurements(telemetryItem[_DYN_DATA /* @min:%2edata */], properties, measurements);\r\n if (!isNullOrUndefined(customUndefinedValue)) {\r\n _convertPropsUndefinedToCustomDefinedValue(properties, customUndefinedValue);\r\n }\r\n var baseData = new PageViewPerformance(logger, name, url, undefined, properties, measurements, bd);\r\n var data = new Data(PageViewPerformance[_DYN_DATA_TYPE /* @min:%2edataType */], baseData);\r\n return _createEnvelope(logger, PageViewPerformance[_DYN_ENVELOPE_TYPE /* @min:%2eenvelopeType */], telemetryItem, data);\r\n}\r\nexport function TraceEnvelopeCreator(logger, telemetryItem, customUndefinedValue) {\r\n EnvelopeCreatorInit(logger, telemetryItem);\r\n var message = telemetryItem[strBaseData].message;\r\n var severityLevel = telemetryItem[strBaseData].severityLevel;\r\n var props = telemetryItem[strBaseData][strProperties] || {};\r\n var measurements = telemetryItem[strBaseData][_DYN_MEASUREMENTS /* @min:%2emeasurements */] || {};\r\n _extractPropsAndMeasurements(telemetryItem[_DYN_DATA /* @min:%2edata */], props, measurements);\r\n if (!isNullOrUndefined(customUndefinedValue)) {\r\n _convertPropsUndefinedToCustomDefinedValue(props, customUndefinedValue);\r\n }\r\n var baseData = new Trace(logger, message, severityLevel, props, measurements);\r\n var data = new Data(Trace[_DYN_DATA_TYPE /* @min:%2edataType */], baseData);\r\n return _createEnvelope(logger, Trace[_DYN_ENVELOPE_TYPE /* @min:%2eenvelopeType */], telemetryItem, data);\r\n}\r\n//# sourceMappingURL=EnvelopeCreator.js.map"],"names":[],"mappings":";;;;AAAA,8EAAiC;AACjC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;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":"EnvelopeCreator.js.map","sources":["EnvelopeCreator.js"],"sourcesContent":["import { __assign } from \"tslib\";\r\nimport { CtxTagKeys, Data, Envelope, Event, Exception, HttpMethod, Metric, PageView, PageViewPerformance, RemoteDependencyData, SampleRate, Trace, dataSanitizeString } from \"@microsoft/applicationinsights-common\";\r\nimport { _throwInternal, _warnToConsole, getJSON, hasJSON, isNullOrUndefined, isNumber, isString, isTruthy, objForEachKey, optimizeObject, setValue, toISOString } from \"@microsoft/applicationinsights-core-js\";\r\nimport { STR_DURATION } from \"./InternalConstants\";\r\nimport { _DYN_DATA, _DYN_DATA_TYPE, _DYN_DEVICE_TYPE, _DYN_ENVELOPE_TYPE, _DYN_LENGTH, _DYN_MEASUREMENTS, _DYN_NAME, _DYN_STRINGIFY, _DYN_TAGS, _DYN_TO_STRING, _DYN_TRACE_ID } from \"./__DynamicConstants\";\r\n// these two constants are used to filter out properties not needed when trying to extract custom properties and measurements from the incoming payload\r\nvar strBaseType = \"baseType\";\r\nvar strBaseData = \"baseData\";\r\nvar strProperties = \"properties\";\r\nvar strTrue = \"true\";\r\nfunction _setValueIf(target, field, value) {\r\n return setValue(target, field, value, isTruthy);\r\n}\r\n/*\r\n * Maps Part A data from CS 4.0\r\n */\r\nfunction _extractPartAExtensions(logger, item, env) {\r\n // todo: switch to keys from common in this method\r\n var envTags = env[_DYN_TAGS /* @min:%2etags */] = env[_DYN_TAGS /* @min:%2etags */] || {};\r\n var itmExt = item.ext = item.ext || {};\r\n var itmTags = item[_DYN_TAGS /* @min:%2etags */] = item[_DYN_TAGS /* @min:%2etags */] || [];\r\n var extUser = itmExt.user;\r\n if (extUser) {\r\n _setValueIf(envTags, CtxTagKeys.userAuthUserId, extUser.authId);\r\n _setValueIf(envTags, CtxTagKeys.userId, extUser.id || extUser.localId);\r\n }\r\n var extApp = itmExt.app;\r\n if (extApp) {\r\n _setValueIf(envTags, CtxTagKeys.sessionId, extApp.sesId);\r\n }\r\n var extDevice = itmExt.device;\r\n if (extDevice) {\r\n _setValueIf(envTags, CtxTagKeys.deviceId, extDevice.id || extDevice.localId);\r\n _setValueIf(envTags, CtxTagKeys[_DYN_DEVICE_TYPE /* @min:%2edeviceType */], extDevice.deviceClass);\r\n _setValueIf(envTags, CtxTagKeys.deviceIp, extDevice.ip);\r\n _setValueIf(envTags, CtxTagKeys.deviceModel, extDevice.model);\r\n _setValueIf(envTags, CtxTagKeys[_DYN_DEVICE_TYPE /* @min:%2edeviceType */], extDevice[_DYN_DEVICE_TYPE /* @min:%2edeviceType */]);\r\n }\r\n var web = item.ext.web;\r\n if (web) {\r\n _setValueIf(envTags, CtxTagKeys.deviceLanguage, web.browserLang);\r\n _setValueIf(envTags, CtxTagKeys.deviceBrowserVersion, web.browserVer);\r\n _setValueIf(envTags, CtxTagKeys.deviceBrowser, web.browser);\r\n var envData = env[_DYN_DATA /* @min:%2edata */] = env[_DYN_DATA /* @min:%2edata */] || {};\r\n var envBaseData = envData[strBaseData] = envData[strBaseData] || {};\r\n var envProps = envBaseData[strProperties] = envBaseData[strProperties] || {};\r\n _setValueIf(envProps, \"domain\", web.domain);\r\n _setValueIf(envProps, \"isManual\", web.isManual ? strTrue : null);\r\n _setValueIf(envProps, \"screenRes\", web.screenRes);\r\n _setValueIf(envProps, \"userConsent\", web.userConsent ? strTrue : null);\r\n }\r\n var extOs = itmExt.os;\r\n if (extOs) {\r\n _setValueIf(envTags, CtxTagKeys.deviceOS, extOs[_DYN_NAME /* @min:%2ename */]);\r\n _setValueIf(envTags, CtxTagKeys.deviceOSVersion, extOs.osVer);\r\n }\r\n // No support for mapping Trace.traceState to 2.0 as it is currently empty\r\n var extTrace = itmExt.trace;\r\n if (extTrace) {\r\n _setValueIf(envTags, CtxTagKeys.operationParentId, extTrace.parentID);\r\n _setValueIf(envTags, CtxTagKeys.operationName, dataSanitizeString(logger, extTrace[_DYN_NAME /* @min:%2ename */]));\r\n _setValueIf(envTags, CtxTagKeys.operationId, extTrace[_DYN_TRACE_ID /* @min:%2etraceID */]);\r\n }\r\n // Sample 4.0 schema\r\n // {\r\n // \"time\" : \"2018-09-05T22:51:22.4936Z\",\r\n // \"name\" : \"MetricWithNamespace\",\r\n // \"iKey\" : \"ABC-5a4cbd20-e601-4ef5-a3c6-5d6577e4398e\",\r\n // \"ext\": { \"cloud\": {\r\n // \"role\": \"WATSON3\",\r\n // \"roleInstance\": \"CO4AEAP00000260\"\r\n // },\r\n // \"device\": {}, \"correlation\": {} },\r\n // \"tags\": [\r\n // { \"amazon.region\" : \"east2\" },\r\n // { \"os.expid\" : \"wp:02df239\" }\r\n // ]\r\n // }\r\n var tgs = {};\r\n // deals with tags.push({object})\r\n for (var i = itmTags[_DYN_LENGTH /* @min:%2elength */] - 1; i >= 0; i--) {\r\n var tg = itmTags[i];\r\n objForEachKey(tg, function (key, value) {\r\n tgs[key] = value;\r\n });\r\n itmTags.splice(i, 1);\r\n }\r\n // deals with tags[key]=value (and handles hasOwnProperty)\r\n objForEachKey(itmTags, function (tg, value) {\r\n tgs[tg] = value;\r\n });\r\n var theTags = __assign(__assign({}, envTags), tgs);\r\n if (!theTags[CtxTagKeys.internalSdkVersion]) {\r\n // Append a version in case it is not already set\r\n theTags[CtxTagKeys.internalSdkVersion] = dataSanitizeString(logger, \"javascript:\".concat(EnvelopeCreator.Version), 64);\r\n }\r\n env[_DYN_TAGS /* @min:%2etags */] = optimizeObject(theTags);\r\n}\r\nfunction _extractPropsAndMeasurements(data, properties, measurements) {\r\n if (!isNullOrUndefined(data)) {\r\n objForEachKey(data, function (key, value) {\r\n if (isNumber(value)) {\r\n measurements[key] = value;\r\n }\r\n else if (isString(value)) {\r\n properties[key] = value;\r\n }\r\n else if (hasJSON()) {\r\n properties[key] = getJSON()[_DYN_STRINGIFY /* @min:%2estringify */](value);\r\n }\r\n });\r\n }\r\n}\r\nfunction _convertPropsUndefinedToCustomDefinedValue(properties, customUndefinedValue) {\r\n if (!isNullOrUndefined(properties)) {\r\n objForEachKey(properties, function (key, value) {\r\n properties[key] = value || customUndefinedValue;\r\n });\r\n }\r\n}\r\n// TODO: Do we want this to take logger as arg or use this._logger as nonstatic?\r\nfunction _createEnvelope(logger, envelopeType, telemetryItem, data) {\r\n var envelope = new Envelope(logger, data, envelopeType);\r\n _setValueIf(envelope, \"sampleRate\", telemetryItem[SampleRate]);\r\n if ((telemetryItem[strBaseData] || {}).startTime) {\r\n // Starting from Version 3.0.3, the time property will be assigned by the startTime value,\r\n // which records the loadEvent time for the pageView event.\r\n envelope.time = toISOString(telemetryItem[strBaseData].startTime);\r\n }\r\n envelope.iKey = telemetryItem.iKey;\r\n var iKeyNoDashes = telemetryItem.iKey.replace(/-/g, \"\");\r\n envelope[_DYN_NAME /* @min:%2ename */] = envelope[_DYN_NAME /* @min:%2ename */].replace(\"{0}\", iKeyNoDashes);\r\n // extract all extensions from ctx\r\n _extractPartAExtensions(logger, telemetryItem, envelope);\r\n // loop through the envelope tags (extension of Part A) and pick out the ones that should go in outgoing envelope tags\r\n telemetryItem[_DYN_TAGS /* @min:%2etags */] = telemetryItem[_DYN_TAGS /* @min:%2etags */] || [];\r\n return optimizeObject(envelope);\r\n}\r\nfunction EnvelopeCreatorInit(logger, telemetryItem) {\r\n if (isNullOrUndefined(telemetryItem[strBaseData])) {\r\n _throwInternal(logger, 1 /* eLoggingSeverity.CRITICAL */, 46 /* _eInternalMessageId.TelemetryEnvelopeInvalid */, \"telemetryItem.baseData cannot be null.\");\r\n }\r\n}\r\nexport var EnvelopeCreator = {\r\n Version: '3.4.0-nightlybeta3.2507-23'\r\n};\r\nexport function DependencyEnvelopeCreator(logger, telemetryItem, customUndefinedValue) {\r\n EnvelopeCreatorInit(logger, telemetryItem);\r\n var customMeasurements = telemetryItem[strBaseData][_DYN_MEASUREMENTS /* @min:%2emeasurements */] || {};\r\n var customProperties = telemetryItem[strBaseData][strProperties] || {};\r\n _extractPropsAndMeasurements(telemetryItem[_DYN_DATA /* @min:%2edata */], customProperties, customMeasurements);\r\n if (!isNullOrUndefined(customUndefinedValue)) {\r\n _convertPropsUndefinedToCustomDefinedValue(customProperties, customUndefinedValue);\r\n }\r\n var bd = telemetryItem[strBaseData];\r\n if (isNullOrUndefined(bd)) {\r\n _warnToConsole(logger, \"Invalid input for dependency data\");\r\n return null;\r\n }\r\n var method = bd[strProperties] && bd[strProperties][HttpMethod] ? bd[strProperties][HttpMethod] : \"GET\";\r\n var remoteDepData = new RemoteDependencyData(logger, bd.id, bd.target, bd[_DYN_NAME /* @min:%2ename */], bd[STR_DURATION /* @min:%2eduration */], bd.success, bd.responseCode, method, bd.type, bd.correlationContext, customProperties, customMeasurements);\r\n var data = new Data(RemoteDependencyData[_DYN_DATA_TYPE /* @min:%2edataType */], remoteDepData);\r\n return _createEnvelope(logger, RemoteDependencyData[_DYN_ENVELOPE_TYPE /* @min:%2eenvelopeType */], telemetryItem, data);\r\n}\r\nexport function EventEnvelopeCreator(logger, telemetryItem, customUndefinedValue) {\r\n EnvelopeCreatorInit(logger, telemetryItem);\r\n var customProperties = {};\r\n var customMeasurements = {};\r\n if (telemetryItem[strBaseType] !== Event[_DYN_DATA_TYPE /* @min:%2edataType */]) {\r\n customProperties[\"baseTypeSource\"] = telemetryItem[strBaseType]; // save the passed in base type as a property\r\n }\r\n if (telemetryItem[strBaseType] === Event[_DYN_DATA_TYPE /* @min:%2edataType */]) { // take collection\r\n customProperties = telemetryItem[strBaseData][strProperties] || {};\r\n customMeasurements = telemetryItem[strBaseData][_DYN_MEASUREMENTS /* @min:%2emeasurements */] || {};\r\n }\r\n else { // if its not a known type, convert to custom event\r\n if (telemetryItem[strBaseData]) {\r\n _extractPropsAndMeasurements(telemetryItem[strBaseData], customProperties, customMeasurements);\r\n }\r\n }\r\n // Extract root level properties from part C telemetryItem.data\r\n _extractPropsAndMeasurements(telemetryItem[_DYN_DATA /* @min:%2edata */], customProperties, customMeasurements);\r\n if (!isNullOrUndefined(customUndefinedValue)) {\r\n _convertPropsUndefinedToCustomDefinedValue(customProperties, customUndefinedValue);\r\n }\r\n var eventName = telemetryItem[strBaseData][_DYN_NAME /* @min:%2ename */];\r\n var eventData = new Event(logger, eventName, customProperties, customMeasurements);\r\n var data = new Data(Event[_DYN_DATA_TYPE /* @min:%2edataType */], eventData);\r\n return _createEnvelope(logger, Event[_DYN_ENVELOPE_TYPE /* @min:%2eenvelopeType */], telemetryItem, data);\r\n}\r\nexport function ExceptionEnvelopeCreator(logger, telemetryItem, customUndefinedValue) {\r\n EnvelopeCreatorInit(logger, telemetryItem);\r\n // Extract root level properties from part C telemetryItem.data\r\n var customMeasurements = telemetryItem[strBaseData][_DYN_MEASUREMENTS /* @min:%2emeasurements */] || {};\r\n var customProperties = telemetryItem[strBaseData][strProperties] || {};\r\n _extractPropsAndMeasurements(telemetryItem[_DYN_DATA /* @min:%2edata */], customProperties, customMeasurements);\r\n if (!isNullOrUndefined(customUndefinedValue)) {\r\n _convertPropsUndefinedToCustomDefinedValue(customProperties, customUndefinedValue);\r\n }\r\n var bd = telemetryItem[strBaseData];\r\n var exData = Exception.CreateFromInterface(logger, bd, customProperties, customMeasurements);\r\n var data = new Data(Exception[_DYN_DATA_TYPE /* @min:%2edataType */], exData);\r\n return _createEnvelope(logger, Exception[_DYN_ENVELOPE_TYPE /* @min:%2eenvelopeType */], telemetryItem, data);\r\n}\r\nexport function MetricEnvelopeCreator(logger, telemetryItem, customUndefinedValue) {\r\n EnvelopeCreatorInit(logger, telemetryItem);\r\n var baseData = telemetryItem[strBaseData];\r\n var props = baseData[strProperties] || {};\r\n var measurements = baseData[_DYN_MEASUREMENTS /* @min:%2emeasurements */] || {};\r\n _extractPropsAndMeasurements(telemetryItem[_DYN_DATA /* @min:%2edata */], props, measurements);\r\n if (!isNullOrUndefined(customUndefinedValue)) {\r\n _convertPropsUndefinedToCustomDefinedValue(props, customUndefinedValue);\r\n }\r\n var baseMetricData = new Metric(logger, baseData[_DYN_NAME /* @min:%2ename */], baseData.average, baseData.sampleCount, baseData.min, baseData.max, baseData.stdDev, props, measurements);\r\n var data = new Data(Metric[_DYN_DATA_TYPE /* @min:%2edataType */], baseMetricData);\r\n return _createEnvelope(logger, Metric[_DYN_ENVELOPE_TYPE /* @min:%2eenvelopeType */], telemetryItem, data);\r\n}\r\nexport function PageViewEnvelopeCreator(logger, telemetryItem, customUndefinedValue) {\r\n EnvelopeCreatorInit(logger, telemetryItem);\r\n // Since duration is not part of the domain properties in Common Schema, extract it from part C\r\n var duration;\r\n var baseData = telemetryItem[strBaseData];\r\n if (!isNullOrUndefined(baseData) &&\r\n !isNullOrUndefined(baseData[strProperties]) &&\r\n !isNullOrUndefined(baseData[strProperties][STR_DURATION])) { // from part B properties\r\n duration = baseData[strProperties][STR_DURATION];\r\n delete baseData[strProperties][STR_DURATION];\r\n }\r\n else if (!isNullOrUndefined(telemetryItem[_DYN_DATA /* @min:%2edata */]) &&\r\n !isNullOrUndefined(telemetryItem[_DYN_DATA /* @min:%2edata */][STR_DURATION])) { // from custom properties\r\n duration = telemetryItem[_DYN_DATA /* @min:%2edata */][STR_DURATION];\r\n delete telemetryItem[_DYN_DATA /* @min:%2edata */][STR_DURATION];\r\n }\r\n var bd = telemetryItem[strBaseData];\r\n // special case: pageview.id is grabbed from current operation id. Analytics plugin is decoupled from properties plugin, so this is done here instead. This can be made a default telemetry intializer instead if needed to be decoupled from channel\r\n var currentContextId;\r\n if (((telemetryItem.ext || {}).trace || {})[_DYN_TRACE_ID /* @min:%2etraceID */]) {\r\n currentContextId = telemetryItem.ext.trace[_DYN_TRACE_ID /* @min:%2etraceID */];\r\n }\r\n var id = bd.id || currentContextId;\r\n var name = bd[_DYN_NAME /* @min:%2ename */];\r\n var url = bd.uri;\r\n var properties = bd[strProperties] || {};\r\n var measurements = bd[_DYN_MEASUREMENTS /* @min:%2emeasurements */] || {};\r\n // refUri is a field that Breeze still does not recognize as part of Part B. For now, put it in Part C until it supports it as a domain property\r\n if (!isNullOrUndefined(bd.refUri)) {\r\n properties[\"refUri\"] = bd.refUri;\r\n }\r\n // pageType is a field that Breeze still does not recognize as part of Part B. For now, put it in Part C until it supports it as a domain property\r\n if (!isNullOrUndefined(bd.pageType)) {\r\n properties[\"pageType\"] = bd.pageType;\r\n }\r\n // isLoggedIn is a field that Breeze still does not recognize as part of Part B. For now, put it in Part C until it supports it as a domain property\r\n if (!isNullOrUndefined(bd.isLoggedIn)) {\r\n properties[\"isLoggedIn\"] = bd.isLoggedIn[_DYN_TO_STRING /* @min:%2etoString */]();\r\n }\r\n // pageTags is a field that Breeze still does not recognize as part of Part B. For now, put it in Part C until it supports it as a domain property\r\n if (!isNullOrUndefined(bd[strProperties])) {\r\n var pageTags = bd[strProperties];\r\n objForEachKey(pageTags, function (key, value) {\r\n properties[key] = value;\r\n });\r\n }\r\n _extractPropsAndMeasurements(telemetryItem[_DYN_DATA /* @min:%2edata */], properties, measurements);\r\n if (!isNullOrUndefined(customUndefinedValue)) {\r\n _convertPropsUndefinedToCustomDefinedValue(properties, customUndefinedValue);\r\n }\r\n var pageViewData = new PageView(logger, name, url, duration, properties, measurements, id);\r\n var data = new Data(PageView[_DYN_DATA_TYPE /* @min:%2edataType */], pageViewData);\r\n return _createEnvelope(logger, PageView[_DYN_ENVELOPE_TYPE /* @min:%2eenvelopeType */], telemetryItem, data);\r\n}\r\nexport function PageViewPerformanceEnvelopeCreator(logger, telemetryItem, customUndefinedValue) {\r\n EnvelopeCreatorInit(logger, telemetryItem);\r\n var bd = telemetryItem[strBaseData];\r\n var name = bd[_DYN_NAME /* @min:%2ename */];\r\n var url = bd.uri || bd.url;\r\n var properties = bd[strProperties] || {};\r\n var measurements = bd[_DYN_MEASUREMENTS /* @min:%2emeasurements */] || {};\r\n _extractPropsAndMeasurements(telemetryItem[_DYN_DATA /* @min:%2edata */], properties, measurements);\r\n if (!isNullOrUndefined(customUndefinedValue)) {\r\n _convertPropsUndefinedToCustomDefinedValue(properties, customUndefinedValue);\r\n }\r\n var baseData = new PageViewPerformance(logger, name, url, undefined, properties, measurements, bd);\r\n var data = new Data(PageViewPerformance[_DYN_DATA_TYPE /* @min:%2edataType */], baseData);\r\n return _createEnvelope(logger, PageViewPerformance[_DYN_ENVELOPE_TYPE /* @min:%2eenvelopeType */], telemetryItem, data);\r\n}\r\nexport function TraceEnvelopeCreator(logger, telemetryItem, customUndefinedValue) {\r\n EnvelopeCreatorInit(logger, telemetryItem);\r\n var message = telemetryItem[strBaseData].message;\r\n var severityLevel = telemetryItem[strBaseData].severityLevel;\r\n var props = telemetryItem[strBaseData][strProperties] || {};\r\n var measurements = telemetryItem[strBaseData][_DYN_MEASUREMENTS /* @min:%2emeasurements */] || {};\r\n _extractPropsAndMeasurements(telemetryItem[_DYN_DATA /* @min:%2edata */], props, measurements);\r\n if (!isNullOrUndefined(customUndefinedValue)) {\r\n _convertPropsUndefinedToCustomDefinedValue(props, customUndefinedValue);\r\n }\r\n var baseData = new Trace(logger, message, severityLevel, props, measurements);\r\n var data = new Data(Trace[_DYN_DATA_TYPE /* @min:%2edataType */], baseData);\r\n return _createEnvelope(logger, Trace[_DYN_ENVELOPE_TYPE /* @min:%2eenvelopeType */], telemetryItem, data);\r\n}\r\n//# sourceMappingURL=EnvelopeCreator.js.map"],"names":[],"mappings":";;;;AAAA,8EAAiC;AACjC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;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 - Channel, 3.4.0-nightlybeta3.2505-35
2
+ * Application Insights JavaScript SDK - Channel, 3.4.0-nightlybeta3.2507-23
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  */
5
5
  export {};
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Application Insights JavaScript SDK - Channel, 3.4.0-nightlybeta3.2505-35
2
+ * Application Insights JavaScript SDK - Channel, 3.4.0-nightlybeta3.2507-23
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Application Insights JavaScript SDK - Channel, 3.4.0-nightlybeta3.2505-35
2
+ * Application Insights JavaScript SDK - Channel, 3.4.0-nightlybeta3.2507-23
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  */
5
5
  import { __extendsFn as __extends } from "@microsoft/applicationinsights-shims";
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Application Insights JavaScript SDK - Channel, 3.4.0-nightlybeta3.2505-35
2
+ * Application Insights JavaScript SDK - Channel, 3.4.0-nightlybeta3.2507-23
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  */
5
5
  var _a, _b;
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Application Insights JavaScript SDK - Channel, 3.4.0-nightlybeta3.2505-35
2
+ * Application Insights JavaScript SDK - Channel, 3.4.0-nightlybeta3.2507-23
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  */
5
5
  import dynamicProto from "@microsoft/dynamicproto-js";
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Application Insights JavaScript SDK - Channel, 3.4.0-nightlybeta3.2505-35
2
+ * Application Insights JavaScript SDK - Channel, 3.4.0-nightlybeta3.2507-23
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Application Insights JavaScript SDK - Channel, 3.4.0-nightlybeta3.2505-35
2
+ * Application Insights JavaScript SDK - Channel, 3.4.0-nightlybeta3.2507-23
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Application Insights JavaScript SDK - Channel, 3.4.0-nightlybeta3.2505-35
2
+ * Application Insights JavaScript SDK - Channel, 3.4.0-nightlybeta3.2507-23
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Application Insights JavaScript SDK - Channel, 3.4.0-nightlybeta3.2505-35
2
+ * Application Insights JavaScript SDK - Channel, 3.4.0-nightlybeta3.2507-23
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Application Insights JavaScript SDK - Channel, 3.4.0-nightlybeta3.2505-35
2
+ * Application Insights JavaScript SDK - Channel, 3.4.0-nightlybeta3.2507-23
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  */
5
5
  export { Sender } from "./Sender";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@microsoft/applicationinsights-channel-js",
3
- "version": "3.4.0-nightlybeta3.2505-35",
3
+ "version": "3.4.0-nightlybeta3.2507-23",
4
4
  "description": "Microsoft Application Insights JavaScript SDK Channel",
5
5
  "homepage": "https://github.com/microsoft/ApplicationInsights-JS#readme",
6
6
  "author": "Microsoft Application Insights Team",
@@ -57,8 +57,8 @@
57
57
  "dependencies": {
58
58
  "@microsoft/dynamicproto-js": "^2.0.3",
59
59
  "@microsoft/applicationinsights-shims": "3.0.1",
60
- "@microsoft/applicationinsights-core-js": "3.4.0-nightlybeta3.2505-35",
61
- "@microsoft/applicationinsights-common": "3.4.0-nightlybeta3.2505-35",
60
+ "@microsoft/applicationinsights-core-js": "3.4.0-nightlybeta3.2507-23",
61
+ "@microsoft/applicationinsights-common": "3.4.0-nightlybeta3.2507-23",
62
62
  "@nevware21/ts-utils": ">= 0.11.8 < 2.x",
63
63
  "@nevware21/ts-async": ">= 0.5.4 < 2.x"
64
64
  },
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Microsoft Application Insights JavaScript SDK Channel, 3.4.0-nightlybeta3.2505-35
2
+ * Microsoft Application Insights JavaScript SDK Channel, 3.4.0-nightlybeta3.2507-23
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  *
5
5
  * Microsoft Application Insights Team
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Microsoft Application Insights JavaScript SDK Channel, 3.4.0-nightlybeta3.2505-35
2
+ * Microsoft Application Insights JavaScript SDK Channel, 3.4.0-nightlybeta3.2507-23
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  *
5
5
  * Microsoft Application Insights Team
@@ -48,9 +48,12 @@ declare namespace ApplicationInsights {
48
48
  */
49
49
  processNext: (env: ITelemetryItem, itemCtx: IProcessTelemetryContext) => void;
50
50
  /**
51
- * Set next extension for telemetry processing
51
+ * Set next extension for telemetry processing, this is now optional as plugins should use the
52
+ * processNext() function of the passed IProcessTelemetryContext instead. It is being kept for
53
+ * now for backward compatibility only.
54
+ * @deprecated - Use processNext() function of the passed IProcessTelemetryContext instead
52
55
  */
53
- setNextPlugin: (next: ITelemetryPlugin | ITelemetryPluginChain) => void;
56
+ setNextPlugin?: (next: ITelemetryPlugin | ITelemetryPluginChain) => void;
54
57
  /**
55
58
  * Returns the current diagnostic logger that can be used to log issues, if no logger is currently
56
59
  * assigned a new default one will be created and returned.
@@ -148,17 +151,78 @@ declare namespace ApplicationInsights {
148
151
 
149
152
  const enum eDistributedTracingModes {
150
153
  /**
151
- * (Default) Send Application Insights correlation headers
154
+ * Send only the legacy Application Insights correlation headers
155
+ *
156
+ * Headers Sent:
157
+ * - `Request-Id` (Legacy Application Insights header for older Server side SDKs)
158
+ *
159
+ * Config Decimal Value: `0` (Zero)
152
160
  */
153
161
  AI = 0,
154
162
  /**
155
- * Send both W3C Trace Context headers and back-compatibility Application Insights headers
163
+ * (Default) Send both W3C Trace parent header and back-compatibility Application Insights headers
164
+ * - `Request-Id`
165
+ * - [`traceparent`](https://www.w3.org/TR/trace-context/#traceparent-header)
166
+ *
167
+ * Config Decimal Value: `1` (One)
156
168
  */
157
169
  AI_AND_W3C = 1,
158
170
  /**
159
- * Send W3C Trace Context headers
171
+ * Send Only the W3C Trace parent header
172
+ *
173
+ * Headers Sent:
174
+ * - [`traceparent`](https://www.w3.org/TR/trace-context/#traceparent-header)
175
+ *
176
+ * Config Decimal Value: `2` (Two)
177
+ */
178
+ W3C = 2,
179
+ /**
180
+ * @internal
181
+ * Bitwise mask used to separate the base distributed tracing mode from the additional optional
182
+ * tracing modes.
183
+ * @since 3.4.0
184
+ */
185
+ _BaseMask = 15,
186
+ /**
187
+ * @internal
188
+ * Enabling this bit will send the W3C Trace State header, it is not intended to be used directly
189
+ * or on its own. The code may assume that if this bit is set, then the W3C Trace Context headers
190
+ * will also be included.
191
+ *
192
+ * Config Decimal Value: `16` (Sixteen in decimal)
193
+ * @since 3.4.0
194
+ */
195
+ _W3CTraceState = 16,
196
+ /**
197
+ * Send all of the W3C Trace Context headers and the W3C Trace State headers and back-compatibility
198
+ * Application Insights headers.
199
+ *
200
+ * Currently sent headers:
201
+ * - `Request-Id` (Legacy Application Insights header for older Server side SDKs)
202
+ * - [`traceparent`](https://www.w3.org/TR/trace-context/#traceparent-header)
203
+ * - [`tracestate`](https://www.w3.org/TR/trace-context/#tracestate-header)
204
+ *
205
+ * NOTE!: Additional headers may be added as part of a future update should the W3C Trace Context specification be updated
206
+ * to include additional headers.
207
+ *
208
+ * Config Decimal Value: `17` (Seventeen in decimal)
209
+ * @since 3.4.0
210
+ */
211
+ AI_AND_W3C_TRACE = 17,
212
+ /**
213
+ * Send all of the W3C Trace Context headers and the W3C Trace State headers.
214
+ *
215
+ * Currently sent headers:
216
+ * - [`traceparent`](https://www.w3.org/TR/trace-context/#traceparent-header)
217
+ * - [`tracestate`](https://www.w3.org/TR/trace-context/#tracestate-header)
218
+ *
219
+ * NOTE!: Additional headers may be added as part of a future update should the W3C Trace Context specification be updated
220
+ * to include additional headers.
221
+ *
222
+ * Config Decimal Value: `18` (Eighteen in decimal)
223
+ * @since 3.4.0
160
224
  */
161
- W3C = 2
225
+ W3C_TRACE = 18
162
226
  }
163
227
 
164
228
  const enum _eInternalMessageId {
@@ -300,6 +364,30 @@ declare namespace ApplicationInsights {
300
364
  Offline = 2
301
365
  }
302
366
 
367
+ /**
368
+ * Controls how the SDK should look for trace headers (traceparent/tracestate) from the initial page load
369
+ * The values are bitwise OR'd together to allow for multiple values to be set at once.
370
+ * @since 3.4.0
371
+ */
372
+ const enum eTraceHeadersMode {
373
+ /**
374
+ * Don't look for any trace headers
375
+ */
376
+ None = 0,
377
+ /**
378
+ * Look for traceparent header/meta tag
379
+ */
380
+ TraceParent = 1,
381
+ /**
382
+ * Look for tracestate header/meta tag
383
+ */
384
+ TraceState = 2,
385
+ /**
386
+ * Look for both traceparent and tracestate headers/meta tags
387
+ */
388
+ All = 3
389
+ }
390
+
303
391
  const enum FeatureOptInMode {
304
392
  /**
305
393
  * not set, completely depends on cdn cfg
@@ -442,7 +530,7 @@ declare namespace ApplicationInsights {
442
530
  */
443
531
  flush(isAsync?: boolean, callBack?: (flushComplete?: boolean) => void, sendReason?: SendRequestReason, cbTimeout?: number): boolean | void;
444
532
  /**
445
- * Gets the current distributed trace context for this instance if available
533
+ * Gets the current distributed trace active context for this instance
446
534
  * @param createNew - Optional flag to create a new instance if one doesn't currently exist, defaults to true
447
535
  */
448
536
  getTraceCtx(createNew?: boolean): IDistributedTraceContext | null;
@@ -510,9 +598,12 @@ declare namespace ApplicationInsights {
510
598
  */
511
599
  getCfg: () => IConfiguration;
512
600
  /**
513
- * Gets the named extension config
601
+ * Gets the named extension configuration
602
+ * @param identifier - The named extension identifier
603
+ * @param defaultValue - The default value(s) to return if no defined config exists
604
+ * @param rootOnly - If true, only the look for the configuration in the top level and not in the "extensionConfig"
514
605
  */
515
- getExtCfg: <T>(identifier: string, defaultValue?: IConfigDefaults<T>) => T;
606
+ getExtCfg: <T>(identifier: string, defaultValue?: IConfigDefaults<T>, rootOnly?: boolean) => T;
516
607
  /**
517
608
  * Gets the named config from either the named identifier extension or core config if neither exist then the
518
609
  * default value is returned
@@ -1133,7 +1224,7 @@ declare namespace ApplicationInsights {
1133
1224
  * }
1134
1225
  * ```
1135
1226
  *
1136
- * For more details, see the [Page Unload Events documentation](https://microsoft.github.io/ApplicationInsights-JS/docs/PageUnloadEvents.html).
1227
+ * For more details, see the [Page Unload Events documentation](https://microsoft.github.io/ApplicationInsights-JS/PageUnloadEvents.html).
1137
1228
  */
1138
1229
  disablePageUnloadEvents?: string[];
1139
1230
  /**
@@ -1148,7 +1239,7 @@ declare namespace ApplicationInsights {
1148
1239
  * }
1149
1240
  * ```
1150
1241
  *
1151
- * For more details, see the [Page Unload Events documentation](https://microsoft.github.io/ApplicationInsights-JS/docs/PageUnloadEvents.html).
1242
+ * For more details, see the [Page Unload Events documentation](https://microsoft.github.io/ApplicationInsights-JS/PageUnloadEvents.html).
1152
1243
  */
1153
1244
  disablePageShowEvents?: string[];
1154
1245
  /**
@@ -1190,6 +1281,25 @@ declare namespace ApplicationInsights {
1190
1281
  * @since 3.3.2
1191
1282
  */
1192
1283
  expCfg?: IExceptionConfig;
1284
+ /**
1285
+ * [Optional] A flag to enable or disable the use of the field redaction for urls.
1286
+ * @defaultValue true
1287
+ */
1288
+ redactUrls?: boolean;
1289
+ /**
1290
+ * [Optional] Additional query parameters to redact beyond the default set.
1291
+ * Use this to specify custom parameters that contain sensitive information.
1292
+ * These will be combined with the default parameters that are redacted.
1293
+ * @defaultValue ["sig", "Signature", "AWSAccessKeyId", "X-Goog-Signature"]
1294
+ * @example ["sig", "Signature", "AWSAccessKeyId", "X-Goog-Signature","auth_token", "api_key", "private_data"]
1295
+ */
1296
+ redactQueryParams?: string[];
1297
+ /**
1298
+ * [Optional] Controls if the SDK should look for the `traceparent` and/or `tracestate` values from
1299
+ * the service timing headers or meta tags from the initial page load.
1300
+ * @defaultValue eTraceHeadersMode.All
1301
+ */
1302
+ traceHdrMode?: eTraceHeadersMode;
1193
1303
  }
1194
1304
 
1195
1305
  interface ICookieMgr {
@@ -1370,8 +1480,13 @@ declare namespace ApplicationInsights {
1370
1480
  */
1371
1481
  getName(): string;
1372
1482
  /**
1373
- * Sets the current name of the page
1483
+ * Sets the current name of the page, also updates the name for any parent context.
1484
+ * This is used to identify the page in the telemetry data.
1485
+ * @remarks This function updates the current and ALL parent contexts with the new name,
1486
+ * to just update the name of the current context, use the `pageName` property.
1374
1487
  * @param pageName - The name of the page
1488
+ * @deprecated Use the `pageName` property to avoid the side effect of changing the page name of all
1489
+ * parent contexts.
1375
1490
  */
1376
1491
  setName(pageName: string): void;
1377
1492
  /**
@@ -1384,6 +1499,12 @@ declare namespace ApplicationInsights {
1384
1499
  * Set the unique identifier for a trace. All requests / spans from the same trace share the same traceId.
1385
1500
  * Must be conform to the W3C TraceContext specification, in a hex representation of 16-byte array.
1386
1501
  * A.k.a. trace-id, TraceID or Distributed TraceID https://www.w3.org/TR/trace-context/#trace-id
1502
+ *
1503
+ * @remarks Sets the traceId for the current context AND all parent contexts, if you want to set the traceId
1504
+ * for the current context only, use the `traceId` property.
1505
+ * @param newValue - The traceId to set
1506
+ * @deprecated Use the `traceId` property to avoid the side effect of changing the traceId of all
1507
+ * parent contexts.
1387
1508
  */
1388
1509
  setTraceId(newValue: string): void;
1389
1510
  /**
@@ -1395,6 +1516,12 @@ declare namespace ApplicationInsights {
1395
1516
  * Self-generated 8-bytes identifier of the incoming request. Must be a hex representation of 8-byte array.
1396
1517
  * Also know as the parentId, used to link requests together
1397
1518
  * https://www.w3.org/TR/trace-context/#parent-id
1519
+ *
1520
+ * @remarks Sets the spanId for the current context AND all parent contexts, if you want to set the spanId for
1521
+ * the current context only, use the `spanId` property.
1522
+ * @param newValue - The spanId to set
1523
+ * @deprecated Use the `spanId` property to avoid the side effect of changing the spanId of all
1524
+ * parent contexts.
1398
1525
  */
1399
1526
  setSpanId(newValue: string): void;
1400
1527
  /**
@@ -1403,9 +1530,80 @@ declare namespace ApplicationInsights {
1403
1530
  getTraceFlags(): number | undefined;
1404
1531
  /**
1405
1532
  * https://www.w3.org/TR/trace-context/#trace-flags
1533
+ * @remarks Sets the trace flags for the current context and ALL parent contexts, if you want to set the trace
1534
+ * flags for the current context only, use the `traceFlags` property.
1406
1535
  * @param newValue - An integer representation of the W3C TraceContext trace-flags.
1536
+ * @deprecated Use the `traceFlags` property to avoid the side effect of changing the traceFlags of all
1537
+ * parent contexts.
1407
1538
  */
1408
1539
  setTraceFlags(newValue?: number): void;
1540
+ /**
1541
+ * Returns the current name of the page
1542
+ * @remarks This function updates the current context only, to update the name of the current and ALL parent contexts,
1543
+ * use the `setName` method.
1544
+ * @default undefined
1545
+ * @since 3.4.0
1546
+ */
1547
+ pageName: string;
1548
+ /**
1549
+ * The current ID of the trace that this span belongs to. It is worldwide unique
1550
+ * with practically sufficient probability by being made as 16 randomly
1551
+ * generated bytes, encoded as a 32 lowercase hex characters corresponding to
1552
+ * 128 bits.
1553
+ * @remarks If you update this value, it will only update for the current context, not the parent context,
1554
+ * if you need to update the current and ALL parent contexts, use the `setTraceId` method.
1555
+ * @since 3.4.0
1556
+ */
1557
+ traceId: string;
1558
+ /**
1559
+ * The ID of the Span. It is globally unique with practically sufficient
1560
+ * probability by being made as 8 randomly generated bytes, encoded as a 16
1561
+ * lowercase hex characters corresponding to 64 bits.
1562
+ * If you update this value, it will only update for the current context, not the parent context.
1563
+ * @remarks If you update this value, it will only update for the current context, not the parent context,
1564
+ * if you need to update the current and ALL parent contexts, use the `setSpanId` method.
1565
+ * @since 3.4.0
1566
+ */
1567
+ spanId: string;
1568
+ /**
1569
+ * Returns true if the current context was initialized (propagated) from a remote parent.
1570
+ * @since 3.4.0
1571
+ * @default false
1572
+ * @returns True if the context was propagated from a remote parent
1573
+ */
1574
+ readonly isRemote: boolean;
1575
+ /**
1576
+ * Trace flags to propagate.
1577
+ *
1578
+ * It is represented as 1 byte (bitmap). Bit to represent whether trace is
1579
+ * sampled or not. When set, the least significant bit documents that the
1580
+ * caller may have recorded trace data. A caller who does not record trace
1581
+ * data out-of-band leaves this flag unset.
1582
+ *
1583
+ * see {@link eW3CTraceFlags} for valid flag values.
1584
+ *
1585
+ * @remarks If you update this value, it will only update for the current context, not the parent context,
1586
+ * if you need to update the current and ALL parent contexts, use the `setTraceFlags` method.
1587
+ * @since 3.4.0
1588
+ */
1589
+ traceFlags?: number;
1590
+ /**
1591
+ * Returns the current trace state which will be used to propgate context across different services.
1592
+ * Updating (adding / removing keys) of the trace state will modify the current context.
1593
+ * @remarks Unlike the OpenTelemetry {@link TraceState}, this value is a mutable object, so you can
1594
+ * modify it directly you do not need to reassign the new value to this property.
1595
+ * @since 3.4.0
1596
+ */
1597
+ readonly traceState: IW3cTraceState;
1598
+ /**
1599
+ * Provides access to the parent context of the current context.
1600
+ * @remarks This is a read-only property, you cannot modify the parent context directly, you can only
1601
+ * modify the current context. If you need to modify the parent context, you need to do it through the
1602
+ * current context using the `setTraceId`, `setSpanId`, `setTraceFlags` and `setName` methods.
1603
+ * @default null
1604
+ * @since 3.4.0
1605
+ */
1606
+ readonly parentCtx?: IDistributedTraceContext | null;
1409
1607
  }
1410
1608
 
1411
1609
  interface IEnvelope extends ISerializable {
@@ -2462,9 +2660,10 @@ declare namespace ApplicationInsights {
2462
2660
  */
2463
2661
  interface ITelemetryPlugin extends ITelemetryProcessor, IPlugin {
2464
2662
  /**
2465
- * Set next extension for telemetry processing, this is not optional as plugins should use the
2663
+ * Set next extension for telemetry processing, this is now optional as plugins should use the
2466
2664
  * processNext() function of the passed IProcessTelemetryContext instead. It is being kept for
2467
2665
  * now for backward compatibility only.
2666
+ * @deprecated - Use processNext() function of the passed IProcessTelemetryContext instead
2468
2667
  */
2469
2668
  setNextPlugin?: (next: ITelemetryPlugin | ITelemetryPluginChain) => void;
2470
2669
  /**
@@ -2746,6 +2945,76 @@ declare namespace ApplicationInsights {
2746
2945
  run: (logger?: IDiagnosticLogger) => void;
2747
2946
  }
2748
2947
 
2948
+ /**
2949
+ * Represents a mutable [W3C trace state list](https://www.w3.org/TR/trace-context/#tracestate-header), this is a
2950
+ * list of key/value pairs that are used to pass trace state information between different tracing systems. The
2951
+ * list is ordered and the order is important as it determines the processing order.
2952
+ *
2953
+ * Importantly instances of this type are mutable, change made to an instance via {@link IW3cTraceState.set} or
2954
+ * {@link IW3cTraceState.del} will be reflected on the instance and any child instances that use it as a parent.
2955
+ * However, any parent instance associated with an instance will not be modified by operations on that particular
2956
+ * instance.
2957
+ *
2958
+ * @since 3.4.0
2959
+ */
2960
+ interface IW3cTraceState {
2961
+ /**
2962
+ * Returns a readonly array of the current keys associated with the trace state, keys are returned in the
2963
+ * required processing order and if this instance has a parent the keys from the parent will be included
2964
+ * unless they have been removed (deleted) from the child instance.
2965
+ * Once created any modifications to the parent will also be reflected in the child, this is different from
2966
+ * the OpenTelemetry implementation which creates a new instance for each call.
2967
+ * @returns A readonly array of the current keys associated with the trace state
2968
+ */
2969
+ readonly keys: string[];
2970
+ /**
2971
+ * Check if the trace state list is empty, meaning it has no keys or values.
2972
+ * This exists to allow for quick checks without needing to create a new array of keys.
2973
+ * @since 3.4.0
2974
+ * @returns true if the trace state list is empty, false otherwise
2975
+ */
2976
+ readonly isEmpty: boolean;
2977
+ /**
2978
+ * Get the value for the specified key that is associated with this instance, either directly or from the parent.
2979
+ * @param key - The key to lookup
2980
+ * @returns The value for the key, or undefined if not found
2981
+ */
2982
+ get(key: string): string | undefined;
2983
+ /**
2984
+ * Set the value for the specified key for this instance, returning its new location within the list.
2985
+ * - 0 is the front of the list
2986
+ * - -1 not set because the key/value pair is invalid
2987
+ * If the key already exists it will be removed from its current location and added to the front of the list. And
2988
+ * if the key was in the parent this will override the value inherited from the parent, more importantly it will
2989
+ * not modify the parent value.
2990
+ * @param key - The key to set
2991
+ * @param value - The value to set
2992
+ * @returns 0 if successful, -1 if not
2993
+ */
2994
+ set(key: string, value: string): number;
2995
+ /**
2996
+ * Delete the specified key from this instance, if the key was in the parent it will be removed (hidden) from
2997
+ * this instance but will still be available directly from the parent.
2998
+ * @param key - The key to delete
2999
+ */
3000
+ del(key: string): void;
3001
+ /**
3002
+ * Format the trace state list into a strings where each string can be used as a header value.
3003
+ * This will return an empty array if the trace state list is empty.
3004
+ * @param maxHeaders - The maximum number of entries to include in the output, once the limit is reached no more entries will be included
3005
+ * @param maxKeys - The maximum number of keys to include in the output, once the limit is reached no more keys will be included
3006
+ * @param maxLen - The maximum length of each header value, once the limit is reached a new header value will be created
3007
+ * @returns An array of strings that can be used for the header values, if the trace state list is empty an empty array will be returned
3008
+ */
3009
+ hdrs(maxHeaders?: number, maxKeys?: number, maxLen?: number): string[];
3010
+ /**
3011
+ * Create a new instance of IW3cTraceState which is a child of this instance, meaning it will inherit the keys
3012
+ * and values from this instance but any changes made to the child will not affect this instance.
3013
+ * @returns A new instance of IW3cTraceState which is a child of this instance
3014
+ */
3015
+ child(): IW3cTraceState;
3016
+ }
3017
+
2749
3018
  interface IWatchDetails<T = IConfiguration> {
2750
3019
  /**
2751
3020
  * The current config object