diff --git a/src/browser/telemetryReporter.ts b/src/browser/telemetryReporter.ts index b20cc5d..955ae31 100644 --- a/src/browser/telemetryReporter.ts +++ b/src/browser/telemetryReporter.ts @@ -4,10 +4,10 @@ import * as vscode from "vscode"; import { oneDataSystemClientFactory } from "../common/1dsClientFactory"; -import { BaseTelemetrySender } from "../common/baseTelemetrySender"; +import { appInsightsClientFactory } from "../common/appInsightsClientFactory"; import { BaseTelemetryReporter, ReplacementOption } from "../common/baseTelemetryReporter"; +import { BaseTelemetrySender } from "../common/baseTelemetrySender"; import { TelemetryUtil } from "../common/util"; -import { appInsightsClientFactory } from "../common/appInsightsClientFactory"; function getBrowserRelease(navigator: Navigator): string { if (navigator.userAgentData) { @@ -22,7 +22,7 @@ function getBrowserRelease(navigator: Navigator): string { export default class TelemetryReporter extends BaseTelemetryReporter { constructor(key: string, replacementOptions?: ReplacementOption[]) { - let clientFactory = (key: string) => appInsightsClientFactory(key, undefined, replacementOptions); + let clientFactory = (key: string) => appInsightsClientFactory(key, vscode.env.machineId, undefined, replacementOptions); // If key is usable by 1DS use the 1DS SDk if (TelemetryUtil.shouldUseOneDataSystemSDK(key)) { clientFactory = (key: string) => oneDataSystemClientFactory(key, vscode); diff --git a/src/common/appInsightsClientFactory.ts b/src/common/appInsightsClientFactory.ts index 38db724..989b9fd 100644 --- a/src/common/appInsightsClientFactory.ts +++ b/src/common/appInsightsClientFactory.ts @@ -3,15 +3,15 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import type { ApplicationInsights } from "@microsoft/applicationinsights-web-basic"; -import type { IXHROverride, IConfiguration } from "@microsoft/applicationinsights-core-js"; +import type { IChannelConfiguration } from "@microsoft/1ds-post-js"; import { BreezeChannelIdentifier } from "@microsoft/applicationinsights-common"; +import type { IConfiguration, IXHROverride } from "@microsoft/applicationinsights-core-js"; +import type { ApplicationInsights } from "@microsoft/applicationinsights-web-basic"; import { ReplacementOption, SenderData } from "./baseTelemetryReporter"; import { BaseTelemetryClient } from "./baseTelemetrySender"; import { TelemetryUtil } from "./util"; -import type { IChannelConfiguration } from "@microsoft/1ds-post-js"; -export const appInsightsClientFactory = async (key: string, xhrOverride?: IXHROverride, replacementOptions?: ReplacementOption[]): Promise => { +export const appInsightsClientFactory = async (key: string, machineId: string, xhrOverride?: IXHROverride, replacementOptions?: ReplacementOption[]): Promise => { let appInsightsClient: ApplicationInsights | undefined; try { const basicAISDK = await import/* webpackMode: "eager" */("@microsoft/applicationinsights-web-basic"); @@ -37,6 +37,7 @@ export const appInsightsClientFactory = async (key: string, xhrOverride?: IXHROv disableInstrumentationKeyValidation: true, extensionConfig, }); + } catch (e) { return Promise.reject(e); } @@ -51,6 +52,7 @@ export const appInsightsClientFactory = async (key: string, xhrOverride?: IXHROv name: eventName, data: properties, baseType: "EventData", + ext: { user: { id: machineId, authenticatedId: machineId } }, baseData: { name: eventName, properties: data?.properties, measurements: data?.measurements } }); }, diff --git a/src/node/telemetryReporter.ts b/src/node/telemetryReporter.ts index 51e2617..a148b2b 100644 --- a/src/node/telemetryReporter.ts +++ b/src/node/telemetryReporter.ts @@ -2,15 +2,15 @@ * Copyright (C) Microsoft Corporation. All rights reserved. *--------------------------------------------------------*/ +import type { IPayloadData, IXHROverride } from "@microsoft/1ds-post-js"; +import * as https from "https"; import * as os from "os"; import * as vscode from "vscode"; -import * as https from "https"; +import { oneDataSystemClientFactory } from "../common/1dsClientFactory"; +import { appInsightsClientFactory } from "../common/appInsightsClientFactory"; import { BaseTelemetryReporter, ReplacementOption } from "../common/baseTelemetryReporter"; import { BaseTelemetrySender } from "../common/baseTelemetrySender"; import { TelemetryUtil } from "../common/util"; -import type { IXHROverride, IPayloadData } from "@microsoft/1ds-post-js"; -import { oneDataSystemClientFactory } from "../common/1dsClientFactory"; -import { appInsightsClientFactory } from "../common/appInsightsClientFactory"; /** * Create a replacement for the XHTMLRequest object utilizing nodes HTTP module. @@ -55,7 +55,7 @@ function getXHROverride() { export default class TelemetryReporter extends BaseTelemetryReporter { constructor(key: string, replacementOptions?: ReplacementOption[]) { - let clientFactory = (key: string) => appInsightsClientFactory(key, getXHROverride(), replacementOptions); + let clientFactory = (key: string) => appInsightsClientFactory(key, vscode.env.machineId, getXHROverride(), replacementOptions); // If key is usable by 1DS use the 1DS SDk if (TelemetryUtil.shouldUseOneDataSystemSDK(key)) { clientFactory = (key: string) => oneDataSystemClientFactory(key, vscode, getXHROverride());