diff --git a/.idea/uiDesigner.xml b/.idea/uiDesigner.xml index 27f211eb0..197a4ae12 100644 --- a/.idea/uiDesigner.xml +++ b/.idea/uiDesigner.xml @@ -2,124 +2,124 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + diff --git a/flutter-idea/src/io/flutter/FlutterErrorReportSubmitter.java b/flutter-idea/src/io/flutter/FlutterErrorReportSubmitter.java index 890087550..51a2df74f 100644 --- a/flutter-idea/src/io/flutter/FlutterErrorReportSubmitter.java +++ b/flutter-idea/src/io/flutter/FlutterErrorReportSubmitter.java @@ -180,10 +180,6 @@ public boolean submit(@NotNull IdeaLoggingEvent[] events, builder.append("\n"); } - for (IdeaLoggingEvent event : events) { - FlutterInitializer.getAnalytics().sendException(event.getThrowableText(), false); - } - final String text = builder.toString().trim() + "\n"; // Create scratch file. diff --git a/flutter-idea/src/io/flutter/FlutterInitializer.java b/flutter-idea/src/io/flutter/FlutterInitializer.java index b1c424c4c..e2290b5e7 100644 --- a/flutter-idea/src/io/flutter/FlutterInitializer.java +++ b/flutter-idea/src/io/flutter/FlutterInitializer.java @@ -5,20 +5,15 @@ */ package io.flutter; -import com.google.common.annotations.VisibleForTesting; import com.google.gson.JsonObject; import com.google.gson.JsonPrimitive; import com.intellij.ProjectTopics; -import com.intellij.ide.BrowserUtil; import com.intellij.ide.browsers.BrowserLauncher; -import com.intellij.ide.plugins.IdeaPluginDescriptor; import com.intellij.ide.plugins.PluginManagerCore; import com.intellij.ide.ui.UISettingsListener; -import com.intellij.ide.util.PropertiesComponent; import com.intellij.notification.*; import com.intellij.openapi.actionSystem.AnAction; import com.intellij.openapi.actionSystem.AnActionEvent; -import com.intellij.openapi.application.ApplicationInfo; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.editor.colors.EditorColorsListener; @@ -33,13 +28,8 @@ import com.intellij.openapi.startup.StartupActivity; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.util.messages.MessageBusConnection; -import com.jetbrains.lang.dart.analyzer.DartAnalysisServerService; import com.jetbrains.lang.dart.ide.toolingDaemon.DartToolingDaemonService; import de.roderick.weberknecht.WebSocketException; -import io.flutter.analytics.Analytics; -import io.flutter.analytics.FlutterAnalysisServerListener; -import io.flutter.analytics.ToolWindowTracker; -import io.flutter.analytics.UnifiedAnalytics; import io.flutter.android.IntelliJAndroidSdk; import io.flutter.bazel.WorkspaceCache; import io.flutter.dart.DtdUtils; @@ -67,9 +57,7 @@ import io.flutter.view.FlutterViewFactory; import org.jetbrains.annotations.NotNull; -import javax.swing.event.HyperlinkEvent; import java.util.List; -import java.util.UUID; import java.util.concurrent.ExecutionException; import java.util.concurrent.Executors; import java.util.concurrent.TimeUnit; @@ -84,11 +72,6 @@ */ public class FlutterInitializer implements StartupActivity { private static final Logger LOG = Logger.getInstance(FlutterInitializer.class); - private static final String analyticsClientIdKey = "io.flutter.analytics.clientId"; - private static final String analyticsOptOutKey = "io.flutter.analytics.optOut"; - private static final String analyticsToastShown = "io.flutter.analytics.toastShown"; - - private static Analytics analytics; private boolean toolWindowsInitialized = false; @@ -205,12 +188,6 @@ public void moduleAdded(@NotNull Project project, @NotNull Module module) { final FlutterPluginsLibraryManager libraryManager = new FlutterPluginsLibraryManager(project); libraryManager.startWatching(); - // Initialize the analytics notification group. - NotificationsConfiguration.getNotificationsConfiguration().register( - Analytics.GROUP_DISPLAY_ID, - NotificationDisplayType.STICKY_BALLOON, - false); - // Set our preferred settings for the run console. FlutterConsoleLogManager.initConsolePreferences(); @@ -223,64 +200,18 @@ public void moduleAdded(@NotNull Project project, @NotNull Module module) { checkSdkVersionNotification(project); setUpDtdAnalytics(project); - - // Initialize analytics. - final PropertiesComponent properties = PropertiesComponent.getInstance(); - if (!properties.getBoolean(analyticsToastShown)) { - properties.setValue(analyticsToastShown, true); - - final Notification notification = new Notification( - Analytics.GROUP_DISPLAY_ID, - "Welcome to Flutter!", - FlutterBundle.message("flutter.analytics.notification.content"), - NotificationType.INFORMATION, - (notification1, event) -> { - if (event.getEventType() == HyperlinkEvent.EventType.ACTIVATED) { - if ("url".equals(event.getDescription())) { - BrowserUtil.browse("https://www.google.com/policies/privacy/"); - } - } - }); - boolean finalHasFlutterModule = hasFlutterModule; - //noinspection DialogTitleCapitalization - notification.addAction(new AnAction("Sounds good!") { - @Override - public void actionPerformed(@NotNull AnActionEvent event) { - notification.expire(); - // We only track for flutter projects. - if (finalHasFlutterModule) { - enableAnalytics(project); - } - } - }); - //noinspection DialogTitleCapitalization - notification.addAction(new AnAction("No thanks") { - @Override - public void actionPerformed(@NotNull AnActionEvent event) { - notification.expire(); - setCanReportAnalytics(false); - } - }); - Notifications.Bus.notify(notification, project); - } - else { - // We only track for flutter projects. - if (hasFlutterModule) { - enableAnalytics(project); - } - } } private void setUpDtdAnalytics(Project project) { if (project == null) return; FlutterSdk sdk = FlutterSdk.getFlutterSdk(project); if (sdk == null || !sdk.getVersion().canUseDtd()) return; - Thread t1 = new Thread(() -> { - UnifiedAnalytics unifiedAnalytics = new UnifiedAnalytics(project); - // TODO(helin24): Turn on after adding some unified analytics reporting. + //Thread t1 = new Thread(() -> { + // UnifiedAnalytics unifiedAnalytics = new UnifiedAnalytics(project); + // TODO(helin24): Turn on after adding some unified analytics reporting. //unifiedAnalytics.manageConsent(); - }); - t1.start(); + //}); + //t1.start(); } private void setUpThemeChangeNotifications(@NotNull Project project) { @@ -402,11 +333,6 @@ public void actionPerformed(@NotNull AnActionEvent event) { } } - private static void enableAnalytics(@NotNull Project project) { - ToolWindowTracker.track(project, getAnalytics()); - DartAnalysisServerService.getInstance(project).addAnalysisServerListener(FlutterAnalysisServerListener.getInstance(project)); - } - private void initializeToolWindows(@NotNull Project project) { // Start watching for Flutter debug active events. FlutterViewFactory.init(project); @@ -432,69 +358,4 @@ private void ensureAndroidSdk(@NotNull Project project) { ApplicationManager.getApplication().runWriteAction(() -> wanted.setCurrent(project)); } - - /** - * This method is only used for testing. - */ - @VisibleForTesting - public static void setAnalytics(Analytics inAnalytics) { - analytics = inAnalytics; - } - - @NotNull - public static Analytics getAnalytics() { - if (analytics == null) { - final PropertiesComponent properties = PropertiesComponent.getInstance(); - - String clientId = properties.getValue(analyticsClientIdKey); - if (clientId == null) { - clientId = UUID.randomUUID().toString(); - properties.setValue(analyticsClientIdKey, clientId); - } - - final IdeaPluginDescriptor descriptor = PluginManagerCore.getPlugin(FlutterUtils.getPluginId()); - assert descriptor != null; - final ApplicationInfo info = ApplicationInfo.getInstance(); - analytics = new Analytics(clientId, descriptor.getVersion(), info.getVersionName(), info.getFullVersion()); - - // Set up reporting prefs. - analytics.setCanSend(getCanReportAnalytics()); - - // Send initial loading hit. - analytics.sendScreenView("main"); - - FlutterSettings.getInstance().sendSettingsToAnalytics(analytics); - } - - return analytics; - } - - public static boolean getCanReportAnalytics() { - final PropertiesComponent properties = PropertiesComponent.getInstance(); - return !properties.getBoolean(analyticsOptOutKey, false); - } - - public static void setCanReportAnalytics(boolean canReportAnalytics) { - if (getCanReportAnalytics() != canReportAnalytics) { - final boolean wasReporting = getCanReportAnalytics(); - - final PropertiesComponent properties = PropertiesComponent.getInstance(); - properties.setValue(analyticsOptOutKey, !canReportAnalytics); - if (analytics != null) { - analytics.setCanSend(getCanReportAnalytics()); - } - - if (!wasReporting && canReportAnalytics) { - getAnalytics().sendScreenView("main"); - } - } - } - - public static void sendAnalyticsAction(@NotNull AnAction action) { - sendAnalyticsAction(action.getClass().getSimpleName()); - } - - public static void sendAnalyticsAction(@NotNull String name) { - getAnalytics().sendEvent("intellij", name); - } } diff --git a/flutter-idea/src/io/flutter/ProjectOpenActivity.java b/flutter-idea/src/io/flutter/ProjectOpenActivity.java index a097541c5..77fa64e5a 100644 --- a/flutter-idea/src/io/flutter/ProjectOpenActivity.java +++ b/flutter-idea/src/io/flutter/ProjectOpenActivity.java @@ -18,14 +18,12 @@ import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.extensions.PluginId; import com.intellij.openapi.project.DumbAware; -import com.intellij.openapi.project.DumbService; import com.intellij.openapi.project.Project; import com.intellij.openapi.project.ProjectType; import com.intellij.openapi.project.ProjectTypeService; import com.intellij.openapi.startup.StartupActivity; import com.intellij.openapi.ui.Messages; import icons.FlutterIcons; -import io.flutter.analytics.TimeTracker; import io.flutter.bazel.WorkspaceCache; import io.flutter.jxbrowser.JxBrowserManager; import io.flutter.pub.PubRoot; @@ -50,8 +48,6 @@ public ProjectOpenActivity() { @Override public void runActivity(@NotNull Project project) { - TimeTracker.getInstance(project).onProjectOpen(); - // TODO(helinx): We don't have a good way to check whether a Bazel project is using Flutter. Look into whether we can // build a better Flutter Bazel check into `declaresFlutter` so we don't need the second condition. if (!FlutterModuleUtils.declaresFlutter(project) && !WorkspaceCache.getInstance(project).isBazel()) { @@ -70,16 +66,6 @@ public void runActivity(@NotNull Project project) { return; } - // Report time when indexing finishes. - DumbService.getInstance(project).runWhenSmart(() -> { - FlutterInitializer.getAnalytics().sendEventMetric( - "startup", - "indexingFinished", - project.getService(TimeTracker.class).millisSinceProjectOpen(), - FlutterSdk.getFlutterSdk(project) - ); - }); - ApplicationManager.getApplication().executeOnPooledThread(() -> { sdk.queryFlutterConfig("android-studio-dir", false); }); diff --git a/flutter-idea/src/io/flutter/actions/AttachDebuggerAction.java b/flutter-idea/src/io/flutter/actions/AttachDebuggerAction.java index d338c2bc0..f33c608e8 100644 --- a/flutter-idea/src/io/flutter/actions/AttachDebuggerAction.java +++ b/flutter-idea/src/io/flutter/actions/AttachDebuggerAction.java @@ -21,7 +21,6 @@ import com.intellij.util.ThreeState; import com.intellij.util.messages.MessageBusConnection; import io.flutter.FlutterConstants; -import io.flutter.FlutterInitializer; import io.flutter.bazel.Workspace; import io.flutter.pub.PubRoot; import io.flutter.run.FlutterLaunchMode; @@ -55,8 +54,6 @@ public class AttachDebuggerAction extends FlutterSdkAction { @Override public void startCommand(@NotNull Project project, @NotNull FlutterSdk sdk, @Nullable PubRoot root, @NotNull DataContext context) { // NOTE: When making changes here, consider making similar changes to RunFlutterAction. - FlutterInitializer.sendAnalyticsAction(this); - RunConfiguration configuration = findRunConfig(project); if (configuration == null) { final RunnerAndConfigurationSettings settings = RunManagerEx.getInstanceEx(project).getSelectedConfiguration(); @@ -94,8 +91,6 @@ public void startCommand(@NotNull Project project, @NotNull FlutterSdk sdk, @Nul } public void startCommandInBazelContext(@NotNull Project project, @NotNull Workspace workspace, @NotNull AnActionEvent event) { - FlutterInitializer.sendAnalyticsAction(this); - RunConfiguration configuration = findRunConfig(project); if (configuration == null) { final RunnerAndConfigurationSettings settings = RunManagerEx.getInstanceEx(project).getSelectedConfiguration(); diff --git a/flutter-idea/src/io/flutter/actions/FlutterGettingStartedAction.java b/flutter-idea/src/io/flutter/actions/FlutterGettingStartedAction.java index 42d337b88..818567111 100644 --- a/flutter-idea/src/io/flutter/actions/FlutterGettingStartedAction.java +++ b/flutter-idea/src/io/flutter/actions/FlutterGettingStartedAction.java @@ -9,13 +9,11 @@ import com.intellij.openapi.actionSystem.AnActionEvent; import com.intellij.openapi.project.DumbAwareAction; import io.flutter.FlutterConstants; -import io.flutter.FlutterInitializer; import org.jetbrains.annotations.NotNull; public class FlutterGettingStartedAction extends DumbAwareAction { @Override public void actionPerformed(@NotNull final AnActionEvent e) { - FlutterInitializer.sendAnalyticsAction(this); BrowserLauncher.getInstance().browse(FlutterConstants.URL_GETTING_STARTED_IDE, null); } } diff --git a/flutter-idea/src/io/flutter/actions/FlutterSdkAction.java b/flutter-idea/src/io/flutter/actions/FlutterSdkAction.java index a42394468..527bb8203 100644 --- a/flutter-idea/src/io/flutter/actions/FlutterSdkAction.java +++ b/flutter-idea/src/io/flutter/actions/FlutterSdkAction.java @@ -12,7 +12,6 @@ import com.intellij.openapi.project.DumbAwareAction; import com.intellij.openapi.project.Project; import io.flutter.FlutterBundle; -import io.flutter.FlutterInitializer; import io.flutter.FlutterMessages; import io.flutter.FlutterUtils; import io.flutter.bazel.Workspace; @@ -40,7 +39,6 @@ public void actionPerformed(@NotNull AnActionEvent event) { // See if the Bazel workspace exists for this project. final Workspace workspace = FlutterModuleUtils.getFlutterBazelWorkspace(project); if (workspace != null) { - FlutterInitializer.sendAnalyticsAction(this); FileDocumentManager.getInstance().saveAllDocuments(); startCommandInBazelContext(project, workspace, event); return; @@ -53,7 +51,6 @@ public void actionPerformed(@NotNull AnActionEvent event) { return; } - FlutterInitializer.sendAnalyticsAction(this); FileDocumentManager.getInstance().saveAllDocuments(); PubRoot root = PubRoot.forEventWithRefresh(event); @NotNull DataContext context = event.getDataContext(); diff --git a/flutter-idea/src/io/flutter/actions/FlutterSubmitFeedback.java b/flutter-idea/src/io/flutter/actions/FlutterSubmitFeedback.java index 19c406094..e32e081f4 100644 --- a/flutter-idea/src/io/flutter/actions/FlutterSubmitFeedback.java +++ b/flutter-idea/src/io/flutter/actions/FlutterSubmitFeedback.java @@ -8,14 +8,11 @@ import com.intellij.ide.browsers.BrowserLauncher; import com.intellij.openapi.actionSystem.AnActionEvent; import com.intellij.openapi.project.DumbAwareAction; -import io.flutter.FlutterInitializer; import org.jetbrains.annotations.NotNull; public class FlutterSubmitFeedback extends DumbAwareAction { @Override public void actionPerformed(@NotNull final AnActionEvent e) { - FlutterInitializer.sendAnalyticsAction(this); - final String url = "https://github.com/flutter/flutter-intellij/issues/new"; BrowserLauncher.getInstance().browse(url, null); } diff --git a/flutter-idea/src/io/flutter/actions/ReloadAllFlutterApps.java b/flutter-idea/src/io/flutter/actions/ReloadAllFlutterApps.java index 3ad779038..8b8014a2a 100644 --- a/flutter-idea/src/io/flutter/actions/ReloadAllFlutterApps.java +++ b/flutter-idea/src/io/flutter/actions/ReloadAllFlutterApps.java @@ -12,7 +12,6 @@ import icons.FlutterIcons; import io.flutter.FlutterBundle; import io.flutter.FlutterConstants; -import io.flutter.FlutterInitializer; import io.flutter.run.FlutterReloadManager; import io.flutter.run.daemon.FlutterApp; import org.jetbrains.annotations.NotNull; @@ -38,8 +37,6 @@ public void actionPerformed(@NotNull AnActionEvent e) { if (project == null) { return; } - - FlutterInitializer.sendAnalyticsAction(this); FlutterReloadManager.getInstance(project) .saveAllAndReloadAll(FlutterApp.allFromProjectProcess(project), FlutterConstants.RELOAD_REASON_MANUAL); } diff --git a/flutter-idea/src/io/flutter/actions/ReloadFlutterApp.java b/flutter-idea/src/io/flutter/actions/ReloadFlutterApp.java index 9293742f1..45e992028 100644 --- a/flutter-idea/src/io/flutter/actions/ReloadFlutterApp.java +++ b/flutter-idea/src/io/flutter/actions/ReloadFlutterApp.java @@ -12,7 +12,6 @@ import icons.FlutterIcons; import io.flutter.FlutterBundle; import io.flutter.FlutterConstants; -import io.flutter.FlutterInitializer; import io.flutter.run.FlutterReloadManager; import io.flutter.run.daemon.FlutterApp; import org.jetbrains.annotations.NotNull; @@ -42,12 +41,10 @@ public void actionPerformed(@NotNull AnActionEvent e) { final boolean shouldRestart = (e.getModifiers() & InputEvent.SHIFT_MASK) != 0 && !"GoToAction".equals(e.getPlace()); if (shouldRestart) { - FlutterInitializer.sendAnalyticsAction(RestartFlutterApp.class.getSimpleName()); FlutterReloadManager.getInstance(project).saveAllAndRestart(getApp(), FlutterConstants.RELOAD_REASON_MANUAL); } else { // Else perform a hot reload. - FlutterInitializer.sendAnalyticsAction(this); FlutterReloadManager.getInstance(project).saveAllAndReload(getApp(), FlutterConstants.RELOAD_REASON_MANUAL); } } diff --git a/flutter-idea/src/io/flutter/actions/RestartAllFlutterApps.java b/flutter-idea/src/io/flutter/actions/RestartAllFlutterApps.java index 642f9b47b..e3ffdf1d7 100644 --- a/flutter-idea/src/io/flutter/actions/RestartAllFlutterApps.java +++ b/flutter-idea/src/io/flutter/actions/RestartAllFlutterApps.java @@ -12,7 +12,6 @@ import icons.FlutterIcons; import io.flutter.FlutterBundle; import io.flutter.FlutterConstants; -import io.flutter.FlutterInitializer; import io.flutter.run.FlutterReloadManager; import io.flutter.run.daemon.FlutterApp; import org.jetbrains.annotations.NotNull; @@ -39,7 +38,6 @@ public void actionPerformed(@NotNull AnActionEvent e) { return; } - FlutterInitializer.sendAnalyticsAction(this); FlutterReloadManager.getInstance(project) .saveAllAndRestartAll(FlutterApp.allFromProjectProcess(project), FlutterConstants.RELOAD_REASON_MANUAL); } diff --git a/flutter-idea/src/io/flutter/actions/RestartFlutterApp.java b/flutter-idea/src/io/flutter/actions/RestartFlutterApp.java index 9e88c78e6..3f1fdaa00 100644 --- a/flutter-idea/src/io/flutter/actions/RestartFlutterApp.java +++ b/flutter-idea/src/io/flutter/actions/RestartFlutterApp.java @@ -15,7 +15,6 @@ import icons.FlutterIcons; import io.flutter.FlutterBundle; import io.flutter.FlutterConstants; -import io.flutter.FlutterInitializer; import io.flutter.FlutterMessages; import io.flutter.bazel.WorkspaceCache; import io.flutter.run.FlutterReloadManager; @@ -41,8 +40,6 @@ public void actionPerformed(@NotNull AnActionEvent e) { return; } - FlutterInitializer.sendAnalyticsAction(this); - FlutterReloadManager.getInstance(project).saveAllAndRestart(getApp(), FlutterConstants.RELOAD_REASON_MANUAL); if (WorkspaceCache.getInstance(project).isBazel() && diff --git a/flutter-idea/src/io/flutter/actions/RestartFlutterDaemonAction.java b/flutter-idea/src/io/flutter/actions/RestartFlutterDaemonAction.java index 671eb0120..f352084a0 100644 --- a/flutter-idea/src/io/flutter/actions/RestartFlutterDaemonAction.java +++ b/flutter-idea/src/io/flutter/actions/RestartFlutterDaemonAction.java @@ -9,7 +9,6 @@ import com.intellij.openapi.actionSystem.AnAction; import com.intellij.openapi.actionSystem.AnActionEvent; import com.intellij.openapi.project.Project; -import io.flutter.FlutterInitializer; import io.flutter.run.daemon.DeviceService; import org.jetbrains.annotations.NotNull; @@ -20,8 +19,6 @@ public RestartFlutterDaemonAction() { @Override public void actionPerformed(AnActionEvent event) { - FlutterInitializer.sendAnalyticsAction(this); - final Project project = event.getProject(); if (project == null) { return; diff --git a/flutter-idea/src/io/flutter/actions/RunFlutterAction.java b/flutter-idea/src/io/flutter/actions/RunFlutterAction.java index 95c007001..12c07e1fc 100644 --- a/flutter-idea/src/io/flutter/actions/RunFlutterAction.java +++ b/flutter-idea/src/io/flutter/actions/RunFlutterAction.java @@ -18,7 +18,6 @@ import com.intellij.openapi.actionSystem.AnActionEvent; import com.intellij.openapi.project.Project; import io.flutter.FlutterBundle; -import io.flutter.FlutterInitializer; import io.flutter.run.FlutterLaunchMode; import io.flutter.run.LaunchState; import io.flutter.run.SdkFields; @@ -51,8 +50,6 @@ public RunFlutterAction(@NotNull String text, @Override public void actionPerformed(@NotNull AnActionEvent e) { // NOTE: When making changes here, consider making similar changes to ConnectAndroidDebuggerAction. - FlutterInitializer.sendAnalyticsAction(this); - final RunnerAndConfigurationSettings settings = getRunConfigSettings(e); if (settings == null) { return; diff --git a/flutter-idea/src/io/flutter/analytics/Analytics.java b/flutter-idea/src/io/flutter/analytics/Analytics.java deleted file mode 100644 index 0b711001c..000000000 --- a/flutter-idea/src/io/flutter/analytics/Analytics.java +++ /dev/null @@ -1,335 +0,0 @@ -/* - * Copyright 2016 The Chromium Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ -package io.flutter.analytics; - -import com.intellij.openapi.application.ApplicationManager; -import com.intellij.openapi.diagnostic.Logger; -import com.intellij.openapi.project.Project; -import com.intellij.openapi.project.ProjectManager; -import com.intellij.openapi.util.SystemInfo; -import com.intellij.util.concurrency.QueueProcessor; -import com.jetbrains.lang.dart.sdk.DartSdk; -import io.flutter.bazel.WorkspaceCache; -import io.flutter.sdk.FlutterSdk; -import io.flutter.sdk.FlutterSdkVersion; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -import java.awt.*; -import java.io.IOException; -import java.io.InputStream; -import java.io.UnsupportedEncodingException; -import java.net.HttpURLConnection; -import java.net.URL; -import java.net.URLEncoder; -import java.nio.charset.StandardCharsets; -import java.util.HashMap; -import java.util.Locale; -import java.util.Map; - -/** - * Lightweight Google Analytics integration. - */ -public class Analytics { - public static final String GROUP_DISPLAY_ID = "Flutter Usage Statistics"; - public static final String TIMING_COMPLETE = "timing_complete"; - - private static final String analyticsUrl = "https://www.google-analytics.com/collect"; - private static final String applicationName = "Flutter IntelliJ Plugin"; - private static final String trackingId = "UA-67589403-7"; - - private static final int maxExceptionLength = 512; - - @NotNull - private final String clientId; - @NotNull - private final String pluginVersion; - @NotNull - private final String platformName; - @NotNull - private final String platformVersion; - - @NotNull - private Transport transport = new HttpTransport(); - @NotNull - private ThrottlingBucket bucket = new ThrottlingBucket(20); - private boolean myCanSend = false; - - public Analytics(@NotNull String clientId, @NotNull String pluginVersion, @NotNull String platformName, @NotNull String platformVersion) { - this.clientId = clientId; - this.pluginVersion = pluginVersion; - this.platformName = platformName; - this.platformVersion = platformVersion; - } - - public void disableThrottling(@NotNull Runnable func) { - ThrottlingBucket original = bucket; - try { - bucket = new ThrottlingBucket.NonTrhottlingBucket(0); - func.run(); - } finally { - bucket = original; - } - } - - @NotNull - public String getClientId() { - return clientId; - } - - public boolean canSend() { - return myCanSend; - } - - public void setCanSend(boolean value) { - this.myCanSend = value; - } - - /** - * Public for testing. - */ - public void setTransport(@NotNull Transport transport) { - this.transport = transport; - } - - public void sendScreenView(@NotNull String viewName) { - final Map args = new HashMap<>(); - args.put("cd", viewName); - sendPayload("screenview", args, null); - } - - public void sendEvent(@NotNull String category, @NotNull String action) { - sendEvent(category, action, null); - } - - public void sendEvent(@NotNull String category, @NotNull String action, @Nullable FlutterSdk flutterSdk) { - final Map args = new HashMap<>(); - args.put("ec", category); - args.put("ea", action); - sendPayload("event", args, flutterSdk); - } - - public void sendEventWithSdk(@NotNull String category, @NotNull String action, @NotNull String sdkVersion) { - final Map args = new HashMap<>(); - args.put("ec", category); - args.put("ea", action); - sendPayload("event", args, null, sdkVersion); - } - - public void sendEventMetric(@NotNull String category, @NotNull String action, int value) { - sendEventMetric(category, action, value, null); - } - - public void sendEventMetric(@NotNull String category, @NotNull String action, int value, @Nullable FlutterSdk flutterSdk) { - final Map args = new HashMap<>(); - args.put("ec", category); - args.put("ea", action); - args.put("ev", Integer.toString(value)); - sendPayload("event", args, flutterSdk); - } - - public void sendEvent(@NotNull String category, @NotNull String action, @NotNull String label, @NotNull String value) { - final Map args = new HashMap<>(); - args.put("ec", category); - args.put("ea", action); - if (!label.isEmpty()) { - args.put("el", label); - } - args.put("ev", value); - sendPayload("event", args, null); - } - - public void sendTiming(@NotNull String category, @NotNull String variable, long timeMillis) { - sendEvent(category, TIMING_COMPLETE, variable, Long.toString(timeMillis)); - } - - public void sendExpectedException(@NotNull String location, @NotNull Throwable throwable) { - sendEvent("expected-exception", location + ":" + throwable.getClass().getName()); - } - - public void sendException(@NotNull String throwableText, boolean isFatal) { - String description = throwableText; - description = description.replaceAll("com.intellij.openapi.", "c.i.o."); - description = description.replaceAll("com.intellij.", "c.i."); - if (description.length() > maxExceptionLength) { - description = description.substring(0, maxExceptionLength); - } - - final Map args = new HashMap<>(); - args.put("exd", description); - if (isFatal) { - args.put("'exf'", "1"); - } - sendPayload("exception", args, null); - } - - private void sendPayload(@NotNull String hitType, @NotNull Map args, @Nullable FlutterSdk flutterSdk) { - sendPayload(hitType, args, flutterSdk, null); - } - - private void sendPayload(@NotNull String hitType, - @NotNull Map args, - @Nullable FlutterSdk flutterSdk, - @Nullable String sdkVersion) { - if (!canSend()) { - return; - } - - if (!bucket.removeDrop()) { - return; - } - - args.put("v", "1"); // protocol version - args.put("ds", "app"); // specify an 'app' data source - - args.put("an", applicationName); - args.put("av", pluginVersion); - - args.put("aiid", platformName); // Record the platform name as the application installer ID - args.put("cd1", platformVersion); // Record the Open API version as a custom dimension - - // If the Flutter SDK is provided, send the SDK version in a custom dimension. - if (flutterSdk != null) { - final FlutterSdkVersion flutterVersion = flutterSdk.getVersion(); - if (flutterVersion.getVersionText() != null) { - args.put("cd2", flutterVersion.getVersionText()); - } - } - else if (sdkVersion != null) { - args.put("cd2", sdkVersion); - } - - // Record whether this client uses bazel. - if (anyProjectUsesBazel()) { - args.put("cd3", "bazel"); - } - - args.put("tid", trackingId); - args.put("cid", clientId); - args.put("t", hitType); - - try { - final Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); - args.put("sr", screenSize.width + "x" + screenSize.height); - } - catch (HeadlessException he) { - // ignore this - allow the tests to run when the IDE is headless - } - - final String language = System.getProperty("user.language"); - if (language != null) { - args.put("ul", language); - } - - transport.send(analyticsUrl, args); - } - - /** - * Return true if any open project is a Dart project and uses Bazel. - */ - private boolean anyProjectUsesBazel() { - if (ApplicationManager.getApplication() == null) { - return false; // In unit testing. - } - ProjectManager mgr = ProjectManager.getInstance(); - if (mgr == null) { - return false; // In unit testing. - } - for (Project project : mgr.getOpenProjects()) { - if (project.isDisposed()) { - continue; - } - - if (DartSdk.getDartSdk(project) != null && WorkspaceCache.getInstance(project).isBazel()) { - return true; - } - } - - return false; - } - - public interface Transport { - void send(@NotNull String url, @NotNull Map values); - } - - private static class HttpTransport implements Transport { - private final QueueProcessor sendingQueue = QueueProcessor.createRunnableQueueProcessor(); - - @Nullable - private static String createUserAgent() { - final String locale = Locale.getDefault().toString(); - - if (SystemInfo.isWindows) { - return "Mozilla/5.0 (Windows; Windows; Windows; " + locale + ")"; - } - else if (SystemInfo.isMac) { - return "Mozilla/5.0 (Macintosh; Intel Mac OS X; Macintosh; " + locale + ")"; - } - else if (SystemInfo.isLinux) { - return "Mozilla/5.0 (Linux; Linux; Linux; " + locale + ")"; - } - - return null; - } - - @Override - public void send(@NotNull String url, @NotNull Map values) { - sendingQueue.add(() -> { - try { - final byte[] postDataBytes = createPostData(values); - final HttpURLConnection conn = (HttpURLConnection)new URL(url).openConnection(); - conn.setRequestMethod("POST"); - conn.setRequestProperty("Content-Type", "application/x-www-form-urlencoded"); - conn.setRequestProperty("Content-Length", String.valueOf(postDataBytes.length)); - final String userAgent = createUserAgent(); - if (userAgent != null) { - conn.setRequestProperty("User-Agent", userAgent); - } - conn.setDoOutput(true); - conn.getOutputStream().write(postDataBytes); - - final InputStream in = conn.getInputStream(); - //noinspection ResultOfMethodCallIgnored - in.read(); - in.close(); - } - catch (IOException ignore) { - } - }); - } - - byte[] createPostData(@NotNull Map values) throws UnsupportedEncodingException { - final StringBuilder postData = new StringBuilder(); - for (Map.Entry param : values.entrySet()) { - if (!postData.isEmpty()) { - postData.append('&'); - } - postData.append(URLEncoder.encode(param.getKey(), StandardCharsets.UTF_8)); - postData.append('='); - postData.append(URLEncoder.encode(param.getValue(), StandardCharsets.UTF_8)); - } - return postData.toString().getBytes(StandardCharsets.UTF_8); - } - } - - // This class is intended to be used during debugging. Replacing the reference to - // HttpTransport with NonTransport stops sending any data to Google Analytics, - // and instead logs the number of bytes that would have been sent (minus HTTP header bytes). - private static class NonTransport extends HttpTransport { - private static final Logger LOG = Logger.getInstance(Analytics.class); - - @Override - public void send(@NotNull String url, @NotNull Map values) { - try { - final byte[] postDataBytes = createPostData(values); - //noinspection ConstantConditions - LOG.info("Sending " + postDataBytes.length + " bytes " + new String(postDataBytes)); - } - catch (UnsupportedEncodingException ignore) { - } - } - } -} \ No newline at end of file diff --git a/flutter-idea/src/io/flutter/analytics/DartCompletionTimerListener.java b/flutter-idea/src/io/flutter/analytics/DartCompletionTimerListener.java deleted file mode 100644 index c19d92c80..000000000 --- a/flutter-idea/src/io/flutter/analytics/DartCompletionTimerListener.java +++ /dev/null @@ -1,56 +0,0 @@ -package io.flutter.analytics; - -import com.intellij.openapi.project.Project; -import com.intellij.openapi.project.ProjectManager; - -import com.intellij.util.IncorrectOperationException; -import com.jetbrains.lang.dart.ide.completion.DartCompletionTimerExtension; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -import java.time.Instant; - -/** - * Implementation of the {@link DartCompletionTimerExtension} which allows the Flutter plugin to - * measure the total time to present a code completion to the user. - */ -public class DartCompletionTimerListener extends DartCompletionTimerExtension { - @Nullable FlutterAnalysisServerListener dasListener; - @Nullable Long startTimeMS; - - @Override - public void dartCompletionStart() { - if (dasListener == null) { - try { - Project project = ProjectManager.getInstance().getDefaultProject(); - dasListener = FlutterAnalysisServerListener.getInstance(project); - } catch (IncorrectOperationException ex) { - return; - } - } - startTimeMS = Instant.now().toEpochMilli(); - } - - @Override - public void dartCompletionEnd() { - if (dasListener != null && startTimeMS != null) { - long durationTimeMS = Instant.now().toEpochMilli() - startTimeMS; - dasListener.logE2ECompletionSuccessMS(durationTimeMS); // test: logE2ECompletionSuccessMS() - startTimeMS = null; - } - } - - /** - * The parameters match those of {@link org.dartlang.analysis.server.protocol.RequestError}, they - * are not used currently because our hypothesis is that this method will never be called. - */ - @Override - public void dartCompletionError( - @NotNull String code, @NotNull String message, @NotNull String stackTrace) { - if (dasListener != null && startTimeMS != null) { - long durationTimeMS = Instant.now().toEpochMilli() - startTimeMS; - dasListener.logE2ECompletionErrorMS(durationTimeMS); // test: logE2ECompletionErrorMS() - startTimeMS = null; - } - } -} \ No newline at end of file diff --git a/flutter-idea/src/io/flutter/analytics/FlutterAnalysisServerListener.java b/flutter-idea/src/io/flutter/analytics/FlutterAnalysisServerListener.java deleted file mode 100644 index d382e4cfe..000000000 --- a/flutter-idea/src/io/flutter/analytics/FlutterAnalysisServerListener.java +++ /dev/null @@ -1,662 +0,0 @@ -package io.flutter.analytics; - -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.Sets; -import com.google.dart.server.AnalysisServerListener; -import com.google.dart.server.RequestListener; -import com.google.dart.server.ResponseListener; -import com.google.gson.Gson; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.intellij.codeInsight.lookup.LookupEvent; -import com.intellij.codeInsight.lookup.LookupListener; -import com.intellij.codeInsight.lookup.LookupManager; -import com.intellij.codeInsight.lookup.impl.LookupImpl; -import com.intellij.openapi.Disposable; -import com.intellij.openapi.application.ApplicationManager; -import com.intellij.openapi.diagnostic.Logger; -import com.intellij.openapi.editor.Editor; -import com.intellij.openapi.fileEditor.FileEditorManager; -import com.intellij.openapi.fileEditor.FileEditorManagerEvent; -import com.intellij.openapi.fileEditor.FileEditorManagerListener; -import com.intellij.openapi.project.Project; -import com.intellij.openapi.project.ProjectManager; -import com.intellij.openapi.project.ProjectManagerListener; -import com.intellij.openapi.util.text.StringUtil; -import com.intellij.openapi.vfs.VirtualFile; -import com.intellij.psi.PsiFile; -import com.intellij.util.messages.MessageBusConnection; -import com.jetbrains.lang.dart.analyzer.DartAnalysisServerService; -import com.jetbrains.lang.dart.fixes.DartQuickFix; -import com.jetbrains.lang.dart.fixes.DartQuickFixListener; -import io.flutter.FlutterInitializer; -import io.flutter.utils.FileUtils; -import org.dartlang.analysis.server.protocol.*; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; -import org.jetbrains.annotations.VisibleForTesting; - -import java.beans.PropertyChangeEvent; -import java.time.Duration; -import java.time.Instant; -import java.util.*; -import java.util.stream.Collectors; - -@SuppressWarnings("LocalCanBeFinal") -public final class FlutterAnalysisServerListener implements Disposable, AnalysisServerListener { - // statics - static final String INITIAL_COMPUTE_ERRORS_TIME = "initialComputeErrorsTime"; - static final String INITIAL_HIGHLIGHTS_TIME = "initialHighlightsTime"; - static final String INITIAL_OUTLINE_TIME = "initialOutlineTime"; - static final String ROUND_TRIP_TIME = "roundTripTime"; - static final String QUICK_FIX = "quickFix"; - static final String UNKNOWN_LOOKUP_STRING = ""; - static final String ANALYSIS_SERVER_LOG = "analysisServerLog"; - static final String ACCEPTED_COMPLETION = "acceptedCompletion"; - static final String REJECTED_COMPLETION = "rejectedCompletion"; - static final String E2E_IJ_COMPLETION_TIME = "e2eIJCompletionTime"; - static final String GET_SUGGESTIONS = "completion.getSuggestions"; - static final String FIND_REFERENCES = "search.findElementReferences"; - static final Set MANUALLY_MANAGED_METHODS = Sets.newHashSet(GET_SUGGESTIONS, FIND_REFERENCES); - static final String ERRORS = "errors"; - static final String WARNINGS = "warnings"; - static final String HINTS = "hints"; - static final String LINTS = "lints"; - static final String DURATION = "duration"; - static final String FAILURE = "failure"; - static final String SUCCESS = "success"; - static final String ERROR_TYPE_REQUEST = "R"; - static final String ERROR_TYPE_SERVER = "@"; - - static final String DAS_STATUS_EVENT_TYPE = "analysisServerStatus"; - static final String[] ERROR_TYPES = new String[]{ - AnalysisErrorType.CHECKED_MODE_COMPILE_TIME_ERROR, - AnalysisErrorType.COMPILE_TIME_ERROR, - AnalysisErrorType.HINT, - AnalysisErrorType.LINT, - AnalysisErrorType.STATIC_TYPE_WARNING, - AnalysisErrorType.STATIC_WARNING, - AnalysisErrorType.SYNTACTIC_ERROR - }; - - static final String LOG_ENTRY_KIND = "kind"; - static final String LOG_ENTRY_TIME = "time"; - static final String LOG_ENTRY_DATA = "data"; - static final String LOG_ENTRY_SDK_VERSION = "sdkVersion"; - static final HashSet REQUEST_ERRORS_TO_IGNORE = new HashSet<>(); - static { - REQUEST_ERRORS_TO_IGNORE.addAll(Arrays.asList("FORMAT_WITH_ERRORS", "ORGANIZE_DIRECTIVES_ERROR", "REFACTORING_REQUEST_CANCELLED")); - } - private static final long ERROR_REPORT_INTERVAL = 1000 * 60 * 60 * 2; // Two hours between cumulative error reports, in ms. - private static final long GENERAL_REPORT_INTERVAL = 1000 * 60; // One minute between general analytic reports, in ms. - private static final Logger LOG = Logger.getInstance(FlutterAnalysisServerListener.class); - private static final boolean IS_TESTING = ApplicationManager.getApplication().isUnitTestMode(); - - @NotNull final FlutterRequestListener requestListener; - @NotNull final FlutterResponseListener responseListener; - @NotNull final DartQuickFixListener quickFixListener; - // instance members - @NotNull private final Project project; - @NotNull private final Map> pathToErrors; - @NotNull private final Map pathToErrorTimestamps; - @NotNull private final Map pathToHighlightTimestamps; - @NotNull private final Map pathToOutlineTimestamps; - @NotNull private final Map requestToDetails; - @NotNull private final MessageBusConnection messageBusConnection; - @NotNull private final FileEditorManagerListener fileEditorManagerListener; - LookupSelectionHandler lookupSelectionHandler; - @NotNull private Instant nextMemoryUsageLoggedInstant = Instant.EPOCH; - private long errorsTimestamp; - private long generalTimestamp; - private int errorCount; - private int warningCount; - private int hintCount; - private int lintCount; - - FlutterAnalysisServerListener(@NotNull Project project) { - this.project = project; - this.pathToErrors = new HashMap<>(); - this.pathToErrorTimestamps = new HashMap<>(); - this.pathToHighlightTimestamps = new HashMap<>(); - this.pathToOutlineTimestamps = new HashMap<>(); - this.requestToDetails = new HashMap<>(); - this.messageBusConnection = project.getMessageBus().connect(); - LookupManager.getInstance(project).addPropertyChangeListener(this::onPropertyChange); - - this.fileEditorManagerListener = new FileEditorManagerListener() { - @Override - public void fileOpened(@NotNull final FileEditorManager source, @NotNull final VirtualFile file) { - // Record the time that this file was opened so that we'll be able to log - // relative timings for errors, highlights, outlines, etc. - String filePath = file.getPath(); - Instant nowInstant = Instant.now(); - pathToErrorTimestamps.put(filePath, nowInstant); - pathToHighlightTimestamps.put(filePath, nowInstant); - pathToOutlineTimestamps.put(filePath, nowInstant); - } - - @Override - public void selectionChanged(@NotNull FileEditorManagerEvent event) { - } - - @Override - public void fileClosed(@NotNull final FileEditorManager source, @NotNull final VirtualFile file) { - } - }; - messageBusConnection.subscribe(FileEditorManagerListener.FILE_EDITOR_MANAGER, fileEditorManagerListener); - messageBusConnection.subscribe(ProjectManager.TOPIC, new ProjectManagerListener() { - public void projectClosing(@NotNull Project project) { - messageBusConnection.disconnect(); // Do this first to void memory leaks when switching pojects. - errorsTimestamp = 0L; // Ensure we always report error counts on shutdown. - maybeReportErrorCounts(); // The ShutdownTracker only allows three seconds, so this might not always complete. - } - }); - this.quickFixListener = new QuickFixListener(); - this.requestListener = new FlutterRequestListener(); - this.responseListener = new FlutterResponseListener(); - DartAnalysisServerService analysisServer = DartAnalysisServerService.getInstance(project); - analysisServer.addQuickFixListener(this.quickFixListener); - analysisServer.addRequestListener(this.requestListener); - analysisServer.addResponseListener(this.responseListener); - } - - @NotNull - public static FlutterAnalysisServerListener getInstance(@NotNull final Project project) { - return Objects.requireNonNull(project.getService(FlutterAnalysisServerListener.class)); - } - - @NotNull - private static String safelyGetString(JsonObject jsonObject, String memberName) { - if (jsonObject != null && StringUtil.isNotEmpty(memberName)) { - JsonElement jsonElement = jsonObject.get(memberName); - if (jsonElement != null) { - return Objects.requireNonNull(jsonElement.getAsString()); - } - } - return ""; - } - - @Override - public void dispose() { - // This is deprecated and marked for removal in 2021.3. If it is removed we will - // have to do some funny stuff to support older versions of Android Studio. - //noinspection UnstableApiUsage - LookupManager.getInstance(project).removePropertyChangeListener(this::onPropertyChange); - } - - @Override - public void computedAnalyzedFiles(List list) { - // No start time is recorded. - } - - @Override - public void computedAvailableSuggestions(@NotNull List list, int[] ints) { - // No start time is recorded. - } - - @Override - public void computedCompletion(String completionId, - int replacementOffset, - int replacementLength, - List completionSuggestions, - List includedSuggestionSets, - List includedElementKinds, - List includedSuggestionRelevanceTags, - boolean isLast, - String libraryFilePathSD) { - long currentTimestamp = System.currentTimeMillis(); - String id = getIdForMethod(GET_SUGGESTIONS); - if (id == null) { - return; - } - RequestDetails details = requestToDetails.remove(id); - if (details == null) { - return; - } - maybeReport(true, (analytics) -> { - long startTime = details.startTime().toEpochMilli(); - analytics.sendTiming(ROUND_TRIP_TIME, GET_SUGGESTIONS, currentTimestamp - startTime); // test: computedCompletion - }); - } - - @Nullable - private String getIdForMethod(@NotNull String method) { - Set keys = requestToDetails.keySet(); - for (String id : keys) { - RequestDetails details = requestToDetails.get(id); - assert details != null; - if (GET_SUGGESTIONS.equals(details.method())) { - return id; - } - } - return null; - } - - @Override - public void computedErrors(String path, List list) { - assert list != null; - pathToErrors.put(path, list); - assert path != null; - maybeLogInitialAnalysisTime(INITIAL_COMPUTE_ERRORS_TIME, path, pathToErrorTimestamps); - } - - @NotNull - public List getAnalysisErrorsForFile(String path) { - if (path == null) { - return AnalysisError.EMPTY_LIST; - } - return Objects.requireNonNull(pathToErrors.getOrDefault(path, AnalysisError.EMPTY_LIST)); - } - - /** - * Iterate through all files in this {@link Project}, counting how many of each {@link - * AnalysisErrorType} is in each file. The returned {@link HashMap} will contain the set of String - * keys in ERROR_TYPES and values with the mentioned sums, converted to Strings. - */ - @NotNull - private HashMap getTotalAnalysisErrorCounts() { - // Create a zero-filled array of length ERROR_TYPES.length. - int[] errorCountsArray = new int[ERROR_TYPES.length]; - - // Iterate through each file in this project. - for (String keyPath : pathToErrors.keySet()) { - // Get the list of AnalysisErrors and remove any todos from the list, these are ignored in the - // Dart Problems view, and can be ignored for any dashboard work. - assert keyPath != null; - List errors = getAnalysisErrorsForFile(keyPath); - errors.removeIf(e -> { - assert e != null; - return Objects.equals(e.getType(), AnalysisErrorType.TODO); - }); - if (errors.isEmpty()) { - continue; - } - - // For this file, count how many of each ERROR_TYPES type we have and add this count to each - // errorCountsArray[*] - for (int i = 0; i < ERROR_TYPES.length; i++) { - final int j = i; - errorCountsArray[j] += (int) errors.stream().filter(e -> { - assert e != null; - return Objects.equals(e.getType(), ERROR_TYPES[j]); - }).count(); - } - } - - // Finally, create and return the final HashMap. - HashMap errorCounts = new HashMap<>(); - for (int i = 0; i < ERROR_TYPES.length; i++) { - errorCounts.put(ERROR_TYPES[i], errorCountsArray[i]); - } - return errorCounts; - } - - @Override - public void computedHighlights(String path, List list) { - assert path != null; - maybeLogInitialAnalysisTime(INITIAL_HIGHLIGHTS_TIME, path, pathToHighlightTimestamps); - } - - @Override - public void computedImplemented(String s, List list, List list1) { - // No start time is recorded. - } - - @Override - public void computedLaunchData(String s, String s1, String[] strings) { - } - - @Override - public void computedNavigation(String s, List list) { - // No start time is recorded. - } - - @Override - public void computedOccurrences(String s, List list) { - // No start time is recorded. - } - - @Override - public void computedOutline(String path, Outline outline) { - assert path != null; - maybeLogInitialAnalysisTime(INITIAL_OUTLINE_TIME, path, pathToOutlineTimestamps); - } - - @Override - public void computedOverrides(String s, List list) { - // No start time is recorded. - } - - @Override - public void computedClosingLabels(String s, List list) { - // No start time is recorded. - } - - @Override - public void computedSearchResults(String searchId, List results, boolean isLast) { - RequestDetails details = requestToDetails.remove(searchId); - if (details == null) { - return; - } - maybeReport(true, (analytics) -> { - String method = details.method(); - long duration = generalTimestamp - details.startTime().toEpochMilli(); - LOG.debug(ROUND_TRIP_TIME + " " + method + " " + duration); - analytics.sendTiming(ROUND_TRIP_TIME, method, duration); // test: computedSearchResults() - }); - } - - @Override - public void flushedResults(List list) { - // Timing info not valid. - } - - @Override - public void requestError(RequestError requestError) { - maybeReport(true, (analytics) -> { - assert requestError != null; - String code = requestError.getCode(); - if (code == null) { - code = requestError.getMessage(); // test: requestErrorNoCode() - } - if (REQUEST_ERRORS_TO_IGNORE.contains(code)) { - return; - } - String stack = requestError.getStackTrace(); - String exception = composeException(ERROR_TYPE_REQUEST, code, stack); - LOG.debug(exception); - analytics.sendException(exception, false); // test: requestError() - }); - } - - /** - * Build an exception parameter containing type, code, and stack. Limit it to 150 chars. - * - * @param type "R" for request error, "S" for server error - * @param code error code or message - * @param stack stack trace - * @return exception description, value of "exd" parameter in analytics - */ - private static String composeException(@NotNull String type, @Nullable String code, @Nullable String stack) { - String exception = type + " "; - if (code != null && !code.isEmpty()) { - exception += code; - if (stack != null && !stack.isEmpty()) { - exception += "\n" + stack; - } - } - else if (stack != null && !stack.isEmpty()) { - exception += stack; - } - else { - exception += "exception"; - } - if (exception.length() > 150) { - exception = exception.substring(0, 149); - } - return exception; - } - - @Override - public void serverConnected(String s) { - } - - @Override - public void serverError(boolean isFatal, String message, String stackTraceString) { - maybeReport(true, (analytics) -> { - String exception = composeException(ERROR_TYPE_SERVER, message, stackTraceString); - LOG.debug(exception + " fatal"); - analytics.sendException(exception, isFatal); // test: serverError() - }); - } - - @Override - public void serverIncompatibleVersion(String s) { - } - - @Override - public void serverStatus(AnalysisStatus analysisStatus, PubStatus pubStatus) { - assert analysisStatus != null; - if (!analysisStatus.isAnalyzing()) { - @NotNull HashMap errorCounts = getTotalAnalysisErrorCounts(); - errorCount = 0; - errorCount += extractCount(errorCounts, AnalysisErrorType.CHECKED_MODE_COMPILE_TIME_ERROR); - errorCount += extractCount(errorCounts, AnalysisErrorType.COMPILE_TIME_ERROR); - errorCount += extractCount(errorCounts, AnalysisErrorType.SYNTACTIC_ERROR); - warningCount = 0; - warningCount += extractCount(errorCounts, AnalysisErrorType.STATIC_TYPE_WARNING); - warningCount += extractCount(errorCounts, AnalysisErrorType.STATIC_WARNING); - hintCount = extractCount(errorCounts, AnalysisErrorType.HINT); - lintCount = extractCount(errorCounts, AnalysisErrorType.LINT); - if (IS_TESTING) { - errorCount = warningCount = hintCount = lintCount = 1; - } - maybeReportErrorCounts(); - } - } - - private void maybeReport(boolean observeThrottling, @NotNull java.util.function.Consumer<@NotNull Analytics> func) { - long currentTimestamp = System.currentTimeMillis(); - if (observeThrottling && !IS_TESTING) { - // Throttle to one report per interval. - if (currentTimestamp - generalTimestamp < GENERAL_REPORT_INTERVAL) { - return; - } - } - generalTimestamp = currentTimestamp; - func.accept(FlutterInitializer.getAnalytics()); - } - - private void maybeReportErrorCounts() { - long currentTimestamp = System.currentTimeMillis(); - // Send accumulated error counts once every defined interval, plus when the project is closed. - if (errorsTimestamp == 0L || currentTimestamp - errorsTimestamp > ERROR_REPORT_INTERVAL || IS_TESTING) { - errorsTimestamp = currentTimestamp; - Analytics analytics = FlutterInitializer.getAnalytics(); - LOG.debug(DAS_STATUS_EVENT_TYPE + " " + errorCount + " " + warningCount + " " + hintCount + " " + lintCount); - analytics.disableThrottling(() -> { - if (errorCount > 0) { - analytics.sendEventMetric(DAS_STATUS_EVENT_TYPE, ERRORS, errorCount); // test: serverStatus() - } - if (warningCount > 0) { - analytics.sendEventMetric(DAS_STATUS_EVENT_TYPE, WARNINGS, warningCount); // test: serverStatus() - } - if (hintCount > 0) { - analytics.sendEventMetric(DAS_STATUS_EVENT_TYPE, HINTS, hintCount); // test: serverStatus() - } - if (lintCount > 0) { - analytics.sendEventMetric(DAS_STATUS_EVENT_TYPE, LINTS, lintCount); // test: serverStatus() - } - }); - errorCount = warningCount = hintCount = lintCount = 0; - } - } - - private static int extractCount(@NotNull Map errorCounts, String name) { - //noinspection Java8MapApi,ConstantConditions - return errorCounts.containsKey(name) ? errorCounts.get(name) : 0; - } - - @Override - public void computedExistingImports(String file, Map>> existingImports) { - // No start time is recorded. - } - - private void logCompletion(@NotNull String selection, int prefixLength, @NotNull String eventType) { - maybeReport(true, (analytics) -> { - LOG.debug(eventType + " " + selection + " " + prefixLength); - analytics.sendEventMetric(eventType, selection, prefixLength); // test: acceptedCompletion(), lookupCanceled() - }); - } - - void logE2ECompletionSuccessMS(long e2eCompletionMS) { - maybeReport(true, (analytics) -> { - LOG.debug(E2E_IJ_COMPLETION_TIME + " " + SUCCESS + " " + e2eCompletionMS); - analytics.sendTiming(E2E_IJ_COMPLETION_TIME, SUCCESS, e2eCompletionMS); // test: logE2ECompletionSuccessMS() - }); - } - - void logE2ECompletionErrorMS(long e2eCompletionMS) { - maybeReport(true, (analytics) -> { - LOG.debug(E2E_IJ_COMPLETION_TIME + " " + FAILURE + " " + e2eCompletionMS); - analytics.sendTiming(E2E_IJ_COMPLETION_TIME, FAILURE, e2eCompletionMS); // test: logE2ECompletionErrorMS() - }); - } - - private void maybeLogInitialAnalysisTime(@NotNull String eventType, @NotNull String path, @NotNull Map pathToStartTime) { - if (!pathToStartTime.containsKey(path)) { - return; - } - - logFileAnalysisTime(eventType, path, Objects.requireNonNull( - Duration.between(Objects.requireNonNull(pathToStartTime.get(path)), Instant.now())).toMillis()); - pathToStartTime.remove(path); - } - - private void logFileAnalysisTime(@NotNull String kind, String path, long analysisTime) { - maybeReport(false, (analytics) -> { - LOG.debug(kind + " " + DURATION + " " + analysisTime); - analytics.sendEvent(kind, DURATION, "", Long.toString(analysisTime)); // test: computedErrors() - }); - } - - /** - * Observe when the active {@link LookupImpl} changes and register the {@link - * LookupSelectionHandler} on any new instances. - */ - void onPropertyChange(@NotNull PropertyChangeEvent propertyChangeEvent) { - Object newValue = propertyChangeEvent.getNewValue(); - if (!(newValue instanceof LookupImpl lookup)) { - return; - } - - setLookupSelectionHandler(); - lookup.addLookupListener(lookupSelectionHandler); - } - - @VisibleForTesting - void setLookupSelectionHandler() { - this.lookupSelectionHandler = new LookupSelectionHandler(); - } - - class LookupSelectionHandler implements LookupListener { - @Override - public void lookupCanceled(@NotNull LookupEvent event) { - if (event.isCanceledExplicitly() && isDartLookupEvent(event)) { - logCompletion(UNKNOWN_LOOKUP_STRING, -1, REJECTED_COMPLETION); // test: lookupCanceled() - } - } - - @Override - public void itemSelected(@NotNull LookupEvent event) { - if (event.getItem() == null) { - return; - } - String selection = event.getItem().getLookupString(); - LookupImpl lookup = (LookupImpl)event.getLookup(); - assert lookup != null; - int prefixLength = lookup.getPrefixLength(event.getItem()); - - if (isDartLookupEvent(event)) { - logCompletion(selection, prefixLength, ACCEPTED_COMPLETION); // test: acceptedCompletion() - } - } - - @Override - public void currentItemChanged(@NotNull LookupEvent event) { - } - - private boolean isDartLookupEvent(@NotNull LookupEvent event) { - LookupImpl lookup = (LookupImpl)event.getLookup(); - return lookup != null && - lookup.getPsiFile() != null && - lookup.getPsiFile().getVirtualFile() != null && - FileUtils.isDartFile(Objects.requireNonNull(lookup.getPsiFile().getVirtualFile())); - } - } - - private class QuickFixListener implements DartQuickFixListener { - @Override - public void beforeQuickFixInvoked(@NotNull DartQuickFix intention, @NotNull Editor editor, @NotNull PsiFile file) { - maybeReport(true, (analytics) -> { - String path = Objects.requireNonNull(file.getVirtualFile()).getPath(); - int lineNumber = editor.getCaretModel().getLogicalPosition().line + 1; - @SuppressWarnings("ConstantConditions") - List errorsOnLine = - pathToErrors.containsKey(path) ? pathToErrors.get(path).stream().filter(error -> error.getLocation().getStartLine() == lineNumber) - .map(AnalysisError::getCode).collect(Collectors.toList()) : ImmutableList.of(); - LOG.debug(QUICK_FIX + " " + intention.getText() + " " + errorsOnLine.size()); - analytics.sendEventMetric(QUICK_FIX, intention.getText(), errorsOnLine.size()); // test: quickFix() - }); - } - } - - class FlutterRequestListener implements RequestListener { - @Override - public void onRequest(String jsonString) { - JsonObject request = new Gson().fromJson(jsonString, JsonObject.class); - //noinspection ConstantConditions - RequestDetails details = new RequestDetails(request.get("method").getAsString(), Instant.now()); - String id = Objects.requireNonNull(request.get("id")).getAsString(); - requestToDetails.put(id, details); - } - } - - @SuppressWarnings("LocalCanBeFinal") - class FlutterResponseListener implements ResponseListener { - final Map methodTimestamps = new HashMap<>(); - - @Override - public void onResponse(String jsonString) { - JsonObject response = new Gson().fromJson(jsonString, JsonObject.class); - if (response == null) return; - if (safelyGetString(response, "event").equals("server.log")) { - JsonObject serverLogEntry = Objects.requireNonNull(response.getAsJsonObject("params")).getAsJsonObject("entry"); - if (serverLogEntry != null) { - maybeReport(true, (analytics) -> { - String sdkVersionValue = safelyGetString(serverLogEntry, LOG_ENTRY_SDK_VERSION); - ImmutableMap map; - - @SuppressWarnings("ConstantConditions") - String logEntry = - String.format("%s|%s|%s|%s|%s|%s", LOG_ENTRY_TIME, serverLogEntry.get(LOG_ENTRY_TIME).getAsInt(), - LOG_ENTRY_KIND, serverLogEntry.get(LOG_ENTRY_KIND).getAsString(), LOG_ENTRY_DATA, - serverLogEntry.get(LOG_ENTRY_DATA).getAsString()); - assert logEntry != null; - LOG.debug(ANALYSIS_SERVER_LOG + " " + logEntry); - // Log the "sdkVersion" only if it was provided in the event - if (StringUtil.isEmpty(sdkVersionValue)) { - analytics.sendEvent(ANALYSIS_SERVER_LOG, logEntry); // test: dasListenerLogging() - } - else { // test: dasListenerLoggingWithSdk() - analytics.sendEventWithSdk(ANALYSIS_SERVER_LOG, logEntry, sdkVersionValue); - } - }); - } - } - if (response.get("id") == null) { - return; - } - //noinspection ConstantConditions - String id = response.get("id").getAsString(); - RequestDetails details = requestToDetails.get(id); - if (details != null) { - if (MANUALLY_MANAGED_METHODS.contains(details.method())) { - return; - } - Long timestamp = methodTimestamps.get(details.method()); - long currentTimestamp = System.currentTimeMillis(); - // Throttle to one report per interval for each distinct details.method(). - if (timestamp == null || currentTimestamp - timestamp > GENERAL_REPORT_INTERVAL) { - methodTimestamps.put(details.method(), currentTimestamp); - LOG.debug(ROUND_TRIP_TIME + " " + details.method() + " " + Duration.between(details.startTime(), Instant.now()).toMillis()); - FlutterInitializer.getAnalytics() - .sendTiming(ROUND_TRIP_TIME, details.method(), // test: dasListenerTiming() - Objects.requireNonNull(Duration.between(details.startTime(), Instant.now())).toMillis()); - } - } - requestToDetails.remove(id); - } - } -} diff --git a/flutter-idea/src/io/flutter/analytics/TimeTracker.java b/flutter-idea/src/io/flutter/analytics/TimeTracker.java deleted file mode 100644 index e8a1dd2f2..000000000 --- a/flutter-idea/src/io/flutter/analytics/TimeTracker.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright 2020 The Chromium Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ -package io.flutter.analytics; - -import com.intellij.openapi.components.Service; -import com.intellij.openapi.project.Project; -import org.jetbrains.annotations.NotNull; - -import java.util.Objects; - -@Service -public final class TimeTracker { - private final Project project; - private Long projectOpenTime; - - @NotNull - public static TimeTracker getInstance(@NotNull final Project project) { - return Objects.requireNonNull(project.getService(TimeTracker.class)); - } - - public TimeTracker(Project project) { - this.project = project; - } - - public void onProjectOpen() { - this.projectOpenTime = System.currentTimeMillis(); - } - - public int millisSinceProjectOpen() { - if (projectOpenTime == null) { - return 0; - } - return (int)(System.currentTimeMillis() - projectOpenTime); - } -} diff --git a/flutter-idea/src/io/flutter/analytics/ToolWindowTracker.java b/flutter-idea/src/io/flutter/analytics/ToolWindowTracker.java deleted file mode 100644 index 3afb96708..000000000 --- a/flutter-idea/src/io/flutter/analytics/ToolWindowTracker.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright 2017 The Chromium Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ -package io.flutter.analytics; - -import com.intellij.openapi.project.Project; -import com.intellij.openapi.util.text.StringUtil; -import com.intellij.openapi.wm.ToolWindowManager; -import com.intellij.openapi.wm.ex.ToolWindowManagerEx; -import com.intellij.openapi.wm.ex.ToolWindowManagerListener; -import org.jetbrains.annotations.NotNull; - -/** - * This class interfaces with the IntelliJ tool window manager and reports tool window - * usage to analytics. - */ -public class ToolWindowTracker implements ToolWindowManagerListener { - - public static void track(@NotNull Project project, @NotNull Analytics analytics) { - new ToolWindowTracker(project, analytics); - } - - private final Analytics myAnalytics; - private final ToolWindowManagerEx myToolWindowManager; - - private String currentWindowId; - - private ToolWindowTracker(@NotNull Project project, @NotNull Analytics analytics) { - myAnalytics = analytics; - - myToolWindowManager = ToolWindowManagerEx.getInstanceEx(project); - - project.getMessageBus().connect().subscribe(ToolWindowManagerListener.TOPIC, this); - - update(); - } - - @Override - public void stateChanged(@NotNull ToolWindowManager toolWindowManager) { - update(); - } - - private void update() { - final String newWindow = findWindowId(); - - if (!StringUtil.equals(newWindow, currentWindowId)) { - currentWindowId = newWindow; - myAnalytics.sendScreenView(currentWindowId); - } - } - - @NotNull - private String findWindowId() { - final String newWindow = myToolWindowManager.getActiveToolWindowId(); - return newWindow == null ? "editor" : newWindow.toLowerCase(); - } -} diff --git a/flutter-idea/src/io/flutter/analytics/UnifiedAnalytics.java b/flutter-idea/src/io/flutter/analytics/UnifiedAnalytics.java index 54c6a34a9..66b8a06d7 100644 --- a/flutter-idea/src/io/flutter/analytics/UnifiedAnalytics.java +++ b/flutter-idea/src/io/flutter/analytics/UnifiedAnalytics.java @@ -137,7 +137,7 @@ private CompletableFuture showMessage(@NotNull String message) { CompletableFuture finalResult = new CompletableFuture<>(); ApplicationManager.getApplication().invokeLater(() -> { final Notification notification = new Notification( - Analytics.GROUP_DISPLAY_ID, + "Flutter Usage Statistics", // Analytics.GROUP_DISPLAY_ID, "Welcome to Flutter!", message, NotificationType.INFORMATION); diff --git a/flutter-idea/src/io/flutter/dart/FlutterDartAnalysisServer.java b/flutter-idea/src/io/flutter/dart/FlutterDartAnalysisServer.java index 65b85722e..848d8638d 100644 --- a/flutter-idea/src/io/flutter/dart/FlutterDartAnalysisServer.java +++ b/flutter-idea/src/io/flutter/dart/FlutterDartAnalysisServer.java @@ -22,8 +22,6 @@ import com.intellij.openapi.vfs.VirtualFile; import com.intellij.util.Consumer; import com.jetbrains.lang.dart.analyzer.DartAnalysisServerService; -import io.flutter.FlutterInitializer; -import io.flutter.analytics.TimeTracker; import io.flutter.utils.JsonUtils; import org.dartlang.analysis.server.protocol.*; import org.jetbrains.annotations.NotNull; @@ -99,11 +97,6 @@ public void serverConnected(String s) { @Override public void computedErrors(String file, List errors) { if (!hasComputedErrors && project.isOpen()) { - FlutterInitializer.getAnalytics().sendEventMetric( - "startup", - "analysisComputedErrors", - TimeTracker.getInstance(project).millisSinceProjectOpen() - ); hasComputedErrors = true; } diff --git a/flutter-idea/src/io/flutter/inspector/WidgetPerfTipsPanel.java b/flutter-idea/src/io/flutter/inspector/WidgetPerfTipsPanel.java index 5e0a9d0ad..c2178e59c 100644 --- a/flutter-idea/src/io/flutter/inspector/WidgetPerfTipsPanel.java +++ b/flutter-idea/src/io/flutter/inspector/WidgetPerfTipsPanel.java @@ -19,7 +19,6 @@ import com.intellij.ui.components.panels.VerticalLayout; import com.intellij.util.messages.MessageBusConnection; import com.intellij.util.ui.JBUI; -import io.flutter.FlutterInitializer; import io.flutter.perf.*; import io.flutter.run.daemon.FlutterApp; import io.flutter.utils.AsyncUtils; @@ -81,8 +80,6 @@ public void selectionChanged(@NotNull FileEditorManagerEvent event) { } private static void handleTipSelection(@NotNull PerfTip tip) { - // Send analytics. - FlutterInitializer.getAnalytics().sendEvent("perf", "perfTipSelected." + tip.getRule().getId()); BrowserLauncher.getInstance().browse(tip.getUrl(), null); } diff --git a/flutter-idea/src/io/flutter/jxbrowser/EmbeddedBrowserEngine.java b/flutter-idea/src/io/flutter/jxbrowser/EmbeddedBrowserEngine.java index 11a7b48af..f43e74e18 100644 --- a/flutter-idea/src/io/flutter/jxbrowser/EmbeddedBrowserEngine.java +++ b/flutter-idea/src/io/flutter/jxbrowser/EmbeddedBrowserEngine.java @@ -13,7 +13,6 @@ import com.teamdev.jxbrowser.engine.Engine; import com.teamdev.jxbrowser.engine.EngineOptions; import com.teamdev.jxbrowser.engine.PasswordStore; -import io.flutter.FlutterInitializer; import java.io.File; import java.nio.file.Paths; @@ -51,7 +50,6 @@ public EmbeddedBrowserEngine() { } catch (Exception ex) { temp = null; LOG.info(ex); - FlutterInitializer.getAnalytics().sendExpectedException("jxbrowser-engine", ex); } engine = temp; @@ -64,7 +62,6 @@ public boolean canExitApplication() { } } catch (Exception ex) { LOG.info(ex); - FlutterInitializer.getAnalytics().sendExpectedException("jxbrowswer-engine-close", ex); } return true; } diff --git a/flutter-idea/src/io/flutter/jxbrowser/EmbeddedJxBrowser.java b/flutter-idea/src/io/flutter/jxbrowser/EmbeddedJxBrowser.java index 46a3e1f9b..534207fc3 100644 --- a/flutter-idea/src/io/flutter/jxbrowser/EmbeddedJxBrowser.java +++ b/flutter-idea/src/io/flutter/jxbrowser/EmbeddedJxBrowser.java @@ -22,7 +22,6 @@ import com.teamdev.jxbrowser.view.swing.BrowserView; import com.teamdev.jxbrowser.view.swing.callback.DefaultAlertCallback; import com.teamdev.jxbrowser.view.swing.callback.DefaultConfirmCallback; -import io.flutter.FlutterInitializer; import io.flutter.settings.FlutterSettings; import io.flutter.utils.AsyncUtils; import io.flutter.utils.JxBrowserUtils; @@ -62,7 +61,6 @@ public EmbeddedJxBrowserTab(Engine engine) { } catch (Exception | Error ex) { LOG.info(ex); - FlutterInitializer.getAnalytics().sendExpectedException("jxbrowser-setup", ex); } } @@ -203,7 +201,6 @@ protected void waitForJxBrowserInstallation(ContentManager contentManager) { } catch (TimeoutException e) { showMessageWithUrlLink(INSTALLATION_TIMED_OUT_LABEL, contentManager); - FlutterInitializer.getAnalytics().sendEvent(JxBrowserManager.ANALYTICS_CATEGORY, "timedOut"); } } diff --git a/flutter-idea/src/io/flutter/jxbrowser/JxBrowserManager.java b/flutter-idea/src/io/flutter/jxbrowser/JxBrowserManager.java index bababb10d..77f1e288b 100644 --- a/flutter-idea/src/io/flutter/jxbrowser/JxBrowserManager.java +++ b/flutter-idea/src/io/flutter/jxbrowser/JxBrowserManager.java @@ -23,8 +23,6 @@ import com.intellij.util.download.FileDownloader; import com.teamdev.jxbrowser.browser.UnsupportedRenderingModeException; import com.teamdev.jxbrowser.engine.RenderingMode; -import io.flutter.FlutterInitializer; -import io.flutter.analytics.Analytics; import io.flutter.settings.FlutterSettings; import io.flutter.utils.FileUtils; import io.flutter.utils.JxBrowserUtils; @@ -89,13 +87,11 @@ else if (Objects.equals(info.getMajorVersion(), "2020")) { public static final String ANALYTICS_CATEGORY = "jxbrowser"; private static InstallationFailedReason latestFailureReason; private final JxBrowserUtils jxBrowserUtils; - private final Analytics analytics; private final FileUtils fileUtils; @VisibleForTesting - protected JxBrowserManager(@NotNull JxBrowserUtils jxBrowserUtils, @NotNull Analytics analytics, @NotNull FileUtils fileUtils) { + protected JxBrowserManager(@NotNull JxBrowserUtils jxBrowserUtils, @NotNull FileUtils fileUtils) { this.jxBrowserUtils = jxBrowserUtils; - this.analytics = analytics; this.fileUtils = fileUtils; } @@ -103,7 +99,7 @@ protected JxBrowserManager(@NotNull JxBrowserUtils jxBrowserUtils, @NotNull Anal public static JxBrowserManager getInstance() { if (manager == null) { //noinspection ConstantConditions - manager = new JxBrowserManager(new JxBrowserUtils(), FlutterInitializer.getAnalytics(), FileUtils.getInstance()); + manager = new JxBrowserManager(new JxBrowserUtils(), FileUtils.getInstance()); } return manager; } @@ -181,13 +177,6 @@ private void setStatusFailed(@NotNull InstallationFailedReason reason, @Nullable eventName.append(reason.detail); } - if (time != null) { - analytics.sendEventMetric(ANALYTICS_CATEGORY, eventName.toString(), time.intValue()); - } - else { - analytics.sendEvent(ANALYTICS_CATEGORY, eventName.toString()); - } - latestFailureReason = reason; status.set(JxBrowserStatus.INSTALLATION_FAILED); installation.complete(JxBrowserStatus.INSTALLATION_FAILED); @@ -335,7 +324,6 @@ public void run(@NotNull ProgressIndicator indicator) { } } - analytics.sendEvent(ANALYTICS_CATEGORY, "filesDownloaded"); loadClasses(fileNames); } catch (IOException e) { @@ -387,7 +375,6 @@ private void loadClasses(@NotNull String[] fileNames) { } finally { Thread.currentThread().setContextClassLoader(current); } - analytics.sendEvent(ANALYTICS_CATEGORY, "installed"); status.set(JxBrowserStatus.INSTALLED); installation.complete(JxBrowserStatus.INSTALLED); } diff --git a/flutter-idea/src/io/flutter/logging/FlutterConsoleLogManager.java b/flutter-idea/src/io/flutter/logging/FlutterConsoleLogManager.java index badc001e6..ebe038843 100644 --- a/flutter-idea/src/io/flutter/logging/FlutterConsoleLogManager.java +++ b/flutter-idea/src/io/flutter/logging/FlutterConsoleLogManager.java @@ -29,7 +29,6 @@ import com.intellij.openapi.wm.ex.ToolWindowManagerEx; import com.intellij.ui.SimpleTextAttributes; import com.intellij.util.concurrency.QueueProcessor; -import io.flutter.FlutterInitializer; import io.flutter.FlutterUtils; import io.flutter.devtools.DevToolsUtils; import io.flutter.inspector.DiagnosticLevel; @@ -38,7 +37,6 @@ import io.flutter.inspector.InspectorService; import io.flutter.jxbrowser.JxBrowserManager; import io.flutter.run.daemon.FlutterApp; -import io.flutter.sdk.FlutterSdk; import io.flutter.settings.FlutterSettings; import io.flutter.utils.JsonUtils; import io.flutter.view.EmbeddedBrowser; @@ -425,12 +423,6 @@ public void actionPerformed(@NotNull AnActionEvent event) { } notification.expire(); - - FlutterInitializer.getAnalytics().sendEvent( - "deep-link-clicked", - errorSummary.contains("RenderFlex overflowed") ? "overflow" : "unknown", - FlutterSdk.getFlutterSdk(app.getProject()) - ); } }); Notifications.Bus.notify(notification, app.getProject()); diff --git a/flutter-idea/src/io/flutter/perf/FlutterWidgetPerfManager.java b/flutter-idea/src/io/flutter/perf/FlutterWidgetPerfManager.java index c2c88f67b..78c052d95 100644 --- a/flutter-idea/src/io/flutter/perf/FlutterWidgetPerfManager.java +++ b/flutter-idea/src/io/flutter/perf/FlutterWidgetPerfManager.java @@ -12,7 +12,6 @@ import com.intellij.openapi.util.Disposer; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.util.messages.MessageBusConnection; -import io.flutter.FlutterInitializer; import io.flutter.FlutterUtils; import io.flutter.run.FlutterAppManager; import io.flutter.run.daemon.FlutterApp; @@ -149,10 +148,6 @@ public void setTrackRebuildWidgets(boolean value) { if (debugIsActive && app != null && app.isSessionActive()) { updateTrackWidgetRebuilds(); } - // Send analytics. - if (trackRebuildWidgets) { - FlutterInitializer.getAnalytics().sendEvent("intellij", "TrackWidgetRebuilds"); - } } public boolean isTrackRepaintWidgets() { @@ -168,10 +163,6 @@ public void setTrackRepaintWidgets(boolean value) { if (debugIsActive && app != null && app.isSessionActive()) { updateTrackWidgetRepaints(); } - // Send analytics. - if (trackRepaintWidgets) { - FlutterInitializer.getAnalytics().sendEvent("intellij", "TrackRepaintWidgets"); - } } private void onProfilingFlagsChanged() { diff --git a/flutter-idea/src/io/flutter/preview/PreviewView.java b/flutter-idea/src/io/flutter/preview/PreviewView.java index 694d2bc11..1ca08e3d5 100644 --- a/flutter-idea/src/io/flutter/preview/PreviewView.java +++ b/flutter-idea/src/io/flutter/preview/PreviewView.java @@ -36,7 +36,6 @@ import com.intellij.ui.speedSearch.SpeedSearchUtil; import com.intellij.ui.treeStructure.Tree; import com.intellij.util.messages.MessageBusConnection; -import io.flutter.FlutterInitializer; import io.flutter.FlutterUtils; import io.flutter.dart.FlutterDartAnalysisServer; import io.flutter.dart.FlutterOutlineListener; @@ -324,8 +323,6 @@ private void jumpToOutlineInEditor(FlutterOutline outline, boolean focusEditor) final int offset = outline.getDartElement() != null ? outline.getDartElement().getLocation().getOffset() : outline.getOffset(); final int editorOffset = getOutlineOffsetConverter().getConvertedFileOffset(offset); - sendAnalyticEvent("jumpToSource"); - if (currentFile != null) { currentEditor.getCaretModel().removeCaretListener(caretListener); try { @@ -639,10 +636,6 @@ private static void doLayoutRecursively(Component component) { } } - private void sendAnalyticEvent(@NotNull String name) { - FlutterInitializer.getAnalytics().sendEvent("preview", name); - } - private class ShowOnlyWidgetsAction extends AnAction implements Toggleable, RightAlignedToolbarAction { ShowOnlyWidgetsAction() { super("Show Only Widgets", "Show only widgets", AllIcons.General.Filter); diff --git a/flutter-idea/src/io/flutter/preview/WidgetEditToolbar.java b/flutter-idea/src/io/flutter/preview/WidgetEditToolbar.java index 9a2fa80bf..4dac30c92 100644 --- a/flutter-idea/src/io/flutter/preview/WidgetEditToolbar.java +++ b/flutter-idea/src/io/flutter/preview/WidgetEditToolbar.java @@ -19,7 +19,6 @@ import com.jetbrains.lang.dart.assists.AssistUtils; import com.jetbrains.lang.dart.assists.DartSourceEditException; import icons.FlutterIcons; -import io.flutter.FlutterInitializer; import io.flutter.FlutterMessages; import io.flutter.dart.FlutterDartAnalysisServer; import io.flutter.inspector.InspectorGroupManagerService; @@ -56,7 +55,6 @@ private class QuickAssistAction extends AnAction { @Override public void actionPerformed(@NotNull AnActionEvent e) { - sendAnalyticEvent(id); final SourceChange change; synchronized (actionToChangeMap) { change = actionToChangeMap.get(this); @@ -318,10 +316,6 @@ FlutterOutline getWidgetOutline() { return null; } - private void sendAnalyticEvent(@NotNull String name) { - FlutterInitializer.getAnalytics().sendEvent("preview", name); - } - private void applyChangeAndShowException(SourceChange change) { ApplicationManager.getApplication().runWriteAction(() -> { try { diff --git a/flutter-idea/src/io/flutter/run/FlutterPositionMapper.java b/flutter-idea/src/io/flutter/run/FlutterPositionMapper.java index 4c01bd8ce..49fde9a4c 100644 --- a/flutter-idea/src/io/flutter/run/FlutterPositionMapper.java +++ b/flutter-idea/src/io/flutter/run/FlutterPositionMapper.java @@ -23,10 +23,7 @@ import com.jetbrains.lang.dart.util.DartResolveUtil; import com.jetbrains.lang.dart.util.DartUrlResolver; import gnu.trove.THashMap; -import io.flutter.FlutterInitializer; import io.flutter.FlutterUtils; -import io.flutter.analytics.Analytics; -import io.flutter.bazel.WorkspaceCache; import io.flutter.dart.DartPlugin; import io.flutter.vmService.DartVmServiceDebugProcess; import org.dartlang.vm.service.element.LibraryRef; @@ -41,7 +38,6 @@ import java.util.Map; import java.util.Set; import java.util.concurrent.CompletableFuture; -import java.util.concurrent.TimeUnit; /** * Converts positions between Dart files in Observatory and local Dart files. @@ -208,10 +204,6 @@ public Collection getBreakpointUris(@NotNull final VirtualFile file) { results.add(threeSlashize(new File(file.getPath()).toURI().toString())); } - if (project != null && !project.isDisposed() && WorkspaceCache.getInstance(project).isBazel()) { - FlutterInitializer.getAnalytics().sendEvent("breakpoint", analyzer == null ? "analyzer-found" : "analyzer-null"); - } - // package: (if applicable) if (analyzer != null) { final String uriByServer = analyzer.getUri(file.getPath()); @@ -343,23 +335,6 @@ protected VirtualFile findLocalFile(@NotNull String uri, CompletableFuture { if (project.isDisposed()) { return; diff --git a/flutter-idea/src/io/flutter/run/SdkFields.java b/flutter-idea/src/io/flutter/run/SdkFields.java index 7ff413229..30e80a659 100644 --- a/flutter-idea/src/io/flutter/run/SdkFields.java +++ b/flutter-idea/src/io/flutter/run/SdkFields.java @@ -19,7 +19,6 @@ import com.jetbrains.lang.dart.sdk.DartConfigurable; import com.jetbrains.lang.dart.sdk.DartSdk; import io.flutter.FlutterBundle; -import io.flutter.FlutterInitializer; import io.flutter.dart.DartPlugin; import io.flutter.pub.PubRoot; import io.flutter.pub.PubRootCache; @@ -230,13 +229,9 @@ public GeneralCommandLine createFlutterSdkRunCommand( }, "Starting DevTools", false, project); final DevToolsInstance instance = devToolsFuture.get(); args = ArrayUtil.append(args, "--devtools-server-address=http://" + instance.host + ":" + instance.port); - if (firstRun) { - FlutterInitializer.getAnalytics().sendEvent("devtools", "first-run-success"); - } } catch (Exception e) { LOG.info(e); - FlutterInitializer.getAnalytics().sendExpectedException("devtools", e); } } command = flutterSdk.flutterRun(root, main.getFile(), device, runMode, flutterLaunchMode, project, args); diff --git a/flutter-idea/src/io/flutter/run/daemon/DaemonConsoleView.java b/flutter-idea/src/io/flutter/run/daemon/DaemonConsoleView.java index 247ad274e..53388cfdc 100644 --- a/flutter-idea/src/io/flutter/run/daemon/DaemonConsoleView.java +++ b/flutter-idea/src/io/flutter/run/daemon/DaemonConsoleView.java @@ -18,9 +18,6 @@ import com.intellij.psi.search.GlobalSearchScope; import com.intellij.psi.search.GlobalSearchScopes; import com.jetbrains.lang.dart.ide.runner.DartRelativePathsConsoleFilter; -import io.flutter.FlutterInitializer; -import io.flutter.analytics.Analytics; -import io.flutter.bazel.WorkspaceCache; import io.flutter.settings.FlutterSettings; import io.flutter.utils.FlutterModuleUtils; import io.flutter.utils.StdoutJsonParser; @@ -31,7 +28,6 @@ */ public class DaemonConsoleView extends ConsoleViewImpl { private static final Logger LOG = Logger.getInstance(DaemonConsoleView.class); - private final Analytics analytics = FlutterInitializer.getAnalytics(); /** * Sets up a launcher to use a DaemonConsoleView. @@ -74,12 +70,6 @@ public void print(@NotNull String text, @NotNull ConsoleViewContentType contentT if (contentType != ConsoleViewContentType.NORMAL_OUTPUT) { writeAvailableLines(); - - // TODO(helin24): We want to log only disconnection messages, but we aren't sure what those are yet. - // Until then, only log error messages for internal users. - if (WorkspaceCache.getInstance(getProject()).isBazel() && contentType.equals(ConsoleViewContentType.ERROR_OUTPUT) && !text.isEmpty()) { - analytics.sendEvent("potential-disconnect", text); - } super.print(text, contentType); } else { diff --git a/flutter-idea/src/io/flutter/run/daemon/DevToolsService.java b/flutter-idea/src/io/flutter/run/daemon/DevToolsService.java index 2dba7569e..1934ce86b 100644 --- a/flutter-idea/src/io/flutter/run/daemon/DevToolsService.java +++ b/flutter-idea/src/io/flutter/run/daemon/DevToolsService.java @@ -24,7 +24,6 @@ import com.jetbrains.lang.dart.ide.devtools.DartDevToolsService; import com.jetbrains.lang.dart.ide.toolingDaemon.DartToolingDaemonService; import com.jetbrains.lang.dart.sdk.DartSdk; -import io.flutter.FlutterInitializer; import io.flutter.FlutterUtils; import io.flutter.bazel.Workspace; import io.flutter.bazel.WorkspaceCache; @@ -412,7 +411,6 @@ private void logExceptionAndComplete(String message) { private void logExceptionAndComplete(Exception exception) { LOG.info(exception); - FlutterInitializer.getAnalytics().sendExpectedException("devtools-service", exception); final CompletableFuture future = devToolsFutureRef.get(); if (future != null) { future.completeExceptionally(exception); diff --git a/flutter-idea/src/io/flutter/run/daemon/FlutterApp.java b/flutter-idea/src/io/flutter/run/daemon/FlutterApp.java index 6f179fbb1..e6482c280 100644 --- a/flutter-idea/src/io/flutter/run/daemon/FlutterApp.java +++ b/flutter-idea/src/io/flutter/run/daemon/FlutterApp.java @@ -28,7 +28,6 @@ import com.intellij.openapi.vfs.VirtualFile; import com.intellij.util.EventDispatcher; import com.intellij.util.concurrency.AppExecutorUtil; -import io.flutter.FlutterInitializer; import io.flutter.FlutterMessages; import io.flutter.FlutterUtils; import io.flutter.ObservatoryConnector; @@ -268,11 +267,6 @@ public static FlutterApp start(@NotNull ExecutionEnvironment env, final ProcessHandler process = new MostlySilentColoredProcessHandler(command, onTextAvailable); Disposer.register(project, process::destroyProcess); - // Send analytics for the start and stop events. - if (analyticsStart != null) { - FlutterInitializer.sendAnalyticsAction(analyticsStart); - } - final DaemonApi api = new DaemonApi(process); final FlutterApp app = new FlutterApp(project, module, mode, device, process, env, api, command); @@ -280,21 +274,6 @@ public static FlutterApp start(@NotNull ExecutionEnvironment env, @Override public void processTerminated(@NotNull ProcessEvent event) { LOG.info(analyticsStop + " " + project.getName() + " (" + mode.mode() + ")"); - if (analyticsStop != null) { - FlutterInitializer.sendAnalyticsAction(analyticsStop); - } - - // Send analytics about whether this session used the reload workflow, the restart workflow, or neither. - final String workflowType = app.reloadCount > 0 ? "reload" : (app.restartCount > 0 ? "restart" : "none"); - FlutterInitializer.getAnalytics().sendEvent("workflow", workflowType); - - // Send the ratio of reloads to restarts. - int reloadfraction = 0; - if ((app.reloadCount + app.restartCount) > 0) { - final double fraction = (app.reloadCount * 100.0) / (app.reloadCount + app.restartCount); - reloadfraction = (int)Math.round(fraction); - } - FlutterInitializer.getAnalytics().sendEventMetric("workflow", "reloadFraction", reloadfraction); Disposer.dispose(app); } @@ -919,23 +898,6 @@ public void onAppProgressStarting(@NotNull DaemonEvent.AppProgress event) { @Override public void onAppProgressFinished(@NotNull DaemonEvent.AppProgress event) { progress.done(); - final Stopwatch watch = stopwatch.getAndSet(null); - if (watch != null) { - watch.stop(); - switch (event.getType()) { - case "hot.reload": - reportElapsed(watch, "Reloaded", "reload"); - break; - case "hot.restart": - reportElapsed(watch, "Restarted", "restart"); - break; - } - } - } - - private void reportElapsed(@NotNull Stopwatch watch, String verb, String analyticsName) { - final long elapsedMs = watch.elapsed(TimeUnit.MILLISECONDS); - FlutterInitializer.getAnalytics().sendTiming("run", analyticsName, elapsedMs); } @Override diff --git a/flutter-idea/src/io/flutter/sdk/FlutterCommand.java b/flutter-idea/src/io/flutter/sdk/FlutterCommand.java index 9ae0bf030..dad94481e 100644 --- a/flutter-idea/src/io/flutter/sdk/FlutterCommand.java +++ b/flutter-idea/src/io/flutter/sdk/FlutterCommand.java @@ -15,7 +15,6 @@ import com.intellij.openapi.util.io.FileUtil; import com.intellij.openapi.vfs.VirtualFile; import io.flutter.FlutterBundle; -import io.flutter.FlutterInitializer; import io.flutter.FlutterMessages; import io.flutter.android.IntelliJAndroidSdk; import io.flutter.console.FlutterConsoles; @@ -168,11 +167,7 @@ public ColoredProcessHandler startProcess(boolean sendAnalytics) { try { final GeneralCommandLine commandLine = createGeneralCommandLine(null); LOG.info(commandLine.toString()); - final ColoredProcessHandler handler = new ColoredProcessHandler(commandLine); - if (sendAnalytics) { - type.sendAnalyticsEvent(); - } - return handler; + return new ColoredProcessHandler(commandLine); } catch (ExecutionException e) { FlutterMessages.showError( @@ -209,7 +204,6 @@ public void processTerminated(@NotNull final ProcessEvent event) { } } }); - type.sendAnalyticsEvent(); return new FlutterCommandStartResult(handler); } catch (ExecutionException e) { @@ -294,10 +288,5 @@ enum Type { this.title = title; this.subCommand = ImmutableList.copyOf(subCommand); } - - void sendAnalyticsEvent() { - final String action = String.join("_", subCommand).replaceAll("-", ""); - FlutterInitializer.getAnalytics().sendEvent("flutter", action); - } } } diff --git a/flutter-idea/src/io/flutter/sdk/FlutterSettingsConfigurable.form b/flutter-idea/src/io/flutter/sdk/FlutterSettingsConfigurable.form index 1b08c8c65..c304e0c11 100644 --- a/flutter-idea/src/io/flutter/sdk/FlutterSettingsConfigurable.form +++ b/flutter-idea/src/io/flutter/sdk/FlutterSettingsConfigurable.form @@ -59,7 +59,7 @@ - + @@ -67,38 +67,18 @@ - - - - - - - - - - + - - - - - - - - - - - - + diff --git a/flutter-idea/src/io/flutter/sdk/FlutterSettingsConfigurable.java b/flutter-idea/src/io/flutter/sdk/FlutterSettingsConfigurable.java index 8da41c57c..3dc315380 100644 --- a/flutter-idea/src/io/flutter/sdk/FlutterSettingsConfigurable.java +++ b/flutter-idea/src/io/flutter/sdk/FlutterSettingsConfigurable.java @@ -63,7 +63,6 @@ public class FlutterSettingsConfigurable implements SearchableConfigurable { private JPanel mainPanel; private ComboboxWithBrowseButton mySdkCombo; private JBLabel myVersionLabel; - private JCheckBox myReportUsageInformationCheckBox; private LinkLabel myPrivacyPolicy; private JCheckBox myHotReloadOnSaveCheckBox; private JCheckBox myEnableVerboseLoggingCheckBox; @@ -198,10 +197,6 @@ public boolean isModified() { return true; } - if (FlutterInitializer.getCanReportAnalytics() != myReportUsageInformationCheckBox.isSelected()) { - return true; - } - if (settings.isReloadOnSave() != myHotReloadOnSaveCheckBox.isSelected()) { return true; } @@ -304,8 +299,6 @@ public void apply() throws ConfigurationException { } } - FlutterInitializer.setCanReportAnalytics(myReportUsageInformationCheckBox.isSelected()); - final FlutterSettings settings = FlutterSettings.getInstance(); final String oldFontPackages = settings.getFontPackages(); settings.setReloadOnSave(myHotReloadOnSaveCheckBox.isSelected()); @@ -370,8 +363,6 @@ public void reset() { previousSdkVersion = null; } - myReportUsageInformationCheckBox.setSelected(FlutterInitializer.getCanReportAnalytics()); - final FlutterSettings settings = FlutterSettings.getInstance(); myHotReloadOnSaveCheckBox.setSelected(settings.isReloadOnSave()); myFormatCodeOnSaveCheckBox.setSelected(settings.isFormatCodeOnSave()); diff --git a/flutter-idea/src/io/flutter/settings/FlutterSettings.java b/flutter-idea/src/io/flutter/settings/FlutterSettings.java index 4619a5dbf..2f20c8e1d 100644 --- a/flutter-idea/src/io/flutter/settings/FlutterSettings.java +++ b/flutter-idea/src/io/flutter/settings/FlutterSettings.java @@ -11,7 +11,6 @@ import com.intellij.openapi.util.registry.Registry; import com.intellij.util.EventDispatcher; import com.jetbrains.lang.dart.analyzer.DartClosingLabelManager; -import io.flutter.analytics.Analytics; import java.util.EventListener; @@ -79,80 +78,6 @@ public interface Listener extends EventListener { public FlutterSettings() { } - public void sendSettingsToAnalytics(Analytics analytics) { - - // Send data on the number of experimental features enabled by users. - analytics.sendEvent("settings", "ping"); - - if (isReloadOnSave()) { - analytics.sendEvent("settings", afterLastPeriod(reloadOnSaveKey)); - } - - if (isOpenInspectorOnAppLaunch()) { - analytics.sendEvent("settings", afterLastPeriod(openInspectorOnAppLaunchKey)); - } - - if (isPerserveLogsDuringHotReloadAndRestart()) { - analytics.sendEvent("settings", afterLastPeriod(perserveLogsDuringHotReloadAndRestartKey)); - } - - if (isFormatCodeOnSave()) { - analytics.sendEvent("settings", afterLastPeriod(formatCodeOnSaveKey)); - - if (isOrganizeImportsOnSave()) { - analytics.sendEvent("settings", afterLastPeriod(organizeImportsOnSaveKey)); - } - } - - if (isShowOnlyWidgets()) { - analytics.sendEvent("settings", afterLastPeriod(showOnlyWidgetsKey)); - } - - if (isSyncingAndroidLibraries()) { - analytics.sendEvent("settings", afterLastPeriod(syncAndroidLibrariesKey)); - } - - if (isShowBuildMethodGuides()) { - analytics.sendEvent("settings", afterLastPeriod(showBuildMethodGuidesKey)); - } - - if (isShowStructuredErrors()) { - analytics.sendEvent("settings", afterLastPeriod(showStructuredErrorsKey)); - - if (isIncludeAllStackTraces()) { - analytics.sendEvent("settings", afterLastPeriod(includeAllStackTracesKey)); - } - } - - if (showAllRunConfigurationsInContext()) { - analytics.sendEvent("settings", "showAllRunConfigurations"); - } - - if (isEnableHotUi()) { - analytics.sendEvent("settings", afterLastPeriod(enableHotUiKey)); - } - - if (isShowBazelHotRestartWarning()) { - analytics.sendEvent("settings", afterLastPeriod(showBazelHotRestartWarningKey)); - } - - if (isChangeBigSurToTrue()) { - analytics.sendEvent("settings", afterLastPeriod(changeBigSurToTrueKey)); - } - - if (isAllowTestsInSourcesRoot()) { - analytics.sendEvent("settings", afterLastPeriod(allowTestsInSourcesRootKey)); - } - - if (!getFontPackages().isEmpty()) { - analytics.sendEvent("settings", afterLastPeriod(fontPackagesKey)); - } - - if (isShowBazelIosRunNotification()) { - analytics.sendEvent("settings", afterLastPeriod(showBazelIosRunNotificationKey)); - } - } - public void addListener(Listener listener) { dispatcher.addListener(listener); } diff --git a/flutter-idea/src/io/flutter/survey/FlutterSurveyNotifications.java b/flutter-idea/src/io/flutter/survey/FlutterSurveyNotifications.java index ad4496f5f..e5a912fda 100644 --- a/flutter-idea/src/io/flutter/survey/FlutterSurveyNotifications.java +++ b/flutter-idea/src/io/flutter/survey/FlutterSurveyNotifications.java @@ -19,7 +19,6 @@ import com.intellij.openapi.vfs.VirtualFile; import com.jetbrains.lang.dart.DartFileType; import icons.FlutterIcons; -import io.flutter.FlutterInitializer; import io.flutter.FlutterMessages; import io.flutter.pub.PubRoot; import org.jetbrains.annotations.NotNull; @@ -88,8 +87,6 @@ private void checkForDisplaySurvey() { // Or, if the survey has already been taken. if (properties.getBoolean(survey.uniqueId)) return; - final boolean reportAnalytics = FlutterInitializer.getCanReportAnalytics(); - final Notification notification = new Notification( FlutterMessages.FLUTTER_NOTIFICATION_GROUP_ID, FlutterIcons.Flutter, @@ -108,11 +105,6 @@ public void actionPerformed(@NotNull AnActionEvent event) { notification.expire(); String url = survey.urlPrefix + "?Source=IntelliJ"; - // Add a client ID if analytics have been opted into. - if (reportAnalytics) { - FlutterInitializer.getAnalytics().sendEvent("intellij", "SurveyPromptAccepted"); - } - BrowserUtil.browse(url); } }); @@ -121,9 +113,6 @@ public void actionPerformed(@NotNull AnActionEvent event) { notification.addAction(new AnAction(SURVEY_DISMISSAL_TEXT) { @Override public void actionPerformed(@NotNull AnActionEvent event) { - if (reportAnalytics) { - FlutterInitializer.getAnalytics().sendEvent("intellij", "SurveyPromptDismissed"); - } properties.setValue(survey.uniqueId, true); notification.expire(); } @@ -133,9 +122,6 @@ public void actionPerformed(@NotNull AnActionEvent event) { final ScheduledExecutorService scheduler = Executors.newSingleThreadScheduledExecutor(); scheduler.schedule(() -> { if (!myProject.isDisposed()) { - if (reportAnalytics) { - FlutterInitializer.getAnalytics().sendEvent("intellij", "SurveyPromptShown"); - } Notifications.Bus.notify(notification, myProject); } }, NOTIFICATION_DELAY_IN_SECS, TimeUnit.SECONDS); diff --git a/flutter-idea/src/io/flutter/utils/MostlySilentColoredProcessHandler.java b/flutter-idea/src/io/flutter/utils/MostlySilentColoredProcessHandler.java index 8350a5d16..4cf88a8db 100644 --- a/flutter-idea/src/io/flutter/utils/MostlySilentColoredProcessHandler.java +++ b/flutter-idea/src/io/flutter/utils/MostlySilentColoredProcessHandler.java @@ -13,7 +13,6 @@ import com.intellij.openapi.util.Key; import com.intellij.openapi.util.SystemInfo; import com.intellij.util.io.BaseOutputReader; -import io.flutter.FlutterInitializer; import org.jetbrains.annotations.NotNull; import java.util.function.Consumer; @@ -63,7 +62,6 @@ protected void doDestroyProcess() { if (SystemInfo.isUnix && shouldDestroyProcessRecursively() && processCanBeKilledByOS(process)) { final boolean result = UnixProcessManager.sendSigIntToProcessTree(process); if (!result) { - FlutterInitializer.getAnalytics().sendEvent("process", "process kill failed"); super.doDestroyProcess(); } } diff --git a/flutter-idea/src/io/flutter/view/EmbeddedBrowser.java b/flutter-idea/src/io/flutter/view/EmbeddedBrowser.java index 40d41ce61..96649b130 100644 --- a/flutter-idea/src/io/flutter/view/EmbeddedBrowser.java +++ b/flutter-idea/src/io/flutter/view/EmbeddedBrowser.java @@ -18,8 +18,6 @@ import com.intellij.ui.content.ContentManager; import com.intellij.util.ui.JBUI; import icons.FlutterIcons; -import io.flutter.FlutterInitializer; -import io.flutter.analytics.Analytics; import io.flutter.devtools.DevToolsUrl; import io.flutter.utils.AsyncUtils; import io.flutter.utils.LabelInput; @@ -54,12 +52,9 @@ public abstract class EmbeddedBrowser { public abstract Logger logger(); - private final Analytics analytics; - private DevToolsUrl url; public EmbeddedBrowser(Project project) { - this.analytics = FlutterInitializer.getAnalytics(); ProjectManager.getInstance().addProjectManagerListener(project, new ProjectManagerListener() { @Override public void projectClosing(@NotNull Project project) { @@ -93,7 +88,6 @@ public void openPanel(ToolWindow toolWindow, String tabName, DevToolsUrl devTool tabs.put(tabName, openBrowserTabFor(tabName, toolWindow)); } catch (Exception ex) { - analytics.sendEvent(ANALYTICS_CATEGORY, "openBrowserTabFailed-" + this.getClass()); onBrowserUnavailable.accept(ex.getMessage()); return; } @@ -289,7 +283,6 @@ private void updateUrlAndReload(Function newDevToolsUr AsyncUtils.whenCompleteUiThread(updatedUrlFuture, (devToolsUrl, ex) -> { if (ex != null) { logger().info(ex); - FlutterInitializer.getAnalytics().sendExpectedException("browser-update", ex); return; } if (devToolsUrl == null) { diff --git a/flutter-idea/src/io/flutter/view/FlutterView.java b/flutter-idea/src/io/flutter/view/FlutterView.java index 9415eff57..9ddfd56a5 100644 --- a/flutter-idea/src/io/flutter/view/FlutterView.java +++ b/flutter-idea/src/io/flutter/view/FlutterView.java @@ -29,7 +29,6 @@ import com.intellij.util.ui.UIUtil; import com.intellij.xdebugger.XSourcePosition; import io.flutter.FlutterBundle; -import io.flutter.FlutterInitializer; import io.flutter.FlutterUtils; import io.flutter.actions.RefreshToolWindowAction; import io.flutter.bazel.WorkspaceCache; @@ -386,8 +385,6 @@ protected void waitForJxBrowserInstallation(FlutterApp app, ToolWindow toolWindo } catch (TimeoutException e) { presentOpenDevToolsOptionWithMessage(app, toolWindow, INSTALLATION_TIMED_OUT_LABEL, ideFeature); - - FlutterInitializer.getAnalytics().sendEvent(JxBrowserManager.ANALYTICS_CATEGORY, "timedOut"); } } diff --git a/flutter-idea/src/io/flutter/view/FlutterViewAction.java b/flutter-idea/src/io/flutter/view/FlutterViewAction.java index d7419b207..bfd93a717 100644 --- a/flutter-idea/src/io/flutter/view/FlutterViewAction.java +++ b/flutter-idea/src/io/flutter/view/FlutterViewAction.java @@ -7,7 +7,6 @@ import com.intellij.openapi.actionSystem.AnActionEvent; import com.intellij.openapi.project.DumbAwareAction; -import io.flutter.FlutterInitializer; import io.flutter.run.daemon.FlutterApp; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -31,7 +30,6 @@ public abstract class FlutterViewAction extends DumbAwareAction { @Override public void actionPerformed(@NotNull AnActionEvent e) { - FlutterInitializer.sendAnalyticsAction(this); perform(e); } diff --git a/flutter-idea/src/io/flutter/vmService/DartVmServiceDebugProcess.java b/flutter-idea/src/io/flutter/vmService/DartVmServiceDebugProcess.java index a3ef45cfa..7f4ad1de2 100644 --- a/flutter-idea/src/io/flutter/vmService/DartVmServiceDebugProcess.java +++ b/flutter-idea/src/io/flutter/vmService/DartVmServiceDebugProcess.java @@ -36,7 +36,6 @@ import gnu.trove.THashMap; import gnu.trove.TIntObjectHashMap; import io.flutter.FlutterBundle; -import io.flutter.FlutterInitializer; import io.flutter.FlutterUtils; import io.flutter.ObservatoryConnector; import io.flutter.run.FlutterLaunchMode; @@ -466,7 +465,6 @@ private String formatStackTraces(Throwable e) { } private void onConnectFailed(@NotNull String message) { - FlutterInitializer.getAnalytics().sendException(message, false); if (!message.endsWith("\n")) { message = message + "\n"; } diff --git a/flutter-idea/src/io/flutter/vmService/VmServiceWrapper.java b/flutter-idea/src/io/flutter/vmService/VmServiceWrapper.java index 18e6b3076..117cb8986 100644 --- a/flutter-idea/src/io/flutter/vmService/VmServiceWrapper.java +++ b/flutter-idea/src/io/flutter/vmService/VmServiceWrapper.java @@ -23,8 +23,6 @@ import com.intellij.xdebugger.frame.XStackFrame; import com.intellij.xdebugger.impl.XDebugSessionImpl; import com.jetbrains.lang.dart.DartFileType; -import io.flutter.FlutterInitializer; -import io.flutter.analytics.Analytics; import io.flutter.bazel.WorkspaceCache; import io.flutter.run.daemon.FlutterApp; import io.flutter.sdk.FlutterSdk; @@ -420,9 +418,6 @@ public void received(Isolate response) { } } - Analytics analytics = FlutterInitializer.getAnalytics(); - String category = "breakpoint"; - Sets.SetView initialDifference = Sets.difference(canonicalBreakpoints, mappedCanonicalBreakpoints); Set finalDifference = new HashSet<>(); @@ -434,29 +429,14 @@ public void received(Isolate response) { finalDifference.add(missingBreakpoint); } } - - analytics.sendEventMetric(category, "unmapped-count", finalDifference.size()); - - // TODO(helin24): Get rid of this and instead track unmapped files in addBreakpoint? - // For internal bazel projects, report files where mapping failed. - if (WorkspaceCache.getInstance(myDebugProcess.getSession().getProject()).isBazel()) { - for (CanonicalBreakpoint canonicalBreakpoint : finalDifference) { - if (canonicalBreakpoint.path.contains("google3")) { - analytics.sendEvent(category, - String.format("unmapped-file|%s|%s", response.getRootLib().getUri(), canonicalBreakpoint.path)); - } - } - } } @Override public void received(Sentinel response) { - } @Override public void onError(RPCError error) { - } }); } @@ -584,17 +564,6 @@ public void received(UriList response) { JsonObject error = new JsonObject(); error.addProperty("error", "Breakpoint could not be mapped to package URI"); errorResponses.add(new RPCError(error)); - - Analytics analytics = FlutterInitializer.getAnalytics(); - String category = "breakpoint"; - - // For internal bazel projects, report files where mapping failed. - if (WorkspaceCache.getInstance(myDebugProcess.getSession().getProject()).isBazel()) { - if (resolvedUri.contains("google3")) { - analytics.sendEvent(category, String.format("no-package-uri|%s", resolvedUri)); - } - } - consumer.received(breakpointResponses, errorResponses); return; } diff --git a/flutter-idea/testSrc/unit/io/flutter/analytics/AnalyticsTest.java b/flutter-idea/testSrc/unit/io/flutter/analytics/AnalyticsTest.java deleted file mode 100644 index cda4020d3..000000000 --- a/flutter-idea/testSrc/unit/io/flutter/analytics/AnalyticsTest.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright 2016 The Chromium Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ -package io.flutter.analytics; - -import org.junit.Before; -import org.junit.Test; - -import java.io.PrintWriter; -import java.io.StringWriter; - -import static org.junit.Assert.assertEquals; - -public class AnalyticsTest { - private Analytics analytics; - private MockAnalyticsTransport transport; - - @Before - public void setUp() { - transport = new MockAnalyticsTransport(); - - analytics = new Analytics("123e4567-e89b-12d3-a456-426655440000", "1.0", "IntelliJ CE", "2016.3.2"); - analytics.setTransport(transport); - analytics.setCanSend(true); - } - - @Test - public void testSendScreenView() { - analytics.sendScreenView("testAnalyticsPage"); - assertEquals(1, transport.sentValues.size()); - } - - @Test - public void testSendEvent() { - analytics.sendEvent("flutter", "doctor"); - assertEquals(1, transport.sentValues.size()); - } - - @Test - public void testSendTiming() { - analytics.sendTiming("perf", "reloadTime", 100); - assertEquals(1, transport.sentValues.size()); - } - - @Test - public void testSendException() { - final Throwable throwable = new UnsupportedOperationException("test operation"); - final StringWriter stringWriter = new StringWriter(); - final PrintWriter printWriter = new PrintWriter(stringWriter); - throwable.printStackTrace(printWriter); - - analytics.sendException(stringWriter.toString().trim(), true); - assertEquals(1, transport.sentValues.size()); - } - - @Test - public void testOptOutDoesntSend() { - analytics.setCanSend(false); - analytics.sendScreenView("testAnalyticsPage"); - assertEquals(0, transport.sentValues.size()); - } -} diff --git a/flutter-idea/testSrc/unit/io/flutter/analytics/FlutterAnalysisServerListenerTest.java b/flutter-idea/testSrc/unit/io/flutter/analytics/FlutterAnalysisServerListenerTest.java deleted file mode 100644 index 57c1a6695..000000000 --- a/flutter-idea/testSrc/unit/io/flutter/analytics/FlutterAnalysisServerListenerTest.java +++ /dev/null @@ -1,285 +0,0 @@ -/* - * Copyright 2022 The Chromium Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ -package io.flutter.analytics; - -import com.intellij.codeInsight.completion.PrefixMatcher; -import com.intellij.codeInsight.lookup.*; -import com.intellij.codeInsight.lookup.impl.LookupImpl; -import com.intellij.openapi.editor.Editor; -import com.intellij.openapi.project.Project; -import com.intellij.psi.PsiFile; -import com.intellij.psi.PsiManager; -import com.intellij.testFramework.fixtures.CodeInsightTestFixture; -import com.jetbrains.lang.dart.analyzer.DartAnalysisServerService; -import com.jetbrains.lang.dart.fixes.DartQuickFix; -import com.jetbrains.lang.dart.fixes.DartQuickFixSet; -import io.flutter.FlutterInitializer; -import io.flutter.testing.CodeInsightProjectFixture; -import io.flutter.testing.Testing; -import org.dartlang.analysis.server.protocol.AnalysisError; -import org.dartlang.analysis.server.protocol.AnalysisStatus; -import org.dartlang.analysis.server.protocol.PubStatus; -import org.dartlang.analysis.server.protocol.RequestError; -import org.jetbrains.annotations.NotNull; -import org.junit.*; - -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -import static io.flutter.analytics.Analytics.TIMING_COMPLETE; -import static io.flutter.analytics.FlutterAnalysisServerListener.*; -import static org.junit.Assert.*; - -@SuppressWarnings({"LocalCanBeFinal"}) -public class FlutterAnalysisServerListenerTest { - private static final String fileContents = """ - void main() { - group('group 1', () { - test('test 1', () {}); - }); - }"""; - - @Rule - public final @NotNull CodeInsightProjectFixture projectFixture = Testing.makeCodeInsightModule(); - - private @NotNull CodeInsightTestFixture innerFixture; - private @NotNull Project project; - private @NotNull PsiFile mainFile; - private @NotNull MockAnalyticsTransport transport; - private @NotNull Analytics analytics; - private @NotNull FlutterAnalysisServerListener fasl; - - @SuppressWarnings("ConstantConditions") - @Before - public void setUp() { - assert projectFixture.getInner() != null; - innerFixture = projectFixture.getInner(); - assert innerFixture != null; - project = innerFixture.getProject(); - assert project != null; - mainFile = innerFixture.addFileToProject("lib/main.dart", fileContents); - transport = new MockAnalyticsTransport(); - analytics = new Analytics("123e4567-e89b-12d3-a456-426655440000", "1.0", "IntelliJ CE", "2021.3.2"); - analytics.setTransport(transport); - analytics.setCanSend(true); - FlutterInitializer.setAnalytics(analytics); - fasl = FlutterAnalysisServerListener.getInstance(project); - } - - @After - public void tearDown() { - fasl.dispose(); - } - - @Test @Ignore - public void requestError() throws Exception { - RequestError error = new RequestError("101", "error", "trace"); - fasl.requestError(error); - assertEquals(1, transport.sentValues.size()); - Map map = transport.sentValues.get(0); - assertNotNull(map.get("exd")); - assertTrue(map.get("exd").endsWith("trace")); - assertTrue(map.get("exd").startsWith("R 101")); - } - - @Test @Ignore - public void requestErrorNoCode() throws Exception { - RequestError error = new RequestError(null, "error", "trace"); - fasl.requestError(error); - assertEquals(1, transport.sentValues.size()); - Map map = transport.sentValues.get(0); - assertNotNull(map.get("exd")); - assertTrue(map.get("exd").endsWith("trace")); - assertTrue(map.get("exd").startsWith("R error")); - } - - @Test @Ignore - public void serverError() throws Exception { - fasl.serverError(true, "message", "trace"); - assertEquals(1, transport.sentValues.size()); - Map map = transport.sentValues.get(0); - assertNotNull(map.get("exd")); - assertEquals("1", map.get("'exf'")); // extra quotes since 2016 - assertTrue(map.get("exd").endsWith("trace")); - assertTrue(map.get("exd").contains("message")); - } - - @Test @Ignore - public void acceptedCompletion() throws Exception { - Editor editor = editor(); - Testing.runOnDispatchThread(() -> { - editor.getSelectionModel().setSelection(18, 18); - fasl.setLookupSelectionHandler(); - LookupImpl lookup = new LookupImpl(project, editor, new LookupArranger.DefaultArranger()); - LookupItem item = new LookupItem(LookupItem.TYPE_TEXT_ATTR, "gr"); - lookup.addItem(item, PrefixMatcher.ALWAYS_TRUE); - lookup.addLookupListener(fasl.lookupSelectionHandler); - LookupEvent lookupEvent = new LookupEvent(lookup, item, 'o'); - fasl.lookupSelectionHandler.itemSelected(lookupEvent); - }); - assertEquals(1, transport.sentValues.size()); - Map map = transport.sentValues.get(0); - assertEquals(ACCEPTED_COMPLETION, map.get("ec")); - assertEquals("gr", map.get("ea")); - assertEquals("0", map.get("ev")); - } - - @Test @Ignore - public void lookupCanceled() throws Exception { - Editor editor = editor(); - Testing.runOnDispatchThread(() -> { - editor.getSelectionModel().setSelection(18, 18); - fasl.setLookupSelectionHandler(); - LookupImpl lookup = new LookupImpl(project, editor, new LookupArranger.DefaultArranger()); - LookupItem item = new LookupItem(LookupItem.TYPE_TEXT_ATTR, "gr"); - lookup.addItem(item, PrefixMatcher.ALWAYS_TRUE); - lookup.addLookupListener(fasl.lookupSelectionHandler); - LookupEvent lookupEvent = new LookupEvent(lookup, true); - fasl.lookupSelectionHandler.lookupCanceled(lookupEvent); - assertEquals(1, transport.sentValues.size()); - Map map = transport.sentValues.get(0); - assertEquals(REJECTED_COMPLETION, map.get("ec")); - assertEquals(UNKNOWN_LOOKUP_STRING, map.get("ea")); - }); - } - - @Test @Ignore - public void computedErrors() throws Exception { - editor(); // Ensure file is open. - String path = mainFile.getVirtualFile().getPath(); - List list = new ArrayList<>(); - list.add(new AnalysisError("ERROR", "", null, "", "", "101", "", null, false)); - fasl.computedErrors(path, list); - assertEquals(1, transport.sentValues.size()); - Map map = transport.sentValues.get(0); - assertNotNull(map.get("ev")); - assertEquals(DURATION, map.get("ea")); - assertEquals(INITIAL_COMPUTE_ERRORS_TIME, map.get("ec")); - } - - @SuppressWarnings("ConstantConditions") - @Test @Ignore - public void serverStatus() throws Exception { - fasl.serverStatus(new AnalysisStatus(false, null), new PubStatus(false)); - assertEquals(4, transport.sentValues.size()); - checkStatus(transport.sentValues.get(0), ERRORS, "1"); - checkStatus(transport.sentValues.get(1), WARNINGS, "1"); - checkStatus(transport.sentValues.get(2), HINTS, "1"); - checkStatus(transport.sentValues.get(3), LINTS, "1"); - } - - private void checkStatus(@NotNull Map map, String label, String value) { - assertEquals("analysisServerStatus", map.get("ec")); - assertEquals(label, map.get("ea")); - assertEquals(value, map.get("ev")); - } - - @Test @Ignore - public void quickFix() throws Exception { - Editor editor = editor(); - DartAnalysisServerService analysisServer = DartAnalysisServerService.getInstance(project); - PsiManager manager = PsiManager.getInstance(project); - DartQuickFixSet quickFixSet = new DartQuickFixSet(manager, mainFile.getVirtualFile(), 18, null); - DartQuickFix fix = new DartQuickFix(quickFixSet, 0); - analysisServer.fireBeforeQuickFixInvoked(fix, editor, mainFile); - assertEquals(1, transport.sentValues.size()); - Map map = transport.sentValues.get(0); - assertEquals(QUICK_FIX, map.get("ec")); - assertEquals("", map.get("ea")); - assertEquals("0", map.get("ev")); - } - - @Test @Ignore - public void computedSearchResults() throws Exception { - fasl.requestListener.onRequest("{\"method\":\"" + FIND_REFERENCES + "\",\"id\":\"2\"}"); - fasl.responseListener.onResponse("{\"event\":\"none\",\"id\":\"2\"}"); - fasl.computedSearchResults("2", new ArrayList<>(), true); - assertEquals(1, transport.sentValues.size()); - Map map = transport.sentValues.get(0); - assertEquals(TIMING_COMPLETE, map.get("ea")); - assertEquals(ROUND_TRIP_TIME, map.get("ec")); - assertEquals(FIND_REFERENCES, map.get("el")); - String value = map.get("ev"); - assertNotNull(value); - assertTrue(0 <= Integer.parseInt(value)); - } - - @Test @Ignore - public void computedCompletion() throws Exception { - fasl.requestListener.onRequest("{\"method\":\"" + GET_SUGGESTIONS + "\",\"id\":\"2\"}"); - fasl.responseListener.onResponse("{\"event\":\"none\",\"id\":\"2\"}"); - List none = new ArrayList(); - fasl.computedCompletion("2", 0, 0, none, none, none, none, true, ""); - assertEquals(1, transport.sentValues.size()); - Map map = transport.sentValues.get(0); - assertEquals(TIMING_COMPLETE, map.get("ea")); - assertEquals(ROUND_TRIP_TIME, map.get("ec")); - assertEquals(GET_SUGGESTIONS, map.get("el")); - String value = map.get("ev"); - assertNotNull(value); - assertTrue(0 <= Integer.parseInt(value)); - } - - @Test @Ignore - public void dasListenerLogging() throws Exception { - fasl.requestListener.onRequest("{\"method\":\"test\",\"id\":\"2\"}"); - fasl.responseListener.onResponse("{\"event\":\"server.log\",\"params\":{\"entry\":{\"time\":\"1\",\"kind\":\"\",\"data\":\"\"}}}"); - assertEquals(1, transport.sentValues.size()); - Map map = transport.sentValues.get(0); - assertEquals(ANALYSIS_SERVER_LOG, map.get("ec")); - assertEquals("time|1|kind||data|", map.get("ea")); - } - - @Test @Ignore - public void dasListenerLoggingWithSdk() throws Exception { - fasl.requestListener.onRequest("{\"method\":\"test\",\"id\":\"2\"}"); - fasl.responseListener.onResponse("{\"event\":\"server.log\",\"params\":{\"entry\":{\"time\":\"1\",\"kind\":\"\",\"data\":\"\",\"sdkVersion\":\"1\"}}}"); - assertEquals(1, transport.sentValues.size()); - Map map = transport.sentValues.get(0); - assertEquals(ANALYSIS_SERVER_LOG, map.get("ec")); - assertEquals("time|1|kind||data|", map.get("ea")); - assertEquals("1", map.get("cd2")); - } - - @Test @Ignore - public void logE2ECompletionSuccessMS() throws Exception { - DartCompletionTimerListener dctl = new DartCompletionTimerListener(); - dctl.dasListener = fasl; - dctl.dartCompletionStart(); - dctl.dartCompletionEnd(); - assertEquals(1, transport.sentValues.size()); - Map map = transport.sentValues.get(0); - assertEquals(TIMING_COMPLETE, map.get("ea")); - assertEquals(E2E_IJ_COMPLETION_TIME, map.get("ec")); - assertEquals(SUCCESS, map.get("el")); - } - - @Test @Ignore - public void logE2ECompletionErrorMS() throws Exception { - DartCompletionTimerListener dctl = new DartCompletionTimerListener(); - dctl.dasListener = fasl; - dctl.dartCompletionStart(); - dctl.dartCompletionError("101", "message", "trace"); - assertEquals(1, transport.sentValues.size()); - Map map = transport.sentValues.get(0); - assertEquals(TIMING_COMPLETE, map.get("ea")); - assertEquals(E2E_IJ_COMPLETION_TIME, map.get("ec")); - assertEquals(FAILURE, map.get("el")); - String value = map.get("ev"); - assertNotNull(value); - assertTrue(0 <= Integer.parseInt(value)); - } - - @NotNull - private Editor editor() throws Exception{ - //noinspection ConstantConditions - Testing.runOnDispatchThread(() -> innerFixture.openFileInEditor(mainFile.getVirtualFile())); - Editor e = innerFixture.getEditor(); - assert e != null; - return e; - } -} diff --git a/flutter-idea/testSrc/unit/io/flutter/analytics/MockAnalyticsTransport.java b/flutter-idea/testSrc/unit/io/flutter/analytics/MockAnalyticsTransport.java deleted file mode 100644 index 1f88d979d..000000000 --- a/flutter-idea/testSrc/unit/io/flutter/analytics/MockAnalyticsTransport.java +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright 2020 The Chromium Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ -package io.flutter.analytics; - -import org.jetbrains.annotations.NotNull; - -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -public class MockAnalyticsTransport implements Analytics.Transport { - final public List> sentValues = new ArrayList<>(); - - @Override - public void send(@NotNull String url, @NotNull Map values) { - sentValues.add(values); - } -} diff --git a/flutter-idea/testSrc/unit/io/flutter/jxbrowser/JxBrowserManagerTest.java b/flutter-idea/testSrc/unit/io/flutter/jxbrowser/JxBrowserManagerTest.java index b3867287c..1434afe1e 100644 --- a/flutter-idea/testSrc/unit/io/flutter/jxbrowser/JxBrowserManagerTest.java +++ b/flutter-idea/testSrc/unit/io/flutter/jxbrowser/JxBrowserManagerTest.java @@ -5,7 +5,6 @@ */ package io.flutter.jxbrowser; -import io.flutter.analytics.Analytics; import io.flutter.utils.FileUtils; import io.flutter.utils.JxBrowserUtils; import org.junit.Assert; @@ -20,7 +19,6 @@ public class JxBrowserManagerTest { final String projectName = "projectName"; - final Analytics mockAnalytics = mock(Analytics.class); final String PLATFORM_FILE_NAME = "test/platform/file/name"; final String API_FILE_NAME = "test/api/file/name"; final String SWING_FILE_NAME = "test/swing/file/name"; @@ -36,7 +34,7 @@ public void testSetUpIfKeyNotFound() throws FileNotFoundException { when(mockUtils.getJxBrowserKey()).thenThrow(new FileNotFoundException("Key not found")); // If the directory for JxBrowser files cannot be created, the installation should fail. - final JxBrowserManager manager = new JxBrowserManager(mockUtils, mockAnalytics, mock(FileUtils.class)); + final JxBrowserManager manager = new JxBrowserManager(mockUtils, mock(FileUtils.class)); manager.setUp(projectName); Assert.assertEquals(JxBrowserStatus.INSTALLATION_FAILED, manager.getStatus()); @@ -51,7 +49,7 @@ public void testSetUpIfDirectoryFails() throws FileNotFoundException { when(mockFileUtils.makeDirectory(DOWNLOAD_PATH)).thenReturn(false); // If the directory for JxBrowser files cannot be created, the installation should fail. - final JxBrowserManager manager = new JxBrowserManager(mockUtils, mockAnalytics, mockFileUtils); + final JxBrowserManager manager = new JxBrowserManager(mockUtils, mockFileUtils); manager.setUp(projectName); Assert.assertEquals(JxBrowserStatus.INSTALLATION_FAILED, manager.getStatus()); @@ -67,7 +65,7 @@ public void testSetUpIfPlatformFileNotFound() throws FileNotFoundException { when(mockFileUtils.makeDirectory(DOWNLOAD_PATH)).thenReturn(true); // If the system platform is not found among JxBrowser files, then the installation should fail. - final JxBrowserManager manager = new JxBrowserManager(mockUtils, mockAnalytics, mockFileUtils); + final JxBrowserManager manager = new JxBrowserManager(mockUtils, mockFileUtils); manager.setUp(projectName); Assert.assertEquals(JxBrowserStatus.INSTALLATION_FAILED, manager.getStatus()); @@ -86,7 +84,7 @@ public void testSetUpIfAllFilesExist() throws FileNotFoundException { when(mockFileUtils.fileExists(anyString())).thenReturn(true); // If all of the files are already downloaded, we should load the existing files. - final JxBrowserManager manager = new JxBrowserManager(mockUtils, mockAnalytics, mockFileUtils); + final JxBrowserManager manager = new JxBrowserManager(mockUtils, mockFileUtils); manager.setUp(projectName); final String[] expectedFileNames = {PLATFORM_FILE_NAME, API_FILE_NAME, SWING_FILE_NAME}; @@ -110,7 +108,7 @@ public void testSetUpIfFilesMissing() throws FileNotFoundException { when(mockFileUtils.deleteFile(anyString())).thenReturn(true); // If any of our required files do not exist, we want to delete any existing files and start a download of all of the required files. - final JxBrowserManager manager = new JxBrowserManager(mockUtils, mockAnalytics, mockFileUtils); + final JxBrowserManager manager = new JxBrowserManager(mockUtils, mockFileUtils); final JxBrowserManager spy = spy(manager); final String[] expectedFileNames = {PLATFORM_FILE_NAME, API_FILE_NAME, SWING_FILE_NAME}; doNothing().when(spy).downloadJxBrowser(expectedFileNames); diff --git a/flutter-idea/testSrc/unit/io/flutter/logging/FlutterConsoleLogManagerTest.java b/flutter-idea/testSrc/unit/io/flutter/logging/FlutterConsoleLogManagerTest.java index b4282d382..b8c274f00 100644 --- a/flutter-idea/testSrc/unit/io/flutter/logging/FlutterConsoleLogManagerTest.java +++ b/flutter-idea/testSrc/unit/io/flutter/logging/FlutterConsoleLogManagerTest.java @@ -11,9 +11,6 @@ import com.intellij.execution.ui.ConsoleView; import com.intellij.execution.ui.ConsoleViewContentType; import com.intellij.openapi.actionSystem.AnAction; -import io.flutter.FlutterInitializer; -import io.flutter.analytics.Analytics; -import io.flutter.analytics.MockAnalyticsTransport; import io.flutter.run.FlutterDebugProcess; import io.flutter.run.daemon.FlutterApp; import io.flutter.settings.FlutterSettings; @@ -24,7 +21,6 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.junit.After; -import org.junit.Before; import org.junit.Test; import javax.swing.*; @@ -38,20 +34,6 @@ import static org.mockito.Mockito.when; public class FlutterConsoleLogManagerTest { - private Analytics analytics; - private MockAnalyticsTransport transport; - - @Before - public void setUp() { - transport = new MockAnalyticsTransport(); - - analytics = new Analytics("123e4567-e89b-12d3-a456-426655440000", "1.0", "IntelliJ CE", "2016.3.2"); - analytics.setTransport(transport); - analytics.setCanSend(false); - - FlutterInitializer.setAnalytics(analytics); - } - @After public void tearDown() { FlutterSettings.setInstance(null); diff --git a/flutter-studio/src/io/flutter/actions/OpenFlutterNewsSidePanelAction.java b/flutter-studio/src/io/flutter/actions/OpenFlutterNewsSidePanelAction.java index ce2a1f98c..997485615 100644 --- a/flutter-studio/src/io/flutter/actions/OpenFlutterNewsSidePanelAction.java +++ b/flutter-studio/src/io/flutter/actions/OpenFlutterNewsSidePanelAction.java @@ -27,7 +27,6 @@ import com.intellij.openapi.wm.ToolWindow; import com.intellij.openapi.wm.ToolWindowManager; import com.intellij.openapi.wm.ex.ToolWindowManagerListener; -import io.flutter.FlutterInitializer; import io.flutter.assistant.whatsnew.FlutterNewsBundleCreator; import java.util.HashMap; import java.util.HashSet; @@ -164,13 +163,11 @@ else if (!isOpen && window.isVisible()) { private static void fireOpenEvent(@NotNull Project project, boolean isAutoOpened) { // An extra "open" can fire when the window is already open and the user manually uses the OpenFlutterNewsSidePanelAction // again, so in this case just ignore the call. - if (openProjectTools.contains(project)) return; - FlutterInitializer.getAnalytics().sendEvent("intellij", isAutoOpened ? "AutoOpenFlutterNews" : "OpenFlutterNews"); + //if (openProjectTools.contains(project)) return; } private static void fireClosedEvent(@NotNull Project project) { openProjectTools.remove(project); - FlutterInitializer.getAnalytics().sendEvent("intellij", "CloseFlutterNews"); } } } diff --git a/resources/META-INF/plugin.xml b/resources/META-INF/plugin.xml index b2cbc89e8..c1daafe40 100644 --- a/resources/META-INF/plugin.xml +++ b/resources/META-INF/plugin.xml @@ -603,7 +603,6 @@ - @@ -723,7 +722,6 @@ - diff --git a/resources/META-INF/plugin_template.xml b/resources/META-INF/plugin_template.xml index ec71fc597..079120580 100644 --- a/resources/META-INF/plugin_template.xml +++ b/resources/META-INF/plugin_template.xml @@ -282,7 +282,6 @@ - @@ -402,7 +401,6 @@ -