Skip to content
This repository was archived by the owner on Apr 23, 2025. It is now read-only.

Commit 5b50b2e

Browse files
authored
fix: Add cluster information in telemetry login information (#321)
Fixes #317 Signed-off-by: Jeff MAURY <[email protected]>
1 parent b783e35 commit 5b50b2e

File tree

4 files changed

+33
-2
lines changed

4 files changed

+33
-2
lines changed

USAGE_DATA.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@
88
* action duration time
99
* action error message (in case of exception)
1010
* action specific data if applicable (see details below)
11+
* when connecting to a cluster
12+
* Kubernetes version
13+
* flag for Kubernetes/OpenShift cluster
14+
* OpenShift version
1115
* when plugin is shut down
1216

1317
### Specific data collected

build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,10 @@ dependencies {
6565
compile 'org.apache.commons:commons-compress:1.19'
6666
compile 'org.apache.commons:commons-exec:1.3'
6767
compile 'org.apache.commons:commons-lang3:3.9'
68-
compile 'com.redhat.devtools.intellij:intellij-common:1.1.0'
68+
compile 'com.redhat.devtools.intellij:intellij-common:1.2.0-SNAPSHOT'
6969
testCompile 'org.mockito:mockito-core:2.28.2'
7070
testCompile 'org.easytesting:fest-assert:1.4'
71-
testCompile 'com.redhat.devtools.intellij:intellij-common:1.1.0:test'
71+
testCompile 'com.redhat.devtools.intellij:intellij-common:1.2.0-SNAPSHOT:test'
7272
}
7373

7474
sonarqube {

src/main/java/org/jboss/tools/intellij/openshift/telemetry/TelemetryService.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ public enum TelemetryResult {
2121

2222
public static final String VALUE_ABORTED = "aborted";
2323
public static final String PREFIX_ACTION = "ui-";
24+
public static final String NAME_PREFIX_MISC = "misc-";
2425

2526
public static final String PROP_COMPONENT_SOURCE_TYPE = "component_sourcetype";
2627
public static final String PROP_COMPONENT_KIND = "component_kind";
@@ -31,6 +32,10 @@ public enum TelemetryResult {
3132

3233
public static final String PROP_DEBUG_COMPONENT_LANGUAGE = "debug_component_language";
3334

35+
public static final String KUBERNETES_VERSION = "kubernetes_version";
36+
public static final String IS_OPENSHIFT = "is_openshift";
37+
public static final String OPENSHIFT_VERSION = "openshift_version";
38+
3439
private static TelemetryService instance;
3540

3641
private final Lazy<TelemetryMessageBuilder> builder = new Lazy<>(() -> new TelemetryMessageBuilder(TelemetryService.class.getClassLoader()));

src/main/java/org/jboss/tools/intellij/openshift/utils/odo/OdoCli.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,11 @@
1616
import com.fasterxml.jackson.databind.ObjectMapper;
1717
import com.fasterxml.jackson.databind.deser.std.StdNodeBasedDeserializer;
1818
import com.fasterxml.jackson.databind.module.SimpleModule;
19+
import com.redhat.devtools.intellij.common.kubernetes.ClusterHelper;
20+
import com.redhat.devtools.intellij.common.kubernetes.ClusterInfo;
1921
import com.redhat.devtools.intellij.common.utils.ExecHelper;
2022
import com.redhat.devtools.intellij.common.utils.NetworkUtils;
23+
import com.redhat.devtools.intellij.telemetry.core.service.TelemetryMessageBuilder;
2124
import io.fabric8.kubernetes.api.model.ConfigMap;
2225
import io.fabric8.kubernetes.api.model.LabelSelector;
2326
import io.fabric8.kubernetes.api.model.LabelSelectorBuilder;
@@ -33,6 +36,7 @@
3336
import io.fabric8.servicecatalog.client.ServiceCatalogClient;
3437
import org.apache.commons.lang3.StringUtils;
3538
import org.jboss.tools.intellij.openshift.KubernetesLabels;
39+
import org.jboss.tools.intellij.openshift.telemetry.TelemetryService;
3640
import org.slf4j.Logger;
3741
import org.slf4j.LoggerFactory;
3842

@@ -58,6 +62,9 @@
5862
import static org.jboss.tools.intellij.openshift.Constants.OCP4_CONSOLE_URL_KEY_NAME;
5963
import static org.jboss.tools.intellij.openshift.Constants.PLUGIN_FOLDER;
6064
import static org.jboss.tools.intellij.openshift.KubernetesLabels.NAME_LABEL;
65+
import static org.jboss.tools.intellij.openshift.telemetry.TelemetryService.IS_OPENSHIFT;
66+
import static org.jboss.tools.intellij.openshift.telemetry.TelemetryService.KUBERNETES_VERSION;
67+
import static org.jboss.tools.intellij.openshift.telemetry.TelemetryService.OPENSHIFT_VERSION;
6168

6269
public class OdoCli implements Odo {
6370

@@ -82,8 +89,23 @@ public class OdoCli implements Odo {
8289
} catch (URISyntaxException e) {
8390
this.envVars = Collections.emptyMap();
8491
}
92+
reportTelemetry();
8593
}
8694

95+
private void reportTelemetry() {
96+
TelemetryMessageBuilder.ActionMessage telemetry = TelemetryService.instance().getBuilder().action(TelemetryService.NAME_PREFIX_MISC + "login");
97+
try {
98+
ClusterInfo info = ClusterHelper.getClusterInfo(client);
99+
telemetry.property(KUBERNETES_VERSION, info.getKubernetesVersion());
100+
telemetry.property(IS_OPENSHIFT, Boolean.toString(info.isOpenshift()));
101+
telemetry.property(OPENSHIFT_VERSION, info.getOpenshiftVersion());
102+
telemetry.send();
103+
} catch (RuntimeException e) {
104+
telemetry.error(e).send();
105+
}
106+
}
107+
108+
87109
private ObjectMapper configureObjectMapper(final StdNodeBasedDeserializer<? extends List<?>> deserializer) {
88110
final SimpleModule module = new SimpleModule();
89111
module.addDeserializer(List.class, deserializer);

0 commit comments

Comments
 (0)