Repository navigation
feat(tracking): capture Perplexity shopping_cards into prompt_results - #83
Merged
Merged
Conversation
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
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 was referenced May 26, 2026
Merged
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Perplexity returns a structured
shopping_cardsarray 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
00005_prompt_results_shopping_cards.sql—shopping_cards jsonb NOT NULL DEFAULT '[]'onprompt_results(mirrorscitations/competitor_mentions).cloro-scraper.js— parsed object now carriesshopping_cards: the generic/Perplexity branch passesresult.shopping_cards ?? []; the AI Overview / AI Mode branches return[]so the field is always present. JSDoc updated.cloro-result-handler.js— writesshopping_cards: aiResponse.shopping_cards ?? []on theprompt_resultsinsert.supabase.ts—prompt_resultsRow/Insert/Update gainshopping_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, servernode --check, and lint-parity all pass.shopping_cardsis 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.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 pushis 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.