@microsoft/applicationinsights-core-js 3.1.1-nightly3.2403-02 → 3.1.1-nightly3.2403-04

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 (101) hide show
  1. package/browser/es5/applicationinsights-core-js.cjs.js +1321 -745
  2. package/browser/es5/applicationinsights-core-js.cjs.js.map +1 -1
  3. package/browser/es5/applicationinsights-core-js.cjs.min.js +2 -2
  4. package/browser/es5/applicationinsights-core-js.cjs.min.js.map +1 -1
  5. package/browser/es5/applicationinsights-core-js.gbl.js +1323 -747
  6. package/browser/es5/applicationinsights-core-js.gbl.js.map +1 -1
  7. package/browser/es5/applicationinsights-core-js.gbl.min.js +2 -2
  8. package/browser/es5/applicationinsights-core-js.gbl.min.js.map +1 -1
  9. package/browser/es5/applicationinsights-core-js.integrity.json +25 -25
  10. package/browser/es5/applicationinsights-core-js.js +1323 -747
  11. package/browser/es5/applicationinsights-core-js.js.map +1 -1
  12. package/browser/es5/applicationinsights-core-js.min.js +2 -2
  13. package/browser/es5/applicationinsights-core-js.min.js.map +1 -1
  14. package/dist/es5/applicationinsights-core-js.js +1321 -745
  15. package/dist/es5/applicationinsights-core-js.js.map +1 -1
  16. package/dist/es5/applicationinsights-core-js.min.js +2 -2
  17. package/dist/es5/applicationinsights-core-js.min.js.map +1 -1
  18. package/dist-es5/Config/ConfigDefaultHelpers.js +1 -1
  19. package/dist-es5/Config/ConfigDefaults.js +1 -1
  20. package/dist-es5/Config/DynamicConfig.js +1 -1
  21. package/dist-es5/Config/DynamicProperty.js +1 -1
  22. package/dist-es5/Config/DynamicState.js +1 -1
  23. package/dist-es5/Config/DynamicSupport.js +1 -1
  24. package/dist-es5/Config/IConfigDefaults.js +1 -1
  25. package/dist-es5/Config/IDynamicConfigHandler.js +1 -1
  26. package/dist-es5/Config/IDynamicPropertyHandler.js +1 -1
  27. package/dist-es5/Config/IDynamicWatcher.js +1 -1
  28. package/dist-es5/Config/_IDynamicConfigHandlerState.js +1 -1
  29. package/dist-es5/JavaScriptSDK/AggregationError.js +1 -1
  30. package/dist-es5/JavaScriptSDK/AppInsightsCore.js +1 -1
  31. package/dist-es5/JavaScriptSDK/AsyncUtils.js +1 -1
  32. package/dist-es5/JavaScriptSDK/BaseTelemetryPlugin.js +1 -1
  33. package/dist-es5/JavaScriptSDK/Constants.js +9 -1
  34. package/dist-es5/JavaScriptSDK/Constants.js.map +1 -1
  35. package/dist-es5/JavaScriptSDK/CookieMgr.js +3 -3
  36. package/dist-es5/JavaScriptSDK/CookieMgr.js.map +1 -1
  37. package/dist-es5/JavaScriptSDK/CoreUtils.js +1 -1
  38. package/dist-es5/JavaScriptSDK/DataCacheHelper.js +1 -1
  39. package/dist-es5/JavaScriptSDK/DbgExtensionUtils.js +1 -1
  40. package/dist-es5/JavaScriptSDK/DiagnosticLogger.js +1 -1
  41. package/dist-es5/JavaScriptSDK/EnvUtils.js +1 -1
  42. package/dist-es5/JavaScriptSDK/EventHelpers.js +1 -1
  43. package/dist-es5/JavaScriptSDK/HelperFuncs.js +171 -3
  44. package/dist-es5/JavaScriptSDK/HelperFuncs.js.map +1 -1
  45. package/dist-es5/JavaScriptSDK/InstrumentHooks.js +1 -1
  46. package/dist-es5/JavaScriptSDK/InternalConstants.js +1 -1
  47. package/dist-es5/JavaScriptSDK/NotificationManager.js +3 -3
  48. package/dist-es5/JavaScriptSDK/NotificationManager.js.map +1 -1
  49. package/dist-es5/JavaScriptSDK/PerfManager.js +1 -1
  50. package/dist-es5/JavaScriptSDK/ProcessTelemetryContext.js +1 -1
  51. package/dist-es5/JavaScriptSDK/RandomHelper.js +1 -1
  52. package/dist-es5/JavaScriptSDK/SenderPostManager.js +533 -0
  53. package/dist-es5/JavaScriptSDK/SenderPostManager.js.map +1 -0
  54. package/dist-es5/JavaScriptSDK/TelemetryHelpers.js +1 -1
  55. package/dist-es5/JavaScriptSDK/TelemetryInitializerPlugin.js +1 -1
  56. package/dist-es5/JavaScriptSDK/UnloadHandlerContainer.js +1 -1
  57. package/dist-es5/JavaScriptSDK/UnloadHookContainer.js +1 -1
  58. package/dist-es5/JavaScriptSDK/W3cTraceParent.js +1 -1
  59. package/dist-es5/JavaScriptSDK.Enums/EnumHelperFuncs.js +1 -1
  60. package/dist-es5/JavaScriptSDK.Enums/EventsDiscardedReason.js +1 -1
  61. package/dist-es5/JavaScriptSDK.Enums/FeatureOptInEnums.js +1 -1
  62. package/dist-es5/JavaScriptSDK.Enums/LoggingEnums.js +1 -1
  63. package/dist-es5/JavaScriptSDK.Enums/SendRequestReason.js +1 -1
  64. package/dist-es5/JavaScriptSDK.Enums/TelemetryUnloadReason.js +1 -1
  65. package/dist-es5/JavaScriptSDK.Enums/TelemetryUpdateReason.js +1 -1
  66. package/dist-es5/JavaScriptSDK.Interfaces/IAppInsightsCore.js +1 -1
  67. package/dist-es5/JavaScriptSDK.Interfaces/IChannelControls.js +1 -1
  68. package/dist-es5/JavaScriptSDK.Interfaces/IChannelControlsHost.js +1 -1
  69. package/dist-es5/JavaScriptSDK.Interfaces/IConfiguration.js +1 -1
  70. package/dist-es5/JavaScriptSDK.Interfaces/ICookieMgr.js +1 -1
  71. package/dist-es5/JavaScriptSDK.Interfaces/IDbgExtension.js +1 -1
  72. package/dist-es5/JavaScriptSDK.Interfaces/IDiagnosticLogger.js +1 -1
  73. package/dist-es5/JavaScriptSDK.Interfaces/IDistributedTraceContext.js +1 -1
  74. package/dist-es5/JavaScriptSDK.Interfaces/IFeatureOptIn.js +1 -1
  75. package/dist-es5/JavaScriptSDK.Interfaces/IInstrumentHooks.js +1 -1
  76. package/dist-es5/JavaScriptSDK.Interfaces/INotificationListener.js +1 -1
  77. package/dist-es5/JavaScriptSDK.Interfaces/INotificationManager.js +1 -1
  78. package/dist-es5/JavaScriptSDK.Interfaces/IPerfEvent.js +1 -1
  79. package/dist-es5/JavaScriptSDK.Interfaces/IPerfManager.js +1 -1
  80. package/dist-es5/JavaScriptSDK.Interfaces/IProcessTelemetryContext.js +1 -1
  81. package/dist-es5/JavaScriptSDK.Interfaces/ISenderPostManager.js +6 -0
  82. package/dist-es5/JavaScriptSDK.Interfaces/ISenderPostManager.js.map +1 -0
  83. package/dist-es5/JavaScriptSDK.Interfaces/ITelemetryInitializers.js +1 -1
  84. package/dist-es5/JavaScriptSDK.Interfaces/ITelemetryItem.js +1 -1
  85. package/dist-es5/JavaScriptSDK.Interfaces/ITelemetryPlugin.js +1 -1
  86. package/dist-es5/JavaScriptSDK.Interfaces/ITelemetryPluginChain.js +1 -1
  87. package/dist-es5/JavaScriptSDK.Interfaces/ITelemetryUnloadState.js +1 -1
  88. package/dist-es5/JavaScriptSDK.Interfaces/ITelemetryUpdateState.js +1 -1
  89. package/dist-es5/JavaScriptSDK.Interfaces/ITraceParent.js +1 -1
  90. package/dist-es5/JavaScriptSDK.Interfaces/IUnloadHook.js +1 -1
  91. package/dist-es5/JavaScriptSDK.Interfaces/IUnloadableComponent.js +1 -1
  92. package/dist-es5/JavaScriptSDK.Interfaces/IXDomainRequest.js +6 -0
  93. package/dist-es5/JavaScriptSDK.Interfaces/IXDomainRequest.js.map +1 -0
  94. package/dist-es5/JavaScriptSDK.Interfaces/IXHROverride.js +1 -1
  95. package/dist-es5/__DynamicConstants.js +19 -8
  96. package/dist-es5/__DynamicConstants.js.map +1 -1
  97. package/dist-es5/applicationinsights-core-js.js +3 -2
  98. package/dist-es5/applicationinsights-core-js.js.map +1 -1
  99. package/package.json +1 -1
  100. package/types/applicationinsights-core-js.d.ts +241 -1
  101. package/types/applicationinsights-core-js.namespaced.d.ts +241 -1
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Microsoft Application Insights Core Javascript SDK, 3.1.1-nightly3.2403-02
2
+ * Microsoft Application Insights Core Javascript SDK, 3.1.1-nightly3.2403-04
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  *
5
5
  * Microsoft Application Insights Team
@@ -134,6 +134,12 @@ export declare function addPageShowEventListener(listener: any, excludeEvents?:
134
134
  */
135
135
  export declare function addPageUnloadEventListener(listener: any, excludeEvents?: string[], evtNamespace?: string | string[]): boolean;
136
136
 
137
+ /**
138
+ * append the XHR headers.
139
+ * @internal
140
+ */
141
+ export declare function _appendHeader(theHeaders: any, xhr: XMLHttpRequest, name: string): any;
142
+
137
143
  /**
138
144
  * @group Classes
139
145
  * @group Entrypoint
@@ -539,6 +545,14 @@ export declare function cfgDfString<T, C = IConfiguration>(defaultValue?: string
539
545
  */
540
546
  export declare function cfgDfValidate<V, T, C = IConfiguration>(validator: IConfigCheckFn<V>, defaultValue: V, fallBackName?: keyof T | keyof C | Array<keyof T | keyof C>): IConfigDefaultCheck<T, V, C>;
541
547
 
548
+ /**
549
+ * Converts the XHR getAllResponseHeaders to a map containing the header key and value.
550
+ * @internal
551
+ */
552
+ export declare function convertAllHeadersToMap(headersString: string): {
553
+ [headerName: string]: string;
554
+ };
555
+
542
556
  /**
543
557
  * Simpler helper to create a dynamic class that implements the interface and populates the values with the defaults.
544
558
  * Only instance properties (hasOwnProperty) values are copied from the defaults to the new instance
@@ -960,6 +974,10 @@ export declare function findW3cTraceParent(selectIdx?: number): ITraceParent;
960
974
  */
961
975
  export declare function forceDynamicConversion<T>(value: T): T;
962
976
 
977
+ export declare function formatErrorMessageXdr(xdr: IXDomainRequest, message?: string): string;
978
+
979
+ export declare function formatErrorMessageXhr(xhr: XMLHttpRequest, message?: string): string;
980
+
963
981
  /**
964
982
  * Format the ITraceParent value as a string using the supported and know version formats.
965
983
  * So even if the passed traceParent is a later version the string value returned from this
@@ -975,6 +993,12 @@ export declare function formatTraceParent(value: ITraceParent): string;
975
993
  */
976
994
  export declare function generateW3CId(): string;
977
995
 
996
+ /**
997
+ * get the XHR getAllResponseHeaders.
998
+ * @internal
999
+ */
1000
+ export declare function _getAllResponseHeaders(xhr: XMLHttpRequest, isOneDs?: boolean): {};
1001
+
978
1002
  /**
979
1003
  * Returns the global console object
980
1004
  */
@@ -1048,6 +1072,8 @@ export { getNavigator }
1048
1072
 
1049
1073
  export { getPerformance }
1050
1074
 
1075
+ export declare function getResponseText(xhr: XMLHttpRequest | IXDomainRequest): string;
1076
+
1051
1077
  /**
1052
1078
  * Returns the current value from the target object if not null or undefined otherwise sets the new value and returns it
1053
1079
  * @param target - The target object to return or set the default value
@@ -1221,6 +1247,25 @@ export declare interface IAppInsightsCore<CfgType extends IConfiguration = IConf
1221
1247
  getWParam: () => number;
1222
1248
  }
1223
1249
 
1250
+ export declare interface IBackendResponse {
1251
+ /**
1252
+ * Number of items received by the backend
1253
+ */
1254
+ readonly itemsReceived: number;
1255
+ /**
1256
+ * Number of items succesfuly accepted by the backend
1257
+ */
1258
+ readonly itemsAccepted: number;
1259
+ /**
1260
+ * List of errors for items which were not accepted
1261
+ */
1262
+ readonly errors: IResponseError[];
1263
+ /**
1264
+ * App id returned by the backend - not necessary returned, but we don't need it with each response.
1265
+ */
1266
+ readonly appId?: string;
1267
+ }
1268
+
1224
1269
  export declare interface IBaseProcessingContext {
1225
1270
  /**
1226
1271
  * The current core instance for the request
@@ -2034,6 +2079,17 @@ export declare interface IInternalOfflineSupport {
2034
2079
  shouldProcess?: (evt: ITelemetryItem) => boolean;
2035
2080
  }
2036
2081
 
2082
+ /**
2083
+ * Internal interface
2084
+ * internal sendpost interface
2085
+ * @internal
2086
+ * @since version after 3.1.0
2087
+ */
2088
+ export declare interface _IInternalXhrOverride extends IXHROverride {
2089
+ _transport?: TransportType;
2090
+ _isSync?: boolean;
2091
+ }
2092
+
2037
2093
  /**
2038
2094
  * An alternate interface which provides automatic removal during unloading of the component
2039
2095
  */
@@ -2485,6 +2541,12 @@ export declare interface _IRegisteredEvents {
2485
2541
  handler: any;
2486
2542
  }
2487
2543
 
2544
+ declare interface IResponseError {
2545
+ readonly index: number;
2546
+ readonly statusCode: number;
2547
+ readonly message: string;
2548
+ }
2549
+
2488
2550
  export { isArray }
2489
2551
 
2490
2552
  /**
@@ -2499,6 +2561,114 @@ export { isBoolean }
2499
2561
 
2500
2562
  export { isDate }
2501
2563
 
2564
+ /**
2565
+ * internal interface
2566
+ * Define functions when xhr/xdr/fetch requests are successfully returned. If they are not defined, oncomplete with be called instead
2567
+ * @internal for internal use only
2568
+ */
2569
+ export declare interface _ISenderOnComplete {
2570
+ /**
2571
+ * defined xdr onload function to handle response
2572
+ * @param dxr xdr request object
2573
+ * @param oncomplete oncomplete function
2574
+ * @since version after 3.1.0
2575
+ */
2576
+ xdrOnComplete?(xdr: IXDomainRequest, onComplete: OnCompleteCallback, payload?: IPayloadData): void;
2577
+ /**
2578
+ * defined fetch on complete function to handle response
2579
+ * @param response response object
2580
+ * @param onComplete oncomplete function
2581
+ * @param resValue response.text().value
2582
+ * @since version after 3.1.0
2583
+ */
2584
+ fetchOnComplete?(response: Response, onComplete: OnCompleteCallback, resValue?: string, payload?: IPayloadData): void;
2585
+ /**
2586
+ * defined xhr onreadystatechange function to handle response
2587
+ * @param request request object
2588
+ * @param oncomplete oncomplete function
2589
+ * @since version after 3.1.0
2590
+ */
2591
+ xhrOnComplete?(request: XMLHttpRequest, onComplete: OnCompleteCallback, payload?: IPayloadData): void;
2592
+ /**
2593
+ * Define functions during beacon can not send payload after first attempt. If not defined, will be apyload will be retried with fallback sender.
2594
+ * @param data payload data
2595
+ * @param onComplete oncomplete function
2596
+ * @param canSend can the current data sent by beacon sender
2597
+ * @since version after 3.1.0
2598
+ */
2599
+ beaconOnRetry?(data: IPayloadData, onComplete: OnCompleteCallback, canSend: (payload: IPayloadData, oncomplete: OnCompleteCallback, sync?: boolean) => boolean): void;
2600
+ }
2601
+
2602
+ /**
2603
+ * Internal interface for SendPostMnager
2604
+ * @internal for internal use only
2605
+ */
2606
+ export declare interface _ISendPostMgrConfig {
2607
+ /**
2608
+ * Enable the sender interface to return a promise
2609
+ * Note: Enabling this may cause unhandled promise rejection errors to occur if you do not listen and handle any rejection response,
2610
+ * Defaults to false
2611
+ * @since version after 3.1.0
2612
+ */
2613
+ enableSendPromise?: boolean;
2614
+ /**
2615
+ * Identifies if the sender is 1ds post channel
2616
+ * Default is false
2617
+ * @since version after 3.1.0
2618
+ */
2619
+ isOneDs?: boolean;
2620
+ /**
2621
+ * Identify if Credentials should be disabled for 1ds post channel, application insights sender will igore this config
2622
+ * Default is false
2623
+ * @since version after 3.1.0
2624
+ */
2625
+ disableCredentials?: boolean;
2626
+ /**
2627
+ * Identifies if XMLHttpRequest or XDomainRequest (for IE < 9) should be used
2628
+ * Default: false
2629
+ * @since version after 3.1.0
2630
+ */
2631
+ disableXhr?: boolean;
2632
+ /**
2633
+ * Is beacon disabled during async sending
2634
+ * Default: false
2635
+ * @since version after 3.1.0
2636
+ */
2637
+ disableBeacon?: boolean;
2638
+ /**
2639
+ * Is beacon disabled during sync sending
2640
+ * Default: false
2641
+ * @since version after 3.1.0
2642
+ */
2643
+ disableBeaconSync?: boolean;
2644
+ /**
2645
+ * Is FetchKeepAlive disabled during sync sending
2646
+ * Default: false
2647
+ * @since version after 3.1.0
2648
+ */
2649
+ disableFetchKeepAlive?: boolean;
2650
+ /**
2651
+ * Identifies functions when xhr/xdr/fetch requests are successfully returned. If they are not defined, oncomplete with be called instead
2652
+ * @since version after 3.1.0
2653
+ */
2654
+ senderOnCompleteCallBack?: _ISenderOnComplete;
2655
+ /**
2656
+ * time wrapper to handle payload timeout
2657
+ * this is for 1ds post channel only
2658
+ * Default: null
2659
+ * @since version after 3.1.0
2660
+ */
2661
+ timeWrapper?: _ITimeoutOverrideWrapper;
2662
+ /**
2663
+ * [Optional] flag to indicate whether the sendBeacon and fetch (with keep-alive flag) should add the "NoResponseBody" query string
2664
+ * value to indicate that the server should return a 204 for successful requests. Defaults to true
2665
+ * this is for 1ds post channel only
2666
+ * Default: true
2667
+ * @since version after 3.1.0
2668
+ */
2669
+ addNoResponse?: boolean;
2670
+ }
2671
+
2502
2672
  export { isError }
2503
2673
 
2504
2674
  export declare function isFeatureEnabled<T extends IConfiguration = IConfiguration>(feature?: string, cfg?: T): boolean;
@@ -2737,6 +2907,16 @@ export declare interface ITelemetryUpdateState {
2737
2907
  removed?: IPlugin[];
2738
2908
  }
2739
2909
 
2910
+ /**
2911
+ * Internal interface
2912
+ * Simple internal timeout wrapper
2913
+ * @internal
2914
+ * @since version after 3.1.0
2915
+ */
2916
+ export declare interface _ITimeoutOverrideWrapper {
2917
+ set: (callback: (...args: any[]) => void, ms: number, ...args: any[]) => ITimerHandler;
2918
+ }
2919
+
2740
2920
  /**
2741
2921
  * This interface represents the components of a W3C traceparent header
2742
2922
  */
@@ -2845,6 +3025,17 @@ export declare interface IWatcherHandler<T = IConfiguration> extends IUnloadHook
2845
3025
  rm: () => void;
2846
3026
  }
2847
3027
 
3028
+ export declare interface IXDomainRequest extends XMLHttpRequestEventTarget {
3029
+ readonly responseText: string;
3030
+ send(payload: string): void;
3031
+ open(method: string, url: string): void;
3032
+ timeout: number;
3033
+ contentType: string;
3034
+ addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void;
3035
+ addEventListener(type: "load" | "timeout", listener: (ev: Event) => any, useCapture?: boolean): void;
3036
+ addEventListener(type: "progress", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void;
3037
+ }
3038
+
2848
3039
  /**
2849
3040
  * The IXHROverride interface overrides the way HTTP requests are sent.
2850
3041
  */
@@ -3009,6 +3200,18 @@ export declare type OnCompleteCallback = (status: number, headers: {
3009
3200
  */
3010
3201
  export declare function onConfigChange<T = IConfiguration>(config: T, configHandler: WatcherFunction<T>, logger?: IDiagnosticLogger): IWatcherHandler<T>;
3011
3202
 
3203
+ /**
3204
+ * Create and open an XMLHttpRequest object
3205
+ * @param method - The request method
3206
+ * @param urlString - The url
3207
+ * @param withCredentials - Option flag indicating that credentials should be sent
3208
+ * @param disabled - Optional flag indicating that the XHR object should be marked as disabled and not tracked (default is false)
3209
+ * @param isSync - Optional flag indicating if the instance should be a synchronous request (defaults to false)
3210
+ * @param timeout - Optional value identifying the timeout value that should be assigned to the XHR request
3211
+ * @returns A new opened XHR request
3212
+ */
3213
+ export declare function openXhr(method: string, urlString: string, withCredentials?: boolean, disabled?: boolean, isSync?: boolean, timeout?: number): XMLHttpRequest;
3214
+
3012
3215
  /**
3013
3216
  * A helper function to assist with JIT performance for objects that have properties added / removed dynamically
3014
3217
  * this is primarily for chromium based browsers and has limited effects on Firefox and none of IE. Only call this
@@ -3018,6 +3221,12 @@ export declare function onConfigChange<T = IConfiguration>(config: T, configHand
3018
3221
  */
3019
3222
  export declare function optimizeObject<T>(theObject: T): T;
3020
3223
 
3224
+ /**
3225
+ * Parses the response from the backend.
3226
+ * @param response - XMLHttpRequest or XDomainRequest response
3227
+ */
3228
+ export declare function parseResponse(response: any, diagLog?: IDiagnosticLogger): IBackendResponse;
3229
+
3021
3230
  /**
3022
3231
  * Attempt to parse the provided string as a W3C TraceParent header value (https://www.w3.org/TR/trace-context/#traceparent-header)
3023
3232
  *
@@ -3102,6 +3311,8 @@ export declare class PerfManager implements IPerfManager {
3102
3311
 
3103
3312
  export { perfNow }
3104
3313
 
3314
+ export declare function prependTransports(theTransports: TransportType[], newTransports: TransportType | TransportType[]): TransportType[];
3315
+
3105
3316
  /**
3106
3317
  * This class will be removed!
3107
3318
  * @deprecated use createProcessTelemetryContext() instead
@@ -3292,6 +3503,35 @@ export declare function safeGetLogger(core: IAppInsightsCore, config?: IConfigur
3292
3503
 
3293
3504
  export declare function sendCustomEvent(evtName: string, cfg?: any, customDetails?: any): boolean;
3294
3505
 
3506
+ /**
3507
+ * This Internal component
3508
+ * Manager SendPost functions
3509
+ * SendPostManger
3510
+ * @internal for internal use only
3511
+ */
3512
+ export declare class SenderPostManager {
3513
+ constructor();
3514
+ initialize(config: _ISendPostMgrConfig, diagLog: IDiagnosticLogger): void;
3515
+ /**
3516
+ * Get size of current sync fetch payload
3517
+ */
3518
+ getSyncFetchPayload(): number;
3519
+ /**
3520
+ * reset Config
3521
+ * @returns True if set is successfully
3522
+ */
3523
+ SetConfig(config: _ISendPostMgrConfig): boolean;
3524
+ /**
3525
+ * Get current xhr instance
3526
+ */
3527
+ getSenderInst(transports: TransportType[], sync?: boolean): IXHROverride;
3528
+ /**
3529
+ * Get current fallback sender instance
3530
+ */
3531
+ getFallbackInst(): IXHROverride;
3532
+ _doTeardown(unloadCtx?: IProcessTelemetryUnloadContext, unloadState?: ITelemetryUnloadState): void;
3533
+ }
3534
+
3295
3535
  /**
3296
3536
  * SendPOSTFunction type defines how an HTTP POST request is sent to an ingestion server
3297
3537
  * @param payload - The payload object that should be sent, contains the url, bytes/string and headers for the request
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Microsoft Application Insights Core Javascript SDK, 3.1.1-nightly3.2403-02
2
+ * Microsoft Application Insights Core Javascript SDK, 3.1.1-nightly3.2403-04
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  *
5
5
  * Microsoft Application Insights Team
@@ -76,6 +76,12 @@ declare namespace ApplicationInsights {
76
76
  */
77
77
  function addPageUnloadEventListener(listener: any, excludeEvents?: string[], evtNamespace?: string | string[]): boolean;
78
78
 
79
+ /**
80
+ * append the XHR headers.
81
+ * @internal
82
+ */
83
+ function _appendHeader(theHeaders: any, xhr: XMLHttpRequest, name: string): any;
84
+
79
85
  /**
80
86
  * @group Classes
81
87
  * @group Entrypoint
@@ -734,6 +740,14 @@ declare namespace ApplicationInsights {
734
740
  */
735
741
  function cfgDfValidate<V, T, C = IConfiguration>(validator: IConfigCheckFn<V>, defaultValue: V, fallBackName?: keyof T | keyof C | Array<keyof T | keyof C>): IConfigDefaultCheck<T, V, C>;
736
742
 
743
+ /**
744
+ * Converts the XHR getAllResponseHeaders to a map containing the header key and value.
745
+ * @internal
746
+ */
747
+ function convertAllHeadersToMap(headersString: string): {
748
+ [headerName: string]: string;
749
+ };
750
+
737
751
  /**
738
752
  * Simpler helper to create a dynamic class that implements the interface and populates the values with the defaults.
739
753
  * Only instance properties (hasOwnProperty) values are copied from the defaults to the new instance
@@ -1250,6 +1264,10 @@ declare namespace ApplicationInsights {
1250
1264
  */
1251
1265
  function forceDynamicConversion<T>(value: T): T;
1252
1266
 
1267
+ function formatErrorMessageXdr(xdr: IXDomainRequest, message?: string): string;
1268
+
1269
+ function formatErrorMessageXhr(xhr: XMLHttpRequest, message?: string): string;
1270
+
1253
1271
  /**
1254
1272
  * Format the ITraceParent value as a string using the supported and know version formats.
1255
1273
  * So even if the passed traceParent is a later version the string value returned from this
@@ -1265,6 +1283,12 @@ declare namespace ApplicationInsights {
1265
1283
  */
1266
1284
  function generateW3CId(): string;
1267
1285
 
1286
+ /**
1287
+ * get the XHR getAllResponseHeaders.
1288
+ * @internal
1289
+ */
1290
+ function _getAllResponseHeaders(xhr: XMLHttpRequest, isOneDs?: boolean): {};
1291
+
1268
1292
  /**
1269
1293
  * Returns the global console object
1270
1294
  */
@@ -1400,6 +1424,8 @@ declare namespace ApplicationInsights {
1400
1424
  */
1401
1425
  function getPerformance(): Performance;
1402
1426
 
1427
+ function getResponseText(xhr: XMLHttpRequest | IXDomainRequest): string;
1428
+
1403
1429
  /**
1404
1430
  * Returns the current value from the target object if not null or undefined otherwise sets the new value and returns it
1405
1431
  * @param target - The target object to return or set the default value
@@ -1630,6 +1656,25 @@ declare namespace ApplicationInsights {
1630
1656
  getWParam: () => number;
1631
1657
  }
1632
1658
 
1659
+ interface IBackendResponse {
1660
+ /**
1661
+ * Number of items received by the backend
1662
+ */
1663
+ readonly itemsReceived: number;
1664
+ /**
1665
+ * Number of items succesfuly accepted by the backend
1666
+ */
1667
+ readonly itemsAccepted: number;
1668
+ /**
1669
+ * List of errors for items which were not accepted
1670
+ */
1671
+ readonly errors: IResponseError[];
1672
+ /**
1673
+ * App id returned by the backend - not necessary returned, but we don't need it with each response.
1674
+ */
1675
+ readonly appId?: string;
1676
+ }
1677
+
1633
1678
  interface IBaseProcessingContext {
1634
1679
  /**
1635
1680
  * The current core instance for the request
@@ -2443,6 +2488,17 @@ declare namespace ApplicationInsights {
2443
2488
  shouldProcess?: (evt: ITelemetryItem) => boolean;
2444
2489
  }
2445
2490
 
2491
+ /**
2492
+ * Internal interface
2493
+ * internal sendpost interface
2494
+ * @internal
2495
+ * @since version after 3.1.0
2496
+ */
2497
+ interface _IInternalXhrOverride extends IXHROverride {
2498
+ _transport?: TransportType;
2499
+ _isSync?: boolean;
2500
+ }
2501
+
2446
2502
  /**
2447
2503
  * An alternate interface which provides automatic removal during unloading of the component
2448
2504
  */
@@ -3102,6 +3158,12 @@ declare namespace ApplicationInsights {
3102
3158
  handler: any;
3103
3159
  }
3104
3160
 
3161
+ interface IResponseError {
3162
+ readonly index: number;
3163
+ readonly statusCode: number;
3164
+ readonly message: string;
3165
+ }
3166
+
3105
3167
  /**
3106
3168
  * Checks if the type of value is an Array.
3107
3169
  *
@@ -3158,6 +3220,114 @@ declare namespace ApplicationInsights {
3158
3220
  */
3159
3221
  const isDate: (value: any) => value is Date;
3160
3222
 
3223
+ /**
3224
+ * internal interface
3225
+ * Define functions when xhr/xdr/fetch requests are successfully returned. If they are not defined, oncomplete with be called instead
3226
+ * @internal for internal use only
3227
+ */
3228
+ interface _ISenderOnComplete {
3229
+ /**
3230
+ * defined xdr onload function to handle response
3231
+ * @param dxr xdr request object
3232
+ * @param oncomplete oncomplete function
3233
+ * @since version after 3.1.0
3234
+ */
3235
+ xdrOnComplete?(xdr: IXDomainRequest, onComplete: OnCompleteCallback, payload?: IPayloadData): void;
3236
+ /**
3237
+ * defined fetch on complete function to handle response
3238
+ * @param response response object
3239
+ * @param onComplete oncomplete function
3240
+ * @param resValue response.text().value
3241
+ * @since version after 3.1.0
3242
+ */
3243
+ fetchOnComplete?(response: Response, onComplete: OnCompleteCallback, resValue?: string, payload?: IPayloadData): void;
3244
+ /**
3245
+ * defined xhr onreadystatechange function to handle response
3246
+ * @param request request object
3247
+ * @param oncomplete oncomplete function
3248
+ * @since version after 3.1.0
3249
+ */
3250
+ xhrOnComplete?(request: XMLHttpRequest, onComplete: OnCompleteCallback, payload?: IPayloadData): void;
3251
+ /**
3252
+ * Define functions during beacon can not send payload after first attempt. If not defined, will be apyload will be retried with fallback sender.
3253
+ * @param data payload data
3254
+ * @param onComplete oncomplete function
3255
+ * @param canSend can the current data sent by beacon sender
3256
+ * @since version after 3.1.0
3257
+ */
3258
+ beaconOnRetry?(data: IPayloadData, onComplete: OnCompleteCallback, canSend: (payload: IPayloadData, oncomplete: OnCompleteCallback, sync?: boolean) => boolean): void;
3259
+ }
3260
+
3261
+ /**
3262
+ * Internal interface for SendPostMnager
3263
+ * @internal for internal use only
3264
+ */
3265
+ interface _ISendPostMgrConfig {
3266
+ /**
3267
+ * Enable the sender interface to return a promise
3268
+ * Note: Enabling this may cause unhandled promise rejection errors to occur if you do not listen and handle any rejection response,
3269
+ * Defaults to false
3270
+ * @since version after 3.1.0
3271
+ */
3272
+ enableSendPromise?: boolean;
3273
+ /**
3274
+ * Identifies if the sender is 1ds post channel
3275
+ * Default is false
3276
+ * @since version after 3.1.0
3277
+ */
3278
+ isOneDs?: boolean;
3279
+ /**
3280
+ * Identify if Credentials should be disabled for 1ds post channel, application insights sender will igore this config
3281
+ * Default is false
3282
+ * @since version after 3.1.0
3283
+ */
3284
+ disableCredentials?: boolean;
3285
+ /**
3286
+ * Identifies if XMLHttpRequest or XDomainRequest (for IE < 9) should be used
3287
+ * Default: false
3288
+ * @since version after 3.1.0
3289
+ */
3290
+ disableXhr?: boolean;
3291
+ /**
3292
+ * Is beacon disabled during async sending
3293
+ * Default: false
3294
+ * @since version after 3.1.0
3295
+ */
3296
+ disableBeacon?: boolean;
3297
+ /**
3298
+ * Is beacon disabled during sync sending
3299
+ * Default: false
3300
+ * @since version after 3.1.0
3301
+ */
3302
+ disableBeaconSync?: boolean;
3303
+ /**
3304
+ * Is FetchKeepAlive disabled during sync sending
3305
+ * Default: false
3306
+ * @since version after 3.1.0
3307
+ */
3308
+ disableFetchKeepAlive?: boolean;
3309
+ /**
3310
+ * Identifies functions when xhr/xdr/fetch requests are successfully returned. If they are not defined, oncomplete with be called instead
3311
+ * @since version after 3.1.0
3312
+ */
3313
+ senderOnCompleteCallBack?: _ISenderOnComplete;
3314
+ /**
3315
+ * time wrapper to handle payload timeout
3316
+ * this is for 1ds post channel only
3317
+ * Default: null
3318
+ * @since version after 3.1.0
3319
+ */
3320
+ timeWrapper?: _ITimeoutOverrideWrapper;
3321
+ /**
3322
+ * [Optional] flag to indicate whether the sendBeacon and fetch (with keep-alive flag) should add the "NoResponseBody" query string
3323
+ * value to indicate that the server should return a 204 for successful requests. Defaults to true
3324
+ * this is for 1ds post channel only
3325
+ * Default: true
3326
+ * @since version after 3.1.0
3327
+ */
3328
+ addNoResponse?: boolean;
3329
+ }
3330
+
3161
3331
  /**
3162
3332
  * Checks if the type of value is a Error object.
3163
3333
  * @group Type Identity
@@ -3557,6 +3727,16 @@ declare namespace ApplicationInsights {
3557
3727
  removed?: IPlugin[];
3558
3728
  }
3559
3729
 
3730
+ /**
3731
+ * Internal interface
3732
+ * Simple internal timeout wrapper
3733
+ * @internal
3734
+ * @since version after 3.1.0
3735
+ */
3736
+ interface _ITimeoutOverrideWrapper {
3737
+ set: (callback: (...args: any[]) => void, ms: number, ...args: any[]) => ITimerHandler;
3738
+ }
3739
+
3560
3740
  /**
3561
3741
  * A Timer handler which is returned from {@link scheduleTimeout} which contains functions to
3562
3742
  * cancel or restart (refresh) the timeout function.
@@ -3779,6 +3959,17 @@ declare namespace ApplicationInsights {
3779
3959
  rm: () => void;
3780
3960
  }
3781
3961
 
3962
+ interface IXDomainRequest extends XMLHttpRequestEventTarget {
3963
+ readonly responseText: string;
3964
+ send(payload: string): void;
3965
+ open(method: string, url: string): void;
3966
+ timeout: number;
3967
+ contentType: string;
3968
+ addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void;
3969
+ addEventListener(type: "load" | "timeout", listener: (ev: Event) => any, useCapture?: boolean): void;
3970
+ addEventListener(type: "progress", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void;
3971
+ }
3972
+
3782
3973
  /**
3783
3974
  * The IXHROverride interface overrides the way HTTP requests are sent.
3784
3975
  */
@@ -4068,6 +4259,18 @@ declare namespace ApplicationInsights {
4068
4259
  */
4069
4260
  function onConfigChange<T = IConfiguration>(config: T, configHandler: WatcherFunction<T>, logger?: IDiagnosticLogger): IWatcherHandler<T>;
4070
4261
 
4262
+ /**
4263
+ * Create and open an XMLHttpRequest object
4264
+ * @param method - The request method
4265
+ * @param urlString - The url
4266
+ * @param withCredentials - Option flag indicating that credentials should be sent
4267
+ * @param disabled - Optional flag indicating that the XHR object should be marked as disabled and not tracked (default is false)
4268
+ * @param isSync - Optional flag indicating if the instance should be a synchronous request (defaults to false)
4269
+ * @param timeout - Optional value identifying the timeout value that should be assigned to the XHR request
4270
+ * @returns A new opened XHR request
4271
+ */
4272
+ function openXhr(method: string, urlString: string, withCredentials?: boolean, disabled?: boolean, isSync?: boolean, timeout?: number): XMLHttpRequest;
4273
+
4071
4274
  /**
4072
4275
  * A helper function to assist with JIT performance for objects that have properties added / removed dynamically
4073
4276
  * this is primarily for chromium based browsers and has limited effects on Firefox and none of IE. Only call this
@@ -4077,6 +4280,12 @@ declare namespace ApplicationInsights {
4077
4280
  */
4078
4281
  function optimizeObject<T>(theObject: T): T;
4079
4282
 
4283
+ /**
4284
+ * Parses the response from the backend.
4285
+ * @param response - XMLHttpRequest or XDomainRequest response
4286
+ */
4287
+ function parseResponse(response: any, diagLog?: IDiagnosticLogger): IBackendResponse;
4288
+
4080
4289
  /**
4081
4290
  * Attempt to parse the provided string as a W3C TraceParent header value (https://www.w3.org/TR/trace-context/#traceparent-header)
4082
4291
  *
@@ -4176,6 +4385,8 @@ declare namespace ApplicationInsights {
4176
4385
  */
4177
4386
  function perfNow(): number;
4178
4387
 
4388
+ function prependTransports(theTransports: TransportType[], newTransports: TransportType | TransportType[]): TransportType[];
4389
+
4179
4390
  /**
4180
4391
  * This class will be removed!
4181
4392
  * @deprecated use createProcessTelemetryContext() instead
@@ -4380,6 +4591,35 @@ declare namespace ApplicationInsights {
4380
4591
 
4381
4592
  function sendCustomEvent(evtName: string, cfg?: any, customDetails?: any): boolean;
4382
4593
 
4594
+ /**
4595
+ * This Internal component
4596
+ * Manager SendPost functions
4597
+ * SendPostManger
4598
+ * @internal for internal use only
4599
+ */
4600
+ class SenderPostManager {
4601
+ constructor();
4602
+ initialize(config: _ISendPostMgrConfig, diagLog: IDiagnosticLogger): void;
4603
+ /**
4604
+ * Get size of current sync fetch payload
4605
+ */
4606
+ getSyncFetchPayload(): number;
4607
+ /**
4608
+ * reset Config
4609
+ * @returns True if set is successfully
4610
+ */
4611
+ SetConfig(config: _ISendPostMgrConfig): boolean;
4612
+ /**
4613
+ * Get current xhr instance
4614
+ */
4615
+ getSenderInst(transports: TransportType[], sync?: boolean): IXHROverride;
4616
+ /**
4617
+ * Get current fallback sender instance
4618
+ */
4619
+ getFallbackInst(): IXHROverride;
4620
+ _doTeardown(unloadCtx?: IProcessTelemetryUnloadContext, unloadState?: ITelemetryUnloadState): void;
4621
+ }
4622
+
4383
4623
  /**
4384
4624
  * SendPOSTFunction type defines how an HTTP POST request is sent to an ingestion server
4385
4625
  * @param payload - The payload object that should be sent, contains the url, bytes/string and headers for the request