Repository navigation
Description
Epic — supersedes #95. Adds an org-level "Shopping mode" toggle in Settings on top of the per-brand ChatGPT Shopping platform from #95, plus an explicit Insights isolation rule.
Why now
Shopping is meaningful for product / e-commerce brands and irrelevant for everyone else — so the Shopping dashboard and the per-brand ChatGPT Shopping scrape should both stay hidden by default. Today the Shopping sidebar entry is always visible (plan-gated only) and #95 only exposes ChatGPT Shopping as a per-brand toggle deep in Brand Settings. A single coarse switch — "I do e-commerce" — at the org level is a cleaner UX hook than expecting customers to find a per-brand checkbox.
A second decision: ChatGPT Shopping returns answers from a different model (gpt-5-3-mini) under include.shopping: true — its visibility_score is not comparable to a normal ChatGPT text response. Mixing those rows into the Insights aggregates would skew brand-level visibility numbers. The shopping data captured by Perplexity / AI Mode / Copilot is fine to keep in Insights because their shopping cards are a side-payload of the same model's answer; ChatGPT Shopping isn't.
Scope
1. Org-level "Shopping mode" toggle
- New field on
organizations(e.g.shopping_mode_enabled boolean not null default false). - New section in
web/src/components/settings— Settings → Project (or its own card) — single checkbox "I'm in e-commerce / shopping". Default off. Admin-only via the existinguseUserRole().canAdmingate. - New REST endpoint to read / update the flag (mirror the
/api/settings/anthropic-keypattern).
2. Sidebar gating
- The Shopping entry in
web/src/config/dashboard.tsis hidden unlessshopping_mode_enabled === true. Combine the existingrequiredFeature: 'shopping_analytics'plan gate with the new org-preference gate — both must pass.
3. Auto-bulk ChatGPT Shopping platform
When the org toggle flips from false → true:
- For every existing brand in the org: insert a
brand_platformsrow withplatform = 'chatgpt-shopping'andis_enabled = true(idempotent — useON CONFLICT DO NOTHINGagainst the existing unique constraint). - For brands created after the toggle is on, the new-brand path defaults
chatgpt-shoppingon too. - When the toggle flips
true → false: do not delete the rows or disable them (preserve historical opt-ins). Just hide the sidebar entry and stop adding the platform to new brands. The per-brand toggle in Brand Settings remains the granular override.
4. ChatGPT Shopping pipeline (#95's original scope, kept)
- New scraper
chatgpt-shoppinginserver/src/lib/cloro-scraper.js— CloroCHATGPTtask withinclude.shopping: true. parseScraperResponsereturnsshopping_cards: result.shoppingCards ?? []ANDinline_products: result.inlineProducts ?? []for this scraper.- Migration:
prompt_results.inline_products jsonb not null default '[]'(mirrorsshopping_cards). - Plan gating in
web/src/config/plans.ts:chatgpt-shoppingstays out ofstarter.allowedScrapers. Growth + self-hosted + enterprise allow it.
5. Insights data isolation
Every server function that aggregates prompt_results for visibility / Insights / Citations / Competitors excludes platform = 'chatgpt-shopping'. Concrete touch points:
web/src/lib/actions/tracking.ts— everyfrom('prompt_results').…chain and every RPC call.- The RPC functions themselves in
supabase/migrations/00006_insights_aggregates.sqland00008_visibility_trend_aggregates.sql— addAND pr.platform <> 'chatgpt-shopping'to eachWHEREclause. web/src/lib/mcp/data.ts— same filter forgetVisibilitySummaryFor,getCompetitorComparisonFor,listCitationsFor,getVisibilityTrendFor.
Document the rule with a comment near each call site so the next contributor doesn't accidentally drop it.
The Shopping page (/dashboard/shopping) is the only surface that should consume platform = 'chatgpt-shopping' rows — it already does the right thing via the prompt_result_shopping_cards table.
Acceptance criteria
- New Settings checkbox toggles
organizations.shopping_mode_enabled. Admin-only write. - Sidebar Shopping entry visible only when both
shopping_analyticsplan feature is unlocked ANDshopping_mode_enabled = true. - Flipping the toggle ON bulk-adds
chatgpt-shoppingto every brand'sbrand_platforms; flipping it OFF does not remove them. - New brand creation path adds
chatgpt-shoppingwhen org has shopping mode on. - ChatGPT Shopping rows (
platform = 'chatgpt-shopping') are excluded from Insights aggregations — Brand visibility, Competitor comparison, Citations, Visibility trend. - The Shopping page still shows ChatGPT Shopping data (no double-filtering).
-
pnpm tsc --noEmit+yarn lint+pnpm format:checkclean.
Out of scope
- A bulk "remove ChatGPT Shopping from all brands" admin action — flipping the toggle off intentionally preserves history. If anyone wants this later, separate issue.
- The Shopping page's My Products / Competitors / Prompts tabs — tracked in feat(shopping): My Products / Competitors tabs with brand matching #105 / feat(shopping): card-eligible prompts tab #106 / feat(mcp): expose list_shopping_cards / get_product_visibility tools + REST endpoints #107.
- An audit table of who toggled the flag — not worth the complexity until we hear a real ask.
Why this supersedes #95
#95 is the capture-and-platform layer only (new scraper, per-brand toggle, plan gating). The org-level toggle + the Insights isolation rule are new asks on top. This issue covers both layers as one shippable epic. Closing #95 with a redirect here.
Activity
feat(shopping): brand-level Shopping mode toggle + ChatGPT Shopping p…
fix(citations): exclude chatgpt-shopping rows to match the insights KPIs
fix(shopping): keep chatgpt-shopping off brands that have Shopping di…
fix(citations): exclude chatgpt-shopping rows to match the insights K…
fix(topics): paginate the overview scan and exclude chatgpt-shopping (#…
feat(topics): persisted AI topic suggestions on the Topics page (#497)