Skip to content

feat(tracking): capture Microsoft Copilot shoppingCards data into prompt_results #47

Closed

Description

@gkhngyk

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:

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 platform for shape interpretation
    — that's already how model_used works

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_results row has a non-empty shopping_cards array
    containing products with Copilot-shaped fields (name,
    price.amount, seller, etc.)
  • Trigger a tracking job for a non-shopping prompt on Copilot
    → shopping_cards is [] (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 / url against brand domains)
  • MCP / REST API exposure of the new field

Contribution guide

See CONTRIBUTING.md for branch naming, commit
conventions, and PR workflow.

Activity

  1. added
    enhancement
    good first issue
    help wanted
    on May 18, 2026
  2. added a commit that references this issue on May 23, 2026
    61e64fb
  3. added a commit that references this issue on Sep 17, 2026
    f916064
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementgood first issuehelp wanted

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions