Repository navigation
Description
Goal
Add Google Analytics as the second provider in Settings → Integrations, reusing the Composio managed-auth plumbing built for Google Search Console (#577). This phase is connection only: connect, show status, disconnect. Property mapping, data sync, and product surfaces (AI-traffic history without the tracking snippet, conversion metrics, citations enrichment) are later phases.
Why
Today the AI Traffic page depends entirely on the customer installing our tracking snippet — until then it's empty. A GA4 connection is the gateway to pulling AI-sourced sessions (and later conversions) straight from data customers already have, with months of history and zero code changes on their site. Phase 1 lands the connect flow so the data phases can build on it.
What exists already
The plumbing was deliberately built provider-generic:
integration_connectionshas aprovidercolumn withUNIQUE (organization_id, provider)— no schema change needed: supabase/migrations/00045_integration_connections.sql- Composio client + GSC connect flow to mirror: server/src/lib/composio.js, server/src/routes/integrations.js
- Settings UI card pattern: web/src/components/settings/integrations-section.tsx, web/src/lib/actions/integrations.ts
Scope
- Generalize the provider-specific parts of
composio.js/integrations.js(auth-config id,PROVIDERconstant) so a second provider slots in cleanly — e.g. a small per-provider config map instead of copy-pasting the route set. - New env:
COMPOSIO_GA_AUTH_CONFIG_ID(documented inserver/.env.example). Same no-op guarantee as GSC: when Composio env vars are absent, everything reports "not configured" and nothing breaks — self-host stays safe. - Composio entity stays
org_<organizationId>(one Google account connection per org per provider). - Settings → Integrations shows a Google Analytics card next to Search Console: Connect (OAuth via Composio link flow), Connected status with account e-mail, Disconnect.
- Connect/callback/status/disconnect endpoints for the new provider, mirroring GSC's.
Out of scope (later phases)
- GA4 property listing + brand ↔ property mapping (Phase 2, mirrors GSC property mapping)
- Daily report sync + storage (Phase 2)
- AI Traffic page / conversions / citations surfaces (Phase 3)
Acceptance criteria
- An org admin can connect a Google Analytics account from Settings → Integrations and see the connected state persist across reloads; disconnect removes it.
- GSC connection behavior is completely unaffected.
- With Composio env vars unset, both cards degrade to the existing "not configured" state.
Activity
feat(integrations): connect Google Analytics via Composio (#695)