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

fix: Track if the workspace contains android manifest #1440

Merged
merged 2 commits into from
Oct 24, 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
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ public class GradleBuildClient implements BuildClient {
/**
* Client command to send telemetry data to the LS client.
*/
private static final String CLIENT_BUILD_SEND_TELEMETRY = "_java.gradle.buildServer.sendTelemetry";

private final JavaLanguageClient lsClient;

Expand All @@ -68,8 +67,12 @@ public GradleBuildClient() {
@Override
public void onBuildLogMessage(LogMessageParams params) {
MessageType type = params.getType();
String cmd = type == MessageType.LOG ? CLIENT_BUILD_SEND_TELEMETRY : CLIENT_BUILD_LOG_CMD;
this.lsClient.sendNotification(new ExecuteCommandParams(cmd, Arrays.asList(params.getMessage())));
if (type == MessageType.LOG) {
Utils.sendTelemetry(this.lsClient, params.getMessage());
} else {
this.lsClient.sendNotification(new ExecuteCommandParams(CLIENT_BUILD_LOG_CMD,
Arrays.asList(params.getMessage())));
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@
import org.eclipse.jdt.ls.core.internal.managers.BasicFileDetector;
import org.eclipse.jdt.ls.core.internal.managers.DigestStore;
import org.eclipse.jdt.ls.core.internal.preferences.Preferences;

import com.microsoft.java.builder.JavaProblemChecker;
import com.microsoft.gradle.bs.importer.model.BuildServerPreferences;
import com.microsoft.gradle.bs.importer.model.Telemetry;

import ch.epfl.scala.bsp4j.BuildClientCapabilities;
import ch.epfl.scala.bsp4j.BuildTarget;
Expand Down Expand Up @@ -85,6 +85,9 @@ public boolean applies(IProgressMonitor monitor) throws OperationCanceledExcepti
.addExclusions("**/bin");
Collection<java.nio.file.Path> androidDirectories = androidDetector.scan(monitor);
if (!androidDirectories.isEmpty()) {
Telemetry telemetry = new Telemetry("hasAndroidManifest", "true");
Utils.sendTelemetry(JavaLanguageServerPlugin.getProjectsManager().getConnection(),
telemetry);
return false;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@
import org.eclipse.core.runtime.SubMonitor;
import org.eclipse.core.runtime.URIUtil;
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.ls.core.internal.JavaClientConnection.JavaLanguageClient;
import org.eclipse.jdt.ls.core.internal.ProjectUtils;
import org.eclipse.jdt.ls.core.internal.preferences.Preferences;
import org.eclipse.lsp4j.ExecuteCommandParams;

import com.microsoft.gradle.bs.importer.builder.BuildServerBuilder;

Expand Down Expand Up @@ -207,4 +209,9 @@ public static boolean isBuildServerEnabled(Preferences preferences) {
String bspImporterEnabled = getString(preferences.asMap(), JAVA_BUILD_SERVER_GRADLE_ENABLED);
return "on".equalsIgnoreCase(bspImporterEnabled);
}

public static void sendTelemetry(JavaLanguageClient client, Object message) {
client.sendNotification(new ExecuteCommandParams("_java.gradle.buildServer.sendTelemetry",
Arrays.asList(message)));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.microsoft.gradle.bs.importer.model;

public record Telemetry(String kind, Object data) {

}
16 changes: 12 additions & 4 deletions extension/src/bs/BuildServerController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,20 @@
this.logOutputChannel.appendLine(msg);
}
}),
commands.registerCommand(SEND_TELEMETRY_CMD, (jsonString: string) => {
const log = JSON.parse(jsonString);
commands.registerCommand(SEND_TELEMETRY_CMD, (data: string | object) => {
let jsonString: string;
let jsonObj: { [key: string]: any };

Check warning on line 64 in extension/src/bs/BuildServerController.ts

View workflow job for this annotation

GitHub Actions / Build & Analyse

Unexpected any. Specify a different type
if (typeof data === "string") {
jsonObj = JSON.parse(data);
jsonString = data;
} else {
jsonObj = data;
jsonString = JSON.stringify(data);
}
sendInfo("", {
kind: log.kind,
kind: jsonObj.kind,
data: jsonString,
...(log.schemaVersion && { schemaVersion: log.schemaVersion }),
...(jsonObj.schemaVersion && { schemaVersion: jsonObj.schemaVersion }),
});
}),
workspace.onDidChangeConfiguration((e: ConfigurationChangeEvent) => {
Expand Down
Loading