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

Report modernNet option and whether project is sdk style #5567

Merged
merged 2 commits into from
Mar 11, 2023
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
5 changes: 3 additions & 2 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,11 +150,12 @@ export async function activate(context: vscode.ExtensionContext): Promise<CSharp
// If the dotnet bundle is installed, this will ensure the dotnet CLI is on the path.
await initializeDotnetPath();

let telemetryObserver = new TelemetryObserver(platformInfo, () => reporter);
let useModernNetOption = optionProvider.GetLatestOptions().useModernNet;
let telemetryObserver = new TelemetryObserver(platformInfo, () => reporter, useModernNetOption);
eventStream.subscribe(telemetryObserver.post);

let networkSettingsProvider = vscodeNetworkSettingsProvider(vscode);
const useFramework = optionProvider.GetLatestOptions().useModernNet !== true;
const useFramework = useModernNetOption !== true;
let installDependencies: IInstallDependencies = async (dependencies: AbsolutePathPackage[]) => downloadAndInstallPackages(dependencies, networkSettingsProvider, eventStream, isValidDownload, useFramework);
let runtimeDependenciesExist = await ensureRuntimeDependencies(context.extension, eventStream, platformInfo, installDependencies, useFramework);

Expand Down
6 changes: 5 additions & 1 deletion src/observers/TelemetryObserver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,12 @@ export class TelemetryObserver {
private platformInfo: PlatformInformation;
private solutionId?: string;
private dotnetInfo?: DotnetInfo;
private useModernNet: boolean;

constructor(platformInfo: PlatformInformation, reporterCreator: () => ITelemetryReporter) {
constructor(platformInfo: PlatformInformation, reporterCreator: () => ITelemetryReporter, useModernNet: boolean) {
this.platformInfo = platformInfo;
this.reporter = reporterCreator();
this.useModernNet = useModernNet;
}

public post = (event: BaseEvent) => {
Expand Down Expand Up @@ -109,6 +111,8 @@ export class TelemetryObserver {
telemetryProps['FileExtensions'] = projectConfig.FileExtensions.join("|");
telemetryProps['FileCounts'] = projectConfig.FileCounts?.join("|") ?? "";
telemetryProps['NetSdkVersion'] = this.dotnetInfo?.Version ?? "";
telemetryProps['useModernNet'] = this.useModernNet.toString();
telemetryProps['sdkStyleProject'] = projectConfig.SdkStyleProject.toString();
this.reporter.sendTelemetryEvent("ProjectConfiguration", telemetryProps);
}

Expand Down
1 change: 1 addition & 0 deletions src/omnisharp/protocol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,7 @@ export interface ProjectConfigurationMessage {
References: string[];
FileExtensions: string[];
FileCounts: number[];
SdkStyleProject: boolean;
}

export interface PackageDependency {
Expand Down
9 changes: 7 additions & 2 deletions test/unitTests/logging/TelemetryObserver.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ suite('TelemetryReporterObserver', () => {
let property: { [key: string]: string } = null;
let measure: { [key: string]: number }[] = [];
let errorProp: string[][] = [];
let useModernNet = true;
let observer = new TelemetryObserver(platformInfo, () => {
return {
...getNullTelemetryReporter,
Expand All @@ -35,7 +36,7 @@ suite('TelemetryReporterObserver', () => {
errorProp.push(errorProps);
},
};
});
}, useModernNet);

setup(() => {
name = "";
Expand Down Expand Up @@ -66,6 +67,7 @@ suite('TelemetryReporterObserver', () => {
const references = ["ref1", "ref2"];
const fileExtensions = [".cs", ".cshtml"];
const fileCounts = [7, 3];
const sdkStyleProject = true;
let event = new ProjectConfiguration({
ProjectCapabilities: projectCapabilities,
TargetFrameworks: targetFrameworks,
Expand All @@ -74,7 +76,8 @@ suite('TelemetryReporterObserver', () => {
OutputKind: outputKind,
References: references,
FileExtensions: fileExtensions,
FileCounts: fileCounts
FileCounts: fileCounts,
SdkStyleProject: sdkStyleProject
});

observer.post(event);
Expand All @@ -86,6 +89,8 @@ suite('TelemetryReporterObserver', () => {
expect(property["References"]).to.be.equal("ref1|ref2");
expect(property["FileExtensions"]).to.be.equal(".cs|.cshtml");
expect(property["FileCounts"]).to.be.equal("7|3");
expect(property["useModernNet"]).to.be.equal("true");
expect(property["sdkStyleProject"]).to.be.equal("true");
});

[
Expand Down