Remove client productionBuild guard in AnalyticsImplementation - #13851
Remove client productionBuild guard in AnalyticsImplementation#13851jesskuras wants to merge 1 commit into
Conversation
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.
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
|
@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. |
|
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 |
|
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 |
|
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. |
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
Description of what this PR is changing or adding, and why:
Removes the client-side
if (!productionBuild) return;guard inAnalyticsImplementationwithinsite_shared.In client-side
dart2jsbuilds, thePRODUCTIONenvironment variable is not passed to the compiler options inbuild.yaml, resulting inproductionBuildevaluating tofalse. As a result, the-O4compiler stripped out thewindow.dataLayerpush insendEvent.Feedback events are now verified and working on the Dart documentation site (
dart-lang/site-www), and this update matches the implementation indart-lang/site-wwwwheresendEventdirectly pushes todataLayer. On local development builds, Google Tag Manager is not injected, sowindow['dataLayer']does not exist and calls tosendEventsafely 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