@microsoft/applicationinsights-core-js 2.8.0-beta.2203-04 → 2.8.0-beta.2203-07

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (102) hide show
  1. package/browser/applicationinsights-core-js.integrity.json +9 -9
  2. package/browser/applicationinsights-core-js.js +147 -33
  3. package/browser/applicationinsights-core-js.js.map +1 -1
  4. package/browser/applicationinsights-core-js.min.js +2 -2
  5. package/browser/applicationinsights-core-js.min.js.map +1 -1
  6. package/dist/applicationinsights-core-js.api.json +1832 -94
  7. package/dist/applicationinsights-core-js.api.md +70 -12
  8. package/dist/applicationinsights-core-js.d.ts +167 -11
  9. package/dist/applicationinsights-core-js.js +147 -33
  10. package/dist/applicationinsights-core-js.js.map +1 -1
  11. package/dist/applicationinsights-core-js.min.js +2 -2
  12. package/dist/applicationinsights-core-js.min.js.map +1 -1
  13. package/dist/applicationinsights-core-js.rollup.d.ts +170 -14
  14. package/dist-esm/JavaScriptSDK/AppInsightsCore.js +1 -1
  15. package/dist-esm/JavaScriptSDK/BaseCore.js +41 -17
  16. package/dist-esm/JavaScriptSDK/BaseCore.js.map +1 -1
  17. package/dist-esm/JavaScriptSDK/BaseTelemetryPlugin.js +31 -3
  18. package/dist-esm/JavaScriptSDK/BaseTelemetryPlugin.js.map +1 -1
  19. package/dist-esm/JavaScriptSDK/ChannelController.js +15 -2
  20. package/dist-esm/JavaScriptSDK/ChannelController.js.map +1 -1
  21. package/dist-esm/JavaScriptSDK/Constants.js +1 -1
  22. package/dist-esm/JavaScriptSDK/CookieMgr.js +3 -2
  23. package/dist-esm/JavaScriptSDK/CookieMgr.js.map +1 -1
  24. package/dist-esm/JavaScriptSDK/CoreUtils.js +1 -1
  25. package/dist-esm/JavaScriptSDK/DataCacheHelper.js +1 -1
  26. package/dist-esm/JavaScriptSDK/DbgExtensionUtils.js +1 -1
  27. package/dist-esm/JavaScriptSDK/DiagnosticLogger.js +14 -1
  28. package/dist-esm/JavaScriptSDK/DiagnosticLogger.js.map +1 -1
  29. package/dist-esm/JavaScriptSDK/EnvUtils.js +1 -1
  30. package/dist-esm/JavaScriptSDK/EventHelpers.js +18 -13
  31. package/dist-esm/JavaScriptSDK/EventHelpers.js.map +1 -1
  32. package/dist-esm/JavaScriptSDK/HelperFuncs.js +2 -12
  33. package/dist-esm/JavaScriptSDK/HelperFuncs.js.map +1 -1
  34. package/dist-esm/JavaScriptSDK/InstrumentHooks.js +1 -1
  35. package/dist-esm/JavaScriptSDK/InternalConstants.js +1 -1
  36. package/dist-esm/JavaScriptSDK/NotificationManager.js +1 -1
  37. package/dist-esm/JavaScriptSDK/PerfManager.js +1 -1
  38. package/dist-esm/JavaScriptSDK/ProcessTelemetryContext.js +56 -5
  39. package/dist-esm/JavaScriptSDK/ProcessTelemetryContext.js.map +1 -1
  40. package/dist-esm/JavaScriptSDK/RandomHelper.js +1 -1
  41. package/dist-esm/JavaScriptSDK/TelemetryHelpers.js +1 -1
  42. package/dist-esm/JavaScriptSDK/TelemetryInitializerPlugin.js +3 -2
  43. package/dist-esm/JavaScriptSDK/TelemetryInitializerPlugin.js.map +1 -1
  44. package/dist-esm/JavaScriptSDK/UnloadHandlerContainer.js +3 -2
  45. package/dist-esm/JavaScriptSDK/UnloadHandlerContainer.js.map +1 -1
  46. package/dist-esm/JavaScriptSDK.Enums/EventsDiscardedReason.js +1 -1
  47. package/dist-esm/JavaScriptSDK.Enums/LoggingEnums.js +1 -1
  48. package/dist-esm/JavaScriptSDK.Enums/SendRequestReason.js +1 -1
  49. package/dist-esm/JavaScriptSDK.Enums/TelemetryUnloadReason.js +1 -1
  50. package/dist-esm/JavaScriptSDK.Enums/TelemetryUpdateReason.js +8 -0
  51. package/dist-esm/JavaScriptSDK.Enums/TelemetryUpdateReason.js.map +1 -0
  52. package/dist-esm/JavaScriptSDK.Interfaces/IAppInsightsCore.js +1 -1
  53. package/dist-esm/JavaScriptSDK.Interfaces/IChannelControls.js +1 -1
  54. package/dist-esm/JavaScriptSDK.Interfaces/IConfiguration.js +1 -1
  55. package/dist-esm/JavaScriptSDK.Interfaces/ICookieMgr.js +1 -1
  56. package/dist-esm/JavaScriptSDK.Interfaces/IDbgExtension.js +1 -1
  57. package/dist-esm/JavaScriptSDK.Interfaces/IDiagnosticLogger.js +1 -1
  58. package/dist-esm/JavaScriptSDK.Interfaces/IInstrumentHooks.js +1 -1
  59. package/dist-esm/JavaScriptSDK.Interfaces/INotificationListener.js +1 -1
  60. package/dist-esm/JavaScriptSDK.Interfaces/INotificationManager.js +1 -1
  61. package/dist-esm/JavaScriptSDK.Interfaces/IPerfEvent.js +1 -1
  62. package/dist-esm/JavaScriptSDK.Interfaces/IPerfManager.js +1 -1
  63. package/dist-esm/JavaScriptSDK.Interfaces/IProcessTelemetryContext.js +1 -1
  64. package/dist-esm/JavaScriptSDK.Interfaces/ITelemetryInitializers.js +1 -1
  65. package/dist-esm/JavaScriptSDK.Interfaces/ITelemetryItem.js +1 -1
  66. package/dist-esm/JavaScriptSDK.Interfaces/ITelemetryPlugin.js +1 -1
  67. package/dist-esm/JavaScriptSDK.Interfaces/ITelemetryPluginChain.js +1 -1
  68. package/dist-esm/JavaScriptSDK.Interfaces/ITelemetryUnloadState.js +1 -1
  69. package/dist-esm/JavaScriptSDK.Interfaces/ITelemetryUpdateState.js +8 -0
  70. package/dist-esm/JavaScriptSDK.Interfaces/ITelemetryUpdateState.js.map +1 -0
  71. package/dist-esm/applicationinsights-core-js.js +3 -3
  72. package/dist-esm/applicationinsights-core-js.js.map +1 -1
  73. package/package.json +1 -1
  74. package/src/JavaScriptSDK/BaseCore.ts +82 -17
  75. package/src/JavaScriptSDK/BaseTelemetryPlugin.ts +55 -3
  76. package/src/JavaScriptSDK/ChannelController.ts +20 -1
  77. package/src/JavaScriptSDK/CookieMgr.ts +3 -1
  78. package/src/JavaScriptSDK/DiagnosticLogger.ts +14 -0
  79. package/src/JavaScriptSDK/EventHelpers.ts +18 -12
  80. package/src/JavaScriptSDK/HelperFuncs.ts +3 -1
  81. package/src/JavaScriptSDK/ProcessTelemetryContext.ts +71 -8
  82. package/src/JavaScriptSDK/TelemetryInitializerPlugin.ts +3 -1
  83. package/src/JavaScriptSDK/UnloadHandlerContainer.ts +3 -1
  84. package/src/JavaScriptSDK.Enums/TelemetryUpdateReason.ts +27 -0
  85. package/src/JavaScriptSDK.Interfaces/IAppInsightsCore.ts +22 -5
  86. package/src/JavaScriptSDK.Interfaces/IInstrumentHooks.ts +11 -6
  87. package/src/JavaScriptSDK.Interfaces/IProcessTelemetryContext.ts +25 -2
  88. package/src/JavaScriptSDK.Interfaces/ITelemetryPlugin.ts +12 -1
  89. package/src/JavaScriptSDK.Interfaces/ITelemetryUpdateState.ts +34 -0
  90. package/types/JavaScriptSDK/BaseCore.d.ts +32 -3
  91. package/types/JavaScriptSDK/BaseTelemetryPlugin.d.ts +17 -1
  92. package/types/JavaScriptSDK/DiagnosticLogger.d.ts +10 -0
  93. package/types/JavaScriptSDK/EventHelpers.d.ts +4 -2
  94. package/types/JavaScriptSDK/HelperFuncs.d.ts +2 -1
  95. package/types/JavaScriptSDK/ProcessTelemetryContext.d.ts +9 -1
  96. package/types/JavaScriptSDK.Enums/TelemetryUpdateReason.d.ts +20 -0
  97. package/types/JavaScriptSDK.Interfaces/IAppInsightsCore.d.ts +20 -4
  98. package/types/JavaScriptSDK.Interfaces/IInstrumentHooks.d.ts +5 -0
  99. package/types/JavaScriptSDK.Interfaces/IProcessTelemetryContext.d.ts +23 -2
  100. package/types/JavaScriptSDK.Interfaces/ITelemetryPlugin.d.ts +11 -1
  101. package/types/JavaScriptSDK.Interfaces/ITelemetryUpdateState.d.ts +22 -0
  102. package/types/applicationinsights-core-js.d.ts +6 -3
@@ -12,7 +12,7 @@ import { strShimPrototype as strPrototype } from '@microsoft/applicationinsights
12
12
  import { strShimUndefined as strUndefined } from '@microsoft/applicationinsights-shims';
13
13
 
14
14
  // @public
15
- export function __getRegisteredEvents(target: any, evtName?: string): _IRegisteredEvents[];
15
+ export function __getRegisteredEvents(target: any, eventName?: string, evtNamespace?: string | string[]): _IRegisteredEvents[];
16
16
 
17
17
  // @public
18
18
  export function addEventHandler(eventName: string, callback: any, evtNamespace?: string | string[]): boolean;
@@ -60,8 +60,7 @@ export function attachEvent(obj: any, eventNameWithoutOn: string, handlerRef: an
60
60
  export class BaseCore implements IAppInsightsCore {
61
61
  constructor();
62
62
  addNotificationListener(listener: INotificationListener): void;
63
- // (undocumented)
64
- addPlugin<T extends IPlugin = ITelemetryPlugin>(plugin: T, replaceExisting: boolean, doAsync: boolean, addCb?: (added?: boolean) => void): void;
63
+ addPlugin<T extends IPlugin = ITelemetryPlugin>(plugin: T, replaceExisting?: boolean, doAsync?: boolean, addCb?: (added?: boolean) => void): void;
65
64
  addTelemetryInitializer(telemetryInitializer: TelemetryInitializerFunction): ITelemetryInitializerHandler | void;
66
65
  addUnloadCb(handler: UnloadHandler): void;
67
66
  // (undocumented)
@@ -73,6 +72,7 @@ export class BaseCore implements IAppInsightsCore {
73
72
  evtNamespace(): string;
74
73
  // (undocumented)
75
74
  _extensions: IPlugin[];
75
+ flush(isAsync?: boolean, callBack?: (flushComplete?: boolean) => void, sendReason?: SendRequestReason): void;
76
76
  getCookieMgr(): ICookieMgr;
77
77
  // (undocumented)
78
78
  getNotifyMgr(): INotificationManager;
@@ -102,7 +102,8 @@ export class BaseCore implements IAppInsightsCore {
102
102
  stopPollingInternalLogs(): void;
103
103
  // (undocumented)
104
104
  track(telemetryItem: ITelemetryItem): void;
105
- unload(isAsync?: boolean, unloadComplete?: () => void): void;
105
+ unload(isAsync?: boolean, unloadComplete?: (unloadState: ITelemetryUnloadState) => void, cbTimeout?: number): void;
106
+ protected _updateHook?(updateCtx: IProcessTelemetryUpdateContext, updateState: ITelemetryUpdateState): void | boolean;
106
107
  }
107
108
 
108
109
  // @public
@@ -112,8 +113,8 @@ export abstract class BaseTelemetryPlugin implements ITelemetryPlugin {
112
113
  protected _addUnloadCb(handler: UnloadHandler): void;
113
114
  core: IAppInsightsCore;
114
115
  diagLog: (itemCtx?: IProcessTelemetryContext) => IDiagnosticLogger;
115
- // Warning: (ae-forgotten-export) The symbol "IProcessTelemetryUnloadContext" needs to be exported by the entry point applicationinsights-core-js.d.ts
116
116
  protected _doTeardown?: (unloadCtx?: IProcessTelemetryUnloadContext, unloadState?: ITelemetryUnloadState, asyncCallback?: () => void) => void | boolean;
117
+ protected _doUpdate?: (updateCtx?: IProcessTelemetryUpdateContext, updateState?: ITelemetryUpdateState, asyncCallback?: () => void) => void | boolean;
117
118
  protected _getTelCtx: (currentCtx?: IProcessTelemetryContext) => IProcessTelemetryContext;
118
119
  // (undocumented)
119
120
  identifier: string;
@@ -128,6 +129,7 @@ export abstract class BaseTelemetryPlugin implements ITelemetryPlugin {
128
129
  protected setInitialized: (isInitialized: boolean) => void;
129
130
  setNextPlugin: (next: ITelemetryPlugin | ITelemetryPluginChain) => void;
130
131
  teardown(unloadCtx?: IProcessTelemetryUnloadContext, unloadState?: ITelemetryUnloadState): void | boolean;
132
+ update(updateCtx: IProcessTelemetryUpdateContext, updateState: ITelemetryUpdateState): void | boolean;
131
133
  // (undocumented)
132
134
  version?: string;
133
135
  }
@@ -477,12 +479,13 @@ export function hasWindow(): boolean;
477
479
  // @public (undocumented)
478
480
  export interface IAppInsightsCore extends IPerfManagerProvider {
479
481
  addNotificationListener?(listener: INotificationListener): void;
480
- addPlugin<T extends IPlugin = ITelemetryPlugin>(plugin: T, replaceExisting: boolean, doAsync: boolean, addCb?: (added?: boolean) => void): void;
482
+ addPlugin<T extends IPlugin = ITelemetryPlugin>(plugin: T, replaceExisting?: boolean, doAsync?: boolean, addCb?: (added?: boolean) => void): void;
481
483
  addTelemetryInitializer(telemetryInitializer: TelemetryInitializerFunction): ITelemetryInitializerHandler | void;
482
484
  addUnloadCb(handler: UnloadHandler): void;
483
485
  // (undocumented)
484
486
  config: IConfiguration;
485
487
  evtNamespace(): string;
488
+ flush(isAsync?: boolean, callBack?: (flushComplete?: boolean) => void, sendReason?: SendRequestReason, cbTimeout?: number): boolean | void;
486
489
  getCookieMgr(): ICookieMgr;
487
490
  getNotifyMgr(): INotificationManager;
488
491
  getPlugin<T extends IPlugin = IPlugin>(pluginIdentifier: string): ILoadedPlugin<T>;
@@ -502,7 +505,22 @@ export interface IAppInsightsCore extends IPerfManagerProvider {
502
505
  stopPollingInternalLogs?(): void;
503
506
  // (undocumented)
504
507
  track(telemetryItem: ITelemetryItem): void;
505
- unload(isAsync?: boolean, unloadComplete?: () => void): void;
508
+ unload(isAsync?: boolean, unloadComplete?: (unloadState: ITelemetryUnloadState) => void, cbTimeout?: number): void;
509
+ }
510
+
511
+ // @public (undocumented)
512
+ export interface IBaseProcessingContext {
513
+ core: () => IAppInsightsCore;
514
+ createNew: (plugins?: IPlugin[] | ITelemetryPluginChain, startAt?: IPlugin) => IBaseProcessingContext;
515
+ diagLog: () => IDiagnosticLogger;
516
+ getCfg: () => IConfiguration;
517
+ getConfig: (identifier: string, field: string, defaultValue?: number | string | boolean | string[] | RegExp[] | Function) => number | string | boolean | string[] | RegExp[] | Function;
518
+ getExtCfg: <T>(identifier: string, defaultValue?: T | any, mergeDefault?: GetExtCfgMergeType) => T;
519
+ getNext: () => ITelemetryPluginChain;
520
+ hasNext: () => boolean;
521
+ iterate: <T extends ITelemetryPlugin = ITelemetryPlugin>(callback: (plugin: T) => void) => void;
522
+ onComplete: (onComplete: Function, that?: any, ...args: any[]) => void;
523
+ setNext: (nextCtx: ITelemetryPluginChain) => void;
506
524
  }
507
525
 
508
526
  // @public
@@ -691,6 +709,7 @@ export interface IInstrumentHooks {
691
709
  export interface IInstrumentHooksCallbacks {
692
710
  fnErr?: InstrumentorHooksCallback;
693
711
  hkErr?: InstrumentorHooksCallback;
712
+ ns?: string | string[];
694
713
  req?: InstrumentorHooksCallback;
695
714
  rsp?: InstrumentorHooksCallback;
696
715
  }
@@ -872,14 +891,24 @@ export interface IPlugin {
872
891
  readonly version?: string;
873
892
  }
874
893
 
875
- // Warning: (ae-forgotten-export) The symbol "IBaseProcessingContext" needs to be exported by the entry point applicationinsights-core-js.d.ts
876
- //
877
894
  // @public
878
895
  export interface IProcessTelemetryContext extends IBaseProcessingContext {
879
896
  createNew: (plugins?: IPlugin[] | ITelemetryPluginChain, startAt?: IPlugin) => IProcessTelemetryContext;
880
897
  processNext: (env: ITelemetryItem) => boolean | void;
881
898
  }
882
899
 
900
+ // @public
901
+ export interface IProcessTelemetryUnloadContext extends IBaseProcessingContext {
902
+ createNew: (plugins?: IPlugin[] | ITelemetryPluginChain, startAt?: IPlugin) => IProcessTelemetryUnloadContext;
903
+ processNext: (unloadState: ITelemetryUnloadState) => boolean | void;
904
+ }
905
+
906
+ // @public
907
+ export interface IProcessTelemetryUpdateContext extends IBaseProcessingContext {
908
+ createNew: (plugins?: IPlugin[] | ITelemetryPluginChain, startAt?: IPlugin) => IProcessTelemetryUpdateContext;
909
+ processNext: (updateState: ITelemetryUpdateState) => boolean | void;
910
+ }
911
+
883
912
  // @public (undocumented)
884
913
  export interface _IRegisteredEvents {
885
914
  // (undocumented)
@@ -1003,12 +1032,17 @@ export interface ITelemetryUnloadState {
1003
1032
  flushComplete?: boolean;
1004
1033
  // (undocumented)
1005
1034
  isAsync: boolean;
1006
- // Warning: (ae-forgotten-export) The symbol "TelemetryUnloadReason" needs to be exported by the entry point applicationinsights-core-js.d.ts
1007
- //
1008
1035
  // (undocumented)
1009
1036
  reason: TelemetryUnloadReason;
1010
1037
  }
1011
1038
 
1039
+ // @public (undocumented)
1040
+ export interface ITelemetryUpdateState {
1041
+ added?: IPlugin[];
1042
+ reason: TelemetryUpdateReason;
1043
+ removed?: IPlugin[];
1044
+ }
1045
+
1012
1046
  // @public (undocumented)
1013
1047
  export interface IUnloadHandlerContainer {
1014
1048
  // (undocumented)
@@ -1069,7 +1103,10 @@ export { objCreate }
1069
1103
  export function objDefineAccessors<T>(target: any, prop: string, getProp?: () => T, setProp?: (v: T) => void): boolean;
1070
1104
 
1071
1105
  // @public
1072
- export function objExtend<T1, T2, T3, T4, T5, T6>(obj?: boolean | T1, obj2?: T2, obj3?: T3, obj4?: T4, obj5?: T5, obj6?: T6): T1 & T2 & T3 & T4 & T5 & T6;
1106
+ export function objExtend<T2, T3, T4, T5, T6>(deepExtend?: boolean, obj2?: T2, obj3?: T3, obj4?: T4, obj5?: T5, obj6?: T6): T2 & T3 & T4 & T5 & T6;
1107
+
1108
+ // @public (undocumented)
1109
+ export function objExtend<T1, T2, T3, T4, T5, T6>(obj1?: T1, obj2?: T2, obj3?: T3, obj4?: T4, obj5?: T5, obj6?: T6): T1 & T2 & T3 & T4 & T5 & T6;
1073
1110
 
1074
1111
  // @public
1075
1112
  export function objForEachKey<T = any>(target: T, callbackfn: (name: string, value: T[keyof T]) => void): void;
@@ -1163,6 +1200,9 @@ export function removeEventListeners(events: string[], listener: any, evtNamespa
1163
1200
  // @public
1164
1201
  export function removePageHideEventListener(listener: any, evtNamespace?: string | string[]): void;
1165
1202
 
1203
+ // @public
1204
+ export function removePageShowEventListener(listener: any, evtNamespace?: string | string[]): void;
1205
+
1166
1206
  // @public
1167
1207
  export function removePageUnloadEventListener(listener: any, evtNamespace?: string | string[]): void;
1168
1208
 
@@ -1236,9 +1276,27 @@ export interface Tags {
1236
1276
  // @public (undocumented)
1237
1277
  export type TelemetryInitializerFunction = <T extends ITelemetryItem>(item: T) => boolean | void;
1238
1278
 
1279
+ // @public
1280
+ export const enum TelemetryUnloadReason {
1281
+ ManualTeardown = 0,
1282
+ PluginReplace = 2,
1283
+ PluginUnload = 1,
1284
+ SdkUnload = 50
1285
+ }
1286
+
1287
+ // @public
1288
+ export const enum TelemetryUpdateReason {
1289
+ PluginAdded = 16,
1290
+ PluginRemoved = 32,
1291
+ Unknown = 0
1292
+ }
1293
+
1239
1294
  // @public (undocumented)
1240
1295
  export function throwError(message: string): never;
1241
1296
 
1297
+ // @public
1298
+ export function _throwInternal(logger: IDiagnosticLogger, severity: LoggingSeverity, msgId: _InternalMessageId, msg: string, properties?: Object, isUserAct?: boolean): void;
1299
+
1242
1300
  // @public
1243
1301
  export function toISOString(date: Date): string;
1244
1302
 
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Microsoft Application Insights Core Javascript SDK, 2.8.0-beta.2203-04
2
+ * Microsoft Application Insights Core Javascript SDK, 2.8.0-beta.2203-07
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  *
5
5
  * Microsoft Application Insights Team
@@ -18,9 +18,11 @@ declare namespace ApplicationInsights {
18
18
  * Get all of the registered events on the target object, this is primarily used for testing cleanup but may also be used by
19
19
  * applications to remove their own events
20
20
  * @param target - The EventTarget that has registered events
21
- * @param evtName - [Optional] The name of the event to return the registered handlers and full name (with namespaces)
21
+ * @param eventName - [Optional] The name of the event to return the registered handlers and full name (with namespaces)
22
+ * @param evtNamespace - [Optional] Additional namespace(s) to append to the event listeners so they can be uniquely identified and removed based on this namespace,
23
+ * if the eventName also includes a namespace the namespace(s) are merged into a single namespace
22
24
  */
23
- function __getRegisteredEvents(target: any, evtName?: string): _IRegisteredEvents[];
25
+ function __getRegisteredEvents(target: any, eventName?: string, evtNamespace?: string | string[]): _IRegisteredEvents[];
24
26
 
25
27
  /**
26
28
  * Trys to add an event handler for the specified event to the window, body and document
@@ -196,10 +198,20 @@ declare namespace ApplicationInsights {
196
198
  * approach is to create a new instance and initialize that instance.
197
199
  * This is due to possible unexpected side effects caused by plugins not supporting unload / teardown, unable
198
200
  * to successfully remove any global references or they may just be completing the unload process asynchronously.
201
+ * @param isAsync - Can the unload be performed asynchronously (default)
202
+ * @param unloadComplete - An optional callback that will be called once the unload has completed
203
+ * @param cbTimeout - An optional timeout to wait for any flush operations to complete before proceeding with the unload. Defaults to 5 seconds.
199
204
  */
200
- unload(isAsync?: boolean, unloadComplete?: () => void): void;
205
+ unload(isAsync?: boolean, unloadComplete?: (unloadState: ITelemetryUnloadState) => void, cbTimeout?: number): void;
201
206
  getPlugin<T extends IPlugin = IPlugin>(pluginIdentifier: string): ILoadedPlugin<T>;
202
- addPlugin<T extends IPlugin = ITelemetryPlugin>(plugin: T, replaceExisting: boolean, doAsync: boolean, addCb?: (added?: boolean) => void): void;
207
+ /**
208
+ * Add a new plugin to the installation
209
+ * @param plugin - The new plugin to add
210
+ * @param replaceExisting - should any existing plugin be replaced, default is false
211
+ * @param doAsync - Should the add be performed asynchronously
212
+ * @param addCb - [Optional] callback to call after the plugin has been added
213
+ */
214
+ addPlugin<T extends IPlugin = ITelemetryPlugin>(plugin: T, replaceExisting?: boolean, doAsync?: boolean, addCb?: (added?: boolean) => void): void;
203
215
  /**
204
216
  * Returns the unique event namespace that should be used
205
217
  */
@@ -209,7 +221,23 @@ declare namespace ApplicationInsights {
209
221
  * @param handler - the handler
210
222
  */
211
223
  addUnloadCb(handler: UnloadHandler): void;
224
+ /**
225
+ * Flush and send any batched / cached data immediately
226
+ * @param async - send data asynchronously when true (defaults to true)
227
+ * @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.
228
+ * If the caller doesn't return true the caller should assume that it may never be called.
229
+ * @param sendReason - specify the reason that you are calling "flush" defaults to ManualFlush (1) if not specified
230
+ * @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
231
+ */
232
+ flush(isAsync?: boolean, callBack?: (flushComplete?: boolean) => void, sendReason?: SendRequestReason): void;
212
233
  protected releaseQueue(): void;
234
+ /**
235
+ * Hook for Core extensions to allow them to update their own configuration before updating all of the plugins.
236
+ * @param updateCtx - The plugin update context
237
+ * @param updateState - The Update State
238
+ * @returns boolean - True means the extension class will call updateState otherwise the Core will
239
+ */
240
+ protected _updateHook?(updateCtx: IProcessTelemetryUpdateContext, updateState: ITelemetryUpdateState): void | boolean;
213
241
  }
214
242
 
215
243
  /**
@@ -266,6 +294,14 @@ declare namespace ApplicationInsights {
266
294
  * @returns boolean - true if the plugin has or will call asyncCallback, this allows the plugin to perform any asynchronous operations.
267
295
  */
268
296
  protected _doTeardown?: (unloadCtx?: IProcessTelemetryUnloadContext, unloadState?: ITelemetryUnloadState, asyncCallback?: () => void) => void | boolean;
297
+ /**
298
+ * Extension hook to allow implementations to perform some additional update operations before the BaseTelemetryPlugin finishes it's removal
299
+ * @param updateCtx - This is the context that should be used during updating.
300
+ * @param updateState - The details / state of the update process, it holds details like the current and previous configuration.
301
+ * @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.
302
+ * @returns boolean - true if the plugin has or will call asyncCallback, this allows the plugin to perform any asynchronous operations.
303
+ */
304
+ protected _doUpdate?: (updateCtx?: IProcessTelemetryUpdateContext, updateState?: ITelemetryUpdateState, asyncCallback?: () => void) => void | boolean;
269
305
  constructor();
270
306
  initialize(config: IConfiguration, core: IAppInsightsCore, extensions: IPlugin[], pluginChain?: ITelemetryPluginChain): void;
271
307
  /**
@@ -278,6 +314,13 @@ declare namespace ApplicationInsights {
278
314
  */
279
315
  teardown(unloadCtx?: IProcessTelemetryUnloadContext, unloadState?: ITelemetryUnloadState): void | boolean;
280
316
  abstract processTelemetry(env: ITelemetryItem, itemCtx?: IProcessTelemetryContext): void;
317
+ /**
318
+ * The the plugin should re-evaluate configuration and update any cached configuration settings.
319
+ * @param updateCtx - This is the context that should be used during updating.
320
+ * @param updateState - The details / state of the update process, it holds details like the current and previous configuration.
321
+ * @returns boolean - true if the plugin has or will call updateCtx.processNext(), this allows the plugin to perform any asynchronous operations.
322
+ */
323
+ update(updateCtx: IProcessTelemetryUpdateContext, updateState: ITelemetryUpdateState): void | boolean;
281
324
  /**
282
325
  * Add an unload handler that will be called when the SDK is being unloaded
283
326
  * @param handler - the handler
@@ -814,8 +857,11 @@ declare namespace ApplicationInsights {
814
857
  * approach is to create a new instance and initialize that instance.
815
858
  * This is due to possible unexpected side effects caused by plugins not supporting unload / teardown, unable
816
859
  * to successfully remove any global references or they may just be completing the unload process asynchronously.
860
+ * @param isAsync - Can the unload be performed asynchronously (default)
861
+ * @param unloadComplete - An optional callback that will be called once the unload has completed
862
+ * @param cbTimeout - An optional timeout to wait for any flush operations to complete before proceeding with the unload. Defaults to 5 seconds.
817
863
  */
818
- unload(isAsync?: boolean, unloadComplete?: () => void): void;
864
+ unload(isAsync?: boolean, unloadComplete?: (unloadState: ITelemetryUnloadState) => void, cbTimeout?: number): void;
819
865
  /**
820
866
  * Find and return the (first) plugin with the specified identifier if present
821
867
  * @param pluginIdentifier
@@ -824,10 +870,11 @@ declare namespace ApplicationInsights {
824
870
  /**
825
871
  * Add a new plugin to the installation
826
872
  * @param plugin - The new plugin to add
827
- * @param replaceExisting - should any existing plugin be replaced
873
+ * @param replaceExisting - should any existing plugin be replaced, default is false
828
874
  * @param doAsync - Should the add be performed asynchronously
875
+ * @param addCb - [Optional] callback to call after the plugin has been added
829
876
  */
830
- addPlugin<T extends IPlugin = ITelemetryPlugin>(plugin: T, replaceExisting: boolean, doAsync: boolean, addCb?: (added?: boolean) => void): void;
877
+ addPlugin<T extends IPlugin = ITelemetryPlugin>(plugin: T, replaceExisting?: boolean, doAsync?: boolean, addCb?: (added?: boolean) => void): void;
831
878
  /**
832
879
  * Returns the unique event namespace that should be used when registering events
833
880
  */
@@ -837,6 +884,16 @@ declare namespace ApplicationInsights {
837
884
  * @param handler - the handler
838
885
  */
839
886
  addUnloadCb(handler: UnloadHandler): void;
887
+ /**
888
+ * Flush and send any batched / cached data immediately
889
+ * @param async - send data asynchronously when true (defaults to true)
890
+ * @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.
891
+ * If the caller doesn't return true the caller should assume that it may never be called.
892
+ * @param sendReason - specify the reason that you are calling "flush" defaults to ManualFlush (1) if not specified
893
+ * @param cbTimeout - An optional timeout to wait for any flush operations to complete before proceeding with the unload. Defaults to 5 seconds.
894
+ * @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
895
+ */
896
+ flush(isAsync?: boolean, callBack?: (flushComplete?: boolean) => void, sendReason?: SendRequestReason, cbTimeout?: number): boolean | void;
840
897
  }
841
898
 
842
899
  interface IBaseProcessingContext {
@@ -1504,6 +1561,11 @@ declare namespace ApplicationInsights {
1504
1561
  * You must always supply the error callback
1505
1562
  */
1506
1563
  interface IInstrumentHooksCallbacks {
1564
+ /**
1565
+ * [Optional] Namespace details (same as the namespace used for events), useful for debugging and testing to
1566
+ * identify the source of the instrumented hooks
1567
+ */
1568
+ ns?: string | string[];
1507
1569
  /**
1508
1570
  * The hook callback to call before the original function is called
1509
1571
  */
@@ -1918,8 +1980,8 @@ declare namespace ApplicationInsights {
1918
1980
  }
1919
1981
 
1920
1982
  /**
1921
- * The current context for the current call to processTelemetry(), used to support sharing the same plugin instance
1922
- * between multiple AppInsights instances
1983
+ * The current context for the current call to teardown() implementations, used to support when plugins are being removed
1984
+ * or the SDK is being unloaded.
1923
1985
  */
1924
1986
  interface IProcessTelemetryUnloadContext extends IBaseProcessingContext {
1925
1987
  /**
@@ -1938,6 +2000,27 @@ declare namespace ApplicationInsights {
1938
2000
  createNew: (plugins?: IPlugin[] | ITelemetryPluginChain, startAt?: IPlugin) => IProcessTelemetryUnloadContext;
1939
2001
  }
1940
2002
 
2003
+ /**
2004
+ * The current context for the current call to the plugin update() implementations, used to support the notifications
2005
+ * for when plugins are added, removed or the configuration was changed.
2006
+ */
2007
+ interface IProcessTelemetryUpdateContext extends IBaseProcessingContext {
2008
+ /**
2009
+ * This Plugin has finished unloading, so unload the next one
2010
+ * @param updateState - The update State
2011
+ * @returns boolean (true) if there is no more plugins to process otherwise false or undefined (void)
2012
+ */
2013
+ processNext: (updateState: ITelemetryUpdateState) => boolean | void;
2014
+ /**
2015
+ * Create a new context using the core and config from the current instance, returns a new instance of the same type
2016
+ * @param plugins - The execution order to process the plugins, if null or not supplied
2017
+ * then the current execution order will be copied.
2018
+ * @param startAt - The plugin to start processing from, if missing from the execution
2019
+ * order then the next plugin will be NOT set.
2020
+ */
2021
+ createNew: (plugins?: IPlugin[] | ITelemetryPluginChain, startAt?: IPlugin) => IProcessTelemetryUpdateContext;
2022
+ }
2023
+
1941
2024
  interface _IRegisteredEvents {
1942
2025
  name: string;
1943
2026
  handler: any;
@@ -2142,6 +2225,15 @@ declare namespace ApplicationInsights {
2142
2225
  * to later plugins (vs appending items to the telemetry item)
2143
2226
  */
2144
2227
  processTelemetry: (env: ITelemetryItem, itemCtx?: IProcessTelemetryContext) => void;
2228
+ /**
2229
+ * The the plugin should re-evaluate configuration and update any cached configuration settings or
2230
+ * plugins. If implemented this method will be called whenever a plugin is added or removed and if
2231
+ * the configuration has bee updated.
2232
+ * @param updateCtx - This is the context that should be used during updating.
2233
+ * @param updateState - The details / state of the update process, it holds details like the current and previous configuration.
2234
+ * @returns boolean - true if the plugin has or will call updateCtx.processNext(), this allows the plugin to perform any asynchronous operations.
2235
+ */
2236
+ update?: (updateCtx: IProcessTelemetryUpdateContext, updateState: ITelemetryUpdateState) => void | boolean;
2145
2237
  }
2146
2238
 
2147
2239
  interface ITelemetryUnloadState {
@@ -2150,6 +2242,27 @@ declare namespace ApplicationInsights {
2150
2242
  flushComplete?: boolean;
2151
2243
  }
2152
2244
 
2245
+ interface ITelemetryUpdateState {
2246
+ /**
2247
+ * Identifies the reason for the update notification, this is a bitwise numeric value
2248
+ */
2249
+ reason: TelemetryUpdateReason;
2250
+ /**
2251
+ * If this is a configuration update this was the previous configuration that was used
2252
+ */
2253
+ /**
2254
+ * If this is a configuration update is the new configuration that is being used
2255
+ */
2256
+ /**
2257
+ * This holds a collection of plugins that have been added (if the reason identifies that one or more plugins have been added)
2258
+ */
2259
+ added?: IPlugin[];
2260
+ /**
2261
+ * This holds a collection of plugins that have been removed (if the reason identifies that one or more plugins have been removed)
2262
+ */
2263
+ removed?: IPlugin[];
2264
+ }
2265
+
2153
2266
  interface IUnloadHandlerContainer {
2154
2267
  add: (handler: UnloadHandler) => void;
2155
2268
  run: (itemCtx: IProcessTelemetryUnloadContext, unloadState: ITelemetryUnloadState) => void;
@@ -2276,7 +2389,9 @@ declare namespace ApplicationInsights {
2276
2389
  * @param obj5 - object to merge.
2277
2390
  * @returns The extended first object.
2278
2391
  */
2279
- function objExtend<T1, T2, T3, T4, T5, T6>(obj?: boolean | T1, obj2?: T2, obj3?: T3, obj4?: T4, obj5?: T5, obj6?: T6): T1 & T2 & T3 & T4 & T5 & T6;
2392
+ function objExtend<T2, T3, T4, T5, T6>(deepExtend?: boolean, obj2?: T2, obj3?: T3, obj4?: T4, obj5?: T5, obj6?: T6): T2 & T3 & T4 & T5 & T6;
2393
+
2394
+ function objExtend<T1, T2, T3, T4, T5, T6>(obj1?: T1, obj2?: T2, obj3?: T3, obj4?: T4, obj5?: T5, obj6?: T6): T1 & T2 & T3 & T4 & T5 & T6;
2280
2395
 
2281
2396
  /**
2282
2397
  * This is a helper function for the equivalent of arForEach(objKeys(target), callbackFn), this is a
@@ -2523,6 +2638,15 @@ declare namespace ApplicationInsights {
2523
2638
  */
2524
2639
  function removePageHideEventListener(listener: any, evtNamespace?: string | string[]): void;
2525
2640
 
2641
+ /**
2642
+ * Removes the pageShow event listeners added by addPageShowEventListener, because the 'visibilitychange' uses
2643
+ * an internal proxy to detect the visibility state you SHOULD use a unique namespace when calling addPageShowEventListener
2644
+ * as the remove ignores the listener argument for the 'visibilitychange' event.
2645
+ * @param listener - The specific listener to remove for the 'pageshow' event only (ignored for 'visibilitychange')
2646
+ * @param evtNamespace - The unique namespace used when calling addPageShowEventListener
2647
+ */
2648
+ function removePageShowEventListener(listener: any, evtNamespace?: string | string[]): void;
2649
+
2526
2650
  /**
2527
2651
  * Remove any matching 'beforeunload', 'unload' and 'pagehide' events that may have been added via addEventListener,
2528
2652
  * addEventListeners, addPageUnloadEventListener or addPageHideEventListener.
@@ -2689,8 +2813,40 @@ declare namespace ApplicationInsights {
2689
2813
  SdkUnload = 50
2690
2814
  }
2691
2815
 
2816
+ /**
2817
+ * The TelemetryUpdateReason enumeration contains a set of bit-wise values that specify the reason for update request.
2818
+ */
2819
+ const enum TelemetryUpdateReason {
2820
+ /**
2821
+ * Unknown.
2822
+ */
2823
+ Unknown = 0,
2824
+ /**
2825
+ * The configuration has ben updated or changed
2826
+ */
2827
+ /**
2828
+ * One or more plugins have been added
2829
+ */
2830
+ PluginAdded = 16,
2831
+ /**
2832
+ * One or more plugins have been removed
2833
+ */
2834
+ PluginRemoved = 32
2835
+ }
2836
+
2692
2837
  function throwError(message: string): never;
2693
2838
 
2839
+ /**
2840
+ * This is a helper method which will call throwInternal on the passed logger, will throw exceptions in
2841
+ * debug mode or attempt to log the error as a console warning. This helper is provided mostly to better
2842
+ * support minification as logger.throwInternal() will not compress the publish "throwInternal" used throughout
2843
+ * the code.
2844
+ * @param logger - The Diagnostic Logger instance to use.
2845
+ * @param severity {LoggingSeverity} - The severity of the log message
2846
+ * @param message {_InternalLogMessage} - The log message.
2847
+ */
2848
+ function _throwInternal(logger: IDiagnosticLogger, severity: LoggingSeverity, msgId: _InternalMessageId, msg: string, properties?: Object, isUserAct?: boolean): void;
2849
+
2694
2850
  /**
2695
2851
  * Convert a date to I.S.O. format in IE8
2696
2852
  */