Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Send user id in extension paylod #210

Merged
merged 1 commit into from
Jul 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/browser/telemetryReporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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);
Expand Down
10 changes: 6 additions & 4 deletions src/common/appInsightsClientFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<BaseTelemetryClient> => {
export const appInsightsClientFactory = async (key: string, machineId: string, xhrOverride?: IXHROverride, replacementOptions?: ReplacementOption[]): Promise<BaseTelemetryClient> => {
let appInsightsClient: ApplicationInsights | undefined;
try {
const basicAISDK = await import/* webpackMode: "eager" */("@microsoft/applicationinsights-web-basic");
Expand All @@ -37,6 +37,7 @@ export const appInsightsClientFactory = async (key: string, xhrOverride?: IXHROv
disableInstrumentationKeyValidation: true,
extensionConfig,
});

} catch (e) {
return Promise.reject(e);
}
Expand All @@ -51,6 +52,7 @@ export const appInsightsClientFactory = async (key: string, xhrOverride?: IXHROv
name: eventName,
data: properties,
baseType: "EventData",
ext: { user: { id: machineId, authenticatedId: machineId } },
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The actual field for the authenticated id is authId

baseData: { name: eventName, properties: data?.properties, measurements: data?.measurements }
});
},
Expand Down
10 changes: 5 additions & 5 deletions src/node/telemetryReporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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());
Expand Down
Loading