Repository navigation
feat(shopping): say from Search Console whether Google shows the brand's products in its shopping results - #1751
Conversation
For an AI assistant working on a shop's catalog (MCP plan B6a): - get_catalog_sources (REST GET /api/mcp/catalog/sources): where the catalog is read from (feeds, uploads, connected stores) and how each last sync went, with its products in the catalog now. - list_catalog_products (REST GET /api/mcp/catalog/products): the live products, by title, as Product Visibility reads them, each with its readiness for AI shopping, its Google Merchant Center issues by severity and the AI visits and orders its page brought over 30 days; `search`, and paged with `limit` and `offset`. Product Visibility's catalog reads (readCatalogProducts and its paged readers) and Settings' source read (readCatalogSources) move to lib/shopping/catalog-read.ts and take the client: the member's session on the pages, the service role for the MCP once the brand is the key's. Co-Authored-By: Claude Opus 5.5 <[email protected]>
# Conflicts: # docs/guides/mcp-server.mdx # web/src/lib/mcp/server.ts # web/src/lib/mcp/subscription-gate.test.ts
…wer past its end - Read the page's variants and their issues 100 ids and 1,000 rows a request, so a page past PostgREST's row cap keeps every issue. - Count each issue (code and attribute) once per product, however many variants and destinations it is on, and only for a Merchant Center account whose last sync went through (hasMerchantCenter, now shared with the editor's shopping check from lib/shopping/catalog-read). - Answer an empty page for an offset past the matches, which PostgREST refuses (PGRST103) once it counts them. - Search titles as written: a case-insensitive regex with its special characters escaped, since PostgREST turns every `*` of a like pattern into `%`. - One CARD_MAX_ROWS for the card and catalog reads. - Tests for the REST mirrors, the paged reads and the brand scoping; readiness.unknown, revenue_30d and the REST `search` in the tool description and docs. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Three read tools and their REST mirrors (MCP plan B6b), on top of the catalog tools (B6a): - get_shopping_shelf: each shopping question's latest shelf per AI channel, the brand's place on it and its last 7 days, and "Why not you?" on the shelves it isn't on (its catalog product the question asks for most, with its readiness). Paged; period, platform, market and absent_only filters. - get_shopping_readiness: the Readiness checklist and score, each check's text as the tab writes it (en.json) and where its fix starts, and each AI channel's state. - get_product_ai_says: a catalog product's "What AI says": answers, quotes and the pages they cited. They run the page's own loaders with the service role (dbClient / withDbClient) once the brand is the key's, so the tools and the page read the same. Like the page's tabs they need a plan with shopping_analytics (403 over REST). copyValues moves to lib/shopping/readiness.ts for both. Co-Authored-By: Claude Opus 5.5 <[email protected]>
- Plan: read the plan the organization is on (usagePlanFromOrgRow), as the page does, so a workspace whose trial ended still reads; the locked message names the first plan with Product Visibility. - Shelf: read the products for "Why not you?" beside the shelves; pages of 10 shelves (50 at most), each with its first 10 products and products_total. - Readiness: read which channels hold the brand's products one row a channel (getShoppingOwnChannels) instead of every card on the shelves. - Guard test: the page's loaders through the MCP client with the member's client failing, every read and RPC naming the brand; plan lock and not found answered as errors. - Comments on the shared loaders say the MCP runs them with the service role; docs table no longer split by a blank line. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Google Merchant Center can't be connected where the API has no Composio auth config for it (COMPOSIO_GMC_AUTH_CONFIG_ID), as on Cloud today, yet Product Visibility asked for it: Readiness's "Google Merchant Center feed connected" warned in the US and failed in Europe, pulling the score down, and its Connect led to Settings' Coming soon. - readinessChecklist takes merchantCenterOffered: where Merchant Center isn't offered and the brand has no Merchant Center source, the check is neither listed nor scored. A source connected before still passes. - The page reads it from /api/integrations/config (getMerchantCenterOffered, false when unread); the data strip's Merchant Center chip says Soon there, as the marketplaces with no connector. - The MCP readiness reads the same through a new CRON_SECRET internal endpoint, GET /api/internal/integrations-config (the MCP has no member session); unread counts as not offered. integrationsConfig() is the one definition for both routes. - Europe's market note no longer says only a Merchant Center feed decides ChatGPT: Google Shopping does, from a feed or the pages' product schema. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…d's products in its shopping results
Readiness had no way to tell whether Google lists a shop's products
where Merchant Center can't be connected. Search Console can, from the
brand's own property: the pages shown as merchant listings (the free
shopping listings) and product snippets.
- The daily GSC sync reads them in the two steps the API needs (search
appearance can't be a column beside the page): the property's types
over 28 days, then each shopping one's [page, date] rows filtered to it
(types matched by name, so MERCHANT_LISTINGS or "Merchant listings"
both count). A filtered read whose impressions pass its type's total is
dropped as unfiltered, never kept as every page shown. Rows go to
gsc_shopping_page_stats (00377, members read); another property's rows
are dropped first; 90 days kept. brands.gsc_shopping_synced_at says it
was read.
- Readiness's new "Google shows your products in shopping results
(Search Console)": the catalog's product pages (feed-match pageKey)
shown in 28 days; half or more passes, some warn, none fails, with
what to check (product schema: price, availability, GTIN). Without
Search Console, before its first read or unread: unknown, not scored.
- The MCP readiness reads the same (get_shopping_readiness).
To check on a live property (gkhngyk): the step 1 types list, and that
Composio applies dimension_filter_groups as sent
({ groupType, filters: [{ dimension, operator, expression }] }).
Co-Authored-By: Claude Opus 5.5 <[email protected]>
…g-appearance # Conflicts: # docs/guides/mcp-server.mdx # supabase/schema.sql # web/src/app/[locale]/(dashboard)/dashboard/shopping/page.tsx # web/src/app/api/mcp/product-visibility/ai-says/route.test.ts # web/src/app/api/mcp/product-visibility/ai-says/route.ts # web/src/app/api/mcp/product-visibility/readiness/route.test.ts # web/src/app/api/mcp/product-visibility/readiness/route.ts # web/src/app/api/mcp/product-visibility/shelf/route.test.ts # web/src/app/api/mcp/product-visibility/shelf/route.ts # web/src/lib/mcp/catalog.test.ts # web/src/lib/mcp/catalog.ts # web/src/lib/mcp/product-visibility-scope.test.ts # web/src/lib/mcp/product-visibility.test.ts # web/src/lib/mcp/product-visibility.ts # web/src/lib/mcp/server.ts # web/src/lib/mcp/subscription-gate.test.ts # web/src/lib/shopping/readiness.test.ts # web/src/lib/shopping/readiness.ts
|
Merged main forward. The conflicts (18 files: the MCP catalog / Product Visibility files, readiness, the Shopping page, Typecheck and the conflicted files' tests pass (readiness, Product Visibility MCP + routes, catalog, subscription gate, shopping search appearance; server gsc-sync tests); server lint clean. |
…ped read as unknown The type's total was counted by property, where a result showing several of the shop's products counts once, so a shop's page rows always added up past it and were dropped; the brand was then marked read and showed as having no product in Google's shopping results. The total is now counted by page, as the rows are, and a dropped read leaves the brand unread, so Readiness says it can't tell.
gkhngyk
left a comment
There was a problem hiding this comment.
Looks good with cc6b833: the totals per appearance type are read by page, as the rows are (aggregation_type: 'byPage'), and a dropped read clears gsc_shopping_synced_at so Readiness shows the item as not read yet rather than failing it; two tests. 00377 also revokes the default grants before giving members select. At merge time gsc_shopping_page_stats is listed in the demo coverage as skipped (Search Console never syncs a demo brand).
What I changed
- The filter check compared different counts. Step 1 read each appearance type's total with
aggregation_type: 'auto'. With only thesearchAppearancedimension, that means by property. Step 2 groups by page, so it is counted by page. Counted by property, a result that shows several of the shop's products counts once. Counted by page, each of those pages counts. So a shop whose products show side by side in a shopping unit (the shops this item is for) would add up more than 5% past the total, and every read would be dropped as "filter not applied". The brand was still stampedgsc_shopping_synced_at, so Readiness would read zero products shown and mark the item fail ("Google hasn't shown any of your product pages…").- Step 1 now asks
aggregation_type: 'byPage', so both sides are counted the same way. - A dropped read now clears
gsc_shopping_synced_at. Readiness then shows the item as unknown and leaves it out of the score, instead of claiming no product is shown. Another type that read fine is still kept. - Tests: the sync's appearance call asks by page, and a dropped read leaves the brand unread while the other type's rows are kept. Both fail on the PR's head.
- For the live-property check you already listed: please also confirm that the appearance read with
byPagecomes back for the property. If the API or Composio rejects it, the shopping sync logs "shopping sync failed" and the item stays unknown. Nothing would read wrong.
- Step 1 now asks
What I checked
- Migration 00377.
gsc_shopping_page_statshas RLS on, with only a member select policy. It's scoped like 00181'sgsc_page_stats, throughbrands.organization_id = profiles.organization_idforauth.uid(). There's agrant selecttoauthenticated. With no insert/update/delete policy, the default table grants don't let anon or members write. Only the sync (service role) does.- The unique key
(brand_id, page, appearance, date)matches the upsert'sonConflict. - Indexes cover the brand/date read and the table-wide date prune.
- The two
brandscolumns are nullable and have no default, so adding them doesn't rewrite the table. notify pgrstis at the end.
- Server. The shopping read runs inside the brand loop's own try/catch, so a failure there doesn't stop the query or page sync. Another property's rows are deleted before the read. Retention is 90 days.
- Web.
getShoppingSearchAppearancereads throughdbClient()(RLS for a person, the key's scope over MCP), the same as the other Readiness reads. Without a property, or before the first read, the item is unknown and isn't scored. Pages are matched withpageKeyon both sides. - No PostgREST embeds are added. No new server action writes.
- Tests:
gsc-sync*(23), the readiness, MCP and shopping-action tests (52) pass. Webtscpasses. The full server suite passes, except for suites that need a package missing from my local install and the known content-people timing test.
Merge on main: this PR's own diff merges cleanly. The stack under it (#1729 → #1733 → #1747) conflicts with main in web/src/lib/mcp/server.ts, web/src/lib/mcp/subscription-gate.test.ts and docs/guides/mcp-server.mdx (from #1715's MCP tools). Those conflicts belong to #1729 and need resolving there first.
Follow-ups
getShoppingSearchAppearancereads every (page, day, type) row of 28 days and dedupes them in the app. A large shop can have tens of thousands of rows: dozens of 1,000-row requests each time the Readiness tab opens (and on each MCP call). Aselect distinct pageRPC, or rolling up to one row per page and type, would make it a single small read.- The new function is inserted between
getShoppingFilterOptionsand its doc comment ("values that actually appear in this brand's data…"). That comment now sits abovegetShoppingSearchAppearance's own. - When a read is dropped, Readiness's unknown text says the results "come with its next daily sync". If the filter keeps being dropped, that's not quite right. A
not_readablereason would say what happened. - 00377's
create policyhas nodrop policy if exists, so it can't be run twice. That's the same as 00181. Fine as long as it's applied once.
Summary
Product Visibility's Readiness had no way to tell whether Google lists a shop's products when Merchant Center can't be connected, which is the case on the cloud today. Search Console can tell, from the brand's own property: the pages Google shows as merchant listings (the free shopping listings) and as product snippets.
Server: the daily GSC sync reads them.
[page, date]rows, filtered to that type.MERCHANT_LISTINGSand "Merchant listings" both count.gsc_shopping_page_stats(00377, readable by the brand's members). Rows for another property are dropped first, and 90 days are kept.brands.gsc_shopping_synced_atrecords that the read ran.Web: a new Readiness item.
pageKey) that were shown in the last 28 days:get_shopping_readiness) reads the same.Related issue
Follows #1270. Merchant Center isn't offered on the cloud; this is the Search Console fallback.
Stacked on #1747 (don't ask for Merchant Center where it isn't offered). The diff against #1747 holds only this change.
Type of change
feat— New featureHow to test
gsc_shopping_page_statsgets rows only if the property has merchant listings or product snippets, andbrands.gsc_shopping_synced_atis set either way.For the maintainer (live property): please check two things that can't be tried without a real property:
dimension_filter_groupsas sent ({ groupType, filters: [{ dimension, operator, expression }] }). If it ignores the filter, the impression check drops the read instead of storing every page.Checklist
bash supabase/build-schema.sh:schema.sqlis currentgsc-sync-shopping.test.js,shopping-search-appearance.test.ts,readiness.test.ts, MCP)🤖 Generated with Claude Code