Skip to content

Commit 641b39a

Browse files
committed
fix(similarweb): accept both page_views key spellings in page views response
Cursor Bugbot and Greptile both flagged the response field as page_views by convention, but SimilarWeb's own docs example response uses pages_views for this specific endpoint. Accept both spellings defensively so the tool works regardless of which is actually returned.
1 parent 30f937d commit 641b39a

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

apps/sim/tools/similarweb/page_views.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,11 +101,16 @@ export const similarwebPageViewsTool: ToolConfig<
101101
country: request.country ?? null,
102102
granularity: request.granularity ?? null,
103103
lastUpdated: meta.last_updated ?? null,
104+
// SimilarWeb's own docs example response uses "pages_views" (with the extra "s") for
105+
// this endpoint, unlike its sibling total-traffic-and-engagement endpoints; fall back
106+
// to "page_views" too in case that spelling changes or varies by account.
104107
pageViews:
105-
data.pages_views?.map((p: { date: string; pages_views: number }) => ({
106-
date: p.date,
107-
pageViews: p.pages_views,
108-
})) ?? [],
108+
(data.pages_views ?? data.page_views)?.map(
109+
(p: { date: string; pages_views?: number; page_views?: number }) => ({
110+
date: p.date,
111+
pageViews: p.pages_views ?? p.page_views ?? 0,
112+
})
113+
) ?? [],
109114
},
110115
}
111116
},

0 commit comments

Comments
 (0)