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): show whether the catalog is in OpenAI's product index, and the verified seller flag (00277) (#1485)

Gökhan Geyikbc65961a6091
diff --git a/supabase/migrations/00277_brand_openai_product_feed.sql b/supabase/migrations/00277_brand_openai_product_feed.sql
new file mode 100644
index 000000000..e88e01338
--- /dev/null
+++ b/supabase/migrations/00277_brand_openai_product_feed.sql
@@ -0,0 +1,15 @@
+-- ============================================================================
+-- 00277: a brand's word that it sends OpenAI a direct product feed (#1281)
+-- ============================================================================
+-- In the US, ChatGPT Shopping picks products from OpenAI's own product
+-- index. There's no public API to check whether a catalog is in it, so the
+-- Shopping page shows what we can know: the brand's own word that it sends a
+-- direct feed (this column), else whether its own products appear in tracked
+-- US ChatGPT Shopping answers. Off by default. Admins and managers change it,
+-- as the rest of a brand (brands: admin/manager update).
+
+alter table public.brands
+ add column if not exists openai_product_feed boolean not null default false;
+
+comment on column public.brands.openai_product_feed is
+ 'Shopping (#1281): the brand says it sends OpenAI a direct product feed, so its catalog is in OpenAI''s product index (ChatGPT Shopping, US). Off by default.';
diff --git a/supabase/schema.sql b/supabase/schema.sql
index de296cf66..e9eccb52e 100644
--- a/supabase/schema.sql
+++ b/supabase/schema.sql
@@ -39472,3 +39472,22 @@ create trigger organizations_guard_server_columns
for each row
execute function public.guard_organization_server_columns();
+-- ─────────────────────────────────────────────────────────────────────────
+-- migrations/00277_brand_openai_product_feed.sql
+-- ─────────────────────────────────────────────────────────────────────────
+-- ============================================================================
+-- 00277: a brand's word that it sends OpenAI a direct product feed (#1281)
+-- ============================================================================
+-- In the US, ChatGPT Shopping picks products from OpenAI's own product
+-- index. There's no public API to check whether a catalog is in it, so the
+-- Shopping page shows what we can know: the brand's own word that it sends a
+-- direct feed (this column), else whether its own products appear in tracked
+-- US ChatGPT Shopping answers. Off by default. Admins and managers change it,
+-- as the rest of a brand (brands: admin/manager update).
+
+alter table public.brands
+ add column if not exists openai_product_feed boolean not null default false;
+
+comment on column public.brands.openai_product_feed is
+ 'Shopping (#1281): the brand says it sends OpenAI a direct product feed, so its catalog is in OpenAI''s product index (ChatGPT Shopping, US). Off by default.';
+
diff --git a/web/messages/en.json b/web/messages/en.json
index 7e2a8cd6c..6787e7c39 100644
--- a/web/messages/en.json
+++ b/web/messages/en.json
@@ -6962,6 +6962,29 @@
"untitled": "Untitled product",
"unknownMerchant": "Unknown merchant",
"openLink": "Open {merchant} in a new tab"
+ },
+ "openaiIndex": {
+ "title": "ChatGPT in the US",
+ "description": "In the US, ChatGPT Shopping picks products from OpenAI's own product index. There's no public way to check either status, so this shows what we can know.",
+ "unavailable": "Couldn't read this right now.",
+ "catalogLabel": "Catalog in OpenAI's product index",
+ "status": {
+ "direct_feed": "Direct feed",
+ "found": "Found, source unknown",
+ "not_found": "Not found in tracked answers"
+ },
+ "detail": {
+ "direct_feed": "You send OpenAI a direct product feed.",
+ "found": "Your own products appear in tracked US ChatGPT Shopping answers in this window ({count, plural, one {# card} other {# cards}}). They likely come from a copy of your site, but we can't confirm the source.",
+ "not_found": "None of your own products appear in tracked US ChatGPT Shopping answers in this window."
+ },
+ "catalogAdvice": "Send OpenAI a direct product feed, or connect a Shopify store with its ChatGPT channel on.",
+ "directFeedLabel": "We send OpenAI a direct product feed",
+ "directFeedManagers": "Admins and managers can change this.",
+ "saveFailed": "Couldn't save. Try again.",
+ "verifiedLabel": "Verified seller in ChatGPT",
+ "verifiedStatus": "Unknown",
+ "verifiedDetail": "OpenAI hasn't said how the verified-seller flag is granted, and in early tests shops without it were left out of answers. Until it says more, send a direct product feed."
}
},
"reports": {
diff --git a/web/src/app/[locale]/(dashboard)/dashboard/shopping/openai_index_card.test.tsx b/web/src/app/[locale]/(dashboard)/dashboard/shopping/openai_index_card.test.tsx
new file mode 100644
index 000000000..e21bed362
--- /dev/null
+++ b/web/src/app/[locale]/(dashboard)/dashboard/shopping/openai_index_card.test.tsx
@@ -0,0 +1,133 @@
+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 { OpenAiIndexCard } from './openai_index_card';
+
+/** #1281: ChatGPT in the US, OpenAI's product index and the verified seller flag. */
+
+(globalThis as typeof globalThis & { IS_REACT_ACT_ENVIRONMENT: boolean }).IS_REACT_ACT_ENVIRONMENT =
+ true;
+
+let container: HTMLDivElement;
+let root: Root;
+
+beforeEach(() => {
+ container = document.createElement('div');
+ document.body.appendChild(container);
+ root = createRoot(container);
+});
+
+afterEach(() => {
+ act(() => root.unmount());
+ container.remove();
+});
+
+function render(node: React.ReactNode) {
+ act(() => {
+ root.render(
+ <NextIntlClientProvider locale="en" messages={messages} timeZone="UTC">
+ {node}
+ </NextIntlClientProvider>,
+ );
+ });
+ return container.textContent ?? '';
+}
+
+const noop = async () => {};
+const box = () => container.querySelector('button[role="checkbox"]') as HTMLButtonElement;
+
+describe('OpenAiIndexCard', () => {
+ it('reads found, source unknown, with the cards and the advice', () => {
+ const text = render(
+ <OpenAiIndexCard
+ read={{ directFeed: false, ownCards: 3 }}
+ loading={false}
+ canManage
+ onDirectFeedChange={noop}
+ />,
+ );
+ expect(text).toContain("Catalog in OpenAI's product index");
+ expect(text).toContain('Found, source unknown');
+ expect(text).toContain('(3 cards)');
+ expect(text).toContain('Send OpenAI a direct product feed, or connect a Shopify store');
+ expect(box().getAttribute('aria-checked')).toBe('false');
+ expect(box().disabled).toBe(false);
+ });
+
+ it("reads not found with no cards, and a direct feed on the brand's word with no advice", () => {
+ expect(
+ render(
+ <OpenAiIndexCard
+ read={{ directFeed: false, ownCards: 0 }}
+ loading={false}
+ canManage
+ onDirectFeedChange={noop}
+ />,
+ ),
+ ).toContain('Not found in tracked answers');
+ const text = render(
+ <OpenAiIndexCard
+ read={{ directFeed: true, ownCards: 0 }}
+ loading={false}
+ canManage
+ onDirectFeedChange={noop}
+ />,
+ );
+ expect(text).toContain('Direct feed');
+ expect(text).not.toContain('or connect a Shopify store');
+ expect(box().getAttribute('aria-checked')).toBe('true');
+ });
+
+ it('always reads the verified seller flag as unknown', () => {
+ const text = render(
+ <OpenAiIndexCard
+ read={{ directFeed: true, ownCards: 9 }}
+ loading={false}
+ canManage
+ onDirectFeedChange={noop}
+ />,
+ );
+ expect(text).toContain('Verified seller in ChatGPT');
+ expect(text).toContain('Unknown');
+ });
+
+ it('lets only admins and managers change the direct-feed word', () => {
+ const text = render(
+ <OpenAiIndexCard
+ read={{ directFeed: false, ownCards: 0 }}
+ loading={false}
+ canManage={false}
+ onDirectFeedChange={noop}
+ />,
+ );
+ expect(box().disabled).toBe(true);
+ expect(text).toContain('Admins and managers can change this.');
+ });
+
+ it('saves the word, and says so when the save fails', async () => {
+ const change = vi.fn().mockRejectedValue(new Error('forbidden'));
+ render(
+ <OpenAiIndexCard
+ read={{ directFeed: false, ownCards: 0 }}
+ loading={false}
+ canManage
+ onDirectFeedChange={change}
+ />,
+ );
+ await act(async () => {
+ box().click();
+ });
+ expect(change).toHaveBeenCalledWith(true);
+ expect(container.querySelector('[role="alert"]')?.textContent).toBe(
+ "Couldn't save. Try again.",
+ );
+ });
+
+ it('says so when the read failed', () => {
+ expect(
+ render(<OpenAiIndexCard read={null} loading={false} canManage onDirectFeedChange={noop} />),
+ ).toContain("Couldn't read this right now.");
+ });
+});
diff --git a/web/src/app/[locale]/(dashboard)/dashboard/shopping/openai_index_card.tsx b/web/src/app/[locale]/(dashboard)/dashboard/shopping/openai_index_card.tsx
new file mode 100644
index 000000000..4b81d5a8f
--- /dev/null
+++ b/web/src/app/[locale]/(dashboard)/dashboard/shopping/openai_index_card.tsx
@@ -0,0 +1,119 @@
+'use client';
+
+import { useId, useState } from 'react';
+import { useTranslations } from 'next-intl';
+import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card';
+import { Checkbox } from '@/components/ui/checkbox';
+import { Skeleton } from '@/components/ui/skeleton';
+import {
+ openAiIndexStatus,
+ type OpenAiIndexRead,
+ type OpenAiIndexStatus,
+} from '@/lib/shopping/openai-index';
+import { cn } from '@/lib/utils';
+
+const STATUS_TONE: Record<OpenAiIndexStatus, string> = {
+ direct_feed: 'bg-emerald-50 text-emerald-700 dark:bg-emerald-950/40 dark:text-emerald-300',
+ found: 'bg-amber-50 text-amber-800 dark:bg-amber-950/40 dark:text-amber-300',
+ not_found: 'bg-muted text-muted-foreground',
+};
+
+/**
+ * ChatGPT in the US (#1281): whether the brand's catalog is in OpenAI's
+ * product index, and whether it's a verified seller, as far as anyone can
+ * know without a public API. Shown on the Overview while the market is the US.
+ */
+export function OpenAiIndexCard({
+ read,
+ loading,
+ canManage,
+ onDirectFeedChange,
+}: {
+ read: OpenAiIndexRead | null;
+ loading: boolean;
+ /** Admins and managers change the brand's direct-feed word. */
+ canManage: boolean;
+ onDirectFeedChange: (on: boolean) => Promise<void>;
+}) {
+ const t = useTranslations('shopping.openaiIndex');
+ const feedId = useId();
+ const [saving, setSaving] = useState(false);
+ const [failed, setFailed] = useState(false);
+ const status = read ? openAiIndexStatus(read) : null;
+
+ const changeFeed = (on: boolean) => {
+ setSaving(true);
+ setFailed(false);
+ onDirectFeedChange(on)
+ .catch(() => setFailed(true))
+ .finally(() => setSaving(false));
+ };
+
+ return (
+ <Card>
+ <CardHeader className="pb-2">
+ <CardTitle className="text-sm font-medium">{t('title')}</CardTitle>
+ <p className="text-xs text-muted-foreground">{t('description')}</p>
+ </CardHeader>
+ <CardContent>
+ {loading ? (
+ <Skeleton className="h-[148px] w-full" />
+ ) : !read || !status ? (
+ <p className="py-8 text-center text-sm text-muted-foreground">{t('unavailable')}</p>
+ ) : (
+ <dl className="divide-y text-sm">
+ <div className="space-y-2 pb-4">
+ <div className="flex flex-wrap items-center justify-between gap-2">
+ <dt className="font-medium text-foreground">{t('catalogLabel')}</dt>
+ <dd
+ className={cn('rounded-md px-2 py-0.5 text-xs font-medium', STATUS_TONE[status])}
+ >
+ {t(`status.${status}`)}
+ </dd>
+ </div>
+ <dd className="text-xs text-muted-foreground">
+ {t(`detail.${status}`, { count: read.ownCards })}
+ </dd>
+ {status !== 'direct_feed' && (
+ <dd className="text-xs text-foreground">{t('catalogAdvice')}</dd>
+ )}
+ <dd className="flex flex-wrap items-center gap-x-2 gap-y-1 pt-1">
+ <Checkbox
+ id={feedId}
+ checked={read.directFeed}
+ disabled={!canManage || saving}
+ onCheckedChange={(checked) => changeFeed(checked === true)}
+ />
+ <label htmlFor={feedId} className="text-xs text-foreground">
+ {t('directFeedLabel')}
+ </label>
+ {!canManage && (
+ <span className="text-xs text-muted-foreground">{t('directFeedManagers')}</span>
+ )}
+ {failed && (
+ <span role="alert" className="text-xs text-destructive">
+ {t('saveFailed')}
+ </span>
+ )}
+ </dd>
+ </div>
+ <div className="space-y-2 pt-4">
+ <div className="flex flex-wrap items-center justify-between gap-2">
+ <dt className="font-medium text-foreground">{t('verifiedLabel')}</dt>
+ <dd
+ className={cn(
+ 'rounded-md px-2 py-0.5 text-xs font-medium',
+ STATUS_TONE.not_found,
+ )}
+ >
+ {t('verifiedStatus')}
+ </dd>
+ </div>
+ <dd className="text-xs text-muted-foreground">{t('verifiedDetail')}</dd>
+ </div>
+ </dl>
+ )}
+ </CardContent>
+ </Card>
+ );
+}
diff --git a/web/src/app/[locale]/(dashboard)/dashboard/shopping/page.tsx b/web/src/app/[locale]/(dashboard)/dashboard/shopping/page.tsx
index ef1c77d61..8a75ee972 100644
--- a/web/src/app/[locale]/(dashboard)/dashboard/shopping/page.tsx
+++ b/web/src/app/[locale]/(dashboard)/dashboard/shopping/page.tsx
@@ -35,6 +35,7 @@ import {
} from 'lucide-react';
import { useBrandStore } from '@/stores/use-brand-store';
import { useFeatureGate } from '@/hooks/use-feature-gate';
+import { useUserRole } from '@/hooks/use-user-role';
import {
getShoppingFilterOptions,
getShoppingOverview,
@@ -94,8 +95,10 @@ import type { AmazonShareDropAlert } from '@/lib/shopping-amazon-share-alert';
import { HeaderWithAiUsage } from '@/components/ai-usage/ai-usage-meter';
import { ShoppingMarketSwitch, useShoppingMarket } from './_market-switch';
import { MerchantSplitCard } from './merchant_split_card';
+import { OpenAiIndexCard } from './openai_index_card';
import { ResellerPriceAlerts } from './reseller_price_alerts';
import { useMerchantDestinations } from './use_merchant_destinations';
+import { useOpenAiIndex } from './use_openai_index';
const DATE_PRESETS: ShoppingDatePreset[] = ['7d', '30d', '90d', 'all'];
@@ -115,6 +118,7 @@ export default function ShoppingPage() {
const tCommon = useTranslations('common');
const { activeBrandId } = useBrandStore();
const { canUse, requiredPlanFor } = useFeatureGate();
+ const { canManage } = useUserRole();
const hasFullAccess = canUse('shopping_analytics');
const [datePreset, setDatePreset] = useState<ShoppingDatePreset>('30d');
@@ -159,6 +163,9 @@ export default function ShoppingPage() {
hasFullAccess && shoppingMarket.ready,
);
const destinationsLoading = destinations.loading || !shoppingMarket.ready;
+ // ChatGPT in the US (#1281): only while the market shown is the US.
+ const showOpenAiIndex = shoppingMarket.shown === 'us';
+ const openAiIndex = useOpenAiIndex(activeBrandId, datePreset, hasFullAccess && showOpenAiIndex);
// Load filter options once per brand so the dropdowns only show
// platform / region values that actually appear in this brand's data.
@@ -348,6 +355,14 @@ export default function ShoppingPage() {
loading={destinationsLoading}
/>
</div>
+ {showOpenAiIndex && (
+ <OpenAiIndexCard
+ read={openAiIndex.read}
+ loading={openAiIndex.loading}
+ canManage={canManage}
+ onDirectFeedChange={openAiIndex.setDirectFeed}
+ />
+ )}
</>
) : (
<UpgradeCard t={t} requiredPlan={requiredPlanFor('shopping_analytics')} />
diff --git a/web/src/app/[locale]/(dashboard)/dashboard/shopping/use_openai_index.ts b/web/src/app/[locale]/(dashboard)/dashboard/shopping/use_openai_index.ts
new file mode 100644
index 000000000..c3b076f2a
--- /dev/null
+++ b/web/src/app/[locale]/(dashboard)/dashboard/shopping/use_openai_index.ts
@@ -0,0 +1,67 @@
+'use client';
+
+import { useCallback, useEffect, useState } from 'react';
+import type { ShoppingDatePreset } from '@/lib/actions/shopping';
+import { getOpenAiIndexRead, setOpenAiProductFeed } from '@/lib/actions/shopping-openai-index';
+import type { OpenAiIndexRead } from '@/lib/shopping/openai-index';
+
+interface Loaded {
+ key: string;
+ read: OpenAiIndexRead | null;
+}
+
+/**
+ * "Catalog in OpenAI's product index" (#1281): the brand's direct-feed word
+ * and its own products' US ChatGPT Shopping cards, over the Overview's window.
+ * Read in the page, as the destinations are, so switching tabs doesn't read
+ * it again. Supplemental: a failed read leaves the row empty.
+ */
+export function useOpenAiIndex(
+ brandId: string | null,
+ datePreset: ShoppingDatePreset,
+ enabled: boolean,
+): {
+ read: OpenAiIndexRead | null;
+ loading: boolean;
+ /** Saves the brand's word; the box shows it at once and goes back if the save fails. */
+ setDirectFeed: (on: boolean) => Promise<void>;
+} {
+ const key = enabled && brandId ? `${brandId}|${datePreset}` : null;
+ const [loaded, setLoaded] = useState<Loaded | null>(null);
+
+ useEffect(() => {
+ if (!key || !brandId) return;
+ let cancelled = false;
+ getOpenAiIndexRead(brandId, datePreset)
+ .catch(() => null)
+ .then((read) => {
+ if (!cancelled) setLoaded({ key, read });
+ });
+ return () => {
+ cancelled = true;
+ };
+ }, [key, brandId, datePreset]);
+
+ const setDirectFeed = useCallback(
+ async (on: boolean) => {
+ if (!brandId || !key) return;
+ const before = loaded?.key === key ? loaded.read : null;
+ if (!before) return;
+ setLoaded({ key, read: { ...before, directFeed: on } });
+ try {
+ await setOpenAiProductFeed(brandId, on);
+ } catch (err) {
+ setLoaded((current) => (current?.key === key ? { key, read: before } : current));
+ throw err;
+ }
+ },
+ [brandId, key, loaded],
+ );
+
+ const current = key !== null && loaded?.key === key ? loaded : null;
+ return {
+ read: current?.read ?? null,
+ loading: key !== null && current === null,
+ setDirectFeed,
+ };
+}
diff --git a/web/src/lib/actions/shopping-openai-index.test.ts b/web/src/lib/actions/shopping-openai-index.test.ts
new file mode 100644
index 000000000..3cabc90e8
--- /dev/null
+++ b/web/src/lib/actions/shopping-openai-index.test.ts
@@ -0,0 +1,100 @@
+import { beforeEach, describe, expect, it, vi } from 'vitest';
+
+/**
+ * #1281 — "Catalog in OpenAI's product index" reads the brand's direct-feed
+ * word and its own products' US ChatGPT Shopping cards; admins and managers
+ * change the word.
+ */
+
+const BRAND = '5b0c3b8e-8a5f-4a41-9d0e-1f2a3b4c5d6e';
+
+let brandRow: { openai_product_feed: boolean } | null = null;
+let updatedRows: Array<{ id: string }> = [];
+let calls: Array<{ op: string; value?: unknown; filters: Array<[string, unknown]> }> = [];
+
+function fakeQueryBuilder() {
+ const call: { op: string; value?: unknown; filters: Array<[string, unknown]> } = {
+ op: 'select',
+ filters: [],
+ };
+ calls.push(call);
+ const builder = {
+ select: () => builder,
+ update: (value: unknown) => {
+ call.op = 'update';
+ call.value = value;
+ return builder;
+ },
+ eq: (column: string, value: unknown) => {
+ call.filters.push([column, value]);
+ return builder;
+ },
+ maybeSingle: async () => ({ data: brandRow, error: null }),
+ then: (onFulfilled: (v: unknown) => unknown) =>
+ Promise.resolve({ data: updatedRows, error: null }).then(onFulfilled),
+ };
+ return builder;
+}
+
+vi.mock('@/lib/supabase/server', () => ({
+ createClient: async () => ({ from: () => fakeQueryBuilder() }),
+}));
+
+const splitCalls: Array<{ brandId: string; filters: unknown }> = [];
+vi.mock('./shopping', () => ({
+ getShoppingMerchantSplit: async (brandId: string, filters: unknown) => {
+ splitCalls.push({ brandId, filters });
+ return { parts: [], classifiedCards: 3, unclassifiedCards: 2 };
+ },
+}));
+
+const { getOpenAiIndexRead, setOpenAiProductFeed } = await import('./shopping-openai-index');
+
+beforeEach(() => {
+ brandRow = { openai_product_feed: false };
+ updatedRows = [{ id: BRAND }];
+ calls = [];
+ splitCalls.length = 0;
+});
+
+describe('getOpenAiIndexRead', () => {
+ it("reads the brand's word and counts its own US ChatGPT Shopping cards, classified or not", async () => {
+ expect(await getOpenAiIndexRead(BRAND, '30d')).toEqual({ directFeed: false, ownCards: 5 });
+ expect(calls[0].filters).toEqual([['id', BRAND]]);
+ expect(splitCalls).toEqual([
+ {
+ brandId: BRAND,
+ filters: { datePreset: '30d', platforms: ['chatgpt-shopping'], chatgptMarket: 'us' },
+ },
+ ]);
+ brandRow = { openai_product_feed: true };
+ expect((await getOpenAiIndexRead(BRAND, '7d')).directFeed).toBe(true);
+ });
+
+ it("refuses a bad id, and says so when the brand isn't the member's", async () => {
+ await expect(getOpenAiIndexRead('b1', '30d')).rejects.toThrow('invalid');
+ brandRow = null;
+ await expect(getOpenAiIndexRead(BRAND, '30d')).rejects.toThrow('not_found');
+ });
+});
+
+describe('setOpenAiProductFeed', () => {
+ it("sets the brand's word", async () => {
+ await setOpenAiProductFeed(BRAND, true);
+ expect(calls[0]).toEqual({
+ op: 'update',
+ value: { openai_product_feed: true },
+ filters: [['id', BRAND]],
+ });
+ });
+
+ it("refuses bad input, and a brand the member can't change", async () => {
+ await expect(setOpenAiProductFeed('b1', true)).rejects.toThrow('invalid');
+ await expect(setOpenAiProductFeed(BRAND, 'yes' as unknown as boolean)).rejects.toThrow(
+ 'invalid',
+ );
+ expect(calls).toEqual([]);
+ updatedRows = [];
+ await expect(setOpenAiProductFeed(BRAND, false)).rejects.toThrow('forbidden');
+ });
+});
diff --git a/web/src/lib/actions/shopping-openai-index.ts b/web/src/lib/actions/shopping-openai-index.ts
new file mode 100644
index 000000000..03349b422
--- /dev/null
+++ b/web/src/lib/actions/shopping-openai-index.ts
@@ -0,0 +1,52 @@
+'use server';
+
+import { z } from 'zod';
+import { createClient } from '@/lib/supabase/server';
+import type { OpenAiIndexRead } from '@/lib/shopping/openai-index';
+import { getShoppingMerchantSplit, type ShoppingDatePreset } from './shopping';
+
+/**
+ * What "Catalog in OpenAI's product index" reads (#1281): the brand's word
+ * that it sends a direct feed, and the cards for its own products in US
+ * ChatGPT Shopping answers over the Overview's window, counted by
+ * `shopping_merchant_split` (own-product cards, classified or not). RLS and
+ * the RPC's membership check keep both to the caller's organization.
+ */
+export async function getOpenAiIndexRead(
+ brandId: string,
+ datePreset: ShoppingDatePreset,
+): Promise<OpenAiIndexRead> {
+ if (!z.guid().safeParse(brandId).success) throw new Error('invalid');
+ const supabase = await createClient();
+ const [brand, split] = await Promise.all([
+ supabase.from('brands').select('openai_product_feed').eq('id', brandId).maybeSingle(),
+ getShoppingMerchantSplit(brandId, {
+ datePreset,
+ platforms: ['chatgpt-shopping'],
+ chatgptMarket: 'us',
+ }),
+ ]);
+ if (brand.error) throw new Error(brand.error.message);
+ if (!brand.data) throw new Error('not_found');
+ return {
+ directFeed: !!brand.data.openai_product_feed,
+ ownCards: split.classifiedCards + split.unclassifiedCards,
+ };
+}
+
+/**
+ * The brand's word that it sends OpenAI a direct product feed (00277).
+ * Admins and managers (brands: admin/manager update); a brand they can't
+ * change is refused.
+ */
+export async function setOpenAiProductFeed(brandId: string, on: boolean): Promise<void> {
+ if (!z.guid().safeParse(brandId).success || typeof on !== 'boolean') throw new Error('invalid');
+ const supabase = await createClient();
+ const { data, error } = await supabase
+ .from('brands')
+ .update({ openai_product_feed: on })
+ .eq('id', brandId)
+ .select('id');
+ if (error) throw new Error(error.message);
+ if (!data?.length) throw new Error('forbidden');
+}
diff --git a/web/src/lib/shopping/openai-index.test.ts b/web/src/lib/shopping/openai-index.test.ts
new file mode 100644
index 000000000..39abdd086
--- /dev/null
+++ b/web/src/lib/shopping/openai-index.test.ts
@@ -0,0 +1,17 @@
+import { describe, expect, it } from 'vitest';
+import { openAiIndexStatus } from './openai-index';
+
+describe('openAiIndexStatus (#1281)', () => {
+ it("is a direct feed on the brand's word, whatever the answers show", () => {
+ expect(openAiIndexStatus({ directFeed: true, ownCards: 0 })).toBe('direct_feed');
+ expect(openAiIndexStatus({ directFeed: true, ownCards: 12 })).toBe('direct_feed');
+ });
+
+ it('is found, source unknown, when its own products appear in US ChatGPT Shopping cards', () => {
+ expect(openAiIndexStatus({ directFeed: false, ownCards: 1 })).toBe('found');
+ });
+
+ it('is not found in tracked answers otherwise', () => {
+ expect(openAiIndexStatus({ directFeed: false, ownCards: 0 })).toBe('not_found');
+ });
+});
diff --git a/web/src/lib/shopping/openai-index.ts b/web/src/lib/shopping/openai-index.ts
new file mode 100644
index 000000000..427e4e0d0
--- /dev/null
+++ b/web/src/lib/shopping/openai-index.ts
@@ -0,0 +1,29 @@
+/**
+ * "Catalog in OpenAI's product index" (#1281), US only.
+ *
+ * In the US, ChatGPT Shopping picks products from OpenAI's own product index,
+ * built from direct brand feeds, from Shopify, or from copies made by reading
+ * retailer sites. There's no public API for it, so the status is what we can
+ * know:
+ * - `direct_feed`: the brand says it sends OpenAI a direct product feed
+ * (`brands.openai_product_feed`);
+ * - `found`: otherwise, its own products appear in tracked US ChatGPT
+ * Shopping cards. The source is unknown: likely a copy of its site;
+ * - `not_found`: neither.
+ * A Shopify-connected store with its ChatGPT channel on reads "via Shopify"
+ * once the Shopify integration (#1265) exists.
+ */
+
+export type OpenAiIndexStatus = 'direct_feed' | 'found' | 'not_found';
+
+export interface OpenAiIndexRead {
+ /** The brand says it sends OpenAI a direct product feed. */
+ directFeed: boolean;
+ /** Cards for the brand's own products in US ChatGPT Shopping answers, in the window. */
+ ownCards: number;
+}
+
+export function openAiIndexStatus(read: OpenAiIndexRead): OpenAiIndexStatus {
+ if (read.directFeed) return 'direct_feed';
+ return read.ownCards > 0 ? 'found' : 'not_found';
+}
diff --git a/web/src/types/supabase.ts b/web/src/types/supabase.ts
index f1180e40b..1a6ae7c08 100644
--- a/web/src/types/supabase.ts
+++ b/web/src/types/supabase.ts
@@ -661,6 +661,7 @@ export type Database = {
language: string | null
logo_url: string | null
name: string
+ openai_product_feed: boolean
organization_id: string
region: string | null
shopping_mode_enabled: boolean
@@ -687,6 +688,7 @@ export type Database = {
language?: string | null
logo_url?: string | null
name: string
+ openai_product_feed?: boolean
organization_id: string
region?: string | null
shopping_mode_enabled?: boolean
@@ -713,6 +715,7 @@ export type Database = {
language?: string | null
logo_url?: string | null
name?: string
+ openai_product_feed?: boolean
organization_id?: string
region?: string | null
shopping_mode_enabled?: boolean