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(tracking): capture Perplexity shopping_cards into prompt_results (#83)

Gökhan Geyik1b2860fce073
diff --git a/server/src/lib/cloro-result-handler.js b/server/src/lib/cloro-result-handler.js
index abd2df869..5299e5305 100644
--- a/server/src/lib/cloro-result-handler.js
+++ b/server/src/lib/cloro-result-handler.js
@@ -18,7 +18,7 @@ import { parseResponse, countBrandMentions } from './response-parser.js';
/**
* @param {object} args
- * @param {{ text: string, citations: Array, model: string }} args.aiResponse
+ * @param {{ text: string, citations: Array, model: string, shopping_cards: Array }} args.aiResponse
* Already parsed via parseScraperResponse (cloro-scraper.js)
* @param {string} args.scraperId Cloro scraper id (e.g. 'chatgpt-web')
* @param {string} args.promptId
@@ -63,6 +63,7 @@ export async function handleScraperResult({
model_used: aiResponse.model,
region: region ?? null,
competitor_mentions: metrics.competitorMentions,
+ shopping_cards: aiResponse.shopping_cards ?? [],
});
if (error) {
diff --git a/server/src/lib/cloro-scraper.js b/server/src/lib/cloro-scraper.js
index 9befaa28e..0f0e0ecbd 100644
--- a/server/src/lib/cloro-scraper.js
+++ b/server/src/lib/cloro-scraper.js
@@ -80,7 +80,7 @@ export function parseScraperResponse(result, scraperId) {
endIndex: idx * 100 + 50,
}));
- return { text, citations, model: 'google-aio' };
+ return { text, citations, model: 'google-aio', shopping_cards: [] };
}
if (scraperId === 'google-aimode') {
@@ -93,7 +93,7 @@ export function parseScraperResponse(result, scraperId) {
endIndex: idx * 100 + 50,
}));
- return { text, citations, model: 'google-aimode' };
+ return { text, citations, model: 'google-aimode', shopping_cards: [] };
}
const text = result.markdown || result.text || '';
@@ -105,7 +105,12 @@ export function parseScraperResponse(result, scraperId) {
endIndex: idx * 100 + 50,
}));
- return { text, citations, model };
+ return {
+ text,
+ citations,
+ model,
+ shopping_cards: result.shopping_cards ?? [],
+ };
}
/**
@@ -173,7 +178,7 @@ export async function submitScraperTask(promptText, scraperId, region, opts = {}
* @param {string} taskId
* @param {string} scraperId - needed to parse the response correctly
* @param {{ maxWaitMs?: number, pollIntervalMs?: number }} [opts]
- * @returns {Promise<{ text: string, citations: Array, model: string }>}
+ * @returns {Promise<{ text: string, citations: Array, model: string, shopping_cards: Array }>}
*/
export async function pollScraperResult(taskId, scraperId, opts = {}) {
const maxWait = opts.maxWaitMs ?? DEFAULT_MAX_WAIT_MS;
@@ -248,7 +253,7 @@ export async function pollScraperResult(taskId, scraperId, opts = {}) {
* @param {string} promptText
* @param {string} scraperId
* @param {string} [region]
- * @returns {Promise<{ text: string, citations: Array<{ url: string, title: string, startIndex: number, endIndex: number }>, model: string }>}
+ * @returns {Promise<{ text: string, citations: Array<{ url: string, title: string, startIndex: number, endIndex: number }>, model: string, shopping_cards: Array }>}
*/
export async function runScraperPrompt(promptText, scraperId, region) {
const { taskId } = await submitScraperTask(promptText, scraperId, region);
diff --git a/supabase/migrations/00005_prompt_results_shopping_cards.sql b/supabase/migrations/00005_prompt_results_shopping_cards.sql
new file mode 100644
index 000000000..e8f6c18ea
--- /dev/null
+++ b/supabase/migrations/00005_prompt_results_shopping_cards.sql
@@ -0,0 +1,8 @@
+-- Capture Perplexity shopping cards alongside text + citations so the
+-- commerce-intent signal isn't lost. Other AI providers leave this empty;
+-- only Perplexity populates it today. Mirrors the citations /
+-- competitor_mentions columns on the same table (jsonb NOT NULL DEFAULT '[]').
+
+ALTER TABLE "public"."prompt_results"
+ ADD COLUMN IF NOT EXISTS "shopping_cards" jsonb
+ NOT NULL DEFAULT '[]'::jsonb;
diff --git a/web/src/types/supabase.ts b/web/src/types/supabase.ts
index 47a7e6015..5a882e7de 100644
--- a/web/src/types/supabase.ts
+++ b/web/src/types/supabase.ts
@@ -472,6 +472,7 @@ export type Database = {
region: string | null;
response: string;
sentiment: string;
+ shopping_cards: Json;
visibility_score: number;
};
Insert: {
@@ -488,6 +489,7 @@ export type Database = {
region?: string | null;
response?: string;
sentiment?: string;
+ shopping_cards?: Json;
visibility_score?: number;
};
Update: {
@@ -504,6 +506,7 @@ export type Database = {
region?: string | null;
response?: string;
sentiment?: string;
+ shopping_cards?: Json;
visibility_score?: number;
};
Relationships: [