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

Populate attributes for desktop extension telemetry #832

Merged
merged 11 commits into from
Mar 5, 2024
3 changes: 2 additions & 1 deletion src/client/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ import { fetchArtemisResponse } from "../common/ArtemisService";
import { oneDSLoggerWrapper } from "../common/OneDSLoggerTelemetry/oneDSLoggerWrapper";
import { OrgChangeNotifier, orgChangeEvent } from "../common/OrgChangeNotifier";
import { ActiveOrgOutput } from "./pac/PacTypes";

import { telemetryEventNames } from "./telemetry/TelemetryEventNames";

let client: LanguageClient;
let _context: vscode.ExtensionContext;
Expand Down Expand Up @@ -195,6 +195,7 @@ export async function activate(
if (artemisResponse) {
const { geoName } = artemisResponse[0];
oneDSLoggerWrapper.instantiate(geoName);
oneDSLoggerWrapper.getLogger().traceInfo(telemetryEventNames.DESKTOP_EXTENSION_INIT_CONTEXT, orgDetails);
}
})
);
Expand Down
9 changes: 9 additions & 0 deletions src/client/telemetry/TelemetryEventNames.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/*
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*/

export enum telemetryEventNames {
gshivi marked this conversation as resolved.
Show resolved Hide resolved
DESKTOP_EXTENSION_INIT_CONTEXT = "DesktopExtensionInitContext",

}
12 changes: 8 additions & 4 deletions src/common/OneDSLoggerTelemetry/oneDSLogger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { EXTENSION_ID } from "../../client/constants";
import {OneDSCollectorEventName} from "./EventContants";
import { telemetryEventNames } from "../../web/client/telemetry/constants";
import { region } from "../telemetry-generated/buildRegionConfiguration";
import { telemetryEventNames as desktopExtTelemetryEventNames } from "../../client/telemetry/TelemetryEventNames";

interface IInstrumentationSettings {
endpointURL: string;
Expand Down Expand Up @@ -270,17 +271,16 @@ export class OneDSLogger implements ITelemetryLogger{

envelope.data.clientSessionId = vscode.env.sessionId;
envelope.data.vscodeSurface = getExtensionType();
envelope.data.vscodeMachineId = vscode.env.machineId;
envelope.data.vscodeExtensionName = EXTENSION_ID;
envelope.data.vscodeExtensionVersion = getExtensionVersion();
envelope.data.vscodeVersion = vscode.version;
envelope.data.domain = vscode.env.appHost;
envelope.data.measurements = envelope.data.measurement;
// Adding below attributes so they get populated in Geneva.
// TODO: It needs implementation for populating the actual value
envelope.data.eventSubType = "test";
envelope.data.scenarioId = "test";
envelope.data.eventModifier = "test";
envelope.data.timestamp = "test";
envelope.data.country = "test";
envelope.data.userLocale = "test";
envelope.data.userDataBoundary = "test";
Expand Down Expand Up @@ -342,8 +342,12 @@ export class OneDSLogger implements ITelemetryLogger{

// eslint-disable-next-line @typescript-eslint/no-explicit-any
private populateVscodeDesktopAttributes(envelope: any){
// TODO: this method helps in populating desktop attributes.
console.log(envelope);
if (envelope.data.eventName == desktopExtTelemetryEventNames.DESKTOP_EXTENSION_INIT_CONTEXT) {
OneDSLogger.contextInfo.orgId = JSON.parse(envelope.data.eventInfo).OrgId;
OneDSLogger.contextInfo.envId = JSON.parse(envelope.data.eventInfo).EnvironmentId;
// TODO: Populate website id
gshivi marked this conversation as resolved.
Show resolved Hide resolved
OneDSLogger.contextInfo.websiteId = 'test'
gshivi marked this conversation as resolved.
Show resolved Hide resolved
}
}

//// Redact Sensitive data for the fields susceptible to contain codes/tokens/keys/secrets etc.
Expand Down
Loading