Skip to content

Display today period current hour as dashed line#480

Merged
Blaumaus merged 3 commits into
mainfrom
improvement/dashed-line-today-period
Mar 7, 2026
Merged

Display today period current hour as dashed line#480
Blaumaus merged 3 commits into
mainfrom
improvement/dashed-line-today-period

Conversation

@Blaumaus
Copy link
Copy Markdown
Member

@Blaumaus Blaumaus commented Mar 7, 2026

Changes

If applicable, please describe what changes were made in this pull request.

Community Edition support

  • Your feature is implemented for the Swetrix Community Edition
  • This PR only updates the Cloud (Enterprise) Edition code (e.g. Paddle webhooks, blog, payouts, etc.)

Database migrations

  • Clickhouse / MySQL migrations added for this PR
  • No table schemas changed in this PR

Documentation

  • You have updated the documentation according to your PR
  • This PR did not change any publicly documented endpoints

Summary by CodeRabbit

  • New Features

    • Traffic charts: support period and timezone parameters for more accurate, timezone-aware displays and formatting.
    • Improved region calculations with better handling for 'today' views and unified region application across metrics.
  • Chores

    • Feedback widget tracking updated to use the integrated tracking interface (no user-facing behavior changes).

@Blaumaus Blaumaus self-assigned this Mar 7, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Mar 7, 2026

Caution

Review failed

Pull request was closed or merged during review

📝 Walkthrough

Walkthrough

Adds period and timezone propagation from TrafficView → TrafficChart → getSettings, initializes dayjs UTC/timezone plugins, and refactors feedback tracking to use a Swetrix import and aligned error variable naming.

Changes

Cohort / File(s) Summary
Feedback Widget Updates
docs/components/FeedbackWidget.tsx
Replaced window.swetrix.track with Swetrix.track via an explicit Swetrix import; renamed catch variable from reason to errorReason.
Chart Region & Timezone Support
web/app/pages/Project/View/ViewProject.helpers.tsx
Initialized dayjs UTC & timezone plugins; extended getSettings signature with period?: string and timezone?: string; reworked region calculation to handle timezone-aware "today" logic and consolidate regions into a single regionObj.
Traffic Chart Props & Propagation
web/app/pages/Project/tabs/Traffic/TrafficChart.tsx, web/app/pages/Project/tabs/Traffic/TrafficView.tsx
Added optional period and timezone props to TrafficChartProps; TrafficChart forwards period/timezone to getSettings and includes them in memo deps; TrafficView passes activePeriod?.period and timezone into TrafficChart.

Sequence Diagram(s)

mermaid
sequenceDiagram
participant View as TrafficView
participant Chart as TrafficChart
participant Helpers as ViewProject.helpers
View->>Chart: render(period, timezone, other props)
Chart->>Helpers: getSettings(chart, ..., period, timezone)
Helpers-->>Chart: settings (regions adjusted for timezone/period)
Chart-->>View: rendered chart with timezone-aware regions

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Poem

🐰 I hopped through timezones, nibbling at dates,
Passing periods down tiny component gates,
dayjs lit my path, Swetrix heard my cheer,
Regions aligned—now the charts are clear! ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Display today period current hour as dashed line' directly summarizes the main change: rendering the current hour as a dashed line when viewing the 'today' period in the traffic chart.
Description check ✅ Passed The PR description addresses all required template sections with appropriate checkboxes marked, indicating Community Edition support and no schema changes, though implementation details are minimal.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch improvement/dashed-line-today-period

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@web/app/pages/Project/View/ViewProject.helpers.tsx`:
- Around line 683-697: The formatter error is caused by inconsistent wrapping in
the regionStart ternary/object block around regionStart and regionObj
(references: regionStart, regionObj, chart.x, xAxisSize); fix by running the
project's formatter (oxfmt --write) to normalize the ternary branches and object
formatting, or manually reformat that block so the ternary expressions and the
regionObj literal follow the project's oxfmt style (consistent line breaks and
indentation) and then re-run oxfmt to ensure CI passes.
- Around line 661-697: The region currently created in the today/timezone branch
(regionObj) only sets start which makes the dashed style run to the end of the
series; update the logic that computes regionObj to also set an end timestamp
clipped to the current hour boundary—use the computed currentIndex and chart.x
to choose the next hour boundary (e.g., chart.x[currentIndex] or
chart.x[currentIndex + 1] / the next hour start) when available, otherwise
compute the next hour from nowInTz, and assign that value to regionObj.end so
the dashed region covers only the active hour.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 510ca9c6-fa98-4fc2-a90f-794681666c91

📥 Commits

Reviewing files that changed from the base of the PR and between 682e848 and 18e06ac.

📒 Files selected for processing (4)
  • docs/components/FeedbackWidget.tsx
  • web/app/pages/Project/View/ViewProject.helpers.tsx
  • web/app/pages/Project/tabs/Traffic/TrafficChart.tsx
  • web/app/pages/Project/tabs/Traffic/TrafficView.tsx

Comment thread web/app/pages/Project/View/ViewProject.helpers.tsx
Comment thread web/app/pages/Project/View/ViewProject.helpers.tsx Outdated
@Blaumaus Blaumaus merged commit 5c57a29 into main Mar 7, 2026
11 of 12 checks passed
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