Repository navigation
[flutter tool] honor inherited DASH__SUPPRESS_ANALYTICS - #194750
Conversation
There was a problem hiding this comment.
Code Review
This pull request implements support for suppressing analytics via the DASH__SUPPRESS_ANALYTICS environment variable. When this variable is set to true, attempts to enable or disable analytics via command-line flags or configuration will output a warning instead of modifying telemetry settings, and a no-op analytics instance will be used. Relevant unit tests have been added to verify this behavior. A review comment identifies a typo in a comment within runner.dart.
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
|
@pq I think this needs the CI/CD label to run the bots (and I think the |
|
Thanks, Danny! |
|
Golden file changes have been found for this pull request. Click here to view and triage (e.g. because this is an intentional change). If you are still iterating on this change and are not ready to resolve the images on the Flutter Gold dashboard, consider marking this PR as a draft pull request above. You will still be able to view image results on the dashboard, commenting will be silenced, and the check will not try to resolve itself until marked ready for review. For more guidance, visit Writing a golden file test for Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. |
…4750) When a parent Dash tool sets `DASH__SUPPRESS_ANALYTICS=true` (for example, during the root tool's first run), the Flutter CLI now stops reporting analytics itself. Before this change, `getAnalytics()` only checked `FLUTTER_SUPPRESS_ANALYTICS`. Flutter passed the flag on to the tools it launches (flutter#194261), but still reported on its own. `getAnalytics()` now returns `NoOpAnalytics` when the flag is set. Like `FLUTTER_SUPPRESS_ANALYTICS`, this also means no crash reports and no consent message for that invocation. Only the exact string `true` counts as a request to suppress, which matches `package:unified_analytics`, the `dart` CLI, and `ErrorHandlingProcessManager`. A no-op instance can't change the telemetry setting. So when the flag is set, `--enable-analytics`, `--disable-analytics`, and `flutter config --[no-]analytics` now print a warning that the setting wasn't changed and why. Before, they reported success without saving anything. Test notes: - Some `runner_test.dart` tests now override `Platform`. The test process can inherit `DASH__SUPPRESS_ANALYTICS=true` from the `flutter test` that launched it: on bots, or when telemetry is disabled locally. - Any new test of the opt-out/opt-in commands needs to override `Platform` the same way. Follow-up to flutter#194261. (Fixes flutter/dash-devexp-internal#98.) ## Pre-launch Checklist - [x] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [x] I read the [AI contribution guidelines] and understand my responsibilities, or I am not using AI tools. - [x] I read the [Tree Hygiene] wiki page, which explains my responsibilities. - [x] I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement]. - [x] I signed the [CLA]. - [x] I listed at least one issue that this PR fixes in the description above. - [x] I updated/added relevant in-code documentation (doc comments with `///`). - [x] If this PR introduces a new feature or capability, I created and linked a website documentation issue or PR in [flutter/website] (or verified none is needed). - [x] I added new tests to check the change I am making, or this PR is [test-exempt]. - [x] I followed the [breaking change policy] and added [Data Driven Fixes] where supported. - [x] All existing and new tests are passing. If you need help, consider asking for advice on the #hackers-new channel on [Discord]. If this change needs to override an active code freeze, provide a comment explaining why. The code freeze workflow can be overridden by code reviewers. See pinned issues for any active code freezes with guidance. **Note**: The Flutter team is currently trialing the use of [Gemini Code Assist for GitHub](https://developers.google.com/gemini-code-assist/docs/review-github-code). Comments from the `gemini-code-assist` bot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed. <!-- Links --> [Contributor Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview [AI contribution guidelines]: https://github.com/flutter/flutter/blob/main/CONTRIBUTING.ai.md [Tree Hygiene]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md [test-exempt]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests [Flutter Style Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md [Features we expect every widget to implement]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement [CLA]: https://cla.developers.google.com/ [flutter/tests]: https://github.com/flutter/tests [flutter/website]: https://github.com/flutter/website [breaking change policy]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes [Discord]: https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md [Data Driven Fixes]: https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md --------- Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
When a parent Dash tool sets
DASH__SUPPRESS_ANALYTICS=true(for example, during the root tool's first run), the Flutter CLI now stops reporting analytics itself. Before this change,getAnalytics()only checkedFLUTTER_SUPPRESS_ANALYTICS. Flutter passed the flag on to the tools it launches (#194261), but still reported on its own.getAnalytics()now returnsNoOpAnalyticswhen the flag is set. LikeFLUTTER_SUPPRESS_ANALYTICS, this also means no crash reports and no consent message for that invocation. Only the exact stringtruecounts as a request to suppress, which matchespackage:unified_analytics, thedartCLI, andErrorHandlingProcessManager.A no-op instance can't change the telemetry setting. So when the flag is set,
--enable-analytics,--disable-analytics, andflutter config --[no-]analyticsnow print a warning that the setting wasn't changed and why. Before, they reported success without saving anything.Test notes:
runner_test.darttests now overridePlatform. The test process can inheritDASH__SUPPRESS_ANALYTICS=truefrom theflutter testthat launched it: on bots, or when telemetry is disabled locally.Platformthe same way.Follow-up to #194261.
(Fixes flutter/dash-devexp-internal#98.)
Pre-launch Checklist
///).If you need help, consider asking for advice on the #hackers-new channel on Discord.
If this change needs to override an active code freeze, provide a comment explaining why. The code freeze workflow can be overridden by code reviewers. See pinned issues for any active code freezes with guidance.
Note: The Flutter team is currently trialing the use of Gemini Code Assist for GitHub. Comments from the
gemini-code-assistbot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed.