fix(ga4): GA4 sidebar shows generic error for all customers [ES-433]#11065
Merged
Tyler (tylerwashington888) merged 3 commits intoJul 10, 2026
Merged
Conversation
useCMA() from react-apps-toolkit internally calls createClient() from contentful-management, which can fail due to CJS/ESM interop issues introduced in newer app-sdk versions. Mirrors the fix applied to AssignContentTypeSection in the config screen — use sdk.cma directly since app-sdk >= 4.20 exposes it on the SDK instance. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
… [ES-433] currencyCode and timeZone in ResponseMetaData are optional proto3 fields. When not set (e.g. non-ecommerce GA4 properties), protobufjs binary decode produces undefined for both the field value and the oneof discriminator (_currencyCode / _timeZone). JSON.stringify drops undefined keys entirely, so the frontend receives a JSON payload where those fields are absent. The previous strict z.string() on these fields caused ZodError for any property without currency tracking → malformedApiResponse error type → generic "We couldn't load Google Analytics data" message. Also widens propertyQuota from z.null() to z.unknown() since high-traffic properties return a QuotaStatus object rather than null. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
| rowCount: z.number(), | ||
| metadata: z.object({ | ||
| currencyCode: z.string(), | ||
| // currencyCode is an optional proto3 field — absent from JSON when not set (non-ecommerce properties) |
Contributor
There was a problem hiding this comment.
remove comment
| _currencyCode: z.string(), | ||
| _timeZone: z.string(), | ||
| timeZone: z.string().optional(), | ||
| // _currencyCode/_timeZone are protobuf oneof discriminators — absent from JSON when field is not set |
Contributor
There was a problem hiding this comment.
remove comment
| _timeZone: z.string().optional(), | ||
| }), | ||
| propertyQuota: z.null(), | ||
| // null when quota tracking is disabled; object when property has quota data |
Contributor
There was a problem hiding this comment.
remove comment
ryunsong-contentful
approved these changes
Jul 10, 2026
ryunsong-contentful
left a comment
Contributor
There was a problem hiding this comment.
Please make code changes in the comments before merging
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Tyler (tylerwashington888)
left a comment
Contributor
Author
There was a problem hiding this comment.
Removed all three inline comments per your feedback. No other changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Since June 30, every customer using the Google Analytics 4 sidebar sees "We couldn't load Google Analytics data" even though the lambda is returning valid data.
What's happening end-to-end
/api/run_reportendpoint via a signed requestZRunReportData) before renderingMalformedApiResponseerror type →ErrorDisplayhas no handler for it → falls todefault→ shows the generic messageWhy the schema fails
PR #11042 introduced
ZRunReportDatawith this metadata shape:_currencyCodeand_timeZoneare internal protobuf/protobufjs implementation details — they exist on the in-memory JS object that protobufjs produces when decoding the binary gRPC response, but they areundefinedand get silently dropped when the lambda callsres.json(). They are never part of the actual JSON payload the frontend receives. The schema was written by inspecting the raw JS object rather than the actual API contract.The actual JSON the lambda sends looks like:
_currencyCodeand_timeZoneare never there.z.string()on a missing field fails for every single customer.Additionally,
propertyQuota: z.null()would fail for any high-traffic property where Google returns aQuotaStatusobject instead of null.Why only reported for some customers
The Zod failure affects all customers — the "3 customers" in the report are just the ones who surfaced it. The bug has been live since June 30.
Fix
Make the fields that are never actually present optional, and widen
propertyQuotato accept any value:The frontend only reads
rowsandrowCountfrom the response — none of the loosened fields are accessed anywhere in UI code.Test plan
npm run test:ciinapps/google-analytics-4/frontendpasses🤖 Generated with Claude Code on behalf of Tyler