@microsoft/applicationinsights-common 2.8.4-nightly.2205-09 → 2.8.4-nightly.2205-10

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/applicationinsights-common.integrity.json +9 -9
  2. package/browser/applicationinsights-common.js +174 -127
  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 +81 -501
  7. package/dist/applicationinsights-common.api.md +24 -23
  8. package/dist/applicationinsights-common.d.ts +33 -91
  9. package/dist/applicationinsights-common.js +174 -127
  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 +33 -91
  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 +1 -1
  51. package/dist-esm/Interfaces/IAppInsights.js +1 -1
  52. package/dist-esm/Interfaces/IChannelControlsAI.js +1 -1
  53. package/dist-esm/Interfaces/IConfig.js +1 -1
  54. package/dist-esm/Interfaces/ICorrelationConfig.js +1 -1
  55. package/dist-esm/Interfaces/IDependencyTelemetry.js +1 -1
  56. package/dist-esm/Interfaces/IEventTelemetry.js +1 -1
  57. package/dist-esm/Interfaces/IExceptionTelemetry.js +1 -1
  58. package/dist-esm/Interfaces/IMetricTelemetry.js +1 -1
  59. package/dist-esm/Interfaces/IPageViewPerformanceTelemetry.js +1 -1
  60. package/dist-esm/Interfaces/IPageViewTelemetry.js +1 -1
  61. package/dist-esm/Interfaces/IPartC.js +1 -1
  62. package/dist-esm/Interfaces/IPropertiesPlugin.js +1 -1
  63. package/dist-esm/Interfaces/IRequestContext.js +1 -1
  64. package/dist-esm/Interfaces/ITelemetryContext.js +1 -1
  65. package/dist-esm/Interfaces/ITraceTelemetry.js +1 -1
  66. package/dist-esm/Interfaces/PartAExtensions.js +1 -1
  67. package/dist-esm/Interfaces/Telemetry/IEnvelope.js +1 -1
  68. package/dist-esm/Interfaces/Telemetry/ISerializable.js +1 -1
  69. package/dist-esm/RequestResponseHeaders.js +1 -1
  70. package/dist-esm/StorageHelperFuncs.js +1 -1
  71. package/dist-esm/Telemetry/Common/Data.js +1 -1
  72. package/dist-esm/Telemetry/Common/DataPoint.js +1 -1
  73. package/dist-esm/Telemetry/Common/DataSanitizer.js +1 -1
  74. package/dist-esm/Telemetry/Common/Envelope.js +1 -1
  75. package/dist-esm/Telemetry/Event.js +1 -1
  76. package/dist-esm/Telemetry/Exception.js +1 -1
  77. package/dist-esm/Telemetry/Metric.js +1 -1
  78. package/dist-esm/Telemetry/PageView.js +1 -1
  79. package/dist-esm/Telemetry/PageViewPerformance.js +1 -1
  80. package/dist-esm/Telemetry/RemoteDependencyData.js +1 -1
  81. package/dist-esm/Telemetry/Trace.js +1 -1
  82. package/dist-esm/TelemetryItemCreator.js +1 -1
  83. package/dist-esm/UrlHelperFuncs.js +1 -1
  84. package/dist-esm/Util.js +45 -2
  85. package/dist-esm/Util.js.map +1 -1
  86. package/dist-esm/applicationinsights-common.js +3 -4
  87. package/dist-esm/applicationinsights-common.js.map +1 -1
  88. package/package.json +2 -2
  89. package/src/Interfaces/Context/ITelemetryTrace.ts +6 -0
  90. package/src/Util.ts +49 -2
  91. package/src/applicationinsights-common.ts +6 -6
  92. package/types/Interfaces/Context/ITelemetryTrace.d.ts +5 -0
  93. package/types/Util.d.ts +9 -1
  94. package/types/applicationinsights-common.d.ts +2 -4
  95. package/types/tsdoc-metadata.json +1 -1
  96. package/dist-esm/Interfaces/ITraceParent.js +0 -8
  97. package/dist-esm/Interfaces/ITraceParent.js.map +0 -1
  98. package/dist-esm/W3cTraceParent.js +0 -192
  99. package/dist-esm/W3cTraceParent.js.map +0 -1
  100. package/src/Interfaces/ITraceParent.ts +0 -38
  101. package/src/W3cTraceParent.ts +0 -219
  102. package/types/Interfaces/ITraceParent.d.ts +0 -32
  103. package/types/W3cTraceParent.d.ts +0 -59
@@ -4,16 +4,26 @@
4
4
 
5
5
  ```ts
6
6
 
7
+ import { createTraceParent } from '@microsoft/applicationinsights-core-js';
7
8
  import { _eInternalMessageId } from '@microsoft/applicationinsights-core-js';
8
9
  import { EnumValue } from '@microsoft/applicationinsights-core-js';
10
+ import { findW3cTraceParent } from '@microsoft/applicationinsights-core-js';
11
+ import { formatTraceParent } from '@microsoft/applicationinsights-core-js';
9
12
  import { IChannelControls } from '@microsoft/applicationinsights-core-js';
10
13
  import { IConfiguration } from '@microsoft/applicationinsights-core-js';
11
14
  import { ICookieMgr } from '@microsoft/applicationinsights-core-js';
12
15
  import { ICustomProperties } from '@microsoft/applicationinsights-core-js';
13
16
  import { IDiagnosticLogger } from '@microsoft/applicationinsights-core-js';
17
+ import { IDistributedTraceContext } from '@microsoft/applicationinsights-core-js';
14
18
  import { IPlugin } from '@microsoft/applicationinsights-core-js';
15
19
  import { isBeaconsSupported as isBeaconApiSupported } from '@microsoft/applicationinsights-core-js';
20
+ import { isSampledFlag } from '@microsoft/applicationinsights-core-js';
21
+ import { isValidSpanId } from '@microsoft/applicationinsights-core-js';
22
+ import { isValidTraceId } from '@microsoft/applicationinsights-core-js';
23
+ import { isValidTraceParent } from '@microsoft/applicationinsights-core-js';
16
24
  import { ITelemetryItem } from '@microsoft/applicationinsights-core-js';
25
+ import { ITraceParent } from '@microsoft/applicationinsights-core-js';
26
+ import { parseTraceParent } from '@microsoft/applicationinsights-core-js';
17
27
 
18
28
  // @public
19
29
  export interface AIBase {
@@ -53,6 +63,9 @@ export class ContextTagKeys extends ContextTagKeys_base {
53
63
  // @public (undocumented)
54
64
  export const CorrelationIdHelper: ICorrelationIdHelper;
55
65
 
66
+ // @public
67
+ export function createDistributedTraceContextFromTrace(telemetryTrace?: ITelemetryTrace, parentCtx?: IDistributedTraceContext): IDistributedTraceContext;
68
+
56
69
  // @public (undocumented)
57
70
  export function createDomEvent(eventName: string): Event;
58
71
 
@@ -63,8 +76,7 @@ export function createTelemetryItem<T>(item: T, baseType: string, envelopeName:
63
76
  [key: string]: any;
64
77
  }): ITelemetryItem;
65
78
 
66
- // @public
67
- export function createTraceParent(traceId?: string, spanId?: string, flags?: number, version?: string): ITraceParent;
79
+ export { createTraceParent }
68
80
 
69
81
  // @public (undocumented)
70
82
  export let CtxTagKeys: ContextTagKeys;
@@ -300,11 +312,9 @@ export const enum FieldType {
300
312
  Required = 1
301
313
  }
302
314
 
303
- // @public
304
- export function findW3cTraceParent(): ITraceParent;
315
+ export { findW3cTraceParent }
305
316
 
306
- // @public
307
- export function formatTraceParent(value: ITraceParent): string;
317
+ export { formatTraceParent }
308
318
 
309
319
  // @public (undocumented)
310
320
  export function getExtensionByName(extensions: IPlugin[], identifier: string): IPlugin | null;
@@ -833,17 +843,13 @@ export interface ISession {
833
843
  // @public (undocumented)
834
844
  export function isInternalApplicationInsightsEndpoint(endpointUrl: string): boolean;
835
845
 
836
- // @public
837
- export function isSampledFlag(value: ITraceParent): boolean;
846
+ export { isSampledFlag }
838
847
 
839
- // @public
840
- export function isValidSpanId(value: string): boolean;
848
+ export { isValidSpanId }
841
849
 
842
- // @public
843
- export function isValidTraceId(value: string): boolean;
850
+ export { isValidTraceId }
844
851
 
845
- // @public
846
- export function isValidTraceParent(value: ITraceParent): boolean;
852
+ export { isValidTraceParent }
847
853
 
848
854
  // @public (undocumented)
849
855
  export interface ITelemetryContext {
@@ -864,17 +870,13 @@ export interface ITelemetryContext {
864
870
  export interface ITelemetryTrace {
865
871
  name?: string;
866
872
  parentID?: string;
873
+ traceFlags?: number;
867
874
  traceID?: string;
875
+ // @deprecated (undocumented)
868
876
  traceState?: ITraceState;
869
877
  }
870
878
 
871
- // @public
872
- export interface ITraceParent {
873
- spanId: string;
874
- traceFlags: number;
875
- traceId: string;
876
- version: string;
877
- }
879
+ export { ITraceParent }
878
880
 
879
881
  // @public (undocumented)
880
882
  export interface ITraceState {
@@ -1090,8 +1092,7 @@ export class PageViewPerformance implements IPageViewPerfData, ISerializable {
1090
1092
  // @public (undocumented)
1091
1093
  export function parseConnectionString(connectionString?: string): ConnectionString;
1092
1094
 
1093
- // @public
1094
- export function parseTraceParent(value: string): ITraceParent;
1095
+ export { parseTraceParent }
1095
1096
 
1096
1097
  // @public (undocumented)
1097
1098
  export const ProcessLegacy = "ProcessLegacy";
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Microsoft Application Insights Common JavaScript Library, 2.8.4-nightly.2205-09
2
+ * Microsoft Application Insights Common JavaScript Library, 2.8.4-nightly.2205-10
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  *
5
5
  * Microsoft Application Insights Team
@@ -7,16 +7,26 @@
7
7
  */
8
8
 
9
9
  declare namespace ApplicationInsights {
10
+ import { createTraceParent } from '@microsoft/applicationinsights-core-js';
10
11
  import { _eInternalMessageId } from '@microsoft/applicationinsights-core-js';
11
12
  import { EnumValue } from '@microsoft/applicationinsights-core-js';
13
+ import { findW3cTraceParent } from '@microsoft/applicationinsights-core-js';
14
+ import { formatTraceParent } from '@microsoft/applicationinsights-core-js';
12
15
  import { IChannelControls } from '@microsoft/applicationinsights-core-js';
13
16
  import { IConfiguration } from '@microsoft/applicationinsights-core-js';
14
17
  import { ICookieMgr } from '@microsoft/applicationinsights-core-js';
15
18
  import { ICustomProperties } from '@microsoft/applicationinsights-core-js';
16
19
  import { IDiagnosticLogger } from '@microsoft/applicationinsights-core-js';
20
+ import { IDistributedTraceContext } from '@microsoft/applicationinsights-core-js';
17
21
  import { IPlugin } from '@microsoft/applicationinsights-core-js';
18
22
  import { isBeaconsSupported as isBeaconApiSupported } from '@microsoft/applicationinsights-core-js';
23
+ import { isSampledFlag } from '@microsoft/applicationinsights-core-js';
24
+ import { isValidSpanId } from '@microsoft/applicationinsights-core-js';
25
+ import { isValidTraceId } from '@microsoft/applicationinsights-core-js';
26
+ import { isValidTraceParent } from '@microsoft/applicationinsights-core-js';
19
27
  import { ITelemetryItem } from '@microsoft/applicationinsights-core-js';
28
+ import { ITraceParent } from '@microsoft/applicationinsights-core-js';
29
+ import { parseTraceParent } from '@microsoft/applicationinsights-core-js';
20
30
 
21
31
  /**
22
32
  * Data struct to contain only C section with custom fields.
@@ -68,6 +78,14 @@ declare namespace ApplicationInsights {
68
78
 
69
79
  const CorrelationIdHelper: ICorrelationIdHelper;
70
80
 
81
+ /**
82
+ * Creates a IDistributedTraceContext from an optional telemetryTrace
83
+ * @param telemetryTrace - The telemetryTrace instance that is being wrapped
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
+ * @returns A new IDistributedTraceContext instance that is backed by the telemetryTrace or temporary object
86
+ */
87
+ function createDistributedTraceContextFromTrace(telemetryTrace?: ITelemetryTrace, parentCtx?: IDistributedTraceContext): IDistributedTraceContext;
88
+
71
89
  function createDomEvent(eventName: string): Event;
72
90
 
73
91
  /**
@@ -85,15 +103,7 @@ declare namespace ApplicationInsights {
85
103
  [key: string]: any;
86
104
  }): ITelemetryItem;
87
105
 
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;
106
+ export { createTraceParent }
97
107
 
98
108
  let CtxTagKeys: ContextTagKeys;
99
109
 
@@ -440,11 +450,7 @@ declare namespace ApplicationInsights {
440
450
  Hidden = 4
441
451
  }
442
452
 
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;
453
+ export { findW3cTraceParent }
448
454
 
449
455
  /**
450
456
  * Formats the provided errorObj for display and reporting, it may be a String, Object, integer or undefined depending on the browser.
@@ -452,15 +458,7 @@ declare namespace ApplicationInsights {
452
458
  */
453
459
  function _formatErrorCode(errorObj: any): any;
454
460
 
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;
461
+ export { formatTraceParent }
464
462
 
465
463
  function getExtensionByName(extensions: IPlugin[], identifier: string): IPlugin | null;
466
464
 
@@ -1897,12 +1895,7 @@ declare namespace ApplicationInsights {
1897
1895
 
1898
1896
  function isInternalApplicationInsightsEndpoint(endpointUrl: string): boolean;
1899
1897
 
1900
- /**
1901
- * Is the parsed traceParent indicating that the trace is currently sampled.
1902
- * @param value - The parsed traceParent value
1903
- * @returns
1904
- */
1905
- function isSampledFlag(value: ITraceParent): boolean;
1898
+ export { isSampledFlag }
1906
1899
 
1907
1900
  interface IStackDetails {
1908
1901
  src: string;
@@ -1935,30 +1928,11 @@ declare namespace ApplicationInsights {
1935
1928
  line: number;
1936
1929
  }
1937
1930
 
1938
- /**
1939
- * Is the provided W3c span id (aka. parent id) a valid string representation, it must be a 16-character
1940
- * string of lowercase hexadecimal characters, for example, 00f067aa0ba902b7.
1941
- * If all characters are zero (0000000000000000) this is considered an invalid value.
1942
- * @param value - The W3c span id to be validated
1943
- * @returns true if valid otherwise false
1944
- */
1945
- function isValidSpanId(value: string): boolean;
1931
+ export { isValidSpanId }
1946
1932
 
1947
- /**
1948
- * Is the provided W3c Trace Id a valid string representation, it must be a 32-character string
1949
- * of lowercase hexadecimal characters for example, 4bf92f3577b34da6a3ce929d0e0e4736.
1950
- * If all characters as zero (00000000000000000000000000000000) it will be considered an invalid value.
1951
- * @param value - The W3c trace Id to be validated
1952
- * @returns true if valid otherwise false
1953
- */
1954
- function isValidTraceId(value: string): boolean;
1933
+ export { isValidTraceId }
1955
1934
 
1956
- /**
1957
- * Validates that the provided ITraceParent instance conforms to the currently supported specifications
1958
- * @param value
1959
- * @returns
1960
- */
1961
- function isValidTraceParent(value: ITraceParent): boolean;
1935
+ export { isValidTraceParent }
1962
1936
 
1963
1937
  interface ITelemetryContext {
1964
1938
  /**
@@ -2017,47 +1991,21 @@ declare namespace ApplicationInsights {
2017
1991
  */
2018
1992
  parentID?: string;
2019
1993
  /**
1994
+ * @deprecated Never Used
2020
1995
  * Trace state
2021
1996
  */
2022
1997
  traceState?: ITraceState;
1998
+ /**
1999
+ * An integer representation of the W3C TraceContext trace-flags. https://www.w3.org/TR/trace-context/#trace-flags
2000
+ */
2001
+ traceFlags?: number;
2023
2002
  /**
2024
2003
  * Name
2025
2004
  */
2026
2005
  name?: string;
2027
2006
  }
2028
2007
 
2029
- /**
2030
- * This interface represents the components of a W3C traceparent header
2031
- */
2032
- interface ITraceParent {
2033
- /**
2034
- * The version of the definition, this MUST be a string with a length of 2 and only contain lowercase
2035
- * hexadecimal characters. A value of 'ff' is considered to be an invalid version.
2036
- */
2037
- version: string;
2038
- /**
2039
- * This is the ID of the whole trace forest and is used to uniquely identify a distributed trace
2040
- * through a system. It is represented as a 32-character string of lowercase hexadecimal characters,
2041
- * for example, 4bf92f3577b34da6a3ce929d0e0e4736.
2042
- * All characters as zero (00000000000000000000000000000000) is considered an invalid value.
2043
- */
2044
- traceId: string;
2045
- /**
2046
- * This is the ID of the current request as known by the caller (in some tracing systems, this is also
2047
- * known as the parent-id, where a span is the execution of a client request). It is represented as an
2048
- * 16-character string of lowercase hexadecimal characters, for example, 00f067aa0ba902b7.
2049
- * All bytes as zero (0000000000000000) is considered an invalid value.
2050
- */
2051
- spanId: string;
2052
- /**
2053
- * An 8-bit value of flags that controls tracing such as sampling, trace level, etc. These flags are
2054
- * recommendations given by the caller rather than strict rules to follow.
2055
- * As this is a bit field, you cannot interpret flags by decoding the hex value and looking at the resulting
2056
- * number. For example, a flag 00000001 could be encoded as 01 in hex, or 09 in hex if present with the flag
2057
- * 00001000. A common mistake in bit fields is forgetting to mask when interpreting flags.
2058
- */
2059
- traceFlags: number;
2060
- }
2008
+ export { ITraceParent }
2061
2009
 
2062
2010
  interface ITraceState {
2063
2011
  }
@@ -2495,13 +2443,7 @@ declare namespace ApplicationInsights {
2495
2443
 
2496
2444
  function parseConnectionString(connectionString?: string): ConnectionString;
2497
2445
 
2498
- /**
2499
- * Attempt to parse the provided string as a W3C TraceParent header value (https://www.w3.org/TR/trace-context/#traceparent-header)
2500
- *
2501
- * @param value
2502
- * @returns
2503
- */
2504
- function parseTraceParent(value: string): ITraceParent;
2446
+ export { parseTraceParent }
2505
2447
 
2506
2448
  const ProcessLegacy = "ProcessLegacy";
2507
2449
 
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * Application Insights JavaScript SDK - Common, 2.8.4-nightly.2205-09
2
+ * Application Insights JavaScript SDK - Common, 2.8.4-nightly.2205-10
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  */
5
5
  (function (global, factory) {
@@ -832,6 +832,35 @@
832
832
  }
833
833
  return _beaconsSupported;
834
834
  }
835
+ function _getNamedValue(values, name) {
836
+ if (values) {
837
+ for (var i = 0; i < values.length; i++) {
838
+ var value = values[i];
839
+ if (value.name) {
840
+ if (value.name === name) {
841
+ return value;
842
+ }
843
+ }
844
+ }
845
+ }
846
+ return {};
847
+ }
848
+ function findMetaTag(name) {
849
+ var doc = getDocument();
850
+ if (doc && name) {
851
+ return _getNamedValue(doc.querySelectorAll("meta"), name).content;
852
+ }
853
+ return null;
854
+ }
855
+ function findNamedServerTiming(name) {
856
+ var value;
857
+ var perf = getPerformance();
858
+ if (perf) {
859
+ var navPerf = perf.getEntriesByType("navigation") || [];
860
+ value = _getNamedValue((navPerf.length > 0 ? navPerf[0] : {}).serverTiming, name).description;
861
+ }
862
+ return value;
863
+ }
835
864
 
836
865
  var _aiNamespace = null;
837
866
  function _getExtensionNamespace() {
@@ -1085,7 +1114,7 @@
1085
1114
  }
1086
1115
 
1087
1116
  var _objDefineProperty = ObjDefineProperty;
1088
- var version = "2.8.4-nightly.2205-09";
1117
+ var version = "2.8.4-nightly.2205-10";
1089
1118
  var instanceName = "." + newId(6);
1090
1119
  var _dataUid = 0;
1091
1120
  function _createAccessor(target, prop, value) {
@@ -1608,6 +1637,111 @@
1608
1637
  return _legacyCookieMgr(null, logger).del(name);
1609
1638
  }
1610
1639
 
1640
+ var TRACE_PARENT_REGEX = /^([\da-f]{2})-([\da-f]{32})-([\da-f]{16})-([\da-f]{2})(-[^\s]*)?$/;
1641
+ var DEFAULT_VERSION = "00";
1642
+ var INVALID_VERSION = "ff";
1643
+ var INVALID_TRACE_ID = "00000000000000000000000000000000";
1644
+ var INVALID_SPAN_ID = "0000000000000000";
1645
+ var SAMPLED_FLAG = 0x01;
1646
+ function _isValid(value, len, invalidValue) {
1647
+ if (value && value.length === len && value !== invalidValue) {
1648
+ return !!value.match(/^[\da-f]*$/);
1649
+ }
1650
+ return false;
1651
+ }
1652
+ function _formatValue(value, len, defValue) {
1653
+ if (_isValid(value, len)) {
1654
+ return value;
1655
+ }
1656
+ return defValue;
1657
+ }
1658
+ function _formatFlags(value) {
1659
+ if (isNaN(value) || value < 0 || value > 255) {
1660
+ value = 0x01;
1661
+ }
1662
+ var result = value.toString(16);
1663
+ while (result.length < 2) {
1664
+ result = "0" + result;
1665
+ }
1666
+ return result;
1667
+ }
1668
+ function createTraceParent(traceId, spanId, flags, version) {
1669
+ return {
1670
+ version: _isValid(version, 2, INVALID_VERSION) ? version : DEFAULT_VERSION,
1671
+ traceId: isValidTraceId(traceId) ? traceId : generateW3CId(),
1672
+ spanId: isValidSpanId(spanId) ? spanId : generateW3CId().substr(0, 16),
1673
+ traceFlags: flags >= 0 && flags <= 0xFF ? flags : 1
1674
+ };
1675
+ }
1676
+ function parseTraceParent(value) {
1677
+ if (!value) {
1678
+ return null;
1679
+ }
1680
+ if (isArray(value)) {
1681
+ value = value[0] || "";
1682
+ }
1683
+ if (!value || !isString(value) || value.length > 8192) {
1684
+ return null;
1685
+ }
1686
+ var match = TRACE_PARENT_REGEX.exec(strTrim(value));
1687
+ if (!match ||
1688
+ match[1] === INVALID_VERSION ||
1689
+ match[2] === INVALID_TRACE_ID ||
1690
+ match[3] === INVALID_SPAN_ID) {
1691
+ return null;
1692
+ }
1693
+ return {
1694
+ version: match[1],
1695
+ traceId: match[2],
1696
+ spanId: match[3],
1697
+ traceFlags: parseInt(match[4], 16)
1698
+ };
1699
+ }
1700
+ function isValidTraceId(value) {
1701
+ return _isValid(value, 32, INVALID_TRACE_ID);
1702
+ }
1703
+ function isValidSpanId(value) {
1704
+ return _isValid(value, 16, INVALID_SPAN_ID);
1705
+ }
1706
+ function isValidTraceParent(value) {
1707
+ if (!value ||
1708
+ !_isValid(value.version, 2, INVALID_VERSION) ||
1709
+ !_isValid(value.traceId, 32, INVALID_TRACE_ID) ||
1710
+ !_isValid(value.spanId, 16, INVALID_SPAN_ID) ||
1711
+ !_isValid(_formatFlags(value.traceFlags), 2)) {
1712
+ return false;
1713
+ }
1714
+ return true;
1715
+ }
1716
+ function isSampledFlag(value) {
1717
+ if (isValidTraceParent(value)) {
1718
+ return (value.traceFlags & SAMPLED_FLAG) === SAMPLED_FLAG;
1719
+ }
1720
+ return false;
1721
+ }
1722
+ function formatTraceParent(value) {
1723
+ if (value) {
1724
+ var flags = _formatFlags(value.traceFlags);
1725
+ if (!_isValid(flags, 2)) {
1726
+ flags = "01";
1727
+ }
1728
+ var version = value.version || DEFAULT_VERSION;
1729
+ if (version !== "00" && version !== "ff") {
1730
+ version = DEFAULT_VERSION;
1731
+ }
1732
+ return "".concat(version, "-").concat(_formatValue(value.traceId, 32, INVALID_TRACE_ID), "-").concat(_formatValue(value.spanId, 16, INVALID_SPAN_ID), "-").concat(flags);
1733
+ }
1734
+ return "";
1735
+ }
1736
+ function findW3cTraceParent() {
1737
+ var name = "traceparent";
1738
+ var traceParent = parseTraceParent(findMetaTag(name));
1739
+ if (!traceParent) {
1740
+ traceParent = parseTraceParent(findNamedServerTiming(name));
1741
+ }
1742
+ return traceParent;
1743
+ }
1744
+
1611
1745
  var RequestHeaders = createValueMap({
1612
1746
  requestContextHeader: [0 , "Request-Context"],
1613
1747
  requestContextTargetKey: [1 , "appId"],
@@ -2212,6 +2346,43 @@
2212
2346
  Now: dateTimeUtilsNow,
2213
2347
  GetDuration: dateTimeUtilsDuration
2214
2348
  };
2349
+ function createDistributedTraceContextFromTrace(telemetryTrace, parentCtx) {
2350
+ var trace = telemetryTrace || {};
2351
+ return {
2352
+ getName: function () {
2353
+ return trace.name;
2354
+ },
2355
+ setName: function (newValue) {
2356
+ parentCtx && parentCtx.setName(newValue);
2357
+ trace.name = newValue;
2358
+ },
2359
+ getTraceId: function () {
2360
+ return trace.traceID;
2361
+ },
2362
+ setTraceId: function (newValue) {
2363
+ parentCtx && parentCtx.setTraceId(newValue);
2364
+ if (isValidTraceId(newValue)) {
2365
+ trace.traceID = newValue;
2366
+ }
2367
+ },
2368
+ getSpanId: function () {
2369
+ return trace.parentID;
2370
+ },
2371
+ setSpanId: function (newValue) {
2372
+ parentCtx && parentCtx.setSpanId(newValue);
2373
+ if (isValidSpanId(newValue)) {
2374
+ trace.parentID = newValue;
2375
+ }
2376
+ },
2377
+ getTraceFlags: function () {
2378
+ return trace.traceFlags;
2379
+ },
2380
+ setTraceFlags: function (newTraceFlags) {
2381
+ parentCtx && parentCtx.setTraceFlags(newTraceFlags);
2382
+ trace.traceFlags = newTraceFlags;
2383
+ }
2384
+ };
2385
+ }
2215
2386
 
2216
2387
  var _FIELDS_SEPARATOR = ";";
2217
2388
  var _FIELD_KEY_VALUE_SEPARATOR = "=";
@@ -3079,131 +3250,6 @@
3079
3250
  };
3080
3251
  var CtxTagKeys = new ContextTagKeys();
3081
3252
 
3082
- var TRACE_PARENT_REGEX = /^([\da-f]{2})-([\da-f]{32})-([\da-f]{16})-([\da-f]{2})(-[^\s]*)?$/;
3083
- var DEFAULT_VERSION = "00";
3084
- var INVALID_VERSION = "ff";
3085
- var INVALID_TRACE_ID = "00000000000000000000000000000000";
3086
- var INVALID_SPAN_ID = "0000000000000000";
3087
- var SAMPLED_FLAG = 0x01;
3088
- function _isValid(value, len, invalidValue) {
3089
- if (value && value.length === len && value !== invalidValue) {
3090
- return !!value.match(/^[\da-f]*$/);
3091
- }
3092
- return false;
3093
- }
3094
- function _formatValue(value, len, defValue) {
3095
- if (_isValid(value, len)) {
3096
- return value;
3097
- }
3098
- return defValue;
3099
- }
3100
- function _formatFlags(value) {
3101
- if (isNaN(value) || value < 0 || value > 255) {
3102
- value = 0x01;
3103
- }
3104
- var result = value.toString(16);
3105
- while (result.length < 2) {
3106
- result = "0" + result;
3107
- }
3108
- return result;
3109
- }
3110
- function _getTraceParentValue(values) {
3111
- if (values) {
3112
- for (var i = 0; i < values.length; i++) {
3113
- var value = values[i];
3114
- if (value.name) {
3115
- if (value.name === "traceparent") {
3116
- return value;
3117
- }
3118
- }
3119
- }
3120
- }
3121
- return {};
3122
- }
3123
- function createTraceParent(traceId, spanId, flags, version) {
3124
- return {
3125
- version: _isValid(version, 2, INVALID_VERSION) ? version : DEFAULT_VERSION,
3126
- traceId: isValidTraceId(traceId) ? traceId : generateW3CId(),
3127
- spanId: isValidSpanId(spanId) ? spanId : generateW3CId().substr(0, 16),
3128
- traceFlags: flags >= 0 && flags <= 0xFF ? flags : 1
3129
- };
3130
- }
3131
- function parseTraceParent(value) {
3132
- if (!value) {
3133
- return null;
3134
- }
3135
- if (isArray(value)) {
3136
- value = value[0] || "";
3137
- }
3138
- if (!value || !isString(value) || value.length > 8192) {
3139
- return null;
3140
- }
3141
- var match = TRACE_PARENT_REGEX.exec(strTrim(value));
3142
- if (!match ||
3143
- match[1] === INVALID_VERSION ||
3144
- match[2] === INVALID_TRACE_ID ||
3145
- match[3] === INVALID_SPAN_ID) {
3146
- return null;
3147
- }
3148
- return {
3149
- version: match[1],
3150
- traceId: match[2],
3151
- spanId: match[3],
3152
- traceFlags: parseInt(match[4], 16)
3153
- };
3154
- }
3155
- function isValidTraceId(value) {
3156
- return _isValid(value, 32, INVALID_TRACE_ID);
3157
- }
3158
- function isValidSpanId(value) {
3159
- return _isValid(value, 16, INVALID_SPAN_ID);
3160
- }
3161
- function isValidTraceParent(value) {
3162
- if (!value ||
3163
- !_isValid(value.version, 2, INVALID_VERSION) ||
3164
- !_isValid(value.traceId, 32, INVALID_TRACE_ID) ||
3165
- !_isValid(value.spanId, 16, INVALID_SPAN_ID) ||
3166
- !_isValid(_formatFlags(value.traceFlags), 2)) {
3167
- return false;
3168
- }
3169
- return true;
3170
- }
3171
- function isSampledFlag(value) {
3172
- if (isValidTraceParent(value)) {
3173
- return (value.traceFlags & SAMPLED_FLAG) === SAMPLED_FLAG;
3174
- }
3175
- return false;
3176
- }
3177
- function formatTraceParent(value) {
3178
- if (value) {
3179
- var flags = _formatFlags(value.traceFlags);
3180
- if (!_isValid(flags, 2)) {
3181
- flags = "01";
3182
- }
3183
- var version = value.version || DEFAULT_VERSION;
3184
- if (version !== "00" && version !== "ff") {
3185
- version = DEFAULT_VERSION;
3186
- }
3187
- return "".concat(version, "-").concat(_formatValue(value.traceId, 32, INVALID_TRACE_ID), "-").concat(_formatValue(value.spanId, 16, INVALID_SPAN_ID), "-").concat(flags);
3188
- }
3189
- return "";
3190
- }
3191
- function findW3cTraceParent() {
3192
- var traceParent;
3193
- var doc = getDocument();
3194
- if (doc) {
3195
- traceParent = parseTraceParent(_getTraceParentValue(doc.querySelectorAll("meta")).content);
3196
- }
3197
- if (!traceParent) {
3198
- var perf = getPerformance();
3199
- if (perf) {
3200
- var navPerf = perf.getEntriesByType("navigation") || [];
3201
- traceParent = parseTraceParent(_getTraceParentValue((navPerf.length > 0 ? navPerf[0] : {}).serverTiming).description);
3202
- }
3203
- }
3204
- return traceParent;
3205
- }
3206
-
3207
3253
  var PropertiesPluginIdentifier = "AppInsightsPropertiesPlugin";
3208
3254
  var BreezeChannelIdentifier = "AppInsightsChannelPlugin";
3209
3255
  var AnalyticsPluginIdentifier = "ApplicationInsightsAnalytics";
@@ -3239,6 +3285,7 @@
3239
3285
  exports.Trace = Trace;
3240
3286
  exports.UrlHelper = UrlHelper;
3241
3287
  exports.Util = Util;
3288
+ exports.createDistributedTraceContextFromTrace = createDistributedTraceContextFromTrace;
3242
3289
  exports.createDomEvent = createDomEvent;
3243
3290
  exports.createTelemetryItem = createTelemetryItem;
3244
3291
  exports.createTraceParent = createTraceParent;