[analytics] propagate ENV to deeplink sub-tool calls#9836
Conversation
There was a problem hiding this comment.
Code Review
This pull request implements the propagation of IDE information and analytics opt-out status from the DevTools client through the server to spawned subprocesses. It introduces new getters for analytics status, updates server request URI construction to include these parameters, and enhances the DeeplinkManager to configure the process environment using package:unified_analytics. A concern was raised regarding a redundant environment variable override in DeeplinkManager.runProcess that might conflict with the canonical naming expected by the analytics package.
|
UPDATE: I needed to rollback our bump to a new Rationale for the Manual Environment ConstructionTo resolve Issue #9702, DevTools must propagate the parent IDE ( While To bypass this SDK-bound version solving conflict while fully delivering the required telemetry propagation, we opted to construct the environment variables map manually using String constants inside |
|
@kenzieschmoll: I think this is ready for review. The integration test failures seem unrelated? |
|
(Re-running w/ debugging enabled in case that gives us any clues.) |
|
Interestingly a few retries got the integration tests green. (Maybe they should be configured to retry?) |
Implements environment variable propagation (
DASH__SUPPRESS_ANALYTICSandDASH__TOOL) when DevTools spawns ecosystem sub-tools (such as theflutterCLI during deep link analysis).This completes the DevTools-side changes for GitHub Issue #9702 and integrates with the new environment construction utilities in
package:unified_analytics(v8.0.13+).Fixes: #9702.
Why This Covers All Required Cases
A comprehensive audit of the repository was performed to identify all places where child processes are spawned:
Ecosystem Sub-Tools (Covered):
DeeplinkManager(packages/devtools_shared): This is the only production runtime component that spawns ecosystem sub-tools (flutter analyze). We have updated it to extract the parent IDE (DASH__TOOL) and client opt-out telemetry state (DASH__SUPPRESS_ANALYTICS), propagating them to the childflutterprocess usingpackage:unified_analytics'sgetEnvironment()builder.Exclusions & Why They Don't Require Special Handling:
BuildExtensionCommandindevtools_extensions): These run directly in the developer's terminal session, naturally inheriting the shell's active environment variables without needing dynamic, server-negotiated overrides.tar,git,which): These are not Dart/Flutter tools and do not integrate with thepackage:unified_analyticstelemetry system, meaning analytics environment variables have no effect.Detailed Changes
1. Client-Side Updates (
packages/devtools_app)server.dart: UpdatedbuildDevToolsServerRequestUrito declaratively append query parameterside(parent tool) andsuppress_analytics(opt-out status) to all server-bound HTTP API requests.analytics_controller.dart: Added synchronous public gettersisAnalyticsEnabledandisAnalyticsControllerInitializedto check client telemetry status safely and synchronously.pubspec.yaml: Upgradedunified_analyticsdependency to^8.0.13to align withdevtools_sharedand prevent monorepo version conflicts.2. Server-Side Updates (
packages/devtools_shared)pubspec.yaml: Addedpackage:unified_analytics: ^8.0.13dependency, sorted alphabetically._deeplink.dart:DeeplinkManager.deeplink_manager.dart:runProcessto acceptideandsuppressAnalyticsparameters._ideToDashToolMapto map IDE query strings toDashToolenums with case-insensitive lookups and alias overrides (such asvscodePluginsorintellijPlugins) in O(1) constant time, falling back to theO(N)enum values list loop only for new unmapped values.Process.run.3. Verification & Test Alignment
fakes.dart: UpdatedFakeDeeplinkManagermethod signatures to correctly match the base class overrides.deeplink_manager_test.dart: Added a dedicated unit test to verify that both the parent IDE and analytics opt-out status are correctly populated and propagated down to the child process.Pre-launch Checklist
General checklist
///).Issues checklist
contributions-welcomeorgood-first-issuelabel.contributions-welcomeorgood-first-issuelabel. I understand this means my PR might take longer to be reviewed.Tests checklist
AI-tooling checklist
Feature-change checklist
release-notes-not-requiredlabel or left a comment requesting the label be added.packages/devtools_app/release_notes/NEXT_RELEASE_NOTES.md.If you need help, consider asking for help on Discord.