Skip to content

feat(similarweb): add page views tool, fix paid referrals field mismatch#5354

Merged
waleedlatif1 merged 2 commits into
stagingfrom
worktree-similarweb-validate
Jul 2, 2026
Merged

feat(similarweb): add page views tool, fix paid referrals field mismatch#5354
waleedlatif1 merged 2 commits into
stagingfrom
worktree-similarweb-validate

Conversation

@waleedlatif1

Copy link
Copy Markdown
Collaborator

Summary

  • Add similarweb_page_views tool (Total Page Views, Desktop & Mobile) — the one clearly-missing endpoint matching the existing "one clean Total operation per metric" pattern
  • Fix paidReferrals in the website overview tool: the API Lite response key is literally paid _referrals (space before underscore), which the fallback chain wasn't checking, so this field always resolved to null
  • Move optional time-range/toggle fields (startDate, endDate, mainDomainOnly) to advanced mode per block-authoring conventions

Type of Change

  • New feature / bug fix

Testing

Validated all 6 tools against live Similarweb API docs (URL paths, params, response field mapping) via independent parallel audits; confirmed 100% backwards compatible (purely additive diff, no removed/renamed fields); biome check and tsc --noEmit clean.

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

@vercel

vercel Bot commented Jul 2, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
docs Skipped Skipped Jul 2, 2026 4:58pm

Request Review

@cursor

cursor Bot commented Jul 2, 2026

Copy link
Copy Markdown

PR Summary

Low Risk
Additive Similarweb integration changes and a small response-key fallback fix; no auth or core execution path changes.

Overview
Adds a Page Views operation to the Similarweb block and a new similarweb_page_views tool that calls the total page-views API (desktop + mobile), including types, registry wiring, and a pageViews time-series block output.

Fixes website overview paidReferrals mapping by also reading the API Lite key paid _referrals, which previously left that value as null.

For non-overview operations, start date, end date, and main domain only are moved to advanced mode in the block UI.

Reviewed by Cursor Bugbot for commit 88c83f4. Configure here.

Comment thread apps/sim/tools/similarweb/page_views.ts Outdated
@greptile-apps

greptile-apps Bot commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR adds a new similarweb_page_views tool for total page views over time (desktop + mobile), fixes a paidReferrals field mapping bug in the website overview tool caused by an undocumented space in the API Lite response key (paid _referrals), and moves optional time-range/toggle fields (startDate, endDate, mainDomainOnly) to advanced mode in the block UI.

  • New similarweb_page_views tool (page_views.ts, types.ts, registry.ts, index.ts, similarweb.ts): follows the established one-operation-per-metric pattern with full type coverage; includes a defensive dual-key mapping (pages_views ?? page_views) to handle the inconsistent field name documented in SimilarWeb's own API example response.
  • paidReferrals bug fix (website_overview.ts): extends the lookup chain to include the literal API key 'paid _referrals' (space before underscore), which was causing this field to always resolve to null on API Lite responses.
  • UX improvement (similarweb.ts): startDate, endDate, and mainDomainOnly are now mode: 'advanced', reducing noise in the default block view.

Confidence Score: 5/5

Purely additive change — new tool and a narrow bug fix with no removed or renamed fields.

The paidReferrals fix is a correctly ordered lookup chain that adds a new key without touching the existing ones. The new page_views tool faithfully mirrors the sibling tool structure, handles the documented API key inconsistency defensively, and is wired into the registry and block in all the right places. No existing behavior is altered.

No files require special attention.

Important Files Changed

Filename Overview
apps/sim/tools/similarweb/page_views.ts New tool implementation for the page-views endpoint; follows established sibling patterns, includes defensive dual-key mapping for the docs-confirmed pages_views spelling quirk, and handles error/meta extraction consistently.
apps/sim/tools/similarweb/website_overview.ts Bug fix: extends paidReferrals lookup to include the literal 'paid _referrals' key (space before underscore) that the API Lite response actually uses, preventing it from always returning null.
apps/sim/tools/similarweb/types.ts Adds SimilarwebPageViewsParams and SimilarwebPageViewsResponse interfaces, consistent with the established empty-extension pattern for other metric types.
apps/sim/blocks/blocks/similarweb.ts Registers the new similarweb_page_views operation, adds its output key, and promotes the optional time-range/toggle inputs to advanced mode for cleaner default block UI.
apps/sim/tools/registry.ts Imports and registers similarwebPageViewsTool under the similarweb_page_views key; placement is consistent with sibling tools.
apps/sim/tools/similarweb/index.ts Adds the barrel export for similarwebPageViewsTool; ordering matches sibling exports alphabetically.

Reviews (3): Last reviewed commit: "fix(similarweb): accept both page_views ..." | Re-trigger Greptile

Comment thread apps/sim/tools/similarweb/page_views.ts Outdated
@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cursor review

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 641b39a. Configure here.

- Add similarweb_page_views tool (Total Page Views, Desktop & Mobile)
- Fix paidReferrals in website overview: API Lite response key is
  literally "paid _referrals" (space before underscore), not caught
  by the existing fallback chain, so it always resolved to null
- Move startDate/endDate/mainDomainOnly to advanced mode
…esponse

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.
@waleedlatif1 waleedlatif1 force-pushed the worktree-similarweb-validate branch from 641b39a to 88c83f4 Compare July 2, 2026 16:58
@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cursor review

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 88c83f4. Configure here.

@waleedlatif1 waleedlatif1 merged commit 5966e5c into staging Jul 2, 2026
18 checks passed
@waleedlatif1 waleedlatif1 deleted the worktree-similarweb-validate branch July 2, 2026 17:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant