@microsoft/applicationinsights-dependencies-js 3.0.0-beta.2208-19 → 3.0.0-beta.2209-03

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 (38) hide show
  1. package/browser/applicationinsights-dependencies-js.integrity.json +9 -9
  2. package/browser/applicationinsights-dependencies-js.js +157 -103
  3. package/browser/applicationinsights-dependencies-js.js.map +1 -1
  4. package/browser/applicationinsights-dependencies-js.min.js +2 -2
  5. package/browser/applicationinsights-dependencies-js.min.js.map +1 -1
  6. package/dist/applicationinsights-dependencies-js.api.json +671 -34
  7. package/dist/applicationinsights-dependencies-js.api.md +63 -9
  8. package/dist/applicationinsights-dependencies-js.d.ts +73 -8
  9. package/dist/applicationinsights-dependencies-js.js +157 -103
  10. package/dist/applicationinsights-dependencies-js.js.map +1 -1
  11. package/dist/applicationinsights-dependencies-js.min.js +2 -2
  12. package/dist/applicationinsights-dependencies-js.min.js.map +1 -1
  13. package/dist/applicationinsights-dependencies-js.rollup.d.ts +75 -10
  14. package/dist-esm/DependencyInitializer.js +6 -0
  15. package/dist-esm/DependencyInitializer.js.map +1 -0
  16. package/dist-esm/DependencyListener.js +1 -1
  17. package/dist-esm/InternalConstants.js +1 -1
  18. package/dist-esm/__DynamicConstants.js +6 -6
  19. package/dist-esm/__DynamicConstants.js.map +1 -1
  20. package/dist-esm/ajax.js +153 -98
  21. package/dist-esm/ajax.js.map +1 -1
  22. package/dist-esm/ajaxRecord.js +1 -1
  23. package/dist-esm/ajaxUtils.js +1 -1
  24. package/dist-esm/applicationinsights-dependencies-js.js +1 -1
  25. package/package.json +3 -3
  26. package/src/DependencyInitializer.ts +44 -0
  27. package/src/DependencyListener.ts +13 -3
  28. package/src/__DynamicConstants.ts +5 -5
  29. package/src/ajax.ts +183 -106
  30. package/src/ajaxRecord.ts +5 -0
  31. package/src/applicationinsights-dependencies-js.ts +5 -1
  32. package/types/DependencyInitializer.d.ts +41 -0
  33. package/types/DependencyListener.d.ts +14 -3
  34. package/types/__DynamicConstants.d.ts +4 -4
  35. package/types/ajax.d.ts +18 -5
  36. package/types/ajaxRecord.d.ts +6 -0
  37. package/types/applicationinsights-dependencies-js.d.ts +2 -0
  38. package/types/tsdoc-metadata.json +1 -1
@@ -17,16 +17,21 @@ import { IProcessTelemetryContext } from '@microsoft/applicationinsights-core-js
17
17
  import { ITelemetryItem } from '@microsoft/applicationinsights-core-js';
18
18
  import { ITelemetryPluginChain } from '@microsoft/applicationinsights-core-js';
19
19
 
20
+ // Warning: (ae-forgotten-export) The symbol "IDependencyListenerContainer" needs to be exported by the entry point applicationinsights-dependencies-js.d.ts
21
+ //
20
22
  // @public (undocumented)
21
- export class AjaxPlugin extends BaseTelemetryPlugin implements IDependenciesPlugin, IInstrumentationRequirements {
23
+ export class AjaxPlugin extends BaseTelemetryPlugin implements IDependenciesPlugin, IInstrumentationRequirements, IDependencyListenerContainer {
22
24
  constructor();
23
- // Warning: (ae-forgotten-export) The symbol "DependencyListenerFunction" needs to be exported by the entry point applicationinsights-dependencies-js.d.ts
24
- // Warning: (ae-forgotten-export) The symbol "IDependencyListenerHandler" needs to be exported by the entry point applicationinsights-dependencies-js.d.ts
25
+ addDependencyInitializer(dependencyInitializer: DependencyInitializerFunction): IDependencyInitializerHandler;
25
26
  addDependencyListener(dependencyListener: DependencyListenerFunction): IDependencyListenerHandler;
27
+ // Warning: (ae-forgotten-export) The symbol "_getDefaultConfig" needs to be exported by the entry point applicationinsights-dependencies-js.d.ts
28
+ //
26
29
  // (undocumented)
27
- static getDefaultConfig(): ICorrelationConfig;
30
+ static getDefaultConfig: typeof _getDefaultConfig;
31
+ // Warning: (ae-forgotten-export) The symbol "_getEmptyConfig" needs to be exported by the entry point applicationinsights-dependencies-js.d.ts
32
+ //
28
33
  // (undocumented)
29
- static getEmptyConfig(): ICorrelationConfig;
34
+ static getEmptyConfig: typeof _getEmptyConfig;
30
35
  // (undocumented)
31
36
  static identifier: string;
32
37
  // (undocumented)
@@ -66,6 +71,9 @@ export class ajaxRecord {
66
71
  clientFailure: number;
67
72
  // (undocumented)
68
73
  completed: boolean;
74
+ context?: {
75
+ [key: string]: any;
76
+ };
69
77
  // Warning: (ae-forgotten-export) The symbol "IAjaxRecordResponse" needs to be exported by the entry point applicationinsights-dependencies-js.d.ts
70
78
  //
71
79
  // (undocumented)
@@ -121,22 +129,68 @@ export class ajaxRecord {
121
129
  xhrMonitoringState: XHRMonitoringState;
122
130
  }
123
131
 
132
+ // @public
133
+ export type DependencyInitializerFunction = (item: IDependencyInitializerDetails) => boolean | void;
134
+
135
+ // @public
136
+ export type DependencyListenerFunction = (dependencyDetails: IDependencyListenerDetails) => void;
137
+
124
138
  // @public (undocumented)
125
139
  export const DfltAjaxCorrelationHeaderExDomains: string[];
126
140
 
127
- // Warning: (ae-forgotten-export) The symbol "IDependencyListenerContainer" needs to be exported by the entry point applicationinsights-dependencies-js.d.ts
128
- //
129
141
  // @public (undocumented)
130
142
  export interface IDependenciesPlugin extends IDependencyListenerContainer {
131
143
  trackDependencyData(dependency: IDependencyTelemetry): void;
132
144
  }
133
145
 
146
+ // @public (undocumented)
147
+ export interface IDependencyHandler {
148
+ // (undocumented)
149
+ remove(): void;
150
+ }
151
+
152
+ // @public (undocumented)
153
+ export interface IDependencyInitializerDetails {
154
+ context?: {
155
+ [key: string]: any;
156
+ };
157
+ item: IDependencyTelemetry;
158
+ properties?: {
159
+ [key: string]: any;
160
+ };
161
+ sysProperties?: {
162
+ [key: string]: any;
163
+ };
164
+ }
165
+
166
+ // @public (undocumented)
167
+ export interface IDependencyInitializerHandler extends IDependencyHandler {
168
+ }
169
+
170
+ // @public (undocumented)
171
+ export interface IDependencyListenerDetails {
172
+ context?: {
173
+ [key: string]: any;
174
+ };
175
+ core: IAppInsightsCore;
176
+ init?: RequestInit;
177
+ input?: Request | string;
178
+ spanId?: string;
179
+ traceFlags?: number;
180
+ traceId?: string;
181
+ xhr?: XMLHttpRequest;
182
+ }
183
+
184
+ // @public (undocumented)
185
+ export interface IDependencyListenerHandler extends IDependencyHandler {
186
+ }
187
+
134
188
  // @public (undocumented)
135
189
  export interface IInstrumentationRequirements extends IDependenciesPlugin {
136
- // Warning: (ae-forgotten-export) The symbol "_DYN_INCLUDE_CORRELATION_3" needs to be exported by the entry point applicationinsights-dependencies-js.d.ts
190
+ // Warning: (ae-forgotten-export) The symbol "_DYN_INCLUDE_CORRELATION_2" needs to be exported by the entry point applicationinsights-dependencies-js.d.ts
137
191
  //
138
192
  // (undocumented)
139
- [_DYN_INCLUDE_CORRELATION_3]: (ajaxData: ajaxRecord, input?: Request | string, init?: RequestInit, xhr?: XMLHttpRequestInstrumented) => any;
193
+ [_DYN_INCLUDE_CORRELATION_2]: (ajaxData: ajaxRecord, input?: Request | string, init?: RequestInit, xhr?: XMLHttpRequestInstrumented) => any;
140
194
  }
141
195
 
142
196
  // @public (undocumented)
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Microsoft Application Insights XHR dependencies plugin, 3.0.0-beta.2208-19
2
+ * Microsoft Application Insights XHR dependencies plugin, 3.0.0-beta.2209-03
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  *
5
5
  * Microsoft Application Insights Team
@@ -20,10 +20,10 @@ declare namespace ApplicationInsights {
20
20
  import { ITelemetryItem } from '@microsoft/applicationinsights-core-js';
21
21
  import { ITelemetryPluginChain } from '@microsoft/applicationinsights-core-js';
22
22
 
23
- class AjaxPlugin extends BaseTelemetryPlugin implements IDependenciesPlugin, IInstrumentationRequirements {
23
+ class AjaxPlugin extends BaseTelemetryPlugin implements IDependenciesPlugin, IInstrumentationRequirements, IDependencyListenerContainer {
24
24
  static identifier: string;
25
- static getDefaultConfig(): ICorrelationConfig;
26
- static getEmptyConfig(): ICorrelationConfig;
25
+ static getDefaultConfig: typeof _getDefaultConfig;
26
+ static getEmptyConfig: typeof _getEmptyConfig;
27
27
  identifier: string;
28
28
  priority: number;
29
29
  constructor();
@@ -44,6 +44,15 @@ declare namespace ApplicationInsights {
44
44
  * @returns - A IDependencyListenerHandler to enable the initializer to be removed
45
45
  */
46
46
  addDependencyListener(dependencyListener: DependencyListenerFunction): IDependencyListenerHandler;
47
+ /**
48
+ * Add an dependency telemetry initializer callback function to allow populating additional properties or drop the request.
49
+ * It is called after the dependency call has completed and any available performance details are available. A dependency
50
+ * initializer is similar to the TelemetryInitializer function but it allows you to block the reporting of the dependency
51
+ * request so that it doesn't count against the `maxAjaxCallsPerView`.
52
+ * @param dependencyInitializer - The Dependency Telemetry Initializer function
53
+ * @returns - A IDependencyInitializerHandler to enable the initializer to be removed
54
+ */
55
+ addDependencyInitializer(dependencyInitializer: DependencyInitializerFunction): IDependencyInitializerHandler;
47
56
  /**
48
57
  * Protected function to allow sub classes the chance to add additional properties to the dependency event
49
58
  * before it's sent. This function calls track, so sub-classes must call this function after they have
@@ -98,6 +107,12 @@ declare namespace ApplicationInsights {
98
107
  * The trace context to use for reporting the remote dependency call
99
108
  */
100
109
  eventTraceCtx: ITraceCtx;
110
+ /**
111
+ * The listener assigned context values that will be passed to any dependency initializer
112
+ */
113
+ context?: {
114
+ [key: string]: any;
115
+ };
101
116
  constructor(traceId: string, spanId: string, logger: IDiagnosticLogger, traceCtx?: IDistributedTraceContext);
102
117
  getAbsoluteUrl(): string;
103
118
  getPathName(): string;
@@ -107,13 +122,26 @@ declare namespace ApplicationInsights {
107
122
  };
108
123
  }
109
124
 
125
+ /**
126
+ * The initializer function that will be called, if it returns false the event will be dropped and not reported
127
+ * or counted against the `maxAjaxCallsPerView`.
128
+ */
129
+ type DependencyInitializerFunction = (item: IDependencyInitializerDetails) => boolean | void;
130
+
131
+ /**
132
+ * The function that will get called when the ajax request is about to occur.
133
+ */
110
134
  type DependencyListenerFunction = (dependencyDetails: IDependencyListenerDetails) => void;
111
135
 
112
136
  const DfltAjaxCorrelationHeaderExDomains: string[];
113
137
 
114
138
  const _DYN_HEADER_MAP = "headerMap";
115
139
 
116
- const _DYN_INCLUDE_CORRELATION_3 = "includeCorrelationHeaders";
140
+ const _DYN_INCLUDE_CORRELATION_2 = "includeCorrelationHeaders";
141
+
142
+ function _getDefaultConfig(): ICorrelationConfig;
143
+
144
+ function _getEmptyConfig(): ICorrelationConfig;
117
145
 
118
146
  interface IAjaxRecordResponse {
119
147
  statusText: string;
@@ -132,6 +160,38 @@ declare namespace ApplicationInsights {
132
160
  trackDependencyData(dependency: IDependencyTelemetry): void;
133
161
  }
134
162
 
163
+ interface IDependencyHandler {
164
+ remove(): void;
165
+ }
166
+
167
+ interface IDependencyInitializerDetails {
168
+ /**
169
+ * The DependencyTelemetry event that will be passed to the `trackDependencyDataInternal` function.
170
+ */
171
+ item: IDependencyTelemetry;
172
+ /**
173
+ * Additional properties to be added to the event
174
+ */
175
+ properties?: {
176
+ [key: string]: any;
177
+ };
178
+ /**
179
+ * Additional system properties to be added to the event.
180
+ */
181
+ sysProperties?: {
182
+ [key: string]: any;
183
+ };
184
+ /**
185
+ * The context that the application can assigned via the dependency listener(s)
186
+ */
187
+ context?: {
188
+ [key: string]: any;
189
+ };
190
+ }
191
+
192
+ interface IDependencyInitializerHandler extends IDependencyHandler {
193
+ }
194
+
135
195
  interface IDependencyListenerContainer {
136
196
  /**
137
197
  * Add an ajax listener which is called just prior to the request being sent and before the correlation headers are added, to allow you
@@ -179,14 +239,19 @@ declare namespace ApplicationInsights {
179
239
  * https://www.w3.org/TR/trace-context/#trace-flags
180
240
  */
181
241
  traceFlags?: number;
242
+ /**
243
+ * [Optional] Context that the application can assign that will also be passed to any dependency initializer
244
+ */
245
+ context?: {
246
+ [key: string]: any;
247
+ };
182
248
  }
183
249
 
184
- interface IDependencyListenerHandler {
185
- remove(): void;
250
+ interface IDependencyListenerHandler extends IDependencyHandler {
186
251
  }
187
252
 
188
253
  interface IInstrumentationRequirements extends IDependenciesPlugin {
189
- [_DYN_INCLUDE_CORRELATION_3]: (ajaxData: ajaxRecord, input?: Request | string, init?: RequestInit, xhr?: XMLHttpRequestInstrumented) => any;
254
+ [_DYN_INCLUDE_CORRELATION_2]: (ajaxData: ajaxRecord, input?: Request | string, init?: RequestInit, xhr?: XMLHttpRequestInstrumented) => any;
190
255
  }
191
256
 
192
257
  interface ITraceCtx {