Repository navigation
Description
What
When Google AI Mode detects shopping intent on a prompt, it returns
a structured shopping_cards array alongside the usual text +
sources. We currently throw that array away. This issue captures it
end-to-end so the data lands in prompt_results.shopping_cards for
future use.
Companion to #46 (Perplexity) and #47 (Copilot). All three
providers write into the same shopping_cards JSONB column on
prompt_results, raw, in their respective provider shapes. The
platform column on each row tells downstream consumers which shape
to expect.
Scope is intentionally narrow: data capture only. No UI, no
scoring changes, no brand-presence detection. UI lands in a separate
"Shopping" feature later.
Depends on #46
The migration that adds the shopping_cards column on
prompt_results is in #46. Either:
- Wait for feat(tracking): capture Perplexity shopping_cards data into prompt_results #46 to merge, then this PR only touches the AI Mode
parser branch (truly a one-file change), or - Coordinate with feat(tracking): capture Perplexity shopping_cards data into prompt_results #46's author so the migration lands first
If #46 hasn't merged when you open your PR, please rebase / reference
it explicitly so reviewers know the ordering.
Why three providers write into one column
Same reasoning as #47: different providers, different card shapes,
same semantic ("the AI surfaced product cards for this prompt").
Keeping one column means future UI just queries
WHERE shopping_cards != '[]'::jsonb across all platforms, with
no schema sprawl. Downstream consumers branch on platform for
shape interpretation.
The three shapes are genuinely different — that's fine, we store
raw and let the future UI map them.
Data shape (from the Cloro AI Mode endpoint)
Cloro returns result.shopping_cards (snake_case, like Perplexity).
Each card has fields like title, price (object with value +
currency), store, rating (number), reviews (string e.g.
"2.3k"), thumbnail, product_link, old_price, snippet,
snippet_links[]. See Cloro's AI Mode shopping cards endpoint
docs
for the full schema.
Note how this differs from the other two providers we've already
covered:
| Perplexity (#46) | Copilot (#47) | AI Mode (this PR) | |
|---|---|---|---|
| Raw key | shopping_cards |
shoppingCards |
shopping_cards |
| Product title field | title |
name |
title |
| Price field | string ("$140.00") |
object (amount/currency) |
object (value/currency) |
| Merchant field | merchant |
seller + brandName |
store |
| Image field | imageUrls[] (strings) |
images[] (objects) |
thumbnail (string) |
| Reviews count | numReviews (number) |
rating.count |
reviews (string!) |
We store the AI Mode array verbatim — no flattening, no shape
normalization. The future UI will branch on
prompt_results.platform === 'google-aimode' (or whatever the
scraper id is — confirm in cloro-scraper.js) to know it's AI Mode
shape.
Where to change
Cloro parser — AI Mode branch
server/src/lib/cloro-scraper.js — in the AI Mode branch of the
response-parsing function (around the 'google-aimode' model
mapping), pick up result.shopping_cards and pass it through:
return {
text,
citations,
model: 'google-aimode',
shopping_cards: result.shopping_cards ?? [],
};Same shape as the Perplexity branch in #46 — AI Mode uses snake_case
in the raw response too, so no key renaming is needed.
Don't transform the contents of the array — leave AI Mode's
field names alone (e.g., shopping_cards[0].title,
shopping_cards[0].store, shopping_cards[0].price.value).
The other branches that #46 covers (shopping_cards: [] default
for ChatGPT, Gemini, Claude) and #47 covers (Copilot's
camelCase-to-snake_case mapping) stay untouched — only the AI Mode
branch changes.
Anything else?
Nothing. The migration (#46), Supabase types (#46), and result
handler (#46) all already cover the storage path. This PR is a
single file change in cloro-scraper.js.
How to verify
- Trigger a tracking job for a brand with a clearly
shopping-intent prompt (e.g. "best wireless headphones under
$200") on AI Mode and confirm the resultingprompt_results
row has a non-emptyshopping_cardsarray containing
products with AI Mode-shaped fields (title,price.value,
store, etc.) - Trigger a tracking job for a non-shopping prompt on AI Mode
→shopping_cardsis[](AI Mode didn't return cards,
which is correct) - Perplexity rows (from feat(tracking): capture Perplexity shopping_cards data into prompt_results #46) and Copilot rows (from feat(tracking): capture Microsoft Copilot shoppingCards data into prompt_results #47) still
capture correctly with their respective shapes — all three
shapes coexist in the same column without collision - Non-shopping providers (ChatGPT, Gemini, Claude) still store
[]— no regression
Out of scope (explicitly future)
- AI Mode's separate
inline_productsarray (individual
product references embedded inline within the response text,
rather than in a dedicated carousel). That's a different surface
and deserves its own capture path — separate issue if/when we
want it. - Unifying the three provider shapes into a normalised schema —
done at the read / UI layer, not here - UI to display shopping cards (planned separately)
- Visibility score changes / shopping-card bonus
- Brand-in-shopping-cards detection
- MCP / REST API exposure of the new field
Contribution guide
See CONTRIBUTING.md for branch naming, commit
conventions, and PR workflow.
Activity
gkhngyk commentedon May 23, 2026
Quick correction for the record (implemented in #86): against the live Cloro response, AI Mode returns its cards under camelCase
shoppingCards(like Copilot), not snake_caseshopping_cardsas written above. The product fields are camelCase too (productLink,oldPrice,price.{value,currency,raw},store,rating,reviews). Verified with a real populated card. The PR usesaiMode.shoppingCards ?? []; stored verbatim. (inlineProductsconfirmed present, left out of scope.)feat(shopping): normalize prompt_result_shopping_cards + parser worker (
feat(tracking): capture Google AI Mode shopping cards into prompt_res…