Skip to content

Traffic: align the date range picker with the Insights filter (24h / All / Custom) #505

Closed

Description

@gkhngyk

Problem

The AI Traffic Analytics page has a partial time range picker — only 7d / 30d / 90d relative presets (web/src/app/[locale]/(dashboard)/dashboard/traffic/page.tsx, TIME_RANGE_OPTIONS). Every other analytical page (Insights, Citations, the prompt detail page) offers 24h / 7d / 30d / 90d / All / Custom with From/To date inputs. A user who reviews yesterday's spike or a specific campaign week on Insights cannot reproduce the same window on Traffic.

Design

Mirror the Insights filter bar (reference implementations: the getDateRange helper + preset bar in web/src/app/[locale]/(dashboard)/dashboard/insights/page.tsx, and the recent prompt-detail version added in #496):

UI

  • Replace the three-button strip with the full preset row: 24h / 7d / 30d / 90d / All / Custom; Custom reveals From/To date inputs. Keep the current visual style of the page's picker.
  • Section labels that interpolate the day count ("Last {days} Days", "last {days} days") need range-aware wording — e.g. "Last 24 hours", "All time", or the explicit From–To dates for custom.
  • The referral visits table's pager must reset to page 0 when the range changes (it already resets on filter changes — extend the same dependency).

Server actions (web/src/lib/actions/traffic.ts)

  • getTrafficSummary, getTrafficTrend and the visits query currently take days: number. Accept an optional { dateFrom?: string; dateTo?: string } window instead (or alongside, with the presets resolved client-side via getDateRange), applying the repo's expandDateToEndOfDay convention from web/src/lib/dates.ts so a bare YYYY-MM-DD To-date includes the whole day.
  • All sections (summary KPIs, trend chart, referral visits table) must follow the same window from the same resolved range — no section may keep its own notion of the period.
  • All = no date bounds. The trend query buckets per day; verify it stays reasonable on long histories (cap or aggregate if needed and say so in the PR).

Acceptance criteria

  • The picker offers 24h / 7d / 30d / 90d / All / Custom (with working From/To inputs) and defaults to 7d (current behavior).
  • KPIs, the trend chart and the visits table all change together with the selected range; the pager resets on range change.
  • Section headings describe the selected range correctly for every preset, including Custom and All.
  • A window selected on Insights and the same window selected on Traffic cover the same time span (end-of-day inclusive To dates).
  • yarn lint, yarn typecheck and yarn format:check pass from web/.

Getting started

See CONTRIBUTING.md for setup. npm run dev with the seed data (supabase/seed.sql) is enough to verify. Comment here to claim the issue before opening a PR.

Activity

  1. added
    enhancement
    good first issue
    help wanted
    on Jul 22, 2026
  2. Utkarsh-Singhal-26 commented on Jul 22, 2026

    @Utkarsh-Singhal-26
    Contributor

    hi @gkhngyk, can i work on this ?

  3. gkhngyk commented on Jul 22, 2026

    @gkhngyk
    ContributorAuthor

    hi @Utkarsh-Singhal-26 , I've assigned this to you. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

enhancementgood first issuehelp wanted

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions