@microsoft/applicationinsights-web-basic 2.8.0-beta.2203-02 → 2.8.0-beta.2203-05

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.
@@ -705,6 +705,130 @@
705
705
  ],
706
706
  "name": "addNotificationListener"
707
707
  },
708
+ {
709
+ "kind": "MethodSignature",
710
+ "canonicalReference": "@microsoft/applicationinsights-web-basic!IAppInsightsCore#addPlugin:member(1)",
711
+ "docComment": "/**\n * Add a new plugin to the installation\n *\n * @param plugin - The new plugin to add\n *\n * @param replaceExisting - should any existing plugin be replaced\n *\n * @param doAsync - Should the add be performed asynchronously\n */\n",
712
+ "excerptTokens": [
713
+ {
714
+ "kind": "Content",
715
+ "text": "addPlugin<T extends "
716
+ },
717
+ {
718
+ "kind": "Reference",
719
+ "text": "IPlugin",
720
+ "canonicalReference": "@microsoft/applicationinsights-web-basic!IPlugin:interface"
721
+ },
722
+ {
723
+ "kind": "Content",
724
+ "text": " "
725
+ },
726
+ {
727
+ "kind": "Content",
728
+ "text": "= "
729
+ },
730
+ {
731
+ "kind": "Reference",
732
+ "text": "ITelemetryPlugin",
733
+ "canonicalReference": "@microsoft/applicationinsights-web-basic!ITelemetryPlugin:interface"
734
+ },
735
+ {
736
+ "kind": "Content",
737
+ "text": ">(plugin: "
738
+ },
739
+ {
740
+ "kind": "Content",
741
+ "text": "T"
742
+ },
743
+ {
744
+ "kind": "Content",
745
+ "text": ", replaceExisting: "
746
+ },
747
+ {
748
+ "kind": "Content",
749
+ "text": "boolean"
750
+ },
751
+ {
752
+ "kind": "Content",
753
+ "text": ", doAsync: "
754
+ },
755
+ {
756
+ "kind": "Content",
757
+ "text": "boolean"
758
+ },
759
+ {
760
+ "kind": "Content",
761
+ "text": ", addCb?: "
762
+ },
763
+ {
764
+ "kind": "Content",
765
+ "text": "(added?: boolean) => void"
766
+ },
767
+ {
768
+ "kind": "Content",
769
+ "text": "): "
770
+ },
771
+ {
772
+ "kind": "Content",
773
+ "text": "void"
774
+ },
775
+ {
776
+ "kind": "Content",
777
+ "text": ";"
778
+ }
779
+ ],
780
+ "isOptional": false,
781
+ "returnTypeTokenRange": {
782
+ "startIndex": 14,
783
+ "endIndex": 15
784
+ },
785
+ "releaseTag": "Public",
786
+ "overloadIndex": 1,
787
+ "parameters": [
788
+ {
789
+ "parameterName": "plugin",
790
+ "parameterTypeTokenRange": {
791
+ "startIndex": 6,
792
+ "endIndex": 7
793
+ }
794
+ },
795
+ {
796
+ "parameterName": "replaceExisting",
797
+ "parameterTypeTokenRange": {
798
+ "startIndex": 8,
799
+ "endIndex": 9
800
+ }
801
+ },
802
+ {
803
+ "parameterName": "doAsync",
804
+ "parameterTypeTokenRange": {
805
+ "startIndex": 10,
806
+ "endIndex": 11
807
+ }
808
+ },
809
+ {
810
+ "parameterName": "addCb",
811
+ "parameterTypeTokenRange": {
812
+ "startIndex": 12,
813
+ "endIndex": 13
814
+ }
815
+ }
816
+ ],
817
+ "typeParameters": [
818
+ {
819
+ "typeParameterName": "T",
820
+ "constraintTokenRange": {
821
+ "startIndex": 1,
822
+ "endIndex": 3
823
+ },
824
+ "defaultTypeTokenRange": {
825
+ "startIndex": 4,
826
+ "endIndex": 5
827
+ }
828
+ }
829
+ ],
830
+ "name": "addPlugin"
831
+ },
708
832
  {
709
833
  "kind": "MethodSignature",
710
834
  "canonicalReference": "@microsoft/applicationinsights-web-basic!IAppInsightsCore#addTelemetryInitializer:member(1)",
@@ -755,6 +879,51 @@
755
879
  ],
756
880
  "name": "addTelemetryInitializer"
757
881
  },
882
+ {
883
+ "kind": "MethodSignature",
884
+ "canonicalReference": "@microsoft/applicationinsights-web-basic!IAppInsightsCore#addUnloadCb:member(1)",
885
+ "docComment": "/**\n * Add a handler that will be called when the SDK is being unloaded\n *\n * @param handler - the handler\n */\n",
886
+ "excerptTokens": [
887
+ {
888
+ "kind": "Content",
889
+ "text": "addUnloadCb(handler: "
890
+ },
891
+ {
892
+ "kind": "Reference",
893
+ "text": "UnloadHandler",
894
+ "canonicalReference": "@microsoft/applicationinsights-web-basic!UnloadHandler:type"
895
+ },
896
+ {
897
+ "kind": "Content",
898
+ "text": "): "
899
+ },
900
+ {
901
+ "kind": "Content",
902
+ "text": "void"
903
+ },
904
+ {
905
+ "kind": "Content",
906
+ "text": ";"
907
+ }
908
+ ],
909
+ "isOptional": false,
910
+ "returnTypeTokenRange": {
911
+ "startIndex": 3,
912
+ "endIndex": 4
913
+ },
914
+ "releaseTag": "Public",
915
+ "overloadIndex": 1,
916
+ "parameters": [
917
+ {
918
+ "parameterName": "handler",
919
+ "parameterTypeTokenRange": {
920
+ "startIndex": 1,
921
+ "endIndex": 2
922
+ }
923
+ }
924
+ ],
925
+ "name": "addUnloadCb"
926
+ },
758
927
  {
759
928
  "kind": "PropertySignature",
760
929
  "canonicalReference": "@microsoft/applicationinsights-web-basic!IAppInsightsCore#config:member",
@@ -1370,6 +1539,65 @@
1370
1539
  }
1371
1540
  ],
1372
1541
  "name": "track"
1542
+ },
1543
+ {
1544
+ "kind": "MethodSignature",
1545
+ "canonicalReference": "@microsoft/applicationinsights-web-basic!IAppInsightsCore#unload:member(1)",
1546
+ "docComment": "/**\n * Unload and Tear down the SDK and any initialized plugins, after calling this the SDK will be considered to be un-initialized and non-operational, re-initializing the SDK should only be attempted if the previous unload call return `true` stating that all plugins reported that they also unloaded, the recommended approach is to create a new instance and initialize that instance. This is due to possible unexpected side effects caused by plugins not supporting unload / teardown, unable to successfully remove any global references or they may just be completing the unload process asynchronously.\n */\n",
1547
+ "excerptTokens": [
1548
+ {
1549
+ "kind": "Content",
1550
+ "text": "unload(isAsync?: "
1551
+ },
1552
+ {
1553
+ "kind": "Content",
1554
+ "text": "boolean"
1555
+ },
1556
+ {
1557
+ "kind": "Content",
1558
+ "text": ", unloadComplete?: "
1559
+ },
1560
+ {
1561
+ "kind": "Content",
1562
+ "text": "() => void"
1563
+ },
1564
+ {
1565
+ "kind": "Content",
1566
+ "text": "): "
1567
+ },
1568
+ {
1569
+ "kind": "Content",
1570
+ "text": "void"
1571
+ },
1572
+ {
1573
+ "kind": "Content",
1574
+ "text": ";"
1575
+ }
1576
+ ],
1577
+ "isOptional": false,
1578
+ "returnTypeTokenRange": {
1579
+ "startIndex": 5,
1580
+ "endIndex": 6
1581
+ },
1582
+ "releaseTag": "Public",
1583
+ "overloadIndex": 1,
1584
+ "parameters": [
1585
+ {
1586
+ "parameterName": "isAsync",
1587
+ "parameterTypeTokenRange": {
1588
+ "startIndex": 1,
1589
+ "endIndex": 2
1590
+ }
1591
+ },
1592
+ {
1593
+ "parameterName": "unloadComplete",
1594
+ "parameterTypeTokenRange": {
1595
+ "startIndex": 3,
1596
+ "endIndex": 4
1597
+ }
1598
+ }
1599
+ ],
1600
+ "name": "unload"
1373
1601
  }
1374
1602
  ],
1375
1603
  "extendsTokenRanges": [
@@ -44,9 +44,13 @@ export const CoreUtils: ICoreUtils;
44
44
  export interface IAppInsightsCore extends IPerfManagerProvider {
45
45
  // Warning: (ae-forgotten-export) The symbol "INotificationListener" needs to be exported by the entry point index.d.ts
46
46
  addNotificationListener?(listener: INotificationListener): void;
47
+ // Warning: (ae-forgotten-export) The symbol "ITelemetryPlugin" needs to be exported by the entry point index.d.ts
48
+ addPlugin<T extends IPlugin = ITelemetryPlugin>(plugin: T, replaceExisting: boolean, doAsync: boolean, addCb?: (added?: boolean) => void): void;
47
49
  // Warning: (ae-forgotten-export) The symbol "TelemetryInitializerFunction" needs to be exported by the entry point index.d.ts
48
50
  // Warning: (ae-forgotten-export) The symbol "ITelemetryInitializerHandler" needs to be exported by the entry point index.d.ts
49
51
  addTelemetryInitializer(telemetryInitializer: TelemetryInitializerFunction): ITelemetryInitializerHandler | void;
52
+ // Warning: (ae-forgotten-export) The symbol "UnloadHandler" needs to be exported by the entry point index.d.ts
53
+ addUnloadCb(handler: UnloadHandler): void;
50
54
  // (undocumented)
51
55
  config: IConfiguration;
52
56
  evtNamespace(): string;
@@ -74,6 +78,7 @@ export interface IAppInsightsCore extends IPerfManagerProvider {
74
78
  stopPollingInternalLogs?(): void;
75
79
  // (undocumented)
76
80
  track(telemetryItem: ITelemetryItem): void;
81
+ unload(isAsync?: boolean, unloadComplete?: () => void): void;
77
82
  }
78
83
 
79
84
  // @public
@@ -112,7 +117,6 @@ export interface IConfiguration {
112
117
  extensionConfig?: {
113
118
  [key: string]: any;
114
119
  };
115
- // Warning: (ae-forgotten-export) The symbol "ITelemetryPlugin" needs to be exported by the entry point index.d.ts
116
120
  extensions?: ITelemetryPlugin[];
117
121
  idLength?: number;
118
122
  instrumentationKey?: string;
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Microsoft.ApplicationInsights, 2.8.0-beta.2203-02
2
+ * Microsoft.ApplicationInsights, 2.8.0-beta.2203-05
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  *
5
5
  * Microsoft Application Insights Team
@@ -100,12 +100,34 @@ declare namespace ApplicationInsights {
100
100
  * @returns - A ITelemetryInitializerHandler to enable the initializer to be removed
101
101
  */
102
102
  addTelemetryInitializer(telemetryInitializer: TelemetryInitializerFunction): ITelemetryInitializerHandler | void;
103
+ /**
104
+ * Unload and Tear down the SDK and any initialized plugins, after calling this the SDK will be considered
105
+ * to be un-initialized and non-operational, re-initializing the SDK should only be attempted if the previous
106
+ * unload call return `true` stating that all plugins reported that they also unloaded, the recommended
107
+ * approach is to create a new instance and initialize that instance.
108
+ * This is due to possible unexpected side effects caused by plugins not supporting unload / teardown, unable
109
+ * to successfully remove any global references or they may just be completing the unload process asynchronously.
110
+ */
111
+ unload(isAsync?: boolean, unloadComplete?: (unloadState: ITelemetryUnloadState) => void, cbTimeout?: number): void;
103
112
  getPlugin<T extends IPlugin = IPlugin>(pluginIdentifier: string): ILoadedPlugin<T>;
113
+ addPlugin<T extends IPlugin = ITelemetryPlugin>(plugin: T, replaceExisting: boolean, doAsync: boolean, addCb?: (added?: boolean) => void): void;
104
114
  /**
105
115
  * Returns the unique event namespace that should be used
106
116
  */
107
117
  evtNamespace(): string;
118
+ /**
119
+ * Add an unload handler that will be called when the SDK is being unloaded
120
+ * @param handler - the handler
121
+ */
122
+ addUnloadCb(handler: UnloadHandler): void;
108
123
  protected releaseQueue(): void;
124
+ /**
125
+ * Hook for Core extensions to allow them to update their own configuration before updating all of the plugins.
126
+ * @param updateCtx - The plugin update context
127
+ * @param updateState - The Update State
128
+ * @returns boolean - True means the extension class will call updateState otherwise the Core will
129
+ */
130
+ protected _updateHook?(updateCtx: IProcessTelemetryUpdateContext, updateState: ITelemetryUpdateState): void | boolean;
109
131
  }
110
132
 
111
133
  /**
@@ -162,6 +184,14 @@ declare namespace ApplicationInsights {
162
184
  * @returns boolean - true if the plugin has or will call asyncCallback, this allows the plugin to perform any asynchronous operations.
163
185
  */
164
186
  protected _doTeardown?: (unloadCtx?: IProcessTelemetryUnloadContext, unloadState?: ITelemetryUnloadState, asyncCallback?: () => void) => void | boolean;
187
+ /**
188
+ * Extension hook to allow implementations to perform some additional update operations before the BaseTelemetryPlugin finishes it's removal
189
+ * @param updateCtx - This is the context that should be used during updating.
190
+ * @param updateState - The details / state of the update process, it holds details like the current and previous configuration.
191
+ * @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.
192
+ * @returns boolean - true if the plugin has or will call asyncCallback, this allows the plugin to perform any asynchronous operations.
193
+ */
194
+ protected _doUpdate?: (updateCtx?: IProcessTelemetryUpdateContext, updateState?: ITelemetryUpdateState, asyncCallback?: () => void) => void | boolean;
165
195
  constructor();
166
196
  initialize(config: IConfiguration, core: IAppInsightsCore, extensions: IPlugin[], pluginChain?: ITelemetryPluginChain): void;
167
197
  /**
@@ -174,6 +204,18 @@ declare namespace ApplicationInsights {
174
204
  */
175
205
  teardown(unloadCtx?: IProcessTelemetryUnloadContext, unloadState?: ITelemetryUnloadState): void | boolean;
176
206
  abstract processTelemetry(env: ITelemetryItem, itemCtx?: IProcessTelemetryContext): void;
207
+ /**
208
+ * The the plugin should re-evaluate configuration and update any cached configuration settings.
209
+ * @param updateCtx - This is the context that should be used during updating.
210
+ * @param updateState - The details / state of the update process, it holds details like the current and previous configuration.
211
+ * @returns boolean - true if the plugin has or will call updateCtx.processNext(), this allows the plugin to perform any asynchronous operations.
212
+ */
213
+ update(updateCtx: IProcessTelemetryUpdateContext, updateState: ITelemetryUpdateState): void | boolean;
214
+ /**
215
+ * Add an unload handler that will be called when the SDK is being unloaded
216
+ * @param handler - the handler
217
+ */
218
+ protected _addUnloadCb(handler: UnloadHandler): void;
177
219
  /**
178
220
  * Add this hook so that it is automatically removed during unloading
179
221
  * @param hooks - The single hook or an array of IInstrumentHook objects
@@ -361,15 +403,36 @@ declare namespace ApplicationInsights {
361
403
  * Return a new instance of the IProcessTelemetryContext for processing events
362
404
  */
363
405
  getProcessTelContext(): IProcessTelemetryContext;
406
+ /**
407
+ * Unload and Tear down the SDK and any initialized plugins, after calling this the SDK will be considered
408
+ * to be un-initialized and non-operational, re-initializing the SDK should only be attempted if the previous
409
+ * unload call return `true` stating that all plugins reported that they also unloaded, the recommended
410
+ * approach is to create a new instance and initialize that instance.
411
+ * This is due to possible unexpected side effects caused by plugins not supporting unload / teardown, unable
412
+ * to successfully remove any global references or they may just be completing the unload process asynchronously.
413
+ */
414
+ unload(isAsync?: boolean, unloadComplete?: () => void): void;
364
415
  /**
365
416
  * Find and return the (first) plugin with the specified identifier if present
366
417
  * @param pluginIdentifier
367
418
  */
368
419
  getPlugin<T extends IPlugin = IPlugin>(pluginIdentifier: string): ILoadedPlugin<T>;
420
+ /**
421
+ * Add a new plugin to the installation
422
+ * @param plugin - The new plugin to add
423
+ * @param replaceExisting - should any existing plugin be replaced
424
+ * @param doAsync - Should the add be performed asynchronously
425
+ */
426
+ addPlugin<T extends IPlugin = ITelemetryPlugin>(plugin: T, replaceExisting: boolean, doAsync: boolean, addCb?: (added?: boolean) => void): void;
369
427
  /**
370
428
  * Returns the unique event namespace that should be used when registering events
371
429
  */
372
430
  evtNamespace(): string;
431
+ /**
432
+ * Add a handler that will be called when the SDK is being unloaded
433
+ * @param handler - the handler
434
+ */
435
+ addUnloadCb(handler: UnloadHandler): void;
373
436
  }
374
437
 
375
438
  /**
@@ -1426,6 +1489,11 @@ declare namespace ApplicationInsights {
1426
1489
  * You must always supply the error callback
1427
1490
  */
1428
1491
  interface IInstrumentHooksCallbacks {
1492
+ /**
1493
+ * [Optional] Namespace details (same as the namespace used for events), useful for debugging and testing to
1494
+ * identify the source of the instrumented hooks
1495
+ */
1496
+ ns?: string | string[];
1429
1497
  /**
1430
1498
  * The hook callback to call before the original function is called
1431
1499
  */
@@ -1460,6 +1528,7 @@ declare namespace ApplicationInsights {
1460
1528
  * (unless it's also been re-initialized)
1461
1529
  */
1462
1530
  setEnabled: (isEnabled: boolean) => void;
1531
+ remove: (isAsync?: boolean, removeCb?: (removed?: boolean) => void) => void;
1463
1532
  }
1464
1533
 
1465
1534
  interface IMetricTelemetry extends IPartC {
@@ -1936,8 +2005,8 @@ declare namespace ApplicationInsights {
1936
2005
  }
1937
2006
 
1938
2007
  /**
1939
- * The current context for the current call to processTelemetry(), used to support sharing the same plugin instance
1940
- * between multiple AppInsights instances
2008
+ * The current context for the current call to teardown() implementations, used to support when plugins are being removed
2009
+ * or the SDK is being unloaded.
1941
2010
  */
1942
2011
  interface IProcessTelemetryUnloadContext extends IBaseProcessingContext {
1943
2012
  /**
@@ -1956,6 +2025,27 @@ declare namespace ApplicationInsights {
1956
2025
  createNew: (plugins?: IPlugin[] | ITelemetryPluginChain, startAt?: IPlugin) => IProcessTelemetryUnloadContext;
1957
2026
  }
1958
2027
 
2028
+ /**
2029
+ * The current context for the current call to the plugin update() implementations, used to support the notifications
2030
+ * for when plugins are added, removed or the configuration was changed.
2031
+ */
2032
+ interface IProcessTelemetryUpdateContext extends IBaseProcessingContext {
2033
+ /**
2034
+ * This Plugin has finished unloading, so unload the next one
2035
+ * @param updateState - The update State
2036
+ * @returns boolean (true) if there is no more plugins to process otherwise false or undefined (void)
2037
+ */
2038
+ processNext: (updateState: ITelemetryUpdateState) => boolean | void;
2039
+ /**
2040
+ * Create a new context using the core and config from the current instance, returns a new instance of the same type
2041
+ * @param plugins - The execution order to process the plugins, if null or not supplied
2042
+ * then the current execution order will be copied.
2043
+ * @param startAt - The plugin to start processing from, if missing from the execution
2044
+ * order then the next plugin will be NOT set.
2045
+ */
2046
+ createNew: (plugins?: IPlugin[] | ITelemetryPluginChain, startAt?: IPlugin) => IProcessTelemetryUpdateContext;
2047
+ }
2048
+
1959
2049
  interface IRequestContext {
1960
2050
  status?: number;
1961
2051
  xhr?: XMLHttpRequest;
@@ -2191,6 +2281,15 @@ declare namespace ApplicationInsights {
2191
2281
  * to later plugins (vs appending items to the telemetry item)
2192
2282
  */
2193
2283
  processTelemetry: (env: ITelemetryItem, itemCtx?: IProcessTelemetryContext) => void;
2284
+ /**
2285
+ * The the plugin should re-evaluate configuration and update any cached configuration settings or
2286
+ * plugins. If implemented this method will be called whenever a plugin is added or removed and if
2287
+ * the configuration has bee updated.
2288
+ * @param updateCtx - This is the context that should be used during updating.
2289
+ * @param updateState - The details / state of the update process, it holds details like the current and previous configuration.
2290
+ * @returns boolean - true if the plugin has or will call updateCtx.processNext(), this allows the plugin to perform any asynchronous operations.
2291
+ */
2292
+ update?: (updateCtx: IProcessTelemetryUpdateContext, updateState: ITelemetryUpdateState) => void | boolean;
2194
2293
  }
2195
2294
 
2196
2295
  interface ITelemetryUnloadState {
@@ -2199,6 +2298,27 @@ declare namespace ApplicationInsights {
2199
2298
  flushComplete?: boolean;
2200
2299
  }
2201
2300
 
2301
+ interface ITelemetryUpdateState {
2302
+ /**
2303
+ * Identifies the reason for the update notification, this is a bitwise numeric value
2304
+ */
2305
+ reason: TelemetryUpdateReason;
2306
+ /**
2307
+ * If this is a configuration update this was the previous configuration that was used
2308
+ */
2309
+ /**
2310
+ * If this is a configuration update is the new configuration that is being used
2311
+ */
2312
+ /**
2313
+ * This holds a collection of plugins that have been added (if the reason identifies that one or more plugins have been added)
2314
+ */
2315
+ added?: IPlugin[];
2316
+ /**
2317
+ * This holds a collection of plugins that have been removed (if the reason identifies that one or more plugins have been removed)
2318
+ */
2319
+ removed?: IPlugin[];
2320
+ }
2321
+
2202
2322
  interface ITraceTelemetry extends IPartC {
2203
2323
  /**
2204
2324
  * @description A message string
@@ -2342,6 +2462,10 @@ declare namespace ApplicationInsights {
2342
2462
  * The event(s) being sent as a retry
2343
2463
  */
2344
2464
  Retry = 5,
2465
+ /**
2466
+ * The SDK is unloading
2467
+ */
2468
+ SdkUnload = 6,
2345
2469
  /**
2346
2470
  * Maximum batch size would be exceeded
2347
2471
  */
@@ -2376,9 +2500,44 @@ declare namespace ApplicationInsights {
2376
2500
  /**
2377
2501
  * Teardown has been called without any context.
2378
2502
  */
2379
- ManualTeardown = 0
2503
+ ManualTeardown = 0,
2504
+ /**
2505
+ * Just this plugin is being removed
2506
+ */
2507
+ PluginUnload = 1,
2508
+ /**
2509
+ * This instance of the plugin is being removed and replaced
2510
+ */
2511
+ PluginReplace = 2,
2512
+ /**
2513
+ * The entire SDK is being unloaded
2514
+ */
2515
+ SdkUnload = 50
2516
+ }
2517
+
2518
+ /**
2519
+ * The TelemetryUpdateReason enumeration contains a set of bit-wise values that specify the reason for update request.
2520
+ */
2521
+ const enum TelemetryUpdateReason {
2522
+ /**
2523
+ * Unknown.
2524
+ */
2525
+ Unknown = 0,
2526
+ /**
2527
+ * The configuration has ben updated or changed
2528
+ */
2529
+ /**
2530
+ * One or more plugins have been added
2531
+ */
2532
+ PluginAdded = 16,
2533
+ /**
2534
+ * One or more plugins have been removed
2535
+ */
2536
+ PluginRemoved = 32
2380
2537
  }
2381
2538
 
2539
+ type UnloadHandler = (itemCtx: IProcessTelemetryUnloadContext, unloadState: ITelemetryUnloadState) => void;
2540
+
2382
2541
  interface XDomainRequest extends XMLHttpRequestEventTarget {
2383
2542
  readonly responseText: string;
2384
2543
  send(payload: string): void;