@microsoft/applicationinsights-offlinechannel-js 0.1.0-nightly3.2402-09 → 0.1.0-nightly3.2402-12

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