Skip to content

Commit 3ca3bb2

Browse files
authored
[analytics] propagate env to sub-tools (#8976)
Follow-up from #8966 which introduced support for propagating the standard JetBrains telemetry environment variables (`DASH__*` and `FLUTTER_HOST`) via the `Analytics.updateEnvironment(commandLine)` utility, this updates four additional spots where standalone processes are spawned manually using the `GeneralCommandLine` class, ensuring environment variables are propagated correctly in those contexts as well. Fixes: #8975 --- ### Changes #### 1. Device Daemon Spawning (`src/io/flutter/run/daemon/DeviceDaemon.java`) * **Modification**: Invoked `Analytics.updateEnvironment(result)` inside the `toCommandLine()` helper before returning the `GeneralCommandLine` instance. This ensures the background `flutter daemon` process runs with propagated telemetry parameters. #### 2. Bazel Test Execution (`src/io/flutter/run/bazelTest/BazelTestFields.java`) * **Modification**: Invoked `Analytics.updateEnvironment(commandLine)` in the `getLaunchCommand(...)` method before returning the constructed command line, allowing the Bazel test runner process to receive the telemetry variables. #### 3. Bazel Flutter Doctor Execution (`src/io/flutter/actions/FlutterDoctorAction.java`) * **Modification**: Invoked `Analytics.updateEnvironment(cmdLine)` in `runWorkspaceFlutterDoctorScript(...)` before spawning the workspace-specific doctor script. #### 4. Bazel File Synchronization (`src/io/flutter/run/FlutterReloadManager.java`) * **Modification**: Invoked `Analytics.updateEnvironment(commandLine)` in the `syncFiles()` helper to propagate the environment variables to the Bazel file synchronization script during reload events. --- Review the contribution guidelines below: - [x] I’ve reviewed the contributor guide and applied the relevant portions to this PR. - [x] I've included the required information in the description above. - [x] My up-to-date information is in the `AUTHORS` file. - [x] I've updated `CHANGELOG.md` if appropriate. <details> <summary>Contribution guidelines:</summary><br> - See our [contributor guide](../CONTRIBUTING.md) and the [Flutter organization contributor guide]([https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md) for general expectations for PRs. - Larger or significant changes should be discussed in an issue before creating a PR. - Dart contributions to our repos should follow the [Dart style guide](https://dart.dev/guides/language/effective-dart) and use `dart format`. - Java and Kotlin contributions should strive to follow Java and Kotlin best practices ([discussion](#8098)). </details>
1 parent 34960e8 commit 3ca3bb2

4 files changed

Lines changed: 10 additions & 0 deletions

File tree

src/io/flutter/actions/FlutterDoctorAction.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import io.flutter.logging.PluginLogger;
2020
import io.flutter.pub.PubRoot;
2121
import io.flutter.sdk.FlutterSdk;
22+
import com.jetbrains.lang.dart.analytics.Analytics;
2223
import org.jetbrains.annotations.NotNull;
2324
import org.jetbrains.annotations.Nullable;
2425

@@ -53,6 +54,8 @@ private void runWorkspaceFlutterDoctorScript(@NotNull Project project, @NotNull
5354
cmdLine.setCharset(StandardCharsets.UTF_8);
5455
cmdLine.setExePath(FileUtil.toSystemDependentName(doctorScript));
5556

57+
Analytics.updateEnvironment(cmdLine);
58+
5659
final ColoredProcessHandler handler;
5760
try {
5861
handler = new ColoredProcessHandler(cmdLine);

src/io/flutter/run/FlutterReloadManager.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
import io.flutter.bazel.WorkspaceCache;
5757
import io.flutter.dart.FlutterDartAnalysisServer;
5858
import io.flutter.logging.PluginLogger;
59+
import com.jetbrains.lang.dart.analytics.Analytics;
5960
import io.flutter.run.common.RunMode;
6061
import io.flutter.run.daemon.FlutterApp;
6162
import io.flutter.settings.FlutterSettings;
@@ -318,6 +319,8 @@ private void syncFiles() {
318319
commandLine.setCharset(StandardCharsets.UTF_8);
319320
commandLine.setExePath(FileUtil.toSystemDependentName(script));
320321

322+
Analytics.updateEnvironment(commandLine);
323+
321324
try {
322325
final MostlySilentColoredProcessHandler handler = new MostlySilentColoredProcessHandler(commandLine);
323326
handler.startNotify();

src/io/flutter/run/bazelTest/BazelTestFields.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import com.intellij.openapi.vfs.VirtualFile;
1919
import com.jetbrains.lang.dart.sdk.DartConfigurable;
2020
import com.jetbrains.lang.dart.sdk.DartSdk;
21+
import com.jetbrains.lang.dart.analytics.Analytics;
2122
import io.flutter.FlutterBundle;
2223
import io.flutter.bazel.Workspace;
2324
import io.flutter.bazel.WorkspaceCache;
@@ -221,6 +222,7 @@ GeneralCommandLine getLaunchCommand(@NotNull final Project project,
221222
if (mode == RunMode.DEBUG) {
222223
commandLine.addParameters(Flags.separator, Flags.enableDebugging);
223224
}
225+
Analytics.updateEnvironment(commandLine);
224226
return commandLine;
225227
}
226228

src/io/flutter/run/daemon/DeviceDaemon.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
import io.flutter.utils.MostlySilentColoredProcessHandler;
3333
import io.flutter.utils.OpenApiUtils;
3434
import io.flutter.utils.SystemUtils;
35+
import com.jetbrains.lang.dart.analytics.Analytics;
3536
import org.jetbrains.annotations.NotNull;
3637
import org.jetbrains.annotations.Nullable;
3738

@@ -315,6 +316,7 @@ private GeneralCommandLine toCommandLine() {
315316
for (String param : parameters) {
316317
result.addParameter(param);
317318
}
319+
Analytics.updateEnvironment(result);
318320
return result;
319321
}
320322

0 commit comments

Comments
 (0)