Repository navigation
fix(web): show period-specific empty state on AI Traffic page - #631
Conversation
gkhngyk
left a comment
There was a problem hiding this comment.
Nice touch running the lifetime count only when a window actually narrows the query — the trulyEmpty/isEmpty split matches the Insights pattern exactly. Thanks!
|
This picked up conflicts after #630 (same header/imports area in |
1d3666a to
9a9c265
Compare
|
Rebased onto main and resolved the conflicts — kept both the |
Summary
The Traffic page's empty check (
totalVisits === 0 && logs.length === 0) was date-range-blind, so a brand with plenty of historical traffic that picks a narrow window (e.g. "Last 24 hours") with no visits in it saw the snippet-onboarding card ("Add the tracking snippet to your website...") — wrongly implying their integration was broken.This mirrors the
NoDataForPeriodpattern already used on the Insights page:getTrafficSummary(web/src/lib/actions/traffic.ts) now returnshasAnyData, a cheap unfilteredcount-only check for whether the brand has any lifetime traffic, independent of the selected window.web/src/app/[locale]/.../traffic/page.tsx) splits the old singleisEmptyintoisEmpty(nothing in the current window) andtrulyEmpty(isEmpty && !hasAnyData). The onboarding card now only shows fortrulyEmpty. A newNoTrafficForPeriodstate renders when the window is empty but lifetime data exists, naming the selected range with a "Show all data" button that resets to "All time."Related issue
Closes #608
Type of change
fix— Bug fixChecklist
feature/,fix/,chore/,docs/) — see CONTRIBUTING.mdyarn lintpasses (run fromweb/)yarn typecheckpasses (run fromweb/)yarn format:checkpasses (run fromweb/)