Skip to content

[analytics]Use unified_analytics getEnvironment() for deep link flutt… - #10077

Merged
keertip merged 2 commits into
flutter:masterfrom
keertip:deeplink-get-environment
Nov 9, 2026
Merged

keertip merged 2 commits into
flutter:masterfrom
keertip:deeplink-get-environment

Conversation

@keertip

@keertip keertip commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

Fixes #10051. Resolves the TODO for #9702.

DeeplinkManager built the environment for the flutter analyze processes it starts by hand, with a string map from the ?ide= query parameter to DASH__TOOL labels. It now uses getEnvironment() from package:unified_analytics 8.4.0, which is now possible because the repo requires Dart ^3.11.0.

Changes

  • New DeeplinkManager.buildEnvironment(), marked @visibleForTesting:
    • Starts from getEnvironment(currentTool: DashTool.devtools, suppressAnalytics: ...), which passes on this process's root tool from DASH__TOOL (falling back to devtools) and sets DASH__SUPPRESS_ANALYTICS.
    • Overrides DASH__TOOL when ?ide= names a known IDE, because the IDE that opened DevTools is the user's entry point for the request. The IDE map now uses DashTool values.
    • Forces DASH__SUPPRESS_ANALYTICS=true when suppressAnalytics is true. On its own, getEnvironment() lets an inherited DASH__SUPPRESS_ANALYTICS=false (which dart sets for its child processes) win.
  • devtools_shared now depends on unified_analytics: ^8.4.0, and devtools_app moves from ^7.0.0 to ^8.4.0. The Dart SDK already pins 8.4.0.

Behavior changes

  • An unknown ?ide= value now passes on the inherited root tool instead of always devtools.
  • With suppressAnalytics: false, an inherited DASH__SUPPRESS_ANALYTICS=true is passed on instead of being reset to false.

Follow-up

dart-lang/tools#2803 adds fallbackRootTool to getEnvironment(), so the IDE override here can be replaced with a single call.

Testing

  • New buildEnvironment tests: IDE mapping, unknown or missing IDE, root-tool validity, suppression, and environment pass-through.
  • dart analyze --fatal-infos and dart test in packages/devtools_shared: all pass.

@keertip
keertip requested review from a team, bkonyi and kenzieschmoll as code owners November 6, 2026 20:54
@keertip
keertip requested review from srawlins and removed request for a team November 6, 2026 20:54

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates DeeplinkManager to construct the environment for started flutter processes using getEnvironment() from package:unified_analytics (upgraded to ^8.4.0), ensuring correct handling of root tools and inherited analytics suppression. Unit tests have been added to verify this behavior. The reviewer suggested declaring the _ideToDashTool map as static const instead of static final to avoid runtime initialization.

@srawlins srawlins left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@keertip
keertip merged commit acdd9a6 into flutter:master Nov 9, 2026
51 of 52 checks passed
@keertip
keertip deleted the deeplink-get-environment branch November 9, 2026 17:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Use unified_analytics getEnvironment() instead of hand-written DASH__TOOL mapping

2 participants