@microsoft/applicationinsights-common 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 (103) hide show
  1. package/browser/es5/applicationinsights-common.cjs.js +794 -202
  2. package/browser/es5/applicationinsights-common.cjs.js.map +1 -1
  3. package/browser/es5/applicationinsights-common.cjs.min.js +2 -2
  4. package/browser/es5/applicationinsights-common.cjs.min.js.map +1 -1
  5. package/browser/es5/applicationinsights-common.gbl.js +796 -204
  6. package/browser/es5/applicationinsights-common.gbl.js.map +1 -1
  7. package/browser/es5/applicationinsights-common.gbl.min.js +2 -2
  8. package/browser/es5/applicationinsights-common.gbl.min.js.map +1 -1
  9. package/browser/es5/applicationinsights-common.integrity.json +25 -25
  10. package/browser/es5/applicationinsights-common.js +796 -204
  11. package/browser/es5/applicationinsights-common.js.map +1 -1
  12. package/browser/es5/applicationinsights-common.min.js +2 -2
  13. package/browser/es5/applicationinsights-common.min.js.map +1 -1
  14. package/dist/es5/applicationinsights-common.js +794 -202
  15. package/dist/es5/applicationinsights-common.js.map +1 -1
  16. package/dist/es5/applicationinsights-common.min.js +2 -2
  17. package/dist/es5/applicationinsights-common.min.js.map +1 -1
  18. package/dist-es5/ConnectionStringParser.js +1 -1
  19. package/dist-es5/Constants.js +1 -1
  20. package/dist-es5/DomHelperFuncs.js +1 -1
  21. package/dist-es5/Enums.js +13 -8
  22. package/dist-es5/Enums.js.map +1 -1
  23. package/dist-es5/HelperFuncs.js +1 -1
  24. package/dist-es5/Interfaces/ConnectionString.js +1 -1
  25. package/dist-es5/Interfaces/Context/IApplication.js +1 -1
  26. package/dist-es5/Interfaces/Context/IDevice.js +1 -1
  27. package/dist-es5/Interfaces/Context/IInternal.js +1 -1
  28. package/dist-es5/Interfaces/Context/ILocation.js +1 -1
  29. package/dist-es5/Interfaces/Context/IOperatingSystem.js +1 -1
  30. package/dist-es5/Interfaces/Context/ISample.js +1 -1
  31. package/dist-es5/Interfaces/Context/ISession.js +1 -1
  32. package/dist-es5/Interfaces/Context/ISessionManager.js +1 -1
  33. package/dist-es5/Interfaces/Context/ITelemetryTrace.js +1 -1
  34. package/dist-es5/Interfaces/Context/IUser.js +1 -1
  35. package/dist-es5/Interfaces/Context/IWeb.js +1 -1
  36. package/dist-es5/Interfaces/Contracts/AvailabilityData.js +1 -1
  37. package/dist-es5/Interfaces/Contracts/ContextTagKeys.js +1 -1
  38. package/dist-es5/Interfaces/Contracts/DataPointType.js +1 -1
  39. package/dist-es5/Interfaces/Contracts/DependencyKind.js +1 -1
  40. package/dist-es5/Interfaces/Contracts/DependencySourceType.js +1 -1
  41. package/dist-es5/Interfaces/Contracts/IBase.js +1 -1
  42. package/dist-es5/Interfaces/Contracts/IData.js +1 -1
  43. package/dist-es5/Interfaces/Contracts/IDataPoint.js +1 -1
  44. package/dist-es5/Interfaces/Contracts/IDomain.js +1 -1
  45. package/dist-es5/Interfaces/Contracts/IEnvelope.js +1 -1
  46. package/dist-es5/Interfaces/Contracts/IEventData.js +1 -1
  47. package/dist-es5/Interfaces/Contracts/IExceptionData.js +1 -1
  48. package/dist-es5/Interfaces/Contracts/IExceptionDetails.js +1 -1
  49. package/dist-es5/Interfaces/Contracts/IMessageData.js +1 -1
  50. package/dist-es5/Interfaces/Contracts/IMetricData.js +1 -1
  51. package/dist-es5/Interfaces/Contracts/IPageViewData.js +1 -1
  52. package/dist-es5/Interfaces/Contracts/IPageViewPerfData.js +1 -1
  53. package/dist-es5/Interfaces/Contracts/IRemoteDependencyData.js +1 -1
  54. package/dist-es5/Interfaces/Contracts/IStackFrame.js +1 -1
  55. package/dist-es5/Interfaces/Contracts/RequestData.js +1 -1
  56. package/dist-es5/Interfaces/Contracts/SeverityLevel.js +3 -3
  57. package/dist-es5/Interfaces/Contracts/SeverityLevel.js.map +1 -1
  58. package/dist-es5/Interfaces/IAppInsights.js +1 -1
  59. package/dist-es5/Interfaces/IConfig.js +1 -1
  60. package/dist-es5/Interfaces/ICorrelationConfig.js +1 -1
  61. package/dist-es5/Interfaces/IDependencyTelemetry.js +1 -1
  62. package/dist-es5/Interfaces/IEventTelemetry.js +1 -1
  63. package/dist-es5/Interfaces/IExceptionTelemetry.js +1 -1
  64. package/dist-es5/Interfaces/IMetricTelemetry.js +1 -1
  65. package/dist-es5/Interfaces/IPageViewPerformanceTelemetry.js +1 -1
  66. package/dist-es5/Interfaces/IPageViewTelemetry.js +1 -1
  67. package/dist-es5/Interfaces/IPartC.js +1 -1
  68. package/dist-es5/Interfaces/IPropertiesPlugin.js +1 -1
  69. package/dist-es5/Interfaces/IRequestContext.js +1 -1
  70. package/dist-es5/Interfaces/IStorageBuffer.js +1 -1
  71. package/dist-es5/Interfaces/ITelemetryContext.js +1 -1
  72. package/dist-es5/Interfaces/IThrottleMgr.js +1 -1
  73. package/dist-es5/Interfaces/ITraceTelemetry.js +1 -1
  74. package/dist-es5/Interfaces/PartAExtensions.js +1 -1
  75. package/dist-es5/Interfaces/Telemetry/IEnvelope.js +1 -1
  76. package/dist-es5/Interfaces/Telemetry/ISerializable.js +1 -1
  77. package/dist-es5/Offline.js +1 -1
  78. package/dist-es5/RequestResponseHeaders.js +3 -3
  79. package/dist-es5/RequestResponseHeaders.js.map +1 -1
  80. package/dist-es5/StorageHelperFuncs.js +1 -1
  81. package/dist-es5/Telemetry/Common/Data.js +1 -1
  82. package/dist-es5/Telemetry/Common/DataPoint.js +1 -1
  83. package/dist-es5/Telemetry/Common/DataSanitizer.js +7 -4
  84. package/dist-es5/Telemetry/Common/DataSanitizer.js.map +1 -1
  85. package/dist-es5/Telemetry/Common/Envelope.js +1 -1
  86. package/dist-es5/Telemetry/Event.js +1 -1
  87. package/dist-es5/Telemetry/Exception.js +1 -1
  88. package/dist-es5/Telemetry/Metric.js +1 -1
  89. package/dist-es5/Telemetry/PageView.js +1 -1
  90. package/dist-es5/Telemetry/PageViewPerformance.js +1 -1
  91. package/dist-es5/Telemetry/RemoteDependencyData.js +1 -1
  92. package/dist-es5/Telemetry/Trace.js +1 -1
  93. package/dist-es5/TelemetryItemCreator.js +1 -1
  94. package/dist-es5/ThrottleMgr.js +1 -1
  95. package/dist-es5/UrlHelperFuncs.js +1 -1
  96. package/dist-es5/Util.js +13 -38
  97. package/dist-es5/Util.js.map +1 -1
  98. package/dist-es5/__DynamicConstants.js +3 -2
  99. package/dist-es5/__DynamicConstants.js.map +1 -1
  100. package/dist-es5/applicationinsights-common.js +1 -1
  101. package/package.json +2 -2
  102. package/types/applicationinsights-common.d.ts +165 -15
  103. package/types/applicationinsights-common.namespaced.d.ts +377 -22
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Microsoft Application Insights Common JavaScript Library, 3.4.0-nightlybeta3.2505-35
2
+ * Microsoft Application Insights Common JavaScript Library, 3.4.0-nightlybeta3.2507-23
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  *
5
5
  * Microsoft Application Insights Team
@@ -83,6 +83,8 @@ declare namespace ApplicationInsights {
83
83
  * @param telemetryTrace - The telemetryTrace instance that is being wrapped
84
84
  * @param parentCtx - An optional parent distributed trace instance, almost always undefined as this scenario is only used in the case of multiple property handlers.
85
85
  * @returns A new IDistributedTraceContext instance that is backed by the telemetryTrace or temporary object
86
+ * @deprecated This function is deprecated and will be removed in a future version. Use the createDistributedTraceContext function instead and set the necessary properties
87
+ * on the context object directly.
86
88
  */
87
89
  function createDistributedTraceContextFromTrace(telemetryTrace?: ITelemetryTrace, parentCtx?: IDistributedTraceContext): IDistributedTraceContext;
88
90
 
@@ -243,7 +245,7 @@ declare namespace ApplicationInsights {
243
245
 
244
246
  function dataSanitizeString(logger: IDiagnosticLogger, value: any, maxLength?: number): any;
245
247
 
246
- function dataSanitizeUrl(logger: IDiagnosticLogger, url: any): any;
248
+ function dataSanitizeUrl(logger: IDiagnosticLogger, url: any, config?: IConfiguration): any;
247
249
 
248
250
  function dateTimeUtilsDuration(start: number, end: number): number;
249
251
 
@@ -287,17 +289,78 @@ declare namespace ApplicationInsights {
287
289
 
288
290
  const enum eDistributedTracingModes {
289
291
  /**
290
- * (Default) Send Application Insights correlation headers
292
+ * Send only the legacy Application Insights correlation headers
293
+ *
294
+ * Headers Sent:
295
+ * - `Request-Id` (Legacy Application Insights header for older Server side SDKs)
296
+ *
297
+ * Config Decimal Value: `0` (Zero)
291
298
  */
292
299
  AI = 0,
293
300
  /**
294
- * Send both W3C Trace Context headers and back-compatibility Application Insights headers
301
+ * (Default) Send both W3C Trace parent header and back-compatibility Application Insights headers
302
+ * - `Request-Id`
303
+ * - [`traceparent`](https://www.w3.org/TR/trace-context/#traceparent-header)
304
+ *
305
+ * Config Decimal Value: `1` (One)
295
306
  */
296
307
  AI_AND_W3C = 1,
297
308
  /**
298
- * Send W3C Trace Context headers
309
+ * Send Only the W3C Trace parent header
310
+ *
311
+ * Headers Sent:
312
+ * - [`traceparent`](https://www.w3.org/TR/trace-context/#traceparent-header)
313
+ *
314
+ * Config Decimal Value: `2` (Two)
299
315
  */
300
- W3C = 2
316
+ W3C = 2,
317
+ /**
318
+ * @internal
319
+ * Bitwise mask used to separate the base distributed tracing mode from the additional optional
320
+ * tracing modes.
321
+ * @since 3.4.0
322
+ */
323
+ _BaseMask = 15,
324
+ /**
325
+ * @internal
326
+ * Enabling this bit will send the W3C Trace State header, it is not intended to be used directly
327
+ * or on its own. The code may assume that if this bit is set, then the W3C Trace Context headers
328
+ * will also be included.
329
+ *
330
+ * Config Decimal Value: `16` (Sixteen in decimal)
331
+ * @since 3.4.0
332
+ */
333
+ _W3CTraceState = 16,
334
+ /**
335
+ * Send all of the W3C Trace Context headers and the W3C Trace State headers and back-compatibility
336
+ * Application Insights headers.
337
+ *
338
+ * Currently sent headers:
339
+ * - `Request-Id` (Legacy Application Insights header for older Server side SDKs)
340
+ * - [`traceparent`](https://www.w3.org/TR/trace-context/#traceparent-header)
341
+ * - [`tracestate`](https://www.w3.org/TR/trace-context/#tracestate-header)
342
+ *
343
+ * NOTE!: Additional headers may be added as part of a future update should the W3C Trace Context specification be updated
344
+ * to include additional headers.
345
+ *
346
+ * Config Decimal Value: `17` (Seventeen in decimal)
347
+ * @since 3.4.0
348
+ */
349
+ AI_AND_W3C_TRACE = 17,
350
+ /**
351
+ * Send all of the W3C Trace Context headers and the W3C Trace State headers.
352
+ *
353
+ * Currently sent headers:
354
+ * - [`traceparent`](https://www.w3.org/TR/trace-context/#traceparent-header)
355
+ * - [`tracestate`](https://www.w3.org/TR/trace-context/#tracestate-header)
356
+ *
357
+ * NOTE!: Additional headers may be added as part of a future update should the W3C Trace Context specification be updated
358
+ * to include additional headers.
359
+ *
360
+ * Config Decimal Value: `18` (Eighteen in decimal)
361
+ * @since 3.4.0
362
+ */
363
+ W3C_TRACE = 18
301
364
  }
302
365
 
303
366
  const enum _eInternalMessageId {
@@ -505,6 +568,30 @@ declare namespace ApplicationInsights {
505
568
  Critical = 4
506
569
  }
507
570
 
571
+ /**
572
+ * Controls how the SDK should look for trace headers (traceparent/tracestate) from the initial page load
573
+ * The values are bitwise OR'd together to allow for multiple values to be set at once.
574
+ * @since 3.4.0
575
+ */
576
+ const enum eTraceHeadersMode {
577
+ /**
578
+ * Don't look for any trace headers
579
+ */
580
+ None = 0,
581
+ /**
582
+ * Look for traceparent header/meta tag
583
+ */
584
+ TraceParent = 1,
585
+ /**
586
+ * Look for tracestate header/meta tag
587
+ */
588
+ TraceState = 2,
589
+ /**
590
+ * Look for both traceparent and tracestate headers/meta tags
591
+ */
592
+ All = 3
593
+ }
594
+
508
595
  class Event_2 implements IEventData, ISerializable {
509
596
  static envelopeType: string;
510
597
  static dataType: string;
@@ -848,7 +935,7 @@ declare namespace ApplicationInsights {
848
935
  */
849
936
  flush(isAsync?: boolean, callBack?: (flushComplete?: boolean) => void, sendReason?: SendRequestReason, cbTimeout?: number): boolean | void;
850
937
  /**
851
- * Gets the current distributed trace context for this instance if available
938
+ * Gets the current distributed trace active context for this instance
852
939
  * @param createNew - Optional flag to create a new instance if one doesn't currently exist, defaults to true
853
940
  */
854
941
  getTraceCtx(createNew?: boolean): IDistributedTraceContext | null;
@@ -952,9 +1039,12 @@ declare namespace ApplicationInsights {
952
1039
  */
953
1040
  getCfg: () => IConfiguration;
954
1041
  /**
955
- * Gets the named extension config
1042
+ * Gets the named extension configuration
1043
+ * @param identifier - The named extension identifier
1044
+ * @param defaultValue - The default value(s) to return if no defined config exists
1045
+ * @param rootOnly - If true, only the look for the configuration in the top level and not in the "extensionConfig"
956
1046
  */
957
- getExtCfg: <T>(identifier: string, defaultValue?: IConfigDefaults<T>) => T;
1047
+ getExtCfg: <T>(identifier: string, defaultValue?: IConfigDefaults<T>, rootOnly?: boolean) => T;
958
1048
  /**
959
1049
  * Gets the named config from either the named identifier extension or core config if neither exist then the
960
1050
  * default value is returned
@@ -1575,7 +1665,7 @@ declare namespace ApplicationInsights {
1575
1665
  * }
1576
1666
  * ```
1577
1667
  *
1578
- * For more details, see the [Page Unload Events documentation](https://microsoft.github.io/ApplicationInsights-JS/docs/PageUnloadEvents.html).
1668
+ * For more details, see the [Page Unload Events documentation](https://microsoft.github.io/ApplicationInsights-JS/PageUnloadEvents.html).
1579
1669
  */
1580
1670
  disablePageUnloadEvents?: string[];
1581
1671
  /**
@@ -1590,7 +1680,7 @@ declare namespace ApplicationInsights {
1590
1680
  * }
1591
1681
  * ```
1592
1682
  *
1593
- * For more details, see the [Page Unload Events documentation](https://microsoft.github.io/ApplicationInsights-JS/docs/PageUnloadEvents.html).
1683
+ * For more details, see the [Page Unload Events documentation](https://microsoft.github.io/ApplicationInsights-JS/PageUnloadEvents.html).
1594
1684
  */
1595
1685
  disablePageShowEvents?: string[];
1596
1686
  /**
@@ -1632,6 +1722,25 @@ declare namespace ApplicationInsights {
1632
1722
  * @since 3.3.2
1633
1723
  */
1634
1724
  expCfg?: IExceptionConfig;
1725
+ /**
1726
+ * [Optional] A flag to enable or disable the use of the field redaction for urls.
1727
+ * @defaultValue true
1728
+ */
1729
+ redactUrls?: boolean;
1730
+ /**
1731
+ * [Optional] Additional query parameters to redact beyond the default set.
1732
+ * Use this to specify custom parameters that contain sensitive information.
1733
+ * These will be combined with the default parameters that are redacted.
1734
+ * @defaultValue ["sig", "Signature", "AWSAccessKeyId", "X-Goog-Signature"]
1735
+ * @example ["sig", "Signature", "AWSAccessKeyId", "X-Goog-Signature","auth_token", "api_key", "private_data"]
1736
+ */
1737
+ redactQueryParams?: string[];
1738
+ /**
1739
+ * [Optional] Controls if the SDK should look for the `traceparent` and/or `tracestate` values from
1740
+ * the service timing headers or meta tags from the initial page load.
1741
+ * @defaultValue eTraceHeadersMode.All
1742
+ */
1743
+ traceHdrMode?: eTraceHeadersMode;
1635
1744
  }
1636
1745
 
1637
1746
  interface IContextTagKeys {
@@ -1915,9 +2024,68 @@ declare namespace ApplicationInsights {
1915
2024
 
1916
2025
  interface ICorrelationConfig {
1917
2026
  enableCorsCorrelation: boolean;
2027
+ /**
2028
+ * [Optional] Domains to be excluded from correlation headers.
2029
+ * To override or discard the default, add an array with all domains to be excluded or
2030
+ * an empty array to the configuration.
2031
+ *
2032
+ * @example
2033
+ * ```ts
2034
+ * import { ApplicationInsights } from '@microsoft/applicationinsights-web';
2035
+ * const appInsights = new ApplicationInsights({
2036
+ * config: {
2037
+ * connectionString: 'InstrumentationKey=YOUR_INSTRUMENTATION_KEY_GOES_HERE',
2038
+ * extensionConfig: {
2039
+ * AjaxDependencyPlugin: {
2040
+ * // Both arrays of strings are used to match the request URL against the
2041
+ * // current host and the request URL to determine if correlation headers
2042
+ * // The strings are converted to RegExp objects by translating
2043
+ * // - `.` to `\\.` (to match a literal dot)
2044
+ * // - `*` to `.*` (to match any character)
2045
+ * // - `\` to `\\` (to match a literal slash)
2046
+ * // All other characters are ignored and passed to the RegExp constructor
2047
+ * correlationHeaderExcludedDomains: ["test", "*.azure.com", "ignore.microsoft.com"],
2048
+ * correlationHeaderDomains: ["azure.com", "prefix.bing.com", "*.microsoft.com", "example.com"]
2049
+ * }
2050
+ * }
2051
+ * });
2052
+ * appInsights.loadAppInsights();
2053
+ * appInsights.trackPageView(); // Manually call trackPageView to establish the current user/session/pageview
2054
+ * ```
2055
+ */
1918
2056
  correlationHeaderExcludedDomains: string[];
2057
+ /**
2058
+ * [Optional] Domains to be included in correlation headers.
2059
+ * To override or discard the default, add an array with all domains to be included or
2060
+ * an empty array to the configuration.
2061
+ *
2062
+ * @example
2063
+ * ```ts
2064
+ * import { ApplicationInsights } from '@microsoft/applicationinsights-web';
2065
+ * const appInsights = new ApplicationInsights({
2066
+ * config: {
2067
+ * connectionString: 'InstrumentationKey=YOUR_INSTRUMENTATION_KEY_GOES_HERE',
2068
+ * extensionConfig: {
2069
+ * AjaxDependencyPlugin: {
2070
+ * // Values MUST be RegExp objects
2071
+ * correlationHeaderExcludePatterns: [/*\.azure.com/, /prefix.bing.com/, /.*\.microsoft.com/, /example.com/]
2072
+ * }
2073
+ * }
2074
+ * });
2075
+ * appInsights.loadAppInsights();
2076
+ * appInsights.trackPageView(); // Manually call trackPageView to establish the current user/session/pageview
2077
+ * ```
2078
+ */
1919
2079
  correlationHeaderExcludePatterns?: RegExp[];
1920
2080
  disableCorrelationHeaders: boolean;
2081
+ /**
2082
+ * The distributed tracing mode to use for this configuration.
2083
+ * Defaults to AI_AND_W3C.
2084
+ * This is used to determine which headers are sent with requests and how the
2085
+ * telemetry is correlated across services.
2086
+ * @default AI_AND_W3C
2087
+ * @see {@link DistributedTracingModes}
2088
+ */
1921
2089
  distributedTracingMode: DistributedTracingModes;
1922
2090
  maxAjaxCallsPerView: number;
1923
2091
  disableAjaxTracking: boolean;
@@ -1945,6 +2113,35 @@ declare namespace ApplicationInsights {
1945
2113
  * Defaults to 25.
1946
2114
  */
1947
2115
  ajaxPerfLookupDelay?: number;
2116
+ /**
2117
+ * [Optional] Domains to be excluded from correlation headers.
2118
+ * To override or discard the default, add an array with all domains to be excluded or
2119
+ * an empty array to the configuration.
2120
+ *
2121
+ * @example
2122
+ * ```ts
2123
+ * import { ApplicationInsights } from '@microsoft/applicationinsights-web';
2124
+ * const appInsights = new ApplicationInsights({
2125
+ * config: {
2126
+ * connectionString: 'InstrumentationKey=YOUR_INSTRUMENTATION_KEY_GOES_HERE',
2127
+ * extensionConfig: {
2128
+ * AjaxDependencyPlugin: {
2129
+ * // Both arrays of strings are used to match the request URL against the
2130
+ * // current host and the request URL to determine if correlation headers
2131
+ * // The strings are converted to RegExp objects by translating
2132
+ * // - `.` to `\\.` (to match a literal dot)
2133
+ * // - `*` to `.*` (to match any character)
2134
+ * // - `\` to `\\` (to match a literal slash)
2135
+ * // All other characters are ignored and passed to the RegExp constructor
2136
+ * correlationHeaderExcludedDomains: ["test", "*.azure.com", "ignore.microsoft.com"],
2137
+ * correlationHeaderDomains: ["azure.com", "prefix.bing.com", "*.microsoft.com", "example.com"]
2138
+ * }
2139
+ * }
2140
+ * });
2141
+ * appInsights.loadAppInsights();
2142
+ * appInsights.trackPageView(); // Manually call trackPageView to establish the current user/session/pageview
2143
+ * ```
2144
+ */
1948
2145
  correlationHeaderDomains?: string[];
1949
2146
  /**
1950
2147
  * [Optional] Response and request headers to be excluded from AJAX & Fetch tracking data.
@@ -1964,7 +2161,7 @@ declare namespace ApplicationInsights {
1964
2161
  * connectionString: 'InstrumentationKey=YOUR_INSTRUMENTATION_KEY_GOES_HERE',
1965
2162
  * extensions: [dependencyPlugin],
1966
2163
  * extensionConfig: {
1967
- * [dependencyPlugin.identifier]: {
2164
+ * AjaxDependencyPlugin: {
1968
2165
  * ignoreHeaders: [
1969
2166
  * "Authorization",
1970
2167
  * "X-API-Key",
@@ -2143,8 +2340,13 @@ declare namespace ApplicationInsights {
2143
2340
  */
2144
2341
  getName(): string;
2145
2342
  /**
2146
- * Sets the current name of the page
2343
+ * Sets the current name of the page, also updates the name for any parent context.
2344
+ * This is used to identify the page in the telemetry data.
2345
+ * @remarks This function updates the current and ALL parent contexts with the new name,
2346
+ * to just update the name of the current context, use the `pageName` property.
2147
2347
  * @param pageName - The name of the page
2348
+ * @deprecated Use the `pageName` property to avoid the side effect of changing the page name of all
2349
+ * parent contexts.
2148
2350
  */
2149
2351
  setName(pageName: string): void;
2150
2352
  /**
@@ -2157,6 +2359,12 @@ declare namespace ApplicationInsights {
2157
2359
  * Set the unique identifier for a trace. All requests / spans from the same trace share the same traceId.
2158
2360
  * Must be conform to the W3C TraceContext specification, in a hex representation of 16-byte array.
2159
2361
  * A.k.a. trace-id, TraceID or Distributed TraceID https://www.w3.org/TR/trace-context/#trace-id
2362
+ *
2363
+ * @remarks Sets the traceId for the current context AND all parent contexts, if you want to set the traceId
2364
+ * for the current context only, use the `traceId` property.
2365
+ * @param newValue - The traceId to set
2366
+ * @deprecated Use the `traceId` property to avoid the side effect of changing the traceId of all
2367
+ * parent contexts.
2160
2368
  */
2161
2369
  setTraceId(newValue: string): void;
2162
2370
  /**
@@ -2168,6 +2376,12 @@ declare namespace ApplicationInsights {
2168
2376
  * Self-generated 8-bytes identifier of the incoming request. Must be a hex representation of 8-byte array.
2169
2377
  * Also know as the parentId, used to link requests together
2170
2378
  * https://www.w3.org/TR/trace-context/#parent-id
2379
+ *
2380
+ * @remarks Sets the spanId for the current context AND all parent contexts, if you want to set the spanId for
2381
+ * the current context only, use the `spanId` property.
2382
+ * @param newValue - The spanId to set
2383
+ * @deprecated Use the `spanId` property to avoid the side effect of changing the spanId of all
2384
+ * parent contexts.
2171
2385
  */
2172
2386
  setSpanId(newValue: string): void;
2173
2387
  /**
@@ -2176,9 +2390,80 @@ declare namespace ApplicationInsights {
2176
2390
  getTraceFlags(): number | undefined;
2177
2391
  /**
2178
2392
  * https://www.w3.org/TR/trace-context/#trace-flags
2393
+ * @remarks Sets the trace flags for the current context and ALL parent contexts, if you want to set the trace
2394
+ * flags for the current context only, use the `traceFlags` property.
2179
2395
  * @param newValue - An integer representation of the W3C TraceContext trace-flags.
2396
+ * @deprecated Use the `traceFlags` property to avoid the side effect of changing the traceFlags of all
2397
+ * parent contexts.
2180
2398
  */
2181
2399
  setTraceFlags(newValue?: number): void;
2400
+ /**
2401
+ * Returns the current name of the page
2402
+ * @remarks This function updates the current context only, to update the name of the current and ALL parent contexts,
2403
+ * use the `setName` method.
2404
+ * @default undefined
2405
+ * @since 3.4.0
2406
+ */
2407
+ pageName: string;
2408
+ /**
2409
+ * The current ID of the trace that this span belongs to. It is worldwide unique
2410
+ * with practically sufficient probability by being made as 16 randomly
2411
+ * generated bytes, encoded as a 32 lowercase hex characters corresponding to
2412
+ * 128 bits.
2413
+ * @remarks If you update this value, it will only update for the current context, not the parent context,
2414
+ * if you need to update the current and ALL parent contexts, use the `setTraceId` method.
2415
+ * @since 3.4.0
2416
+ */
2417
+ traceId: string;
2418
+ /**
2419
+ * The ID of the Span. It is globally unique with practically sufficient
2420
+ * probability by being made as 8 randomly generated bytes, encoded as a 16
2421
+ * lowercase hex characters corresponding to 64 bits.
2422
+ * If you update this value, it will only update for the current context, not the parent context.
2423
+ * @remarks If you update this value, it will only update for the current context, not the parent context,
2424
+ * if you need to update the current and ALL parent contexts, use the `setSpanId` method.
2425
+ * @since 3.4.0
2426
+ */
2427
+ spanId: string;
2428
+ /**
2429
+ * Returns true if the current context was initialized (propagated) from a remote parent.
2430
+ * @since 3.4.0
2431
+ * @default false
2432
+ * @returns True if the context was propagated from a remote parent
2433
+ */
2434
+ readonly isRemote: boolean;
2435
+ /**
2436
+ * Trace flags to propagate.
2437
+ *
2438
+ * It is represented as 1 byte (bitmap). Bit to represent whether trace is
2439
+ * sampled or not. When set, the least significant bit documents that the
2440
+ * caller may have recorded trace data. A caller who does not record trace
2441
+ * data out-of-band leaves this flag unset.
2442
+ *
2443
+ * see {@link eW3CTraceFlags} for valid flag values.
2444
+ *
2445
+ * @remarks If you update this value, it will only update for the current context, not the parent context,
2446
+ * if you need to update the current and ALL parent contexts, use the `setTraceFlags` method.
2447
+ * @since 3.4.0
2448
+ */
2449
+ traceFlags?: number;
2450
+ /**
2451
+ * Returns the current trace state which will be used to propgate context across different services.
2452
+ * Updating (adding / removing keys) of the trace state will modify the current context.
2453
+ * @remarks Unlike the OpenTelemetry {@link TraceState}, this value is a mutable object, so you can
2454
+ * modify it directly you do not need to reassign the new value to this property.
2455
+ * @since 3.4.0
2456
+ */
2457
+ readonly traceState: IW3cTraceState;
2458
+ /**
2459
+ * Provides access to the parent context of the current context.
2460
+ * @remarks This is a read-only property, you cannot modify the parent context directly, you can only
2461
+ * modify the current context. If you need to modify the parent context, you need to do it through the
2462
+ * current context using the `setTraceId`, `setSpanId`, `setTraceFlags` and `setName` methods.
2463
+ * @default null
2464
+ * @since 3.4.0
2465
+ */
2466
+ readonly parentCtx?: IDistributedTraceContext | null;
2182
2467
  }
2183
2468
 
2184
2469
  /**
@@ -3641,6 +3926,8 @@ declare namespace ApplicationInsights {
3641
3926
  readonly location: ILocation;
3642
3927
  /**
3643
3928
  * The object describing a operation tracked by this object.
3929
+ * @deprecated Use the core getTraceCtx method instead to get / set the current trace context, this is required to
3930
+ * support distributed tracing and allows the core to manage the trace context.
3644
3931
  */
3645
3932
  readonly telemetryTrace: ITelemetryTrace;
3646
3933
  /**
@@ -3728,9 +4015,10 @@ declare namespace ApplicationInsights {
3728
4015
  */
3729
4016
  interface ITelemetryPlugin extends ITelemetryProcessor, IPlugin {
3730
4017
  /**
3731
- * Set next extension for telemetry processing, this is not optional as plugins should use the
4018
+ * Set next extension for telemetry processing, this is now optional as plugins should use the
3732
4019
  * processNext() function of the passed IProcessTelemetryContext instead. It is being kept for
3733
4020
  * now for backward compatibility only.
4021
+ * @deprecated - Use processNext() function of the passed IProcessTelemetryContext instead
3734
4022
  */
3735
4023
  setNextPlugin?: (next: ITelemetryPlugin | ITelemetryPluginChain) => void;
3736
4024
  /**
@@ -3780,6 +4068,11 @@ declare namespace ApplicationInsights {
3780
4068
  update?: (updateCtx: IProcessTelemetryUpdateContext, updateState: ITelemetryUpdateState) => void | boolean;
3781
4069
  }
3782
4070
 
4071
+ /**
4072
+ * Interface for telemetry trace context.
4073
+ * @deprecated Use the core getTraceCtx method instead to get / set the current trace context, this is required to
4074
+ * support distributed tracing and allows the core to manage the trace context.
4075
+ */
3783
4076
  interface ITelemetryTrace {
3784
4077
  /**
3785
4078
  * Trace id
@@ -3789,11 +4082,6 @@ declare namespace ApplicationInsights {
3789
4082
  * Parent id
3790
4083
  */
3791
4084
  parentID?: string;
3792
- /**
3793
- * @deprecated Never Used
3794
- * Trace state
3795
- */
3796
- traceState?: ITraceState;
3797
4085
  /**
3798
4086
  * An integer representation of the W3C TraceContext trace-flags. https://www.w3.org/TR/trace-context/#trace-flags
3799
4087
  */
@@ -4083,9 +4371,6 @@ declare namespace ApplicationInsights {
4083
4371
  traceFlags: number;
4084
4372
  }
4085
4373
 
4086
- interface ITraceState {
4087
- }
4088
-
4089
4374
  interface ITraceTelemetry extends IPartC {
4090
4375
  /**
4091
4376
  * @description A message string
@@ -4152,6 +4437,76 @@ declare namespace ApplicationInsights {
4152
4437
  update(userId?: string): void;
4153
4438
  }
4154
4439
 
4440
+ /**
4441
+ * Represents a mutable [W3C trace state list](https://www.w3.org/TR/trace-context/#tracestate-header), this is a
4442
+ * list of key/value pairs that are used to pass trace state information between different tracing systems. The
4443
+ * list is ordered and the order is important as it determines the processing order.
4444
+ *
4445
+ * Importantly instances of this type are mutable, change made to an instance via {@link IW3cTraceState.set} or
4446
+ * {@link IW3cTraceState.del} will be reflected on the instance and any child instances that use it as a parent.
4447
+ * However, any parent instance associated with an instance will not be modified by operations on that particular
4448
+ * instance.
4449
+ *
4450
+ * @since 3.4.0
4451
+ */
4452
+ interface IW3cTraceState {
4453
+ /**
4454
+ * Returns a readonly array of the current keys associated with the trace state, keys are returned in the
4455
+ * required processing order and if this instance has a parent the keys from the parent will be included
4456
+ * unless they have been removed (deleted) from the child instance.
4457
+ * Once created any modifications to the parent will also be reflected in the child, this is different from
4458
+ * the OpenTelemetry implementation which creates a new instance for each call.
4459
+ * @returns A readonly array of the current keys associated with the trace state
4460
+ */
4461
+ readonly keys: string[];
4462
+ /**
4463
+ * Check if the trace state list is empty, meaning it has no keys or values.
4464
+ * This exists to allow for quick checks without needing to create a new array of keys.
4465
+ * @since 3.4.0
4466
+ * @returns true if the trace state list is empty, false otherwise
4467
+ */
4468
+ readonly isEmpty: boolean;
4469
+ /**
4470
+ * Get the value for the specified key that is associated with this instance, either directly or from the parent.
4471
+ * @param key - The key to lookup
4472
+ * @returns The value for the key, or undefined if not found
4473
+ */
4474
+ get(key: string): string | undefined;
4475
+ /**
4476
+ * Set the value for the specified key for this instance, returning its new location within the list.
4477
+ * - 0 is the front of the list
4478
+ * - -1 not set because the key/value pair is invalid
4479
+ * If the key already exists it will be removed from its current location and added to the front of the list. And
4480
+ * if the key was in the parent this will override the value inherited from the parent, more importantly it will
4481
+ * not modify the parent value.
4482
+ * @param key - The key to set
4483
+ * @param value - The value to set
4484
+ * @returns 0 if successful, -1 if not
4485
+ */
4486
+ set(key: string, value: string): number;
4487
+ /**
4488
+ * Delete the specified key from this instance, if the key was in the parent it will be removed (hidden) from
4489
+ * this instance but will still be available directly from the parent.
4490
+ * @param key - The key to delete
4491
+ */
4492
+ del(key: string): void;
4493
+ /**
4494
+ * Format the trace state list into a strings where each string can be used as a header value.
4495
+ * This will return an empty array if the trace state list is empty.
4496
+ * @param maxHeaders - The maximum number of entries to include in the output, once the limit is reached no more entries will be included
4497
+ * @param maxKeys - The maximum number of keys to include in the output, once the limit is reached no more keys will be included
4498
+ * @param maxLen - The maximum length of each header value, once the limit is reached a new header value will be created
4499
+ * @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
4500
+ */
4501
+ hdrs(maxHeaders?: number, maxKeys?: number, maxLen?: number): string[];
4502
+ /**
4503
+ * Create a new instance of IW3cTraceState which is a child of this instance, meaning it will inherit the keys
4504
+ * and values from this instance but any changes made to the child will not affect this instance.
4505
+ * @returns A new instance of IW3cTraceState which is a child of this instance
4506
+ */
4507
+ child(): IW3cTraceState;
4508
+ }
4509
+
4155
4510
  interface IWatchDetails<T = IConfiguration> {
4156
4511
  /**
4157
4512
  * The current config object