Repository navigation
Description
What
When Microsoft Copilot surfaces product data on a prompt, it returns
a structured shoppingCards 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 (same capture for Perplexity). Both 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 Copilot
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 both providers write into one column
Different providers, different card shapes — but the 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 - No schema sprawl as more providers add similar features
- Downstream consumers branch on
platformfor shape interpretation
— that's already howmodel_usedworks
Copilot and Perplexity payload shapes differ significantly — that's
fine, we store raw and let the future UI map them.
Data shape (from the Cloro Copilot endpoint)
Cloro returns result.shoppingCards (note the camelCase) as an
array of card objects, each with type, layout, and products[].
See Cloro's Copilot shopping cards endpoint docs
for the full schema.
Per-product fields differ from Perplexity's — relevant ones include
name, url, description, images[] (objects with title +
url), specifications[], price (object with amount /
currency / currencySymbol), discountPrice, seller,
brandName, rating (object with value / count),
canTrackPrice.
We store the whole array verbatim — no flattening, no shape
normalization. Future UI / analytics code will branch on
prompt_results.platform === 'copilot-web' to know it's Copilot
shape.
Where to change
Cloro parser — Copilot branch
server/src/lib/cloro-scraper.js — in the Copilot branch of the
response-parsing function, pick up result.shoppingCards and pass
it through under the snake_case key shopping_cards so the
downstream handler doesn't need a Copilot-specific code path:
return {
text,
citations,
model,
shopping_cards: result.shoppingCards ?? [],
// ^^^^^^^^^^^^^^^^^^^^ Copilot uses camelCase in
// its raw response — we normalise the parsed-object
// key so it matches the column name and the
// Perplexity branch.
};Don't transform the contents of the array — just unwrap the
camelCase key. Inside each card object, leave Copilot's field names
alone (e.g., shopping_cards[0].products[0].name, not title).
The other branches that #46 already updated (shopping_cards: []
default for ChatGPT, Gemini, AI Overview, AI Mode, Claude) stay
untouched — only the Copilot 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 laptops for software
development") on Copilot and confirm the resulting
prompt_resultsrow has a non-emptyshopping_cardsarray
containing products with Copilot-shaped fields (name,
price.amount,seller, etc.) - Trigger a tracking job for a non-shopping prompt on Copilot
→shopping_cardsis[](Copilot didn't return cards,
which is correct) - Perplexity rows from feat(tracking): capture Perplexity shopping_cards data into prompt_results #46 still capture correctly with their
shape (shopping_cards[0].products[0].title, etc.) — the two
shapes coexist in the same column without collision - Non-shopping providers (ChatGPT, Gemini, etc.) still store
[]— no regression
Out of scope (explicitly future)
- Unifying the Copilot vs Perplexity 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 (matching
seller/
brandName/urlagainst brand domains) - MCP / REST API exposure of the new field
Contribution guide
See CONTRIBUTING.md for branch naming, commit
conventions, and PR workflow.
Activity
feat(tracking): capture Microsoft Copilot shoppingCards into prompt_r…
feat(tracking): capture Google AI Mode shopping cards into prompt_res…
feat(tracking): capture Microsoft Copilot shoppingCards into prompt_r…