Skip to content

Commit 3b66acd

Browse files
committed
Fix service and operation name for file explorer
1 parent 62d4cb6 commit 3b66acd

File tree

3 files changed

+31
-11
lines changed

3 files changed

+31
-11
lines changed

Utils/azure-explorer-common/src/com/microsoft/tooling/msservices/serviceexplorer/azure/appservice/file/AppServiceFileNode.java

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import com.microsoft.azuretools.telemetry.AppInsightsConstants;
1818
import com.microsoft.azuretools.telemetry.TelemetryConstants;
1919
import com.microsoft.azuretools.telemetry.TelemetryProperties;
20+
import com.microsoft.azuretools.telemetrywrapper.EventUtil;
2021
import com.microsoft.tooling.msservices.components.DefaultLoader;
2122
import com.microsoft.tooling.msservices.serviceexplorer.AzureRefreshableNode;
2223
import com.microsoft.tooling.msservices.serviceexplorer.Node;
@@ -64,17 +65,19 @@ private void download() {
6465
@Override
6566
@AzureOperation(name = "appservice|file.refresh", params = {"this.file.getName()"}, type = AzureOperation.Type.ACTION)
6667
protected void refreshItems() {
67-
if (this.file.getType() != AppServiceFile.Type.DIRECTORY) {
68-
return;
69-
}
70-
this.fileService.getFilesInDirectory(this.file.getPath()).stream()
71-
.map(file -> new AppServiceFileNode(file, this, fileService))
72-
.forEach(this::addChildNode);
68+
executeWithTelemetryWrapper(TelemetryConstants.REFRESH_FILE, () -> {
69+
if (this.file.getType() != AppServiceFile.Type.DIRECTORY) {
70+
return;
71+
}
72+
this.fileService.getFilesInDirectory(this.file.getPath()).stream()
73+
.map(file -> new AppServiceFileNode(file, this, fileService))
74+
.forEach(this::addChildNode);
75+
});
7376
}
7477

7578
@AzureOperation(name = "appservice|file.open", params = {"this.file.getName()"}, type = AzureOperation.Type.ACTION)
7679
private void open(final Object context) {
77-
DefaultLoader.getIdeHelper().openAppServiceFile(this.file, context);
80+
executeWithTelemetryWrapper(TelemetryConstants.OPEN_FILE, () -> DefaultLoader.getIdeHelper().openAppServiceFile(this.file, context));
7881
}
7982

8083
@Override
@@ -116,4 +119,13 @@ public String getServiceName() {
116119
public Map<String, String> toProperties() {
117120
return Collections.singletonMap(AppInsightsConstants.SubscriptionId, Utils.getSubscriptionId(file.getApp().id()));
118121
}
122+
123+
// todo: replace with AzureOperation when custom properties is supported for AzureOperation
124+
private void executeWithTelemetryWrapper(final String operationName, Runnable runnable) {
125+
EventUtil.executeWithLog(getServiceName(), operationName, operation -> {
126+
operation.trackProperty(TelemetryConstants.SUBSCRIPTIONID, Utils.getSubscriptionId(file.getApp().id()));
127+
runnable.run();
128+
});
129+
}
130+
119131
}

Utils/azure-explorer-common/src/com/microsoft/tooling/msservices/serviceexplorer/azure/appservice/file/AppServiceUserFilesRootNode.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import com.microsoft.azuretools.telemetry.AppInsightsConstants;
1616
import com.microsoft.azuretools.telemetry.TelemetryConstants;
1717
import com.microsoft.azuretools.telemetry.TelemetryProperties;
18+
import com.microsoft.azuretools.telemetrywrapper.EventUtil;
1819
import com.microsoft.tooling.msservices.components.DefaultLoader;
1920
import com.microsoft.tooling.msservices.serviceexplorer.AzureRefreshableNode;
2021
import com.microsoft.tooling.msservices.serviceexplorer.Node;
@@ -51,10 +52,13 @@ public void removeNode(final String sid, final String name, Node node) {
5152
@Override
5253
@AzureOperation(name = "appservice|file.list", params = {"this.app.name()"}, type = AzureOperation.Type.ACTION)
5354
protected void refreshItems() {
54-
final AppServiceFileService service = this.getFileService();
55-
service.getFilesInDirectory(getRootPath()).stream()
56-
.map(file -> new AppServiceFileNode(file, this, service))
57-
.forEach(this::addChildNode);
55+
EventUtil.executeWithLog(getServiceName(), TelemetryConstants.LIST_FILE, operation -> {
56+
operation.trackProperty(TelemetryConstants.SUBSCRIPTIONID, subscriptionId);
57+
final AppServiceFileService service = this.getFileService();
58+
service.getFilesInDirectory(getRootPath()).stream()
59+
.map(file -> new AppServiceFileNode(file, this, service))
60+
.forEach(this::addChildNode);
61+
});
5862
}
5963

6064
@NotNull

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,10 @@ public class TelemetryConstants {
185185
public static final String SHOW_WHATS_NEW = "show-whats-new";
186186
public static final String UNHANDLED_EXCEPTION = "unhandled-exception";
187187

188+
public static final String LIST_FILE = "list-file";
189+
public static final String REFRESH_FILE = "refresh-file";
190+
public static final String OPEN_FILE = "open-file";
191+
188192
// property name
189193
public static final String WEBAPP_DEPLOY_TO_SLOT = "webappDeployToSlot";
190194
public static final String RUNTIME = "runtime";

0 commit comments

Comments
 (0)