From c93099d4dec63d96eeadf4e90fade3badf84df64 Mon Sep 17 00:00:00 2001 From: pq Date: Wed, 5 Nov 2025 13:42:10 -0800 Subject: [PATCH] [analytics] instrument device selector actions --- .../flutter/actions/DeviceSelectorAction.java | 41 ++++++++++++++++--- .../DeviceSelectorRefresherAction.java | 9 ++-- 2 files changed, 41 insertions(+), 9 deletions(-) diff --git a/src/io/flutter/actions/DeviceSelectorAction.java b/src/io/flutter/actions/DeviceSelectorAction.java index 074fb50ef3..594fef85ce 100644 --- a/src/io/flutter/actions/DeviceSelectorAction.java +++ b/src/io/flutter/actions/DeviceSelectorAction.java @@ -8,7 +8,16 @@ import com.intellij.icons.AllIcons; import com.intellij.ide.ActivityTracker; import com.intellij.ide.DataManager; -import com.intellij.openapi.actionSystem.*; +import com.intellij.openapi.actionSystem.ActionUpdateThread; +import com.intellij.openapi.actionSystem.AnAction; +import com.intellij.openapi.actionSystem.AnActionEvent; +import com.intellij.openapi.actionSystem.CommonDataKeys; +import com.intellij.openapi.actionSystem.DataContext; +import com.intellij.openapi.actionSystem.DataKey; +import com.intellij.openapi.actionSystem.DefaultActionGroup; +import com.intellij.openapi.actionSystem.PlatformCoreDataKeys; +import com.intellij.openapi.actionSystem.Presentation; +import com.intellij.openapi.actionSystem.Separator; import com.intellij.openapi.actionSystem.ex.CustomComponentAction; import com.intellij.openapi.application.Application; import com.intellij.openapi.application.ApplicationManager; @@ -31,6 +40,8 @@ import com.intellij.util.ui.UIUtil; import icons.FlutterIcons; import io.flutter.FlutterBundle; +import io.flutter.analytics.Analytics; +import io.flutter.analytics.AnalyticsData; import io.flutter.logging.PluginLogger; import io.flutter.run.FlutterDevice; import io.flutter.run.daemon.DeviceService; @@ -39,12 +50,28 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import javax.swing.*; -import java.awt.*; +import javax.swing.ButtonModel; +import javax.swing.Icon; +import javax.swing.JButton; +import javax.swing.JComponent; +import javax.swing.JPanel; +import javax.swing.SwingUtilities; +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Component; +import java.awt.Container; +import java.awt.Dimension; +import java.awt.FontMetrics; +import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.RenderingHints; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; -import java.util.*; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; import java.util.List; +import java.util.Objects; public class DeviceSelectorAction extends AnAction implements CustomComponentAction, DumbAware { private static final @NotNull Logger LOG = PluginLogger.createLogger(DeviceSelectorAction.class); @@ -89,7 +116,7 @@ public class DeviceSelectorAction extends AnAction implements CustomComponentAct *

* * @return A {@link Color} suitable for toolbar text that adapts to the current theme, - * including configurations like light themes with dark headers. + * including configurations like light themes with dark headers. */ @NotNull Color getToolbarForegroundColor() { return JBColor.namedColor(TOOLBAR_FOREGROUND_KEY, UIUtil.getLabelForeground()); @@ -105,7 +132,7 @@ public class DeviceSelectorAction extends AnAction implements CustomComponentAct *

* * @return A {@link Color} suitable for toolbar icon button hover states that adapts to the - * current theme, ensuring consistency with other toolbar actions. + * current theme, ensuring consistency with other toolbar actions. */ @NotNull Color getToolbarHoverBackgroundColor() { return JBColor.namedColor(TOOLBAR_ICON_HOVER_BACKGROUND_KEY, JBUI.CurrentTheme.ActionButton.hoverBackground()); @@ -122,6 +149,8 @@ public void actionPerformed(@NotNull AnActionEvent e) { return; } + Analytics.report(AnalyticsData.forAction(this, e)); + final DefaultActionGroup group = new DefaultActionGroup(); group.addAll(actions); diff --git a/src/io/flutter/actions/DeviceSelectorRefresherAction.java b/src/io/flutter/actions/DeviceSelectorRefresherAction.java index 40e856ea84..0f63c674cc 100644 --- a/src/io/flutter/actions/DeviceSelectorRefresherAction.java +++ b/src/io/flutter/actions/DeviceSelectorRefresherAction.java @@ -9,6 +9,8 @@ import com.intellij.openapi.actionSystem.AnAction; import com.intellij.openapi.actionSystem.AnActionEvent; import com.intellij.openapi.project.Project; +import io.flutter.analytics.Analytics; +import io.flutter.analytics.AnalyticsData; import io.flutter.run.daemon.DeviceService; import io.flutter.utils.FlutterModuleUtils; import org.jetbrains.annotations.NotNull; @@ -17,9 +19,10 @@ public class DeviceSelectorRefresherAction extends AnAction { @Override public void actionPerformed(@NotNull AnActionEvent e) { final Project project = e.getProject(); - if (project != null) { - DeviceService.getInstance(project).restart(); - } + if (project == null) return; + + Analytics.report(AnalyticsData.forAction(this, e)); + DeviceService.getInstance(project).restart(); } public @NotNull ActionUpdateThread getActionUpdateThread() {