Skip to content

feat: GSC property mapping and daily query-stats sync - #647

Merged
gkhngyk merged 3 commits into
mainfrom
feature/gsc-property-mapping
Aug 4, 2026
Merged

gkhngyk merged 3 commits into
mainfrom
feature/gsc-property-mapping

Conversation

@gkhngyk

@gkhngyk gkhngyk commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Summary

GSC integration phase 2 on top of #643: per-brand property mapping and the daily query-stats pull. Two commits, one per issue.

Phase 2a — property mapping (#642)

  • GET /api/integrations/google-search-console/properties — lists the connected account's properties via the Composio GOOGLE_SEARCH_CONSOLE_LIST_SITES tool (pinned toolkit version, env-overridable via COMPOSIO_GSC_TOOLKIT_VERSION).
  • New nullable brands.gsc_property column (migration 00046) — connection is org-level, property choice is brand-level; kept on disconnect.
  • Integrations card gains a "Property mapping" block when connected: per-brand property select, unambiguous domain matches premapped automatically (sc-domain: covers apex + subdomains, URL-prefix matches by host — unit-tested matcher in web/src/lib/gsc.ts), "N of M brands mapped" counter, optimistic saves with rollback. Writes go through the existing brands RLS (admin/manager).

Phase 2b — query stats pull (#644)

  • New gsc_query_stats table (migration 00047): per-query daily rows, unique (brand_id, query, date), org-member read.
  • server/src/lib/gsc-sync.js — for every active brand with a mapped property in a connected org: last 28 days, dimensions: ['query','date'], fully deterministic parameters (no LLM), paginated in 5k pages up to a logged 25k/brand ceiling, chunked upserts (idempotent). Per-brand failures are logged and skipped.
  • Hooked into runDailyTracking as a non-blocking follow-up (both cloud cron and self-host cron get it); silent no-op without Composio env.
  • POST /api/integrations/google-search-console/sync (admin/manager) for manual runs/backfill.

Orgs without the integration are untouched at every layer: no connection → the sync selects zero brands; no Composio env → immediate no-op; no product surface reads the new table yet.

Related issue

Closes #642
Closes #644

Type of change

  • feat — New feature

How to test

  1. With a connected account (from feat: Settings Integrations tab with Google Search Console connection via Composio #643): Settings → Integrations shows the "Property mapping" block listing the account's properties; a brand whose domain matches one property is premapped, others get a manual select; picks persist across reloads.
  2. Run the sync (POST .../sync or the daily cycle): gsc_query_stats fills with up to 28 days of per-query rows; re-running produces no duplicates.
  3. Unmapped brands, disconnected orgs, and installs without Composio env are skipped with no errors.

Manually tested end-to-end against a live GSC account: 3 properties listed, mapping saved, sync wrote 17,434 rows (3,268 distinct queries, 28-day window), verified idempotent with zero duplicate keys.

Checklist

  • Branch follows the naming convention (feature/)
  • Commits follow Conventional Commits
  • yarn lint passes (run from web/)
  • yarn typecheck passes (run from web/)
  • yarn format:check passes (run from web/)
  • Changes are focused — one concern per PR

@gkhngyk
gkhngyk merged commit 04166b9 into main Aug 4, 2026
4 checks passed
@gkhngyk
gkhngyk deleted the feature/gsc-property-mapping branch August 8, 2026 10:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant