Skip to content

Commit 15925e4

Browse files
committed
Merge branch 'develop' into telemetry/tag
2 parents 19ba086 + 174d494 commit 15925e4

File tree

19 files changed

+132
-63
lines changed

19 files changed

+132
-63
lines changed

PluginsAndFeatures/azure-toolkit-for-intellij/src/com/microsoft/azure/toolkit/intellij/appservice/AppConfigDialog.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
import com.microsoft.azure.toolkit.intellij.common.AzureFormPanel;
1111
import com.microsoft.azure.toolkit.lib.appservice.AppServiceConfig;
1212
import com.microsoft.azure.toolkit.lib.common.form.AzureForm;
13+
import com.microsoft.azure.toolkit.lib.common.operation.AzureOperation;
14+
import com.microsoft.azuretools.ActionConstants;
1315
import lombok.extern.java.Log;
1416

1517
import javax.swing.*;
@@ -36,6 +38,8 @@ public T getData() {
3638
return this.getForm().getData();
3739
}
3840

41+
42+
@AzureOperation(name = "appservice.toggle", type = AzureOperation.Type.TASK)
3943
protected void toggleAdvancedMode(boolean advancedMode) {
4044
this.advancedMode = advancedMode;
4145
final AzureFormPanel<T> previousForm = advancedMode ? this.getBasicFormPanel() : this.getAdvancedFormPanel();

PluginsAndFeatures/azure-toolkit-for-intellij/src/com/microsoft/azure/toolkit/intellij/function/action/CreateFunctionAction.java

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,25 +29,28 @@
2929
import com.microsoft.azure.management.Azure;
3030
import com.microsoft.azure.management.eventhub.EventHubNamespace;
3131
import com.microsoft.azure.management.eventhub.EventHubNamespaceAuthorizationRule;
32+
import com.microsoft.azure.toolkit.intellij.function.AzureFunctionsUtils;
3233
import com.microsoft.azure.toolkit.intellij.function.CreateFunctionForm;
33-
import com.microsoft.azure.toolkit.lib.common.exception.AzureToolkitRuntimeException;
34+
import com.microsoft.azure.toolkit.intellij.function.runner.AzureFunctionSupportConfigurationType;
3435
import com.microsoft.azure.toolkit.lib.common.exception.AzureExceptionHandler;
36+
import com.microsoft.azure.toolkit.lib.common.exception.AzureToolkitRuntimeException;
3537
import com.microsoft.azure.toolkit.lib.common.task.AzureTaskManager;
3638
import com.microsoft.azuretools.authmanage.AuthMethodManager;
3739
import com.microsoft.azuretools.telemetry.TelemetryConstants;
38-
import com.microsoft.azuretools.telemetrywrapper.*;
39-
import com.microsoft.azure.toolkit.intellij.function.runner.AzureFunctionSupportConfigurationType;
40-
import com.microsoft.azure.toolkit.intellij.function.AzureFunctionsUtils;
40+
import com.microsoft.azuretools.telemetrywrapper.ErrorType;
41+
import com.microsoft.azuretools.telemetrywrapper.EventUtil;
42+
import com.microsoft.azuretools.telemetrywrapper.Operation;
43+
import com.microsoft.azuretools.telemetrywrapper.TelemetryManager;
4144
import org.apache.commons.lang3.StringUtils;
4245
import org.jetbrains.annotations.NotNull;
4346
import org.jetbrains.jps.model.java.JavaModuleSourceRootTypes;
4447

4548
import java.io.File;
4649
import java.io.IOException;
47-
import java.util.*;
50+
import java.util.ArrayList;
51+
import java.util.List;
52+
import java.util.Map;
4853

49-
import static com.microsoft.azuretools.telemetry.TelemetryConstants.CREATE_FUNCTION_TRIGGER;
50-
import static com.microsoft.azuretools.telemetry.TelemetryConstants.FUNCTION;
5154
import static com.microsoft.intellij.ui.messages.AzureBundle.message;
5255

5356
public class CreateFunctionAction extends CreateElementActionBase {
@@ -82,7 +85,7 @@ protected PsiElement[] invokeDialog(Project project, PsiDirectory psiDirectory)
8285
PsiDirectory directory = ClassUtil.sourceRoot(psiDirectory);
8386
String newName = packageName.replace('.', '/');
8487
bindingTemplate = AzureFunctionsUtils.getFunctionTemplate(triggerType);
85-
operation.trackProperty("triggerType", triggerType);
88+
operation.trackProperty(TelemetryConstants.TRIGGER_TYPE, triggerType);
8689
if (StringUtils.equalsIgnoreCase(triggerType, CreateFunctionForm.EVENT_HUB_TRIGGER)) {
8790
if (StringUtils.isBlank(connectionName)) {
8891
throw new AzureExecutionException(message("function.createFunction.error.connectionMissed"));

PluginsAndFeatures/azure-toolkit-for-intellij/src/com/microsoft/azure/toolkit/intellij/function/runner/component/table/AppSettingsTableUtils.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import com.intellij.ui.ToolbarDecorator;
1414
import com.intellij.uiDesigner.core.GridConstraints;
1515
import com.intellij.uiDesigner.core.GridLayoutManager;
16+
import com.microsoft.azure.toolkit.lib.common.operation.AzureOperation;
1617
import com.microsoft.azuretools.utils.JsonUtils;
1718
import com.microsoft.azure.toolkit.intellij.function.runner.AzureFunctionsConstants;
1819
import com.microsoft.intellij.util.PluginUtil;
@@ -86,6 +87,7 @@ public void actionPerformed(AnActionEvent anActionEvent) {
8687

8788
final AnActionButton importButton = new AnActionButton(message("common.import"), AllIcons.ToolbarDecorator.Import) {
8889
@Override
90+
@AzureOperation(name = "function.import_app_settings", type = AzureOperation.Type.TASK)
8991
public void actionPerformed(AnActionEvent anActionEvent) {
9092
final ImportAppSettingsDialog importAppSettingsDialog = new ImportAppSettingsDialog(appSettingsTable.getLocalSettingsPath());
9193
importAppSettingsDialog.addWindowListener(new WindowAdapter() {

PluginsAndFeatures/azure-toolkit-for-intellij/src/com/microsoft/azure/toolkit/intellij/function/runner/core/FunctionUtils.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
import java.nio.file.Path;
5252
import java.nio.file.Paths;
5353
import java.util.*;
54+
import java.util.stream.Collectors;
5455

5556
import static com.microsoft.intellij.ui.messages.AzureBundle.message;
5657

@@ -285,6 +286,14 @@ public static String getFuncPath() throws IOException, InterruptedException {
285286
return FunctionCliResolver.resolveFunc();
286287
}
287288

289+
public static List<String> getFunctionBindingList(Map<String, FunctionConfiguration> configMap) {
290+
return configMap.values().stream().flatMap(configuration -> configuration.getBindings().stream())
291+
.map(Binding::getType)
292+
.sorted()
293+
.distinct()
294+
.collect(Collectors.toList());
295+
}
296+
288297
private static void writeFunctionJsonFile(File file, FunctionConfiguration config) throws IOException {
289298
final Map<String, Object> json = new LinkedHashMap<>();
290299
json.put("scriptFile", config.getScriptFile());

PluginsAndFeatures/azure-toolkit-for-intellij/src/com/microsoft/azure/toolkit/intellij/function/runner/deploy/FunctionDeploymentState.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import com.intellij.openapi.project.Project;
99
import com.intellij.psi.PsiMethod;
1010
import com.microsoft.azure.common.exceptions.AzureExecutionException;
11+
import com.microsoft.azure.common.function.configurations.FunctionConfiguration;
1112
import com.microsoft.azure.common.utils.AppServiceUtils;
1213
import com.microsoft.azure.management.appservice.AppServicePlan;
1314
import com.microsoft.azure.management.appservice.FunctionApp;
@@ -26,6 +27,7 @@
2627
import com.microsoft.azuretools.utils.AzureUIRefreshCore;
2728
import com.microsoft.azuretools.utils.AzureUIRefreshEvent;
2829
import com.microsoft.intellij.RunProcessHandler;
30+
import org.apache.commons.lang.StringUtils;
2931
import org.jetbrains.annotations.NotNull;
3032
import org.jetbrains.annotations.Nullable;
3133

@@ -70,7 +72,7 @@ public WebAppBase executeSteps(@NotNull RunProcessHandler processHandler, @NotNu
7072
// Deploy function to Azure
7173
stagingFolder = FunctionUtils.getTempStagingFolder();
7274
deployModel.setDeploymentStagingDirectoryPath(stagingFolder.getPath());
73-
prepareStagingFolder(stagingFolder, processHandler);
75+
prepareStagingFolder(stagingFolder, processHandler, operation);
7476
final DeployFunctionHandler deployFunctionHandler = new DeployFunctionHandler(deployModel, message -> {
7577
if (processHandler.isProcessRunning()) {
7678
processHandler.setText(message);
@@ -101,13 +103,17 @@ private FunctionApp createFunctionApp(@NotNull RunProcessHandler processHandler,
101103
params = {"stagingFolder.getName()", "this.deployModel.getAppName()"},
102104
type = AzureOperation.Type.TASK
103105
)
104-
private void prepareStagingFolder(File stagingFolder, RunProcessHandler processHandler) {
106+
private void prepareStagingFolder(File stagingFolder,
107+
RunProcessHandler processHandler,
108+
final @NotNull Operation operation) {
105109
AzureTaskManager.getInstance().read(() -> {
106110
final Path hostJsonPath = FunctionUtils.getDefaultHostJson(project);
107111
final PsiMethod[] methods = FunctionUtils.findFunctionsByAnnotation(functionDeployConfiguration.getModule());
108112
final Path folder = stagingFolder.toPath();
109113
try {
110-
FunctionUtils.prepareStagingFolder(folder, hostJsonPath, functionDeployConfiguration.getModule(), methods);
114+
final Map<String, FunctionConfiguration> configMap =
115+
FunctionUtils.prepareStagingFolder(folder, hostJsonPath, functionDeployConfiguration.getModule(), methods);
116+
operation.trackProperty(TelemetryConstants.TRIGGER_TYPE, StringUtils.join(FunctionUtils.getFunctionBindingList(configMap), ","));
111117
} catch (final AzureExecutionException | IOException e) {
112118
final String error = String.format("failed prepare staging folder[%s]", folder);
113119
throw new AzureToolkitRuntimeException(error, e);

PluginsAndFeatures/azure-toolkit-for-intellij/src/com/microsoft/azure/toolkit/intellij/function/runner/localrun/FunctionRunState.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ protected FunctionApp executeSteps(@NotNull RunProcessHandler processHandler, @N
116116
validateFunctionRuntime(processHandler);
117117
stagingFolder = FunctionUtils.getTempStagingFolder();
118118
addProcessTerminatedListener(processHandler);
119-
prepareStagingFolder(stagingFolder, processHandler);
119+
prepareStagingFolder(stagingFolder, processHandler, operation);
120120
// Run Function Host
121121
runFunctionCli(processHandler, stagingFolder);
122122
return null;
@@ -269,7 +269,9 @@ private ProcessBuilder getRunFunctionCliExtensionInstallProcessBuilder(File stag
269269
params = {"stagingFolder.getName()", "this.functionRunConfiguration.getFuncPath()"},
270270
type = AzureOperation.Type.SERVICE
271271
)
272-
private void prepareStagingFolder(File stagingFolder, RunProcessHandler processHandler) throws Exception {
272+
private void prepareStagingFolder(File stagingFolder,
273+
RunProcessHandler processHandler,
274+
final @NotNull Operation operation) throws Exception {
273275
AzureTaskManager.getInstance().read(() -> {
274276
final Path hostJsonPath = FunctionUtils.getDefaultHostJson(project);
275277
final Path localSettingsJson = Paths.get(functionRunConfiguration.getLocalSettingsJsonPath());
@@ -278,6 +280,7 @@ private void prepareStagingFolder(File stagingFolder, RunProcessHandler processH
278280
try {
279281
Map<String, FunctionConfiguration> configMap =
280282
FunctionUtils.prepareStagingFolder(folder, hostJsonPath, functionRunConfiguration.getModule(), methods);
283+
operation.trackProperty(TelemetryConstants.TRIGGER_TYPE, StringUtils.join(FunctionUtils.getFunctionBindingList(configMap), ","));
281284
final Map<String, String> appSettings = FunctionUtils.loadAppSettingsFromSecurityStorage(functionRunConfiguration.getAppSettingsKey());
282285
FunctionUtils.copyLocalSettingsToStagingFolder(folder, localSettingsJson, appSettings);
283286

PluginsAndFeatures/azure-toolkit-for-intellij/src/com/microsoft/azure/toolkit/intellij/function/wizard/module/FunctionsModuleBuilder.java

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,7 @@
55

66
package com.microsoft.azure.toolkit.intellij.function.wizard.module;
77

8-
import com.intellij.ide.util.projectWizard.JavaModuleBuilder;
9-
import com.intellij.ide.util.projectWizard.ModuleNameLocationSettings;
10-
import com.intellij.ide.util.projectWizard.ModuleWizardStep;
11-
import com.intellij.ide.util.projectWizard.SettingsStep;
12-
import com.intellij.ide.util.projectWizard.WizardContext;
8+
import com.intellij.ide.util.projectWizard.*;
139
import com.intellij.openapi.Disposable;
1410
import com.intellij.openapi.application.ApplicationManager;
1511
import com.intellij.openapi.project.DumbService;
@@ -23,31 +19,26 @@
2319
import com.intellij.openapi.vfs.VirtualFile;
2420
import com.intellij.openapi.vfs.newvfs.RefreshQueue;
2521
import com.intellij.util.DisposeAwareRunnable;
22+
import com.microsoft.azure.toolkit.intellij.function.AzureFunctionsUtils;
23+
import com.microsoft.azure.toolkit.intellij.function.runner.AzureFunctionSupportConfigurationType;
24+
import com.microsoft.azure.toolkit.intellij.function.wizard.AzureFunctionsConstants;
2625
import com.microsoft.azuretools.telemetry.TelemetryConstants;
2726
import com.microsoft.azuretools.telemetrywrapper.ErrorType;
28-
import com.microsoft.azuretools.telemetrywrapper.EventType;
2927
import com.microsoft.azuretools.telemetrywrapper.EventUtil;
3028
import com.microsoft.azuretools.telemetrywrapper.Operation;
3129
import com.microsoft.azuretools.telemetrywrapper.TelemetryManager;
32-
import com.microsoft.azure.toolkit.intellij.function.runner.AzureFunctionSupportConfigurationType;
33-
import com.microsoft.azure.toolkit.intellij.function.AzureFunctionsUtils;
3430
import com.microsoft.intellij.util.PluginUtil;
35-
import com.microsoft.azure.toolkit.intellij.function.wizard.AzureFunctionsConstants;
3631
import org.apache.commons.io.FileUtils;
3732
import org.apache.commons.lang3.StringUtils;
3833
import org.jetbrains.annotations.NotNull;
3934
import org.jetbrains.annotations.Nullable;
4035
import org.jetbrains.idea.maven.project.MavenProjectsManager;
4136

42-
import javax.swing.Icon;
37+
import javax.swing.*;
4338
import java.io.File;
4439
import java.io.IOException;
4540
import java.nio.file.Paths;
4641
import java.util.Collections;
47-
import java.util.HashMap;
48-
49-
import static com.microsoft.azuretools.telemetry.TelemetryConstants.CREATE_FUNCTION_PROJECT;
50-
import static com.microsoft.azuretools.telemetry.TelemetryConstants.FUNCTION;
5142

5243
public class FunctionsModuleBuilder extends JavaModuleBuilder {
5344
private WizardContext wizardContext;
@@ -120,7 +111,7 @@ public void setupRootModel(@NotNull final ModifiableRootModel rootModel) {
120111
final String packageName = wizardContext.getUserData(AzureFunctionsConstants.WIZARD_PACKAGE_NAME_KEY);
121112
final String[] triggers = wizardContext.getUserData(AzureFunctionsConstants.WIZARD_TRIGGERS_KEY);
122113
operation.trackProperty("tool", tool);
123-
operation.trackProperty("triggerType", StringUtils.join(triggers, ","));
114+
operation.trackProperty(TelemetryConstants.TRIGGER_TYPE, StringUtils.join(triggers, ","));
124115
File tempProjectFolder = null;
125116
try {
126117
tempProjectFolder = AzureFunctionsUtils.createFunctionProjectToTempFolder(groupId, artifactId, version, tool);

PluginsAndFeatures/azure-toolkit-for-intellij/src/com/microsoft/azure/toolkit/intellij/link/mysql/MySQLConnectionUtils.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,16 @@
55

66
package com.microsoft.azure.toolkit.intellij.link.mysql;
77

8+
import com.microsoft.azuretools.ActionConstants;
9+
import com.microsoft.azuretools.telemetry.TelemetryConstants;
10+
import com.microsoft.azuretools.telemetrywrapper.EventType;
11+
import com.microsoft.azuretools.telemetrywrapper.EventUtil;
812
import com.mysql.cj.jdbc.ConnectionImpl;
913
import lombok.AllArgsConstructor;
1014
import lombok.Getter;
1115

1216
import java.sql.*;
17+
import java.util.Collections;
1318

1419
public class MySQLConnectionUtils {
1520

@@ -45,6 +50,9 @@ public static ConnectResult connectWithPing(String url, String username, String
4550
} catch (ClassNotFoundException | SQLException exception) {
4651
errorMessage = exception.getMessage();
4752
}
53+
EventUtil.logEvent(EventType.info, ActionConstants.parse(ActionConstants.MySQL.TEST_CONNECTION).getServiceName(),
54+
ActionConstants.parse(ActionConstants.MySQL.TEST_CONNECTION).getOperationName(),
55+
Collections.singletonMap("result", String.valueOf(connected)));
4856
return new ConnectResult(connected, errorMessage, pingCost, serverVersion);
4957
}
5058

PluginsAndFeatures/azure-toolkit-for-intellij/src/com/microsoft/azure/toolkit/intellij/springcloud/deplolyment/SpringCloudDeploymentConfigurationState.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ protected Map<String, String> getTelemetryMap() {
145145
props.put("instanceCount", String.valueOf(config.getAppConfig().getDeployment().getInstanceCount()));
146146
props.put("memory", String.valueOf(config.getAppConfig().getDeployment().getMemoryInGB()));
147147
props.put("cpu", String.valueOf(config.getAppConfig().getDeployment().getCpu()));
148+
props.put("persistentStorage", String.valueOf(config.getAppConfig().getDeployment().getEnablePersistentStorage()));
148149
return props;
149150
}
150151

PluginsAndFeatures/azure-toolkit-for-intellij/src/com/microsoft/azure/toolkit/intellij/webapp/WebAppBasePropertyView.java

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
import javax.swing.ListSelectionModel;
1919
import javax.swing.table.DefaultTableModel;
2020

21+
import com.microsoft.azuretools.telemetry.TelemetryConstants;
22+
import com.microsoft.azuretools.telemetrywrapper.EventUtil;
2123
import org.jetbrains.annotations.NotNull;
2224
import org.jetbrains.annotations.Nullable;
2325

@@ -120,19 +122,21 @@ protected WebAppBasePropertyView(@NotNull Project project, @NotNull String sid,
120122
btnGetPublishFile.addActionListener(new AzureActionListenerWrapper(INSIGHT_NAME, "btnGetPublishFile", null) {
121123
@Override
122124
public void actionPerformedFunc(ActionEvent event) {
123-
FileChooserDescriptor fileChooserDescriptor = new FileChooserDescriptor(
125+
EventUtil.executeWithLog(TelemetryConstants.APP_SERVICE, TelemetryConstants.GET_PUBLISH_FILE, operation -> {
126+
FileChooserDescriptor fileChooserDescriptor = new FileChooserDescriptor(
124127
false /*chooseFiles*/,
125128
true /*chooseFolders*/,
126129
false /*chooseJars*/,
127130
false /*chooseJarsAsFiles*/,
128131
false /*chooseJarContents*/,
129132
false /*chooseMultiple*/
130-
);
131-
fileChooserDescriptor.setTitle(FILE_SELECTOR_TITLE);
132-
final VirtualFile file = FileChooser.chooseFile(fileChooserDescriptor, null, null);
133-
if (file != null) {
134-
presenter.onGetPublishingProfileXmlWithSecrets(sid, resId, slotName, file.getPath());
135-
}
133+
);
134+
fileChooserDescriptor.setTitle(FILE_SELECTOR_TITLE);
135+
final VirtualFile file = FileChooser.chooseFile(fileChooserDescriptor, null, null);
136+
if (file != null) {
137+
presenter.onGetPublishingProfileXmlWithSecrets(sid, resId, slotName, file.getPath());
138+
}
139+
});
136140
}
137141
});
138142

@@ -151,8 +155,10 @@ public void actionPerformedFunc(ActionEvent event) {
151155
btnSave.addActionListener(new AzureActionListenerWrapper(INSIGHT_NAME, "btnSave", null) {
152156
@Override
153157
public void actionPerformedFunc(ActionEvent event) {
154-
setBtnEnableStatus(false);
155-
presenter.onUpdateWebAppProperty(sid, resId, slotName, cachedAppSettings, editedAppSettings);
158+
EventUtil.executeWithLog(TelemetryConstants.APP_SERVICE, TelemetryConstants.SAVE_APP_SERVICE, operation -> {
159+
setBtnEnableStatus(false);
160+
presenter.onUpdateWebAppProperty(sid, resId, slotName, cachedAppSettings, editedAppSettings);
161+
});
156162
}
157163
});
158164

0 commit comments

Comments
 (0)