Repository navigation
feat(shopping): sidebar entry + Shopping overview page - #144
Merged
Merged
Conversation
Closes #104. Adds the first user-visible surface for the shopping-cards normalization that landed in #103. Sidebar gets a 'Shopping' entry under Citations, new route at /dashboard/shopping with: - Top filter bar: date preset (7d/30d/90d/all) + platform + region, dropdowns populated from the brand's actual data (no values that don't appear get listed). - Four KPI cards: shopping card rate, your products surfaced (`role=own` count), shopping share of voice (own / all cards in card-bearing prompts), top merchant by own-card frequency. - Bar chart of card rate by platform. - 30-day line chart of own cards vs all cards over time. - Empty state for brands with zero shopping data. New `shopping_analytics` feature flag in config/plans.ts. Free / Starter see only the first KPI; the other three plus both charts gate to Growth+ with an upgrade card. Self-host stays unrestricted. Server actions live in web/src/lib/actions/shopping.ts and aggregate in-process — the row counts the dashboard hits are small enough that JS aggregation is cheaper than another RPC. Date-range filters route through expandDateToEndOfDay so today's data lands on the right side of the bound. Also regenerates supabase types so prompt_result_shopping_cards is known to the query builder (was missing after #103).
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 #104. First user-visible surface for the shopping-cards normalization that landed in #103.
What
shopping-bagicon. Plan-gated via the newshopping_analyticsfeature flag./dashboard/shopping(web/src/app/[locale]/(dashboard)/dashboard/shopping/page.tsx).web/src/lib/actions/shopping.ts.shopping_analyticsadded to FEATURES + self_hosted + growth + enterprise feature lists.prompt_result_shopping_cards(was missing after the feat(shopping): normalize prompt_result_shopping_cards + parser worker #103 migration).Page contents
Filter bar — date preset (7d / 30d / 90d / all) + platform + region. Dropdowns are populated from
getShoppingFilterOptionsso they only list values that appear in this brand's data.KPIs (4 cards):
prompts with ≥1 card / total promptsin the window.matched_brand_role = 'own'cards.merchant_domainwhere role isown.Charts:
Empty state when no cards exist yet — friendly explainer pointing at commercial-intent prompts.
Plan gating
Implemented via the existing
useFeatureGatehook with the newshopping_analyticsflag.Data path
Server actions aggregate in JS because the row count is small. The card-rate denominator hits
prompt_resultsdirectly (need to know about cards-free prompts too); the other metrics aggregate over the normalizedprompt_result_shopping_cardstable. Date filters route throughexpandDateToEndOfDayso today's data lands on the right side of the upper bound.Org isolation is enforced at the DB layer — RLS on
prompt_result_shopping_cardsalready restricts to the caller's organization; the action just filters bybrand_id.Test plan
/dashboard/shoppingrenders all 4 KPI cards + both charts. With no cards in the DB yet, the empty state appears instead.Out of scope
use cache—cacheComponentsflag isn't on in next.config, so this is a regular async client component