fix(ga4): use sdk.cma directly in Sidebar instead of useCMA [AIS-59]#11064
Open
Tyler (tylerwashington888) wants to merge 1 commit into
Open
fix(ga4): use sdk.cma directly in Sidebar instead of useCMA [AIS-59]#11064Tyler (tylerwashington888) wants to merge 1 commit into
Tyler (tylerwashington888) wants to merge 1 commit into
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>
3 tasks
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.
Summary
Mirrors the fix from #11037 (config screen) to the GA4 sidebar.
useCMA()from@contentful/react-apps-toolkitinternally callscreateClient()fromcontentful-management. This creates the same CJS/ESM interop risk that #11037 addressed inAssignContentTypeSection.tsx— ifcreateClientfails to initialize, thecmaobject is broken,cma.appSignedRequest.create()never runs, and the signed request header is never attached to the lambda call. The result is a silent client-side failure that surfaces as the generic "We couldn't load Google Analytics data." error in the sidebar.sdk.cmahas been available directly on the SDK instance since app-sdk >= 4.20. The sidebar is already onapp-sdk@4.23.0, so no version bump is needed.Changes
Sidebar.tsx: removeuseCMAimport and usage, passsdk.cmadirectly toApiconstructorRelated
Test plan
createClient is not a functionerrors in the browser console🤖 Generated with Claude Code