Skip to content

Commit 88a085a

Browse files
committed
Remove dependency for azuretools-core and better naming
1 parent 06b35be commit 88a085a

File tree

5 files changed

+25
-20
lines changed

5 files changed

+25
-20
lines changed

PluginsAndFeatures/azure-toolkit-for-intellij/azure-sdk-reference-book/build.gradle

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,6 @@ dependencies {
2929
implementation 'com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:2.11.2', {
3030
exclude group: "com.fasterxml.jackson", module: "jackson-bom"
3131
}
32-
compile 'com.microsoft.azuretools:azuretools-core:3.51.0-SNAPSHOT', {
33-
exclude group: "com.microsoft.azure", module: "azure-client-authentication"
34-
exclude group: "com.microsoft.azure", module: "azure-client-runtime"
35-
exclude group: "javax.xml.bind", module: "jaxb-api"
36-
}
3732
compile project(':azure-intellij-plugin-lib')
3833
compile "com.microsoft.azure:azure-toolkit-common-lib:0.5.0-SNAPSHOT"
3934

PluginsAndFeatures/azure-toolkit-for-intellij/azure-sdk-reference-book/src/main/java/com/microsoft/azure/toolkit/intellij/azuresdk/dependencesurvey/activity/WorkspaceTaggingActivity.java

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,24 @@
1010
import com.intellij.openapi.roots.OrderEnumerator;
1111
import com.intellij.openapi.startup.StartupActivity;
1212
import com.microsoft.azure.toolkit.intellij.azuresdk.service.WorkspaceTaggingService;
13-
import com.microsoft.azuretools.telemetry.TelemetryConstants;
14-
import com.microsoft.azuretools.telemetrywrapper.EventType;
15-
import com.microsoft.azuretools.telemetrywrapper.EventUtil;
13+
import com.microsoft.azure.toolkit.lib.common.telemetry.AzureTelemeter;
14+
import com.microsoft.azure.toolkit.lib.common.telemetry.Telemetry;
1615
import org.apache.commons.lang.StringUtils;
1716
import org.jetbrains.annotations.NotNull;
1817

18+
import java.util.HashMap;
1919
import java.util.Map;
2020
import java.util.Set;
2121
import java.util.regex.Matcher;
2222
import java.util.regex.Pattern;
23-
import java.util.stream.Collectors;
2423

2524
public class WorkspaceTaggingActivity implements StartupActivity.DumbAware {
2625
private static final Pattern PATTERN = Pattern.compile("(Gradle|Maven): (.*):(.*):(.*)");
26+
private static final String WORKSPACE_TAGGING = "workspace-tagging";
27+
private static final String OPERATION_NAME = "operationName";
28+
private static final String SERVICE_NAME = "serviceName";
29+
private static final String SYSTEM = "system";
30+
private static final String TAG = "tag";
2731

2832
@Override
2933
public void runActivity(@NotNull final Project project) {
@@ -43,7 +47,14 @@ private void trackProjectDependencies(@NotNull final Project project) {
4347
}
4448
return true;
4549
});
46-
final Map<String, String> properties = tagSet.stream().collect(Collectors.toMap(tag -> tag, tag -> "true"));
47-
EventUtil.logEvent(EventType.info, TelemetryConstants.SYSTEM, TelemetryConstants.WORKSPACE_TAGGING, properties);
50+
sendWorkspaceTaggingTelemetry(tagSet);
51+
}
52+
53+
private void sendWorkspaceTaggingTelemetry(final Set<String> tagSet) {
54+
final Map<String, String> properties = new HashMap<>();
55+
properties.put(SERVICE_NAME, SYSTEM);
56+
properties.put(OPERATION_NAME, WORKSPACE_TAGGING);
57+
properties.put(TAG, StringUtils.join(tagSet, ","));
58+
AzureTelemeter.log(Telemetry.Type.INFO, properties);
4859
}
4960
}

PluginsAndFeatures/azure-toolkit-for-intellij/azure-sdk-reference-book/src/main/java/com/microsoft/azure/toolkit/intellij/azuresdk/service/WorkspaceTaggingService.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,12 @@ public static String getWorkspaceTag(String groupId, final String artifactId) {
3737
if (StringUtils.isAnyEmpty(groupId, artifactId)) {
3838
return null;
3939
}
40-
return ObjectUtils.firstNonNull(getAzureArtifactTag(groupId, artifactId), getDependencyTag(groupId, artifactId));
40+
return ObjectUtils.firstNonNull(getAzureDependencyTag(groupId, artifactId), getExternalDependencyTag(groupId, artifactId));
4141
}
4242

43-
private static String getAzureArtifactTag(final String groupId, final String artifactId) {
43+
private static String getAzureDependencyTag(final String groupId, final String artifactId) {
4444
try {
45-
return getAzureSDKArtifacts()
45+
return getAzureSDKEntities()
4646
.stream()
4747
.filter(entity -> StringUtils.isNotEmpty(entity.getType())
4848
&& StringUtils.equalsIgnoreCase(entity.getGroupId(), groupId)
@@ -55,12 +55,12 @@ private static String getAzureArtifactTag(final String groupId, final String art
5555
}
5656
}
5757

58-
private static String getDependencyTag(final String groupId, final String artifactId) {
58+
private static String getExternalDependencyTag(final String groupId, final String artifactId) {
5959
try {
6060
return getWorkspaceTagEntities()
6161
.stream()
62-
.filter(entity -> (StringUtils.equalsIgnoreCase(entity.getGroupId(), groupId) || entity.getGroupId().matches(groupId))
63-
&& (StringUtils.equalsIgnoreCase(entity.getArtifactId(), artifactId) || entity.getArtifactId().matches(artifactId)))
62+
.filter(entity -> (StringUtils.isEmpty(entity.getGroupId()) || StringUtils.equalsIgnoreCase(entity.getGroupId(), groupId))
63+
&& (StringUtils.isEmpty(entity.getArtifactId()) || StringUtils.equalsIgnoreCase(entity.getArtifactId(), artifactId)))
6464
.map(WorkspaceTagEntity::getTag)
6565
.findFirst().orElse(null);
6666
} catch (IOException e) {
@@ -80,7 +80,7 @@ public static List<WorkspaceTagEntity> getWorkspaceTagEntities(boolean... force)
8080

8181
@Preload
8282
@Cacheable(value = "workspace-tag-azure", condition = "!(force&&force[0])")
83-
public static List<AzureJavaSdkEntity> getAzureSDKArtifacts(boolean... force) throws IOException {
83+
public static List<AzureJavaSdkEntity> getAzureSDKEntities(boolean... force) throws IOException {
8484
final URL destination = new URL(SDK_METADATA_URL);
8585
final CsvSchema schema = CsvSchema.emptySchema().withHeader();
8686
final MappingIterator<AzureJavaSdkEntity> mappingIterator = CSV_MAPPER.readerFor(AzureJavaSdkEntity.class).with(schema).readValues(destination);

PluginsAndFeatures/azure-toolkit-for-intellij/azure-sdk-reference-book/src/main/resources/workspaceTag.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
{ "groupId": "org.redisson", "artifactId": "redisson", "tag": "redis" },
2121
{ "groupId": "io.lettuce", "artifactId": "lettuce-core", "tag": "redis" },
2222
// spring boot
23-
{ "groupId": "org.springframework.boot", "artifactId": ".*", "tag": "springboot" },
23+
{ "groupId": "org.springframework.boot", "artifactId": "", "tag": "springboot" },
2424
// sql
2525
{ "groupId": "org.jooq", "artifactId": "jooq", "tag": "sql" },
2626
{ "groupId": "org.mybatis", "artifactId": "mybatis", "tag": "sql" },

Utils/azuretools-core/src/com/microsoft/azuretools/telemetry/TelemetryConstants.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,6 @@ public class TelemetryConstants {
181181
public static final String UPDATE_A_CLUSTER = "update-a-cluster";
182182
public static final String SHOW_WHATS_NEW = "show-whats-new";
183183
public static final String UNHANDLED_EXCEPTION = "unhandled-exception";
184-
public static final String WORKSPACE_TAGGING = "workspace-tagging";
185184
// property name
186185
public static final String WEBAPP_DEPLOY_TO_SLOT = "webappDeployToSlot";
187186
public static final String RUNTIME = "runtime";

0 commit comments

Comments
 (0)