4
4
*--------------------------------------------------------------------------------------------*/
5
5
6
6
import type { ApplicationInsights } from "@microsoft/applicationinsights-web-basic" ;
7
- import type { IXHROverride } from "@microsoft/applicationinsights-core-js" ;
7
+ import type { IXHROverride , IConfiguration } from "@microsoft/applicationinsights-core-js" ;
8
8
import { BreezeChannelIdentifier } from "@microsoft/applicationinsights-common" ;
9
9
import { ReplacementOption , SenderData } from "./baseTelemetryReporter" ;
10
10
import { BaseTelemetryClient } from "./baseTelemetrySender" ;
@@ -15,6 +15,16 @@ export const appInsightsClientFactory = async (key: string, xhrOverride?: IXHROv
15
15
let appInsightsClient : ApplicationInsights | undefined ;
16
16
try {
17
17
const basicAISDK = await import /* webpackMode: "eager" */ ( "@microsoft/applicationinsights-web-basic" ) ;
18
+ const extensionConfig : IConfiguration [ "extensionConfig" ] = { } ;
19
+ if ( xhrOverride ) {
20
+ // Configure the channel to use a XHR Request override since it's not available in node
21
+ const channelConfig : IChannelConfiguration = {
22
+ alwaysUseXhrOverride : true ,
23
+ httpXHROverride : xhrOverride
24
+ } ;
25
+ extensionConfig [ BreezeChannelIdentifier ] = channelConfig ;
26
+ }
27
+
18
28
appInsightsClient = new basicAISDK . ApplicationInsights ( {
19
29
instrumentationKey : key ,
20
30
disableAjaxTracking : true ,
@@ -24,19 +34,9 @@ export const appInsightsClientFactory = async (key: string, xhrOverride?: IXHROv
24
34
disableCookiesUsage : true ,
25
35
autoTrackPageVisitTime : false ,
26
36
emitLineDelimitedJson : false ,
27
- disableInstrumentationKeyValidation : true
28
- } ,
29
- ) ;
30
-
31
- if ( xhrOverride ) {
32
- appInsightsClient . config . extensionConfig = { } ;
33
- // Configure the channel to use a XHR Request override since it's not available in node
34
- const channelConfig : IChannelConfiguration = {
35
- alwaysUseXhrOverride : true ,
36
- httpXHROverride : xhrOverride
37
- } ;
38
- appInsightsClient . config . extensionConfig [ BreezeChannelIdentifier ] = channelConfig ;
39
- }
37
+ disableInstrumentationKeyValidation : true ,
38
+ extensionConfig,
39
+ } ) ;
40
40
} catch ( e ) {
41
41
return Promise . reject ( e ) ;
42
42
}
0 commit comments