@microsoft/applicationinsights-web-basic 3.0.0-beta.2210-01 → 3.0.0-beta.2210-03

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Microsoft.ApplicationInsights, 3.0.0-beta.2210-01
2
+ * Microsoft.ApplicationInsights, 3.0.0-beta.2210-03
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  *
5
5
  * Microsoft Application Insights Team
@@ -18,81 +18,7 @@ import { EnumCls } from '@nevware21/ts-utils';
18
18
  import { isNullOrUndefined } from '@nevware21/ts-utils';
19
19
  import { throwError } from '@nevware21/ts-utils';
20
20
 
21
- export declare class AppInsightsCore extends BaseCore implements IAppInsightsCore {
22
- constructor();
23
- initialize(config: IConfiguration, extensions: IPlugin[], logger?: IDiagnosticLogger, notificationManager?: INotificationManager): void;
24
- track(telemetryItem: ITelemetryItem): void;
25
- }
26
-
27
- /**
28
- * @export
29
- * @class ApplicationInsights
30
- */
31
- export declare class ApplicationInsights {
32
- config: IConfiguration & IConfig;
33
- /**
34
- * Creates an instance of ApplicationInsights.
35
- * @param {IConfiguration & IConfig} config
36
- * @memberof ApplicationInsights
37
- */
38
- constructor(config: IConfiguration & IConfig);
39
- /**
40
- * Initialize this instance of ApplicationInsights
41
- *
42
- * @memberof ApplicationInsights
43
- */
44
- initialize(): void;
45
- /**
46
- * Send a manually constructed custom event
47
- *
48
- * @param {ITelemetryItem} item
49
- * @memberof ApplicationInsights
50
- */
51
- track(item: ITelemetryItem): void;
52
- /**
53
- * Immediately send all batched telemetry
54
- * @param {boolean} [async=true]
55
- * @memberof ApplicationInsights
56
- */
57
- flush(async?: boolean): void;
58
- pollInternalLogs(): void;
59
- stopPollingInternalLogs(): void;
60
- getSKUDefaults(): void;
61
- /**
62
- * Unload and Tear down the SDK and any initialized plugins, after calling this the SDK will be considered
63
- * to be un-initialized and non-operational, re-initializing the SDK should only be attempted if the previous
64
- * unload call return `true` stating that all plugins reported that they also unloaded, the recommended
65
- * approach is to create a new instance and initialize that instance.
66
- * This is due to possible unexpected side effects caused by plugins not supporting unload / teardown, unable
67
- * to successfully remove any global references or they may just be completing the unload process asynchronously.
68
- */
69
- unload(isAsync?: boolean, unloadComplete?: () => void): void;
70
- /**
71
- * Find and return the (first) plugin with the specified identifier if present
72
- * @param pluginIdentifier
73
- */
74
- getPlugin<T extends IPlugin = IPlugin>(pluginIdentifier: string): ILoadedPlugin<T>;
75
- /**
76
- * Add a new plugin to the installation
77
- * @param plugin - The new plugin to add
78
- * @param replaceExisting - should any existing plugin be replaced
79
- * @param doAsync - Should the add be performed asynchronously
80
- */
81
- addPlugin<T extends IPlugin = ITelemetryPlugin>(plugin: T, replaceExisting: boolean, doAsync: boolean, addCb?: (added?: boolean) => void): void;
82
- /**
83
- * Returns the unique event namespace that should be used
84
- */
85
- evtNamespace(): string;
86
- /**
87
- * Add an unload handler that will be called when the SDK is being unloaded
88
- * @param handler - the handler
89
- */
90
- addUnloadCb(handler: UnloadHandler): void;
91
- }
92
-
93
- export { arrForEach }
94
-
95
- declare class BaseCore implements IAppInsightsCore {
21
+ export declare class AppInsightsCore implements IAppInsightsCore {
96
22
  static defaultConfig: IConfiguration;
97
23
  config: IConfiguration;
98
24
  logger: IDiagnosticLogger;
@@ -108,12 +34,12 @@ declare class BaseCore implements IAppInsightsCore {
108
34
  * Adds a notification listener. The SDK calls methods on the listener when an appropriate notification is raised.
109
35
  * The added plugins must raise notifications. If the plugins do not implement the notifications, then no methods will be
110
36
  * called.
111
- * @param {INotificationListener} listener - An INotificationListener object.
37
+ * @param listener - An INotificationListener object.
112
38
  */
113
39
  addNotificationListener(listener: INotificationListener): void;
114
40
  /**
115
41
  * Removes all instances of the listener.
116
- * @param {INotificationListener} listener - INotificationListener to remove.
42
+ * @param listener - INotificationListener to remove.
117
43
  */
118
44
  removeNotificationListener(listener: INotificationListener): void;
119
45
  /**
@@ -141,7 +67,7 @@ declare class BaseCore implements IAppInsightsCore {
141
67
  * @param telemetryInitializer - The Telemetry Initializer function
142
68
  * @returns - A ITelemetryInitializerHandler to enable the initializer to be removed
143
69
  */
144
- addTelemetryInitializer(telemetryInitializer: TelemetryInitializerFunction): ITelemetryInitializerHandler | void;
70
+ addTelemetryInitializer(telemetryInitializer: TelemetryInitializerFunction): ITelemetryInitializerHandler;
145
71
  /**
146
72
  * Unload and Tear down the SDK and any initialized plugins, after calling this the SDK will be considered
147
73
  * to be un-initialized and non-operational, re-initializing the SDK should only be attempted if the previous
@@ -163,6 +89,12 @@ declare class BaseCore implements IAppInsightsCore {
163
89
  * @param addCb - [Optional] callback to call after the plugin has been added
164
90
  */
165
91
  addPlugin<T extends IPlugin = ITelemetryPlugin>(plugin: T, replaceExisting?: boolean, doAsync?: boolean, addCb?: (added?: boolean) => void): void;
92
+ /**
93
+ * Update the configuration used and broadcast the changes to all loaded plugins
94
+ * @param newConfig - The new configuration is apply
95
+ * @param mergeExisting - Should the new configuration merge with the existing or just replace it. Default is to true.
96
+ */
97
+ updateCfg<T extends IConfiguration = IConfiguration>(newConfig: T, mergeExisting?: boolean): void;
166
98
  /**
167
99
  * Returns the unique event namespace that should be used
168
100
  */
@@ -190,6 +122,18 @@ declare class BaseCore implements IAppInsightsCore {
190
122
  * Sets the current distributed trace context for this instance if available
191
123
  */
192
124
  setTraceCtx(newTracectx: IDistributedTraceContext): void;
125
+ /**
126
+ * Add this hook so that it is automatically removed during unloading
127
+ * @param hooks - The single hook or an array of IInstrumentHook objects
128
+ */
129
+ addUnloadHook(hooks: IUnloadHook | IUnloadHook[] | Iterator<IUnloadHook> | ILegacyUnloadHook | ILegacyUnloadHook[] | Iterator<ILegacyUnloadHook>): void;
130
+ /**
131
+ * Watches and tracks changes for accesses to the current config, and if the accessed config changes the
132
+ * handler will be recalled.
133
+ * @param handler
134
+ * @returns A watcher handler instance that can be used to remove itself when being unloaded
135
+ */
136
+ onCfgChange<T extends IConfiguration = IConfiguration>(handler: WatcherFunction<T>): IUnloadHook;
193
137
  protected releaseQueue(): void;
194
138
  /**
195
139
  * Hook for Core extensions to allow them to update their own configuration before updating all of the plugins.
@@ -200,6 +144,74 @@ declare class BaseCore implements IAppInsightsCore {
200
144
  protected _updateHook?(updateCtx: IProcessTelemetryUpdateContext, updateState: ITelemetryUpdateState): void | boolean;
201
145
  }
202
146
 
147
+ /**
148
+ * @export
149
+ * @class ApplicationInsights
150
+ */
151
+ export declare class ApplicationInsights {
152
+ readonly config: IConfiguration & IConfig;
153
+ /**
154
+ * Creates an instance of ApplicationInsights.
155
+ * @param config
156
+ * @memberof ApplicationInsights
157
+ */
158
+ constructor(config: IConfiguration & IConfig);
159
+ /**
160
+ * Initialize this instance of ApplicationInsights
161
+ *
162
+ * @memberof ApplicationInsights
163
+ */
164
+ initialize(): void;
165
+ /**
166
+ * Send a manually constructed custom event
167
+ *
168
+ * @param item
169
+ * @memberof ApplicationInsights
170
+ */
171
+ track(item: ITelemetryItem): void;
172
+ /**
173
+ * Immediately send all batched telemetry
174
+ * @param [async=true]
175
+ * @memberof ApplicationInsights
176
+ */
177
+ flush(async?: boolean): void;
178
+ pollInternalLogs(): void;
179
+ stopPollingInternalLogs(): void;
180
+ getSKUDefaults(): void;
181
+ /**
182
+ * Unload and Tear down the SDK and any initialized plugins, after calling this the SDK will be considered
183
+ * to be un-initialized and non-operational, re-initializing the SDK should only be attempted if the previous
184
+ * unload call return `true` stating that all plugins reported that they also unloaded, the recommended
185
+ * approach is to create a new instance and initialize that instance.
186
+ * This is due to possible unexpected side effects caused by plugins not supporting unload / teardown, unable
187
+ * to successfully remove any global references or they may just be completing the unload process asynchronously.
188
+ */
189
+ unload(isAsync?: boolean, unloadComplete?: () => void): void;
190
+ /**
191
+ * Find and return the (first) plugin with the specified identifier if present
192
+ * @param pluginIdentifier
193
+ */
194
+ getPlugin<T extends IPlugin = IPlugin>(pluginIdentifier: string): ILoadedPlugin<T>;
195
+ /**
196
+ * Add a new plugin to the installation
197
+ * @param plugin - The new plugin to add
198
+ * @param replaceExisting - should any existing plugin be replaced
199
+ * @param doAsync - Should the add be performed asynchronously
200
+ */
201
+ addPlugin<T extends IPlugin = ITelemetryPlugin>(plugin: T, replaceExisting: boolean, doAsync: boolean, addCb?: (added?: boolean) => void): void;
202
+ /**
203
+ * Returns the unique event namespace that should be used
204
+ */
205
+ evtNamespace(): string;
206
+ /**
207
+ * Add an unload handler that will be called when the SDK is being unloaded
208
+ * @param handler - the handler
209
+ */
210
+ addUnloadCb(handler: UnloadHandler): void;
211
+ }
212
+
213
+ export { arrForEach }
214
+
203
215
  /**
204
216
  * BaseTelemetryPlugin provides a basic implementation of the ITelemetryPlugin interface so that plugins
205
217
  * can avoid implementation the same set of boiler plate code as well as provide a base
@@ -290,7 +302,7 @@ declare abstract class BaseTelemetryPlugin implements ITelemetryPlugin {
290
302
  * Add this hook so that it is automatically removed during unloading
291
303
  * @param hooks - The single hook or an array of IInstrumentHook objects
292
304
  */
293
- protected _addHook(hooks: IInstrumentHook | IInstrumentHook[]): void;
305
+ protected _addHook(hooks: IUnloadHook | IUnloadHook[] | ILegacyUnloadHook | ILegacyUnloadHook[]): void;
294
306
  }
295
307
 
296
308
  declare const DistributedTracingModes: EnumValue<typeof eDistributedTracingModes>;
@@ -395,10 +407,16 @@ export declare const enum _eInternalMessageId {
395
407
  TrackPageActionEventFailed = 103,
396
408
  FailedAddingCustomDefinedRequestContext = 104,
397
409
  InMemoryStorageBufferFull = 105,
398
- InstrumentationKeyDeprecation = 106
410
+ InstrumentationKeyDeprecation = 106,
411
+ ConfigWatcherException = 107,
412
+ DynamicConfigException = 108
399
413
  }
400
414
 
401
415
  declare const enum eLoggingSeverity {
416
+ /**
417
+ * No Logging will be enabled
418
+ */
419
+ DISABLED = 0,
402
420
  /**
403
421
  * Error will be sent as internal telemetry
404
422
  */
@@ -422,12 +440,6 @@ export declare const enum eSeverityLevel {
422
440
  Critical = 4
423
441
  }
424
442
 
425
- declare const enum GetExtCfgMergeType {
426
- None = 0,
427
- MergeDefaultOnly = 1,
428
- MergeDefaultFromRootOrDefault = 2
429
- }
430
-
431
443
  export declare interface IAppInsightsCore extends IPerfManagerProvider {
432
444
  config: IConfiguration;
433
445
  logger: IDiagnosticLogger;
@@ -455,12 +467,12 @@ export declare interface IAppInsightsCore extends IPerfManagerProvider {
455
467
  * Adds a notification listener. The SDK calls methods on the listener when an appropriate notification is raised.
456
468
  * The added plugins must raise notifications. If the plugins do not implement the notifications, then no methods will be
457
469
  * called.
458
- * @param {INotificationListener} listener - An INotificationListener object.
470
+ * @param listener - An INotificationListener object.
459
471
  */
460
472
  addNotificationListener?(listener: INotificationListener): void;
461
473
  /**
462
474
  * Removes all instances of the listener.
463
- * @param {INotificationListener} listener - INotificationListener to remove.
475
+ * @param listener - INotificationListener to remove.
464
476
  */
465
477
  removeNotificationListener?(listener: INotificationListener): void;
466
478
  /**
@@ -468,7 +480,7 @@ export declare interface IAppInsightsCore extends IPerfManagerProvider {
468
480
  * @param telemetryInitializer - The Telemetry Initializer function
469
481
  * @returns - A ITelemetryInitializerHandler to enable the initializer to be removed
470
482
  */
471
- addTelemetryInitializer(telemetryInitializer: TelemetryInitializerFunction): ITelemetryInitializerHandler | void;
483
+ addTelemetryInitializer(telemetryInitializer: TelemetryInitializerFunction): ITelemetryInitializerHandler;
472
484
  pollInternalLogs?(eventName?: string): number;
473
485
  stopPollingInternalLogs?(): void;
474
486
  /**
@@ -500,6 +512,14 @@ export declare interface IAppInsightsCore extends IPerfManagerProvider {
500
512
  * @param addCb - [Optional] callback to call after the plugin has been added
501
513
  */
502
514
  addPlugin<T extends IPlugin = ITelemetryPlugin>(plugin: T, replaceExisting?: boolean, doAsync?: boolean, addCb?: (added?: boolean) => void): void;
515
+ /**
516
+ * Update the configuration used and broadcast the changes to all loaded plugins, this does NOT support updating, adding or removing
517
+ * any the plugins (extensions or channels). It will notify each plugin (if supported) that the configuration has changed but it will
518
+ * not remove or add any new plugins, you need to call addPlugin or getPlugin(identifier).remove();
519
+ * @param newConfig - The new configuration is apply
520
+ * @param mergeExisting - Should the new configuration merge with the existing or just replace it. Default is to merge.
521
+ */
522
+ updateCfg<T extends IConfiguration = IConfiguration>(newConfig: T, mergeExisting?: boolean): void;
503
523
  /**
504
524
  * Returns the unique event namespace that should be used when registering events
505
525
  */
@@ -509,6 +529,11 @@ export declare interface IAppInsightsCore extends IPerfManagerProvider {
509
529
  * @param handler - the handler
510
530
  */
511
531
  addUnloadCb(handler: UnloadHandler): void;
532
+ /**
533
+ * Add this hook so that it is automatically removed during unloading
534
+ * @param hooks - The single hook or an array of IInstrumentHook objects
535
+ */
536
+ addUnloadHook(hooks: IUnloadHook | IUnloadHook[] | Iterator<IUnloadHook> | ILegacyUnloadHook | ILegacyUnloadHook[] | Iterator<ILegacyUnloadHook>): void;
512
537
  /**
513
538
  * Flush and send any batched / cached data immediately
514
539
  * @param async - send data asynchronously when true (defaults to true)
@@ -528,6 +553,13 @@ export declare interface IAppInsightsCore extends IPerfManagerProvider {
528
553
  * Sets the current distributed trace context for this instance if available
529
554
  */
530
555
  setTraceCtx(newTraceCtx: IDistributedTraceContext | null | undefined): void;
556
+ /**
557
+ * Watches and tracks changes for accesses to the current config, and if the accessed config changes the
558
+ * handler will be recalled.
559
+ * @param handler
560
+ * @returns A watcher handler instance that can be used to remove itself when being unloaded
561
+ */
562
+ onCfgChange<T extends IConfiguration = IConfiguration>(handler: WatcherFunction<T>): IUnloadHook;
531
563
  }
532
564
 
533
565
  /**
@@ -627,13 +659,13 @@ declare interface IBaseProcessingContext {
627
659
  /**
628
660
  * Gets the named extension config
629
661
  */
630
- getExtCfg: <T>(identifier: string, defaultValue?: T | any, mergeDefault?: GetExtCfgMergeType) => T;
662
+ getExtCfg: <T>(identifier: string, defaultValue?: IConfigDefaults<T>) => T;
631
663
  /**
632
664
  * Gets the named config from either the named identifier extension or core config if neither exist then the
633
665
  * default value is returned
634
- * @param identifier The named extension identifier
635
- * @param field The config field name
636
- * @param defaultValue The default value to return if no defined config exists
666
+ * @param identifier - The named extension identifier
667
+ * @param field - The config field name
668
+ * @param defaultValue - The default value to return if no defined config exists
637
669
  */
638
670
  getConfig: (identifier: string, field: string, defaultValue?: number | string | boolean | string[] | RegExp[] | Function) => number | string | boolean | string[] | RegExp[] | Function;
639
671
  /**
@@ -1025,6 +1057,51 @@ declare interface IConfig {
1025
1057
  addIntEndpoints?: boolean;
1026
1058
  }
1027
1059
 
1060
+ /**
1061
+ * The type to identify whether the default value should be applied in preference to the provided value.
1062
+ */
1063
+ declare type IConfigCheckFn<V> = (value: V) => boolean;
1064
+
1065
+ /**
1066
+ * The default values with a check function
1067
+ */
1068
+ declare interface IConfigDefaultCheck<T, V, C extends IConfiguration = IConfiguration> {
1069
+ /**
1070
+ * Callback function to check if the user-supplied value is valid, if not the default will be applied
1071
+ */
1072
+ isVal?: IConfigCheckFn<V>;
1073
+ /**
1074
+ * Optional function to allow converting and setting of the default value
1075
+ */
1076
+ set?: IConfigSetFn<T, V>;
1077
+ /**
1078
+ * The default value to apply if the user-supplied value is not valid
1079
+ */
1080
+ v?: V;
1081
+ /**
1082
+ * The default fallback key if the main key is not present, this is the key value from the config
1083
+ */
1084
+ fb?: keyof T | keyof C | Array<keyof T | keyof C>;
1085
+ /**
1086
+ * Use this check to determine the default fallback, default only checked whether the property isDefined,
1087
+ * therefore `null`; `""` are considered to be valid values.
1088
+ */
1089
+ dfVal?: (value: any) => boolean;
1090
+ }
1091
+
1092
+ /**
1093
+ * The Type definition to define default values to be applied to the config
1094
+ * The value may be either the direct value or a ConfigDefaultCheck definition
1095
+ */
1096
+ declare type IConfigDefaults<T, C extends IConfiguration = IConfiguration> = {
1097
+ [key in keyof T]: T[key] | IConfigDefaultCheck<T, T[key], C>;
1098
+ };
1099
+
1100
+ /**
1101
+ * The type which identifies the function use to validate the user supplied value
1102
+ */
1103
+ declare type IConfigSetFn<T, V> = (value: any, defValue: V, theConfig: T) => V;
1104
+
1028
1105
  /**
1029
1106
  * Configuration provided to SDK core
1030
1107
  */
@@ -1206,6 +1283,11 @@ declare interface ICookieMgr {
1206
1283
  * @returns - True if the cookie was marked for deletion otherwise false (Because cookie usage is not available)
1207
1284
  */
1208
1285
  purge(name: string, path?: string): boolean;
1286
+ /**
1287
+ * Optional Callback hook to allow the diagnostic logger to update it's configuration
1288
+ * @param updateState
1289
+ */
1290
+ update?(updateState: ITelemetryUpdateState): void;
1209
1291
  }
1210
1292
 
1211
1293
  /**
@@ -1306,20 +1388,20 @@ declare interface IDiagnosticLogger {
1306
1388
  queue: _InternalLogMessage[];
1307
1389
  /**
1308
1390
  * This method will throw exceptions in debug mode or attempt to log the error as a console warning.
1309
- * @param severity {LoggingSeverity} - The severity of the log message
1310
- * @param message {_InternalLogMessage} - The log message.
1391
+ * @param severity - {LoggingSeverity} - The severity of the log message
1392
+ * @param message - {_InternalLogMessage} - The log message.
1311
1393
  */
1312
1394
  throwInternal(severity: LoggingSeverity, msgId: _InternalMessageId, msg: string, properties?: Object, isUserAct?: boolean): void;
1313
1395
  /**
1314
1396
  * This will write a warning to the console if possible
1315
- * @param message {string} - The warning message
1397
+ * @param message - {string} - The warning message
1316
1398
  */
1317
1399
  warnToConsole(message: string): void;
1318
1400
  /**
1319
1401
  * This will write an error to the console if possible.
1320
1402
  * Provided by the default DiagnosticLogger instance, and internally the SDK will fall back to warnToConsole, however,
1321
1403
  * direct callers MUST check for its existence on the logger as you can provide your own IDiagnosticLogger instance.
1322
- * @param message {string} - The error message
1404
+ * @param message - {string} - The error message
1323
1405
  */
1324
1406
  errorToConsole?(message: string): void;
1325
1407
  /**
@@ -1328,10 +1410,15 @@ declare interface IDiagnosticLogger {
1328
1410
  resetInternalMessageCount(): void;
1329
1411
  /**
1330
1412
  * Logs a message to the internal queue.
1331
- * @param severity {LoggingSeverity} - The severity of the log message
1332
- * @param message {_InternalLogMessage} - The message to log.
1413
+ * @param severity - {LoggingSeverity} - The severity of the log message
1414
+ * @param message - {_InternalLogMessage} - The message to log.
1333
1415
  */
1334
1416
  logInternalMessage?(severity: LoggingSeverity, message: _InternalLogMessage): void;
1417
+ /**
1418
+ * Optional Callback hook to allow the diagnostic logger to update it's configuration
1419
+ * @param updateState
1420
+ */
1421
+ update?(updateState: ITelemetryUpdateState): void;
1335
1422
  }
1336
1423
 
1337
1424
  declare interface IDistributedTraceContext {
@@ -1378,6 +1465,39 @@ declare interface IDistributedTraceContext {
1378
1465
  setTraceFlags(newValue?: number): void;
1379
1466
  }
1380
1467
 
1468
+ /**
1469
+ * This interface identifies the config which can track changes
1470
+ */
1471
+ declare interface IDynamicConfigHandler<T extends IConfiguration> {
1472
+ /**
1473
+ * Unique Id for this config handler
1474
+ */
1475
+ readonly uid: string;
1476
+ /**
1477
+ * Link back to the configuration object that should be used to get/set values
1478
+ */
1479
+ cfg: T;
1480
+ /**
1481
+ * The logger instance to use to loger any issues
1482
+ */
1483
+ logger: IDiagnosticLogger;
1484
+ /**
1485
+ * Helper to call any listeners that are waiting to be notified
1486
+ */
1487
+ notify: () => void;
1488
+ /**
1489
+ * Watch and track changes for accesses to the current config anb
1490
+ */
1491
+ watch: (configHandler: WatcherFunction<T>) => IWatcherHandler<T>;
1492
+ /**
1493
+ * Set the value against the provided config/name with the value, the property
1494
+ * will be converted to be dynamic (if not already) as long as the provided config
1495
+ * is already a tracked dynamic object.
1496
+ * @throws TypeError if the provided config is not a monitored dynamic config
1497
+ */
1498
+ set: <C, V>(theConfig: C, name: string, value: V) => V;
1499
+ }
1500
+
1381
1501
  declare interface IEnvelope extends ISerializable {
1382
1502
  /**
1383
1503
  * Envelope version. For internal use only. By assigning this the default, it will not be serialized within the payload unless changed to a value other than #1.
@@ -1430,76 +1550,14 @@ export declare interface IEventTelemetry extends IPartC {
1430
1550
  iKey?: string;
1431
1551
  }
1432
1552
 
1433
- declare interface IInstrumentCallDetails {
1434
- name: string;
1435
- inst: any;
1436
- /**
1437
- * This returns an object that the hook function can use to store hook specific
1438
- * context, it it not shared with any other hook instances and is unique for the
1439
- * current call.
1440
- * A hook implementation can use this to pass / share context between different
1441
- * hook callbacks eg. request/response requst/hookErrors etc.
1442
- */
1443
- ctx: () => any;
1444
- /**
1445
- * Allows the hook functions to replace the original arguments
1446
- * @param idx - The argument index (0 based)
1447
- * @param value - The new value for the argument
1448
- */
1449
- set: (idx: number, value: any) => void;
1450
- /**
1451
- * The result of the original method, only populated after the original method has returned
1452
- */
1453
- rslt?: any;
1454
- /**
1455
- * The error (exception) which occurred while executing the original method
1456
- */
1457
- err?: Error;
1458
- /**
1459
- * The Event object from (window.event) at the start of the original call
1460
- */
1461
- evt?: Event;
1462
- }
1463
-
1464
1553
  /**
1465
- * The holder of the specific instance callback
1554
+ * An alternate interface which provides automatic removal during unloading of the component
1466
1555
  */
1467
- declare interface IInstrumentHook {
1468
- /** Unique Id for this callback on the hooked method */
1469
- id: number;
1470
- /** Holds the callbacks */
1471
- cbks: IInstrumentHooksCallbacks;
1472
- /** Remove this hook from the function */
1473
- rm: () => void;
1474
- }
1475
-
1476
- /**
1477
- * The callbacks to call for the instrumented function, you must provide at least the request and/or response callbacks, both are not required.
1478
- * You must always supply the error callback
1479
- */
1480
- declare interface IInstrumentHooksCallbacks {
1481
- /**
1482
- * [Optional] Namespace details (same as the namespace used for events), useful for debugging and testing to
1483
- * identify the source of the instrumented hooks
1484
- */
1485
- ns?: string | string[];
1556
+ declare interface ILegacyUnloadHook {
1486
1557
  /**
1487
- * The hook callback to call before the original function is called
1558
+ * Legacy Self remove the referenced component
1488
1559
  */
1489
- req?: InstrumentorHooksCallback;
1490
- /**
1491
- * The hook callback to call after the original function was called
1492
- */
1493
- rsp?: InstrumentorHooksCallback;
1494
- /**
1495
- * The callback to call if the hook function causes an exception
1496
- */
1497
- hkErr?: InstrumentorHooksCallback;
1498
- /**
1499
- * The callback to call if the original function causes an exception, even if you
1500
- * supply a callback the original exception will still be thrown
1501
- */
1502
- fnErr?: InstrumentorHooksCallback;
1560
+ remove: () => void;
1503
1561
  }
1504
1562
 
1505
1563
  export declare interface ILoadedPlugin<T extends IPlugin> {
@@ -1573,20 +1631,20 @@ export declare interface IMetricTelemetry extends IPartC {
1573
1631
  declare interface INotificationListener {
1574
1632
  /**
1575
1633
  * [Optional] A function called when events are sent.
1576
- * @param {ITelemetryItem[]} events - The array of events that have been sent.
1634
+ * @param events - The array of events that have been sent.
1577
1635
  */
1578
1636
  eventsSent?: (events: ITelemetryItem[]) => void;
1579
1637
  /**
1580
1638
  * [Optional] A function called when events are discarded.
1581
- * @param {ITelemetryItem[]} events - The array of events that have been discarded.
1582
- * @param {number} reason - The reason for discarding the events. The EventsDiscardedReason
1639
+ * @param events - The array of events that have been discarded.
1640
+ * @param reason - The reason for discarding the events. The EventsDiscardedReason
1583
1641
  * constant should be used to check the different values.
1584
1642
  */
1585
1643
  eventsDiscarded?: (events: ITelemetryItem[], reason: number) => void;
1586
1644
  /**
1587
1645
  * [Optional] A function called when the events have been requested to be sent to the sever.
1588
- * @param {number} sendReason - The reason why the event batch is being sent.
1589
- * @param {boolean} isAsync - A flag which identifies whether the requests are being sent in an async or sync manner.
1646
+ * @param sendReason - The reason why the event batch is being sent.
1647
+ * @param isAsync - A flag which identifies whether the requests are being sent in an async or sync manner.
1590
1648
  */
1591
1649
  eventsSendRequest?: (sendReason: number, isAsync?: boolean) => void;
1592
1650
  /**
@@ -1604,46 +1662,40 @@ declare interface INotificationManager {
1604
1662
  listeners: INotificationListener[];
1605
1663
  /**
1606
1664
  * Adds a notification listener.
1607
- * @param {INotificationListener} listener - The notification listener to be added.
1665
+ * @param listener - The notification listener to be added.
1608
1666
  */
1609
1667
  addNotificationListener(listener: INotificationListener): void;
1610
1668
  /**
1611
1669
  * Removes all instances of the listener.
1612
- * @param {INotificationListener} listener - AWTNotificationListener to remove.
1670
+ * @param listener - AWTNotificationListener to remove.
1613
1671
  */
1614
1672
  removeNotificationListener(listener: INotificationListener): void;
1615
1673
  /**
1616
1674
  * Notification for events sent.
1617
- * @param {ITelemetryItem[]} events - The array of events that have been sent.
1675
+ * @param events - The array of events that have been sent.
1618
1676
  */
1619
1677
  eventsSent(events: ITelemetryItem[]): void;
1620
1678
  /**
1621
1679
  * Notification for events being discarded.
1622
- * @param {ITelemetryItem[]} events - The array of events that have been discarded by the SDK.
1623
- * @param {number} reason - The reason for which the SDK discarded the events. The EventsDiscardedReason
1680
+ * @param events - The array of events that have been discarded by the SDK.
1681
+ * @param reason - The reason for which the SDK discarded the events. The EventsDiscardedReason
1624
1682
  * constant should be used to check the different values.
1625
1683
  */
1626
1684
  eventsDiscarded(events: ITelemetryItem[], reason: number): void;
1627
1685
  /**
1628
1686
  * [Optional] A function called when the events have been requested to be sent to the sever.
1629
- * @param {number} sendReason - The reason why the event batch is being sent.
1630
- * @param {boolean} isAsync - A flag which identifies whether the requests are being sent in an async or sync manner.
1687
+ * @param sendReason - The reason why the event batch is being sent.
1688
+ * @param isAsync - A flag which identifies whether the requests are being sent in an async or sync manner.
1631
1689
  */
1632
1690
  eventsSendRequest?(sendReason: number, isAsync: boolean): void;
1633
1691
  /**
1634
1692
  * [Optional] This event is sent if you have enabled perf events, they are primarily used to track internal performance testing and debugging
1635
1693
  * the event can be displayed via the debug plugin extension.
1636
- * @param perfEvent
1694
+ * @param perfEvent - The perf event details
1637
1695
  */
1638
1696
  perfEvent?(perfEvent: IPerfEvent): void;
1639
1697
  }
1640
1698
 
1641
- /**
1642
- * A callback function that will be called for the wrapped instrumentation function
1643
- * before the original function is executed.
1644
- */
1645
- declare type InstrumentorHooksCallback = (funcArgs: IInstrumentCallDetails, ...orgArgs: any[]) => void;
1646
-
1647
1699
  declare class _InternalLogMessage {
1648
1700
  static dataType: string;
1649
1701
  message: string;
@@ -1651,12 +1703,7 @@ declare class _InternalLogMessage {
1651
1703
  constructor(msgId: _InternalMessageId, msg: string, isUserAct?: boolean, properties?: Object);
1652
1704
  }
1653
1705
 
1654
- /**
1655
- * Internal message ID. Please create a new one for every conceptually different message. Please keep alphabetically ordered
1656
- */
1657
- export declare const _InternalMessageId: EnumValue<typeof _eInternalMessageId>;
1658
-
1659
- export declare type _InternalMessageId = number | _eInternalMessageId;
1706
+ declare type _InternalMessageId = number | _eInternalMessageId;
1660
1707
 
1661
1708
  export declare interface IPageViewPerformanceTelemetry extends IPartC {
1662
1709
  /**
@@ -1817,14 +1864,14 @@ declare interface IPerfManager {
1817
1864
  /**
1818
1865
  * Create a new event and start timing, the manager may return null/undefined to indicate that it does not
1819
1866
  * want to monitor this source event.
1820
- * @param src The source name of the event
1867
+ * @param src - The source name of the event
1821
1868
  * @param payloadDetails - An optional callback function to fetch the payload details for the event.
1822
1869
  * @param isAsync - Is the event occurring from a async event
1823
1870
  */
1824
1871
  create(src: string, payloadDetails?: () => any, isAsync?: boolean): IPerfEvent | null | undefined;
1825
1872
  /**
1826
1873
  * Complete the perfEvent and fire any notifications.
1827
- * @param perfEvent Fire the event which will also complete the passed event
1874
+ * @param perfEvent - Fire the event which will also complete the passed event
1828
1875
  */
1829
1876
  fire(perfEvent: IPerfEvent): void;
1830
1877
  /**
@@ -1850,7 +1897,7 @@ declare interface IPerfManagerProvider {
1850
1897
  getPerfMgr(): IPerfManager;
1851
1898
  /**
1852
1899
  * Set the current performance manager
1853
- * @param perfMgr The performance manager
1900
+ * @param perfMgr - The performance manager
1854
1901
  */
1855
1902
  setPerfMgr(perfMgr: IPerfManager): void;
1856
1903
  }
@@ -2019,68 +2066,68 @@ declare interface ISenderConfig {
2019
2066
  /**
2020
2067
  * The url to which payloads will be sent
2021
2068
  */
2022
- endpointUrl: () => string;
2069
+ endpointUrl: string;
2023
2070
  /**
2024
2071
  * The JSON format (normal vs line delimited). True means line delimited JSON.
2025
2072
  */
2026
- emitLineDelimitedJson: () => boolean;
2073
+ emitLineDelimitedJson: boolean;
2027
2074
  /**
2028
2075
  * The maximum size of a batch in bytes
2029
2076
  */
2030
- maxBatchSizeInBytes: () => number;
2077
+ maxBatchSizeInBytes: number;
2031
2078
  /**
2032
2079
  * The maximum interval allowed between calls to batchInvoke
2033
2080
  */
2034
- maxBatchInterval: () => number;
2081
+ maxBatchInterval: number;
2035
2082
  /**
2036
2083
  * The master off switch. Do not send any data if set to TRUE
2037
2084
  */
2038
- disableTelemetry: () => boolean;
2085
+ disableTelemetry: boolean;
2039
2086
  /**
2040
2087
  * Store a copy of a send buffer in the session storage
2041
2088
  */
2042
- enableSessionStorageBuffer: () => boolean;
2089
+ enableSessionStorageBuffer: boolean;
2043
2090
  /**
2044
2091
  * Is retry handler disabled.
2045
2092
  * If enabled, retry on 206 (partial success), 408 (timeout), 429 (too many requests), 500 (internal server error) and 503 (service unavailable).
2046
2093
  */
2047
- isRetryDisabled: () => boolean;
2048
- isBeaconApiDisabled: () => boolean;
2094
+ isRetryDisabled: boolean;
2095
+ isBeaconApiDisabled: boolean;
2049
2096
  /**
2050
2097
  * Don't use XMLHttpRequest or XDomainRequest (for IE < 9) by default instead attempt to use fetch() or sendBeacon.
2051
2098
  * If no other transport is available it will still use XMLHttpRequest
2052
2099
  */
2053
- disableXhr: () => boolean;
2100
+ disableXhr: boolean;
2054
2101
  /**
2055
2102
  * If fetch keepalive is supported do not use it for sending events during unload, it may still fallback to fetch() without keepalive
2056
2103
  */
2057
- onunloadDisableFetch: () => boolean;
2104
+ onunloadDisableFetch: boolean;
2058
2105
  /**
2059
2106
  * Is beacon disabled on page unload.
2060
2107
  * If enabled, flush events through beaconSender.
2061
2108
  */
2062
- onunloadDisableBeacon: () => boolean;
2109
+ onunloadDisableBeacon: boolean;
2063
2110
  /**
2064
2111
  * (Optional) Override the instrumentation key that this channel instance sends to
2065
2112
  */
2066
- instrumentationKey: () => string;
2067
- namePrefix: () => string;
2068
- samplingPercentage: () => number;
2113
+ instrumentationKey: string;
2114
+ namePrefix: string;
2115
+ samplingPercentage: number;
2069
2116
  /**
2070
2117
  * (Optional) The ability for the user to provide extra headers
2071
2118
  */
2072
- customHeaders: () => [{
2119
+ customHeaders: [{
2073
2120
  header: string;
2074
2121
  value: string;
2075
2122
  }];
2076
2123
  /**
2077
2124
  * (Optional) Provide user an option to convert undefined field to user defined value.
2078
2125
  */
2079
- convertUndefined: () => any;
2126
+ convertUndefined: any;
2080
2127
  /**
2081
2128
  * (Optional) The number of events that can be kept in memory before the SDK starts to drop events. By default, this is 10,000.
2082
2129
  */
2083
- eventsLimitInMem: () => number;
2130
+ eventsLimitInMem: number;
2084
2131
  }
2085
2132
 
2086
2133
  declare interface ISerializable {
@@ -2099,7 +2146,7 @@ declare interface IStackDetails {
2099
2146
  obj: string[];
2100
2147
  }
2101
2148
 
2102
- declare interface ITelemetryInitializerHandler {
2149
+ declare interface ITelemetryInitializerHandler extends ILegacyUnloadHook {
2103
2150
  remove(): void;
2104
2151
  }
2105
2152
 
@@ -2217,12 +2264,22 @@ declare interface ITelemetryUpdateState {
2217
2264
  * Identifies the reason for the update notification, this is a bitwise numeric value
2218
2265
  */
2219
2266
  reason: TelemetryUpdateReason;
2267
+ /**
2268
+ * This is a new active configuration that should be used
2269
+ */
2270
+ cfg?: IConfiguration;
2271
+ /**
2272
+ * The detected changes
2273
+ */
2274
+ oldCfg?: IConfiguration;
2220
2275
  /**
2221
2276
  * If this is a configuration update this was the previous configuration that was used
2222
2277
  */
2278
+ newConfig?: IConfiguration;
2223
2279
  /**
2224
- * If this is a configuration update is the new configuration that is being used
2280
+ * Was the new config requested to be merged with the existing config
2225
2281
  */
2282
+ merge?: boolean;
2226
2283
  /**
2227
2284
  * This holds a collection of plugins that have been added (if the reason identifies that one or more plugins have been added)
2228
2285
  */
@@ -2254,6 +2311,26 @@ export declare interface ITraceTelemetry extends IPartC {
2254
2311
  iKey?: string;
2255
2312
  }
2256
2313
 
2314
+ /**
2315
+ * An interface which provides automatic removal during unloading of the component
2316
+ */
2317
+ declare interface IUnloadHook {
2318
+ /**
2319
+ * Self remove the referenced component
2320
+ */
2321
+ rm: () => void;
2322
+ }
2323
+
2324
+ declare interface IWatchDetails<T extends IConfiguration> {
2325
+ cfg: T;
2326
+ hdlr: IDynamicConfigHandler<T>;
2327
+ }
2328
+
2329
+ declare interface IWatcherHandler<T extends IConfiguration> extends IUnloadHook {
2330
+ fn: WatcherFunction<T>;
2331
+ rm: () => void;
2332
+ }
2333
+
2257
2334
  declare const LoggingSeverity: EnumValue<typeof eLoggingSeverity>;
2258
2335
 
2259
2336
  declare type LoggingSeverity = number | eLoggingSeverity;
@@ -2320,8 +2397,8 @@ export declare class Sender extends BaseTelemetryPlugin implements IChannelContr
2320
2397
  _xhrReadyStateChange(xhr: XMLHttpRequest, payload: string[], countOfItemsInPayload: number): void;
2321
2398
  /**
2322
2399
  * Immediately send buffered data
2323
- * @param async {boolean} - Indicates if the events should be sent asynchronously
2324
- * @param forcedSender {SenderFunction} - Indicates the forcedSender, undefined if not passed
2400
+ * @param async - {boolean} - Indicates if the events should be sent asynchronously
2401
+ * @param forcedSender - {SenderFunction} - Indicates the forcedSender, undefined if not passed
2325
2402
  */
2326
2403
  triggerSend(async?: boolean, forcedSender?: SenderFunction, sendReason?: SendRequestReason): void;
2327
2404
  /**
@@ -2342,8 +2419,8 @@ export declare class Sender extends BaseTelemetryPlugin implements IChannelContr
2342
2419
  _xdrOnLoad(xdr: XDomainRequest, payload: string[]): void;
2343
2420
  /**
2344
2421
  * Add header to request
2345
- * @param name - Header name.
2346
- * @param value - Header value.
2422
+ * @param name - Header name.
2423
+ * @param value - Header value.
2347
2424
  */
2348
2425
  addHeader(name: string, value: string): void;
2349
2426
  }
@@ -2442,6 +2519,7 @@ declare const enum TelemetryUpdateReason {
2442
2519
  /**
2443
2520
  * The configuration has ben updated or changed
2444
2521
  */
2522
+ ConfigurationChanged = 1,
2445
2523
  /**
2446
2524
  * One or more plugins have been added
2447
2525
  */
@@ -2456,6 +2534,8 @@ export { throwError }
2456
2534
 
2457
2535
  declare type UnloadHandler = (itemCtx: IProcessTelemetryUnloadContext, unloadState: ITelemetryUnloadState) => void;
2458
2536
 
2537
+ declare type WatcherFunction<T extends IConfiguration> = (details: IWatchDetails<T>) => void;
2538
+
2459
2539
  declare interface XDomainRequest extends XMLHttpRequestEventTarget {
2460
2540
  readonly responseText: string;
2461
2541
  send(payload: string): void;