microsoft / vscode-extension-telemetry

Node module to help VS Code extensions send telemetry using application insights
https://www.npmjs.com/package/@vscode/extension-telemetry
Other
125 stars 46 forks source link

Set xhr override before creating AppInsights client #199

Closed devm33 closed 6 months ago

devm33 commented 6 months ago

If not supplied to the constructor the delegate AppInsightsCore class does not pick up the default channel (BreezeChannelIdentifier = "AppInsightsChannelPlugin") plugin configuration and therefore doesn't use the supplied XHR override.

This is subtle to notice when running in Node 18+ (VS Code 1.82+) since the AppInsights SDK mostly uses the fetch API which is available in Node and appears to work.

This is similar to the pattern used for the 1DS client which presumably doesn't have the same issue and is where I got the idea to try it. Except the 1DS SDK separates the constructor from an initialize method:

https://github.com/microsoft/vscode-extension-telemetry/blob/3a87442dc26f80072f793ac8a1fc47bf0224c81a/src/common/1dsClientFactory.ts#L50