Repository navigation
feat(shopping): brand-level Shopping mode toggle + ChatGPT Shopping platform + Insights isolation (#155) - #157
Merged
Merged
Conversation
…latform + Insights isolation (#155) Adds a per-brand "Shopping mode" toggle in Brand Settings. Flipping it on adds `chatgpt-shopping` to every existing prompt's platforms array and inserts the matching brand_platforms row, and the same default is applied to any new prompt created under that brand thereafter. Flipping off preserves history. ChatGPT Shopping is a new Cloro scraper variant — same CHATGPT task with `include.shopping: true` — that returns `shoppingCards` + `inlineProducts` alongside the normal response. The cards land on the shared prompt_results.shopping_cards column; the new prompt_results.inline_products jsonb column carries the inline-products array. Because that scraper runs a different model (`gpt-5-3-mini`) whose visibility_score isn't comparable to a normal ChatGPT answer, every Insights surface — the three aggregate RPCs in 00006, visibility_trend_aggregates in 00008, and the equivalent TS paths in tracking.ts + mcp/data.ts — now excludes `platform = 'chatgpt-shopping'`. The Shopping dashboard is the only place that consumes those rows; it reads from prompt_result_shopping_cards directly and is unaffected. The Shopping sidebar entry is hidden by default and only appears when at least one brand in the org has Shopping mode on (still subject to the existing `shopping_analytics` plan gate). PlanProvider carries the derived org-wide signal so the sidebar doesn't need its own fetch. Closes #155, supersedes #95.
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.
Closes #155, supersedes #95.
Summary
chatgpt-shoppingto every existing prompt under that brand and inserts the matchingbrand_platformsrow (both idempotent).chatgpt-shoppinginto the platforms list automatically so the user doesn't have to remember it per prompt.brand_platformsrows stay so any already-captured ChatGPT Shopping data remains queryable.ChatGPT Shopping platform
chatgpt-shopping— same CHATGPT task,include.shopping: true. ParsesshoppingCardstoprompt_results.shopping_cardsandinlineProductsto the newprompt_results.inline_productsjsonb column.starter.allowedScraperswas already restrictive enough; growth / self-hosted / enterprise use the implicit "allow all" path.Insights isolation
The ChatGPT Shopping scraper runs on
gpt-5-3-mini, so itsvisibility_scoreis not comparable to a normal ChatGPT answer. Mixing those rows into brand-level Insights would skew visibility/mentions/citations. The migration filtersplatform <> 'chatgpt-shopping'in:insights_aggregates,competitor_aggregates,share_of_voice_aggregates(originally defined in00006_insights_aggregates.sql)visibility_trend_aggregates(originally defined in00008_visibility_trend_aggregates.sql)Plus the matching TS callers in
web/src/lib/actions/tracking.tsandweb/src/lib/mcp/data.ts(getVisibilitySummaryFor,listCitationsFor, the head-to-head comparison, the per-prompt visibility summary, etc.) — each call site has a// #155 — …comment so the next contributor doesn't drop the filter.The Shopping dashboard at
/dashboard/shoppingis the only surface that consumesplatform = 'chatgpt-shopping'rows and isn't affected — it reads from the normalizedprompt_result_shopping_cardstable.Sidebar gating
The Shopping sidebar entry stays hidden by default. It's revealed when any brand in the org has Shopping mode on, on top of the existing
shopping_analyticsplan-feature gate.PlanProvidercarries the derived org-wide flag so the sidebar doesn't need its own fetch.Schema
supabase/migrations/00012_shopping_mode.sql:brands.shopping_mode_enabledboolean default falseprompt_results.inline_productsjsonb default[]CREATE OR REPLACEof the four aggregate RPCs with the new filterAcceptance criteria
shopping_analyticsplan feature is unlocked AND at least one brand has Shopping mode on.chatgpt-shoppingto every prompt's platforms array under that brand; flipping OFF does not remove them.chatgpt-shoppinginto their platforms.yarn tsc --noEmit+yarn lint+yarn format:checkclean.Test plan
X prompt(s) updated; verify in DB that every prompt'splatformsarray now containschatgpt-shoppingbrand_platformshas a(brand_id, 'chatgpt-shopping', is_enabled=true)row for that brandchatgpt-shoppingshows up in the saved platforms list automaticallybrand_platforms+ prompts platforms stay (verify in DB)chatgpt-shoppingand normal results, confirm the shopping rows don't show up in aggregates/dashboard/shoppingstill surfaces shopping datachatgpt-shoppingenabled → confirm aprompt_resultsrow withplatform = 'chatgpt-shopping'lands withshopping_cards+inline_productspopulated