@microsoft/applicationinsights-offlinechannel-js 0.4.0-nightlybeta3.2505-36 → 0.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.
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Microsoft Application Insights JavaScript SDK Offline Channel, 0.4.0-nightlybeta3.2505-36
2
+ * Microsoft Application Insights JavaScript SDK Offline Channel, 0.4.0-nightlybeta3.2507-23
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  *
5
5
  * Microsoft Application Insights Team
@@ -29,9 +29,12 @@ declare namespace ApplicationInsights {
29
29
  */
30
30
  processNext: (env: ITelemetryItem, itemCtx: IProcessTelemetryContext) => void;
31
31
  /**
32
- * Set next extension for telemetry processing
32
+ * Set next extension for telemetry processing, this is now optional as plugins should use the
33
+ * processNext() function of the passed IProcessTelemetryContext instead. It is being kept for
34
+ * now for backward compatibility only.
35
+ * @deprecated - Use processNext() function of the passed IProcessTelemetryContext instead
33
36
  */
34
- setNextPlugin: (next: ITelemetryPlugin | ITelemetryPluginChain) => void;
37
+ setNextPlugin?: (next: ITelemetryPlugin | ITelemetryPluginChain) => void;
35
38
  /**
36
39
  * Returns the current diagnostic logger that can be used to log issues, if no logger is currently
37
40
  * assigned a new default one will be created and returned.
@@ -153,17 +156,78 @@ declare namespace ApplicationInsights {
153
156
 
154
157
  const enum eDistributedTracingModes {
155
158
  /**
156
- * (Default) Send Application Insights correlation headers
159
+ * Send only the legacy Application Insights correlation headers
160
+ *
161
+ * Headers Sent:
162
+ * - `Request-Id` (Legacy Application Insights header for older Server side SDKs)
163
+ *
164
+ * Config Decimal Value: `0` (Zero)
157
165
  */
158
166
  AI = 0,
159
167
  /**
160
- * Send both W3C Trace Context headers and back-compatibility Application Insights headers
168
+ * (Default) Send both W3C Trace parent header and back-compatibility Application Insights headers
169
+ * - `Request-Id`
170
+ * - [`traceparent`](https://www.w3.org/TR/trace-context/#traceparent-header)
171
+ *
172
+ * Config Decimal Value: `1` (One)
161
173
  */
162
174
  AI_AND_W3C = 1,
163
175
  /**
164
- * Send W3C Trace Context headers
176
+ * Send Only the W3C Trace parent header
177
+ *
178
+ * Headers Sent:
179
+ * - [`traceparent`](https://www.w3.org/TR/trace-context/#traceparent-header)
180
+ *
181
+ * Config Decimal Value: `2` (Two)
182
+ */
183
+ W3C = 2,
184
+ /**
185
+ * @internal
186
+ * Bitwise mask used to separate the base distributed tracing mode from the additional optional
187
+ * tracing modes.
188
+ * @since 3.4.0
189
+ */
190
+ _BaseMask = 15,
191
+ /**
192
+ * @internal
193
+ * Enabling this bit will send the W3C Trace State header, it is not intended to be used directly
194
+ * or on its own. The code may assume that if this bit is set, then the W3C Trace Context headers
195
+ * will also be included.
196
+ *
197
+ * Config Decimal Value: `16` (Sixteen in decimal)
198
+ * @since 3.4.0
165
199
  */
166
- W3C = 2
200
+ _W3CTraceState = 16,
201
+ /**
202
+ * Send all of the W3C Trace Context headers and the W3C Trace State headers and back-compatibility
203
+ * Application Insights headers.
204
+ *
205
+ * Currently sent headers:
206
+ * - `Request-Id` (Legacy Application Insights header for older Server side SDKs)
207
+ * - [`traceparent`](https://www.w3.org/TR/trace-context/#traceparent-header)
208
+ * - [`tracestate`](https://www.w3.org/TR/trace-context/#tracestate-header)
209
+ *
210
+ * NOTE!: Additional headers may be added as part of a future update should the W3C Trace Context specification be updated
211
+ * to include additional headers.
212
+ *
213
+ * Config Decimal Value: `17` (Seventeen in decimal)
214
+ * @since 3.4.0
215
+ */
216
+ AI_AND_W3C_TRACE = 17,
217
+ /**
218
+ * Send all of the W3C Trace Context headers and the W3C Trace State headers.
219
+ *
220
+ * Currently sent headers:
221
+ * - [`traceparent`](https://www.w3.org/TR/trace-context/#traceparent-header)
222
+ * - [`tracestate`](https://www.w3.org/TR/trace-context/#tracestate-header)
223
+ *
224
+ * NOTE!: Additional headers may be added as part of a future update should the W3C Trace Context specification be updated
225
+ * to include additional headers.
226
+ *
227
+ * Config Decimal Value: `18` (Eighteen in decimal)
228
+ * @since 3.4.0
229
+ */
230
+ W3C_TRACE = 18
167
231
  }
168
232
 
169
233
  const enum _eInternalMessageId {
@@ -330,6 +394,30 @@ declare namespace ApplicationInsights {
330
394
  IndexDb = 3
331
395
  }
332
396
 
397
+ /**
398
+ * Controls how the SDK should look for trace headers (traceparent/tracestate) from the initial page load
399
+ * The values are bitwise OR'd together to allow for multiple values to be set at once.
400
+ * @since 3.4.0
401
+ */
402
+ const enum eTraceHeadersMode {
403
+ /**
404
+ * Don't look for any trace headers
405
+ */
406
+ None = 0,
407
+ /**
408
+ * Look for traceparent header/meta tag
409
+ */
410
+ TraceParent = 1,
411
+ /**
412
+ * Look for tracestate header/meta tag
413
+ */
414
+ TraceState = 2,
415
+ /**
416
+ * Look for both traceparent and tracestate headers/meta tags
417
+ */
418
+ All = 3
419
+ }
420
+
333
421
  /**
334
422
  * The EventPersistence contains a set of values that specify the event's persistence.
335
423
  */
@@ -493,7 +581,7 @@ declare namespace ApplicationInsights {
493
581
  */
494
582
  flush(isAsync?: boolean, callBack?: (flushComplete?: boolean) => void, sendReason?: SendRequestReason, cbTimeout?: number): boolean | void;
495
583
  /**
496
- * Gets the current distributed trace context for this instance if available
584
+ * Gets the current distributed trace active context for this instance
497
585
  * @param createNew - Optional flag to create a new instance if one doesn't currently exist, defaults to true
498
586
  */
499
587
  getTraceCtx(createNew?: boolean): IDistributedTraceContext | null;
@@ -542,9 +630,12 @@ declare namespace ApplicationInsights {
542
630
  */
543
631
  getCfg: () => IConfiguration;
544
632
  /**
545
- * Gets the named extension config
633
+ * Gets the named extension configuration
634
+ * @param identifier - The named extension identifier
635
+ * @param defaultValue - The default value(s) to return if no defined config exists
636
+ * @param rootOnly - If true, only the look for the configuration in the top level and not in the "extensionConfig"
546
637
  */
547
- getExtCfg: <T>(identifier: string, defaultValue?: IConfigDefaults<T>) => T;
638
+ getExtCfg: <T>(identifier: string, defaultValue?: IConfigDefaults<T>, rootOnly?: boolean) => T;
548
639
  /**
549
640
  * Gets the named config from either the named identifier extension or core config if neither exist then the
550
641
  * default value is returned
@@ -1165,7 +1256,7 @@ declare namespace ApplicationInsights {
1165
1256
  * }
1166
1257
  * ```
1167
1258
  *
1168
- * For more details, see the [Page Unload Events documentation](https://microsoft.github.io/ApplicationInsights-JS/docs/PageUnloadEvents.html).
1259
+ * For more details, see the [Page Unload Events documentation](https://microsoft.github.io/ApplicationInsights-JS/PageUnloadEvents.html).
1169
1260
  */
1170
1261
  disablePageUnloadEvents?: string[];
1171
1262
  /**
@@ -1180,7 +1271,7 @@ declare namespace ApplicationInsights {
1180
1271
  * }
1181
1272
  * ```
1182
1273
  *
1183
- * For more details, see the [Page Unload Events documentation](https://microsoft.github.io/ApplicationInsights-JS/docs/PageUnloadEvents.html).
1274
+ * For more details, see the [Page Unload Events documentation](https://microsoft.github.io/ApplicationInsights-JS/PageUnloadEvents.html).
1184
1275
  */
1185
1276
  disablePageShowEvents?: string[];
1186
1277
  /**
@@ -1222,6 +1313,25 @@ declare namespace ApplicationInsights {
1222
1313
  * @since 3.3.2
1223
1314
  */
1224
1315
  expCfg?: IExceptionConfig;
1316
+ /**
1317
+ * [Optional] A flag to enable or disable the use of the field redaction for urls.
1318
+ * @defaultValue true
1319
+ */
1320
+ redactUrls?: boolean;
1321
+ /**
1322
+ * [Optional] Additional query parameters to redact beyond the default set.
1323
+ * Use this to specify custom parameters that contain sensitive information.
1324
+ * These will be combined with the default parameters that are redacted.
1325
+ * @defaultValue ["sig", "Signature", "AWSAccessKeyId", "X-Goog-Signature"]
1326
+ * @example ["sig", "Signature", "AWSAccessKeyId", "X-Goog-Signature","auth_token", "api_key", "private_data"]
1327
+ */
1328
+ redactQueryParams?: string[];
1329
+ /**
1330
+ * [Optional] Controls if the SDK should look for the `traceparent` and/or `tracestate` values from
1331
+ * the service timing headers or meta tags from the initial page load.
1332
+ * @defaultValue eTraceHeadersMode.All
1333
+ */
1334
+ traceHdrMode?: eTraceHeadersMode;
1225
1335
  }
1226
1336
 
1227
1337
  interface ICookieMgr {
@@ -1402,8 +1512,13 @@ declare namespace ApplicationInsights {
1402
1512
  */
1403
1513
  getName(): string;
1404
1514
  /**
1405
- * Sets the current name of the page
1515
+ * Sets the current name of the page, also updates the name for any parent context.
1516
+ * This is used to identify the page in the telemetry data.
1517
+ * @remarks This function updates the current and ALL parent contexts with the new name,
1518
+ * to just update the name of the current context, use the `pageName` property.
1406
1519
  * @param pageName - The name of the page
1520
+ * @deprecated Use the `pageName` property to avoid the side effect of changing the page name of all
1521
+ * parent contexts.
1407
1522
  */
1408
1523
  setName(pageName: string): void;
1409
1524
  /**
@@ -1416,6 +1531,12 @@ declare namespace ApplicationInsights {
1416
1531
  * Set the unique identifier for a trace. All requests / spans from the same trace share the same traceId.
1417
1532
  * Must be conform to the W3C TraceContext specification, in a hex representation of 16-byte array.
1418
1533
  * A.k.a. trace-id, TraceID or Distributed TraceID https://www.w3.org/TR/trace-context/#trace-id
1534
+ *
1535
+ * @remarks Sets the traceId for the current context AND all parent contexts, if you want to set the traceId
1536
+ * for the current context only, use the `traceId` property.
1537
+ * @param newValue - The traceId to set
1538
+ * @deprecated Use the `traceId` property to avoid the side effect of changing the traceId of all
1539
+ * parent contexts.
1419
1540
  */
1420
1541
  setTraceId(newValue: string): void;
1421
1542
  /**
@@ -1427,6 +1548,12 @@ declare namespace ApplicationInsights {
1427
1548
  * Self-generated 8-bytes identifier of the incoming request. Must be a hex representation of 8-byte array.
1428
1549
  * Also know as the parentId, used to link requests together
1429
1550
  * https://www.w3.org/TR/trace-context/#parent-id
1551
+ *
1552
+ * @remarks Sets the spanId for the current context AND all parent contexts, if you want to set the spanId for
1553
+ * the current context only, use the `spanId` property.
1554
+ * @param newValue - The spanId to set
1555
+ * @deprecated Use the `spanId` property to avoid the side effect of changing the spanId of all
1556
+ * parent contexts.
1430
1557
  */
1431
1558
  setSpanId(newValue: string): void;
1432
1559
  /**
@@ -1435,9 +1562,80 @@ declare namespace ApplicationInsights {
1435
1562
  getTraceFlags(): number | undefined;
1436
1563
  /**
1437
1564
  * https://www.w3.org/TR/trace-context/#trace-flags
1565
+ * @remarks Sets the trace flags for the current context and ALL parent contexts, if you want to set the trace
1566
+ * flags for the current context only, use the `traceFlags` property.
1438
1567
  * @param newValue - An integer representation of the W3C TraceContext trace-flags.
1568
+ * @deprecated Use the `traceFlags` property to avoid the side effect of changing the traceFlags of all
1569
+ * parent contexts.
1439
1570
  */
1440
1571
  setTraceFlags(newValue?: number): void;
1572
+ /**
1573
+ * Returns the current name of the page
1574
+ * @remarks This function updates the current context only, to update the name of the current and ALL parent contexts,
1575
+ * use the `setName` method.
1576
+ * @default undefined
1577
+ * @since 3.4.0
1578
+ */
1579
+ pageName: string;
1580
+ /**
1581
+ * The current ID of the trace that this span belongs to. It is worldwide unique
1582
+ * with practically sufficient probability by being made as 16 randomly
1583
+ * generated bytes, encoded as a 32 lowercase hex characters corresponding to
1584
+ * 128 bits.
1585
+ * @remarks If you update this value, it will only update for the current context, not the parent context,
1586
+ * if you need to update the current and ALL parent contexts, use the `setTraceId` method.
1587
+ * @since 3.4.0
1588
+ */
1589
+ traceId: string;
1590
+ /**
1591
+ * The ID of the Span. It is globally unique with practically sufficient
1592
+ * probability by being made as 8 randomly generated bytes, encoded as a 16
1593
+ * lowercase hex characters corresponding to 64 bits.
1594
+ * If you update this value, it will only update for the current context, not the parent context.
1595
+ * @remarks If you update this value, it will only update for the current context, not the parent context,
1596
+ * if you need to update the current and ALL parent contexts, use the `setSpanId` method.
1597
+ * @since 3.4.0
1598
+ */
1599
+ spanId: string;
1600
+ /**
1601
+ * Returns true if the current context was initialized (propagated) from a remote parent.
1602
+ * @since 3.4.0
1603
+ * @default false
1604
+ * @returns True if the context was propagated from a remote parent
1605
+ */
1606
+ readonly isRemote: boolean;
1607
+ /**
1608
+ * Trace flags to propagate.
1609
+ *
1610
+ * It is represented as 1 byte (bitmap). Bit to represent whether trace is
1611
+ * sampled or not. When set, the least significant bit documents that the
1612
+ * caller may have recorded trace data. A caller who does not record trace
1613
+ * data out-of-band leaves this flag unset.
1614
+ *
1615
+ * see {@link eW3CTraceFlags} for valid flag values.
1616
+ *
1617
+ * @remarks If you update this value, it will only update for the current context, not the parent context,
1618
+ * if you need to update the current and ALL parent contexts, use the `setTraceFlags` method.
1619
+ * @since 3.4.0
1620
+ */
1621
+ traceFlags?: number;
1622
+ /**
1623
+ * Returns the current trace state which will be used to propgate context across different services.
1624
+ * Updating (adding / removing keys) of the trace state will modify the current context.
1625
+ * @remarks Unlike the OpenTelemetry {@link TraceState}, this value is a mutable object, so you can
1626
+ * modify it directly you do not need to reassign the new value to this property.
1627
+ * @since 3.4.0
1628
+ */
1629
+ readonly traceState: IW3cTraceState;
1630
+ /**
1631
+ * Provides access to the parent context of the current context.
1632
+ * @remarks This is a read-only property, you cannot modify the parent context directly, you can only
1633
+ * modify the current context. If you need to modify the parent context, you need to do it through the
1634
+ * current context using the `setTraceId`, `setSpanId`, `setTraceFlags` and `setName` methods.
1635
+ * @default null
1636
+ * @since 3.4.0
1637
+ */
1638
+ readonly parentCtx?: IDistributedTraceContext | null;
1441
1639
  }
1442
1640
 
1443
1641
  /**
@@ -2610,9 +2808,10 @@ declare namespace ApplicationInsights {
2610
2808
  */
2611
2809
  interface ITelemetryPlugin extends ITelemetryProcessor, IPlugin {
2612
2810
  /**
2613
- * Set next extension for telemetry processing, this is not optional as plugins should use the
2811
+ * Set next extension for telemetry processing, this is now optional as plugins should use the
2614
2812
  * processNext() function of the passed IProcessTelemetryContext instead. It is being kept for
2615
2813
  * now for backward compatibility only.
2814
+ * @deprecated - Use processNext() function of the passed IProcessTelemetryContext instead
2616
2815
  */
2617
2816
  setNextPlugin?: (next: ITelemetryPlugin | ITelemetryPluginChain) => void;
2618
2817
  /**
@@ -2894,6 +3093,76 @@ declare namespace ApplicationInsights {
2894
3093
  run: (logger?: IDiagnosticLogger) => void;
2895
3094
  }
2896
3095
 
3096
+ /**
3097
+ * Represents a mutable [W3C trace state list](https://www.w3.org/TR/trace-context/#tracestate-header), this is a
3098
+ * list of key/value pairs that are used to pass trace state information between different tracing systems. The
3099
+ * list is ordered and the order is important as it determines the processing order.
3100
+ *
3101
+ * Importantly instances of this type are mutable, change made to an instance via {@link IW3cTraceState.set} or
3102
+ * {@link IW3cTraceState.del} will be reflected on the instance and any child instances that use it as a parent.
3103
+ * However, any parent instance associated with an instance will not be modified by operations on that particular
3104
+ * instance.
3105
+ *
3106
+ * @since 3.4.0
3107
+ */
3108
+ interface IW3cTraceState {
3109
+ /**
3110
+ * Returns a readonly array of the current keys associated with the trace state, keys are returned in the
3111
+ * required processing order and if this instance has a parent the keys from the parent will be included
3112
+ * unless they have been removed (deleted) from the child instance.
3113
+ * Once created any modifications to the parent will also be reflected in the child, this is different from
3114
+ * the OpenTelemetry implementation which creates a new instance for each call.
3115
+ * @returns A readonly array of the current keys associated with the trace state
3116
+ */
3117
+ readonly keys: string[];
3118
+ /**
3119
+ * Check if the trace state list is empty, meaning it has no keys or values.
3120
+ * This exists to allow for quick checks without needing to create a new array of keys.
3121
+ * @since 3.4.0
3122
+ * @returns true if the trace state list is empty, false otherwise
3123
+ */
3124
+ readonly isEmpty: boolean;
3125
+ /**
3126
+ * Get the value for the specified key that is associated with this instance, either directly or from the parent.
3127
+ * @param key - The key to lookup
3128
+ * @returns The value for the key, or undefined if not found
3129
+ */
3130
+ get(key: string): string | undefined;
3131
+ /**
3132
+ * Set the value for the specified key for this instance, returning its new location within the list.
3133
+ * - 0 is the front of the list
3134
+ * - -1 not set because the key/value pair is invalid
3135
+ * If the key already exists it will be removed from its current location and added to the front of the list. And
3136
+ * if the key was in the parent this will override the value inherited from the parent, more importantly it will
3137
+ * not modify the parent value.
3138
+ * @param key - The key to set
3139
+ * @param value - The value to set
3140
+ * @returns 0 if successful, -1 if not
3141
+ */
3142
+ set(key: string, value: string): number;
3143
+ /**
3144
+ * Delete the specified key from this instance, if the key was in the parent it will be removed (hidden) from
3145
+ * this instance but will still be available directly from the parent.
3146
+ * @param key - The key to delete
3147
+ */
3148
+ del(key: string): void;
3149
+ /**
3150
+ * Format the trace state list into a strings where each string can be used as a header value.
3151
+ * This will return an empty array if the trace state list is empty.
3152
+ * @param maxHeaders - The maximum number of entries to include in the output, once the limit is reached no more entries will be included
3153
+ * @param maxKeys - The maximum number of keys to include in the output, once the limit is reached no more keys will be included
3154
+ * @param maxLen - The maximum length of each header value, once the limit is reached a new header value will be created
3155
+ * @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
3156
+ */
3157
+ hdrs(maxHeaders?: number, maxKeys?: number, maxLen?: number): string[];
3158
+ /**
3159
+ * Create a new instance of IW3cTraceState which is a child of this instance, meaning it will inherit the keys
3160
+ * and values from this instance but any changes made to the child will not affect this instance.
3161
+ * @returns A new instance of IW3cTraceState which is a child of this instance
3162
+ */
3163
+ child(): IW3cTraceState;
3164
+ }
3165
+
2897
3166
  interface IWatchDetails<T = IConfiguration> {
2898
3167
  /**
2899
3168
  * The current config object