@microsoft/applicationinsights-teechannel-js 3.0.7 → 3.0.9

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 (48) hide show
  1. package/browser/es5/{applicationinsights-teechannel-js.3.0.7.cjs.js → applicationinsights-teechannel-js.3.0.9.cjs.js} +232 -217
  2. package/browser/es5/applicationinsights-teechannel-js.3.0.9.cjs.js.map +1 -0
  3. package/browser/es5/applicationinsights-teechannel-js.3.0.9.cjs.min.js +6 -0
  4. package/browser/es5/applicationinsights-teechannel-js.3.0.9.cjs.min.js.map +1 -0
  5. package/browser/es5/{applicationinsights-teechannel-js.3.0.7.gbl.js → applicationinsights-teechannel-js.3.0.9.gbl.js} +234 -219
  6. package/browser/es5/applicationinsights-teechannel-js.3.0.9.gbl.js.map +1 -0
  7. package/browser/es5/applicationinsights-teechannel-js.3.0.9.gbl.min.js +6 -0
  8. package/browser/es5/applicationinsights-teechannel-js.3.0.9.gbl.min.js.map +1 -0
  9. package/browser/es5/applicationinsights-teechannel-js.3.0.9.integrity.json +66 -0
  10. package/browser/es5/{applicationinsights-teechannel-js.3.0.7.js → applicationinsights-teechannel-js.3.0.9.js} +234 -219
  11. package/browser/es5/applicationinsights-teechannel-js.3.0.9.js.map +1 -0
  12. package/browser/es5/applicationinsights-teechannel-js.3.0.9.min.js +6 -0
  13. package/browser/es5/applicationinsights-teechannel-js.3.0.9.min.js.map +1 -0
  14. package/browser/es5/applicationinsights-teechannel-js.3.cjs.js +231 -216
  15. package/browser/es5/applicationinsights-teechannel-js.3.cjs.js.map +1 -1
  16. package/browser/es5/applicationinsights-teechannel-js.3.cjs.min.js +2 -2
  17. package/browser/es5/applicationinsights-teechannel-js.3.cjs.min.js.map +1 -1
  18. package/browser/es5/applicationinsights-teechannel-js.3.gbl.js +233 -218
  19. package/browser/es5/applicationinsights-teechannel-js.3.gbl.js.map +1 -1
  20. package/browser/es5/applicationinsights-teechannel-js.3.gbl.min.js +2 -2
  21. package/browser/es5/applicationinsights-teechannel-js.3.gbl.min.js.map +1 -1
  22. package/browser/es5/applicationinsights-teechannel-js.3.integrity.json +25 -25
  23. package/browser/es5/applicationinsights-teechannel-js.3.js +233 -218
  24. package/browser/es5/applicationinsights-teechannel-js.3.js.map +1 -1
  25. package/browser/es5/applicationinsights-teechannel-js.3.min.js +2 -2
  26. package/browser/es5/applicationinsights-teechannel-js.3.min.js.map +1 -1
  27. package/dist/es5/applicationinsights-teechannel-js.js +231 -216
  28. package/dist/es5/applicationinsights-teechannel-js.js.map +1 -1
  29. package/dist/es5/applicationinsights-teechannel-js.min.js +2 -2
  30. package/dist/es5/applicationinsights-teechannel-js.min.js.map +1 -1
  31. package/dist-es5/ChannelController.js +1 -1
  32. package/dist-es5/Interfaces/ITeeChannelConfig.js +1 -1
  33. package/dist-es5/TeeChannel.js +1 -1
  34. package/dist-es5/__DynamicConstants.js +1 -1
  35. package/dist-es5/applicationinsights-teechannel-js.js +1 -1
  36. package/package.json +66 -63
  37. package/types/applicationinsights-teechannel-js.d.ts +2 -2
  38. package/types/applicationinsights-teechannel-js.namespaced.d.ts +2370 -18
  39. package/browser/es5/applicationinsights-teechannel-js.3.0.7.cjs.js.map +0 -1
  40. package/browser/es5/applicationinsights-teechannel-js.3.0.7.cjs.min.js +0 -6
  41. package/browser/es5/applicationinsights-teechannel-js.3.0.7.cjs.min.js.map +0 -1
  42. package/browser/es5/applicationinsights-teechannel-js.3.0.7.gbl.js.map +0 -1
  43. package/browser/es5/applicationinsights-teechannel-js.3.0.7.gbl.min.js +0 -6
  44. package/browser/es5/applicationinsights-teechannel-js.3.0.7.gbl.min.js.map +0 -1
  45. package/browser/es5/applicationinsights-teechannel-js.3.0.7.integrity.json +0 -66
  46. package/browser/es5/applicationinsights-teechannel-js.3.0.7.js.map +0 -1
  47. package/browser/es5/applicationinsights-teechannel-js.3.0.7.min.js +0 -6
  48. package/browser/es5/applicationinsights-teechannel-js.3.0.7.min.js.map +0 -1
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Microsoft Application Insights JavaScript SDK Tee Channel, 3.0.7
2
+ * Microsoft Application Insights JavaScript SDK Tee Channel, 3.0.9
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  *
5
5
  * Microsoft Application Insights Team
@@ -7,22 +7,1884 @@
7
7
  */
8
8
 
9
9
  declare namespace ApplicationInsights {
10
- import { BaseTelemetryPlugin } from '@microsoft/applicationinsights-core-js';
11
- import { IAppInsightsCore } from '@microsoft/applicationinsights-core-js';
12
- import { IChannelControls } from '@microsoft/applicationinsights-core-js';
13
- import { IChannelControlsHost } from '@microsoft/applicationinsights-core-js';
14
- import { IConfig } from '@microsoft/applicationinsights-common';
15
- import { IConfiguration } from '@microsoft/applicationinsights-core-js';
16
- import { IPlugin } from '@microsoft/applicationinsights-core-js';
17
- import { IProcessTelemetryContext } from '@microsoft/applicationinsights-core-js';
18
- import { IProcessTelemetryUnloadContext } from '@microsoft/applicationinsights-core-js';
19
- import { IProcessTelemetryUpdateContext } from '@microsoft/applicationinsights-core-js';
20
- import { IPromise } from '@nevware21/ts-async';
21
- import { ITelemetryItem } from '@microsoft/applicationinsights-core-js';
22
- import { ITelemetryPluginChain } from '@microsoft/applicationinsights-core-js';
23
- import { ITelemetryUnloadState } from '@microsoft/applicationinsights-core-js';
24
- import { ITelemetryUpdateState } from '@microsoft/applicationinsights-core-js';
25
- import { SendRequestReason } from '@microsoft/applicationinsights-core-js';
10
+ /**
11
+ * BaseTelemetryPlugin provides a basic implementation of the ITelemetryPlugin interface so that plugins
12
+ * can avoid implementation the same set of boiler plate code as well as provide a base
13
+ * implementation so that new default implementations can be added without breaking all plugins.
14
+ */
15
+ abstract class BaseTelemetryPlugin implements ITelemetryPlugin {
16
+ identifier: string;
17
+ version?: string;
18
+ /**
19
+ * Holds the core instance that was used during initialization
20
+ */
21
+ core: IAppInsightsCore;
22
+ priority: number;
23
+ /**
24
+ * Call back for telemetry processing before it it is sent
25
+ * @param env - This is the current event being reported
26
+ * @param itemCtx - This is the context for the current request, ITelemetryPlugin instances
27
+ * can optionally use this to access the current core instance or define / pass additional information
28
+ * to later plugins (vs appending items to the telemetry item)
29
+ */
30
+ processNext: (env: ITelemetryItem, itemCtx: IProcessTelemetryContext) => void;
31
+ /**
32
+ * Set next extension for telemetry processing
33
+ */
34
+ setNextPlugin: (next: ITelemetryPlugin | ITelemetryPluginChain) => void;
35
+ /**
36
+ * Returns the current diagnostic logger that can be used to log issues, if no logger is currently
37
+ * assigned a new default one will be created and returned.
38
+ */
39
+ diagLog: (itemCtx?: IProcessTelemetryContext) => IDiagnosticLogger;
40
+ /**
41
+ * Returns whether the plugin has been initialized
42
+ */
43
+ isInitialized: () => boolean;
44
+ /**
45
+ * Helper to return the current IProcessTelemetryContext, if the passed argument exists this just
46
+ * returns that value (helps with minification for callers), otherwise it will return the configured
47
+ * context or a temporary one.
48
+ * @param currentCtx - [Optional] The current execution context
49
+ */
50
+ protected _getTelCtx: (currentCtx?: IProcessTelemetryContext) => IProcessTelemetryContext;
51
+ /**
52
+ * Internal helper to allow setting of the internal initialized setting for inherited instances and unit testing
53
+ */
54
+ protected setInitialized: (isInitialized: boolean) => void;
55
+ /**
56
+ * Teardown / Unload hook to allow implementations to perform some additional unload operations before the BaseTelemetryPlugin
57
+ * finishes it's removal.
58
+ * @param unloadCtx - This is the context that should be used during unloading.
59
+ * @param unloadState - The details / state of the unload process, it holds details like whether it should be unloaded synchronously or asynchronously and the reason for the unload.
60
+ * @param asyncCallback - An optional callback that the plugin must call if it returns true to inform the caller that it has completed any async unload/teardown operations.
61
+ * @returns boolean - true if the plugin has or will call asyncCallback, this allows the plugin to perform any asynchronous operations.
62
+ */
63
+ protected _doTeardown?: (unloadCtx?: IProcessTelemetryUnloadContext, unloadState?: ITelemetryUnloadState, asyncCallback?: () => void) => void | boolean;
64
+ /**
65
+ * Extension hook to allow implementations to perform some additional update operations before the BaseTelemetryPlugin finishes it's removal
66
+ * @param updateCtx - This is the context that should be used during updating.
67
+ * @param updateState - The details / state of the update process, it holds details like the current and previous configuration.
68
+ * @param asyncCallback - An optional callback that the plugin must call if it returns true to inform the caller that it has completed any async update operations.
69
+ * @returns boolean - true if the plugin has or will call asyncCallback, this allows the plugin to perform any asynchronous operations.
70
+ */
71
+ protected _doUpdate?: (updateCtx?: IProcessTelemetryUpdateContext, updateState?: ITelemetryUpdateState, asyncCallback?: () => void) => void | boolean;
72
+ /**
73
+ * Exposes the underlying unload hook container instance for this extension to allow it to be passed down to any sub components of the class.
74
+ * This should NEVER be exposed or called publically as it's scope is for internal use by BaseTelemetryPlugin and any derived class (which is why
75
+ * it's scoped as protected)
76
+ */
77
+ protected readonly _unloadHooks: IUnloadHookContainer;
78
+ constructor();
79
+ initialize(config: IConfiguration, core: IAppInsightsCore, extensions: IPlugin[], pluginChain?: ITelemetryPluginChain): void;
80
+ /**
81
+ * Tear down the plugin and remove any hooked value, the plugin should be removed so that it is no longer initialized and
82
+ * therefore could be re-initialized after being torn down. The plugin should ensure that once this has been called any further
83
+ * processTelemetry calls are ignored and it just calls the processNext() with the provided context.
84
+ * @param unloadCtx - This is the context that should be used during unloading.
85
+ * @param unloadState - The details / state of the unload process, it holds details like whether it should be unloaded synchronously or asynchronously and the reason for the unload.
86
+ * @returns boolean - true if the plugin has or will call processNext(), this for backward compatibility as previously teardown was synchronous and returned nothing.
87
+ */
88
+ teardown(unloadCtx?: IProcessTelemetryUnloadContext, unloadState?: ITelemetryUnloadState): void | boolean;
89
+ abstract processTelemetry(env: ITelemetryItem, itemCtx?: IProcessTelemetryContext): void;
90
+ /**
91
+ * The the plugin should re-evaluate configuration and update any cached configuration settings.
92
+ * @param updateCtx - This is the context that should be used during updating.
93
+ * @param updateState - The details / state of the update process, it holds details like the current and previous configuration.
94
+ * @returns boolean - true if the plugin has or will call updateCtx.processNext(), this allows the plugin to perform any asynchronous operations.
95
+ */
96
+ update(updateCtx: IProcessTelemetryUpdateContext, updateState: ITelemetryUpdateState): void | boolean;
97
+ /**
98
+ * Add an unload handler that will be called when the SDK is being unloaded
99
+ * @param handler - the handler
100
+ */
101
+ protected _addUnloadCb(handler: UnloadHandler): void;
102
+ /**
103
+ * Add this hook so that it is automatically removed during unloading
104
+ * @param hooks - The single hook or an array of IInstrumentHook objects
105
+ */
106
+ protected _addHook(hooks: IUnloadHook | IUnloadHook[] | Iterator<IUnloadHook> | ILegacyUnloadHook | ILegacyUnloadHook[] | Iterator<ILegacyUnloadHook>): void;
107
+ }
108
+
109
+ const DistributedTracingModes: EnumValue<typeof eDistributedTracingModes>;
110
+
111
+ type DistributedTracingModes = number | eDistributedTracingModes;
112
+
113
+ const enum eDistributedTracingModes {
114
+ /**
115
+ * (Default) Send Application Insights correlation headers
116
+ */
117
+ AI = 0,
118
+ /**
119
+ * Send both W3C Trace Context headers and back-compatibility Application Insights headers
120
+ */
121
+ AI_AND_W3C = 1,
122
+ /**
123
+ * Send W3C Trace Context headers
124
+ */
125
+ W3C = 2
126
+ }
127
+
128
+ const enum _eInternalMessageId {
129
+ BrowserDoesNotSupportLocalStorage = 0,
130
+ BrowserCannotReadLocalStorage = 1,
131
+ BrowserCannotReadSessionStorage = 2,
132
+ BrowserCannotWriteLocalStorage = 3,
133
+ BrowserCannotWriteSessionStorage = 4,
134
+ BrowserFailedRemovalFromLocalStorage = 5,
135
+ BrowserFailedRemovalFromSessionStorage = 6,
136
+ CannotSendEmptyTelemetry = 7,
137
+ ClientPerformanceMathError = 8,
138
+ ErrorParsingAISessionCookie = 9,
139
+ ErrorPVCalc = 10,
140
+ ExceptionWhileLoggingError = 11,
141
+ FailedAddingTelemetryToBuffer = 12,
142
+ FailedMonitorAjaxAbort = 13,
143
+ FailedMonitorAjaxDur = 14,
144
+ FailedMonitorAjaxOpen = 15,
145
+ FailedMonitorAjaxRSC = 16,
146
+ FailedMonitorAjaxSend = 17,
147
+ FailedMonitorAjaxGetCorrelationHeader = 18,
148
+ FailedToAddHandlerForOnBeforeUnload = 19,
149
+ FailedToSendQueuedTelemetry = 20,
150
+ FailedToReportDataLoss = 21,
151
+ FlushFailed = 22,
152
+ MessageLimitPerPVExceeded = 23,
153
+ MissingRequiredFieldSpecification = 24,
154
+ NavigationTimingNotSupported = 25,
155
+ OnError = 26,
156
+ SessionRenewalDateIsZero = 27,
157
+ SenderNotInitialized = 28,
158
+ StartTrackEventFailed = 29,
159
+ StopTrackEventFailed = 30,
160
+ StartTrackFailed = 31,
161
+ StopTrackFailed = 32,
162
+ TelemetrySampledAndNotSent = 33,
163
+ TrackEventFailed = 34,
164
+ TrackExceptionFailed = 35,
165
+ TrackMetricFailed = 36,
166
+ TrackPVFailed = 37,
167
+ TrackPVFailedCalc = 38,
168
+ TrackTraceFailed = 39,
169
+ TransmissionFailed = 40,
170
+ FailedToSetStorageBuffer = 41,
171
+ FailedToRestoreStorageBuffer = 42,
172
+ InvalidBackendResponse = 43,
173
+ FailedToFixDepricatedValues = 44,
174
+ InvalidDurationValue = 45,
175
+ TelemetryEnvelopeInvalid = 46,
176
+ CreateEnvelopeError = 47,
177
+ MaxUnloadHookExceeded = 48,
178
+ CannotSerializeObject = 48,
179
+ CannotSerializeObjectNonSerializable = 49,
180
+ CircularReferenceDetected = 50,
181
+ ClearAuthContextFailed = 51,
182
+ ExceptionTruncated = 52,
183
+ IllegalCharsInName = 53,
184
+ ItemNotInArray = 54,
185
+ MaxAjaxPerPVExceeded = 55,
186
+ MessageTruncated = 56,
187
+ NameTooLong = 57,
188
+ SampleRateOutOfRange = 58,
189
+ SetAuthContextFailed = 59,
190
+ SetAuthContextFailedAccountName = 60,
191
+ StringValueTooLong = 61,
192
+ StartCalledMoreThanOnce = 62,
193
+ StopCalledWithoutStart = 63,
194
+ TelemetryInitializerFailed = 64,
195
+ TrackArgumentsNotSpecified = 65,
196
+ UrlTooLong = 66,
197
+ SessionStorageBufferFull = 67,
198
+ CannotAccessCookie = 68,
199
+ IdTooLong = 69,
200
+ InvalidEvent = 70,
201
+ FailedMonitorAjaxSetRequestHeader = 71,
202
+ SendBrowserInfoOnUserInit = 72,
203
+ PluginException = 73,
204
+ NotificationException = 74,
205
+ SnippetScriptLoadFailure = 99,
206
+ InvalidInstrumentationKey = 100,
207
+ CannotParseAiBlobValue = 101,
208
+ InvalidContentBlob = 102,
209
+ TrackPageActionEventFailed = 103,
210
+ FailedAddingCustomDefinedRequestContext = 104,
211
+ InMemoryStorageBufferFull = 105,
212
+ InstrumentationKeyDeprecation = 106,
213
+ ConfigWatcherException = 107,
214
+ DynamicConfigException = 108,
215
+ DefaultThrottleMsgKey = 109,
216
+ CdnDeprecation = 110,
217
+ SdkLdrUpdate = 111
218
+ }
219
+
220
+ const enum eLoggingSeverity {
221
+ /**
222
+ * No Logging will be enabled
223
+ */
224
+ DISABLED = 0,
225
+ /**
226
+ * Error will be sent as internal telemetry
227
+ */
228
+ CRITICAL = 1,
229
+ /**
230
+ * Error will NOT be sent as internal telemetry, and will only be shown in browser console
231
+ */
232
+ WARNING = 2,
233
+ /**
234
+ * The Error will NOT be sent as an internal telemetry, and will only be shown in the browser
235
+ * console if the logging level allows it.
236
+ */
237
+ DEBUG = 3
238
+ }
239
+
240
+ /**
241
+ * A type that identifies an enum class generated from a constant enum.
242
+ * @group Enum
243
+ * @typeParam E - The constant enum type
244
+ *
245
+ * Returned from {@link createEnum}
246
+ */
247
+ type EnumCls<E = any> = {
248
+ readonly [key in keyof E extends string | number | symbol ? keyof E : never]: key extends string ? E[key] : key;
249
+ } & {
250
+ readonly [key in keyof E]: E[key];
251
+ };
252
+
253
+ type EnumValue<E = any> = EnumCls<E>;
254
+
255
+ const enum FeatureOptInMode {
256
+ /**
257
+ * not set, completely depends on cdn cfg
258
+ */
259
+ none = 1,
260
+ /**
261
+ * try to not apply config from cdn
262
+ */
263
+ disable = 2,
264
+ /**
265
+ * try to apply config from cdn
266
+ */
267
+ enable = 3
268
+ }
269
+
270
+ /**
271
+ * This defines the handler function that is called via the finally when the promise is resolved or rejected
272
+ */
273
+ type FinallyPromiseHandler = (() => void) | undefined | null;
274
+
275
+ interface IAppInsightsCore<CfgType extends IConfiguration = IConfiguration> extends IPerfManagerProvider {
276
+ readonly config: CfgType;
277
+ /**
278
+ * The current logger instance for this instance.
279
+ */
280
+ readonly logger: IDiagnosticLogger;
281
+ /**
282
+ * An array of the installed plugins that provide a version
283
+ */
284
+ readonly pluginVersionStringArr: string[];
285
+ /**
286
+ * The formatted string of the installed plugins that contain a version number
287
+ */
288
+ readonly pluginVersionString: string;
289
+ /**
290
+ * Returns a value that indicates whether the instance has already been previously initialized.
291
+ */
292
+ isInitialized?: () => boolean;
293
+ initialize(config: CfgType, extensions: IPlugin[], logger?: IDiagnosticLogger, notificationManager?: INotificationManager): void;
294
+ getChannels(): IChannelControls[];
295
+ track(telemetryItem: ITelemetryItem): void;
296
+ /**
297
+ * Get the current notification manager
298
+ */
299
+ getNotifyMgr(): INotificationManager;
300
+ /**
301
+ * Get the current cookie manager for this instance
302
+ */
303
+ getCookieMgr(): ICookieMgr;
304
+ /**
305
+ * Set the current cookie manager for this instance
306
+ * @param cookieMgr - The manager, if set to null/undefined will cause the default to be created
307
+ */
308
+ setCookieMgr(cookieMgr: ICookieMgr): void;
309
+ /**
310
+ * Adds a notification listener. The SDK calls methods on the listener when an appropriate notification is raised.
311
+ * The added plugins must raise notifications. If the plugins do not implement the notifications, then no methods will be
312
+ * called.
313
+ * @param listener - An INotificationListener object.
314
+ */
315
+ addNotificationListener?(listener: INotificationListener): void;
316
+ /**
317
+ * Removes all instances of the listener.
318
+ * @param listener - INotificationListener to remove.
319
+ */
320
+ removeNotificationListener?(listener: INotificationListener): void;
321
+ /**
322
+ * Add a telemetry processor to decorate or drop telemetry events.
323
+ * @param telemetryInitializer - The Telemetry Initializer function
324
+ * @returns - A ITelemetryInitializerHandler to enable the initializer to be removed
325
+ */
326
+ addTelemetryInitializer(telemetryInitializer: TelemetryInitializerFunction): ITelemetryInitializerHandler;
327
+ pollInternalLogs?(eventName?: string): ITimerHandler;
328
+ stopPollingInternalLogs?(): void;
329
+ /**
330
+ * Return a new instance of the IProcessTelemetryContext for processing events
331
+ */
332
+ getProcessTelContext(): IProcessTelemetryContext;
333
+ /**
334
+ * Unload and Tear down the SDK and any initialized plugins, after calling this the SDK will be considered
335
+ * to be un-initialized and non-operational, re-initializing the SDK should only be attempted if the previous
336
+ * unload call return `true` stating that all plugins reported that they also unloaded, the recommended
337
+ * approach is to create a new instance and initialize that instance.
338
+ * This is due to possible unexpected side effects caused by plugins not supporting unload / teardown, unable
339
+ * to successfully remove any global references or they may just be completing the unload process asynchronously.
340
+ * If you pass isAsync as `true` (also the default) and DO NOT pass a callback function then an [IPromise](https://nevware21.github.io/ts-async/typedoc/interfaces/IPromise.html)
341
+ * will be returned which will resolve once the unload is complete. The actual implementation of the `IPromise`
342
+ * will be a native Promise (if supported) or the default as supplied by [ts-async library](https://github.com/nevware21/ts-async)
343
+ * @param isAsync - Can the unload be performed asynchronously (default)
344
+ * @param unloadComplete - An optional callback that will be called once the unload has completed
345
+ * @param cbTimeout - An optional timeout to wait for any flush operations to complete before proceeding with the
346
+ * unload. Defaults to 5 seconds.
347
+ * @return Nothing or if occurring asynchronously a [IPromise](https://nevware21.github.io/ts-async/typedoc/interfaces/IPromise.html)
348
+ * which will be resolved once the unload is complete, the [IPromise](https://nevware21.github.io/ts-async/typedoc/interfaces/IPromise.html)
349
+ * will only be returned when no callback is provided and isAsync is true
350
+ */
351
+ unload(isAsync?: boolean, unloadComplete?: (unloadState: ITelemetryUnloadState) => void, cbTimeout?: number): void | IPromise<ITelemetryUnloadState>;
352
+ /**
353
+ * Find and return the (first) plugin with the specified identifier if present
354
+ * @param pluginIdentifier
355
+ */
356
+ getPlugin<T extends IPlugin = IPlugin>(pluginIdentifier: string): ILoadedPlugin<T>;
357
+ /**
358
+ * Add a new plugin to the installation
359
+ * @param plugin - The new plugin to add
360
+ * @param replaceExisting - should any existing plugin be replaced, default is false
361
+ * @param doAsync - Should the add be performed asynchronously
362
+ * @param addCb - [Optional] callback to call after the plugin has been added
363
+ */
364
+ addPlugin<T extends IPlugin = ITelemetryPlugin>(plugin: T, replaceExisting?: boolean, doAsync?: boolean, addCb?: (added?: boolean) => void): void;
365
+ /**
366
+ * Update the configuration used and broadcast the changes to all loaded plugins, this does NOT support updating, adding or removing
367
+ * any the plugins (extensions or channels). It will notify each plugin (if supported) that the configuration has changed but it will
368
+ * not remove or add any new plugins, you need to call addPlugin or getPlugin(identifier).remove();
369
+ * @param newConfig - The new configuration is apply
370
+ * @param mergeExisting - Should the new configuration merge with the existing or just replace it. Default is to merge.
371
+ */
372
+ updateCfg(newConfig: CfgType, mergeExisting?: boolean): void;
373
+ /**
374
+ * Returns the unique event namespace that should be used when registering events
375
+ */
376
+ evtNamespace(): string;
377
+ /**
378
+ * Add a handler that will be called when the SDK is being unloaded
379
+ * @param handler - the handler
380
+ */
381
+ addUnloadCb(handler: UnloadHandler): void;
382
+ /**
383
+ * Add this hook so that it is automatically removed during unloading
384
+ * @param hooks - The single hook or an array of IInstrumentHook objects
385
+ */
386
+ addUnloadHook(hooks: IUnloadHook | IUnloadHook[] | Iterator<IUnloadHook> | ILegacyUnloadHook | ILegacyUnloadHook[] | Iterator<ILegacyUnloadHook>): void;
387
+ /**
388
+ * Flush and send any batched / cached data immediately
389
+ * @param async - send data asynchronously when true (defaults to true)
390
+ * @param callBack - if specified, notify caller when send is complete, the channel should return true to indicate to the caller that it will be called.
391
+ * If the caller doesn't return true the caller should assume that it may never be called.
392
+ * @param sendReason - specify the reason that you are calling "flush" defaults to ManualFlush (1) if not specified
393
+ * @param cbTimeout - An optional timeout to wait for any flush operations to complete before proceeding with the unload. Defaults to 5 seconds.
394
+ * @returns - true if the callback will be return after the flush is complete otherwise the caller should assume that any provided callback will never be called
395
+ */
396
+ flush(isAsync?: boolean, callBack?: (flushComplete?: boolean) => void, sendReason?: SendRequestReason, cbTimeout?: number): boolean | void;
397
+ /**
398
+ * Gets the current distributed trace context for this instance if available
399
+ * @param createNew - Optional flag to create a new instance if one doesn't currently exist, defaults to true
400
+ */
401
+ getTraceCtx(createNew?: boolean): IDistributedTraceContext | null;
402
+ /**
403
+ * Sets the current distributed trace context for this instance if available
404
+ */
405
+ setTraceCtx(newTraceCtx: IDistributedTraceContext | null | undefined): void;
406
+ /**
407
+ * Watches and tracks changes for accesses to the current config, and if the accessed config changes the
408
+ * handler will be recalled.
409
+ * @param handler
410
+ * @returns A watcher handler instance that can be used to remove itself when being unloaded
411
+ */
412
+ onCfgChange(handler: WatcherFunction<CfgType>): IUnloadHook;
413
+ /**
414
+ * Function used to identify the get w parameter used to identify status bit to some channels
415
+ */
416
+ getWParam: () => number;
417
+ }
418
+
419
+ interface IBaseProcessingContext {
420
+ /**
421
+ * The current core instance for the request
422
+ */
423
+ core: () => IAppInsightsCore;
424
+ /**
425
+ * THe current diagnostic logger for the request
426
+ */
427
+ diagLog: () => IDiagnosticLogger;
428
+ /**
429
+ * Gets the current core config instance
430
+ */
431
+ getCfg: () => IConfiguration;
432
+ /**
433
+ * Gets the named extension config
434
+ */
435
+ getExtCfg: <T>(identifier: string, defaultValue?: IConfigDefaults<T>) => T;
436
+ /**
437
+ * Gets the named config from either the named identifier extension or core config if neither exist then the
438
+ * default value is returned
439
+ * @param identifier - The named extension identifier
440
+ * @param field - The config field name
441
+ * @param defaultValue - The default value to return if no defined config exists
442
+ */
443
+ getConfig: (identifier: string, field: string, defaultValue?: number | string | boolean | string[] | RegExp[] | Function) => number | string | boolean | string[] | RegExp[] | Function;
444
+ /**
445
+ * Helper to allow plugins to check and possibly shortcut executing code only
446
+ * required if there is a nextPlugin
447
+ */
448
+ hasNext: () => boolean;
449
+ /**
450
+ * Returns the next configured plugin proxy
451
+ */
452
+ getNext: () => ITelemetryPluginChain;
453
+ /**
454
+ * Helper to set the next plugin proxy
455
+ */
456
+ setNext: (nextCtx: ITelemetryPluginChain) => void;
457
+ /**
458
+ * Synchronously iterate over the context chain running the callback for each plugin, once
459
+ * every plugin has been executed via the callback, any associated onComplete will be called.
460
+ * @param callback - The function call for each plugin in the context chain
461
+ */
462
+ iterate: <T extends ITelemetryPlugin = ITelemetryPlugin>(callback: (plugin: T) => void) => void;
463
+ /**
464
+ * Set the function to call when the current chain has executed all processNext or unloadNext items.
465
+ * @param onComplete - The onComplete to call
466
+ * @param that - The "this" value to use for the onComplete call, if not provided or undefined defaults to the current context
467
+ * @param args - Any additional arguments to pass to the onComplete function
468
+ */
469
+ onComplete: (onComplete: () => void, that?: any, ...args: any[]) => void;
470
+ /**
471
+ * Create a new context using the core and config from the current instance, returns a new instance of the same type
472
+ * @param plugins - The execution order to process the plugins, if null or not supplied
473
+ * then the current execution order will be copied.
474
+ * @param startAt - The plugin to start processing from, if missing from the execution
475
+ * order then the next plugin will be NOT set.
476
+ */
477
+ createNew: (plugins?: IPlugin[] | ITelemetryPluginChain, startAt?: IPlugin) => IBaseProcessingContext;
478
+ }
479
+
480
+ /**
481
+ * Provides data transmission capabilities
482
+ */
483
+ interface IChannelControls extends ITelemetryPlugin {
484
+ /**
485
+ * Pause sending data
486
+ */
487
+ pause?(): void;
488
+ /**
489
+ * Resume sending data
490
+ */
491
+ resume?(): void;
492
+ /**
493
+ * Tear down the plugin and remove any hooked value, the plugin should be removed so that it is no longer initialized and
494
+ * therefore could be re-initialized after being torn down. The plugin should ensure that once this has been called any further
495
+ * processTelemetry calls are ignored and it just calls the processNext() with the provided context.
496
+ * @param unloadCtx - This is the context that should be used during unloading.
497
+ * @param unloadState - The details / state of the unload process, it holds details like whether it should be unloaded synchronously or asynchronously and the reason for the unload.
498
+ * @returns boolean - true if the plugin has or will call processNext(), this for backward compatibility as previously teardown was synchronous and returned nothing.
499
+ */
500
+ teardown?: (unloadCtx?: IProcessTelemetryUnloadContext, unloadState?: ITelemetryUnloadState) => void | boolean;
501
+ /**
502
+ * Flush to send data immediately; channel should default to sending data asynchronously. If executing asynchronously and
503
+ * you DO NOT pass a callback function then a [IPromise](https://nevware21.github.io/ts-async/typedoc/interfaces/IPromise.html)
504
+ * will be returned which will resolve once the flush is complete. The actual implementation of the `IPromise`
505
+ * will be a native Promise (if supported) or the default as supplied by [ts-async library](https://github.com/nevware21/ts-async)
506
+ * @param async - send data asynchronously when true
507
+ * @param callBack - if specified, notify caller when send is complete, the channel should return true to indicate to the caller that it will be called.
508
+ * If the caller doesn't return true the caller should assume that it may never be called.
509
+ * @param sendReason - specify the reason that you are calling "flush" defaults to ManualFlush (1) if not specified
510
+ * @returns - If a callback is provided `true` to indicate that callback will be called after the flush is complete otherwise the caller
511
+ * should assume that any provided callback will never be called, Nothing or if occurring asynchronously a
512
+ * [IPromise](https://nevware21.github.io/ts-async/typedoc/interfaces/IPromise.html) which will be resolved once the unload is complete,
513
+ * the [IPromise](https://nevware21.github.io/ts-async/typedoc/interfaces/IPromise.html) will only be returned when no callback is provided
514
+ * and async is true.
515
+ */
516
+ flush?(async: boolean, callBack?: (flushComplete?: boolean) => void, sendReason?: SendRequestReason): boolean | void | IPromise<boolean>;
517
+ }
518
+
519
+ interface IChannelControlsHost extends IChannelControls {
520
+ /**
521
+ * Get and return the named channel instance (if present) from the queues
522
+ * @param pluginIdentifier - The identifier name of the plugin
523
+ */
524
+ getChannel<T extends IPlugin = IPlugin>(pluginIdentifier: string): T;
525
+ }
526
+
527
+ /**
528
+ * Configuration settings for how telemetry is sent
529
+ * @export
530
+ * @interface IConfig
531
+ */
532
+ interface IConfig {
533
+ /**
534
+ * The JSON format (normal vs line delimited). True means line delimited JSON.
535
+ */
536
+ emitLineDelimitedJson?: boolean;
537
+ /**
538
+ * An optional account id, if your app groups users into accounts. No spaces, commas, semicolons, equals, or vertical bars.
539
+ */
540
+ accountId?: string;
541
+ /**
542
+ * A session is logged if the user is inactive for this amount of time in milliseconds. Default 30 mins.
543
+ * @default 30*60*1000
544
+ */
545
+ sessionRenewalMs?: number;
546
+ /**
547
+ * A session is logged if it has continued for this amount of time in milliseconds. Default 24h.
548
+ * @default 24*60*60*1000
549
+ */
550
+ sessionExpirationMs?: number;
551
+ /**
552
+ * Max size of telemetry batch. If batch exceeds limit, it is sent and a new batch is started
553
+ * @default 100000
554
+ */
555
+ maxBatchSizeInBytes?: number;
556
+ /**
557
+ * How long to batch telemetry for before sending (milliseconds)
558
+ * @default 15 seconds
559
+ */
560
+ maxBatchInterval?: number;
561
+ /**
562
+ * If true, debugging data is thrown as an exception by the logger. Default false
563
+ * @defaultValue false
564
+ */
565
+ enableDebug?: boolean;
566
+ /**
567
+ * If true, exceptions are not autocollected. Default is false
568
+ * @defaultValue false
569
+ */
570
+ disableExceptionTracking?: boolean;
571
+ /**
572
+ * If true, telemetry is not collected or sent. Default is false
573
+ * @defaultValue false
574
+ */
575
+ disableTelemetry?: boolean;
576
+ /**
577
+ * Percentage of events that will be sent. Default is 100, meaning all events are sent.
578
+ * @defaultValue 100
579
+ */
580
+ samplingPercentage?: number;
581
+ /**
582
+ * If true, on a pageview, the previous instrumented page's view time is tracked and sent as telemetry and a new timer is started for the current pageview. It is sent as a custom metric named PageVisitTime in milliseconds and is calculated via the Date now() function (if available) and falls back to (new Date()).getTime() if now() is unavailable (IE8 or less). Default is false.
583
+ */
584
+ autoTrackPageVisitTime?: boolean;
585
+ /**
586
+ * Automatically track route changes in Single Page Applications (SPA). If true, each route change will send a new Pageview to Application Insights.
587
+ */
588
+ enableAutoRouteTracking?: boolean;
589
+ /**
590
+ * If true, Ajax calls are not autocollected. Default is false
591
+ * @defaultValue false
592
+ */
593
+ disableAjaxTracking?: boolean;
594
+ /**
595
+ * If true, Fetch requests are not autocollected. Default is false (Since 2.8.0, previously true).
596
+ * @defaultValue false
597
+ */
598
+ disableFetchTracking?: boolean;
599
+ /**
600
+ * Provide a way to exclude specific route from automatic tracking for XMLHttpRequest or Fetch request. For an ajax / fetch request that the request url matches with the regex patterns, auto tracking is turned off.
601
+ * @defaultValue undefined.
602
+ */
603
+ excludeRequestFromAutoTrackingPatterns?: string[] | RegExp[];
604
+ /**
605
+ * Provide a way to enrich dependencies logs with context at the beginning of api call.
606
+ * Default is undefined.
607
+ */
608
+ addRequestContext?: (requestContext?: IRequestContext) => ICustomProperties;
609
+ /**
610
+ * If true, default behavior of trackPageView is changed to record end of page view duration interval when trackPageView is called. If false and no custom duration is provided to trackPageView, the page view performance is calculated using the navigation timing API. Default is false
611
+ * @defaultValue false
612
+ */
613
+ overridePageViewDuration?: boolean;
614
+ /**
615
+ * Default 500 - controls how many ajax calls will be monitored per page view. Set to -1 to monitor all (unlimited) ajax calls on the page.
616
+ */
617
+ maxAjaxCallsPerView?: number;
618
+ /**
619
+ * @ignore
620
+ * If false, internal telemetry sender buffers will be checked at startup for items not yet sent. Default is true
621
+ * @defaultValue true
622
+ */
623
+ disableDataLossAnalysis?: boolean;
624
+ /**
625
+ * If false, the SDK will add two headers ('Request-Id' and 'Request-Context') to all dependency requests to correlate them with corresponding requests on the server side. Default is false.
626
+ * @defaultValue false
627
+ */
628
+ disableCorrelationHeaders?: boolean;
629
+ /**
630
+ * Sets the distributed tracing mode. If AI_AND_W3C mode or W3C mode is set, W3C trace context headers (traceparent/tracestate) will be generated and included in all outgoing requests.
631
+ * AI_AND_W3C is provided for back-compatibility with any legacy Application Insights instrumented services
632
+ * @defaultValue AI_AND_W3C
633
+ */
634
+ distributedTracingMode?: DistributedTracingModes;
635
+ /**
636
+ * Disable correlation headers for specific domain
637
+ */
638
+ correlationHeaderExcludedDomains?: string[];
639
+ /**
640
+ * Default false. If true, flush method will not be called when onBeforeUnload, onUnload, onPageHide or onVisibilityChange (hidden state) event(s) trigger.
641
+ */
642
+ disableFlushOnBeforeUnload?: boolean;
643
+ /**
644
+ * Default value of {@link #disableFlushOnBeforeUnload}. If true, flush method will not be called when onPageHide or onVisibilityChange (hidden state) event(s) trigger.
645
+ */
646
+ disableFlushOnUnload?: boolean;
647
+ /**
648
+ * If true, the buffer with all unsent telemetry is stored in session storage. The buffer is restored on page load. Default is true.
649
+ * @defaultValue true
650
+ */
651
+ enableSessionStorageBuffer?: boolean;
652
+ /**
653
+ * If specified, overrides the storage & retrieval mechanism that is used to manage unsent telemetry.
654
+ */
655
+ bufferOverride?: IStorageBuffer;
656
+ /**
657
+ * @deprecated Use either disableCookiesUsage or specify a cookieCfg with the enabled value set.
658
+ * If true, the SDK will not store or read any data from cookies. Default is false. As this field is being deprecated, when both
659
+ * isCookieUseDisabled and disableCookiesUsage are used disableCookiesUsage will take precedent.
660
+ * @defaultValue false
661
+ */
662
+ isCookieUseDisabled?: boolean;
663
+ /**
664
+ * If true, the SDK will not store or read any data from cookies. Default is false.
665
+ * If you have also specified a cookieCfg then enabled property (if specified) will take precedent over this value.
666
+ * @defaultValue false
667
+ */
668
+ disableCookiesUsage?: boolean;
669
+ /**
670
+ * Custom cookie domain. This is helpful if you want to share Application Insights cookies across subdomains.
671
+ * @defaultValue ""
672
+ */
673
+ cookieDomain?: string;
674
+ /**
675
+ * Custom cookie path. This is helpful if you want to share Application Insights cookies behind an application gateway.
676
+ * @defaultValue ""
677
+ */
678
+ cookiePath?: string;
679
+ /**
680
+ * 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)
681
+ * @description
682
+ * @defaultValue false
683
+ */
684
+ isRetryDisabled?: boolean;
685
+ /**
686
+ * @deprecated Used when initizialing from snippet only.
687
+ * The url from where the JS SDK will be downloaded.
688
+ */
689
+ url?: string;
690
+ /**
691
+ * If true, the SDK will not store or read any data from local and session storage. Default is false.
692
+ * @defaultValue false
693
+ */
694
+ isStorageUseDisabled?: boolean;
695
+ /**
696
+ * If false, the SDK will send all telemetry using the [Beacon API](https://www.w3.org/TR/beacon)
697
+ * @defaultValue true
698
+ */
699
+ isBeaconApiDisabled?: boolean;
700
+ /**
701
+ * Don't use XMLHttpRequest or XDomainRequest (for IE < 9) by default instead attempt to use fetch() or sendBeacon.
702
+ * If no other transport is available it will still use XMLHttpRequest
703
+ */
704
+ disableXhr?: boolean;
705
+ /**
706
+ * If fetch keepalive is supported do not use it for sending events during unload, it may still fallback to fetch() without keepalive
707
+ */
708
+ onunloadDisableFetch?: boolean;
709
+ /**
710
+ * Sets the sdk extension name. Only alphabetic characters are allowed. The extension name is added as a prefix to the 'ai.internal.sdkVersion' tag (e.g. 'ext_javascript:2.0.0'). Default is null.
711
+ * @defaultValue null
712
+ */
713
+ sdkExtension?: string;
714
+ /**
715
+ * Default is false. If true, the SDK will track all [Browser Link](https://docs.microsoft.com/en-us/aspnet/core/client-side/using-browserlink) requests.
716
+ * @defaultValue false
717
+ */
718
+ isBrowserLinkTrackingEnabled?: boolean;
719
+ /**
720
+ * AppId is used for the correlation between AJAX dependencies happening on the client-side with the server-side requets. When Beacon API is enabled, it cannot be used automatically, but can be set manually in the configuration. Default is null
721
+ * @defaultValue null
722
+ */
723
+ appId?: string;
724
+ /**
725
+ * If true, the SDK will add two headers ('Request-Id' and 'Request-Context') to all CORS requests to correlate outgoing AJAX dependencies with corresponding requests on the server side. Default is false
726
+ * @defaultValue false
727
+ */
728
+ enableCorsCorrelation?: boolean;
729
+ /**
730
+ * An optional value that will be used as name postfix for localStorage and session cookie name.
731
+ * @defaultValue null
732
+ */
733
+ namePrefix?: string;
734
+ /**
735
+ * An optional value that will be used as name postfix for session cookie name. If undefined, namePrefix is used as name postfix for session cookie name.
736
+ * @defaultValue null
737
+ */
738
+ sessionCookiePostfix?: string;
739
+ /**
740
+ * An optional value that will be used as name postfix for user cookie name. If undefined, no postfix is added on user cookie name.
741
+ * @defaultValue null
742
+ */
743
+ userCookiePostfix?: string;
744
+ /**
745
+ * An optional value that will track Request Header through trackDependency function.
746
+ * @defaultValue false
747
+ */
748
+ enableRequestHeaderTracking?: boolean;
749
+ /**
750
+ * An optional value that will track Response Header through trackDependency function.
751
+ * @defaultValue false
752
+ */
753
+ enableResponseHeaderTracking?: boolean;
754
+ /**
755
+ * An optional value that will track Response Error data through trackDependency function.
756
+ * @defaultValue false
757
+ */
758
+ enableAjaxErrorStatusText?: boolean;
759
+ /**
760
+ * Flag to enable looking up and including additional browser window.performance timings
761
+ * in the reported ajax (XHR and fetch) reported metrics.
762
+ * Defaults to false.
763
+ */
764
+ enableAjaxPerfTracking?: boolean;
765
+ /**
766
+ * The maximum number of times to look for the window.performance timings (if available), this
767
+ * is required as not all browsers populate the window.performance before reporting the
768
+ * end of the XHR request and for fetch requests this is added after its complete
769
+ * Defaults to 3
770
+ */
771
+ maxAjaxPerfLookupAttempts?: number;
772
+ /**
773
+ * The amount of time to wait before re-attempting to find the windows.performance timings
774
+ * for an ajax request, time is in milliseconds and is passed directly to setTimeout()
775
+ * Defaults to 25.
776
+ */
777
+ ajaxPerfLookupDelay?: number;
778
+ /**
779
+ * Default false. when tab is closed, the SDK will send all remaining telemetry using the [Beacon API](https://www.w3.org/TR/beacon)
780
+ * @defaultValue false
781
+ */
782
+ onunloadDisableBeacon?: boolean;
783
+ /**
784
+ * @ignore
785
+ * Internal only
786
+ */
787
+ autoExceptionInstrumented?: boolean;
788
+ /**
789
+ *
790
+ */
791
+ correlationHeaderDomains?: string[];
792
+ /**
793
+ * @ignore
794
+ * Internal only
795
+ */
796
+ autoUnhandledPromiseInstrumented?: boolean;
797
+ /**
798
+ * Default false. Define whether to track unhandled promise rejections and report as JS errors.
799
+ * When disableExceptionTracking is enabled (dont track exceptions) this value will be false.
800
+ * @defaultValue false
801
+ */
802
+ enableUnhandledPromiseRejectionTracking?: boolean;
803
+ /**
804
+ * Disable correlation headers using regular expressions
805
+ */
806
+ correlationHeaderExcludePatterns?: RegExp[];
807
+ /**
808
+ * The ability for the user to provide extra headers
809
+ */
810
+ customHeaders?: [{
811
+ header: string;
812
+ value: string;
813
+ }];
814
+ /**
815
+ * Provide user an option to convert undefined field to user defined value.
816
+ */
817
+ convertUndefined?: any;
818
+ /**
819
+ * [Optional] The number of events that can be kept in memory before the SDK starts to drop events. By default, this is 10,000.
820
+ */
821
+ eventsLimitInMem?: number;
822
+ /**
823
+ * [Optional] Disable iKey deprecation error message.
824
+ * @defaultValue true
825
+ */
826
+ disableIkeyDeprecationMessage?: boolean;
827
+ /**
828
+ * [Optional] Flag to indicate whether the internal looking endpoints should be automatically
829
+ * added to the `excludeRequestFromAutoTrackingPatterns` collection. (defaults to true).
830
+ * This flag exists as the provided regex is generic and may unexpectedly match a domain that
831
+ * should not be excluded.
832
+ */
833
+ addIntEndpoints?: boolean;
834
+ /**
835
+ * [Optional] Sets throttle mgr configuration by key
836
+ */
837
+ throttleMgrCfg?: {
838
+ [key: number]: IThrottleMgrConfig;
839
+ };
840
+ }
841
+
842
+ /**
843
+ * The type to identify whether the default value should be applied in preference to the provided value.
844
+ */
845
+ type IConfigCheckFn<V> = (value: V) => boolean;
846
+
847
+ /**
848
+ * The default values with a check function
849
+ */
850
+ interface IConfigDefaultCheck<T, V, C = IConfiguration> {
851
+ /**
852
+ * Callback function to check if the user-supplied value is valid, if not the default will be applied
853
+ */
854
+ isVal?: IConfigCheckFn<V>;
855
+ /**
856
+ * Optional function to allow converting and setting of the default value
857
+ */
858
+ set?: IConfigSetFn<T, V>;
859
+ /**
860
+ * The default value to apply if the user-supplied value is not valid
861
+ */
862
+ v?: V | IConfigDefaults<V, T>;
863
+ /**
864
+ * The default fallback key if the main key is not present, this is the key value from the config
865
+ */
866
+ fb?: keyof T | keyof C | Array<keyof T | keyof C>;
867
+ /**
868
+ * Use this check to determine the default fallback, default only checked whether the property isDefined,
869
+ * therefore `null`; `""` are considered to be valid values.
870
+ */
871
+ dfVal?: (value: any) => boolean;
872
+ /**
873
+ * Specify that any provided value should have the default value(s) merged into the value rather than
874
+ * just using either the default of user provided values. Mergeed objects will automatically be marked
875
+ * as referenced.
876
+ */
877
+ mrg?: boolean;
878
+ /**
879
+ * Set this field of the target as referenced, which will cause any object or array instance
880
+ * to be updated in-place rather than being entirely replaced. All other values will continue to be replaced.
881
+ * This is required for nested default objects to avoid multiple repetitive updates to listeners
882
+ * @returns The referenced properties current value
883
+ */
884
+ ref?: boolean;
885
+ /**
886
+ * Set this field of the target as read-only, which will block this single named property from
887
+ * ever being changed for the target instance.
888
+ * This does NOT freeze or seal the instance, it just stops the direct re-assignment of the named property,
889
+ * if the value is a non-primitive (ie. an object or array) it's properties will still be mutable.
890
+ * @returns The referenced properties current value
891
+ */
892
+ rdOnly?: boolean;
893
+ /**
894
+ * Block the value associated with this property from having it's properties / values converted into
895
+ * dynamic properties, this is generally used to block objects or arrays provided by external libraries
896
+ * which may be a plain object with readonly (non-configurable) or const properties.
897
+ */
898
+ blkVal?: boolean;
899
+ }
900
+
901
+ /**
902
+ * The Type definition to define default values to be applied to the config
903
+ * The value may be either the direct value or a ConfigDefaultCheck definition
904
+ */
905
+ type IConfigDefaults<T, C = IConfiguration> = {
906
+ [key in keyof T]: T[key] | IConfigDefaultCheck<T, T[key], C>;
907
+ };
908
+
909
+ /**
910
+ * The type which identifies the function use to validate the user supplied value
911
+ */
912
+ type IConfigSetFn<T, V> = (value: any, defValue: V, theConfig: T) => V;
913
+
914
+ /**
915
+ * Configuration provided to SDK core
916
+ */
917
+ interface IConfiguration {
918
+ /**
919
+ * Instrumentation key of resource. Either this or connectionString must be specified.
920
+ */
921
+ instrumentationKey?: string;
922
+ /**
923
+ * Connection string of resource. Either this or instrumentationKey must be specified.
924
+ */
925
+ connectionString?: string;
926
+ /**
927
+ * Set the timer interval (in ms) for internal logging queue, this is the
928
+ * amount of time to wait after logger.queue messages are detected to be sent.
929
+ * Note: since 3.0.1 and 2.8.13 the diagnostic logger timer is a normal timeout timer
930
+ * and not an interval timer. So this now represents the timer "delay" and not
931
+ * the frequency at which the events are sent.
932
+ */
933
+ diagnosticLogInterval?: number;
934
+ /**
935
+ * Maximum number of iKey transmitted logging telemetry per page view
936
+ */
937
+ maxMessageLimit?: number;
938
+ /**
939
+ * Console logging level. All logs with a severity level higher
940
+ * than the configured level will be printed to console. Otherwise
941
+ * they are suppressed. ie Level 2 will print both CRITICAL and
942
+ * WARNING logs to console, level 1 prints only CRITICAL.
943
+ *
944
+ * Note: Logs sent as telemetry to instrumentation key will also
945
+ * be logged to console if their severity meets the configured loggingConsoleLevel
946
+ *
947
+ * 0: ALL console logging off
948
+ * 1: logs to console: severity >= CRITICAL
949
+ * 2: logs to console: severity >= WARNING
950
+ */
951
+ loggingLevelConsole?: number;
952
+ /**
953
+ * Telemtry logging level to instrumentation key. All logs with a severity
954
+ * level higher than the configured level will sent as telemetry data to
955
+ * the configured instrumentation key.
956
+ *
957
+ * 0: ALL iKey logging off
958
+ * 1: logs to iKey: severity >= CRITICAL
959
+ * 2: logs to iKey: severity >= WARNING
960
+ */
961
+ loggingLevelTelemetry?: number;
962
+ /**
963
+ * If enabled, uncaught exceptions will be thrown to help with debugging
964
+ */
965
+ enableDebug?: boolean;
966
+ /**
967
+ * Endpoint where telemetry data is sent
968
+ */
969
+ endpointUrl?: string;
970
+ /**
971
+ * Extension configs loaded in SDK
972
+ */
973
+ extensionConfig?: {
974
+ [key: string]: any;
975
+ };
976
+ /**
977
+ * Additional plugins that should be loaded by core at runtime
978
+ */
979
+ readonly extensions?: ITelemetryPlugin[];
980
+ /**
981
+ * Channel queues that is setup by caller in desired order.
982
+ * If channels are provided here, core will ignore any channels that are already setup, example if there is a SKU with an initialized channel
983
+ */
984
+ readonly channels?: IChannelControls[][];
985
+ /**
986
+ * @type {boolean}
987
+ * Flag that disables the Instrumentation Key validation.
988
+ */
989
+ disableInstrumentationKeyValidation?: boolean;
990
+ /**
991
+ * [Optional] When enabled this will create local perfEvents based on sections of the code that have been instrumented
992
+ * to emit perfEvents (via the doPerf()) when this is enabled. This can be used to identify performance issues within
993
+ * the SDK, the way you are using it or optionally your own instrumented code.
994
+ * The provided IPerfManager implementation does NOT send any additional telemetry events to the server it will only fire
995
+ * the new perfEvent() on the INotificationManager which you can listen to.
996
+ * This also does not use the window.performance API, so it will work in environments where this API is not supported.
997
+ */
998
+ enablePerfMgr?: boolean;
999
+ /**
1000
+ * [Optional] Callback function that will be called to create a the IPerfManager instance when required and ```enablePerfMgr```
1001
+ * is enabled, this enables you to override the default creation of a PerfManager() without needing to ```setPerfMgr()```
1002
+ * after initialization.
1003
+ */
1004
+ createPerfMgr?: (core: IAppInsightsCore, notificationManager: INotificationManager) => IPerfManager;
1005
+ /**
1006
+ * [Optional] Fire every single performance event not just the top level root performance event. Defaults to false.
1007
+ */
1008
+ perfEvtsSendAll?: boolean;
1009
+ /**
1010
+ * [Optional] Identifies the default length used to generate random session and user id's if non currently exists for the user / session.
1011
+ * Defaults to 22, previous default value was 5, if you need to keep the previous maximum length you should set this value to 5.
1012
+ */
1013
+ idLength?: number;
1014
+ /**
1015
+ * @description Custom cookie domain. This is helpful if you want to share Application Insights cookies across subdomains. It
1016
+ * can be set here or as part of the cookieCfg.domain, the cookieCfg takes precedence if both are specified.
1017
+ * @type {string}
1018
+ * @defaultValue ""
1019
+ */
1020
+ cookieDomain?: string;
1021
+ /**
1022
+ * @description Custom cookie path. This is helpful if you want to share Application Insights cookies behind an application
1023
+ * gateway. It can be set here or as part of the cookieCfg.domain, the cookieCfg takes precedence if both are specified.
1024
+ * @type {string}
1025
+ * @defaultValue ""
1026
+ */
1027
+ cookiePath?: string;
1028
+ /**
1029
+ * [Optional] A boolean that indicated whether to disable the use of cookies by the SDK. If true, the SDK will not store or
1030
+ * read any data from cookies. Cookie usage can be re-enabled after initialization via the core.getCookieMgr().enable().
1031
+ */
1032
+ disableCookiesUsage?: boolean;
1033
+ /**
1034
+ * [Optional] A Cookie Manager configuration which includes hooks to allow interception of the get, set and delete cookie
1035
+ * operations. If this configuration is specified any specified enabled and domain properties will take precedence over the
1036
+ * cookieDomain and disableCookiesUsage values.
1037
+ */
1038
+ cookieCfg?: ICookieMgrConfig;
1039
+ /**
1040
+ * [Optional] An array of the page unload events that you would like to be ignored, special note there must be at least one valid unload
1041
+ * event hooked, if you list all or the runtime environment only supports a listed "disabled" event it will still be hooked, if required by the SDK.
1042
+ * Unload events include "beforeunload", "unload", "visibilitychange" (with 'hidden' state) and "pagehide"
1043
+ */
1044
+ disablePageUnloadEvents?: string[];
1045
+ /**
1046
+ * [Optional] An array of page show events that you would like to be ignored, special note there must be at lease one valid show event
1047
+ * hooked, if you list all or the runtime environment only supports a listed (disabled) event it will STILL be hooked, if required by the SDK.
1048
+ * Page Show events include "pageshow" and "visibilitychange" (with 'visible' state)
1049
+ */
1050
+ disablePageShowEvents?: string[];
1051
+ /**
1052
+ * [Optional] A flag for performance optimization to disable attempting to use the Chrome Debug Extension, if disabled and the extension is installed
1053
+ * this will not send any notifications.
1054
+ */
1055
+ disableDbgExt?: boolean;
1056
+ /**
1057
+ * Add "&w=0" parameter to support UA Parsing when web-workers don't have access to Document.
1058
+ * Default is false
1059
+ */
1060
+ enableWParam?: boolean;
1061
+ /**
1062
+ * Custom optional value that will be added as a prefix for storage name.
1063
+ * @defaultValue undefined
1064
+ */
1065
+ storagePrefix?: string;
1066
+ /**
1067
+ * Custom optional value to opt in features
1068
+ * @defaultValue undefined
1069
+ */
1070
+ featureOptIn?: IFeatureOptIn;
1071
+ }
1072
+
1073
+ interface ICookieMgr {
1074
+ /**
1075
+ * Enable or Disable the usage of cookies
1076
+ */
1077
+ setEnabled(value: boolean): void;
1078
+ /**
1079
+ * Can the system use cookies, if this returns false then all cookie setting and access functions will return nothing
1080
+ */
1081
+ isEnabled(): boolean;
1082
+ /**
1083
+ * Set the named cookie with the value and optional domain and optional
1084
+ * @param name - The name of the cookie
1085
+ * @param value - The value of the cookie (Must already be encoded)
1086
+ * @param maxAgeSec - [optional] The maximum number of SECONDS that this cookie should survive
1087
+ * @param domain - [optional] The domain to set for the cookie
1088
+ * @param path - [optional] Path to set for the cookie, if not supplied will default to "/"
1089
+ * @returns - True if the cookie was set otherwise false (Because cookie usage is not enabled or available)
1090
+ */
1091
+ set(name: string, value: string, maxAgeSec?: number, domain?: string, path?: string): boolean;
1092
+ /**
1093
+ * Get the value of the named cookie
1094
+ * @param name - The name of the cookie
1095
+ */
1096
+ get(name: string): string;
1097
+ /**
1098
+ * Delete/Remove the named cookie if cookie support is available and enabled.
1099
+ * Note: Not using "delete" as the name because it's a reserved word which would cause issues on older browsers
1100
+ * @param name - The name of the cookie
1101
+ * @param path - [optional] Path to set for the cookie, if not supplied will default to "/"
1102
+ * @returns - True if the cookie was marked for deletion otherwise false (Because cookie usage is not enabled or available)
1103
+ */
1104
+ del(name: string, path?: string): boolean;
1105
+ /**
1106
+ * Purge the cookie from the system if cookie support is available, this function ignores the enabled setting of the manager
1107
+ * so any cookie will be removed.
1108
+ * Note: Not using "delete" as the name because it's a reserved word which would cause issues on older browsers
1109
+ * @param name - The name of the cookie
1110
+ * @param path - [optional] Path to set for the cookie, if not supplied will default to "/"
1111
+ * @returns - True if the cookie was marked for deletion otherwise false (Because cookie usage is not available)
1112
+ */
1113
+ purge(name: string, path?: string): boolean;
1114
+ /**
1115
+ * Optional Callback hook to allow the cookie manager to update it's configuration, not generally implemented now that
1116
+ * dynamic configuration is supported
1117
+ * @param updateState
1118
+ */
1119
+ update?(updateState: ITelemetryUpdateState): void;
1120
+ /**
1121
+ * Unload and remove any state that this ICookieMgr may be holding, this is generally called when the
1122
+ * owning SDK is being unloaded.
1123
+ * @param isAsync - Can the unload be performed asynchronously (default)
1124
+ * @return If the unload occurs synchronously then nothing should be returned, if happening asynchronously then
1125
+ * the function should return an [IPromise](https://nevware21.github.io/ts-async/typedoc/interfaces/IPromise.html)
1126
+ * / Promise to allow any listeners to wait for the operation to complete.
1127
+ */
1128
+ unload?(isAsync?: boolean): void | IPromise<void>;
1129
+ }
1130
+
1131
+ /**
1132
+ * Configuration definition for instance based cookie management configuration
1133
+ */
1134
+ interface ICookieMgrConfig {
1135
+ /**
1136
+ * Defaults to true, A boolean that indicates whether the use of cookies by the SDK is enabled by the current instance.
1137
+ * If false, the instance of the SDK initialized by this configuration will not store or read any data from cookies
1138
+ */
1139
+ enabled?: boolean;
1140
+ /**
1141
+ * Custom cookie domain. This is helpful if you want to share Application Insights cookies across subdomains.
1142
+ */
1143
+ domain?: string;
1144
+ /**
1145
+ * Specifies the path to use for the cookie, defaults to '/'
1146
+ */
1147
+ path?: string;
1148
+ /**
1149
+ * Specify the cookie name(s) to be ignored, this will cause any matching cookie name to never be read or written.
1150
+ * They may still be explicitly purged or deleted. You do not need to repeat the name in the `blockedCookies`
1151
+ * configuration.(Since v2.8.8)
1152
+ */
1153
+ ignoreCookies?: string[];
1154
+ /**
1155
+ * Specify the cookie name(s) to never be written, this will cause any cookie name to never be created or updated,
1156
+ * they will still be read unless also included in the ignoreCookies and may still be explicitly purged or deleted.
1157
+ * If not provided defaults to the same list provided in ignoreCookies. (Since v2.8.8)
1158
+ */
1159
+ blockedCookies?: string[];
1160
+ /**
1161
+ * Hook function to fetch the named cookie value.
1162
+ * @param name - The name of the cookie
1163
+ */
1164
+ getCookie?: (name: string) => string;
1165
+ /**
1166
+ * Hook function to set the named cookie with the specified value.
1167
+ * @param name - The name of the cookie
1168
+ * @param value - The value to set for the cookie
1169
+ */
1170
+ setCookie?: (name: string, value: string) => void;
1171
+ /**
1172
+ * Hook function to delete the named cookie with the specified value, separated from
1173
+ * setCookie to avoid the need to parse the value to determine whether the cookie is being
1174
+ * added or removed.
1175
+ * @param name - The name of the cookie
1176
+ * @param cookieValue - The value to set to expire the cookie
1177
+ */
1178
+ delCookie?: (name: string, cookieValue: string) => void;
1179
+ }
1180
+
1181
+ interface ICustomProperties {
1182
+ [key: string]: any;
1183
+ }
1184
+
1185
+ interface IDiagnosticLogger {
1186
+ /**
1187
+ * 0: OFF
1188
+ * 1: only critical (default)
1189
+ * 2: critical + info
1190
+ */
1191
+ consoleLoggingLevel: () => number;
1192
+ /**
1193
+ * The internal logging queue
1194
+ */
1195
+ queue: _InternalLogMessage[];
1196
+ /**
1197
+ * This method will throw exceptions in debug mode or attempt to log the error as a console warning.
1198
+ * @param severity - The severity of the log message
1199
+ * @param message - The log message.
1200
+ */
1201
+ throwInternal(severity: LoggingSeverity, msgId: _InternalMessageId, msg: string, properties?: Object, isUserAct?: boolean): void;
1202
+ /**
1203
+ * This will write a debug message to the console if possible
1204
+ * @param message - {string} - The debug message
1205
+ */
1206
+ debugToConsole?(message: string): void;
1207
+ /**
1208
+ * This will write a warning to the console if possible
1209
+ * @param message - The warning message
1210
+ */
1211
+ warnToConsole(message: string): void;
1212
+ /**
1213
+ * This will write an error to the console if possible.
1214
+ * Provided by the default DiagnosticLogger instance, and internally the SDK will fall back to warnToConsole, however,
1215
+ * direct callers MUST check for its existence on the logger as you can provide your own IDiagnosticLogger instance.
1216
+ * @param message - The error message
1217
+ */
1218
+ errorToConsole?(message: string): void;
1219
+ /**
1220
+ * Resets the internal message count
1221
+ */
1222
+ resetInternalMessageCount(): void;
1223
+ /**
1224
+ * Logs a message to the internal queue.
1225
+ * @param severity - The severity of the log message
1226
+ * @param message - The message to log.
1227
+ */
1228
+ logInternalMessage?(severity: LoggingSeverity, message: _InternalLogMessage): void;
1229
+ /**
1230
+ * Optional Callback hook to allow the diagnostic logger to update it's configuration
1231
+ * @param updateState
1232
+ */
1233
+ update?(updateState: ITelemetryUpdateState): void;
1234
+ /**
1235
+ * Unload and remove any state that this IDiagnosticLogger may be holding, this is generally called when the
1236
+ * owning SDK is being unloaded.
1237
+ * @param isAsync - Can the unload be performed asynchronously (default)
1238
+ * @return If the unload occurs synchronously then nothing should be returned, if happening asynchronously then
1239
+ * the function should return an [IPromise](https://nevware21.github.io/ts-async/typedoc/interfaces/IPromise.html)
1240
+ * / Promise to allow any listeners to wait for the operation to complete.
1241
+ */
1242
+ unload?(isAsync?: boolean): void | IPromise<void>;
1243
+ }
1244
+
1245
+ interface IDistributedTraceContext {
1246
+ /**
1247
+ * Returns the current name of the page
1248
+ */
1249
+ getName(): string;
1250
+ /**
1251
+ * Sets the current name of the page
1252
+ * @param pageName
1253
+ */
1254
+ setName(pageName: string): void;
1255
+ /**
1256
+ * Returns the unique identifier for a trace. All requests / spans from the same trace share the same traceId.
1257
+ * Must be read from incoming headers or generated according to the W3C TraceContext specification,
1258
+ * in a hex representation of 16-byte array. A.k.a. trace-id, TraceID or Distributed TraceID
1259
+ */
1260
+ getTraceId(): string;
1261
+ /**
1262
+ * Set the unique identifier for a trace. All requests / spans from the same trace share the same traceId.
1263
+ * Must be conform to the W3C TraceContext specification, in a hex representation of 16-byte array.
1264
+ * A.k.a. trace-id, TraceID or Distributed TraceID https://www.w3.org/TR/trace-context/#trace-id
1265
+ */
1266
+ setTraceId(newValue: string): void;
1267
+ /**
1268
+ * Self-generated 8-bytes identifier of the incoming request. Must be a hex representation of 8-byte array.
1269
+ * Also know as the parentId, used to link requests together
1270
+ */
1271
+ getSpanId(): string;
1272
+ /**
1273
+ * Self-generated 8-bytes identifier of the incoming request. Must be a hex representation of 8-byte array.
1274
+ * Also know as the parentId, used to link requests together
1275
+ * https://www.w3.org/TR/trace-context/#parent-id
1276
+ */
1277
+ setSpanId(newValue: string): void;
1278
+ /**
1279
+ * An integer representation of the W3C TraceContext trace-flags.
1280
+ */
1281
+ getTraceFlags(): number | undefined;
1282
+ /**
1283
+ * https://www.w3.org/TR/trace-context/#trace-flags
1284
+ * @param newValue
1285
+ */
1286
+ setTraceFlags(newValue?: number): void;
1287
+ }
1288
+
1289
+ interface IFeatureOptIn {
1290
+ [feature: string]: IFeatureOptInDetails;
1291
+ }
1292
+
1293
+ interface IFeatureOptInDetails {
1294
+ /**
1295
+ * sets feature opt-in mode
1296
+ * @default undefined
1297
+ */
1298
+ mode?: FeatureOptInMode;
1299
+ /**
1300
+ * Identifies configuration override values when given feature is enabled
1301
+ * NOTE: should use flat string for fields, for example, if you want to set value for extensionConfig.Ananlytics.disableAjaxTrackig in configurations,
1302
+ * you should use "extensionConfig.Ananlytics.disableAjaxTrackig" as field name: {["extensionConfig.Analytics.disableAjaxTrackig"]:1}
1303
+ * Default: undefined
1304
+ */
1305
+ onCfg?: {
1306
+ [field: string]: any;
1307
+ };
1308
+ /**
1309
+ * Identifies configuration override values when given feature is disabled
1310
+ * NOTE: should use flat string for fields, for example, if you want to set value for extensionConfig.Ananlytics.disableAjaxTrackig in configurations,
1311
+ * you should use "extensionConfig.Ananlytics.disableAjaxTrackig" as field name: {["extensionConfig.Analytics.disableAjaxTrackig"]:1}
1312
+ * Default: undefined
1313
+ */
1314
+ offCfg?: {
1315
+ [field: string]: any;
1316
+ };
1317
+ /**
1318
+ * define if should block any changes from cdn cfg, if set to true, cfgValue will be applied under all scenarios
1319
+ * @default false
1320
+ */
1321
+ blockCdnCfg?: boolean;
1322
+ }
1323
+
1324
+ /**
1325
+ * An alternate interface which provides automatic removal during unloading of the component
1326
+ */
1327
+ interface ILegacyUnloadHook {
1328
+ /**
1329
+ * Legacy Self remove the referenced component
1330
+ */
1331
+ remove: () => void;
1332
+ }
1333
+
1334
+ interface ILoadedPlugin<T extends IPlugin> {
1335
+ plugin: T;
1336
+ /**
1337
+ * Identifies whether the plugin is enabled and can process events. This is slightly different from isInitialized as the plugin may be initialized but disabled
1338
+ * via the setEnabled() or it may be a shared plugin which has had it's teardown function called from another instance..
1339
+ * @returns boolean = true if the plugin is in a state where it is operational.
1340
+ */
1341
+ isEnabled: () => boolean;
1342
+ /**
1343
+ * You can optionally enable / disable a plugin from processing events.
1344
+ * Setting enabled to true will not necessarily cause the `isEnabled()` to also return true
1345
+ * as the plugin must also have been successfully initialized and not had it's `teardown` method called
1346
+ * (unless it's also been re-initialized)
1347
+ */
1348
+ setEnabled: (isEnabled: boolean) => void;
1349
+ remove: (isAsync?: boolean, removeCb?: (removed?: boolean) => void) => void;
1350
+ }
1351
+
1352
+ /**
1353
+ * An interface used for the notification listener.
1354
+ * @interface
1355
+ */
1356
+ interface INotificationListener {
1357
+ /**
1358
+ * [Optional] A function called when events are sent.
1359
+ * @param events - The array of events that have been sent.
1360
+ */
1361
+ eventsSent?: (events: ITelemetryItem[]) => void;
1362
+ /**
1363
+ * [Optional] A function called when events are discarded.
1364
+ * @param events - The array of events that have been discarded.
1365
+ * @param reason - The reason for discarding the events. The EventsDiscardedReason
1366
+ * constant should be used to check the different values.
1367
+ */
1368
+ eventsDiscarded?: (events: ITelemetryItem[], reason: number) => void;
1369
+ /**
1370
+ * [Optional] A function called when the events have been requested to be sent to the sever.
1371
+ * @param sendReason - The reason why the event batch is being sent.
1372
+ * @param isAsync - A flag which identifies whether the requests are being sent in an async or sync manner.
1373
+ */
1374
+ eventsSendRequest?: (sendReason: number, isAsync?: boolean) => void;
1375
+ /**
1376
+ * [Optional] This event is sent if you have enabled perf events, they are primarily used to track internal performance testing and debugging
1377
+ * the event can be displayed via the debug plugin extension.
1378
+ * @param perfEvent
1379
+ */
1380
+ perfEvent?: (perfEvent: IPerfEvent) => void;
1381
+ /**
1382
+ * Unload and remove any state that this INotificationListener may be holding, this is generally called when the
1383
+ * owning Manager is being unloaded.
1384
+ * @param isAsync - Can the unload be performed asynchronously (default)
1385
+ * @return If the unload occurs synchronously then nothing should be returned, if happening asynchronously then
1386
+ * the function should return an [IPromise](https://nevware21.github.io/ts-async/typedoc/interfaces/IPromise.html)
1387
+ * / Promise to allow any listeners to wait for the operation to complete.
1388
+ */
1389
+ unload?(isAsync?: boolean): void | IPromise<void>;
1390
+ }
1391
+
1392
+ /**
1393
+ * Class to manage sending notifications to all the listeners.
1394
+ */
1395
+ interface INotificationManager {
1396
+ listeners: INotificationListener[];
1397
+ /**
1398
+ * Adds a notification listener.
1399
+ * @param listener - The notification listener to be added.
1400
+ */
1401
+ addNotificationListener(listener: INotificationListener): void;
1402
+ /**
1403
+ * Removes all instances of the listener.
1404
+ * @param listener - AWTNotificationListener to remove.
1405
+ */
1406
+ removeNotificationListener(listener: INotificationListener): void;
1407
+ /**
1408
+ * Notification for events sent.
1409
+ * @param events - The array of events that have been sent.
1410
+ */
1411
+ eventsSent(events: ITelemetryItem[]): void;
1412
+ /**
1413
+ * Notification for events being discarded.
1414
+ * @param events - The array of events that have been discarded by the SDK.
1415
+ * @param reason - The reason for which the SDK discarded the events. The EventsDiscardedReason
1416
+ * constant should be used to check the different values.
1417
+ */
1418
+ eventsDiscarded(events: ITelemetryItem[], reason: number): void;
1419
+ /**
1420
+ * [Optional] A function called when the events have been requested to be sent to the sever.
1421
+ * @param sendReason - The reason why the event batch is being sent.
1422
+ * @param isAsync - A flag which identifies whether the requests are being sent in an async or sync manner.
1423
+ */
1424
+ eventsSendRequest?(sendReason: number, isAsync: boolean): void;
1425
+ /**
1426
+ * [Optional] This event is sent if you have enabled perf events, they are primarily used to track internal performance testing and debugging
1427
+ * the event can be displayed via the debug plugin extension.
1428
+ * @param perfEvent - The perf event details
1429
+ */
1430
+ perfEvent?(perfEvent: IPerfEvent): void;
1431
+ /**
1432
+ * Unload and remove any state that this INotificationManager may be holding, this is generally called when the
1433
+ * owning SDK is being unloaded.
1434
+ * @param isAsync - Can the unload be performed asynchronously (default)
1435
+ * @return If the unload occurs synchronously then nothing should be returned, if happening asynchronously then
1436
+ * the function should return an [IPromise](https://nevware21.github.io/ts-async/typedoc/interfaces/IPromise.html)
1437
+ * / Promise to allow any listeners to wait for the operation to complete.
1438
+ */
1439
+ unload?(isAsync?: boolean): void | IPromise<void>;
1440
+ }
1441
+
1442
+ class _InternalLogMessage {
1443
+ static dataType: string;
1444
+ message: string;
1445
+ messageId: _InternalMessageId;
1446
+ constructor(msgId: _InternalMessageId, msg: string, isUserAct?: boolean, properties?: Object);
1447
+ }
1448
+
1449
+ type _InternalMessageId = number | _eInternalMessageId;
1450
+
1451
+ /**
1452
+ * This interface identifies the details of an internal performance event - it does not represent an outgoing reported event
1453
+ */
1454
+ interface IPerfEvent {
1455
+ /**
1456
+ * The name of the performance event
1457
+ */
1458
+ name: string;
1459
+ /**
1460
+ * The start time of the performance event
1461
+ */
1462
+ start: number;
1463
+ /**
1464
+ * The payload (contents) of the perfEvent, may be null or only set after the event has completed depending on
1465
+ * the runtime environment.
1466
+ */
1467
+ payload: any;
1468
+ /**
1469
+ * Is this occurring from an asynchronous event
1470
+ */
1471
+ isAsync: boolean;
1472
+ /**
1473
+ * Identifies the total inclusive time spent for this event, including the time spent for child events,
1474
+ * this will be undefined until the event is completed
1475
+ */
1476
+ time?: number;
1477
+ /**
1478
+ * Identifies the exclusive time spent in for this event (not including child events),
1479
+ * this will be undefined until the event is completed.
1480
+ */
1481
+ exTime?: number;
1482
+ /**
1483
+ * The Parent event that was started before this event was created
1484
+ */
1485
+ parent?: IPerfEvent;
1486
+ /**
1487
+ * The child perf events that are contained within the total time of this event.
1488
+ */
1489
+ childEvts?: IPerfEvent[];
1490
+ /**
1491
+ * Identifies whether this event is a child event of a parent
1492
+ */
1493
+ isChildEvt: () => boolean;
1494
+ /**
1495
+ * Get the names additional context associated with this perf event
1496
+ */
1497
+ getCtx?: (key: string) => any;
1498
+ /**
1499
+ * Set the named additional context to be associated with this perf event, this will replace any existing value
1500
+ */
1501
+ setCtx?: (key: string, value: any) => void;
1502
+ /**
1503
+ * Mark this event as completed, calculating the total execution time.
1504
+ */
1505
+ complete: () => void;
1506
+ }
1507
+
1508
+ /**
1509
+ * This defines an internal performance manager for tracking and reporting the internal performance of the SDK -- It does
1510
+ * not represent or report any event to the server.
1511
+ */
1512
+ interface IPerfManager {
1513
+ /**
1514
+ * Create a new event and start timing, the manager may return null/undefined to indicate that it does not
1515
+ * want to monitor this source event.
1516
+ * @param src - The source name of the event
1517
+ * @param payloadDetails - An optional callback function to fetch the payload details for the event.
1518
+ * @param isAsync - Is the event occurring from a async event
1519
+ */
1520
+ create(src: string, payloadDetails?: () => any, isAsync?: boolean): IPerfEvent | null | undefined;
1521
+ /**
1522
+ * Complete the perfEvent and fire any notifications.
1523
+ * @param perfEvent - Fire the event which will also complete the passed event
1524
+ */
1525
+ fire(perfEvent: IPerfEvent): void;
1526
+ /**
1527
+ * Set an execution context value
1528
+ * @param key - The context key name
1529
+ * @param value - The value
1530
+ */
1531
+ setCtx(key: string, value: any): void;
1532
+ /**
1533
+ * Get the execution context value
1534
+ * @param key - The context key
1535
+ */
1536
+ getCtx(key: string): any;
1537
+ }
1538
+
1539
+ /**
1540
+ * Identifies an interface to a host that can provide an IPerfManager implementation
1541
+ */
1542
+ interface IPerfManagerProvider {
1543
+ /**
1544
+ * Get the current performance manager
1545
+ */
1546
+ getPerfMgr(): IPerfManager;
1547
+ /**
1548
+ * Set the current performance manager
1549
+ * @param perfMgr - The performance manager
1550
+ */
1551
+ setPerfMgr(perfMgr: IPerfManager): void;
1552
+ }
1553
+
1554
+ interface IPlugin {
1555
+ /**
1556
+ * Initialize plugin loaded by SDK
1557
+ * @param config - The config for the plugin to use
1558
+ * @param core - The current App Insights core to use for initializing this plugin instance
1559
+ * @param extensions - The complete set of extensions to be used for initializing the plugin
1560
+ * @param pluginChain - [Optional] specifies the current plugin chain which identifies the
1561
+ * set of plugins and the order they should be executed for the current request.
1562
+ */
1563
+ initialize: (config: IConfiguration, core: IAppInsightsCore, extensions: IPlugin[], pluginChain?: ITelemetryPluginChain) => void;
1564
+ /**
1565
+ * Returns a value that indicates whether the plugin has already been previously initialized.
1566
+ * New plugins should implement this method to avoid being initialized more than once.
1567
+ */
1568
+ isInitialized?: () => boolean;
1569
+ /**
1570
+ * Tear down the plugin and remove any hooked value, the plugin should be removed so that it is no longer initialized and
1571
+ * therefore could be re-initialized after being torn down. The plugin should ensure that once this has been called any further
1572
+ * processTelemetry calls are ignored and it just calls the processNext() with the provided context.
1573
+ * @param unloadCtx - This is the context that should be used during unloading.
1574
+ * @param unloadState - The details / state of the unload process, it holds details like whether it should be unloaded synchronously or asynchronously and the reason for the unload.
1575
+ * @returns boolean - true if the plugin has or will call processNext(), this for backward compatibility as previously teardown was synchronous and returned nothing.
1576
+ */
1577
+ teardown?: (unloadCtx: IProcessTelemetryUnloadContext, unloadState?: ITelemetryUnloadState) => void | boolean;
1578
+ /**
1579
+ * Extension name
1580
+ */
1581
+ readonly identifier: string;
1582
+ /**
1583
+ * Plugin version (available in data.properties.version in common schema)
1584
+ */
1585
+ readonly version?: string;
1586
+ /**
1587
+ * The App Insights core to use for backward compatibility.
1588
+ * Therefore the interface will be able to access the core without needing to cast to "any".
1589
+ * [optional] any 3rd party plugins which are already implementing this interface don't fail to compile.
1590
+ */
1591
+ core?: IAppInsightsCore;
1592
+ }
1593
+
1594
+ /**
1595
+ * The current context for the current call to processTelemetry(), used to support sharing the same plugin instance
1596
+ * between multiple AppInsights instances
1597
+ */
1598
+ interface IProcessTelemetryContext extends IBaseProcessingContext {
1599
+ /**
1600
+ * Call back for telemetry processing before it it is sent
1601
+ * @param env - This is the current event being reported
1602
+ * @returns boolean (true) if there is no more plugins to process otherwise false or undefined (void)
1603
+ */
1604
+ processNext: (env: ITelemetryItem) => boolean | void;
1605
+ /**
1606
+ * Create a new context using the core and config from the current instance, returns a new instance of the same type
1607
+ * @param plugins - The execution order to process the plugins, if null or not supplied
1608
+ * then the current execution order will be copied.
1609
+ * @param startAt - The plugin to start processing from, if missing from the execution
1610
+ * order then the next plugin will be NOT set.
1611
+ */
1612
+ createNew: (plugins?: IPlugin[] | ITelemetryPluginChain, startAt?: IPlugin) => IProcessTelemetryContext;
1613
+ }
1614
+
1615
+ /**
1616
+ * The current context for the current call to teardown() implementations, used to support when plugins are being removed
1617
+ * or the SDK is being unloaded.
1618
+ */
1619
+ interface IProcessTelemetryUnloadContext extends IBaseProcessingContext {
1620
+ /**
1621
+ * This Plugin has finished unloading, so unload the next one
1622
+ * @param uploadState - The state of the unload process
1623
+ * @returns boolean (true) if there is no more plugins to process otherwise false or undefined (void)
1624
+ */
1625
+ processNext: (unloadState: ITelemetryUnloadState) => boolean | void;
1626
+ /**
1627
+ * Create a new context using the core and config from the current instance, returns a new instance of the same type
1628
+ * @param plugins - The execution order to process the plugins, if null or not supplied
1629
+ * then the current execution order will be copied.
1630
+ * @param startAt - The plugin to start processing from, if missing from the execution
1631
+ * order then the next plugin will be NOT set.
1632
+ */
1633
+ createNew: (plugins?: IPlugin[] | ITelemetryPluginChain, startAt?: IPlugin) => IProcessTelemetryUnloadContext;
1634
+ }
1635
+
1636
+ /**
1637
+ * The current context for the current call to the plugin update() implementations, used to support the notifications
1638
+ * for when plugins are added, removed or the configuration was changed.
1639
+ */
1640
+ interface IProcessTelemetryUpdateContext extends IBaseProcessingContext {
1641
+ /**
1642
+ * This Plugin has finished unloading, so unload the next one
1643
+ * @param updateState - The update State
1644
+ * @returns boolean (true) if there is no more plugins to process otherwise false or undefined (void)
1645
+ */
1646
+ processNext: (updateState: ITelemetryUpdateState) => boolean | void;
1647
+ /**
1648
+ * Create a new context using the core and config from the current instance, returns a new instance of the same type
1649
+ * @param plugins - The execution order to process the plugins, if null or not supplied
1650
+ * then the current execution order will be copied.
1651
+ * @param startAt - The plugin to start processing from, if missing from the execution
1652
+ * order then the next plugin will be NOT set.
1653
+ */
1654
+ createNew: (plugins?: IPlugin[] | ITelemetryPluginChain, startAt?: IPlugin) => IProcessTelemetryUpdateContext;
1655
+ }
1656
+
1657
+ /**
1658
+ * Create a Promise object that represents the eventual completion (or failure) of an asynchronous operation and its resulting value.
1659
+ * This interface definition, closely mirrors the typescript / javascript PromiseLike<T> and Promise<T> definitions as well as providing
1660
+ * simular functions as that provided by jQuery deferred objects.
1661
+ *
1662
+ * The returned Promise is a proxy for a value not necessarily known when the promise is created. It allows you to associate handlers
1663
+ * with an asynchronous action's eventual success value or failure reason. This lets asynchronous methods return values like synchronous
1664
+ * methods: instead of immediately returning the final value, the asynchronous method returns a promise to supply the value at some point
1665
+ * in the future.
1666
+ *
1667
+ * A Promise is in one of these states:
1668
+ * <ul>
1669
+ * <li> pending: initial state, neither fulfilled nor rejected.
1670
+ * <li> fulfilled: meaning that the operation was completed successfully.
1671
+ * <li> rejected: meaning that the operation failed.
1672
+ * </ul>
1673
+ *
1674
+ * A pending promise can either be fulfilled with a value or rejected with a reason (error). When either of these options happens, the
1675
+ * associated handlers queued up by a promise's then method are called synchronously. If the promise has already been fulfilled or rejected
1676
+ * when a corresponding handler is attached, the handler will be called synchronously, so there is no race condition between an asynchronous
1677
+ * operation completing and its handlers being attached.
1678
+ *
1679
+ * As the `then()` and `catch()` methods return promises, they can be chained.
1680
+ * @typeParam T - Identifies the expected return type from the promise
1681
+ */
1682
+ interface IPromise<T> extends PromiseLike<T>, Promise<T> {
1683
+ /**
1684
+ * Returns a string representation of the current state of the promise. The promise can be in one of four states.
1685
+ * <ul>
1686
+ * <li> <b>"pending"</b>: The promise is not yet in a completed state (neither "rejected"; or "resolved").</li>
1687
+ * <li> <b>"resolved"</b>: The promise is in the resolved state.</li>
1688
+ * <li> <b>"rejected"</b>: The promise is in the rejected state.</li>
1689
+ * </ul>
1690
+ * @example
1691
+ * ```ts
1692
+ * let doResolve;
1693
+ * let promise: IPromise<any> = createSyncPromise((resolve) => {
1694
+ * doResolve = resolve;
1695
+ * });
1696
+ *
1697
+ * let state: string = promise.state();
1698
+ * console.log("State: " + state); // State: pending
1699
+ * doResolve(true); // Promise will resolve synchronously as it's a synchronous promise
1700
+ * console.log("State: " + state); // State: resolved
1701
+ * ```
1702
+ */
1703
+ state?: string;
1704
+ /**
1705
+ * Attaches callbacks for the resolution and/or rejection of the Promise.
1706
+ * @param onResolved The callback to execute when the Promise is resolved.
1707
+ * @param onRejected The callback to execute when the Promise is rejected.
1708
+ * @returns A Promise for the completion of which ever callback is executed.
1709
+ * @example
1710
+ * ```ts
1711
+ * const promise1 = createPromise((resolve, reject) => {
1712
+ * resolve('Success!');
1713
+ * });
1714
+ *
1715
+ * promise1.then((value) => {
1716
+ * console.log(value);
1717
+ * // expected output: "Success!"
1718
+ * });
1719
+ * ```
1720
+ */
1721
+ then<TResult1 = T, TResult2 = never>(onResolved?: ResolvedPromiseHandler<T, TResult1>, onRejected?: RejectedPromiseHandler<TResult2>): IPromise<TResult1 | TResult2>;
1722
+ /**
1723
+ * Attaches callbacks for the resolution and/or rejection of the Promise.
1724
+ * @param onResolved The callback to execute when the Promise is resolved.
1725
+ * @param onRejected The callback to execute when the Promise is rejected.
1726
+ * @returns A Promise for the completion of which ever callback is executed.
1727
+ * @example
1728
+ * ```ts
1729
+ * const promise1 = createPromise((resolve, reject) => {
1730
+ * resolve('Success!');
1731
+ * });
1732
+ *
1733
+ * promise1.then((value) => {
1734
+ * console.log(value);
1735
+ * // expected output: "Success!"
1736
+ * });
1737
+ * ```
1738
+ */
1739
+ then<TResult1 = T, TResult2 = never>(onResolved?: ResolvedPromiseHandler<T, TResult1>, onRejected?: RejectedPromiseHandler<TResult2>): PromiseLike<TResult1 | TResult2>;
1740
+ /**
1741
+ * Attaches callbacks for the resolution and/or rejection of the Promise.
1742
+ * @param onResolved The callback to execute when the Promise is resolved.
1743
+ * @param onRejected The callback to execute when the Promise is rejected.
1744
+ * @returns A Promise for the completion of which ever callback is executed.
1745
+ * @example
1746
+ * ```ts
1747
+ * const promise1 = createPromise((resolve, reject) => {
1748
+ * resolve('Success!');
1749
+ * });
1750
+ *
1751
+ * promise1.then((value) => {
1752
+ * console.log(value);
1753
+ * // expected output: "Success!"
1754
+ * });
1755
+ * ```
1756
+ */
1757
+ then<TResult1 = T, TResult2 = never>(onResolved?: ResolvedPromiseHandler<T, TResult1>, onRejected?: RejectedPromiseHandler<TResult2>): Promise<TResult1 | TResult2>;
1758
+ /**
1759
+ * Attaches a callback for only the rejection of the Promise.
1760
+ * @param onRejected The callback to execute when the Promise is rejected.
1761
+ * @returns A Promise for the completion of the callback.
1762
+ * @example
1763
+ * ```ts
1764
+ * const promise1 = createPromise((resolve, reject) => {
1765
+ * throw 'Uh-oh!';
1766
+ * });
1767
+ *
1768
+ * promise1.catch((error) => {
1769
+ * console.error(error);
1770
+ * });
1771
+ * // expected output: Uh-oh!
1772
+ * ```
1773
+ */
1774
+ catch<TResult = never>(onRejected?: ((reason: any) => TResult | IPromise<TResult>) | undefined | null): IPromise<T | TResult>;
1775
+ /**
1776
+ * Attaches a callback for only the rejection of the Promise.
1777
+ * @param onRejected The callback to execute when the Promise is rejected.
1778
+ * @returns A Promise for the completion of the callback.
1779
+ * @example
1780
+ * ```ts
1781
+ * const promise1 = createPromise((resolve, reject) => {
1782
+ * throw 'Uh-oh!';
1783
+ * });
1784
+ *
1785
+ * promise1.catch((error) => {
1786
+ * console.error(error);
1787
+ * });
1788
+ * // expected output: Uh-oh!
1789
+ * ```
1790
+ */
1791
+ catch<TResult = never>(onRejected?: ((reason: any) => TResult | IPromise<TResult>) | undefined | null): PromiseLike<T | TResult>;
1792
+ /**
1793
+ * Attaches a callback for only the rejection of the Promise.
1794
+ * @param onRejected The callback to execute when the Promise is rejected.
1795
+ * @returns A Promise for the completion of the callback.
1796
+ * @example
1797
+ * ```ts
1798
+ * const promise1 = createPromise((resolve, reject) => {
1799
+ * throw 'Uh-oh!';
1800
+ * });
1801
+ *
1802
+ * promise1.catch((error) => {
1803
+ * console.error(error);
1804
+ * });
1805
+ * // expected output: Uh-oh!
1806
+ * ```
1807
+ */
1808
+ catch<TResult = never>(onRejected?: ((reason: any) => TResult | IPromise<TResult>) | undefined | null): Promise<T | TResult>;
1809
+ /**
1810
+ * Attaches a callback that is invoked when the Promise is settled (fulfilled or rejected). The
1811
+ * resolved value cannot be modified from the callback.
1812
+ * @param onfinally The callback to execute when the Promise is settled (fulfilled or rejected).
1813
+ * @returns A Promise for the completion of the callback.
1814
+ * @example
1815
+ * ```ts
1816
+ * function doFunction() {
1817
+ * return createPromise((resolve, reject) => {
1818
+ * if (Math.random() > 0.5) {
1819
+ * resolve('Function has completed');
1820
+ * } else {
1821
+ * reject(new Error('Function failed to process'));
1822
+ * }
1823
+ * });
1824
+ * }
1825
+ *
1826
+ * doFunction().then((data) => {
1827
+ * console.log(data);
1828
+ * }).catch((err) => {
1829
+ * console.error(err);
1830
+ * }).finally(() => {
1831
+ * console.log('Function processing completed');
1832
+ * });
1833
+ * ```
1834
+ */
1835
+ finally(onfinally?: FinallyPromiseHandler): IPromise<T>;
1836
+ /**
1837
+ * Attaches a callback that is invoked when the Promise is settled (fulfilled or rejected). The
1838
+ * resolved value cannot be modified from the callback.
1839
+ * @param onfinally The callback to execute when the Promise is settled (fulfilled or rejected).
1840
+ * @returns A Promise for the completion of the callback.
1841
+ * @example
1842
+ * ```ts
1843
+ * function doFunction() {
1844
+ * return createPromise((resolve, reject) => {
1845
+ * if (Math.random() > 0.5) {
1846
+ * resolve('Function has completed');
1847
+ * } else {
1848
+ * reject(new Error('Function failed to process'));
1849
+ * }
1850
+ * });
1851
+ * }
1852
+ *
1853
+ * doFunction().then((data) => {
1854
+ * console.log(data);
1855
+ * }).catch((err) => {
1856
+ * console.error(err);
1857
+ * }).finally(() => {
1858
+ * console.log('Function processing completed');
1859
+ * });
1860
+ * ```
1861
+ */
1862
+ finally(onFinally?: FinallyPromiseHandler): Promise<T>;
1863
+ }
1864
+
1865
+ interface IRequestContext {
1866
+ status?: number;
1867
+ xhr?: XMLHttpRequest;
1868
+ request?: Request;
1869
+ response?: Response | string;
1870
+ }
1871
+
1872
+ /**
1873
+ * Identifies a simple interface to allow you to override the storage mechanism used
1874
+ * to track unsent and unacknowledged events. When provided it must provide both
1875
+ * the get and set item functions.
1876
+ * @since 2.8.12
1877
+ */
1878
+ interface IStorageBuffer {
1879
+ /**
1880
+ * Retrieves the stored value for a given key
1881
+ */
1882
+ getItem(logger: IDiagnosticLogger, name: string): string;
1883
+ /**
1884
+ * Sets the stored value for a given key
1885
+ */
1886
+ setItem(logger: IDiagnosticLogger, name: string, data: string): boolean;
1887
+ }
26
1888
 
27
1889
  interface ITeeChannelConfig {
28
1890
  /**
@@ -38,6 +1900,447 @@ declare namespace ApplicationInsights {
38
1900
  ignoreCoreChannels?: boolean;
39
1901
  }
40
1902
 
1903
+ interface ITelemetryInitializerHandler extends ILegacyUnloadHook {
1904
+ remove(): void;
1905
+ }
1906
+
1907
+ /**
1908
+ * Telemety item supported in Core
1909
+ */
1910
+ interface ITelemetryItem {
1911
+ /**
1912
+ * CommonSchema Version of this SDK
1913
+ */
1914
+ ver?: string;
1915
+ /**
1916
+ * Unique name of the telemetry item
1917
+ */
1918
+ name: string;
1919
+ /**
1920
+ * Timestamp when item was sent
1921
+ */
1922
+ time?: string;
1923
+ /**
1924
+ * Identifier of the resource that uniquely identifies which resource data is sent to
1925
+ */
1926
+ iKey?: string;
1927
+ /**
1928
+ * System context properties of the telemetry item, example: ip address, city etc
1929
+ */
1930
+ ext?: {
1931
+ [key: string]: any;
1932
+ };
1933
+ /**
1934
+ * System context property extensions that are not global (not in ctx)
1935
+ */
1936
+ tags?: Tags & Tags[];
1937
+ /**
1938
+ * Custom data
1939
+ */
1940
+ data?: ICustomProperties;
1941
+ /**
1942
+ * Telemetry type used for part B
1943
+ */
1944
+ baseType?: string;
1945
+ /**
1946
+ * Based on schema for part B
1947
+ */
1948
+ baseData?: {
1949
+ [key: string]: any;
1950
+ };
1951
+ }
1952
+
1953
+ /**
1954
+ * Configuration provided to SDK core
1955
+ */
1956
+ interface ITelemetryPlugin extends ITelemetryProcessor, IPlugin {
1957
+ /**
1958
+ * Set next extension for telemetry processing, this is not optional as plugins should use the
1959
+ * processNext() function of the passed IProcessTelemetryContext instead. It is being kept for
1960
+ * now for backward compatibility only.
1961
+ */
1962
+ setNextPlugin?: (next: ITelemetryPlugin | ITelemetryPluginChain) => void;
1963
+ /**
1964
+ * Priority of the extension
1965
+ */
1966
+ readonly priority: number;
1967
+ }
1968
+
1969
+ /**
1970
+ * Configuration provided to SDK core
1971
+ */
1972
+ interface ITelemetryPluginChain extends ITelemetryProcessor {
1973
+ /**
1974
+ * Returns the underlying plugin that is being proxied for the processTelemetry call
1975
+ */
1976
+ getPlugin: () => ITelemetryPlugin;
1977
+ /**
1978
+ * Returns the next plugin
1979
+ */
1980
+ getNext: () => ITelemetryPluginChain;
1981
+ /**
1982
+ * This plugin is being unloaded and should remove any hooked events and cleanup any global/scoped values, after this
1983
+ * call the plugin will be removed from the telemetry processing chain and will no longer receive any events..
1984
+ * @param unloadCtx - The unload context to use for this call.
1985
+ * @param unloadState - The details of the unload operation
1986
+ */
1987
+ unload?: (unloadCtx: IProcessTelemetryUnloadContext, unloadState: ITelemetryUnloadState) => void;
1988
+ }
1989
+
1990
+ interface ITelemetryProcessor {
1991
+ /**
1992
+ * Call back for telemetry processing before it it is sent
1993
+ * @param env - This is the current event being reported
1994
+ * @param itemCtx - This is the context for the current request, ITelemetryPlugin instances
1995
+ * can optionally use this to access the current core instance or define / pass additional information
1996
+ * to later plugins (vs appending items to the telemetry item)
1997
+ */
1998
+ processTelemetry: (env: ITelemetryItem, itemCtx?: IProcessTelemetryContext) => void;
1999
+ /**
2000
+ * The the plugin should re-evaluate configuration and update any cached configuration settings or
2001
+ * plugins. If implemented this method will be called whenever a plugin is added or removed and if
2002
+ * the configuration has bee updated.
2003
+ * @param updateCtx - This is the context that should be used during updating.
2004
+ * @param updateState - The details / state of the update process, it holds details like the current and previous configuration.
2005
+ * @returns boolean - true if the plugin has or will call updateCtx.processNext(), this allows the plugin to perform any asynchronous operations.
2006
+ */
2007
+ update?: (updateCtx: IProcessTelemetryUpdateContext, updateState: ITelemetryUpdateState) => void | boolean;
2008
+ }
2009
+
2010
+ interface ITelemetryUnloadState {
2011
+ reason: TelemetryUnloadReason;
2012
+ isAsync: boolean;
2013
+ flushComplete?: boolean;
2014
+ }
2015
+
2016
+ interface ITelemetryUpdateState {
2017
+ /**
2018
+ * Identifies the reason for the update notification, this is a bitwise numeric value
2019
+ */
2020
+ reason: TelemetryUpdateReason;
2021
+ /**
2022
+ * This is a new active configuration that should be used
2023
+ */
2024
+ cfg?: IConfiguration;
2025
+ /**
2026
+ * The detected changes
2027
+ */
2028
+ oldCfg?: IConfiguration;
2029
+ /**
2030
+ * If this is a configuration update this was the previous configuration that was used
2031
+ */
2032
+ newConfig?: IConfiguration;
2033
+ /**
2034
+ * Was the new config requested to be merged with the existing config
2035
+ */
2036
+ merge?: boolean;
2037
+ /**
2038
+ * This holds a collection of plugins that have been added (if the reason identifies that one or more plugins have been added)
2039
+ */
2040
+ added?: IPlugin[];
2041
+ /**
2042
+ * This holds a collection of plugins that have been removed (if the reason identifies that one or more plugins have been removed)
2043
+ */
2044
+ removed?: IPlugin[];
2045
+ }
2046
+
2047
+ /**
2048
+ * Identifies frequency of items sent
2049
+ * Default: send data on 28th every 3 month each year
2050
+ */
2051
+ interface IThrottleInterval {
2052
+ /**
2053
+ * Identifies month interval that items can be sent
2054
+ * For example, if it is set to 2 and start date is in Jan, items will be sent out every two months (Jan, March, May etc.)
2055
+ * If both monthInterval and dayInterval are undefined, it will be set to 3
2056
+ */
2057
+ monthInterval?: number;
2058
+ /**
2059
+ * Identifies days Interval from start date that items can be sent
2060
+ * Default: undefined
2061
+ */
2062
+ dayInterval?: number;
2063
+ /**
2064
+ * Identifies days within each month that items can be sent
2065
+ * If both monthInterval and dayInterval are undefined, it will be default to [28]
2066
+ */
2067
+ daysOfMonth?: number[];
2068
+ }
2069
+
2070
+ /**
2071
+ * Identifies limit number/percentage of items sent per time
2072
+ * If both are provided, minimum number between the two will be used
2073
+ */
2074
+ interface IThrottleLimit {
2075
+ /**
2076
+ * Identifies sampling percentage of items per time
2077
+ * The percentage is set to 4 decimal places, for example: 1 means 0.0001%
2078
+ * Default: 100 (0.01%)
2079
+ */
2080
+ samplingRate?: number;
2081
+ /**
2082
+ * Identifies limit number of items per time
2083
+ * Default: 1
2084
+ */
2085
+ maxSendNumber?: number;
2086
+ }
2087
+
2088
+ /**
2089
+ * Identifies basic config
2090
+ */
2091
+ interface IThrottleMgrConfig {
2092
+ /**
2093
+ * Identifies if throttle is disabled
2094
+ * Default: false
2095
+ */
2096
+ disabled?: boolean;
2097
+ /**
2098
+ * Identifies limit number/percentage of items sent per time
2099
+ * Default: sampling percentage 0.01% with one item sent per time
2100
+ */
2101
+ limit?: IThrottleLimit;
2102
+ /**
2103
+ * Identifies frequency of items sent
2104
+ * Default: send data on 28th every 3 month each year
2105
+ */
2106
+ interval?: IThrottleInterval;
2107
+ }
2108
+
2109
+ /**
2110
+ * A Timer handler which is returned from {@link scheduleTimeout} which contains functions to
2111
+ * cancel or restart (refresh) the timeout function.
2112
+ *
2113
+ * @since 0.4.4
2114
+ * @group Timer
2115
+ */
2116
+ interface ITimerHandler {
2117
+ /**
2118
+ * Cancels a timeout that was previously scheduled, after calling this function any previously
2119
+ * scheduled timer will not execute.
2120
+ * @example
2121
+ * ```ts
2122
+ * let theTimer = scheduleTimeout(...);
2123
+ * theTimer.cancel();
2124
+ * ```
2125
+ */
2126
+ cancel(): void;
2127
+ /**
2128
+ * Reschedules the timer to call its callback at the previously specified duration
2129
+ * adjusted to the current time. This is useful for refreshing a timer without allocating
2130
+ * a new JavaScript object.
2131
+ *
2132
+ * Using this on a timer that has already called its callback will reactivate the timer.
2133
+ * Calling on a timer that has not yet executed will just reschedule the current timer.
2134
+ * @example
2135
+ * ```ts
2136
+ * let theTimer = scheduleTimeout(...);
2137
+ * // The timer will be restarted (if already executed) or rescheduled (if it has not yet executed)
2138
+ * theTimer.refresh();
2139
+ * ```
2140
+ */
2141
+ refresh(): ITimerHandler;
2142
+ /**
2143
+ * When called, requests that the event loop not exit so long when the ITimerHandler is active.
2144
+ * Calling timer.ref() multiple times will have no effect. By default, all ITimerHandler objects
2145
+ * will create "ref'ed" instances, making it normally unnecessary to call timer.ref() unless
2146
+ * timer.unref() had been called previously.
2147
+ * @since 0.7.0
2148
+ * @returns the ITimerHandler instance
2149
+ * @example
2150
+ * ```ts
2151
+ * let theTimer = createTimeout(...);
2152
+ *
2153
+ * // Make sure the timer is referenced (the default) so that the runtime (Node) does not terminate
2154
+ * // if there is a waiting referenced timer.
2155
+ * theTimer.ref();
2156
+ * ```
2157
+ */
2158
+ ref(): this;
2159
+ /**
2160
+ * When called, the any active ITimerHandler instance will not require the event loop to remain
2161
+ * active (Node.js). If there is no other activity keeping the event loop running, the process may
2162
+ * exit before the ITimerHandler instance callback is invoked. Calling timer.unref() multiple times
2163
+ * will have no effect.
2164
+ * @since 0.7.0
2165
+ * @returns the ITimerHandler instance
2166
+ * @example
2167
+ * ```ts
2168
+ * let theTimer = createTimeout(...);
2169
+ *
2170
+ * // Unreference the timer so that the runtime (Node) may terminate if nothing else is running.
2171
+ * theTimer.unref();
2172
+ * ```
2173
+ */
2174
+ unref(): this;
2175
+ /**
2176
+ * If true, any running referenced `ITimerHandler` instance will keep the Node.js event loop active.
2177
+ * @since 0.7.0
2178
+ * @example
2179
+ * ```ts
2180
+ * let theTimer = createTimeout(...);
2181
+ *
2182
+ * // Unreference the timer so that the runtime (Node) may terminate if nothing else is running.
2183
+ * theTimer.unref();
2184
+ * let hasRef = theTimer.hasRef(); // false
2185
+ *
2186
+ * theTimer.ref();
2187
+ * hasRef = theTimer.hasRef(); // true
2188
+ * ```
2189
+ */
2190
+ hasRef(): boolean;
2191
+ /**
2192
+ * Gets or Sets a flag indicating if the underlying timer is currently enabled and running.
2193
+ * Setting the enabled flag to the same as it's current value has no effect, setting to `true`
2194
+ * when already `true` will not {@link ITimerHandler.refresh | refresh}() the timer.
2195
+ * And setting to 'false` will {@link ITimerHandler.cancel | cancel}() the timer.
2196
+ * @since 0.8.1
2197
+ * @example
2198
+ * ```ts
2199
+ * let theTimer = createTimeout(...);
2200
+ *
2201
+ * // Check if enabled
2202
+ * theTimer.enabled; // false
2203
+ *
2204
+ * // Start the timer
2205
+ * theTimer.enabled = true; // Same as calling refresh()
2206
+ * theTimer.enabled; //true
2207
+ *
2208
+ * // Has no effect as it's already running
2209
+ * theTimer.enabled = true;
2210
+ *
2211
+ * // Will refresh / restart the time
2212
+ * theTimer.refresh()
2213
+ *
2214
+ * let theTimer = scheduleTimeout(...);
2215
+ *
2216
+ * // Check if enabled
2217
+ * theTimer.enabled; // true
2218
+ * ```
2219
+ */
2220
+ enabled: boolean;
2221
+ }
2222
+
2223
+ /**
2224
+ * An interface which provides automatic removal during unloading of the component
2225
+ */
2226
+ interface IUnloadHook {
2227
+ /**
2228
+ * Self remove the referenced component
2229
+ */
2230
+ rm: () => void;
2231
+ }
2232
+
2233
+ /**
2234
+ * Interface which identifiesAdd this hook so that it is automatically removed during unloading
2235
+ * @param hooks - The single hook or an array of IInstrumentHook objects
2236
+ */
2237
+ interface IUnloadHookContainer {
2238
+ add: (hooks: IUnloadHook | IUnloadHook[] | Iterator<IUnloadHook> | ILegacyUnloadHook | ILegacyUnloadHook[] | Iterator<ILegacyUnloadHook>) => void;
2239
+ run: (logger?: IDiagnosticLogger) => void;
2240
+ }
2241
+
2242
+ interface IWatchDetails<T = IConfiguration> {
2243
+ /**
2244
+ * The current config object
2245
+ */
2246
+ cfg: T;
2247
+ /**
2248
+ * Set the value against the provided config/name with the value, the property
2249
+ * will be converted to be dynamic (if not already) as long as the provided config
2250
+ * is already a tracked dynamic object.
2251
+ * @throws TypeError if the provided config is not a monitored dynamic config
2252
+ */
2253
+ set: <C, V>(theConfig: C, name: string, value: V) => V;
2254
+ /**
2255
+ * Set default values for the config if not present.
2256
+ * @param theConfig - The configuration object to set default on (if missing)
2257
+ * @param defaultValues - The default values to apply to the config
2258
+ */
2259
+ setDf: <C>(theConfig: C, defaultValues: IConfigDefaults<C>) => C;
2260
+ /**
2261
+ * Set this named property of the target as referenced, which will cause any object or array instance
2262
+ * to be updated in-place rather than being entirely replaced. All other values will continue to be replaced.
2263
+ * @returns The referenced properties current value
2264
+ */
2265
+ ref: <C, V = any>(target: C, name: string) => V;
2266
+ /**
2267
+ * Set this named property of the target as read-only, which will block this single named property from
2268
+ * ever being changed for the target instance.
2269
+ * This does NOT freeze or seal the instance, it just stops the direct re-assignment of the named property,
2270
+ * if the value is a non-primitive (ie. an object or array) it's properties will still be mutable.
2271
+ * @returns The referenced properties current value
2272
+ */
2273
+ rdOnly: <C, V = any>(target: C, name: string) => V;
2274
+ }
2275
+
2276
+ const LoggingSeverity: EnumValue<typeof eLoggingSeverity>;
2277
+
2278
+ type LoggingSeverity = number | eLoggingSeverity;
2279
+
2280
+ /**
2281
+ * This defines the handler function for when a promise is rejected.
2282
+ * @param value This is the value passed as part of resolving the Promise
2283
+ * @return This may return a value, another Promise or void. @see {@link IPromise.then} for how the value is handled.
2284
+ */
2285
+ type RejectedPromiseHandler<T = never> = (((reason: any) => T | IPromise<T> | PromiseLike<T>) | undefined | null);
2286
+
2287
+ /**
2288
+ * This defines the handler function for when a promise is resolved.
2289
+ * @param value This is the value passed as part of resolving the Promise
2290
+ * @return This may return a value, another Promise or void. @see {@link IPromise.then} for how the value is handled.
2291
+ */
2292
+ type ResolvedPromiseHandler<T, TResult1 = T> = (((value: T) => TResult1 | IPromise<TResult1> | PromiseLike<TResult1>) | undefined | null);
2293
+
2294
+ /**
2295
+ * The EventsDiscardedReason enumeration contains a set of values that specify the reason for discarding an event.
2296
+ */
2297
+ const enum SendRequestReason {
2298
+ /**
2299
+ * No specific reason was specified
2300
+ */
2301
+ Undefined = 0,
2302
+ /**
2303
+ * Events are being sent based on the normal event schedule / timer.
2304
+ */
2305
+ NormalSchedule = 1,
2306
+ /**
2307
+ * A manual flush request was received
2308
+ */
2309
+ ManualFlush = 1,
2310
+ /**
2311
+ * Unload event is being processed
2312
+ */
2313
+ Unload = 2,
2314
+ /**
2315
+ * The event(s) being sent are sync events
2316
+ */
2317
+ SyncEvent = 3,
2318
+ /**
2319
+ * The Channel was resumed
2320
+ */
2321
+ Resumed = 4,
2322
+ /**
2323
+ * The event(s) being sent as a retry
2324
+ */
2325
+ Retry = 5,
2326
+ /**
2327
+ * The SDK is unloading
2328
+ */
2329
+ SdkUnload = 6,
2330
+ /**
2331
+ * Maximum batch size would be exceeded
2332
+ */
2333
+ MaxBatchSize = 10,
2334
+ /**
2335
+ * The Maximum number of events have already been queued
2336
+ */
2337
+ MaxQueuedEvents = 20
2338
+ }
2339
+
2340
+ interface Tags {
2341
+ [key: string]: any;
2342
+ }
2343
+
41
2344
  class TeeChannel extends BaseTelemetryPlugin implements IChannelControlsHost {
42
2345
  readonly identifier: string;
43
2346
  readonly priority: number;
@@ -105,5 +2408,54 @@ declare namespace ApplicationInsights {
105
2408
  getChannel<T extends IPlugin = IPlugin>(pluginIdentifier: string): T;
106
2409
  }
107
2410
 
108
-
2411
+ type TelemetryInitializerFunction = <T extends ITelemetryItem>(item: T) => boolean | void;
2412
+
2413
+ /**
2414
+ * The TelemetryUnloadReason enumeration contains the possible reasons for why a plugin is being unloaded / torndown().
2415
+ */
2416
+ const enum TelemetryUnloadReason {
2417
+ /**
2418
+ * Teardown has been called without any context.
2419
+ */
2420
+ ManualTeardown = 0,
2421
+ /**
2422
+ * Just this plugin is being removed
2423
+ */
2424
+ PluginUnload = 1,
2425
+ /**
2426
+ * This instance of the plugin is being removed and replaced
2427
+ */
2428
+ PluginReplace = 2,
2429
+ /**
2430
+ * The entire SDK is being unloaded
2431
+ */
2432
+ SdkUnload = 50
2433
+ }
2434
+
2435
+ /**
2436
+ * The TelemetryUpdateReason enumeration contains a set of bit-wise values that specify the reason for update request.
2437
+ */
2438
+ const enum TelemetryUpdateReason {
2439
+ /**
2440
+ * Unknown.
2441
+ */
2442
+ Unknown = 0,
2443
+ /**
2444
+ * The configuration has ben updated or changed
2445
+ */
2446
+ ConfigurationChanged = 1,
2447
+ /**
2448
+ * One or more plugins have been added
2449
+ */
2450
+ PluginAdded = 16,
2451
+ /**
2452
+ * One or more plugins have been removed
2453
+ */
2454
+ PluginRemoved = 32
2455
+ }
2456
+
2457
+ type UnloadHandler = (itemCtx: IProcessTelemetryUnloadContext, unloadState: ITelemetryUnloadState) => void;
2458
+
2459
+ type WatcherFunction<T = IConfiguration> = (details: IWatchDetails<T>) => void;
2460
+
109
2461
  }