@microsoft/applicationinsights-properties-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 (57) hide show
  1. package/browser/es5/{ai.props.3.0.7.cjs.js → ai.props.3.0.9.cjs.js} +240 -229
  2. package/browser/es5/ai.props.3.0.9.cjs.js.map +1 -0
  3. package/browser/es5/ai.props.3.0.9.cjs.min.js +6 -0
  4. package/browser/es5/ai.props.3.0.9.cjs.min.js.map +1 -0
  5. package/browser/es5/{ai.props.3.0.7.gbl.js → ai.props.3.0.9.gbl.js} +242 -231
  6. package/browser/es5/ai.props.3.0.9.gbl.js.map +1 -0
  7. package/browser/es5/ai.props.3.0.9.gbl.min.js +6 -0
  8. package/browser/es5/ai.props.3.0.9.gbl.min.js.map +1 -0
  9. package/browser/es5/ai.props.3.0.9.integrity.json +66 -0
  10. package/browser/es5/{ai.props.3.0.7.js → ai.props.3.0.9.js} +242 -231
  11. package/browser/es5/ai.props.3.0.9.js.map +1 -0
  12. package/browser/es5/ai.props.3.0.9.min.js +6 -0
  13. package/browser/es5/ai.props.3.0.9.min.js.map +1 -0
  14. package/browser/es5/ai.props.3.cjs.js +239 -228
  15. package/browser/es5/ai.props.3.cjs.js.map +1 -1
  16. package/browser/es5/ai.props.3.cjs.min.js +2 -2
  17. package/browser/es5/ai.props.3.cjs.min.js.map +1 -1
  18. package/browser/es5/ai.props.3.gbl.js +241 -230
  19. package/browser/es5/ai.props.3.gbl.js.map +1 -1
  20. package/browser/es5/ai.props.3.gbl.min.js +2 -2
  21. package/browser/es5/ai.props.3.gbl.min.js.map +1 -1
  22. package/browser/es5/ai.props.3.integrity.json +25 -25
  23. package/browser/es5/ai.props.3.js +241 -230
  24. package/browser/es5/ai.props.3.js.map +1 -1
  25. package/browser/es5/ai.props.3.min.js +2 -2
  26. package/browser/es5/ai.props.3.min.js.map +1 -1
  27. package/dist/es5/applicationinsights-properties-js.js +239 -228
  28. package/dist/es5/applicationinsights-properties-js.js.map +1 -1
  29. package/dist/es5/applicationinsights-properties-js.min.js +2 -2
  30. package/dist/es5/applicationinsights-properties-js.min.js.map +1 -1
  31. package/dist-es5/Context/Application.js +1 -1
  32. package/dist-es5/Context/Device.js +1 -1
  33. package/dist-es5/Context/Internal.js +2 -2
  34. package/dist-es5/Context/Internal.js.map +1 -1
  35. package/dist-es5/Context/Location.js +1 -1
  36. package/dist-es5/Context/Session.js +1 -1
  37. package/dist-es5/Context/TelemetryTrace.js +1 -1
  38. package/dist-es5/Context/User.js +1 -1
  39. package/dist-es5/Interfaces/IPropTelemetryContext.js +1 -1
  40. package/dist-es5/Interfaces/IPropertiesConfig.js +1 -1
  41. package/dist-es5/PropertiesPlugin.js +1 -1
  42. package/dist-es5/TelemetryContext.js +1 -1
  43. package/dist-es5/__DynamicConstants.js +1 -1
  44. package/dist-es5/applicationinsights-properties-js.js +1 -1
  45. package/package.json +69 -66
  46. package/types/applicationinsights-properties-js.d.ts +2 -2
  47. package/types/applicationinsights-properties-js.namespaced.d.ts +2661 -62
  48. package/browser/es5/ai.props.3.0.7.cjs.js.map +0 -1
  49. package/browser/es5/ai.props.3.0.7.cjs.min.js +0 -6
  50. package/browser/es5/ai.props.3.0.7.cjs.min.js.map +0 -1
  51. package/browser/es5/ai.props.3.0.7.gbl.js.map +0 -1
  52. package/browser/es5/ai.props.3.0.7.gbl.min.js +0 -6
  53. package/browser/es5/ai.props.3.0.7.gbl.min.js.map +0 -1
  54. package/browser/es5/ai.props.3.0.7.integrity.json +0 -66
  55. package/browser/es5/ai.props.3.0.7.js.map +0 -1
  56. package/browser/es5/ai.props.3.0.7.min.js +0 -6
  57. package/browser/es5/ai.props.3.0.7.min.js.map +0 -1
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Microsoft Application Insights properties plugin, 3.0.7
2
+ * Microsoft Application Insights properties plugin, 3.0.9
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  *
5
5
  * Microsoft Application Insights Team
@@ -7,75 +7,2561 @@
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 { IApplication } from '@microsoft/applicationinsights-common';
13
- import { IConfig } from '@microsoft/applicationinsights-common';
14
- import { IConfiguration } from '@microsoft/applicationinsights-core-js';
15
- import { IDevice } from '@microsoft/applicationinsights-common';
16
- import { IDiagnosticLogger } from '@microsoft/applicationinsights-core-js';
17
- import { IDistributedTraceContext } from '@microsoft/applicationinsights-core-js';
18
- import { IInternal } from '@microsoft/applicationinsights-common';
19
- import { ILocation } from '@microsoft/applicationinsights-common';
20
- import { IOperatingSystem } from '@microsoft/applicationinsights-common';
21
- import { IPlugin } from '@microsoft/applicationinsights-core-js';
22
- import { IProcessTelemetryContext } from '@microsoft/applicationinsights-core-js';
23
- import { IPropertiesPlugin } from '@microsoft/applicationinsights-common';
24
- import { ISession } from '@microsoft/applicationinsights-common';
25
- import { ISessionManager } from '@microsoft/applicationinsights-common';
26
- import { ITelemetryContext } from '@microsoft/applicationinsights-common';
27
- import { ITelemetryItem } from '@microsoft/applicationinsights-core-js';
28
- import { ITelemetryPluginChain } from '@microsoft/applicationinsights-core-js';
29
- import { ITelemetryTrace } from '@microsoft/applicationinsights-common';
30
- import { ITraceState } from '@microsoft/applicationinsights-common';
31
- import { IUnloadHookContainer } from '@microsoft/applicationinsights-core-js';
32
- import { IUserContext } from '@microsoft/applicationinsights-common';
33
- import { IWeb } from '@microsoft/applicationinsights-common';
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 IApplication {
420
+ /**
421
+ * The application version.
422
+ */
423
+ ver: string;
424
+ /**
425
+ * The application build version.
426
+ */
427
+ build: string;
428
+ }
429
+
430
+ interface IBaseProcessingContext {
431
+ /**
432
+ * The current core instance for the request
433
+ */
434
+ core: () => IAppInsightsCore;
435
+ /**
436
+ * THe current diagnostic logger for the request
437
+ */
438
+ diagLog: () => IDiagnosticLogger;
439
+ /**
440
+ * Gets the current core config instance
441
+ */
442
+ getCfg: () => IConfiguration;
443
+ /**
444
+ * Gets the named extension config
445
+ */
446
+ getExtCfg: <T>(identifier: string, defaultValue?: IConfigDefaults<T>) => T;
447
+ /**
448
+ * Gets the named config from either the named identifier extension or core config if neither exist then the
449
+ * default value is returned
450
+ * @param identifier - The named extension identifier
451
+ * @param field - The config field name
452
+ * @param defaultValue - The default value to return if no defined config exists
453
+ */
454
+ getConfig: (identifier: string, field: string, defaultValue?: number | string | boolean | string[] | RegExp[] | Function) => number | string | boolean | string[] | RegExp[] | Function;
455
+ /**
456
+ * Helper to allow plugins to check and possibly shortcut executing code only
457
+ * required if there is a nextPlugin
458
+ */
459
+ hasNext: () => boolean;
460
+ /**
461
+ * Returns the next configured plugin proxy
462
+ */
463
+ getNext: () => ITelemetryPluginChain;
464
+ /**
465
+ * Helper to set the next plugin proxy
466
+ */
467
+ setNext: (nextCtx: ITelemetryPluginChain) => void;
468
+ /**
469
+ * Synchronously iterate over the context chain running the callback for each plugin, once
470
+ * every plugin has been executed via the callback, any associated onComplete will be called.
471
+ * @param callback - The function call for each plugin in the context chain
472
+ */
473
+ iterate: <T extends ITelemetryPlugin = ITelemetryPlugin>(callback: (plugin: T) => void) => void;
474
+ /**
475
+ * Set the function to call when the current chain has executed all processNext or unloadNext items.
476
+ * @param onComplete - The onComplete to call
477
+ * @param that - The "this" value to use for the onComplete call, if not provided or undefined defaults to the current context
478
+ * @param args - Any additional arguments to pass to the onComplete function
479
+ */
480
+ onComplete: (onComplete: () => void, that?: any, ...args: any[]) => void;
481
+ /**
482
+ * Create a new context using the core and config from the current instance, returns a new instance of the same type
483
+ * @param plugins - The execution order to process the plugins, if null or not supplied
484
+ * then the current execution order will be copied.
485
+ * @param startAt - The plugin to start processing from, if missing from the execution
486
+ * order then the next plugin will be NOT set.
487
+ */
488
+ createNew: (plugins?: IPlugin[] | ITelemetryPluginChain, startAt?: IPlugin) => IBaseProcessingContext;
489
+ }
490
+
491
+ /**
492
+ * Provides data transmission capabilities
493
+ */
494
+ interface IChannelControls extends ITelemetryPlugin {
495
+ /**
496
+ * Pause sending data
497
+ */
498
+ pause?(): void;
499
+ /**
500
+ * Resume sending data
501
+ */
502
+ resume?(): void;
503
+ /**
504
+ * Tear down the plugin and remove any hooked value, the plugin should be removed so that it is no longer initialized and
505
+ * therefore could be re-initialized after being torn down. The plugin should ensure that once this has been called any further
506
+ * processTelemetry calls are ignored and it just calls the processNext() with the provided context.
507
+ * @param unloadCtx - This is the context that should be used during unloading.
508
+ * @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.
509
+ * @returns boolean - true if the plugin has or will call processNext(), this for backward compatibility as previously teardown was synchronous and returned nothing.
510
+ */
511
+ teardown?: (unloadCtx?: IProcessTelemetryUnloadContext, unloadState?: ITelemetryUnloadState) => void | boolean;
512
+ /**
513
+ * Flush to send data immediately; channel should default to sending data asynchronously. If executing asynchronously and
514
+ * you DO NOT pass a callback function then a [IPromise](https://nevware21.github.io/ts-async/typedoc/interfaces/IPromise.html)
515
+ * will be returned which will resolve once the flush is complete. The actual implementation of the `IPromise`
516
+ * will be a native Promise (if supported) or the default as supplied by [ts-async library](https://github.com/nevware21/ts-async)
517
+ * @param async - send data asynchronously when true
518
+ * @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.
519
+ * If the caller doesn't return true the caller should assume that it may never be called.
520
+ * @param sendReason - specify the reason that you are calling "flush" defaults to ManualFlush (1) if not specified
521
+ * @returns - If a callback is provided `true` to indicate that callback will be called after the flush is complete otherwise the caller
522
+ * should assume that any provided callback will never be called, Nothing or if occurring asynchronously a
523
+ * [IPromise](https://nevware21.github.io/ts-async/typedoc/interfaces/IPromise.html) which will be resolved once the unload is complete,
524
+ * the [IPromise](https://nevware21.github.io/ts-async/typedoc/interfaces/IPromise.html) will only be returned when no callback is provided
525
+ * and async is true.
526
+ */
527
+ flush?(async: boolean, callBack?: (flushComplete?: boolean) => void, sendReason?: SendRequestReason): boolean | void | IPromise<boolean>;
528
+ }
529
+
530
+ /**
531
+ * Configuration settings for how telemetry is sent
532
+ * @export
533
+ * @interface IConfig
534
+ */
535
+ interface IConfig {
536
+ /**
537
+ * The JSON format (normal vs line delimited). True means line delimited JSON.
538
+ */
539
+ emitLineDelimitedJson?: boolean;
540
+ /**
541
+ * An optional account id, if your app groups users into accounts. No spaces, commas, semicolons, equals, or vertical bars.
542
+ */
543
+ accountId?: string;
544
+ /**
545
+ * A session is logged if the user is inactive for this amount of time in milliseconds. Default 30 mins.
546
+ * @default 30*60*1000
547
+ */
548
+ sessionRenewalMs?: number;
549
+ /**
550
+ * A session is logged if it has continued for this amount of time in milliseconds. Default 24h.
551
+ * @default 24*60*60*1000
552
+ */
553
+ sessionExpirationMs?: number;
554
+ /**
555
+ * Max size of telemetry batch. If batch exceeds limit, it is sent and a new batch is started
556
+ * @default 100000
557
+ */
558
+ maxBatchSizeInBytes?: number;
559
+ /**
560
+ * How long to batch telemetry for before sending (milliseconds)
561
+ * @default 15 seconds
562
+ */
563
+ maxBatchInterval?: number;
564
+ /**
565
+ * If true, debugging data is thrown as an exception by the logger. Default false
566
+ * @defaultValue false
567
+ */
568
+ enableDebug?: boolean;
569
+ /**
570
+ * If true, exceptions are not autocollected. Default is false
571
+ * @defaultValue false
572
+ */
573
+ disableExceptionTracking?: boolean;
574
+ /**
575
+ * If true, telemetry is not collected or sent. Default is false
576
+ * @defaultValue false
577
+ */
578
+ disableTelemetry?: boolean;
579
+ /**
580
+ * Percentage of events that will be sent. Default is 100, meaning all events are sent.
581
+ * @defaultValue 100
582
+ */
583
+ samplingPercentage?: number;
584
+ /**
585
+ * 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.
586
+ */
587
+ autoTrackPageVisitTime?: boolean;
588
+ /**
589
+ * Automatically track route changes in Single Page Applications (SPA). If true, each route change will send a new Pageview to Application Insights.
590
+ */
591
+ enableAutoRouteTracking?: boolean;
592
+ /**
593
+ * If true, Ajax calls are not autocollected. Default is false
594
+ * @defaultValue false
595
+ */
596
+ disableAjaxTracking?: boolean;
597
+ /**
598
+ * If true, Fetch requests are not autocollected. Default is false (Since 2.8.0, previously true).
599
+ * @defaultValue false
600
+ */
601
+ disableFetchTracking?: boolean;
602
+ /**
603
+ * 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.
604
+ * @defaultValue undefined.
605
+ */
606
+ excludeRequestFromAutoTrackingPatterns?: string[] | RegExp[];
607
+ /**
608
+ * Provide a way to enrich dependencies logs with context at the beginning of api call.
609
+ * Default is undefined.
610
+ */
611
+ addRequestContext?: (requestContext?: IRequestContext) => ICustomProperties;
612
+ /**
613
+ * 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
614
+ * @defaultValue false
615
+ */
616
+ overridePageViewDuration?: boolean;
617
+ /**
618
+ * 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.
619
+ */
620
+ maxAjaxCallsPerView?: number;
621
+ /**
622
+ * @ignore
623
+ * If false, internal telemetry sender buffers will be checked at startup for items not yet sent. Default is true
624
+ * @defaultValue true
625
+ */
626
+ disableDataLossAnalysis?: boolean;
627
+ /**
628
+ * 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.
629
+ * @defaultValue false
630
+ */
631
+ disableCorrelationHeaders?: boolean;
632
+ /**
633
+ * 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.
634
+ * AI_AND_W3C is provided for back-compatibility with any legacy Application Insights instrumented services
635
+ * @defaultValue AI_AND_W3C
636
+ */
637
+ distributedTracingMode?: DistributedTracingModes;
638
+ /**
639
+ * Disable correlation headers for specific domain
640
+ */
641
+ correlationHeaderExcludedDomains?: string[];
642
+ /**
643
+ * Default false. If true, flush method will not be called when onBeforeUnload, onUnload, onPageHide or onVisibilityChange (hidden state) event(s) trigger.
644
+ */
645
+ disableFlushOnBeforeUnload?: boolean;
646
+ /**
647
+ * Default value of {@link #disableFlushOnBeforeUnload}. If true, flush method will not be called when onPageHide or onVisibilityChange (hidden state) event(s) trigger.
648
+ */
649
+ disableFlushOnUnload?: boolean;
650
+ /**
651
+ * If true, the buffer with all unsent telemetry is stored in session storage. The buffer is restored on page load. Default is true.
652
+ * @defaultValue true
653
+ */
654
+ enableSessionStorageBuffer?: boolean;
655
+ /**
656
+ * If specified, overrides the storage & retrieval mechanism that is used to manage unsent telemetry.
657
+ */
658
+ bufferOverride?: IStorageBuffer;
659
+ /**
660
+ * @deprecated Use either disableCookiesUsage or specify a cookieCfg with the enabled value set.
661
+ * If true, the SDK will not store or read any data from cookies. Default is false. As this field is being deprecated, when both
662
+ * isCookieUseDisabled and disableCookiesUsage are used disableCookiesUsage will take precedent.
663
+ * @defaultValue false
664
+ */
665
+ isCookieUseDisabled?: boolean;
666
+ /**
667
+ * If true, the SDK will not store or read any data from cookies. Default is false.
668
+ * If you have also specified a cookieCfg then enabled property (if specified) will take precedent over this value.
669
+ * @defaultValue false
670
+ */
671
+ disableCookiesUsage?: boolean;
672
+ /**
673
+ * Custom cookie domain. This is helpful if you want to share Application Insights cookies across subdomains.
674
+ * @defaultValue ""
675
+ */
676
+ cookieDomain?: string;
677
+ /**
678
+ * Custom cookie path. This is helpful if you want to share Application Insights cookies behind an application gateway.
679
+ * @defaultValue ""
680
+ */
681
+ cookiePath?: string;
682
+ /**
683
+ * 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)
684
+ * @description
685
+ * @defaultValue false
686
+ */
687
+ isRetryDisabled?: boolean;
688
+ /**
689
+ * @deprecated Used when initizialing from snippet only.
690
+ * The url from where the JS SDK will be downloaded.
691
+ */
692
+ url?: string;
693
+ /**
694
+ * If true, the SDK will not store or read any data from local and session storage. Default is false.
695
+ * @defaultValue false
696
+ */
697
+ isStorageUseDisabled?: boolean;
698
+ /**
699
+ * If false, the SDK will send all telemetry using the [Beacon API](https://www.w3.org/TR/beacon)
700
+ * @defaultValue true
701
+ */
702
+ isBeaconApiDisabled?: boolean;
703
+ /**
704
+ * Don't use XMLHttpRequest or XDomainRequest (for IE < 9) by default instead attempt to use fetch() or sendBeacon.
705
+ * If no other transport is available it will still use XMLHttpRequest
706
+ */
707
+ disableXhr?: boolean;
708
+ /**
709
+ * If fetch keepalive is supported do not use it for sending events during unload, it may still fallback to fetch() without keepalive
710
+ */
711
+ onunloadDisableFetch?: boolean;
712
+ /**
713
+ * 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.
714
+ * @defaultValue null
715
+ */
716
+ sdkExtension?: string;
717
+ /**
718
+ * 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.
719
+ * @defaultValue false
720
+ */
721
+ isBrowserLinkTrackingEnabled?: boolean;
722
+ /**
723
+ * 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
724
+ * @defaultValue null
725
+ */
726
+ appId?: string;
727
+ /**
728
+ * 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
729
+ * @defaultValue false
730
+ */
731
+ enableCorsCorrelation?: boolean;
732
+ /**
733
+ * An optional value that will be used as name postfix for localStorage and session cookie name.
734
+ * @defaultValue null
735
+ */
736
+ namePrefix?: string;
737
+ /**
738
+ * 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.
739
+ * @defaultValue null
740
+ */
741
+ sessionCookiePostfix?: string;
742
+ /**
743
+ * An optional value that will be used as name postfix for user cookie name. If undefined, no postfix is added on user cookie name.
744
+ * @defaultValue null
745
+ */
746
+ userCookiePostfix?: string;
747
+ /**
748
+ * An optional value that will track Request Header through trackDependency function.
749
+ * @defaultValue false
750
+ */
751
+ enableRequestHeaderTracking?: boolean;
752
+ /**
753
+ * An optional value that will track Response Header through trackDependency function.
754
+ * @defaultValue false
755
+ */
756
+ enableResponseHeaderTracking?: boolean;
757
+ /**
758
+ * An optional value that will track Response Error data through trackDependency function.
759
+ * @defaultValue false
760
+ */
761
+ enableAjaxErrorStatusText?: boolean;
762
+ /**
763
+ * Flag to enable looking up and including additional browser window.performance timings
764
+ * in the reported ajax (XHR and fetch) reported metrics.
765
+ * Defaults to false.
766
+ */
767
+ enableAjaxPerfTracking?: boolean;
768
+ /**
769
+ * The maximum number of times to look for the window.performance timings (if available), this
770
+ * is required as not all browsers populate the window.performance before reporting the
771
+ * end of the XHR request and for fetch requests this is added after its complete
772
+ * Defaults to 3
773
+ */
774
+ maxAjaxPerfLookupAttempts?: number;
775
+ /**
776
+ * The amount of time to wait before re-attempting to find the windows.performance timings
777
+ * for an ajax request, time is in milliseconds and is passed directly to setTimeout()
778
+ * Defaults to 25.
779
+ */
780
+ ajaxPerfLookupDelay?: number;
781
+ /**
782
+ * Default false. when tab is closed, the SDK will send all remaining telemetry using the [Beacon API](https://www.w3.org/TR/beacon)
783
+ * @defaultValue false
784
+ */
785
+ onunloadDisableBeacon?: boolean;
786
+ /**
787
+ * @ignore
788
+ * Internal only
789
+ */
790
+ autoExceptionInstrumented?: boolean;
791
+ /**
792
+ *
793
+ */
794
+ correlationHeaderDomains?: string[];
795
+ /**
796
+ * @ignore
797
+ * Internal only
798
+ */
799
+ autoUnhandledPromiseInstrumented?: boolean;
800
+ /**
801
+ * Default false. Define whether to track unhandled promise rejections and report as JS errors.
802
+ * When disableExceptionTracking is enabled (dont track exceptions) this value will be false.
803
+ * @defaultValue false
804
+ */
805
+ enableUnhandledPromiseRejectionTracking?: boolean;
806
+ /**
807
+ * Disable correlation headers using regular expressions
808
+ */
809
+ correlationHeaderExcludePatterns?: RegExp[];
810
+ /**
811
+ * The ability for the user to provide extra headers
812
+ */
813
+ customHeaders?: [{
814
+ header: string;
815
+ value: string;
816
+ }];
817
+ /**
818
+ * Provide user an option to convert undefined field to user defined value.
819
+ */
820
+ convertUndefined?: any;
821
+ /**
822
+ * [Optional] The number of events that can be kept in memory before the SDK starts to drop events. By default, this is 10,000.
823
+ */
824
+ eventsLimitInMem?: number;
825
+ /**
826
+ * [Optional] Disable iKey deprecation error message.
827
+ * @defaultValue true
828
+ */
829
+ disableIkeyDeprecationMessage?: boolean;
830
+ /**
831
+ * [Optional] Flag to indicate whether the internal looking endpoints should be automatically
832
+ * added to the `excludeRequestFromAutoTrackingPatterns` collection. (defaults to true).
833
+ * This flag exists as the provided regex is generic and may unexpectedly match a domain that
834
+ * should not be excluded.
835
+ */
836
+ addIntEndpoints?: boolean;
837
+ /**
838
+ * [Optional] Sets throttle mgr configuration by key
839
+ */
840
+ throttleMgrCfg?: {
841
+ [key: number]: IThrottleMgrConfig;
842
+ };
843
+ }
844
+
845
+ /**
846
+ * The type to identify whether the default value should be applied in preference to the provided value.
847
+ */
848
+ type IConfigCheckFn<V> = (value: V) => boolean;
849
+
850
+ /**
851
+ * The default values with a check function
852
+ */
853
+ interface IConfigDefaultCheck<T, V, C = IConfiguration> {
854
+ /**
855
+ * Callback function to check if the user-supplied value is valid, if not the default will be applied
856
+ */
857
+ isVal?: IConfigCheckFn<V>;
858
+ /**
859
+ * Optional function to allow converting and setting of the default value
860
+ */
861
+ set?: IConfigSetFn<T, V>;
862
+ /**
863
+ * The default value to apply if the user-supplied value is not valid
864
+ */
865
+ v?: V | IConfigDefaults<V, T>;
866
+ /**
867
+ * The default fallback key if the main key is not present, this is the key value from the config
868
+ */
869
+ fb?: keyof T | keyof C | Array<keyof T | keyof C>;
870
+ /**
871
+ * Use this check to determine the default fallback, default only checked whether the property isDefined,
872
+ * therefore `null`; `""` are considered to be valid values.
873
+ */
874
+ dfVal?: (value: any) => boolean;
875
+ /**
876
+ * Specify that any provided value should have the default value(s) merged into the value rather than
877
+ * just using either the default of user provided values. Mergeed objects will automatically be marked
878
+ * as referenced.
879
+ */
880
+ mrg?: boolean;
881
+ /**
882
+ * Set this field of the target as referenced, which will cause any object or array instance
883
+ * to be updated in-place rather than being entirely replaced. All other values will continue to be replaced.
884
+ * This is required for nested default objects to avoid multiple repetitive updates to listeners
885
+ * @returns The referenced properties current value
886
+ */
887
+ ref?: boolean;
888
+ /**
889
+ * Set this field of the target as read-only, which will block this single named property from
890
+ * ever being changed for the target instance.
891
+ * This does NOT freeze or seal the instance, it just stops the direct re-assignment of the named property,
892
+ * if the value is a non-primitive (ie. an object or array) it's properties will still be mutable.
893
+ * @returns The referenced properties current value
894
+ */
895
+ rdOnly?: boolean;
896
+ /**
897
+ * Block the value associated with this property from having it's properties / values converted into
898
+ * dynamic properties, this is generally used to block objects or arrays provided by external libraries
899
+ * which may be a plain object with readonly (non-configurable) or const properties.
900
+ */
901
+ blkVal?: boolean;
902
+ }
903
+
904
+ /**
905
+ * The Type definition to define default values to be applied to the config
906
+ * The value may be either the direct value or a ConfigDefaultCheck definition
907
+ */
908
+ type IConfigDefaults<T, C = IConfiguration> = {
909
+ [key in keyof T]: T[key] | IConfigDefaultCheck<T, T[key], C>;
910
+ };
911
+
912
+ /**
913
+ * The type which identifies the function use to validate the user supplied value
914
+ */
915
+ type IConfigSetFn<T, V> = (value: any, defValue: V, theConfig: T) => V;
916
+
917
+ /**
918
+ * Configuration provided to SDK core
919
+ */
920
+ interface IConfiguration {
921
+ /**
922
+ * Instrumentation key of resource. Either this or connectionString must be specified.
923
+ */
924
+ instrumentationKey?: string;
925
+ /**
926
+ * Connection string of resource. Either this or instrumentationKey must be specified.
927
+ */
928
+ connectionString?: string;
929
+ /**
930
+ * Set the timer interval (in ms) for internal logging queue, this is the
931
+ * amount of time to wait after logger.queue messages are detected to be sent.
932
+ * Note: since 3.0.1 and 2.8.13 the diagnostic logger timer is a normal timeout timer
933
+ * and not an interval timer. So this now represents the timer "delay" and not
934
+ * the frequency at which the events are sent.
935
+ */
936
+ diagnosticLogInterval?: number;
937
+ /**
938
+ * Maximum number of iKey transmitted logging telemetry per page view
939
+ */
940
+ maxMessageLimit?: number;
941
+ /**
942
+ * Console logging level. All logs with a severity level higher
943
+ * than the configured level will be printed to console. Otherwise
944
+ * they are suppressed. ie Level 2 will print both CRITICAL and
945
+ * WARNING logs to console, level 1 prints only CRITICAL.
946
+ *
947
+ * Note: Logs sent as telemetry to instrumentation key will also
948
+ * be logged to console if their severity meets the configured loggingConsoleLevel
949
+ *
950
+ * 0: ALL console logging off
951
+ * 1: logs to console: severity >= CRITICAL
952
+ * 2: logs to console: severity >= WARNING
953
+ */
954
+ loggingLevelConsole?: number;
955
+ /**
956
+ * Telemtry logging level to instrumentation key. All logs with a severity
957
+ * level higher than the configured level will sent as telemetry data to
958
+ * the configured instrumentation key.
959
+ *
960
+ * 0: ALL iKey logging off
961
+ * 1: logs to iKey: severity >= CRITICAL
962
+ * 2: logs to iKey: severity >= WARNING
963
+ */
964
+ loggingLevelTelemetry?: number;
965
+ /**
966
+ * If enabled, uncaught exceptions will be thrown to help with debugging
967
+ */
968
+ enableDebug?: boolean;
969
+ /**
970
+ * Endpoint where telemetry data is sent
971
+ */
972
+ endpointUrl?: string;
973
+ /**
974
+ * Extension configs loaded in SDK
975
+ */
976
+ extensionConfig?: {
977
+ [key: string]: any;
978
+ };
979
+ /**
980
+ * Additional plugins that should be loaded by core at runtime
981
+ */
982
+ readonly extensions?: ITelemetryPlugin[];
983
+ /**
984
+ * Channel queues that is setup by caller in desired order.
985
+ * If channels are provided here, core will ignore any channels that are already setup, example if there is a SKU with an initialized channel
986
+ */
987
+ readonly channels?: IChannelControls[][];
988
+ /**
989
+ * @type {boolean}
990
+ * Flag that disables the Instrumentation Key validation.
991
+ */
992
+ disableInstrumentationKeyValidation?: boolean;
993
+ /**
994
+ * [Optional] When enabled this will create local perfEvents based on sections of the code that have been instrumented
995
+ * to emit perfEvents (via the doPerf()) when this is enabled. This can be used to identify performance issues within
996
+ * the SDK, the way you are using it or optionally your own instrumented code.
997
+ * The provided IPerfManager implementation does NOT send any additional telemetry events to the server it will only fire
998
+ * the new perfEvent() on the INotificationManager which you can listen to.
999
+ * This also does not use the window.performance API, so it will work in environments where this API is not supported.
1000
+ */
1001
+ enablePerfMgr?: boolean;
1002
+ /**
1003
+ * [Optional] Callback function that will be called to create a the IPerfManager instance when required and ```enablePerfMgr```
1004
+ * is enabled, this enables you to override the default creation of a PerfManager() without needing to ```setPerfMgr()```
1005
+ * after initialization.
1006
+ */
1007
+ createPerfMgr?: (core: IAppInsightsCore, notificationManager: INotificationManager) => IPerfManager;
1008
+ /**
1009
+ * [Optional] Fire every single performance event not just the top level root performance event. Defaults to false.
1010
+ */
1011
+ perfEvtsSendAll?: boolean;
1012
+ /**
1013
+ * [Optional] Identifies the default length used to generate random session and user id's if non currently exists for the user / session.
1014
+ * Defaults to 22, previous default value was 5, if you need to keep the previous maximum length you should set this value to 5.
1015
+ */
1016
+ idLength?: number;
1017
+ /**
1018
+ * @description Custom cookie domain. This is helpful if you want to share Application Insights cookies across subdomains. It
1019
+ * can be set here or as part of the cookieCfg.domain, the cookieCfg takes precedence if both are specified.
1020
+ * @type {string}
1021
+ * @defaultValue ""
1022
+ */
1023
+ cookieDomain?: string;
1024
+ /**
1025
+ * @description Custom cookie path. This is helpful if you want to share Application Insights cookies behind an application
1026
+ * gateway. It can be set here or as part of the cookieCfg.domain, the cookieCfg takes precedence if both are specified.
1027
+ * @type {string}
1028
+ * @defaultValue ""
1029
+ */
1030
+ cookiePath?: string;
1031
+ /**
1032
+ * [Optional] A boolean that indicated whether to disable the use of cookies by the SDK. If true, the SDK will not store or
1033
+ * read any data from cookies. Cookie usage can be re-enabled after initialization via the core.getCookieMgr().enable().
1034
+ */
1035
+ disableCookiesUsage?: boolean;
1036
+ /**
1037
+ * [Optional] A Cookie Manager configuration which includes hooks to allow interception of the get, set and delete cookie
1038
+ * operations. If this configuration is specified any specified enabled and domain properties will take precedence over the
1039
+ * cookieDomain and disableCookiesUsage values.
1040
+ */
1041
+ cookieCfg?: ICookieMgrConfig;
1042
+ /**
1043
+ * [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
1044
+ * 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.
1045
+ * Unload events include "beforeunload", "unload", "visibilitychange" (with 'hidden' state) and "pagehide"
1046
+ */
1047
+ disablePageUnloadEvents?: string[];
1048
+ /**
1049
+ * [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
1050
+ * 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.
1051
+ * Page Show events include "pageshow" and "visibilitychange" (with 'visible' state)
1052
+ */
1053
+ disablePageShowEvents?: string[];
1054
+ /**
1055
+ * [Optional] A flag for performance optimization to disable attempting to use the Chrome Debug Extension, if disabled and the extension is installed
1056
+ * this will not send any notifications.
1057
+ */
1058
+ disableDbgExt?: boolean;
1059
+ /**
1060
+ * Add "&w=0" parameter to support UA Parsing when web-workers don't have access to Document.
1061
+ * Default is false
1062
+ */
1063
+ enableWParam?: boolean;
1064
+ /**
1065
+ * Custom optional value that will be added as a prefix for storage name.
1066
+ * @defaultValue undefined
1067
+ */
1068
+ storagePrefix?: string;
1069
+ /**
1070
+ * Custom optional value to opt in features
1071
+ * @defaultValue undefined
1072
+ */
1073
+ featureOptIn?: IFeatureOptIn;
1074
+ }
1075
+
1076
+ interface ICookieMgr {
1077
+ /**
1078
+ * Enable or Disable the usage of cookies
1079
+ */
1080
+ setEnabled(value: boolean): void;
1081
+ /**
1082
+ * Can the system use cookies, if this returns false then all cookie setting and access functions will return nothing
1083
+ */
1084
+ isEnabled(): boolean;
1085
+ /**
1086
+ * Set the named cookie with the value and optional domain and optional
1087
+ * @param name - The name of the cookie
1088
+ * @param value - The value of the cookie (Must already be encoded)
1089
+ * @param maxAgeSec - [optional] The maximum number of SECONDS that this cookie should survive
1090
+ * @param domain - [optional] The domain to set for the cookie
1091
+ * @param path - [optional] Path to set for the cookie, if not supplied will default to "/"
1092
+ * @returns - True if the cookie was set otherwise false (Because cookie usage is not enabled or available)
1093
+ */
1094
+ set(name: string, value: string, maxAgeSec?: number, domain?: string, path?: string): boolean;
1095
+ /**
1096
+ * Get the value of the named cookie
1097
+ * @param name - The name of the cookie
1098
+ */
1099
+ get(name: string): string;
1100
+ /**
1101
+ * Delete/Remove the named cookie if cookie support is available and enabled.
1102
+ * Note: Not using "delete" as the name because it's a reserved word which would cause issues on older browsers
1103
+ * @param name - The name of the cookie
1104
+ * @param path - [optional] Path to set for the cookie, if not supplied will default to "/"
1105
+ * @returns - True if the cookie was marked for deletion otherwise false (Because cookie usage is not enabled or available)
1106
+ */
1107
+ del(name: string, path?: string): boolean;
1108
+ /**
1109
+ * Purge the cookie from the system if cookie support is available, this function ignores the enabled setting of the manager
1110
+ * so any cookie will be removed.
1111
+ * Note: Not using "delete" as the name because it's a reserved word which would cause issues on older browsers
1112
+ * @param name - The name of the cookie
1113
+ * @param path - [optional] Path to set for the cookie, if not supplied will default to "/"
1114
+ * @returns - True if the cookie was marked for deletion otherwise false (Because cookie usage is not available)
1115
+ */
1116
+ purge(name: string, path?: string): boolean;
1117
+ /**
1118
+ * Optional Callback hook to allow the cookie manager to update it's configuration, not generally implemented now that
1119
+ * dynamic configuration is supported
1120
+ * @param updateState
1121
+ */
1122
+ update?(updateState: ITelemetryUpdateState): void;
1123
+ /**
1124
+ * Unload and remove any state that this ICookieMgr may be holding, this is generally called when the
1125
+ * owning SDK is being unloaded.
1126
+ * @param isAsync - Can the unload be performed asynchronously (default)
1127
+ * @return If the unload occurs synchronously then nothing should be returned, if happening asynchronously then
1128
+ * the function should return an [IPromise](https://nevware21.github.io/ts-async/typedoc/interfaces/IPromise.html)
1129
+ * / Promise to allow any listeners to wait for the operation to complete.
1130
+ */
1131
+ unload?(isAsync?: boolean): void | IPromise<void>;
1132
+ }
1133
+
1134
+ /**
1135
+ * Configuration definition for instance based cookie management configuration
1136
+ */
1137
+ interface ICookieMgrConfig {
1138
+ /**
1139
+ * Defaults to true, A boolean that indicates whether the use of cookies by the SDK is enabled by the current instance.
1140
+ * If false, the instance of the SDK initialized by this configuration will not store or read any data from cookies
1141
+ */
1142
+ enabled?: boolean;
1143
+ /**
1144
+ * Custom cookie domain. This is helpful if you want to share Application Insights cookies across subdomains.
1145
+ */
1146
+ domain?: string;
1147
+ /**
1148
+ * Specifies the path to use for the cookie, defaults to '/'
1149
+ */
1150
+ path?: string;
1151
+ /**
1152
+ * Specify the cookie name(s) to be ignored, this will cause any matching cookie name to never be read or written.
1153
+ * They may still be explicitly purged or deleted. You do not need to repeat the name in the `blockedCookies`
1154
+ * configuration.(Since v2.8.8)
1155
+ */
1156
+ ignoreCookies?: string[];
1157
+ /**
1158
+ * Specify the cookie name(s) to never be written, this will cause any cookie name to never be created or updated,
1159
+ * they will still be read unless also included in the ignoreCookies and may still be explicitly purged or deleted.
1160
+ * If not provided defaults to the same list provided in ignoreCookies. (Since v2.8.8)
1161
+ */
1162
+ blockedCookies?: string[];
1163
+ /**
1164
+ * Hook function to fetch the named cookie value.
1165
+ * @param name - The name of the cookie
1166
+ */
1167
+ getCookie?: (name: string) => string;
1168
+ /**
1169
+ * Hook function to set the named cookie with the specified value.
1170
+ * @param name - The name of the cookie
1171
+ * @param value - The value to set for the cookie
1172
+ */
1173
+ setCookie?: (name: string, value: string) => void;
1174
+ /**
1175
+ * Hook function to delete the named cookie with the specified value, separated from
1176
+ * setCookie to avoid the need to parse the value to determine whether the cookie is being
1177
+ * added or removed.
1178
+ * @param name - The name of the cookie
1179
+ * @param cookieValue - The value to set to expire the cookie
1180
+ */
1181
+ delCookie?: (name: string, cookieValue: string) => void;
1182
+ }
1183
+
1184
+ interface ICustomProperties {
1185
+ [key: string]: any;
1186
+ }
1187
+
1188
+ interface IDevice {
1189
+ /**
1190
+ * The type for the current device.
1191
+ */
1192
+ deviceClass: string;
1193
+ /**
1194
+ * A device unique ID.
1195
+ */
1196
+ id: string;
1197
+ /**
1198
+ * The device model for the current device.
1199
+ */
1200
+ model: string;
1201
+ /**
1202
+ * The application screen resolution.
1203
+ */
1204
+ resolution: string;
1205
+ /**
1206
+ * The IP address.
1207
+ */
1208
+ ip: string;
1209
+ }
1210
+
1211
+ interface IDiagnosticLogger {
1212
+ /**
1213
+ * 0: OFF
1214
+ * 1: only critical (default)
1215
+ * 2: critical + info
1216
+ */
1217
+ consoleLoggingLevel: () => number;
1218
+ /**
1219
+ * The internal logging queue
1220
+ */
1221
+ queue: _InternalLogMessage[];
1222
+ /**
1223
+ * This method will throw exceptions in debug mode or attempt to log the error as a console warning.
1224
+ * @param severity - The severity of the log message
1225
+ * @param message - The log message.
1226
+ */
1227
+ throwInternal(severity: LoggingSeverity, msgId: _InternalMessageId, msg: string, properties?: Object, isUserAct?: boolean): void;
1228
+ /**
1229
+ * This will write a debug message to the console if possible
1230
+ * @param message - {string} - The debug message
1231
+ */
1232
+ debugToConsole?(message: string): void;
1233
+ /**
1234
+ * This will write a warning to the console if possible
1235
+ * @param message - The warning message
1236
+ */
1237
+ warnToConsole(message: string): void;
1238
+ /**
1239
+ * This will write an error to the console if possible.
1240
+ * Provided by the default DiagnosticLogger instance, and internally the SDK will fall back to warnToConsole, however,
1241
+ * direct callers MUST check for its existence on the logger as you can provide your own IDiagnosticLogger instance.
1242
+ * @param message - The error message
1243
+ */
1244
+ errorToConsole?(message: string): void;
1245
+ /**
1246
+ * Resets the internal message count
1247
+ */
1248
+ resetInternalMessageCount(): void;
1249
+ /**
1250
+ * Logs a message to the internal queue.
1251
+ * @param severity - The severity of the log message
1252
+ * @param message - The message to log.
1253
+ */
1254
+ logInternalMessage?(severity: LoggingSeverity, message: _InternalLogMessage): void;
1255
+ /**
1256
+ * Optional Callback hook to allow the diagnostic logger to update it's configuration
1257
+ * @param updateState
1258
+ */
1259
+ update?(updateState: ITelemetryUpdateState): void;
1260
+ /**
1261
+ * Unload and remove any state that this IDiagnosticLogger may be holding, this is generally called when the
1262
+ * owning SDK is being unloaded.
1263
+ * @param isAsync - Can the unload be performed asynchronously (default)
1264
+ * @return If the unload occurs synchronously then nothing should be returned, if happening asynchronously then
1265
+ * the function should return an [IPromise](https://nevware21.github.io/ts-async/typedoc/interfaces/IPromise.html)
1266
+ * / Promise to allow any listeners to wait for the operation to complete.
1267
+ */
1268
+ unload?(isAsync?: boolean): void | IPromise<void>;
1269
+ }
1270
+
1271
+ interface IDistributedTraceContext {
1272
+ /**
1273
+ * Returns the current name of the page
1274
+ */
1275
+ getName(): string;
1276
+ /**
1277
+ * Sets the current name of the page
1278
+ * @param pageName
1279
+ */
1280
+ setName(pageName: string): void;
1281
+ /**
1282
+ * Returns the unique identifier for a trace. All requests / spans from the same trace share the same traceId.
1283
+ * Must be read from incoming headers or generated according to the W3C TraceContext specification,
1284
+ * in a hex representation of 16-byte array. A.k.a. trace-id, TraceID or Distributed TraceID
1285
+ */
1286
+ getTraceId(): string;
1287
+ /**
1288
+ * Set the unique identifier for a trace. All requests / spans from the same trace share the same traceId.
1289
+ * Must be conform to the W3C TraceContext specification, in a hex representation of 16-byte array.
1290
+ * A.k.a. trace-id, TraceID or Distributed TraceID https://www.w3.org/TR/trace-context/#trace-id
1291
+ */
1292
+ setTraceId(newValue: string): void;
1293
+ /**
1294
+ * Self-generated 8-bytes identifier of the incoming request. Must be a hex representation of 8-byte array.
1295
+ * Also know as the parentId, used to link requests together
1296
+ */
1297
+ getSpanId(): string;
1298
+ /**
1299
+ * Self-generated 8-bytes identifier of the incoming request. Must be a hex representation of 8-byte array.
1300
+ * Also know as the parentId, used to link requests together
1301
+ * https://www.w3.org/TR/trace-context/#parent-id
1302
+ */
1303
+ setSpanId(newValue: string): void;
1304
+ /**
1305
+ * An integer representation of the W3C TraceContext trace-flags.
1306
+ */
1307
+ getTraceFlags(): number | undefined;
1308
+ /**
1309
+ * https://www.w3.org/TR/trace-context/#trace-flags
1310
+ * @param newValue
1311
+ */
1312
+ setTraceFlags(newValue?: number): void;
1313
+ }
1314
+
1315
+ interface IFeatureOptIn {
1316
+ [feature: string]: IFeatureOptInDetails;
1317
+ }
1318
+
1319
+ interface IFeatureOptInDetails {
1320
+ /**
1321
+ * sets feature opt-in mode
1322
+ * @default undefined
1323
+ */
1324
+ mode?: FeatureOptInMode;
1325
+ /**
1326
+ * Identifies configuration override values when given feature is enabled
1327
+ * NOTE: should use flat string for fields, for example, if you want to set value for extensionConfig.Ananlytics.disableAjaxTrackig in configurations,
1328
+ * you should use "extensionConfig.Ananlytics.disableAjaxTrackig" as field name: {["extensionConfig.Analytics.disableAjaxTrackig"]:1}
1329
+ * Default: undefined
1330
+ */
1331
+ onCfg?: {
1332
+ [field: string]: any;
1333
+ };
1334
+ /**
1335
+ * Identifies configuration override values when given feature is disabled
1336
+ * NOTE: should use flat string for fields, for example, if you want to set value for extensionConfig.Ananlytics.disableAjaxTrackig in configurations,
1337
+ * you should use "extensionConfig.Ananlytics.disableAjaxTrackig" as field name: {["extensionConfig.Analytics.disableAjaxTrackig"]:1}
1338
+ * Default: undefined
1339
+ */
1340
+ offCfg?: {
1341
+ [field: string]: any;
1342
+ };
1343
+ /**
1344
+ * define if should block any changes from cdn cfg, if set to true, cfgValue will be applied under all scenarios
1345
+ * @default false
1346
+ */
1347
+ blockCdnCfg?: boolean;
1348
+ }
1349
+
1350
+ interface IInternal {
1351
+ /**
1352
+ * The SDK version used to create this telemetry item.
1353
+ */
1354
+ sdkVersion: string;
1355
+ /**
1356
+ * The SDK agent version.
1357
+ */
1358
+ agentVersion: string;
1359
+ /**
1360
+ * The Snippet version used to initialize the sdk instance, this will contain either
1361
+ * undefined/null - Snippet not used
1362
+ * '-' - Version and legacy mode not determined
1363
+ * # - Version # of the snippet
1364
+ * #.l - Version # in legacy mode
1365
+ * .l - No defined version, but used legacy mode initialization
1366
+ */
1367
+ snippetVer: string;
1368
+ /**
1369
+ * Identifies the source of the sdk script
1370
+ */
1371
+ sdkSrc: string;
1372
+ }
1373
+
1374
+ /**
1375
+ * An alternate interface which provides automatic removal during unloading of the component
1376
+ */
1377
+ interface ILegacyUnloadHook {
1378
+ /**
1379
+ * Legacy Self remove the referenced component
1380
+ */
1381
+ remove: () => void;
1382
+ }
1383
+
1384
+ interface ILoadedPlugin<T extends IPlugin> {
1385
+ plugin: T;
1386
+ /**
1387
+ * Identifies whether the plugin is enabled and can process events. This is slightly different from isInitialized as the plugin may be initialized but disabled
1388
+ * via the setEnabled() or it may be a shared plugin which has had it's teardown function called from another instance..
1389
+ * @returns boolean = true if the plugin is in a state where it is operational.
1390
+ */
1391
+ isEnabled: () => boolean;
1392
+ /**
1393
+ * You can optionally enable / disable a plugin from processing events.
1394
+ * Setting enabled to true will not necessarily cause the `isEnabled()` to also return true
1395
+ * as the plugin must also have been successfully initialized and not had it's `teardown` method called
1396
+ * (unless it's also been re-initialized)
1397
+ */
1398
+ setEnabled: (isEnabled: boolean) => void;
1399
+ remove: (isAsync?: boolean, removeCb?: (removed?: boolean) => void) => void;
1400
+ }
1401
+
1402
+ interface ILocation {
1403
+ /**
1404
+ * Client IP address for reverse lookup
1405
+ */
1406
+ ip: string;
1407
+ }
1408
+
1409
+ /**
1410
+ * An interface used for the notification listener.
1411
+ * @interface
1412
+ */
1413
+ interface INotificationListener {
1414
+ /**
1415
+ * [Optional] A function called when events are sent.
1416
+ * @param events - The array of events that have been sent.
1417
+ */
1418
+ eventsSent?: (events: ITelemetryItem[]) => void;
1419
+ /**
1420
+ * [Optional] A function called when events are discarded.
1421
+ * @param events - The array of events that have been discarded.
1422
+ * @param reason - The reason for discarding the events. The EventsDiscardedReason
1423
+ * constant should be used to check the different values.
1424
+ */
1425
+ eventsDiscarded?: (events: ITelemetryItem[], reason: number) => void;
1426
+ /**
1427
+ * [Optional] A function called when the events have been requested to be sent to the sever.
1428
+ * @param sendReason - The reason why the event batch is being sent.
1429
+ * @param isAsync - A flag which identifies whether the requests are being sent in an async or sync manner.
1430
+ */
1431
+ eventsSendRequest?: (sendReason: number, isAsync?: boolean) => void;
1432
+ /**
1433
+ * [Optional] This event is sent if you have enabled perf events, they are primarily used to track internal performance testing and debugging
1434
+ * the event can be displayed via the debug plugin extension.
1435
+ * @param perfEvent
1436
+ */
1437
+ perfEvent?: (perfEvent: IPerfEvent) => void;
1438
+ /**
1439
+ * Unload and remove any state that this INotificationListener may be holding, this is generally called when the
1440
+ * owning Manager is being unloaded.
1441
+ * @param isAsync - Can the unload be performed asynchronously (default)
1442
+ * @return If the unload occurs synchronously then nothing should be returned, if happening asynchronously then
1443
+ * the function should return an [IPromise](https://nevware21.github.io/ts-async/typedoc/interfaces/IPromise.html)
1444
+ * / Promise to allow any listeners to wait for the operation to complete.
1445
+ */
1446
+ unload?(isAsync?: boolean): void | IPromise<void>;
1447
+ }
1448
+
1449
+ /**
1450
+ * Class to manage sending notifications to all the listeners.
1451
+ */
1452
+ interface INotificationManager {
1453
+ listeners: INotificationListener[];
1454
+ /**
1455
+ * Adds a notification listener.
1456
+ * @param listener - The notification listener to be added.
1457
+ */
1458
+ addNotificationListener(listener: INotificationListener): void;
1459
+ /**
1460
+ * Removes all instances of the listener.
1461
+ * @param listener - AWTNotificationListener to remove.
1462
+ */
1463
+ removeNotificationListener(listener: INotificationListener): void;
1464
+ /**
1465
+ * Notification for events sent.
1466
+ * @param events - The array of events that have been sent.
1467
+ */
1468
+ eventsSent(events: ITelemetryItem[]): void;
1469
+ /**
1470
+ * Notification for events being discarded.
1471
+ * @param events - The array of events that have been discarded by the SDK.
1472
+ * @param reason - The reason for which the SDK discarded the events. The EventsDiscardedReason
1473
+ * constant should be used to check the different values.
1474
+ */
1475
+ eventsDiscarded(events: ITelemetryItem[], reason: number): void;
1476
+ /**
1477
+ * [Optional] A function called when the events have been requested to be sent to the sever.
1478
+ * @param sendReason - The reason why the event batch is being sent.
1479
+ * @param isAsync - A flag which identifies whether the requests are being sent in an async or sync manner.
1480
+ */
1481
+ eventsSendRequest?(sendReason: number, isAsync: boolean): void;
1482
+ /**
1483
+ * [Optional] This event is sent if you have enabled perf events, they are primarily used to track internal performance testing and debugging
1484
+ * the event can be displayed via the debug plugin extension.
1485
+ * @param perfEvent - The perf event details
1486
+ */
1487
+ perfEvent?(perfEvent: IPerfEvent): void;
1488
+ /**
1489
+ * Unload and remove any state that this INotificationManager may be holding, this is generally called when the
1490
+ * owning SDK is being unloaded.
1491
+ * @param isAsync - Can the unload be performed asynchronously (default)
1492
+ * @return If the unload occurs synchronously then nothing should be returned, if happening asynchronously then
1493
+ * the function should return an [IPromise](https://nevware21.github.io/ts-async/typedoc/interfaces/IPromise.html)
1494
+ * / Promise to allow any listeners to wait for the operation to complete.
1495
+ */
1496
+ unload?(isAsync?: boolean): void | IPromise<void>;
1497
+ }
1498
+
1499
+ class _InternalLogMessage {
1500
+ static dataType: string;
1501
+ message: string;
1502
+ messageId: _InternalMessageId;
1503
+ constructor(msgId: _InternalMessageId, msg: string, isUserAct?: boolean, properties?: Object);
1504
+ }
1505
+
1506
+ type _InternalMessageId = number | _eInternalMessageId;
1507
+
1508
+ interface IOperatingSystem {
1509
+ name: string;
1510
+ }
1511
+
1512
+ /**
1513
+ * This interface identifies the details of an internal performance event - it does not represent an outgoing reported event
1514
+ */
1515
+ interface IPerfEvent {
1516
+ /**
1517
+ * The name of the performance event
1518
+ */
1519
+ name: string;
1520
+ /**
1521
+ * The start time of the performance event
1522
+ */
1523
+ start: number;
1524
+ /**
1525
+ * The payload (contents) of the perfEvent, may be null or only set after the event has completed depending on
1526
+ * the runtime environment.
1527
+ */
1528
+ payload: any;
1529
+ /**
1530
+ * Is this occurring from an asynchronous event
1531
+ */
1532
+ isAsync: boolean;
1533
+ /**
1534
+ * Identifies the total inclusive time spent for this event, including the time spent for child events,
1535
+ * this will be undefined until the event is completed
1536
+ */
1537
+ time?: number;
1538
+ /**
1539
+ * Identifies the exclusive time spent in for this event (not including child events),
1540
+ * this will be undefined until the event is completed.
1541
+ */
1542
+ exTime?: number;
1543
+ /**
1544
+ * The Parent event that was started before this event was created
1545
+ */
1546
+ parent?: IPerfEvent;
1547
+ /**
1548
+ * The child perf events that are contained within the total time of this event.
1549
+ */
1550
+ childEvts?: IPerfEvent[];
1551
+ /**
1552
+ * Identifies whether this event is a child event of a parent
1553
+ */
1554
+ isChildEvt: () => boolean;
1555
+ /**
1556
+ * Get the names additional context associated with this perf event
1557
+ */
1558
+ getCtx?: (key: string) => any;
1559
+ /**
1560
+ * Set the named additional context to be associated with this perf event, this will replace any existing value
1561
+ */
1562
+ setCtx?: (key: string, value: any) => void;
1563
+ /**
1564
+ * Mark this event as completed, calculating the total execution time.
1565
+ */
1566
+ complete: () => void;
1567
+ }
1568
+
1569
+ /**
1570
+ * This defines an internal performance manager for tracking and reporting the internal performance of the SDK -- It does
1571
+ * not represent or report any event to the server.
1572
+ */
1573
+ interface IPerfManager {
1574
+ /**
1575
+ * Create a new event and start timing, the manager may return null/undefined to indicate that it does not
1576
+ * want to monitor this source event.
1577
+ * @param src - The source name of the event
1578
+ * @param payloadDetails - An optional callback function to fetch the payload details for the event.
1579
+ * @param isAsync - Is the event occurring from a async event
1580
+ */
1581
+ create(src: string, payloadDetails?: () => any, isAsync?: boolean): IPerfEvent | null | undefined;
1582
+ /**
1583
+ * Complete the perfEvent and fire any notifications.
1584
+ * @param perfEvent - Fire the event which will also complete the passed event
1585
+ */
1586
+ fire(perfEvent: IPerfEvent): void;
1587
+ /**
1588
+ * Set an execution context value
1589
+ * @param key - The context key name
1590
+ * @param value - The value
1591
+ */
1592
+ setCtx(key: string, value: any): void;
1593
+ /**
1594
+ * Get the execution context value
1595
+ * @param key - The context key
1596
+ */
1597
+ getCtx(key: string): any;
1598
+ }
1599
+
1600
+ /**
1601
+ * Identifies an interface to a host that can provide an IPerfManager implementation
1602
+ */
1603
+ interface IPerfManagerProvider {
1604
+ /**
1605
+ * Get the current performance manager
1606
+ */
1607
+ getPerfMgr(): IPerfManager;
1608
+ /**
1609
+ * Set the current performance manager
1610
+ * @param perfMgr - The performance manager
1611
+ */
1612
+ setPerfMgr(perfMgr: IPerfManager): void;
1613
+ }
1614
+
1615
+ interface IPlugin {
1616
+ /**
1617
+ * Initialize plugin loaded by SDK
1618
+ * @param config - The config for the plugin to use
1619
+ * @param core - The current App Insights core to use for initializing this plugin instance
1620
+ * @param extensions - The complete set of extensions to be used for initializing the plugin
1621
+ * @param pluginChain - [Optional] specifies the current plugin chain which identifies the
1622
+ * set of plugins and the order they should be executed for the current request.
1623
+ */
1624
+ initialize: (config: IConfiguration, core: IAppInsightsCore, extensions: IPlugin[], pluginChain?: ITelemetryPluginChain) => void;
1625
+ /**
1626
+ * Returns a value that indicates whether the plugin has already been previously initialized.
1627
+ * New plugins should implement this method to avoid being initialized more than once.
1628
+ */
1629
+ isInitialized?: () => boolean;
1630
+ /**
1631
+ * Tear down the plugin and remove any hooked value, the plugin should be removed so that it is no longer initialized and
1632
+ * therefore could be re-initialized after being torn down. The plugin should ensure that once this has been called any further
1633
+ * processTelemetry calls are ignored and it just calls the processNext() with the provided context.
1634
+ * @param unloadCtx - This is the context that should be used during unloading.
1635
+ * @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.
1636
+ * @returns boolean - true if the plugin has or will call processNext(), this for backward compatibility as previously teardown was synchronous and returned nothing.
1637
+ */
1638
+ teardown?: (unloadCtx: IProcessTelemetryUnloadContext, unloadState?: ITelemetryUnloadState) => void | boolean;
1639
+ /**
1640
+ * Extension name
1641
+ */
1642
+ readonly identifier: string;
1643
+ /**
1644
+ * Plugin version (available in data.properties.version in common schema)
1645
+ */
1646
+ readonly version?: string;
1647
+ /**
1648
+ * The App Insights core to use for backward compatibility.
1649
+ * Therefore the interface will be able to access the core without needing to cast to "any".
1650
+ * [optional] any 3rd party plugins which are already implementing this interface don't fail to compile.
1651
+ */
1652
+ core?: IAppInsightsCore;
1653
+ }
1654
+
1655
+ /**
1656
+ * The current context for the current call to processTelemetry(), used to support sharing the same plugin instance
1657
+ * between multiple AppInsights instances
1658
+ */
1659
+ interface IProcessTelemetryContext extends IBaseProcessingContext {
1660
+ /**
1661
+ * Call back for telemetry processing before it it is sent
1662
+ * @param env - This is the current event being reported
1663
+ * @returns boolean (true) if there is no more plugins to process otherwise false or undefined (void)
1664
+ */
1665
+ processNext: (env: ITelemetryItem) => boolean | void;
1666
+ /**
1667
+ * Create a new context using the core and config from the current instance, returns a new instance of the same type
1668
+ * @param plugins - The execution order to process the plugins, if null or not supplied
1669
+ * then the current execution order will be copied.
1670
+ * @param startAt - The plugin to start processing from, if missing from the execution
1671
+ * order then the next plugin will be NOT set.
1672
+ */
1673
+ createNew: (plugins?: IPlugin[] | ITelemetryPluginChain, startAt?: IPlugin) => IProcessTelemetryContext;
1674
+ }
1675
+
1676
+ /**
1677
+ * The current context for the current call to teardown() implementations, used to support when plugins are being removed
1678
+ * or the SDK is being unloaded.
1679
+ */
1680
+ interface IProcessTelemetryUnloadContext extends IBaseProcessingContext {
1681
+ /**
1682
+ * This Plugin has finished unloading, so unload the next one
1683
+ * @param uploadState - The state of the unload process
1684
+ * @returns boolean (true) if there is no more plugins to process otherwise false or undefined (void)
1685
+ */
1686
+ processNext: (unloadState: ITelemetryUnloadState) => boolean | void;
1687
+ /**
1688
+ * Create a new context using the core and config from the current instance, returns a new instance of the same type
1689
+ * @param plugins - The execution order to process the plugins, if null or not supplied
1690
+ * then the current execution order will be copied.
1691
+ * @param startAt - The plugin to start processing from, if missing from the execution
1692
+ * order then the next plugin will be NOT set.
1693
+ */
1694
+ createNew: (plugins?: IPlugin[] | ITelemetryPluginChain, startAt?: IPlugin) => IProcessTelemetryUnloadContext;
1695
+ }
1696
+
1697
+ /**
1698
+ * The current context for the current call to the plugin update() implementations, used to support the notifications
1699
+ * for when plugins are added, removed or the configuration was changed.
1700
+ */
1701
+ interface IProcessTelemetryUpdateContext extends IBaseProcessingContext {
1702
+ /**
1703
+ * This Plugin has finished unloading, so unload the next one
1704
+ * @param updateState - The update State
1705
+ * @returns boolean (true) if there is no more plugins to process otherwise false or undefined (void)
1706
+ */
1707
+ processNext: (updateState: ITelemetryUpdateState) => boolean | void;
1708
+ /**
1709
+ * Create a new context using the core and config from the current instance, returns a new instance of the same type
1710
+ * @param plugins - The execution order to process the plugins, if null or not supplied
1711
+ * then the current execution order will be copied.
1712
+ * @param startAt - The plugin to start processing from, if missing from the execution
1713
+ * order then the next plugin will be NOT set.
1714
+ */
1715
+ createNew: (plugins?: IPlugin[] | ITelemetryPluginChain, startAt?: IPlugin) => IProcessTelemetryUpdateContext;
1716
+ }
1717
+
1718
+ /**
1719
+ * Create a Promise object that represents the eventual completion (or failure) of an asynchronous operation and its resulting value.
1720
+ * This interface definition, closely mirrors the typescript / javascript PromiseLike<T> and Promise<T> definitions as well as providing
1721
+ * simular functions as that provided by jQuery deferred objects.
1722
+ *
1723
+ * The returned Promise is a proxy for a value not necessarily known when the promise is created. It allows you to associate handlers
1724
+ * with an asynchronous action's eventual success value or failure reason. This lets asynchronous methods return values like synchronous
1725
+ * methods: instead of immediately returning the final value, the asynchronous method returns a promise to supply the value at some point
1726
+ * in the future.
1727
+ *
1728
+ * A Promise is in one of these states:
1729
+ * <ul>
1730
+ * <li> pending: initial state, neither fulfilled nor rejected.
1731
+ * <li> fulfilled: meaning that the operation was completed successfully.
1732
+ * <li> rejected: meaning that the operation failed.
1733
+ * </ul>
1734
+ *
1735
+ * A pending promise can either be fulfilled with a value or rejected with a reason (error). When either of these options happens, the
1736
+ * associated handlers queued up by a promise's then method are called synchronously. If the promise has already been fulfilled or rejected
1737
+ * when a corresponding handler is attached, the handler will be called synchronously, so there is no race condition between an asynchronous
1738
+ * operation completing and its handlers being attached.
1739
+ *
1740
+ * As the `then()` and `catch()` methods return promises, they can be chained.
1741
+ * @typeParam T - Identifies the expected return type from the promise
1742
+ */
1743
+ interface IPromise<T> extends PromiseLike<T>, Promise<T> {
1744
+ /**
1745
+ * Returns a string representation of the current state of the promise. The promise can be in one of four states.
1746
+ * <ul>
1747
+ * <li> <b>"pending"</b>: The promise is not yet in a completed state (neither "rejected"; or "resolved").</li>
1748
+ * <li> <b>"resolved"</b>: The promise is in the resolved state.</li>
1749
+ * <li> <b>"rejected"</b>: The promise is in the rejected state.</li>
1750
+ * </ul>
1751
+ * @example
1752
+ * ```ts
1753
+ * let doResolve;
1754
+ * let promise: IPromise<any> = createSyncPromise((resolve) => {
1755
+ * doResolve = resolve;
1756
+ * });
1757
+ *
1758
+ * let state: string = promise.state();
1759
+ * console.log("State: " + state); // State: pending
1760
+ * doResolve(true); // Promise will resolve synchronously as it's a synchronous promise
1761
+ * console.log("State: " + state); // State: resolved
1762
+ * ```
1763
+ */
1764
+ state?: string;
1765
+ /**
1766
+ * Attaches callbacks for the resolution and/or rejection of the Promise.
1767
+ * @param onResolved The callback to execute when the Promise is resolved.
1768
+ * @param onRejected The callback to execute when the Promise is rejected.
1769
+ * @returns A Promise for the completion of which ever callback is executed.
1770
+ * @example
1771
+ * ```ts
1772
+ * const promise1 = createPromise((resolve, reject) => {
1773
+ * resolve('Success!');
1774
+ * });
1775
+ *
1776
+ * promise1.then((value) => {
1777
+ * console.log(value);
1778
+ * // expected output: "Success!"
1779
+ * });
1780
+ * ```
1781
+ */
1782
+ then<TResult1 = T, TResult2 = never>(onResolved?: ResolvedPromiseHandler<T, TResult1>, onRejected?: RejectedPromiseHandler<TResult2>): IPromise<TResult1 | TResult2>;
1783
+ /**
1784
+ * Attaches callbacks for the resolution and/or rejection of the Promise.
1785
+ * @param onResolved The callback to execute when the Promise is resolved.
1786
+ * @param onRejected The callback to execute when the Promise is rejected.
1787
+ * @returns A Promise for the completion of which ever callback is executed.
1788
+ * @example
1789
+ * ```ts
1790
+ * const promise1 = createPromise((resolve, reject) => {
1791
+ * resolve('Success!');
1792
+ * });
1793
+ *
1794
+ * promise1.then((value) => {
1795
+ * console.log(value);
1796
+ * // expected output: "Success!"
1797
+ * });
1798
+ * ```
1799
+ */
1800
+ then<TResult1 = T, TResult2 = never>(onResolved?: ResolvedPromiseHandler<T, TResult1>, onRejected?: RejectedPromiseHandler<TResult2>): PromiseLike<TResult1 | TResult2>;
1801
+ /**
1802
+ * Attaches callbacks for the resolution and/or rejection of the Promise.
1803
+ * @param onResolved The callback to execute when the Promise is resolved.
1804
+ * @param onRejected The callback to execute when the Promise is rejected.
1805
+ * @returns A Promise for the completion of which ever callback is executed.
1806
+ * @example
1807
+ * ```ts
1808
+ * const promise1 = createPromise((resolve, reject) => {
1809
+ * resolve('Success!');
1810
+ * });
1811
+ *
1812
+ * promise1.then((value) => {
1813
+ * console.log(value);
1814
+ * // expected output: "Success!"
1815
+ * });
1816
+ * ```
1817
+ */
1818
+ then<TResult1 = T, TResult2 = never>(onResolved?: ResolvedPromiseHandler<T, TResult1>, onRejected?: RejectedPromiseHandler<TResult2>): Promise<TResult1 | TResult2>;
1819
+ /**
1820
+ * Attaches a callback for only the rejection of the Promise.
1821
+ * @param onRejected The callback to execute when the Promise is rejected.
1822
+ * @returns A Promise for the completion of the callback.
1823
+ * @example
1824
+ * ```ts
1825
+ * const promise1 = createPromise((resolve, reject) => {
1826
+ * throw 'Uh-oh!';
1827
+ * });
1828
+ *
1829
+ * promise1.catch((error) => {
1830
+ * console.error(error);
1831
+ * });
1832
+ * // expected output: Uh-oh!
1833
+ * ```
1834
+ */
1835
+ catch<TResult = never>(onRejected?: ((reason: any) => TResult | IPromise<TResult>) | undefined | null): IPromise<T | TResult>;
1836
+ /**
1837
+ * Attaches a callback for only the rejection of the Promise.
1838
+ * @param onRejected The callback to execute when the Promise is rejected.
1839
+ * @returns A Promise for the completion of the callback.
1840
+ * @example
1841
+ * ```ts
1842
+ * const promise1 = createPromise((resolve, reject) => {
1843
+ * throw 'Uh-oh!';
1844
+ * });
1845
+ *
1846
+ * promise1.catch((error) => {
1847
+ * console.error(error);
1848
+ * });
1849
+ * // expected output: Uh-oh!
1850
+ * ```
1851
+ */
1852
+ catch<TResult = never>(onRejected?: ((reason: any) => TResult | IPromise<TResult>) | undefined | null): PromiseLike<T | TResult>;
1853
+ /**
1854
+ * Attaches a callback for only the rejection of the Promise.
1855
+ * @param onRejected The callback to execute when the Promise is rejected.
1856
+ * @returns A Promise for the completion of the callback.
1857
+ * @example
1858
+ * ```ts
1859
+ * const promise1 = createPromise((resolve, reject) => {
1860
+ * throw 'Uh-oh!';
1861
+ * });
1862
+ *
1863
+ * promise1.catch((error) => {
1864
+ * console.error(error);
1865
+ * });
1866
+ * // expected output: Uh-oh!
1867
+ * ```
1868
+ */
1869
+ catch<TResult = never>(onRejected?: ((reason: any) => TResult | IPromise<TResult>) | undefined | null): Promise<T | TResult>;
1870
+ /**
1871
+ * Attaches a callback that is invoked when the Promise is settled (fulfilled or rejected). The
1872
+ * resolved value cannot be modified from the callback.
1873
+ * @param onfinally The callback to execute when the Promise is settled (fulfilled or rejected).
1874
+ * @returns A Promise for the completion of the callback.
1875
+ * @example
1876
+ * ```ts
1877
+ * function doFunction() {
1878
+ * return createPromise((resolve, reject) => {
1879
+ * if (Math.random() > 0.5) {
1880
+ * resolve('Function has completed');
1881
+ * } else {
1882
+ * reject(new Error('Function failed to process'));
1883
+ * }
1884
+ * });
1885
+ * }
1886
+ *
1887
+ * doFunction().then((data) => {
1888
+ * console.log(data);
1889
+ * }).catch((err) => {
1890
+ * console.error(err);
1891
+ * }).finally(() => {
1892
+ * console.log('Function processing completed');
1893
+ * });
1894
+ * ```
1895
+ */
1896
+ finally(onfinally?: FinallyPromiseHandler): IPromise<T>;
1897
+ /**
1898
+ * Attaches a callback that is invoked when the Promise is settled (fulfilled or rejected). The
1899
+ * resolved value cannot be modified from the callback.
1900
+ * @param onfinally The callback to execute when the Promise is settled (fulfilled or rejected).
1901
+ * @returns A Promise for the completion of the callback.
1902
+ * @example
1903
+ * ```ts
1904
+ * function doFunction() {
1905
+ * return createPromise((resolve, reject) => {
1906
+ * if (Math.random() > 0.5) {
1907
+ * resolve('Function has completed');
1908
+ * } else {
1909
+ * reject(new Error('Function failed to process'));
1910
+ * }
1911
+ * });
1912
+ * }
1913
+ *
1914
+ * doFunction().then((data) => {
1915
+ * console.log(data);
1916
+ * }).catch((err) => {
1917
+ * console.error(err);
1918
+ * }).finally(() => {
1919
+ * console.log('Function processing completed');
1920
+ * });
1921
+ * ```
1922
+ */
1923
+ finally(onFinally?: FinallyPromiseHandler): Promise<T>;
1924
+ }
1925
+
1926
+ interface IPropertiesConfig {
1927
+ readonly accountId: string;
1928
+ readonly sessionRenewalMs: number;
1929
+ readonly samplingPercentage: number;
1930
+ readonly sessionExpirationMs: number;
1931
+ readonly cookieDomain: string;
1932
+ readonly sdkExtension: string;
1933
+ readonly isBrowserLinkTrackingEnabled: boolean;
1934
+ readonly appId: string;
1935
+ readonly getSessionId: string;
1936
+ readonly namePrefix: string;
1937
+ readonly sessionCookiePostfix: string;
1938
+ readonly userCookiePostfix: string;
1939
+ readonly idLength: number;
1940
+ readonly getNewId: (idLength?: number) => string;
1941
+ }
1942
+
1943
+ interface IPropertiesPlugin {
1944
+ readonly context: ITelemetryContext;
1945
+ }
1946
+
1947
+ interface IPropTelemetryContext extends ITelemetryContext {
1948
+ readonly sessionManager: ISessionManager;
1949
+ applySessionContext(evt: ITelemetryItem, itemCtx?: IProcessTelemetryContext): void;
1950
+ applyOperatingSystemContxt(event: ITelemetryItem, itemCtx?: IProcessTelemetryContext): void;
1951
+ applyApplicationContext(event: ITelemetryItem, itemCtx?: IProcessTelemetryContext): void;
1952
+ applyDeviceContext(event: ITelemetryItem, itemCtx?: IProcessTelemetryContext): void;
1953
+ applyInternalContext(event: ITelemetryItem, itemCtx?: IProcessTelemetryContext): void;
1954
+ applyLocationContext(event: ITelemetryItem, itemCtx?: IProcessTelemetryContext): void;
1955
+ applyOperationContext(event: ITelemetryItem, itemCtx?: IProcessTelemetryContext): void;
1956
+ applyWebContext(event: ITelemetryItem, itemCtx?: IProcessTelemetryContext): void;
1957
+ applyUserContext(event: ITelemetryItem, itemCtx?: IProcessTelemetryContext): void;
1958
+ cleanUp(event: ITelemetryItem, itemCtx?: IProcessTelemetryContext): void;
1959
+ }
1960
+
1961
+ interface IRequestContext {
1962
+ status?: number;
1963
+ xhr?: XMLHttpRequest;
1964
+ request?: Request;
1965
+ response?: Response | string;
1966
+ }
1967
+
1968
+ interface ISession {
1969
+ /**
1970
+ * The session ID.
1971
+ */
1972
+ id?: string;
1973
+ /**
1974
+ * The date at which this guid was genereated.
1975
+ * Per the spec the ID will be regenerated if more than acquisitionSpan milliseconds ellapse from this time.
1976
+ */
1977
+ acquisitionDate?: number;
1978
+ /**
1979
+ * The date at which this session ID was last reported.
1980
+ * This value should be updated whenever telemetry is sent using this ID.
1981
+ * Per the spec the ID will be regenerated if more than renewalSpan milliseconds elapse from this time with no activity.
1982
+ */
1983
+ renewalDate?: number;
1984
+ }
1985
+
1986
+ interface ISessionConfig {
1987
+ readonly sessionRenewalMs?: number;
1988
+ readonly sessionExpirationMs?: number;
1989
+ readonly namePrefix?: string;
1990
+ readonly sessionCookiePostfix?: string;
1991
+ readonly idLength?: number;
1992
+ readonly getNewId?: (idLength?: number) => string;
1993
+ /**
1994
+ * @deprecated Avoid using this value to override the cookie manager cookie domain.
1995
+ */
1996
+ cookieDomain?: string;
1997
+ }
1998
+
1999
+ /**
2000
+ * An interface that identifies the automatic session manager
2001
+ * @since 3.0.3
2002
+ */
2003
+ interface ISessionManager {
2004
+ /**
2005
+ * The automatic Session which has been initialized from the automatic SDK cookies and storage
2006
+ */
2007
+ automaticSession: ISession;
2008
+ /**
2009
+ * Update the automatic session cookie if required
2010
+ * @returns
2011
+ */
2012
+ update: () => void;
2013
+ /**
2014
+ * Record the current state of the automatic session and store it in our cookie string format
2015
+ * into the browser's local storage. This is used to restore the session data when the cookie
2016
+ * expires.
2017
+ */
2018
+ backup: () => void;
2019
+ }
2020
+
2021
+ /**
2022
+ * Identifies a simple interface to allow you to override the storage mechanism used
2023
+ * to track unsent and unacknowledged events. When provided it must provide both
2024
+ * the get and set item functions.
2025
+ * @since 2.8.12
2026
+ */
2027
+ interface IStorageBuffer {
2028
+ /**
2029
+ * Retrieves the stored value for a given key
2030
+ */
2031
+ getItem(logger: IDiagnosticLogger, name: string): string;
2032
+ /**
2033
+ * Sets the stored value for a given key
2034
+ */
2035
+ setItem(logger: IDiagnosticLogger, name: string, data: string): boolean;
2036
+ }
2037
+
2038
+ interface ITelemetryContext {
2039
+ /**
2040
+ * The object describing a component tracked by this object.
2041
+ */
2042
+ readonly application: IApplication;
2043
+ /**
2044
+ * The object describing a device tracked by this object.
2045
+ */
2046
+ readonly device: IDevice;
2047
+ /**
2048
+ * The object describing internal settings.
2049
+ */
2050
+ readonly internal: IInternal;
2051
+ /**
2052
+ * The object describing a location tracked by this object.
2053
+ */
2054
+ readonly location: ILocation;
2055
+ /**
2056
+ * The object describing a operation tracked by this object.
2057
+ */
2058
+ readonly telemetryTrace: ITelemetryTrace;
2059
+ /**
2060
+ * The object describing a user tracked by this object.
2061
+ */
2062
+ readonly user: IUserContext;
2063
+ /**
2064
+ * The object describing a session tracked by this object.
2065
+ */
2066
+ readonly session: ISession;
2067
+ /**
2068
+ * The session manager that manages the automatic session from the cookies
2069
+ */
2070
+ readonly sessionManager: ISessionManager;
2071
+ /**
2072
+ * The object describing os details tracked by this object.
2073
+ */
2074
+ readonly os?: IOperatingSystem;
2075
+ /**
2076
+ * The object describing we details tracked by this object.
2077
+ */
2078
+ readonly web?: IWeb;
2079
+ /**
2080
+ * application id obtained from breeze responses. Is used if appId is not specified by root config
2081
+ */
2082
+ appId: () => string;
2083
+ /**
2084
+ * session id obtained from session manager.
2085
+ */
2086
+ getSessionId: () => string;
2087
+ }
34
2088
 
35
- interface IPropertiesConfig {
36
- readonly accountId: string;
37
- readonly sessionRenewalMs: number;
38
- readonly samplingPercentage: number;
39
- readonly sessionExpirationMs: number;
40
- readonly cookieDomain: string;
41
- readonly sdkExtension: string;
42
- readonly isBrowserLinkTrackingEnabled: boolean;
43
- readonly appId: string;
44
- readonly getSessionId: string;
45
- readonly namePrefix: string;
46
- readonly sessionCookiePostfix: string;
47
- readonly userCookiePostfix: string;
48
- readonly idLength: number;
49
- readonly getNewId: (idLength?: number) => string;
2089
+ interface ITelemetryInitializerHandler extends ILegacyUnloadHook {
2090
+ remove(): void;
50
2091
  }
51
2092
 
52
- interface IPropTelemetryContext extends ITelemetryContext {
53
- readonly sessionManager: ISessionManager;
54
- applySessionContext(evt: ITelemetryItem, itemCtx?: IProcessTelemetryContext): void;
55
- applyOperatingSystemContxt(event: ITelemetryItem, itemCtx?: IProcessTelemetryContext): void;
56
- applyApplicationContext(event: ITelemetryItem, itemCtx?: IProcessTelemetryContext): void;
57
- applyDeviceContext(event: ITelemetryItem, itemCtx?: IProcessTelemetryContext): void;
58
- applyInternalContext(event: ITelemetryItem, itemCtx?: IProcessTelemetryContext): void;
59
- applyLocationContext(event: ITelemetryItem, itemCtx?: IProcessTelemetryContext): void;
60
- applyOperationContext(event: ITelemetryItem, itemCtx?: IProcessTelemetryContext): void;
61
- applyWebContext(event: ITelemetryItem, itemCtx?: IProcessTelemetryContext): void;
62
- applyUserContext(event: ITelemetryItem, itemCtx?: IProcessTelemetryContext): void;
63
- cleanUp(event: ITelemetryItem, itemCtx?: IProcessTelemetryContext): void;
2093
+ /**
2094
+ * Telemety item supported in Core
2095
+ */
2096
+ interface ITelemetryItem {
2097
+ /**
2098
+ * CommonSchema Version of this SDK
2099
+ */
2100
+ ver?: string;
2101
+ /**
2102
+ * Unique name of the telemetry item
2103
+ */
2104
+ name: string;
2105
+ /**
2106
+ * Timestamp when item was sent
2107
+ */
2108
+ time?: string;
2109
+ /**
2110
+ * Identifier of the resource that uniquely identifies which resource data is sent to
2111
+ */
2112
+ iKey?: string;
2113
+ /**
2114
+ * System context properties of the telemetry item, example: ip address, city etc
2115
+ */
2116
+ ext?: {
2117
+ [key: string]: any;
2118
+ };
2119
+ /**
2120
+ * System context property extensions that are not global (not in ctx)
2121
+ */
2122
+ tags?: Tags & Tags[];
2123
+ /**
2124
+ * Custom data
2125
+ */
2126
+ data?: ICustomProperties;
2127
+ /**
2128
+ * Telemetry type used for part B
2129
+ */
2130
+ baseType?: string;
2131
+ /**
2132
+ * Based on schema for part B
2133
+ */
2134
+ baseData?: {
2135
+ [key: string]: any;
2136
+ };
64
2137
  }
65
2138
 
66
- interface ISessionConfig {
67
- readonly sessionRenewalMs?: number;
68
- readonly sessionExpirationMs?: number;
69
- readonly namePrefix?: string;
70
- readonly sessionCookiePostfix?: string;
71
- readonly idLength?: number;
72
- readonly getNewId?: (idLength?: number) => string;
2139
+ /**
2140
+ * Configuration provided to SDK core
2141
+ */
2142
+ interface ITelemetryPlugin extends ITelemetryProcessor, IPlugin {
73
2143
  /**
74
- * @deprecated Avoid using this value to override the cookie manager cookie domain.
2144
+ * Set next extension for telemetry processing, this is not optional as plugins should use the
2145
+ * processNext() function of the passed IProcessTelemetryContext instead. It is being kept for
2146
+ * now for backward compatibility only.
75
2147
  */
76
- cookieDomain?: string;
2148
+ setNextPlugin?: (next: ITelemetryPlugin | ITelemetryPluginChain) => void;
2149
+ /**
2150
+ * Priority of the extension
2151
+ */
2152
+ readonly priority: number;
2153
+ }
2154
+
2155
+ /**
2156
+ * Configuration provided to SDK core
2157
+ */
2158
+ interface ITelemetryPluginChain extends ITelemetryProcessor {
2159
+ /**
2160
+ * Returns the underlying plugin that is being proxied for the processTelemetry call
2161
+ */
2162
+ getPlugin: () => ITelemetryPlugin;
2163
+ /**
2164
+ * Returns the next plugin
2165
+ */
2166
+ getNext: () => ITelemetryPluginChain;
2167
+ /**
2168
+ * This plugin is being unloaded and should remove any hooked events and cleanup any global/scoped values, after this
2169
+ * call the plugin will be removed from the telemetry processing chain and will no longer receive any events..
2170
+ * @param unloadCtx - The unload context to use for this call.
2171
+ * @param unloadState - The details of the unload operation
2172
+ */
2173
+ unload?: (unloadCtx: IProcessTelemetryUnloadContext, unloadState: ITelemetryUnloadState) => void;
2174
+ }
2175
+
2176
+ interface ITelemetryProcessor {
2177
+ /**
2178
+ * Call back for telemetry processing before it it is sent
2179
+ * @param env - This is the current event being reported
2180
+ * @param itemCtx - This is the context for the current request, ITelemetryPlugin instances
2181
+ * can optionally use this to access the current core instance or define / pass additional information
2182
+ * to later plugins (vs appending items to the telemetry item)
2183
+ */
2184
+ processTelemetry: (env: ITelemetryItem, itemCtx?: IProcessTelemetryContext) => void;
2185
+ /**
2186
+ * The the plugin should re-evaluate configuration and update any cached configuration settings or
2187
+ * plugins. If implemented this method will be called whenever a plugin is added or removed and if
2188
+ * the configuration has bee updated.
2189
+ * @param updateCtx - This is the context that should be used during updating.
2190
+ * @param updateState - The details / state of the update process, it holds details like the current and previous configuration.
2191
+ * @returns boolean - true if the plugin has or will call updateCtx.processNext(), this allows the plugin to perform any asynchronous operations.
2192
+ */
2193
+ update?: (updateCtx: IProcessTelemetryUpdateContext, updateState: ITelemetryUpdateState) => void | boolean;
2194
+ }
2195
+
2196
+ interface ITelemetryTrace {
2197
+ /**
2198
+ * Trace id
2199
+ */
2200
+ traceID?: string;
2201
+ /**
2202
+ * Parent id
2203
+ */
2204
+ parentID?: string;
2205
+ /**
2206
+ * @deprecated Never Used
2207
+ * Trace state
2208
+ */
2209
+ traceState?: ITraceState;
2210
+ /**
2211
+ * An integer representation of the W3C TraceContext trace-flags. https://www.w3.org/TR/trace-context/#trace-flags
2212
+ */
2213
+ traceFlags?: number;
2214
+ /**
2215
+ * Name
2216
+ */
2217
+ name?: string;
2218
+ }
2219
+
2220
+ interface ITelemetryUnloadState {
2221
+ reason: TelemetryUnloadReason;
2222
+ isAsync: boolean;
2223
+ flushComplete?: boolean;
2224
+ }
2225
+
2226
+ interface ITelemetryUpdateState {
2227
+ /**
2228
+ * Identifies the reason for the update notification, this is a bitwise numeric value
2229
+ */
2230
+ reason: TelemetryUpdateReason;
2231
+ /**
2232
+ * This is a new active configuration that should be used
2233
+ */
2234
+ cfg?: IConfiguration;
2235
+ /**
2236
+ * The detected changes
2237
+ */
2238
+ oldCfg?: IConfiguration;
2239
+ /**
2240
+ * If this is a configuration update this was the previous configuration that was used
2241
+ */
2242
+ newConfig?: IConfiguration;
2243
+ /**
2244
+ * Was the new config requested to be merged with the existing config
2245
+ */
2246
+ merge?: boolean;
2247
+ /**
2248
+ * This holds a collection of plugins that have been added (if the reason identifies that one or more plugins have been added)
2249
+ */
2250
+ added?: IPlugin[];
2251
+ /**
2252
+ * This holds a collection of plugins that have been removed (if the reason identifies that one or more plugins have been removed)
2253
+ */
2254
+ removed?: IPlugin[];
2255
+ }
2256
+
2257
+ /**
2258
+ * Identifies frequency of items sent
2259
+ * Default: send data on 28th every 3 month each year
2260
+ */
2261
+ interface IThrottleInterval {
2262
+ /**
2263
+ * Identifies month interval that items can be sent
2264
+ * 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.)
2265
+ * If both monthInterval and dayInterval are undefined, it will be set to 3
2266
+ */
2267
+ monthInterval?: number;
2268
+ /**
2269
+ * Identifies days Interval from start date that items can be sent
2270
+ * Default: undefined
2271
+ */
2272
+ dayInterval?: number;
2273
+ /**
2274
+ * Identifies days within each month that items can be sent
2275
+ * If both monthInterval and dayInterval are undefined, it will be default to [28]
2276
+ */
2277
+ daysOfMonth?: number[];
2278
+ }
2279
+
2280
+ /**
2281
+ * Identifies limit number/percentage of items sent per time
2282
+ * If both are provided, minimum number between the two will be used
2283
+ */
2284
+ interface IThrottleLimit {
2285
+ /**
2286
+ * Identifies sampling percentage of items per time
2287
+ * The percentage is set to 4 decimal places, for example: 1 means 0.0001%
2288
+ * Default: 100 (0.01%)
2289
+ */
2290
+ samplingRate?: number;
2291
+ /**
2292
+ * Identifies limit number of items per time
2293
+ * Default: 1
2294
+ */
2295
+ maxSendNumber?: number;
2296
+ }
2297
+
2298
+ /**
2299
+ * Identifies basic config
2300
+ */
2301
+ interface IThrottleMgrConfig {
2302
+ /**
2303
+ * Identifies if throttle is disabled
2304
+ * Default: false
2305
+ */
2306
+ disabled?: boolean;
2307
+ /**
2308
+ * Identifies limit number/percentage of items sent per time
2309
+ * Default: sampling percentage 0.01% with one item sent per time
2310
+ */
2311
+ limit?: IThrottleLimit;
2312
+ /**
2313
+ * Identifies frequency of items sent
2314
+ * Default: send data on 28th every 3 month each year
2315
+ */
2316
+ interval?: IThrottleInterval;
2317
+ }
2318
+
2319
+ /**
2320
+ * A Timer handler which is returned from {@link scheduleTimeout} which contains functions to
2321
+ * cancel or restart (refresh) the timeout function.
2322
+ *
2323
+ * @since 0.4.4
2324
+ * @group Timer
2325
+ */
2326
+ interface ITimerHandler {
2327
+ /**
2328
+ * Cancels a timeout that was previously scheduled, after calling this function any previously
2329
+ * scheduled timer will not execute.
2330
+ * @example
2331
+ * ```ts
2332
+ * let theTimer = scheduleTimeout(...);
2333
+ * theTimer.cancel();
2334
+ * ```
2335
+ */
2336
+ cancel(): void;
2337
+ /**
2338
+ * Reschedules the timer to call its callback at the previously specified duration
2339
+ * adjusted to the current time. This is useful for refreshing a timer without allocating
2340
+ * a new JavaScript object.
2341
+ *
2342
+ * Using this on a timer that has already called its callback will reactivate the timer.
2343
+ * Calling on a timer that has not yet executed will just reschedule the current timer.
2344
+ * @example
2345
+ * ```ts
2346
+ * let theTimer = scheduleTimeout(...);
2347
+ * // The timer will be restarted (if already executed) or rescheduled (if it has not yet executed)
2348
+ * theTimer.refresh();
2349
+ * ```
2350
+ */
2351
+ refresh(): ITimerHandler;
2352
+ /**
2353
+ * When called, requests that the event loop not exit so long when the ITimerHandler is active.
2354
+ * Calling timer.ref() multiple times will have no effect. By default, all ITimerHandler objects
2355
+ * will create "ref'ed" instances, making it normally unnecessary to call timer.ref() unless
2356
+ * timer.unref() had been called previously.
2357
+ * @since 0.7.0
2358
+ * @returns the ITimerHandler instance
2359
+ * @example
2360
+ * ```ts
2361
+ * let theTimer = createTimeout(...);
2362
+ *
2363
+ * // Make sure the timer is referenced (the default) so that the runtime (Node) does not terminate
2364
+ * // if there is a waiting referenced timer.
2365
+ * theTimer.ref();
2366
+ * ```
2367
+ */
2368
+ ref(): this;
2369
+ /**
2370
+ * When called, the any active ITimerHandler instance will not require the event loop to remain
2371
+ * active (Node.js). If there is no other activity keeping the event loop running, the process may
2372
+ * exit before the ITimerHandler instance callback is invoked. Calling timer.unref() multiple times
2373
+ * will have no effect.
2374
+ * @since 0.7.0
2375
+ * @returns the ITimerHandler instance
2376
+ * @example
2377
+ * ```ts
2378
+ * let theTimer = createTimeout(...);
2379
+ *
2380
+ * // Unreference the timer so that the runtime (Node) may terminate if nothing else is running.
2381
+ * theTimer.unref();
2382
+ * ```
2383
+ */
2384
+ unref(): this;
2385
+ /**
2386
+ * If true, any running referenced `ITimerHandler` instance will keep the Node.js event loop active.
2387
+ * @since 0.7.0
2388
+ * @example
2389
+ * ```ts
2390
+ * let theTimer = createTimeout(...);
2391
+ *
2392
+ * // Unreference the timer so that the runtime (Node) may terminate if nothing else is running.
2393
+ * theTimer.unref();
2394
+ * let hasRef = theTimer.hasRef(); // false
2395
+ *
2396
+ * theTimer.ref();
2397
+ * hasRef = theTimer.hasRef(); // true
2398
+ * ```
2399
+ */
2400
+ hasRef(): boolean;
2401
+ /**
2402
+ * Gets or Sets a flag indicating if the underlying timer is currently enabled and running.
2403
+ * Setting the enabled flag to the same as it's current value has no effect, setting to `true`
2404
+ * when already `true` will not {@link ITimerHandler.refresh | refresh}() the timer.
2405
+ * And setting to 'false` will {@link ITimerHandler.cancel | cancel}() the timer.
2406
+ * @since 0.8.1
2407
+ * @example
2408
+ * ```ts
2409
+ * let theTimer = createTimeout(...);
2410
+ *
2411
+ * // Check if enabled
2412
+ * theTimer.enabled; // false
2413
+ *
2414
+ * // Start the timer
2415
+ * theTimer.enabled = true; // Same as calling refresh()
2416
+ * theTimer.enabled; //true
2417
+ *
2418
+ * // Has no effect as it's already running
2419
+ * theTimer.enabled = true;
2420
+ *
2421
+ * // Will refresh / restart the time
2422
+ * theTimer.refresh()
2423
+ *
2424
+ * let theTimer = scheduleTimeout(...);
2425
+ *
2426
+ * // Check if enabled
2427
+ * theTimer.enabled; // true
2428
+ * ```
2429
+ */
2430
+ enabled: boolean;
2431
+ }
2432
+
2433
+ interface ITraceState {
2434
+ }
2435
+
2436
+ /**
2437
+ * An interface which provides automatic removal during unloading of the component
2438
+ */
2439
+ interface IUnloadHook {
2440
+ /**
2441
+ * Self remove the referenced component
2442
+ */
2443
+ rm: () => void;
2444
+ }
2445
+
2446
+ /**
2447
+ * Interface which identifiesAdd this hook so that it is automatically removed during unloading
2448
+ * @param hooks - The single hook or an array of IInstrumentHook objects
2449
+ */
2450
+ interface IUnloadHookContainer {
2451
+ add: (hooks: IUnloadHook | IUnloadHook[] | Iterator<IUnloadHook> | ILegacyUnloadHook | ILegacyUnloadHook[] | Iterator<ILegacyUnloadHook>) => void;
2452
+ run: (logger?: IDiagnosticLogger) => void;
2453
+ }
2454
+
2455
+ interface IUser {
2456
+ /**
2457
+ * The telemetry configuration.
2458
+ */
2459
+ config: any;
2460
+ /**
2461
+ * The user ID.
2462
+ */
2463
+ id: string;
2464
+ /**
2465
+ * Authenticated user id
2466
+ */
2467
+ authenticatedId: string;
2468
+ /**
2469
+ * The account ID.
2470
+ */
2471
+ accountId: string;
2472
+ /**
2473
+ * The account acquisition date.
2474
+ */
2475
+ accountAcquisitionDate: string;
2476
+ /**
2477
+ * The localId
2478
+ */
2479
+ localId: string;
2480
+ /**
2481
+ * A flag indicating whether this represents a new user
2482
+ */
2483
+ isNewUser?: boolean;
2484
+ /**
2485
+ * A flag indicating whether the user cookie has been set
2486
+ */
2487
+ isUserCookieSet?: boolean;
2488
+ }
2489
+
2490
+ interface IUserContext extends IUser {
2491
+ setAuthenticatedUserContext(authenticatedUserId: string, accountId?: string, storeInCookie?: boolean): void;
2492
+ clearAuthenticatedUserContext(): void;
2493
+ update(userId?: string): void;
2494
+ }
2495
+
2496
+ interface IWatchDetails<T = IConfiguration> {
2497
+ /**
2498
+ * The current config object
2499
+ */
2500
+ cfg: T;
2501
+ /**
2502
+ * Set the value against the provided config/name with the value, the property
2503
+ * will be converted to be dynamic (if not already) as long as the provided config
2504
+ * is already a tracked dynamic object.
2505
+ * @throws TypeError if the provided config is not a monitored dynamic config
2506
+ */
2507
+ set: <C, V>(theConfig: C, name: string, value: V) => V;
2508
+ /**
2509
+ * Set default values for the config if not present.
2510
+ * @param theConfig - The configuration object to set default on (if missing)
2511
+ * @param defaultValues - The default values to apply to the config
2512
+ */
2513
+ setDf: <C>(theConfig: C, defaultValues: IConfigDefaults<C>) => C;
2514
+ /**
2515
+ * Set this named property of the target as referenced, which will cause any object or array instance
2516
+ * to be updated in-place rather than being entirely replaced. All other values will continue to be replaced.
2517
+ * @returns The referenced properties current value
2518
+ */
2519
+ ref: <C, V = any>(target: C, name: string) => V;
2520
+ /**
2521
+ * Set this named property of the target as read-only, which will block this single named property from
2522
+ * ever being changed for the target instance.
2523
+ * This does NOT freeze or seal the instance, it just stops the direct re-assignment of the named property,
2524
+ * if the value is a non-primitive (ie. an object or array) it's properties will still be mutable.
2525
+ * @returns The referenced properties current value
2526
+ */
2527
+ rdOnly: <C, V = any>(target: C, name: string) => V;
2528
+ }
2529
+
2530
+ interface IWeb {
2531
+ /**
2532
+ * Browser name, set at ingestion
2533
+ */
2534
+ browser: string;
2535
+ /**
2536
+ * Browser ver, set at ingestion.
2537
+ */
2538
+ browserVer: string;
2539
+ /**
2540
+ * Language
2541
+ */
2542
+ browserLang: string;
2543
+ /**
2544
+ * User consent, populated to properties bag
2545
+ */
2546
+ userConsent: boolean;
2547
+ /**
2548
+ * Whether event was fired manually, populated to properties bag
2549
+ */
2550
+ isManual: boolean;
2551
+ /**
2552
+ * Screen resolution, populated to properties bag
2553
+ */
2554
+ screenRes: string;
2555
+ /**
2556
+ * Current domain. Leverages Window.location.hostname. populated to properties bag
2557
+ */
2558
+ domain: string;
77
2559
  }
78
2560
 
2561
+ const LoggingSeverity: EnumValue<typeof eLoggingSeverity>;
2562
+
2563
+ type LoggingSeverity = number | eLoggingSeverity;
2564
+
79
2565
  class PropertiesPlugin extends BaseTelemetryPlugin implements IPropertiesPlugin {
80
2566
  context: IPropTelemetryContext;
81
2567
  priority: number;
@@ -89,6 +2575,66 @@ declare namespace ApplicationInsights {
89
2575
  processTelemetry(event: ITelemetryItem, itemCtx?: IProcessTelemetryContext): void;
90
2576
  }
91
2577
 
2578
+ /**
2579
+ * This defines the handler function for when a promise is rejected.
2580
+ * @param value This is the value passed as part of resolving the Promise
2581
+ * @return This may return a value, another Promise or void. @see {@link IPromise.then} for how the value is handled.
2582
+ */
2583
+ type RejectedPromiseHandler<T = never> = (((reason: any) => T | IPromise<T> | PromiseLike<T>) | undefined | null);
2584
+
2585
+ /**
2586
+ * This defines the handler function for when a promise is resolved.
2587
+ * @param value This is the value passed as part of resolving the Promise
2588
+ * @return This may return a value, another Promise or void. @see {@link IPromise.then} for how the value is handled.
2589
+ */
2590
+ type ResolvedPromiseHandler<T, TResult1 = T> = (((value: T) => TResult1 | IPromise<TResult1> | PromiseLike<TResult1>) | undefined | null);
2591
+
2592
+ /**
2593
+ * The EventsDiscardedReason enumeration contains a set of values that specify the reason for discarding an event.
2594
+ */
2595
+ const enum SendRequestReason {
2596
+ /**
2597
+ * No specific reason was specified
2598
+ */
2599
+ Undefined = 0,
2600
+ /**
2601
+ * Events are being sent based on the normal event schedule / timer.
2602
+ */
2603
+ NormalSchedule = 1,
2604
+ /**
2605
+ * A manual flush request was received
2606
+ */
2607
+ ManualFlush = 1,
2608
+ /**
2609
+ * Unload event is being processed
2610
+ */
2611
+ Unload = 2,
2612
+ /**
2613
+ * The event(s) being sent are sync events
2614
+ */
2615
+ SyncEvent = 3,
2616
+ /**
2617
+ * The Channel was resumed
2618
+ */
2619
+ Resumed = 4,
2620
+ /**
2621
+ * The event(s) being sent as a retry
2622
+ */
2623
+ Retry = 5,
2624
+ /**
2625
+ * The SDK is unloading
2626
+ */
2627
+ SdkUnload = 6,
2628
+ /**
2629
+ * Maximum batch size would be exceeded
2630
+ */
2631
+ MaxBatchSize = 10,
2632
+ /**
2633
+ * The Maximum number of events have already been queued
2634
+ */
2635
+ MaxQueuedEvents = 20
2636
+ }
2637
+
92
2638
  class Session implements ISession {
93
2639
  /**
94
2640
  * The session ID.
@@ -119,6 +2665,10 @@ declare namespace ApplicationInsights {
119
2665
  backup(): void;
120
2666
  }
121
2667
 
2668
+ interface Tags {
2669
+ [key: string]: any;
2670
+ }
2671
+
122
2672
  class TelemetryContext implements IPropTelemetryContext {
123
2673
  application: IApplication;
124
2674
  device: IDevice;
@@ -145,6 +2695,8 @@ declare namespace ApplicationInsights {
145
2695
  cleanUp(event: ITelemetryItem, itemCtx?: IProcessTelemetryContext): void;
146
2696
  }
147
2697
 
2698
+ type TelemetryInitializerFunction = <T extends ITelemetryItem>(item: T) => boolean | void;
2699
+
148
2700
  class TelemetryTrace implements ITelemetryTrace {
149
2701
  traceID: string;
150
2702
  parentID: string;
@@ -154,5 +2706,52 @@ declare namespace ApplicationInsights {
154
2706
  constructor(id?: string, parentId?: string, name?: string, logger?: IDiagnosticLogger);
155
2707
  }
156
2708
 
157
-
2709
+ /**
2710
+ * The TelemetryUnloadReason enumeration contains the possible reasons for why a plugin is being unloaded / torndown().
2711
+ */
2712
+ const enum TelemetryUnloadReason {
2713
+ /**
2714
+ * Teardown has been called without any context.
2715
+ */
2716
+ ManualTeardown = 0,
2717
+ /**
2718
+ * Just this plugin is being removed
2719
+ */
2720
+ PluginUnload = 1,
2721
+ /**
2722
+ * This instance of the plugin is being removed and replaced
2723
+ */
2724
+ PluginReplace = 2,
2725
+ /**
2726
+ * The entire SDK is being unloaded
2727
+ */
2728
+ SdkUnload = 50
2729
+ }
2730
+
2731
+ /**
2732
+ * The TelemetryUpdateReason enumeration contains a set of bit-wise values that specify the reason for update request.
2733
+ */
2734
+ const enum TelemetryUpdateReason {
2735
+ /**
2736
+ * Unknown.
2737
+ */
2738
+ Unknown = 0,
2739
+ /**
2740
+ * The configuration has ben updated or changed
2741
+ */
2742
+ ConfigurationChanged = 1,
2743
+ /**
2744
+ * One or more plugins have been added
2745
+ */
2746
+ PluginAdded = 16,
2747
+ /**
2748
+ * One or more plugins have been removed
2749
+ */
2750
+ PluginRemoved = 32
2751
+ }
2752
+
2753
+ type UnloadHandler = (itemCtx: IProcessTelemetryUnloadContext, unloadState: ITelemetryUnloadState) => void;
2754
+
2755
+ type WatcherFunction<T = IConfiguration> = (details: IWatchDetails<T>) => void;
2756
+
158
2757
  }