Skip to content

Commit

Permalink
Use the new Ecosystem Usage Reporter (#428)
Browse files Browse the repository at this point in the history
  • Loading branch information
talarian1 authored Oct 10, 2023
1 parent bd1a42f commit 407ac5f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ repositories {
}

def buildInfoVersion = '2.41.6'
def idePluginsCommonVersion = '2.2.x-20231003.090427-2'
def idePluginsCommonVersion = '2.2.x-20231010.092858-3'

dependencies {
implementation group: 'com.fasterxml.jackson.dataformat', name: 'jackson-dataformat-yaml', version: '2.15.2'
Expand Down
11 changes: 7 additions & 4 deletions src/main/java/com/jfrog/ide/idea/utils/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,18 @@
import com.intellij.openapi.project.Project;
import com.intellij.openapi.wm.ToolWindow;
import com.intellij.openapi.wm.ToolWindowManager;
import com.jfrog.ide.common.utils.usage.EcosystemUsageReporter;
import com.jfrog.ide.common.utils.usage.UsageReport;
import com.jfrog.ide.idea.configuration.GlobalSettings;
import com.jfrog.ide.idea.configuration.ServerConfigImpl;
import com.jfrog.ide.idea.log.Logger;
import org.apache.commons.codec.digest.DigestUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.exception.ExceptionUtils;
import org.jfrog.build.extractor.scan.DependencyTree;
import org.jfrog.build.extractor.scan.GeneralInfo;
import org.jfrog.build.extractor.usageReport.ClientIdUsageReporter;
import org.jfrog.build.extractor.usageReport.UsageReporter;

import java.io.IOException;
import java.net.MalformedURLException;
Expand All @@ -29,7 +31,6 @@
import java.util.Collections;

import static com.jfrog.ide.common.utils.Utils.createSSLContext;

import static com.jfrog.ide.common.utils.Utils.resolveArtifactoryUrl;

/**
Expand Down Expand Up @@ -75,10 +76,12 @@ public static void sendUsageReport(String techName) {
return;
}
String pluginVersion = jfrogPlugin.getVersion();
UsageReporter usageReporter = new ClientIdUsageReporter(PRODUCT_ID + pluginVersion, featureIdArray, log);
ClientIdUsageReporter artifactoryUsageReporter = new ClientIdUsageReporter(PRODUCT_ID + pluginVersion, featureIdArray, log);
EcosystemUsageReporter ecosystemUsageReporter = new EcosystemUsageReporter(log);
String artifactoryUrl = resolveArtifactoryUrl(serverConfig.getArtifactoryUrl(), serverConfig.getUrl());
try {
usageReporter.reportUsage(artifactoryUrl, serverConfig.getUsername(), serverConfig.getPassword(), serverConfig.getAccessToken(), serverConfig.getProxyConfForTargetUrl(artifactoryUrl), createSSLContext(serverConfig), log);
artifactoryUsageReporter.reportUsage(artifactoryUrl, serverConfig.getUsername(), serverConfig.getPassword(), serverConfig.getAccessToken(), serverConfig.getProxyConfForTargetUrl(artifactoryUrl), createSSLContext(serverConfig), log);
ecosystemUsageReporter.reportUsage(new UsageReport(PRODUCT_ID + pluginVersion, new String(DigestUtils.md5(serverConfig.getXrayUrl())), artifactoryUsageReporter.getUniqueClientId(), featureIdArray), createSSLContext(serverConfig));
} catch (IOException | RuntimeException | NoSuchAlgorithmException | KeyStoreException |
KeyManagementException e) {
log.debug("Usage report failed: " + ExceptionUtils.getRootCauseMessage(e));
Expand Down

0 comments on commit 407ac5f

Please sign in to comment.