Skip to content

feat(tracking): capture Perplexity shopping_cards into prompt_results - #83

Merged
gkhngyk merged 1 commit into
mainfrom
feat/tracking-shopping-cards
May 23, 2026
Merged

gkhngyk merged 1 commit into
mainfrom
feat/tracking-shopping-cards

Conversation

@gkhngyk

@gkhngyk gkhngyk commented May 23, 2026

Copy link
Copy Markdown
Contributor

Summary

Perplexity returns a structured shopping_cards array on shopping-intent prompts (alongside text + sources). We were discarding it. This captures it end-to-end (Cloro → parser → DB) so the highest-commercial-intent visibility signal is recorded from now on — by the time a Shopping UI lands, there's historical data behind it.

Data-capture only — no UI, no scoring change, no brand-in-card detection (all deliberately out of scope, per the issue).

Closes #46

Changes

  • Migration 00005_prompt_results_shopping_cards.sql — shopping_cards jsonb NOT NULL DEFAULT '[]' on prompt_results (mirrors citations / competitor_mentions).
  • cloro-scraper.js — parsed object now carries shopping_cards: the generic/Perplexity branch passes result.shopping_cards ?? []; the AI Overview / AI Mode branches return [] so the field is always present. JSDoc updated.
  • cloro-result-handler.js — writes shopping_cards: aiResponse.shopping_cards ?? [] on the prompt_results insert.
  • supabase.ts — prompt_results Row/Insert/Update gain shopping_cards: Json.

The whole array is stored verbatim as JSONB — no flattening, every field preserved for future analysis without another schema change.

Verification

  • typecheck, format:check, server node --check, and lint-parity all pass.
  • Live smoke test against Cloro Perplexity: confirmed shopping_cards is a real top-level key in the response (text, sources, citationPills, shopping_cards, related_queries, videos, search_model_queries, markdown) — exactly the path the parser reads. The empty-state ([]) is captured correctly.
  • Note: across ~16 shopping-intent prompts (US + GB) Perplexity returned shopping_cards: [] every time during testing — it isn't surfacing cards right now. The field path and capture are verified; populated cards will be recorded automatically whenever Perplexity returns them.

Migration note

Additive, idempotent default backfill ('[]'), no RLS change. Already applied to the production project; safe to run again (db push is a no-op given the default). Existing rows read fine with the '[]' backfill.

Out of scope (future)

Shopping UI, visibility-score bonus, brand-in-card detection, aggregated insights, MCP/REST exposure.

Perplexity returns a structured shopping_cards array on shopping-intent
prompts; we were discarding it. Capture it end-to-end (Cloro -> parser ->
DB) so the commerce-intent signal is recorded for a future Shopping UI.

- migration 00005 adds shopping_cards jsonb NOT NULL DEFAULT '[]' to
  prompt_results (mirrors citations / competitor_mentions)
- cloro-scraper returns shopping_cards on the parsed object: the
  generic/Perplexity branch passes result.shopping_cards ?? []; AI
  Overview / AI Mode return [] so the field is always present
- cloro-result-handler writes shopping_cards on the prompt_results insert
- supabase types updated (prompt_results Row/Insert/Update)

Data-capture only — no UI, scoring, or brand-in-card detection (all
deliberately out of scope for a follow-up feature).

Closes #46
@gkhngyk gkhngyk closed this May 23, 2026
@gkhngyk gkhngyk reopened this May 23, 2026
@gkhngyk
gkhngyk merged commit 1b2860f into main May 23, 2026
4 checks passed
gkhngyk added a commit that referenced this pull request May 23, 2026
…esults (#85)

Companion to #46. Copilot returns its product cards under camelCase
`shoppingCards`; unwrap it into the same parsed `shopping_cards` key so it
lands in prompt_results.shopping_cards raw (Copilot shape), alongside
Perplexity's snake_case cards in the same column. Contents are stored
verbatim — downstream branches on `platform` for shape.

Stacked on #46 (PR #83), which adds the column, types, and result-handler.

Closes #47

This branch was successfully deployed

1 active deployment
Preview — 22c48032 Deployed May 23, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(tracking): capture Perplexity shopping_cards data into prompt_results

1 participant