Skip to content

Traffic: add a 7 / 30 / 90-day time-range picker #451

Closed

Description

@gkhngyk

Problem

The AI Traffic page is hard-locked to the last 7 days: KPIs, the trend chart (whose title literally says "AI Referral Trend — Last 7 Days"), the platform breakdown and Top Landing Pages all show a fixed window. There is no way to look at a month or a quarter of traffic.

The backend is already ready: getTrafficSummary(brandId, days = 7) and getTrafficTrend(brandId, days = 7) in web/src/lib/actions/traffic.ts accept a days parameter — the page just never passes it.

Fix

In web/src/app/[locale]/(dashboard)/dashboard/traffic/page.tsx:

  • Add a small segmented control in the page header with 7d / 30d / 90d options (default 7d) — same presets the report generate dialog uses. The existing view-toggle button group in the Query Fan-out tab (_fanout-tab.tsx) is a good styling reference.
  • Store the selection in state and pass it to getTrafficSummary, getTrafficTrend, and getTrafficLogs' future callers via the existing load(); reload on change.
  • Make the trend-chart title dynamic ("Last 7 Days" → "Last 30 Days" / "Last 90 Days"), and keep the KPI's "vs previous period" sublabel correct — the actions already compare against the preceding window of the same length.
  • The "last 7 days" fallback sublabel on the visits KPI should follow the selected range too.

Acceptance criteria

  • Switching between 7d / 30d / 90d reloads KPIs, both charts and both tables with the selected window.
  • The trend chart title and KPI sublabels reflect the selected range.
  • Default remains 7 days; switching brands keeps working as before.

Getting started

See CONTRIBUTING.md for setup. From web/, yarn lint, yarn typecheck and yarn format:check must pass. Comment here to claim the issue before opening a PR.

Activity

  1. added
    enhancement
    good first issue
    on Jul 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementgood first issue

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions