Skip to content

Open-source agentic AI Search Execution Platform. Track AI visibility, find opportunities, and let agents turn signals into prioritized actions and drafted fixes across ChatGPT, Claude, Gemini, Google AI Overviews, Google AI Mode, Perplexity, Grok, and Microsoft Copilot.

feat(shopping): open Product Visibility with its data sources, a Why popup and the Shelf and Products tabs (product visibility, part 1) (#1636)

Cihan47c575bd19ff
diff --git a/web/messages/en.json b/web/messages/en.json
index 7b26500a6..bffd78684 100644
--- a/web/messages/en.json
+++ b/web/messages/en.json
@@ -7919,7 +7919,54 @@
},
"shopping": {
"title": "Product Visibility",
- "description": "Product cards AI engines surface — your products versus the competitive set.",
+ "description": "Which of your products AI recommends, why, and what it sells.",
+ "why": {
+ "button": "Why Ansvisor Product Visibility?",
+ "eyebrow": "Why Ansvisor Product Visibility?",
+ "title": "From AI shelf to cart",
+ "lead": "AI assistants now pick products for your shoppers. See which of yours make the shelf, fix the ones that don't, and know what it sells.",
+ "steps": {
+ "shelf": {
+ "title": "See your AI shelf",
+ "body": "For every shopping question, the products AI shows, in order. Yours and your competitors'."
+ },
+ "why": {
+ "title": "Know why you lost",
+ "body": "Your product next to the one AI picked, attribute by attribute: fit, weight, rating, delivery, data."
+ },
+ "fix": {
+ "title": "Fix it, then push",
+ "body": "The agent rewrites titles, feed fields and schema. You approve, we send it to Shopify."
+ },
+ "sell": {
+ "title": "See what it sells",
+ "body": "Orders and revenue from AI, per product, tied to the questions that brought them."
+ }
+ },
+ "closing": "Most tools tell you if you're visible. Ansvisor shows why, fixes it and shows the sales.",
+ "gotIt": "Got it",
+ "connectGa": "Connect Google Analytics",
+ "ga": "Google Analytics"
+ },
+ "sources": {
+ "label": "Data sources",
+ "catalog": "Product catalog",
+ "catalogLine": "{count, plural, one {# product} other {# products}} · synced {when}",
+ "catalogNotSynced": "{count, plural, one {# product} other {# products}} · not synced yet",
+ "catalogNone": "Not connected · your products, from a feed, a file or your store",
+ "catalogFailed": "Couldn't be read right now",
+ "ga": "Google Analytics",
+ "gsc": "Google Search Console",
+ "gaPitch": "Not connected · see the path from AI visit to order",
+ "gscPitch": "Not connected · shopping questions from your real searches",
+ "googleFailed": "Couldn't be read right now",
+ "marketplaces": "Marketplaces & feeds",
+ "connected": "Connected",
+ "connect": "Connect",
+ "notConnected": "Not connected",
+ "soon": "Soon",
+ "manage": "Manage"
+ },
"kpiCardRate": "Shopping card rate",
"kpiCardRateSub": "Tracked prompts that returned ≥1 card",
"kpiOwnProducts": "Your products surfaced",
@@ -7951,7 +7998,8 @@
"emptyDescription": "Perplexity, Google AI Mode, and Microsoft Copilot return shopping cards on commercial-intent prompts (\"best running shoes for marathon training\"). Once tracking runs against a card-eligible prompt, results show up here.",
"lockedTitle": "Upgrade for full shopping analytics",
"lockedDescription": "Free and Starter plans see the shopping card rate. Growth unlocks the My Products tab, competitor breakdown, card-eligible prompts, and merchant analytics.",
- "tabOverview": "Overview",
+ "tabShelf": "Shelf",
+ "tabProducts": "Products",
"tabMyProducts": "My Products",
"connectCatalog": "These are your products as AI shopping cards showed them. Add your product catalog (a product feed URL or a file you upload) in <link>Settings › Integrations</link>, and the Content Editor checks your product pages' price, GTIN and stock against it.",
"tabCompetitors": "Competitors",
diff --git a/web/src/app/[locale]/(dashboard)/dashboard/shopping/_data-strip.test.tsx b/web/src/app/[locale]/(dashboard)/dashboard/shopping/_data-strip.test.tsx
new file mode 100644
index 000000000..26e0fb277
--- /dev/null
+++ b/web/src/app/[locale]/(dashboard)/dashboard/shopping/_data-strip.test.tsx
@@ -0,0 +1,137 @@
+import { act } from 'react';
+import { createRoot, type Root } from 'react-dom/client';
+import { NextIntlClientProvider } from 'next-intl';
+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
+import messages from '../../../../../../messages/en.json';
+import type { CatalogSource } from '@/lib/catalog';
+import type { SourceState } from '@/lib/actions/integrations';
+
+/** Product Visibility's data sources and marketplaces row (ECOM-009). */
+
+vi.mock('@/i18n/navigation', () => ({
+ Link: ({ href, children, ...rest }: { href: string; children: React.ReactNode }) => (
+ <a href={href} {...rest}>
+ {children}
+ </a>
+ ),
+}));
+vi.mock('@/hooks/use-integration-connect', () => ({
+ useIntegrationConnect: () => ({ connecting: false, connect: vi.fn() }),
+}));
+vi.mock('@/lib/actions/catalog', () => ({ listCatalogSources: vi.fn() }));
+vi.mock('@/lib/actions/traffic', () => ({ getTrafficSources: vi.fn() }));
+vi.mock('../traffic/_bots-connect', () => ({ BotsSource: () => null }));
+
+const { ProductDataStrip } = await import('./_data-strip');
+
+(globalThis as typeof globalThis & { IS_REACT_ACT_ENVIRONMENT: boolean }).IS_REACT_ACT_ENVIRONMENT =
+ true;
+
+let container: HTMLDivElement;
+let root: Root;
+
+beforeEach(() => {
+ vi.useFakeTimers({ now: new Date('2026-10-27T12:00:00Z'), toFake: ['Date'] });
+ container = document.createElement('div');
+ document.body.appendChild(container);
+ root = createRoot(container);
+});
+
+afterEach(() => {
+ act(() => root.unmount());
+ container.remove();
+ vi.useRealTimers();
+});
+
+const off: SourceState = {
+ configured: true,
+ connected: false,
+ mapped: false,
+ firstDataAt: null,
+ lastDataAt: null,
+ property: null,
+};
+
+const source = (over: Partial<CatalogSource>): CatalogSource => ({
+ id: 's1',
+ kind: 'feed_url',
+ format: 'auto',
+ url: 'https://shop.example/feed.xml',
+ account: null,
+ label: null,
+ lastSyncedAt: '2026-10-27T11:00:00Z',
+ lastStatus: 'ok',
+ lastError: null,
+ lastCounts: null,
+ products: 200,
+ ...over,
+});
+
+function render(catalog: CatalogSource[] | null, canConnect = true, loaded = true) {
+ act(() => {
+ root.render(
+ <NextIntlClientProvider locale="en" messages={messages} timeZone="UTC">
+ <ProductDataStrip
+ sources={{
+ loaded,
+ catalog,
+ google: { snippetLastVisitAt: null, ga: off, gsc: off },
+ reload: () => {},
+ }}
+ domain="shop.example"
+ canConnect={canConnect}
+ onConnected={() => {}}
+ />
+ </NextIntlClientProvider>,
+ );
+ });
+ return container.textContent ?? '';
+}
+
+const chip = (id: string) => container.querySelector(`[data-marketplace="${id}"]`)?.textContent;
+
+describe('ProductDataStrip', () => {
+ it("counts the catalog's products and its last sync, and says what GA and GSC add here", () => {
+ const text = render([
+ source({}),
+ source({ id: 's2', products: 120, lastSyncedAt: '2026-10-26T12:00:00Z' }),
+ ]);
+ expect(text).toContain('Product catalog');
+ expect(text).toContain('320 products · synced');
+ expect(text).toContain('Not connected · see the path from AI visit to order');
+ expect(text).toContain('Not connected · shopping questions from your real searches');
+ expect(container.querySelector('a[href="/dashboard/settings/integrations"]')?.textContent).toBe(
+ 'Manage',
+ );
+ });
+
+ it('asks for the catalog when there is none, with Connect for those who may connect it', () => {
+ expect(render([])).toContain(
+ 'Not connected · your products, from a feed, a file or your store',
+ );
+ expect([...container.querySelectorAll('a')].some((a) => a.textContent === 'Connect')).toBe(
+ true,
+ );
+ render([], false);
+ expect([...container.querySelectorAll('a')].some((a) => a.textContent === 'Connect')).toBe(
+ false,
+ );
+ });
+
+ it('marks Merchant Center connected when it is a catalog source, and the marketplaces as to come', () => {
+ render([source({})]);
+ expect(chip('merchant_center')).toContain('Connect');
+ expect(chip('amazon')).toBe('aAmazonSoon');
+ expect(chip('hepsiburada')).toBe('HHepsiburadaSoon');
+ render([source({ kind: 'merchant_center' })]);
+ expect(chip('merchant_center')).toBe('GGoogle Merchant CenterConnected');
+ render([source({})], false);
+ expect(chip('merchant_center')).toBe('GGoogle Merchant CenterNot connected');
+ });
+
+ it("says when the catalog couldn't be read, and waits while it loads", () => {
+ expect(render(null)).toContain("Couldn't be read right now");
+ render(null, true, false);
+ expect(container.textContent).toBe('');
+ });
+});
diff --git a/web/src/app/[locale]/(dashboard)/dashboard/shopping/_data-strip.tsx b/web/src/app/[locale]/(dashboard)/dashboard/shopping/_data-strip.tsx
new file mode 100644
index 000000000..7264e0fbb
--- /dev/null
+++ b/web/src/app/[locale]/(dashboard)/dashboard/shopping/_data-strip.tsx
@@ -0,0 +1,225 @@
+'use client';
+
+import { useCallback, useEffect, useState } from 'react';
+import { useTranslations } from 'next-intl';
+import { Link } from '@/i18n/navigation';
+import { buttonVariants } from '@/components/ui/button-variants';
+import { Skeleton } from '@/components/ui/skeleton';
+import { cn } from '@/lib/utils';
+import { formatRelative } from '@/lib/format-relative';
+import { listCatalogSources } from '@/lib/actions/catalog';
+import { getTrafficSources, type TrafficSources } from '@/lib/actions/traffic';
+import type { CatalogSource } from '@/lib/catalog';
+import { CATALOG_SETTINGS_PATH } from '@/lib/content/feed-match';
+import { SourceCard } from '../traffic/_source-card';
+import { GoogleSource } from '../traffic/_sources-strip';
+
+/** What feeds Product Visibility: the brand's catalog sources, and Google Analytics and Search Console. */
+export interface ProductSources {
+ /** Null while loading, or when it couldn't be read. */
+ catalog: CatalogSource[] | null;
+ google: TrafficSources | null;
+}
+
+/** The brand's sources, read once per brand and again after a connection made on the page. */
+export function useProductSources(brandId: string | null) {
+ const [sources, setSources] = useState<ProductSources & { brandId: string | null }>({
+ brandId: null,
+ catalog: null,
+ google: null,
+ });
+ const [attempt, setAttempt] = useState(0);
+ useEffect(() => {
+ if (!brandId) return;
+ let cancelled = false;
+ void Promise.all([
+ listCatalogSources(brandId).catch(() => null),
+ getTrafficSources(brandId).catch(() => null),
+ ]).then(([catalog, google]) => {
+ if (!cancelled) setSources({ brandId, catalog, google });
+ });
+ return () => {
+ cancelled = true;
+ };
+ }, [brandId, attempt]);
+ const reload = useCallback(() => setAttempt((n) => n + 1), []);
+ // A read for another brand (just switched) counts as still loading.
+ const current = sources.brandId === brandId ? sources : { catalog: null, google: null };
+ return {
+ loaded: sources.brandId === brandId,
+ catalog: current.catalog,
+ google: current.google,
+ reload,
+ };
+}
+
+/**
+ * The marketplaces and feeds a brand's products also sell through (ECOM-spec
+ * §3.0). Google Merchant Center connects in Settings › Integrations, as a
+ * catalog source; the marketplaces have no connector yet.
+ */
+const MARKETPLACES = [
+ { id: 'merchant_center', name: 'Google Merchant Center', mark: 'G' },
+ { id: 'amazon', name: 'Amazon', mark: 'a' },
+ { id: 'ebay', name: 'eBay', mark: 'e' },
+ { id: 'walmart', name: 'Walmart', mark: 'W' },
+ { id: 'etsy', name: 'Etsy', mark: 'E' },
+ { id: 'trendyol', name: 'Trendyol', mark: 'T' },
+ { id: 'hepsiburada', name: 'Hepsiburada', mark: 'H' },
+] as const;
+
+type ChipState = 'connected' | 'connect' | 'soon';
+
+function chipState(id: string, catalog: CatalogSource[]): ChipState {
+ if (catalog.some((source) => source.kind === id)) return 'connected';
+ return id === 'merchant_center' ? 'connect' : 'soon';
+}
+
+/** The newest sync of the brand's sources, or null when none has synced. */
+function lastSync(catalog: CatalogSource[]): string | null {
+ return catalog.reduce<string | null>(
+ (latest, source) =>
+ source.lastSyncedAt && (!latest || source.lastSyncedAt > latest)
+ ? source.lastSyncedAt
+ : latest,
+ null,
+ );
+}
+
+/**
+ * Product Visibility's data sources (ECOM-009), as AI Traffic's strip: the
+ * catalog (its products and last sync), Google Analytics (the path from an
+ * AI visit to an order) and Google Search Console (shopping questions from
+ * real searches), each with Connect or Manage. Under it, the marketplaces
+ * and feeds row.
+ */
+export function ProductDataStrip({
+ sources,
+ domain,
+ canConnect,
+ onConnected,
+}: {
+ sources: ReturnType<typeof useProductSources>;
+ /** The brand's primary domain, for the GA4 property line. */
+ domain: string | undefined;
+ canConnect: boolean;
+ onConnected: () => void;
+}) {
+ const t = useTranslations('shopping.sources');
+ const tCommon = useTranslations('common');
+
+ if (!sources.loaded) {
+ return <Skeleton className="h-[104px] w-full rounded-xl" />;
+ }
+
+ const catalog = sources.catalog ?? [];
+ const products = catalog.reduce((sum, source) => sum + source.products, 0);
+ const synced = lastSync(catalog);
+ const failing = catalog.some((source) => source.lastStatus && source.lastStatus !== 'ok');
+ const settingsLink = (label: string, primary = false) => (
+ <Link
+ href={CATALOG_SETTINGS_PATH}
+ className={cn(
+ buttonVariants({ variant: primary ? 'default' : 'outline', size: 'sm' }),
+ 'h-7 text-xs',
+ )}
+ >
+ {label}
+ </Link>
+ );
+
+ return (
+ <div className="space-y-2">
+ <section
+ aria-label={t('label')}
+ className="grid gap-px overflow-hidden rounded-xl border bg-border sm:grid-cols-3"
+ >
+ {sources.catalog === null ? (
+ <SourceCard tone="off" title={t('catalog')} line={t('catalogFailed')} />
+ ) : catalog.length === 0 ? (
+ <SourceCard
+ tone="off"
+ title={t('catalog')}
+ line={t('catalogNone')}
+ action={canConnect ? settingsLink(t('connect'), true) : undefined}
+ />
+ ) : (
+ <SourceCard
+ tone={failing ? 'sync' : 'on'}
+ title={t('catalog')}
+ line={
+ synced
+ ? t('catalogLine', {
+ count: products,
+ when: formatRelative(synced, tCommon),
+ })
+ : t('catalogNotSynced', { count: products })
+ }
+ action={settingsLink(t('manage'))}
+ />
+ )}
+ {sources.google ? (
+ <>
+ <GoogleSource
+ provider="google-analytics"
+ state={sources.google.ga}
+ domain={domain}
+ canConnect={canConnect}
+ onConnected={onConnected}
+ pitch={t('gaPitch')}
+ />
+ <GoogleSource
+ provider="google-search-console"
+ state={sources.google.gsc}
+ domain={domain}
+ canConnect={canConnect}
+ onConnected={onConnected}
+ pitch={t('gscPitch')}
+ />
+ </>
+ ) : (
+ <>
+ <SourceCard tone="off" title={t('ga')} line={t('googleFailed')} />
+ <SourceCard tone="off" title={t('gsc')} line={t('googleFailed')} />
+ </>
+ )}
+ </section>
+
+ <div className="flex flex-wrap items-center gap-1.5">
+ <span className="mr-1 text-xs font-medium text-muted-foreground">{t('marketplaces')}</span>
+ {MARKETPLACES.map((place) => {
+ const state = chipState(place.id, catalog);
+ return (
+ <span
+ key={place.id}
+ data-marketplace={place.id}
+ className="inline-flex items-center gap-1.5 rounded-full border bg-card py-0.5 pl-1 pr-2.5 text-xs"
+ >
+ <span
+ aria-hidden
+ className="grid h-4 w-4 place-items-center rounded-full bg-muted text-[10px] font-semibold"
+ >
+ {place.mark}
+ </span>
+ <span className="font-medium">{place.name}</span>
+ {state === 'connected' ? (
+ <span className="text-emerald-700 dark:text-emerald-400">{t('connected')}</span>
+ ) : state === 'connect' && canConnect ? (
+ <Link
+ href={CATALOG_SETTINGS_PATH}
+ className="font-medium text-primary underline-offset-2 hover:underline"
+ >
+ {t('connect')}
+ </Link>
+ ) : (
+ <span className="text-muted-foreground">
+ {state === 'connect' ? t('notConnected') : t('soon')}
+ </span>
+ )}
+ </span>
+ );
+ })}
+ </div>
+ </div>
+ );
+}
diff --git a/web/src/app/[locale]/(dashboard)/dashboard/shopping/_why-dialog.test.tsx b/web/src/app/[locale]/(dashboard)/dashboard/shopping/_why-dialog.test.tsx
new file mode 100644
index 000000000..ca7b16cae
--- /dev/null
+++ b/web/src/app/[locale]/(dashboard)/dashboard/shopping/_why-dialog.test.tsx
@@ -0,0 +1,77 @@
+import { act } from 'react';
+import { createRoot, type Root } from 'react-dom/client';
+import { NextIntlClientProvider } from 'next-intl';
+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
+import messages from '../../../../../../messages/en.json';
+
+/** "Why Ansvisor Product Visibility?" (ECOM-010). */
+
+const connect = vi.hoisted(() => vi.fn());
+vi.mock('@/hooks/use-integration-connect', () => ({
+ useIntegrationConnect: () => ({ connecting: false, connect }),
+}));
+
+const { WhyDialog } = await import('./_why-dialog');
+
+(globalThis as typeof globalThis & { IS_REACT_ACT_ENVIRONMENT: boolean }).IS_REACT_ACT_ENVIRONMENT =
+ true;
+
+let container: HTMLDivElement;
+let root: Root;
+
+beforeEach(() => {
+ connect.mockReset();
+ container = document.createElement('div');
+ document.body.appendChild(container);
+ root = createRoot(container);
+});
+
+afterEach(() => {
+ act(() => root.unmount());
+ container.remove();
+ document.body.replaceChildren();
+});
+
+async function render(offerGa: boolean, onOpenChange = vi.fn()) {
+ await act(async () => {
+ root.render(
+ <NextIntlClientProvider locale="en" messages={messages} timeZone="UTC">
+ <WhyDialog open onOpenChange={onOpenChange} offerGa={offerGa} onConnected={() => {}} />
+ </NextIntlClientProvider>,
+ );
+ });
+ return onOpenChange;
+}
+
+const button = (label: string) =>
+ [...document.body.querySelectorAll('button')].find((b) => b.textContent?.trim() === label);
+
+describe('WhyDialog', () => {
+ it('tells the shelf-to-cart story in four steps, in order', async () => {
+ await render(false);
+ const steps = [...document.body.querySelectorAll('ol li')].map(
+ (li) => li.querySelector('p')?.textContent,
+ );
+ expect(steps).toEqual([
+ 'See your AI shelf',
+ 'Know why you lost',
+ 'Fix it, then push',
+ 'See what it sells',
+ ]);
+ expect(document.body.textContent).toContain('From AI shelf to cart');
+ expect(document.body.textContent).toContain(
+ "Most tools tell you if you're visible. Ansvisor shows why, fixes it and shows the sales.",
+ );
+ });
+
+ it('offers Connect Google Analytics only when asked, and closes on Got it', async () => {
+ const onOpenChange = await render(false);
+ expect(button('Connect Google Analytics')).toBeUndefined();
+ await act(async () => button('Got it')!.click());
+ expect(onOpenChange).toHaveBeenCalledWith(false);
+
+ await render(true);
+ await act(async () => button('Connect Google Analytics')!.click());
+ expect(connect).toHaveBeenCalledOnce();
+ });
+});
diff --git a/web/src/app/[locale]/(dashboard)/dashboard/shopping/_why-dialog.tsx b/web/src/app/[locale]/(dashboard)/dashboard/shopping/_why-dialog.tsx
new file mode 100644
index 000000000..df4004e27
--- /dev/null
+++ b/web/src/app/[locale]/(dashboard)/dashboard/shopping/_why-dialog.tsx
@@ -0,0 +1,88 @@
+'use client';
+
+import { useTranslations } from 'next-intl';
+import { Loader2 } from 'lucide-react';
+import { Button } from '@/components/ui/button';
+import {
+ Dialog,
+ DialogContent,
+ DialogDescription,
+ DialogFooter,
+ DialogHeader,
+ DialogTitle,
+} from '@/components/ui/dialog';
+import { useIntegrationConnect } from '@/hooks/use-integration-connect';
+
+/** The four steps, in order (en.json shopping.why.steps). */
+const STEPS = ['shelf', 'why', 'fix', 'sell'] as const;
+
+/**
+ * "Why Ansvisor Product Visibility?" (ECOM-010): what the page does for a
+ * shop, from the AI shelf to the sale, in four steps. Its Connect Google
+ * Analytics is there while GA isn't connected and the member may connect
+ * it: GA joins an AI visit to its order.
+ */
+export function WhyDialog({
+ open,
+ onOpenChange,
+ offerGa,
+ onConnected,
+}: {
+ open: boolean;
+ onOpenChange: (open: boolean) => void;
+ /** Whether to offer Connect Google Analytics. */
+ offerGa: boolean;
+ onConnected: () => void;
+}) {
+ const t = useTranslations('shopping.why');
+ const { connecting, connect } = useIntegrationConnect('google-analytics', {
+ label: t('ga'),
+ callbackUrl: () => window.location.href,
+ onStatus: (status) => {
+ if (status === 'connected') {
+ onConnected();
+ onOpenChange(false);
+ }
+ },
+ });
+
+ return (
+ <Dialog open={open} onOpenChange={onOpenChange}>
+ <DialogContent className="sm:max-w-lg">
+ <DialogHeader>
+ <p className="text-xs font-medium text-muted-foreground">{t('eyebrow')}</p>
+ <DialogTitle>{t('title')}</DialogTitle>
+ <DialogDescription>{t('lead')}</DialogDescription>
+ </DialogHeader>
+ <ol className="space-y-3">
+ {STEPS.map((step, i) => (
+ <li key={step} className="flex gap-3">
+ <span
+ aria-hidden
+ className="grid h-6 w-6 shrink-0 place-items-center rounded-full bg-primary/10 text-xs font-semibold text-primary"
+ >
+ {i + 1}
+ </span>
+ <div className="min-w-0">
+ <p className="text-sm font-medium">{t(`steps.${step}.title`)}</p>
+ <p className="text-sm text-muted-foreground">{t(`steps.${step}.body`)}</p>
+ </div>
+ </li>
+ ))}
+ </ol>
+ <p className="rounded-lg bg-muted/60 px-3 py-2 text-sm font-medium">{t('closing')}</p>
+ <DialogFooter>
+ <Button variant="outline" onClick={() => onOpenChange(false)}>
+ {t('gotIt')}
+ </Button>
+ {offerGa && (
+ <Button className="gap-2" disabled={connecting} onClick={() => void connect()}>
+ {connecting && <Loader2 className="h-4 w-4 animate-spin" />}
+ {t('connectGa')}
+ </Button>
+ )}
+ </DialogFooter>
+ </DialogContent>
+ </Dialog>
+ );
+}
diff --git a/web/src/app/[locale]/(dashboard)/dashboard/shopping/page.tsx b/web/src/app/[locale]/(dashboard)/dashboard/shopping/page.tsx
index 11776c66a..80dd05b09 100644
--- a/web/src/app/[locale]/(dashboard)/dashboard/shopping/page.tsx
+++ b/web/src/app/[locale]/(dashboard)/dashboard/shopping/page.tsx
@@ -32,6 +32,7 @@ import {
Calendar,
Globe,
AlertTriangle,
+ HelpCircle,
} from 'lucide-react';
import { useBrandStore } from '@/stores/use-brand-store';
import { useFeatureGate } from '@/hooks/use-feature-gate';
@@ -94,8 +95,12 @@ import { formatRegionDisplay } from '@/lib/region';
import type { AmazonShareDropAlert } from '@/lib/shopping-amazon-share-alert';
import { formatNumber } from '@/lib/format';
import { HeaderWithAiUsage } from '@/components/ai-usage/ai-usage-meter';
+import { googleSourceStatus } from '@/lib/traffic-sources';
+import { readUrlChoice, writeUrlParams } from '@/lib/url-state';
import { CatalogNote } from './_catalog-note';
+import { ProductDataStrip, useProductSources } from './_data-strip';
import { ShoppingMarketSwitch, useShoppingMarket } from './_market-switch';
+import { WhyDialog } from './_why-dialog';
import { MerchantSplitCard } from './merchant_split_card';
import { OpenAiIndexCard } from './openai_index_card';
import { ProductMatchScores } from './product_match_scores';
@@ -105,6 +110,10 @@ import { useOpenAiIndex } from './use_openai_index';
const DATE_PRESETS: ShoppingDatePreset[] = ['7d', '30d', '90d', 'all'];
+/** The page's tabs, the one open in the URL (?tab=products). */
+const SHOPPING_TABS = ['shelf', 'prompts', 'products', 'competitors'] as const;
+type ShoppingTab = (typeof SHOPPING_TABS)[number];
+
// Theme tokens in globals.css ship as full oklch values; reference them
// directly with var(--…). Wrapping in hsl() yields invalid CSS, so chart
// text turns black on dark mode (lesson learned from #138).
@@ -120,6 +129,7 @@ export default function ShoppingPage() {
const t = useTranslations('shopping');
const tCommon = useTranslations('common');
const { activeBrandId } = useBrandStore();
+ const activeBrand = useBrandStore((s) => s.brands.find((b) => b.id === s.activeBrandId));
const { canUse, requiredPlanFor } = useFeatureGate();
const { canManage } = useUserRole();
const hasFullAccess = canUse('shopping_analytics');
@@ -148,7 +158,22 @@ export default function ShoppingPage() {
const [promptsData, setPromptsData] = useState<CardEligiblePromptsResponse | null>(null);
const [tableLoading, setTableLoading] = useState(false);
const [selectedProduct, setSelectedProduct] = useState<ShoppingProduct | null>(null);
- const [activeTab, setActiveTab] = useState<string>('overview');
+ const [activeTab, setActiveTab] = useState<ShoppingTab>('shelf');
+ const [whyOpen, setWhyOpen] = useState(false);
+ const sources = useProductSources(activeBrandId);
+ const primaryDomain =
+ activeBrand?.domains?.find((d) => d.isPrimary)?.domain ?? activeBrand?.domains?.[0]?.domain;
+ // Connect Google Analytics in the Why popup: while GA isn't connected.
+ const offerGa =
+ canManage && !!sources.google && googleSourceStatus(sources.google.ga) === 'not_connected';
+
+ useEffect(() => {
+ setActiveTab(readUrlChoice('tab', SHOPPING_TABS, 'shelf'));
+ }, []);
+ const changeTab = (next: ShoppingTab) => {
+ setActiveTab(next);
+ writeUrlParams({ tab: next }, { tab: 'shelf' });
+ };
const filters = useMemo<ShoppingFilters>(
() => ({
@@ -262,7 +287,7 @@ export default function ShoppingPage() {
if (!activeBrandId) {
return (
<div className="space-y-6">
- <PageHeader t={t} />
+ <PageHeader t={t} onWhy={() => setWhyOpen(true)} />
<EmptyState title={t('noBrandTitle')} description={t('noBrandDescription')} />
</div>
);
@@ -277,7 +302,19 @@ export default function ShoppingPage() {
return (
<div className="space-y-6">
- <PageHeader t={t} />
+ <PageHeader t={t} onWhy={() => setWhyOpen(true)} />
+ <WhyDialog
+ open={whyOpen}
+ onOpenChange={setWhyOpen}
+ offerGa={offerGa}
+ onConnected={sources.reload}
+ />
+ <ProductDataStrip
+ sources={sources}
+ domain={primaryDomain}
+ canConnect={canManage}
+ onConnected={sources.reload}
+ />
{amazonShareDropAlert && (
<div
@@ -328,15 +365,19 @@ export default function ShoppingPage() {
hasFullAccess={hasFullAccess}
triggerRate={promptsData?.triggerRate}
/>
- <Tabs value={activeTab} onValueChange={setActiveTab} className="space-y-6">
+ <Tabs
+ value={activeTab}
+ onValueChange={(value) => changeTab(value as ShoppingTab)}
+ className="space-y-6"
+ >
<TabsList>
- <TabsTrigger value="overview">{t('tabOverview')}</TabsTrigger>
+ <TabsTrigger value="shelf">{t('tabShelf')}</TabsTrigger>
<TabsTrigger value="prompts">{t('tabPrompts')}</TabsTrigger>
- <TabsTrigger value="own_products">{t('tabMyProducts')}</TabsTrigger>
+ <TabsTrigger value="products">{t('tabProducts')}</TabsTrigger>
<TabsTrigger value="competitors">{t('tabCompetitors')}</TabsTrigger>
</TabsList>
- <TabsContent value="overview" className="space-y-6">
+ <TabsContent value="shelf" className="space-y-6">
{hasFullAccess ? (
<>
<div className="grid gap-4 lg:grid-cols-2">
@@ -385,7 +426,7 @@ export default function ShoppingPage() {
)}
</TabsContent>
- <TabsContent value="own_products" className="space-y-6">
+ <TabsContent value="products" className="space-y-6">
{hasFullAccess ? (
<>
<div className="flex items-center justify-between">
@@ -838,14 +879,31 @@ function PromptsTabContent({
// ── Header ────────────────────────────────────────────────────────────────────
-function PageHeader({ t }: { t: ReturnType<typeof useTranslations<'shopping'>> }) {
+/** The title, with "Why Ansvisor Product Visibility?" beside it (ECOM-010). */
+function PageHeader({
+ t,
+ onWhy,
+}: {
+ t: ReturnType<typeof useTranslations<'shopping'>>;
+ onWhy: () => void;
+}) {
return (
<HeaderWithAiUsage>
<div>
- <h1 className="flex items-center gap-2 text-2xl font-bold tracking-tight">
- <ShoppingBag className="h-6 w-6 text-primary" />
- {t('title')}
- </h1>
+ <div className="flex flex-wrap items-center gap-x-3 gap-y-2">
+ <h1 className="flex items-center gap-2 text-2xl font-bold tracking-tight">
+ <ShoppingBag className="h-6 w-6 text-primary" />
+ {t('title')}
+ </h1>
+ <button
+ type="button"
+ onClick={onWhy}
+ className="inline-flex h-7 items-center gap-1.5 rounded-full border bg-card px-3 text-xs font-medium text-muted-foreground transition-colors hover:bg-muted hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/50"
+ >
+ <HelpCircle className="h-3.5 w-3.5" aria-hidden />
+ {t('why.button')}
+ </button>
+ </div>
<p className="mt-1 text-sm text-muted-foreground">{t('description')}</p>
</div>
</HeaderWithAiUsage>
diff --git a/web/src/app/[locale]/(dashboard)/dashboard/traffic/_sources-strip.tsx b/web/src/app/[locale]/(dashboard)/dashboard/traffic/_sources-strip.tsx
index 37e7ed510..aacfff2d0 100644
--- a/web/src/app/[locale]/(dashboard)/dashboard/traffic/_sources-strip.tsx
+++ b/web/src/app/[locale]/(dashboard)/dashboard/traffic/_sources-strip.tsx
@@ -24,19 +24,23 @@ import {
* Google Analytics or Google Search Console: connected with its property and
* last sync, syncing with how long the first data takes, or a Connect that
* runs the Settings OAuth flow in a popup, here. Connections stay org-wide.
+ * Also on Product Visibility's strip, which says what each one adds there
+ * (`pitch`, its line while not connected).
*/
-function GoogleSource({
+export function GoogleSource({
provider,
state,
domain,
canConnect,
onConnected,
+ pitch,
}: {
provider: IntegrationProvider;
state: SourceState;
domain: string | undefined;
canConnect: boolean;
onConnected: () => void;
+ pitch?: string;
}) {
const t = useTranslations('traffic.sources');
const tCommon = useTranslations('common');
@@ -90,7 +94,7 @@ function GoogleSource({
<SourceCard
tone="off"
title={title}
- line={isGa ? t('notConnectedGa') : t('notConnectedGsc')}
+ line={pitch ?? (isGa ? t('notConnectedGa') : t('notConnectedGsc'))}
action={
// A span carries the tooltip: a disabled button gets no hover.
<span title={canConnect ? undefined : t('connectNotAllowed')}>
diff --git a/web/src/config/dashboard.ts b/web/src/config/dashboard.ts
index 7fdf77006..f4ee88c55 100644
--- a/web/src/config/dashboard.ts
+++ b/web/src/config/dashboard.ts
@@ -142,11 +142,14 @@ export const dashboardNav: NavGroup[] = [
icon: Quote,
},
{
+ // Product Visibility (ECOM-spec): new as a whole, with its Shelf,
+ // Products and the rest, for brands that sell online.
title: 'Shopping',
href: '/dashboard/shopping',
icon: ShoppingBag,
requiredFeature: 'shopping_analytics',
requiresBrandPref: 'shoppingModeEnabled',
+ badge: 'New',
},
{
title: 'AI Referral Traffic',
diff --git a/web/src/lib/dashboard-navigation.test.ts b/web/src/lib/dashboard-navigation.test.ts
index 9d8af4069..5590db897 100644
--- a/web/src/lib/dashboard-navigation.test.ts
+++ b/web/src/lib/dashboard-navigation.test.ts
@@ -77,6 +77,11 @@ describe('shouldShowDashboardNavItem', () => {
expect(shouldShowDashboardNavItem(shopping, { shoppingModeEnabled: true })).toBe(true);
});
+ // Product Visibility (ECOM-spec) is new as a whole.
+ it('marks Shopping new', () => {
+ expect(shopping.badge).toBe('New');
+ });
+
it('hides a section off the viewer’s menu, by its route', () => {
const content = dashboardNav
.flatMap((group) => group.items)