Skip to content

Remove client productionBuild guard in AnalyticsImplementation - #13851

Closed
jesskuras wants to merge 1 commit into
flutter:mainfrom
jesskuras:fix-client-analytics-production-guard
Closed

Remove client productionBuild guard in AnalyticsImplementation#13851
jesskuras wants to merge 1 commit into
flutter:mainfrom
jesskuras:fix-client-analytics-production-guard

Conversation

@jesskuras

Copy link
Copy Markdown
Contributor

Description of what this PR is changing or adding, and why:

Removes the client-side if (!productionBuild) return; guard in AnalyticsImplementation within site_shared.

In client-side dart2js builds, the PRODUCTION environment variable is not passed to the compiler options in build.yaml, resulting in productionBuild evaluating to false. As a result, the -O4 compiler stripped out the window.dataLayer push in sendEvent.

Feedback events are now verified and working on the Dart documentation site (dart-lang/site-www), and this update matches the implementation in dart-lang/site-www where sendEvent directly pushes to dataLayer. On local development builds, Google Tag Manager is not injected, so window['dataLayer'] does not exist and calls to sendEvent safely evaluate to a no-op without requiring this check.

Issues fixed by this PR (if any):

PRs or commits this PR depends on (if any):
#13849

Presubmit checklist

  • If you are unwilling, or unable, to sign the CLA, even for a tiny, one-word PR, please file an issue instead of a PR.
  • If this PR is not meant to land until a future stable release, mark it as draft with an explanation.
  • This PR follows the Google Developer Documentation Style Guidelines—for example, it doesn't use i.e. or e.g., and it avoids I and we (first-person pronouns).
  • This PR uses semantic line breaks of 80 characters or fewer.

The productionBuild environment variable is not defined during client-side dart2js compilation, causing sendEvent to return early and strip out the dataLayer push.

Removing this check matches how dart-lang/site-www implements client analytics and allows client events like inline_feedback to be dispatched to window.dataLayer.
@jesskuras
jesskuras requested review from a team and sfshaza2 as code owners September 2, 2026 20:27
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@jesskuras
jesskuras requested a review from parlough September 2, 2026 20:28
@jesskuras

Copy link
Copy Markdown
Contributor Author

@parlough - hopefully this PR makes sense. User feedback is now working on dart.dev/docs but still isn't coming through on the Flutter side. This fix is AI-generated but it claims it matches how the Dart docs are set up, so it seemed promising.

@flutter-website-bot

Copy link
Copy Markdown
Collaborator

Staged preview of the updated docs.flutter.dev site (updated for commit 8663cdb):

https://flutter-docs-prod--docs-pr13851-fix-client-analytics-p-1ljeq09s.web.app

@flutter-website-bot

Copy link
Copy Markdown
Collaborator

Staged preview of the updated flutter.dev site (updated for commit 8663cdb):

https://flutter-dev-230821--www-pr13851-fix-client-analytics-p-l8bezx44.web.app

@parlough

parlough commented Sep 2, 2026

Copy link
Copy Markdown
Member

Thanks for investigating this @jesskuras! Rather than drop the check, I investigated why the code was being dropped on release builds and found an issue with our Jaspr build setup. #13854 is an alternative solution that fixes that issue and as a result, fixes this logic.

dayanruben pushed a commit to dayanruben/flutter-website that referenced this pull request Sep 3, 2026
The `--no-managed-build-options` we were passing to the `jaspr build`
command was meaning `--dart-define` wasn't respected so
`productionBuild` was false for client-compiled code. We don't use the
`build.yaml` files for much special configuration anyway, so we can
instead use Jaspr's managed build options, passing what little we do
need to configure. With that change, `productionBuild` is correctly set
to `true` on release client build. This fixes code such as analytics
sending that was incorrectly being stripped.

Supersedes and closes flutter#13851
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.

3 participants