Repository navigation
Moved duplicated admin analytics files into shared module - #29685
Conversation
no ref - site and post analytics each had an identical empty-stat-view, differing only by a -mt-10 offset; the shared copy takes a className prop and the site call site passes the offset, so both surfaces render exactly as before - POST_ANALYTICS_INCLUDE now lives with the rest of the shared analytics constants; it had no counterpart or conflict there - dropped the unused named GrowthSources exports (all call sites import the default); the two growth-sources components themselves stay separate as they intentionally differ per surface - the site/post KPI_METRICS records and the Stats date-range-select wrapper are deliberately left in place: the records encode surface-specific metrics and colors (visit-duration vs time-on-page), and the wrapper meaningfully binds the shared select to the site analytics context
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
WalkthroughAnalytics empty-state UI is consolidated into a shared component with optional class-name support, and analytics views update their imports and layout usage. The post-analytics include constant moves to shared analytics constants, with its consumers updated. Both GrowthSources components remove their named exports while retaining default exports. 🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
|
| Command | Status | Duration | Result |
|---|---|---|---|
nx run @tryghost/admin:test:acceptance |
✅ Succeeded | 5m 41s | View ↗ |
nx run-many -t test:unit -p @tryghost/admin |
✅ Succeeded | 2m 4s | View ↗ |
nx run ghost-monorepo:lint:boundaries |
✅ Succeeded | 22s | View ↗ |
nx run-many -t lint -p @tryghost/admin,ghost-mo... |
✅ Succeeded | 55s | View ↗ |
nx run @tryghost/admin:build |
✅ Succeeded | 16s | View ↗ |
nx run-many --target=build --projects=tag:publi... |
✅ Succeeded | <1s | View ↗ |
💡 Verify your cache is correct by running tasks in a sandbox. Read docs ↗
☁️ Nx Cloud last updated this comment at 2026-07-30 14:21:16 UTC
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 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 `@apps/admin/src/shared/analytics/empty-stat-view.tsx`:
- Around line 10-11: Move the className merge from the icon container to the
outer empty-state wrapper in the empty-state component, so StatsView’s layout
classes such as -mt-10 affect the complete icon-and-message block. Keep the icon
container’s existing styling unchanged.
🪄 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: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 484b0ca6-79ca-4f32-97e4-6354237ae8af
📒 Files selected for processing (11)
apps/admin/src/analytics/views/Stats/Growth/components/growth-sources.tsxapps/admin/src/analytics/views/Stats/layout/empty-stat-view.tsxapps/admin/src/analytics/views/Stats/layout/stats-view.tsxapps/admin/src/posts/analytics/Growth/components/growth-sources.tsxapps/admin/src/posts/analytics/components/empty-stat-view.tsxapps/admin/src/posts/analytics/components/post-analytics-view.tsxapps/admin/src/posts/analytics/hooks/use-post-details.tsapps/admin/src/posts/analytics/providers/post-analytics-provider.tsxapps/admin/src/posts/analytics/utils/constants.tsapps/admin/src/shared/analytics/constants.tsapps/admin/src/shared/analytics/empty-stat-view.tsx
💤 Files with no reviewable changes (3)
- apps/admin/src/posts/analytics/components/empty-stat-view.tsx
- apps/admin/src/posts/analytics/utils/constants.ts
- apps/admin/src/analytics/views/Stats/layout/empty-stat-view.tsx
ref #29685 Applied custom layout classes to the complete empty state so its icon and message move together.

Deduplicates a handful of small analytics files in
apps/adminbetween the site-wide (src/analytics) and post-scoped (src/posts/analytics) surfaces.Merged
-mt-10offset in the site version. Moved tosrc/shared/analytics/empty-stat-view.tsxwith an optionalclassNameprop merged viacnonto the element the offset was on; the site call site now passes-mt-10, so both surfaces render exactly as before. Both originals deleted.src/posts/analytics/utils/constants.ts(a single constant) intosrc/shared/analytics/constants.ts; it had no name or value conflict with any shared constant. Importers updated, small file deleted.GrowthSourcesalongside their default export; the named exports are dropped (all call sites import the default). The two components themselves are intentionally left separate.Left divergent on purpose
src/analytics/views/Stats/Web/web-kpi-metrics.tsvssrc/posts/analytics/Web/components/kpi-metrics.ts) — concluded these are legitimately divergent rather than accidental drift, because the post record encodes post-page semantics the site record doesn't: a different metric key/label (duration/"Time on page" vsvisit-duration/"Visit duration") and different chart colors; only the already-sharedKpiMetrictype is common.src/analytics/views/Stats/components/date-range-select.tsx) — not a pure re-export: it binds the sharedDateRangeSelectto the site-wide analytics context (useAnalyticsrange state) so call sites don't each read the context, so it stays.Verification
cd apps/admin && pnpm lint— cleancd apps/admin && pnpm test:unit— 100 files, 1083 tests passedcd apps/admin && pnpm typecheck— clean