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.

fix(tracking): run ChatGPT Shopping only on plans with the Shopping page (#1212)

Cihan147e9bc44253
diff --git a/server/src/workers/tracking-worker.js b/server/src/workers/tracking-worker.js
index 4a4e8847a..716a68629 100644
--- a/server/src/workers/tracking-worker.js
+++ b/server/src/workers/tracking-worker.js
@@ -59,6 +59,17 @@ export function runnablePlatforms(platforms, { shoppingEnabled } = {}) {
);
}
+/**
+ * Whether ChatGPT Shopping is run for a brand: its Shopping mode is on, and
+ * its plan has the Shopping page (`shopping_analytics`) that shows the
+ * results. On a plan without it, every ChatGPT Shopping task would be a paid
+ * Cloro submission nobody can see. `plan` is null on self-host, where every
+ * feature is on.
+ */
+export function shoppingTracked(brand, plan) {
+ return Boolean(brand?.shopping_mode_enabled) && (!plan || hasFeature(plan, 'shopping_analytics'));
+}
+
/**
* PostgREST silently caps an un-paginated select at 1000 rows, so reading a
* brand's pending tasks in one request under-reports any run that submitted
@@ -268,25 +279,30 @@ export async function processTrackingJob({ brandId, promptId, promptIds, source,
// filter at run time instead of trusting the stored arrays. `null` means
// every model is allowed (self-host, or a plan without the restriction).
let allowedModels = null;
+ let plan = null;
if (isCloud()) {
const { data: org } = await supabaseAdmin
.from('organizations')
.select('plan, plan_overrides')
.eq('id', brand.organization_id)
.single();
- const plan = applyPlanOverrides(getPlan(org?.plan), org);
+ plan = applyPlanOverrides(getPlan(org?.plan), org);
allowedModels = plan.limits.allowedModels ?? null;
if (allowedModels) {
logger.info({ brandId, allowedModels }, 'api-model tracking plan-gated for this org');
}
}
+ // ChatGPT Shopping, like the models, only where the plan shows its results.
+ const shoppingEnabled = shoppingTracked(brand, plan);
+ if (brand.shopping_mode_enabled && !shoppingEnabled) {
+ logger.info({ brandId }, 'chatgpt-shopping not tracked: the plan has no Shopping page');
+ }
const allowedModelsFor = (prompt) => {
const models = prompt.models && prompt.models.length > 0 ? prompt.models : [];
return allowedModels ? models.filter((m) => allowedModels.includes(m)) : models;
};
- const allowedPlatformsFor = (prompt) =>
- runnablePlatforms(prompt.platforms, { shoppingEnabled: brand.shopping_mode_enabled });
+ const allowedPlatformsFor = (prompt) => runnablePlatforms(prompt.platforms, { shoppingEnabled });
// A prompt's tracked locations (#691): country codes and US state codes
// (`US-CA`) alike. No locations means one untargeted run, which is what an
diff --git a/server/src/workers/tracking-worker.test.js b/server/src/workers/tracking-worker.test.js
index c28afc614..201c75f08 100644
--- a/server/src/workers/tracking-worker.test.js
+++ b/server/src/workers/tracking-worker.test.js
@@ -10,9 +10,11 @@ import {
fetchAllPendingRows,
interactiveTailExhausted,
runnablePlatforms,
+ shoppingTracked,
tailRemainder,
UNAVAILABLE_PLATFORMS,
} from './tracking-worker.js';
+import { PLANS } from '../config/plans.js';
/**
* Ghost detection for the Cloro drain loop (#687).
@@ -268,6 +270,23 @@ describe('runnablePlatforms', () => {
* Nothing is lost by leaving early: /cloro/callback inserts a late delivery
* whether or not the loop is still watching.
*/
+describe('shoppingTracked', () => {
+ const on = { shopping_mode_enabled: true };
+
+ it('runs ChatGPT Shopping only where the plan shows its results', () => {
+ expect(shoppingTracked(on, PLANS.growth)).toBe(true);
+ expect(shoppingTracked(on, PLANS.enterprise)).toBe(true);
+ // Starter has no Shopping page: its scrapes would be paid for and unseen.
+ expect(shoppingTracked(on, PLANS.starter)).toBe(false);
+ });
+
+ it('runs it on self-host, and nowhere with Shopping mode off', () => {
+ expect(shoppingTracked(on, null)).toBe(true);
+ expect(shoppingTracked({ shopping_mode_enabled: false }, PLANS.growth)).toBe(false);
+ expect(shoppingTracked({ shopping_mode_enabled: false }, null)).toBe(false);
+ });
+});
+
describe('tailRemainder', () => {
it('scales with the run for a large brand', () => {
expect(tailRemainder(294)).toBe(15);