Skip to content

fix(ga4): use sdk.cma directly in Sidebar instead of useCMA [AIS-59]#11064

Open
Tyler (tylerwashington888) wants to merge 1 commit into
masterfrom
fix/ga4-sidebar-use-sdk-cma
Open

fix(ga4): use sdk.cma directly in Sidebar instead of useCMA [AIS-59]#11064
Tyler (tylerwashington888) wants to merge 1 commit into
masterfrom
fix/ga4-sidebar-use-sdk-cma

Conversation

@tylerwashington888

@tylerwashington888 Tyler (tylerwashington888) commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Summary

Mirrors the fix from #11037 (config screen) to the GA4 sidebar.

useCMA() from @contentful/react-apps-toolkit internally calls createClient() from contentful-management. This creates the same CJS/ESM interop risk that #11037 addressed in AssignContentTypeSection.tsx — if createClient fails to initialize, the cma object 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.cma has been available directly on the SDK instance since app-sdk >= 4.20. The sidebar is already on app-sdk@4.23.0, so no version bump is needed.

Changes

  • Sidebar.tsx: remove useCMA import and usage, pass sdk.cma directly to Api constructor

Related

Test plan

  • Open an entry in the Contentful UI with the GA4 app installed and confirm the sidebar loads analytics data without error
  • Confirm no createClient is not a function errors in the browser console

🤖 Generated with Claude Code

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>
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.

1 participant