Skip to content

Display user feedback in the admin panel & other minor improvements - #595

Merged
Blaumaus merged 2 commits into
mainfrom
improvement/admin-panel
Jul 24, 2026
Merged

Blaumaus merged 2 commits into
mainfrom
improvement/admin-panel

Conversation

@Blaumaus

@Blaumaus Blaumaus commented Jul 24, 2026 •

Copy link
Copy Markdown
Member

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
    • Added Billing, Feedback, and Bot Blocks sections to the admin area, including charts, stats, tables, and pagination.
    • Introduced revenue reporting with current/previous comparisons, plus billing health and payment activity displays.
    • Expanded analytics with activation funnel and enhanced admin charts.
    • Added project and organisation detail views (including members/projects and recent breakdowns).
  • Improvements
    • Upgraded admin tables and lists to support sorting controls and clearer navigation between list and detail views.

@Blaumaus Blaumaus self-assigned this Jul 24, 2026
@coderabbitai

coderabbitai Bot commented Jul 24, 2026 •

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 96f4144b-4eb7-43e7-96b7-72e89f485194

📥 Commits

Reviewing files that changed from the base of the PR and between 5c95971 and 026a5e1.

📒 Files selected for processing (1)
  • web/app/pages/Admin/ProjectsTab.tsx

📝 Walkthrough

Walkthrough

The admin system adds revenue, billing, bot-block, and feedback capabilities; richer project and organisation details; comparison analytics and activation funnels; sortable tables; shared chart components; and expanded loader, route, type, and UI wiring.

Changes

Admin analytics and operations

Layer / File(s) Summary
Revenue and billing data contracts
backend/apps/cloud/src/admin/*
Paddle payments are cached and aggregated into revenue buckets, while billing combines payment feeds with trials, cancellations, suspensions, and churn-risk accounts.
Analytics and entity details
backend/apps/cloud/src/admin/*
Overview comparisons, activation funnels, bot-block analytics, project details, organisation details, and server-side organisation sorting are added.
Feedback retrieval and presentation
backend/apps/cloud/src/admin/*, web/app/pages/Admin/FeedbackTab.tsx
Feedback is retrieved by category with search, ordering, pagination, counts, author resolution, and attachment rendering.
Shared charts and sortable tables
web/app/pages/Admin/AdminChart.tsx, web/app/pages/Admin/components.tsx, web/app/pages/Admin/DatabaseTab.tsx, web/app/ui/Select.tsx
Reusable charts, change badges, sortable table primitives, database table sorting, and select menu width overrides are introduced.
Loader routing and operational tabs
web/app/routes/admin.tsx, web/app/pages/Admin/index.tsx, web/app/pages/Admin/{OverviewTab,BillingTab,BotBlocksTab}.tsx
New tabs and query parameters are loaded and rendered, including revenue fallback handling, billing, bot-block periods, feedback filters, and detail selections.
Entity detail and list views
web/app/pages/Admin/{ProjectsTab,OrganisationsTab,UsersTab}.tsx
Project and organisation detail screens, sortable selectable lists, linked records, and effective account-limit views are added.

Estimated code review effort: 5 (Critical) | ~120 minutes

Sequence Diagram(s)

sequenceDiagram
  participant AdminPage
  participant AdminRoute
  participant AdminController
  participant AdminService
  participant DataStores
  AdminPage->>AdminRoute: Request tab and query parameters
  AdminRoute->>AdminController: Fetch admin tab data
  AdminController->>AdminService: Load analytics, details, billing, or feedback
  AdminService->>DataStores: Query MySQL, ClickHouse, Redis, or Paddle
  DataStores-->>AdminService: Aggregated admin data
  AdminService-->>AdminController: Typed response payload
  AdminController-->>AdminRoute: JSON response
  AdminRoute-->>AdminPage: Loader data for the selected tab
Loading

Possibly related PRs

  • Swetrix/swetrix#543: Introduces the UserFeedback entity used by the new admin feedback retrieval flow.
  • Swetrix/swetrix#594: Provides the admin panel foundation extended by these backend routes, loader branches, tabs, and data contracts.
🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The template is mostly filled, but the required Changes section is empty, so the pull request description is incomplete. Add a concise Changes summary describing the new admin feedback tab and the related billing, bot-blocks, sorting, and detail-view updates.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title matches the main change by calling out the new admin feedback display and broader admin-panel improvements.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch improvement/admin-panel

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.

@coderabbitai coderabbitai 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.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@web/app/pages/Admin/OverviewTab.tsx`:
- Around line 263-285: Update the growth MetricCards in Admin
OverviewTab—Signups, Projects created, Organisations created, and Events
processed—to use goodChangeDirection='up' so positive count changes are treated
as favorable; leave their values, change calculations, and valueMapper settings
unchanged.

In `@web/app/pages/Admin/ProjectsTab.tsx`:
- Around line 513-540: Update the rank cell in the topProjects table so it
derives the traffic rank from the original unsorted topProjects.projects list
rather than the sorted map index. Keep sorting behavior for the other columns
unchanged, and preserve the stable rank when users sort by Project, Owner, or
Created.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: e93e5cc8-d389-4824-8a10-1ac7812a51a6

📥 Commits

Reviewing files that changed from the base of the PR and between e57194b and 5c95971.

📒 Files selected for processing (17)
  • backend/apps/cloud/src/admin/admin.controller.ts
  • backend/apps/cloud/src/admin/admin.module.ts
  • backend/apps/cloud/src/admin/admin.service.ts
  • web/app/pages/Admin/AdminChart.tsx
  • web/app/pages/Admin/BillingTab.tsx
  • web/app/pages/Admin/BotBlocksTab.tsx
  • web/app/pages/Admin/DatabaseTab.tsx
  • web/app/pages/Admin/FeedbackTab.tsx
  • web/app/pages/Admin/OrganisationsTab.tsx
  • web/app/pages/Admin/OverviewTab.tsx
  • web/app/pages/Admin/ProjectsTab.tsx
  • web/app/pages/Admin/UsersTab.tsx
  • web/app/pages/Admin/components.tsx
  • web/app/pages/Admin/index.tsx
  • web/app/pages/Admin/types.ts
  • web/app/routes/admin.tsx
  • web/app/ui/Select.tsx

Comment on lines +263 to +285
<MetricCard
label='Signups'
value={totals.signups.current}
change={totals.signups.current - totals.signups.previous}
goodChangeDirection='down'
valueMapper={countMetricMapper}
/>
<MetricCard
label='Projects created'
value={totals.projects.current}
change={totals.projects.current - totals.projects.previous}
goodChangeDirection='down'
valueMapper={countMetricMapper}
/>
<MetricCard
label='Organisations created'
value={totals.organisations.current}
change={
totals.organisations.current - totals.organisations.previous
}
goodChangeDirection='down'
valueMapper={countMetricMapper}
/>

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🌐 Web query:

motion react MetricCard goodChangeDirection ChangeBadge colour semantics

💡 Result:

In modern React UI development—often using libraries like Framer Motion with component frameworks like shadcn/ui—the semantic coloring and directional logic for metric cards and badges follow established design patterns rather than a single, universal API [1][2][3]. Semantic Colour Semantics and Trends Metric cards typically determine color semantics based on the relationship between the change and the metric's business context [4][5]. - Trend Directionality: A common pattern involves a trendDirection or trend prop (e.g., 'up-good', 'up-bad', 'down-good', 'down-bad') [4]. This allows developers to invert the meaning of 'up' or 'down' based on the metric type (e.g., an increase in 'Revenue' is good, while an increase in 'Churn' or 'Latency' is bad) [5]. - Implementation: Trend indicators are typically rendered via a Badge component that dynamically assigns CSS classes (e.g., Tailwind 'text-green-500' for positive, 'text-red-500' for negative) based on the calculated trend direction [2][6]. Motion and Badges - Motion Integration: When using Motion (Framer Motion), badges are often wrapped in motion.create() or motion.span to enable entrance/exit animations [7][8]. - Direction-Aware Animation: Advanced implementations use AnimatePresence combined with a custom direction prop (e.g., 'forward' or 'back') to trigger coordinate-based animations (like sliding or morphing) [9]. - Accessibility: Best practices dictate that color alone should never convey trend direction [1]. Developers are encouraged to pair semantic colors with icons (e.g., arrows) and screen-reader-accessible labels (aria-hidden icons with sr-only text) to ensure the UI remains perceivable to users with color vision deficiencies [1]. Summary of Common Props While implementations vary by UI library, common prop patterns include [4][5][10]: - trendDirection: 'up-good' | 'up-bad' | 'down-good' | 'down-bad' - invertTrend: boolean (often used to toggle whether 'down' is considered positive) - status: 'ok' | 'warning' | 'critical' (often used for border or background accents)

Citations:


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "Tracked files matching OverviewTab and MetricCard:"
git ls-files | rg '(^|/)(OverviewTab\.(tsx|ts|jsx|js)|MetricCard\.(tsx|ts|jsx|js))$|MetricCard$' || true

echo
echo "Search MetricCard definition/usages:"
rg -n "class MetricCard|const MetricCard|function MetricCard|export .*MetricCard|goodChangeDirection|ChangeBadge" -S .

Repository: Swetrix/swetrix

Length of output: 4237


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "OverviewTab relevant sections:"
sed -n '70,110p;205,340p' web/app/pages/Admin/OverviewTab.tsx | cat -n

echo
echo "Traffic MetricCards ChangeBadge implementation:"
sed -n '33,107p' web/app/pages/Project/tabs/Traffic/MetricCards.tsx | cat -n

echo
echo "Consistency check: growth metric current values are never negative-like counts"
python3 - <<'PY'
from pathlib import Path
p = Path('web/app/pages/Admin/OverviewTab.tsx')
text = p.read_text()
for label in ['Signups', 'Projects created', 'Organisations created', 'Events']:
    import re
    m = re.search(rf"label='{re.escape(label)}'.*?goodChangeDirection=([^,\n>]+)|label=\{{'\*?Events")
    print(label, m.group(0) if m else 'NOT FOUND')
PY

Repository: Swetrix/swetrix

Length of output: 9822


Use goodChangeDirection='up' for growth MetricCards.

Signups, Projects created, Organisations created, and Events processed count increases as growth. With goodChangeDirection='down', a positive delta is shown as slate/no-positive-color, while a decline is shown green (good); these cards should use goodChangeDirection='up' unless the design intentionally requires slate for positive growth.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@web/app/pages/Admin/OverviewTab.tsx` around lines 263 - 285, Update the
growth MetricCards in Admin OverviewTab—Signups, Projects created, Organisations
created, and Events processed—to use goodChangeDirection='up' so positive count
changes are treated as favorable; leave their values, change calculations, and
valueMapper settings unchanged.

Comment thread web/app/pages/Admin/ProjectsTab.tsx
@Blaumaus
Blaumaus merged commit 913c2a1 into main Jul 24, 2026
9 of 10 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