Skip to content

Use dashTool and dashIdeName to identify the launching IDE - #10037

Open
srawlins wants to merge 1 commit into
flutter:masterfrom
srawlins:env-vars
Open

srawlins wants to merge 1 commit into
flutter:masterfrom
srawlins:env-vars

Conversation

@srawlins

Copy link
Copy Markdown
Contributor

Part of #9811.

IDE integrations now pass the dashTool and dashIdeName query parameters when they launch or embed DevTools, alongside the legacy ide parameter:

  • dashTool is the canonical label of the Dash tool that hosts DevTools, such as vscode-plugins or intellij-plugins. It is shared by every variant of an IDE that uses the same plugin; VS Code, Cursor and Antigravity all pass vscode-plugins.
  • dashIdeName is the name of the IDE, such as Visual Studio Code, Cursor or Android Studio. Its values are open-ended, so it is only suitable for display and diagnostics.

The legacy ide parameter (VSCode, Android-Studio, IntelliJ-IDEA) is an ad-hoc vocabulary that cannot describe new IDEs or forks of IDEs, and it is expected to be removed once IDE integrations have passed dashTool and dashIdeName for long enough (at least two years). This PR moves DevTools over to the new parameters, while remaining compatible with IDE integrations that only pass ide:

  • DevToolsQueryParams gains dashTool, dashIdeName, ideDisplayName (dashIdeName, falling back to ide) and isVsCode. isVsCode is true when dashTool is vscode-plugins or when ide is VSCode. The ide getter is documented as legacy, with a TODO to remove it.
  • The two checks of ide == 'VSCode' now use isVsCode: the choice of docs that the Property Editor links to, and the decision not to notify users that DevTools fell back from WebAssembly to JavaScript when embedded in VS Code, which disables cross-origin isolation.
  • A survey's devEnvironments may now list dashTool labels (like vscode-plugins) as well as the legacy ide values (like VSCode). The legacy VSCode environment also matches VS Code forks. The matching moves to meetsEnvironmentRequirementFor, which takes the query parameters as an argument so that it can be unit tested. Older versions of DevTools only know the legacy values, so surveys that need to reach them should keep listing those.
  • The environment details that DevTools pre-fills into bug reports use ideDisplayName, so they name the actual IDE (like Cursor).

Not included: analytics

Event.devtoolsEvent in package:unified_analytics does not accept dashTool or dashIdeName yet, so DevTools continues to report only the legacy ide value. That needs a change to unified_analytics, and follows once it is published. This is why this PR is "Part of" #9811 rather than "Fixes" it.

Testing

  • New unit tests for DevToolsQueryParams (parsing the new parameters, isVsCode and ideDisplayName) in query_parameters_test.dart, and for survey environment matching (meetsEnvironmentRequirementFor) in survey_test.dart.
  • dt presubmit --fix passes, and the tests for the touched code (query parameters, surveys, environment parameters, preferences and the Property Editor) pass with the pinned Flutter SDK.

Pre-launch Checklist

General checklist

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I read the Tree Hygiene wiki page, which explains my responsibilities.
  • I read the Flutter Style Guide recently, and have followed its advice.
  • I signed the CLA.
  • I updated/added relevant documentation (doc comments with ///).

Issues checklist

Tests checklist

  • I added new tests to check the change I am making...
  • OR there is a reason for not adding tests, which I explained in the PR description.

AI-tooling checklist

  • I did not use any AI tooling in creating this PR.
  • OR I did use AI tooling, and...
    • I read the AI contributions guidelines and agree to follow them.
    • I reviewed all AI-generated code before opening this PR.
    • I understand and am able to discuss the code in this PR.
    • I have verifed the accuracy of any AI-generated text included in the PR description.
    • I commit to verifying the accuracy of any AI-generated code or text that I upload in response to review comments.

Feature-change checklist

  • This PR does not change the DevTools UI or behavior and...
    • I added the release-notes-not-required label or left a comment requesting the label be added.
  • OR this PR does change the DevTools UI or behavior and...
    • I added an entry to packages/devtools_app/release_notes/NEXT_RELEASE_NOTES.md.
    • I included before/after screenshots and/or a GIF demo of the new UI to my PR description.
    • I ran the DevTools app locally to manually verify my changes.

build.yaml badge

If you need help, consider asking for help on Discord.

IDE integrations now pass the `dashTool` and `dashIdeName` query
parameters when they launch or embed DevTools, alongside the legacy
`ide` parameter:

* `dashTool` is the canonical label of the Dash tool that hosts
  DevTools, such as `vscode-plugins` or `intellij-plugins`. It is shared
  by every variant of an IDE that uses the same plugin; VS Code, Cursor
  and Antigravity all pass `vscode-plugins`.
* `dashIdeName` is the name of the IDE, such as `Visual Studio Code`,
  `Cursor` or `Android Studio`. Its values are open-ended, so it is only
  suitable for display and diagnostics.

The legacy `ide` parameter (`VSCode`, `Android-Studio`, `IntelliJ-IDEA`)
is an ad-hoc vocabulary that cannot describe new IDEs or forks of IDEs,
and it is expected to be removed once IDE integrations have passed
`dashTool` and `dashIdeName` for long enough (at least two years). This
change moves DevTools over to the new parameters, while remaining
compatible with IDE integrations that only pass `ide`:

* DevToolsQueryParams gains `dashTool`, `dashIdeName`, `ideDisplayName`
  (`dashIdeName`, falling back to `ide`) and `isVsCode`. `isVsCode` is
  true when `dashTool` is `vscode-plugins` or when `ide` is `VSCode`.
  The `ide` getter is documented as legacy, with a TODO to remove it.
* The two checks of `ide == 'VSCode'` now use `isVsCode`: the choice of
  docs that the Property Editor links to, and the decision not to notify
  users that DevTools fell back from WebAssembly to JavaScript when
  embedded in VS Code, which disables cross-origin isolation.
* A survey's `devEnvironments` may now list `dashTool` labels (like
  `vscode-plugins`) as well as the legacy `ide` values (like `VSCode`).
  The legacy `VSCode` environment also matches VS Code forks. The
  matching moves to `meetsEnvironmentRequirementFor`, which takes the
  query parameters as an argument so that it can be unit tested. Older
  versions of DevTools only know the legacy values, so surveys that need
  to reach them should keep listing those.
* The environment details that DevTools pre-fills into bug reports use
  `ideDisplayName`, so they name the actual IDE (like Cursor).

Analytics are not changed by this commit. `Event.devtoolsEvent` in
`package:unified_analytics` does not accept `dashTool` or `dashIdeName`
yet, so DevTools continues to report only the legacy `ide` value. That
needs a change to `unified_analytics`, and follows once it is published.

Part of flutter#9811

@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 introduces support for the new dashTool and dashIdeName query parameters in DevToolsQueryParams to identify the launching IDE integration more robustly, including support for VS Code forks like Cursor. It updates the survey environment matching logic and other IDE-specific checks to utilize these new parameters. The review feedback highlights a logical gap during the transition period where surveys targeting the new environment names (e.g., vscode-plugins) will not match legacy IDE parameters (e.g., ide=VSCode) when dashTool is null. To resolve this, the reviewer suggests a bidirectional mapping to ensure robust matching for both VS Code and IntelliJ/Android Studio, along with a corresponding test case.

Comment on lines +286 to +289
return environments.contains(ideLaunched) ||
(dashTool != null && environments.contains(dashTool)) ||
(queryParams.isVsCode &&
environments.contains(DevToolsQueryParams.legacyVsCodeIdeValue));

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.

high

[MUST-FIX] There is a logical gap during the transition period when a survey is targeted at the new vscode-plugins or intellij-plugins environments.

If a survey specifies devEnvironments: ['vscode-plugins'], but the user is running an older IDE extension that only passes the legacy ide=VSCode parameter (so dashTool is null), the current logic will return false and the survey will not be shown.

To ensure robust matching during the transition period, we should map both the legacy and new environment names bidirectionally for both VS Code and IntelliJ/Android Studio.

    final isVsCode = queryParams.isVsCode || ideLaunched == 'VSCode';
    final isIntelliJOrAndroidStudio = dashTool == 'intellij-plugins' ||
        ideLaunched == 'Android-Studio' ||
        ideLaunched == 'IntelliJ-IDEA';

    if (isVsCode &&
        (environments.contains(DevToolsQueryParams.legacyVsCodeIdeValue) ||
            environments.contains('vscode-plugins'))) {
      return true;
    }
    if (isIntelliJOrAndroidStudio &&
        (environments.contains('intellij-plugins') ||
            environments.contains('Android-Studio') ||
            environments.contains('IntelliJ-IDEA'))) {
      return true;
    }

    return environments.contains(ideLaunched) ||
        (dashTool != null && environments.contains(dashTool));
References
  1. Prefix every comment with a severity: [MUST-FIX] for logical bugs. (link)

Comment on lines +251 to +252
test('matches VS Code forks for the legacy VSCode environment', () {
// A fork does not have to pass 'VSCode' as its legacy ide value.

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.

medium

[CONCERN] It would be beneficial to add a test case verifying that a survey targeted at the new vscode-plugins environment is correctly matched for legacy VS Code integrations that only pass the legacy ide=VSCode parameter (where dashTool is null).

References
  1. Prefix every comment with a severity: [CONCERN] for maintainability issues or gaps. (link)

@kenzieschmoll

Copy link
Copy Markdown
Member

DBC - please review go/dash-analytics-tool-dimensions before making any changes to the dashTool value that is set for DevTools analytics events.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants