@microsoft/applicationinsights-common 2.8.0-nightly.2204-06 → 2.8.0-nightly.2204-09

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 (114) hide show
  1. package/browser/applicationinsights-common.integrity.json +9 -9
  2. package/browser/applicationinsights-common.js +201 -55
  3. package/browser/applicationinsights-common.js.map +1 -1
  4. package/browser/applicationinsights-common.min.js +2 -2
  5. package/browser/applicationinsights-common.min.js.map +1 -1
  6. package/dist/applicationinsights-common.api.json +1198 -400
  7. package/dist/applicationinsights-common.api.md +101 -25
  8. package/dist/applicationinsights-common.d.ts +165 -28
  9. package/dist/applicationinsights-common.js +201 -55
  10. package/dist/applicationinsights-common.js.map +1 -1
  11. package/dist/applicationinsights-common.min.js +2 -2
  12. package/dist/applicationinsights-common.min.js.map +1 -1
  13. package/dist/applicationinsights-common.rollup.d.ts +165 -28
  14. package/dist-esm/ConnectionStringParser.js +1 -1
  15. package/dist-esm/Constants.js +1 -1
  16. package/dist-esm/DomHelperFuncs.js +1 -1
  17. package/dist-esm/Enums.js +1 -1
  18. package/dist-esm/HelperFuncs.js +1 -1
  19. package/dist-esm/Interfaces/ConnectionString.js +1 -1
  20. package/dist-esm/Interfaces/Context/IApplication.js +1 -1
  21. package/dist-esm/Interfaces/Context/IDevice.js +1 -1
  22. package/dist-esm/Interfaces/Context/IInternal.js +1 -1
  23. package/dist-esm/Interfaces/Context/ILocation.js +1 -1
  24. package/dist-esm/Interfaces/Context/IOperatingSystem.js +1 -1
  25. package/dist-esm/Interfaces/Context/ISample.js +1 -1
  26. package/dist-esm/Interfaces/Context/ISession.js +1 -1
  27. package/dist-esm/Interfaces/Context/ITelemetryTrace.js +1 -1
  28. package/dist-esm/Interfaces/Context/IUser.js +1 -1
  29. package/dist-esm/Interfaces/Context/IWeb.js +1 -1
  30. package/dist-esm/Interfaces/Contracts/AvailabilityData.js +1 -1
  31. package/dist-esm/Interfaces/Contracts/ContextTagKeys.js +1 -1
  32. package/dist-esm/Interfaces/Contracts/DataPointType.js +1 -1
  33. package/dist-esm/Interfaces/Contracts/DependencyKind.js +1 -1
  34. package/dist-esm/Interfaces/Contracts/DependencySourceType.js +1 -1
  35. package/dist-esm/Interfaces/Contracts/IBase.js +1 -1
  36. package/dist-esm/Interfaces/Contracts/IData.js +1 -1
  37. package/dist-esm/Interfaces/Contracts/IDataPoint.js +1 -1
  38. package/dist-esm/Interfaces/Contracts/IDomain.js +1 -1
  39. package/dist-esm/Interfaces/Contracts/IEnvelope.js +1 -1
  40. package/dist-esm/Interfaces/Contracts/IEventData.js +1 -1
  41. package/dist-esm/Interfaces/Contracts/IExceptionData.js +1 -1
  42. package/dist-esm/Interfaces/Contracts/IExceptionDetails.js +1 -1
  43. package/dist-esm/Interfaces/Contracts/IMessageData.js +1 -1
  44. package/dist-esm/Interfaces/Contracts/IMetricData.js +1 -1
  45. package/dist-esm/Interfaces/Contracts/IPageViewData.js +1 -1
  46. package/dist-esm/Interfaces/Contracts/IPageViewPerfData.js +1 -1
  47. package/dist-esm/Interfaces/Contracts/IRemoteDependencyData.js +1 -1
  48. package/dist-esm/Interfaces/Contracts/IStackFrame.js +1 -1
  49. package/dist-esm/Interfaces/Contracts/RequestData.js +1 -1
  50. package/dist-esm/Interfaces/Contracts/SeverityLevel.js +9 -10
  51. package/dist-esm/Interfaces/Contracts/SeverityLevel.js.map +1 -1
  52. package/dist-esm/Interfaces/IAppInsights.js +1 -1
  53. package/dist-esm/Interfaces/IChannelControlsAI.js +1 -1
  54. package/dist-esm/Interfaces/IConfig.js +1 -1
  55. package/dist-esm/Interfaces/ICorrelationConfig.js +1 -1
  56. package/dist-esm/Interfaces/IDependencyTelemetry.js +1 -1
  57. package/dist-esm/Interfaces/IEventTelemetry.js +1 -1
  58. package/dist-esm/Interfaces/IExceptionTelemetry.js +1 -1
  59. package/dist-esm/Interfaces/IMetricTelemetry.js +1 -1
  60. package/dist-esm/Interfaces/IPageViewPerformanceTelemetry.js +1 -1
  61. package/dist-esm/Interfaces/IPageViewTelemetry.js +1 -1
  62. package/dist-esm/Interfaces/IPartC.js +1 -1
  63. package/dist-esm/Interfaces/IPropertiesPlugin.js +1 -1
  64. package/dist-esm/Interfaces/IRequestContext.js +1 -1
  65. package/dist-esm/Interfaces/ITelemetryContext.js +1 -1
  66. package/dist-esm/Interfaces/ITraceParent.js +8 -0
  67. package/dist-esm/Interfaces/ITraceParent.js.map +1 -0
  68. package/dist-esm/Interfaces/ITraceTelemetry.js +1 -1
  69. package/dist-esm/Interfaces/PartAExtensions.js +1 -1
  70. package/dist-esm/Interfaces/Telemetry/IEnvelope.js +1 -1
  71. package/dist-esm/Interfaces/Telemetry/ISerializable.js +1 -1
  72. package/dist-esm/RequestResponseHeaders.js +13 -12
  73. package/dist-esm/RequestResponseHeaders.js.map +1 -1
  74. package/dist-esm/StorageHelperFuncs.js +5 -5
  75. package/dist-esm/StorageHelperFuncs.js.map +1 -1
  76. package/dist-esm/Telemetry/Common/Data.js +1 -1
  77. package/dist-esm/Telemetry/Common/DataPoint.js +1 -1
  78. package/dist-esm/Telemetry/Common/DataSanitizer.js +1 -1
  79. package/dist-esm/Telemetry/Common/Envelope.js +1 -1
  80. package/dist-esm/Telemetry/Event.js +1 -1
  81. package/dist-esm/Telemetry/Exception.js +1 -1
  82. package/dist-esm/Telemetry/Metric.js +1 -1
  83. package/dist-esm/Telemetry/PageView.js +1 -1
  84. package/dist-esm/Telemetry/PageViewPerformance.js +1 -1
  85. package/dist-esm/Telemetry/RemoteDependencyData.js +1 -1
  86. package/dist-esm/Telemetry/Trace.js +1 -1
  87. package/dist-esm/TelemetryItemCreator.js +42 -32
  88. package/dist-esm/TelemetryItemCreator.js.map +1 -1
  89. package/dist-esm/UrlHelperFuncs.js +1 -1
  90. package/dist-esm/Util.js +2 -2
  91. package/dist-esm/Util.js.map +1 -1
  92. package/dist-esm/W3cTraceParent.js +192 -0
  93. package/dist-esm/W3cTraceParent.js.map +1 -0
  94. package/dist-esm/applicationinsights-common.js +3 -2
  95. package/dist-esm/applicationinsights-common.js.map +1 -1
  96. package/package.json +2 -2
  97. package/src/Enums.ts +2 -3
  98. package/src/Interfaces/Contracts/SeverityLevel.ts +15 -2
  99. package/src/Interfaces/IConfig.ts +2 -9
  100. package/src/Interfaces/ITraceParent.ts +38 -0
  101. package/src/RequestResponseHeaders.ts +38 -2
  102. package/src/StorageHelperFuncs.ts +4 -4
  103. package/src/TelemetryItemCreator.ts +56 -44
  104. package/src/Util.ts +3 -3
  105. package/src/W3cTraceParent.ts +219 -0
  106. package/src/applicationinsights-common.ts +8 -3
  107. package/types/Enums.d.ts +2 -9
  108. package/types/Interfaces/Contracts/SeverityLevel.d.ts +6 -1
  109. package/types/Interfaces/IConfig.d.ts +3 -9
  110. package/types/Interfaces/ITraceParent.d.ts +32 -0
  111. package/types/RequestResponseHeaders.d.ts +31 -1
  112. package/types/TelemetryItemCreator.d.ts +15 -5
  113. package/types/W3cTraceParent.d.ts +59 -0
  114. package/types/applicationinsights-common.d.ts +5 -3
@@ -9,7 +9,6 @@ import { EnumValue } from '@microsoft/applicationinsights-core-js';
9
9
  import { IChannelControls } from '@microsoft/applicationinsights-core-js';
10
10
  import { IConfiguration } from '@microsoft/applicationinsights-core-js';
11
11
  import { ICookieMgr } from '@microsoft/applicationinsights-core-js';
12
- import { ICookieMgrConfig } from '@microsoft/applicationinsights-core-js';
13
12
  import { ICustomProperties } from '@microsoft/applicationinsights-core-js';
14
13
  import { IDiagnosticLogger } from '@microsoft/applicationinsights-core-js';
15
14
  import { IPlugin } from '@microsoft/applicationinsights-core-js';
@@ -57,6 +56,16 @@ export const CorrelationIdHelper: ICorrelationIdHelper;
57
56
  // @public (undocumented)
58
57
  export function createDomEvent(eventName: string): Event;
59
58
 
59
+ // @public
60
+ export function createTelemetryItem<T>(item: T, baseType: string, envelopeName: string, logger: IDiagnosticLogger, customProperties?: {
61
+ [key: string]: any;
62
+ }, systemProperties?: {
63
+ [key: string]: any;
64
+ }): ITelemetryItem;
65
+
66
+ // @public
67
+ export function createTraceParent(traceId?: string, spanId?: string, flags?: number, version?: string): ITraceParent;
68
+
60
69
  // @public (undocumented)
61
70
  export let CtxTagKeys: ContextTagKeys;
62
71
 
@@ -131,11 +140,7 @@ export const DEFAULT_BREEZE_ENDPOINT = "https://dc.services.visualstudio.com";
131
140
  export const DisabledPropertyName: string;
132
141
 
133
142
  // @public (undocumented)
134
- export const DistributedTracingModes: EnumValue< {
135
- AI: number;
136
- AI_AND_W3C: number;
137
- W3C: number;
138
- }>;
143
+ export const DistributedTracingModes: EnumValue<typeof eDistributedTracingModes>;
139
144
 
140
145
  // @public (undocumented)
141
146
  export type DistributedTracingModes = number | eDistributedTracingModes;
@@ -164,6 +169,42 @@ export class Envelope implements IEnvelope {
164
169
  ver: number;
165
170
  }
166
171
 
172
+ // @public (undocumented)
173
+ export const enum eRequestHeaders {
174
+ // (undocumented)
175
+ requestContextAppIdFormat = 2,
176
+ // (undocumented)
177
+ requestContextHeader = 0,
178
+ // (undocumented)
179
+ requestContextHeaderLowerCase = 8,
180
+ // (undocumented)
181
+ requestContextTargetKey = 1,
182
+ // (undocumented)
183
+ requestIdHeader = 3,
184
+ // (undocumented)
185
+ sdkContextHeader = 6,
186
+ // (undocumented)
187
+ sdkContextHeaderAppIdRequest = 7,
188
+ // (undocumented)
189
+ traceParentHeader = 4,
190
+ // (undocumented)
191
+ traceStateHeader = 5
192
+ }
193
+
194
+ // @public
195
+ export const enum eSeverityLevel {
196
+ // (undocumented)
197
+ Critical = 4,
198
+ // (undocumented)
199
+ Error = 3,
200
+ // (undocumented)
201
+ Information = 1,
202
+ // (undocumented)
203
+ Verbose = 0,
204
+ // (undocumented)
205
+ Warning = 2
206
+ }
207
+
167
208
  // Warning: (ae-forgotten-export) The symbol "IEventData" needs to be exported by the entry point applicationinsights-common.d.ts
168
209
  //
169
210
  // @public (undocumented)
@@ -259,6 +300,12 @@ export const enum FieldType {
259
300
  Required = 1
260
301
  }
261
302
 
303
+ // @public
304
+ export function findW3cTraceParent(): ITraceParent;
305
+
306
+ // @public
307
+ export function formatTraceParent(value: ITraceParent): string;
308
+
262
309
  // @public (undocumented)
263
310
  export function getExtensionByName(extensions: IPlugin[], identifier: string): IPlugin | null;
264
311
 
@@ -341,7 +388,6 @@ export interface IConfig {
341
388
  autoUnhandledPromiseInstrumented?: boolean;
342
389
  convertUndefined?: any;
343
390
  cookieDomain?: string;
344
- cookieMgrCfg?: ICookieMgrConfig;
345
391
  cookiePath?: string;
346
392
  // (undocumented)
347
393
  correlationHeaderDomains?: string[];
@@ -786,6 +832,18 @@ export interface ISession {
786
832
  // @public (undocumented)
787
833
  export function isInternalApplicationInsightsEndpoint(endpointUrl: string): boolean;
788
834
 
835
+ // @public
836
+ export function isSampledFlag(value: ITraceParent): boolean;
837
+
838
+ // @public
839
+ export function isValidSpanId(value: string): boolean;
840
+
841
+ // @public
842
+ export function isValidTraceId(value: string): boolean;
843
+
844
+ // @public
845
+ export function isValidTraceParent(value: ITraceParent): boolean;
846
+
789
847
  // @public (undocumented)
790
848
  export interface ITelemetryContext {
791
849
  appId: () => string;
@@ -809,6 +867,14 @@ export interface ITelemetryTrace {
809
867
  traceState?: ITraceState;
810
868
  }
811
869
 
870
+ // @public
871
+ export interface ITraceParent {
872
+ spanId: string;
873
+ traceFlags: number;
874
+ traceId: string;
875
+ version: string;
876
+ }
877
+
812
878
  // @public (undocumented)
813
879
  export interface ITraceState {
814
880
  }
@@ -1023,6 +1089,9 @@ export class PageViewPerformance implements IPageViewPerfData, ISerializable {
1023
1089
  // @public (undocumented)
1024
1090
  export function parseConnectionString(connectionString?: string): ConnectionString;
1025
1091
 
1092
+ // @public
1093
+ export function parseTraceParent(value: string): ITraceParent;
1094
+
1026
1095
  // @public (undocumented)
1027
1096
  export const ProcessLegacy = "ProcessLegacy";
1028
1097
 
@@ -1076,24 +1145,35 @@ export class RemoteDependencyData implements IRemoteDependencyData, ISerializabl
1076
1145
  }
1077
1146
 
1078
1147
  // @public (undocumented)
1079
- export const RequestHeaders: IRequestHeaders;
1148
+ export const RequestHeaders: IRequestHeaders & {
1149
+ requestContextHeader: "Request-Context";
1150
+ requestContextTargetKey: "appId";
1151
+ requestContextAppIdFormat: "appId=cid-v1:";
1152
+ requestIdHeader: "Request-Id";
1153
+ traceParentHeader: "traceparent";
1154
+ traceStateHeader: "tracestate";
1155
+ sdkContextHeader: "Sdk-Context";
1156
+ sdkContextHeaderAppIdRequest: "appId";
1157
+ requestContextHeaderLowerCase: "request-context";
1158
+ 0: "Request-Context";
1159
+ 1: "appId";
1160
+ 2: "appId=cid-v1:";
1161
+ 3: "Request-Id";
1162
+ 4: "traceparent";
1163
+ 5: "tracestate";
1164
+ 6: "Sdk-Context";
1165
+ 7: "appId";
1166
+ 8: "request-context";
1167
+ };
1080
1168
 
1081
1169
  // @public (undocumented)
1082
1170
  export const SampleRate = "sampleRate";
1083
1171
 
1084
1172
  // @public
1085
- export enum SeverityLevel {
1086
- // (undocumented)
1087
- Critical = 4,
1088
- // (undocumented)
1089
- Error = 3,
1090
- // (undocumented)
1091
- Information = 1,
1092
- // (undocumented)
1093
- Verbose = 0,
1094
- // (undocumented)
1095
- Warning = 2
1096
- }
1173
+ export const SeverityLevel: EnumValue<typeof eSeverityLevel>;
1174
+
1175
+ // @public (undocumented)
1176
+ export type SeverityLevel = number | eSeverityLevel;
1097
1177
 
1098
1178
  // @public (undocumented)
1099
1179
  export function stringToBoolOrDefault(str: any, defaultValue?: boolean): boolean;
@@ -1103,11 +1183,7 @@ export const strNotSpecified = "not_specified";
1103
1183
 
1104
1184
  // @public (undocumented)
1105
1185
  export class TelemetryItemCreator {
1106
- static create<T>(item: T, baseType: string, envelopeName: string, logger: IDiagnosticLogger, customProperties?: {
1107
- [key: string]: any;
1108
- }, systemProperties?: {
1109
- [key: string]: any;
1110
- }): ITelemetryItem;
1186
+ static create: typeof createTelemetryItem;
1111
1187
  }
1112
1188
 
1113
1189
  // Warning: (ae-forgotten-export) The symbol "IMessageData" needs to be exported by the entry point applicationinsights-common.d.ts
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Microsoft Application Insights Common JavaScript Library, 2.8.0-nightly.2204-06
2
+ * Microsoft Application Insights Common JavaScript Library, 2.8.0-nightly.2204-09
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  *
5
5
  * Microsoft Application Insights Team
@@ -12,7 +12,6 @@ declare namespace ApplicationInsights {
12
12
  import { IChannelControls } from '@microsoft/applicationinsights-core-js';
13
13
  import { IConfiguration } from '@microsoft/applicationinsights-core-js';
14
14
  import { ICookieMgr } from '@microsoft/applicationinsights-core-js';
15
- import { ICookieMgrConfig } from '@microsoft/applicationinsights-core-js';
16
15
  import { ICustomProperties } from '@microsoft/applicationinsights-core-js';
17
16
  import { IDiagnosticLogger } from '@microsoft/applicationinsights-core-js';
18
17
  import { IPlugin } from '@microsoft/applicationinsights-core-js';
@@ -71,6 +70,31 @@ declare namespace ApplicationInsights {
71
70
 
72
71
  function createDomEvent(eventName: string): Event;
73
72
 
73
+ /**
74
+ * Create a telemetry item that the 1DS channel understands
75
+ * @param item domain specific properties; part B
76
+ * @param baseType telemetry item type. ie PageViewData
77
+ * @param envelopeName name of the envelope. ie Microsoft.ApplicationInsights.<instrumentation key>.PageView
78
+ * @param customProperties user defined custom properties; part C
79
+ * @param systemProperties system properties that are added to the context; part A
80
+ * @returns ITelemetryItem that is sent to channel
81
+ */
82
+ function createTelemetryItem<T>(item: T, baseType: string, envelopeName: string, logger: IDiagnosticLogger, customProperties?: {
83
+ [key: string]: any;
84
+ }, systemProperties?: {
85
+ [key: string]: any;
86
+ }): ITelemetryItem;
87
+
88
+ /**
89
+ * Create a new ITraceParent instance using the provided values.
90
+ * @param traceId - The traceId to use, when invalid a new random W3C id will be generated.
91
+ * @param spanId - The parent/span id to use, a new random value will be generated if it is invalid.
92
+ * @param flags - The traceFlags to use, defaults to zero (0) if not supplied or invalid
93
+ * @param version - The version to used, defaults to version "01" if not supplied or invalid.
94
+ * @returns
95
+ */
96
+ function createTraceParent(traceId?: string, spanId?: string, flags?: number, version?: string): ITraceParent;
97
+
74
98
  let CtxTagKeys: ContextTagKeys;
75
99
 
76
100
  class Data<TDomain> implements AIData<TDomain>, ISerializable {
@@ -222,11 +246,7 @@ declare namespace ApplicationInsights {
222
246
  */
223
247
  const DisabledPropertyName: string;
224
248
 
225
- const DistributedTracingModes: EnumValue< {
226
- AI: number;
227
- AI_AND_W3C: number;
228
- W3C: number;
229
- }>;
249
+ const DistributedTracingModes: EnumValue<typeof eDistributedTracingModes>;
230
250
 
231
251
  type DistributedTracingModes = number | eDistributedTracingModes;
232
252
 
@@ -290,6 +310,29 @@ declare namespace ApplicationInsights {
290
310
  constructor(logger: IDiagnosticLogger, data: AIBase, name: string);
291
311
  }
292
312
 
313
+ const enum eRequestHeaders {
314
+ requestContextHeader = 0,
315
+ requestContextTargetKey = 1,
316
+ requestContextAppIdFormat = 2,
317
+ requestIdHeader = 3,
318
+ traceParentHeader = 4,
319
+ traceStateHeader = 5,
320
+ sdkContextHeader = 6,
321
+ sdkContextHeaderAppIdRequest = 7,
322
+ requestContextHeaderLowerCase = 8
323
+ }
324
+
325
+ /**
326
+ * Defines the level of severity for the event.
327
+ */
328
+ const enum eSeverityLevel {
329
+ Verbose = 0,
330
+ Information = 1,
331
+ Warning = 2,
332
+ Error = 3,
333
+ Critical = 4
334
+ }
335
+
293
336
  class Event_2 implements IEventData, ISerializable {
294
337
  static envelopeType: string;
295
338
  static dataType: string;
@@ -397,12 +440,28 @@ declare namespace ApplicationInsights {
397
440
  Hidden = 4
398
441
  }
399
442
 
443
+ /**
444
+ * Helper function to fetch the passed traceparent from the page, looking for it as a meta-tag or a Server-Timing header.
445
+ * @returns
446
+ */
447
+ function findW3cTraceParent(): ITraceParent;
448
+
400
449
  /**
401
450
  * Formats the provided errorObj for display and reporting, it may be a String, Object, integer or undefined depending on the browser.
402
451
  * @param errorObj The supplied errorObj
403
452
  */
404
453
  function _formatErrorCode(errorObj: any): any;
405
454
 
455
+ /**
456
+ * Format the ITraceParent value as a string using the supported and know version formats.
457
+ * So even if the passed traceParent is a later version the string value returned from this
458
+ * function will convert it to only the known version formats.
459
+ * This currently only supports version "00" and invalid "ff"
460
+ * @param value - The parsed traceParent value
461
+ * @returns
462
+ */
463
+ function formatTraceParent(value: ITraceParent): string;
464
+
406
465
  function getExtensionByName(extensions: IPlugin[], identifier: string): IPlugin | null;
407
466
 
408
467
  const HttpMethod = "http.method";
@@ -653,7 +712,7 @@ declare namespace ApplicationInsights {
653
712
  */
654
713
  enableSessionStorageBuffer?: boolean;
655
714
  /**
656
- * @deprecated Use either disableCookiesUsage or specify a cookieMgrCfg with the enabled value set.
715
+ * @deprecated Use either disableCookiesUsage or specify a cookieCfg with the enabled value set.
657
716
  * If true, the SDK will not store or read any data from cookies. Default is false. As this field is being deprecated, when both
658
717
  * isCookieUseDisabled and disableCookiesUsage are used disableCookiesUsage will take precedent.
659
718
  * @defaultValue false
@@ -661,7 +720,7 @@ declare namespace ApplicationInsights {
661
720
  isCookieUseDisabled?: boolean;
662
721
  /**
663
722
  * If true, the SDK will not store or read any data from cookies. Default is false.
664
- * If you have also specified a cookieMgrCfg then enabled property (if specified) will take precedent over this value.
723
+ * If you have also specified a cookieCfg then enabled property (if specified) will take precedent over this value.
665
724
  * @defaultValue false
666
725
  */
667
726
  disableCookiesUsage?: boolean;
@@ -675,12 +734,6 @@ declare namespace ApplicationInsights {
675
734
  * @defaultValue ""
676
735
  */
677
736
  cookiePath?: string;
678
- /**
679
- * [Optional] A Cookie Manager configuration which includes hooks to allow interception of the get, set and delete cookie
680
- * operations. If this configuration is specified any specified enabled and domain properties will take precedence over the
681
- * cookieDomain and disableCookiesUsage values.
682
- */
683
- cookieMgrCfg?: ICookieMgrConfig;
684
737
  /**
685
738
  * Default false. If false, retry on 206 (partial success), 408 (timeout), 429 (too many requests), 500 (internal server error), 503 (service unavailable), and 0 (offline, only if detected)
686
739
  * @description
@@ -1839,6 +1892,13 @@ declare namespace ApplicationInsights {
1839
1892
 
1840
1893
  function isInternalApplicationInsightsEndpoint(endpointUrl: string): boolean;
1841
1894
 
1895
+ /**
1896
+ * Is the parsed traceParent indicating that the trace is currently sampled.
1897
+ * @param value - The parsed traceParent value
1898
+ * @returns
1899
+ */
1900
+ function isSampledFlag(value: ITraceParent): boolean;
1901
+
1842
1902
  interface IStackDetails {
1843
1903
  src: string;
1844
1904
  obj: string[];
@@ -1870,6 +1930,31 @@ declare namespace ApplicationInsights {
1870
1930
  line: number;
1871
1931
  }
1872
1932
 
1933
+ /**
1934
+ * Is the provided W3c span id (aka. parent id) a valid string representation, it must be a 16-character
1935
+ * string of lowercase hexadecimal characters, for example, 00f067aa0ba902b7.
1936
+ * If all characters are zero (0000000000000000) this is considered an invalid value.
1937
+ * @param value - The W3c span id to be validated
1938
+ * @returns true if valid otherwise false
1939
+ */
1940
+ function isValidSpanId(value: string): boolean;
1941
+
1942
+ /**
1943
+ * Is the provided W3c Trace Id a valid string representation, it must be a 32-character string
1944
+ * of lowercase hexadecimal characters for example, 4bf92f3577b34da6a3ce929d0e0e4736.
1945
+ * If all characters as zero (00000000000000000000000000000000) it will be considered an invalid value.
1946
+ * @param value - The W3c trace Id to be validated
1947
+ * @returns true if valid otherwise false
1948
+ */
1949
+ function isValidTraceId(value: string): boolean;
1950
+
1951
+ /**
1952
+ * Validates that the provided ITraceParent instance conforms to the currently supported specifications
1953
+ * @param value
1954
+ * @returns
1955
+ */
1956
+ function isValidTraceParent(value: ITraceParent): boolean;
1957
+
1873
1958
  interface ITelemetryContext {
1874
1959
  /**
1875
1960
  * The object describing a component tracked by this object.
@@ -1936,6 +2021,39 @@ declare namespace ApplicationInsights {
1936
2021
  name?: string;
1937
2022
  }
1938
2023
 
2024
+ /**
2025
+ * This interface represents the components of a W3C traceparent header
2026
+ */
2027
+ interface ITraceParent {
2028
+ /**
2029
+ * The version of the definition, this MUST be a string with a length of 2 and only contain lowercase
2030
+ * hexadecimal characters. A value of 'ff' is considered to be an invalid version.
2031
+ */
2032
+ version: string;
2033
+ /**
2034
+ * This is the ID of the whole trace forest and is used to uniquely identify a distributed trace
2035
+ * through a system. It is represented as a 32-character string of lowercase hexadecimal characters,
2036
+ * for example, 4bf92f3577b34da6a3ce929d0e0e4736.
2037
+ * All characters as zero (00000000000000000000000000000000) is considered an invalid value.
2038
+ */
2039
+ traceId: string;
2040
+ /**
2041
+ * This is the ID of the current request as known by the caller (in some tracing systems, this is also
2042
+ * known as the parent-id, where a span is the execution of a client request). It is represented as an
2043
+ * 16-character string of lowercase hexadecimal characters, for example, 00f067aa0ba902b7.
2044
+ * All bytes as zero (0000000000000000) is considered an invalid value.
2045
+ */
2046
+ spanId: string;
2047
+ /**
2048
+ * An 8-bit value of flags that controls tracing such as sampling, trace level, etc. These flags are
2049
+ * recommendations given by the caller rather than strict rules to follow.
2050
+ * As this is a bit field, you cannot interpret flags by decoding the hex value and looking at the resulting
2051
+ * number. For example, a flag 00000001 could be encoded as 01 in hex, or 09 in hex if present with the flag
2052
+ * 00001000. A common mistake in bit fields is forgetting to mask when interpreting flags.
2053
+ */
2054
+ traceFlags: number;
2055
+ }
2056
+
1939
2057
  interface ITraceState {
1940
2058
  }
1941
2059
 
@@ -2372,6 +2490,14 @@ declare namespace ApplicationInsights {
2372
2490
 
2373
2491
  function parseConnectionString(connectionString?: string): ConnectionString;
2374
2492
 
2493
+ /**
2494
+ * Attempt to parse the provided string as a W3C TraceParent header value (https://www.w3.org/TR/trace-context/#traceparent-header)
2495
+ *
2496
+ * @param value
2497
+ * @returns
2498
+ */
2499
+ function parseTraceParent(value: string): ITraceParent;
2500
+
2375
2501
  const ProcessLegacy = "ProcessLegacy";
2376
2502
 
2377
2503
  const PropertiesPluginIdentifier = "AppInsightsPropertiesPlugin";
@@ -2452,20 +2578,35 @@ declare namespace ApplicationInsights {
2452
2578
  constructor(logger: IDiagnosticLogger, id: string, absoluteUrl: string, commandName: string, value: number, success: boolean, resultCode: number, method?: string, requestAPI?: string, correlationContext?: string, properties?: Object, measurements?: Object);
2453
2579
  }
2454
2580
 
2455
- const RequestHeaders: IRequestHeaders;
2581
+ const RequestHeaders: IRequestHeaders & {
2582
+ requestContextHeader: "Request-Context";
2583
+ requestContextTargetKey: "appId";
2584
+ requestContextAppIdFormat: "appId=cid-v1:";
2585
+ requestIdHeader: "Request-Id";
2586
+ traceParentHeader: "traceparent";
2587
+ traceStateHeader: "tracestate";
2588
+ sdkContextHeader: "Sdk-Context";
2589
+ sdkContextHeaderAppIdRequest: "appId";
2590
+ requestContextHeaderLowerCase: "request-context";
2591
+ 0: "Request-Context";
2592
+ 1: "appId";
2593
+ 2: "appId=cid-v1:";
2594
+ 3: "Request-Id";
2595
+ 4: "traceparent";
2596
+ 5: "tracestate";
2597
+ 6: "Sdk-Context";
2598
+ 7: "appId";
2599
+ 8: "request-context";
2600
+ };
2456
2601
 
2457
2602
  const SampleRate = "sampleRate";
2458
2603
 
2459
2604
  /**
2460
2605
  * Defines the level of severity for the event.
2461
2606
  */
2462
- enum SeverityLevel {
2463
- Verbose = 0,
2464
- Information = 1,
2465
- Warning = 2,
2466
- Error = 3,
2467
- Critical = 4
2468
- }
2607
+ const SeverityLevel: EnumValue<typeof eSeverityLevel>;
2608
+
2609
+ type SeverityLevel = number | eSeverityLevel;
2469
2610
 
2470
2611
  function stringToBoolOrDefault(str: any, defaultValue?: boolean): boolean;
2471
2612
 
@@ -2481,11 +2622,7 @@ declare namespace ApplicationInsights {
2481
2622
  * @param systemProperties system properties that are added to the context; part A
2482
2623
  * @returns ITelemetryItem that is sent to channel
2483
2624
  */
2484
- static create<T>(item: T, baseType: string, envelopeName: string, logger: IDiagnosticLogger, customProperties?: {
2485
- [key: string]: any;
2486
- }, systemProperties?: {
2487
- [key: string]: any;
2488
- }): ITelemetryItem;
2625
+ static create: typeof createTelemetryItem;
2489
2626
  }
2490
2627
 
2491
2628
  class Trace implements IMessageData, ISerializable {