|
17 | 17 | import com.microsoft.azuretools.telemetry.AppInsightsConstants; |
18 | 18 | import com.microsoft.azuretools.telemetry.TelemetryConstants; |
19 | 19 | import com.microsoft.azuretools.telemetry.TelemetryProperties; |
| 20 | +import com.microsoft.azuretools.telemetrywrapper.EventUtil; |
20 | 21 | import com.microsoft.tooling.msservices.components.DefaultLoader; |
21 | 22 | import com.microsoft.tooling.msservices.serviceexplorer.AzureRefreshableNode; |
22 | 23 | import com.microsoft.tooling.msservices.serviceexplorer.Node; |
@@ -64,17 +65,19 @@ private void download() { |
64 | 65 | @Override |
65 | 66 | @AzureOperation(name = "appservice|file.refresh", params = {"this.file.getName()"}, type = AzureOperation.Type.ACTION) |
66 | 67 | 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 | + }); |
73 | 76 | } |
74 | 77 |
|
75 | 78 | @AzureOperation(name = "appservice|file.open", params = {"this.file.getName()"}, type = AzureOperation.Type.ACTION) |
76 | 79 | private void open(final Object context) { |
77 | | - DefaultLoader.getIdeHelper().openAppServiceFile(this.file, context); |
| 80 | + executeWithTelemetryWrapper(TelemetryConstants.OPEN_FILE, () -> DefaultLoader.getIdeHelper().openAppServiceFile(this.file, context)); |
78 | 81 | } |
79 | 82 |
|
80 | 83 | @Override |
@@ -116,4 +119,13 @@ public String getServiceName() { |
116 | 119 | public Map<String, String> toProperties() { |
117 | 120 | return Collections.singletonMap(AppInsightsConstants.SubscriptionId, Utils.getSubscriptionId(file.getApp().id())); |
118 | 121 | } |
| 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 | + |
119 | 131 | } |
0 commit comments