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(traffic): show the platform name in the AI Traffic platform filter (#926)

nimbly101798e233187
diff --git a/web/src/app/[locale]/(dashboard)/dashboard/traffic/_charts.test.ts b/web/src/app/[locale]/(dashboard)/dashboard/traffic/_charts.test.ts
new file mode 100644
index 000000000..5bad523a9
--- /dev/null
+++ b/web/src/app/[locale]/(dashboard)/dashboard/traffic/_charts.test.ts
@@ -0,0 +1,34 @@
+import { describe, expect, it } from 'vitest';
+import { getPlatformFilterItems, getPlatformName } from './_charts';
+
+describe('getPlatformFilterItems', () => {
+ it('starts with the all-platforms option, whose value is empty', () => {
+ expect(getPlatformFilterItems([])).toEqual([{ value: '', label: 'All platforms' }]);
+ expect(getPlatformFilterItems(['chatgpt.com'])[0]).toEqual({
+ value: '',
+ label: 'All platforms',
+ });
+ });
+
+ it('labels each platform with its display name while keeping its domain as the value', () => {
+ expect(getPlatformFilterItems(['chatgpt.com', 'perplexity.ai', 'claude.ai']).slice(1)).toEqual([
+ { value: 'chatgpt.com', label: 'ChatGPT' },
+ { value: 'perplexity.ai', label: 'Perplexity' },
+ { value: 'claude.ai', label: 'Claude' },
+ ]);
+ });
+
+ it('falls back to the domain for a platform without a display name', () => {
+ expect(getPlatformFilterItems(['example.org']).slice(1)).toEqual([
+ { value: 'example.org', label: 'example.org' },
+ ]);
+ expect(getPlatformName('example.org')).toBe('example.org');
+ });
+
+ it('keeps the order of the platforms it is given', () => {
+ const values = getPlatformFilterItems(['poe.com', 'bing.com', 'you.com']).map(
+ (item) => item.value,
+ );
+ expect(values).toEqual(['', 'poe.com', 'bing.com', 'you.com']);
+ });
+});
diff --git a/web/src/app/[locale]/(dashboard)/dashboard/traffic/_charts.tsx b/web/src/app/[locale]/(dashboard)/dashboard/traffic/_charts.tsx
index fef3ca169..ce17d20dd 100644
--- a/web/src/app/[locale]/(dashboard)/dashboard/traffic/_charts.tsx
+++ b/web/src/app/[locale]/(dashboard)/dashboard/traffic/_charts.tsx
@@ -96,6 +96,18 @@ export function getPlatformName(platform: string): string {
return PLATFORM_NAMES[platform] ?? platform;
}
+/**
+ * Options of the platform filter, with an empty-valued "all" option first. Base UI's Select can only
+ * show the label of the picked option in its trigger when it is given the options as `items`;
+ * without them the trigger shows the raw value, the platform's domain (for example `chatgpt.com`).
+ */
+export function getPlatformFilterItems(platforms: string[]): { value: string; label: string }[] {
+ return [
+ { value: '', label: 'All platforms' },
+ ...platforms.map((platform) => ({ value: platform, label: getPlatformName(platform) })),
+ ];
+}
+
function formatTrafficBucketDate(value: string): string {
const d = new Date(value);
diff --git a/web/src/app/[locale]/(dashboard)/dashboard/traffic/page.tsx b/web/src/app/[locale]/(dashboard)/dashboard/traffic/page.tsx
index 46248793d..0b134747e 100644
--- a/web/src/app/[locale]/(dashboard)/dashboard/traffic/page.tsx
+++ b/web/src/app/[locale]/(dashboard)/dashboard/traffic/page.tsx
@@ -1,7 +1,7 @@
'use client';
import { useState, useEffect, useCallback, useMemo } from 'react';
-import { getPlatformName } from './_charts';
+import { getPlatformFilterItems, getPlatformName } from './_charts';
import dynamic from 'next/dynamic';
import { Skeleton } from '@/components/ui/skeleton';
import { getPublicApiBaseUrl } from '@/config/api';
@@ -225,6 +225,7 @@ function TrafficFilterBar({
isLoading: boolean;
}) {
const hasActiveFilters = filters.platform || filters.search;
+ const platformItems = getPlatformFilterItems(platforms);
return (
<div className="flex flex-wrap items-center gap-3">
@@ -239,15 +240,18 @@ function TrafficFilterBar({
/>
</div>
- <Select value={filters.platform || ''} onValueChange={(v) => onChange({ platform: v || '' })}>
+ <Select
+ value={filters.platform || ''}
+ onValueChange={(v) => onChange({ platform: v || '' })}
+ items={platformItems}
+ >
<SelectTrigger className="w-40 h-9 text-sm">
<SelectValue placeholder="All platforms" />
</SelectTrigger>
<SelectContent>
- <SelectItem value="">All platforms</SelectItem>
- {platforms.map((p) => (
- <SelectItem key={p} value={p}>
- {getPlatformName(p)}
+ {platformItems.map((item) => (
+ <SelectItem key={item.value} value={item.value}>
+ {item.label}
</SelectItem>
))}
</SelectContent>