Skip to content

[analytics] Add executor and buildMode to Flutter session events - #9268

Open
pq wants to merge 1 commit into
flutter:mainfrom
pq:run-session-dev-stage
Open

pq wants to merge 1 commit into
flutter:mainfrom
pq:run-session-dev-stage

Conversation

@pq

@pq pq commented Nov 20, 2026 •

Copy link
Copy Markdown
Collaborator

Part of flutter/dash-devexp-internal#193.

Flutter run, attach and test session events now say which executor launched them (run, debug, coverage, profiler or other), and app and attach sessions say which Flutter build mode they run in (debug, profile or release). Until now, a profile or release run looked the same as any other run, and the Android Profiler and Run with Coverage both showed up as plain run_session.

Details
  • executor: mapped to a fixed value, never the raw executor id (other plugins can define executors). Note that executor=debug (like type=debug_session) means a debugger is attached, while buildMode=debug means a debug (JIT) build.
  • buildMode: decided at getState time, where the environment's FlutterLaunchMode isn't final yet:
    • Exact --release/--profile flags in the configuration's extra args set it: additional args for flutter run, attach args for flutter attach. The args themselves are never sent.
    • The Android Profiler executor maps to profile (it only switches the environment's mode later, in LaunchState.launch).
    • Otherwise it's the environment's FlutterLaunchMode, which is what the Run Profile/Release actions set.
    • Test sessions have no build mode.
  • Fail-safe: recordRunOrDebugSession runs in getState, so it now catches all Throwables, like Analytics.report, and can't fail a launch. A null executor id maps to other.
  • Not in this PR: the event still fires before a device is selected, so aborted launches and re-run hot restarts are still counted. Device, platform and flavor fields come with moving the report, in a follow-up.
  • Tests: SessionDataTest covers the event shape (including the project, which events need to be delivered), the executor mapping, and each build-mode source.
  • No CHANGELOG entry (analytics-only).

Review the contribution guidelines below:

  • I’ve reviewed the contributor guide and applied the relevant portions to this PR.
  • I've included the required information in the description above.
  • My up-to-date information is in the AUTHORS file.
  • I've updated CHANGELOG.md if appropriate.
Contribution guidelines:
  • See
    our contributor guide and
    the Flutter organization contributor guide
    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 and use
    dart format.
  • Java and Kotlin contributions should strive to follow Java and Kotlin best
    practices (discussion).

@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 enhances run and debug session analytics by reporting the specific IntelliJ executor and the Flutter build mode (debug, profile, or release). It introduces helper methods executorFor and buildModeFor in Analytics.kt to map and resolve these values, updates the run and attach configurations to pass this data, and adds comprehensive unit tests. Feedback focuses on a critical issue where buildModeFor expects a non-null Array<String> for extraArgs. If the parsed arguments from the launch fields are null, this will cause a NullPointerException before the try-catch block in recordRunOrDebugSession is reached, potentially crashing the launch process. It is recommended to make extraArgs nullable, update the tests to verify null safety, and update the documentation in ABOUT.md accordingly.

Comment thread src/io/flutter/analytics/Analytics.kt Resolved
Comment thread src/io/flutter/analytics/ABOUT.md Resolved
@pq
pq marked this pull request as ready for review November 20, 2026 22:38
@pq
pq requested a review from helin24 as a code owner November 20, 2026 22:38

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant