Skip to content

Removed unused post analytics view - #30135

Merged
cmraible merged 1 commit into
mainfrom
codex/remove-unused-code-2026-08-20
Aug 20, 2026
Merged

cmraible merged 1 commit into
mainfrom
codex/remove-unused-code-2026-08-20

Conversation

@cmraible

Copy link
Copy Markdown
Collaborator

no refs

Evidence that the component is unused

PostAnalyticsView is not exported by the private Admin package, and repository-wide searches for both its symbol and module path find no importer. Admin-only Knip reported apps/admin/src/posts/analytics/components/post-analytics-view.tsx as an unused file before this removal and stopped reporting it afterward. The Admin build uses explicit routes and entry points; no dynamic import or glob references this path.

History and intentionality

Documented facts:

  • ad52284 introduced the component as the loading/empty/content wrapper in the first React post-analytics skeleton. Added Post Analytics skeleton in React #22978 explains that the work began a better breakdown of post statistics, initially focused on web analytics for one post.
  • 54d993b replaced that static wrapper in the main page with real post and traffic data. Added dynamic data loading to page analytics #22986 says this made the previously static skeleton usable for beta users.
  • 26de9ed later reused the component only as the loading screen for a duplicated withFeatureFlag wrapper. Fixed Post Analytics > Newsletter tab premature redirect #23270 documents that the wrapper prevented the Newsletter tab from redirecting before the alpha setting had loaded, and explicitly called the duplication temporary.
  • Updated statsX flag to trafficAnalyticsAlpha #23029 documents the rollout model: trafficAnalytics selected beta users, while trafficAnalyticsAlpha selected features still under development for that beta.
  • f0a33b8 intentionally moved Newsletter analytics out of alpha. Its diff replaced the protected route with the direct Newsletter route and made the sidebar links unconditional; Moved Newsletter tab out of alpha for Stats and Posts #23294 states that purpose directly. Production therefore stopped reaching the wrapper, and consequently PostAnalyticsView, on May 12, 2025. Given the documented flag semantics, this was an intentional promotion to the analytics beta rather than an accidental bypass.
  • fb0790b later restored the alpha flag for other design work but did not restore Newsletter's route guard, corroborating that Newsletter's promotion was deliberate.
  • 566f8a9 removed the now-unreachable wrapper and its tests. Removed dead code from admin and ember-admin #29686 identifies those files as duplicated dead code with no live importers. That deletion removed the component's last source or test importer on July 30, 2026.

Inference: leaving PostAnalyticsView behind in that last cleanup was an incomplete leaf cleanup. No historical source explicitly describes the omission, but the dead-code PR's stated intent, the current zero-reference result, and Knip's independent unused-file report support that conclusion.

Removal

Deleted the 33-line orphaned component. It had no dedicated tests, export, dependency, configuration, or documentation to remove. Its EmptyStatView and PostAnalyticsContent dependencies remain used by live analytics screens.

Verification

  • pnpm exec knip --workspace @tryghost/admin --include files --reporter compact --no-progress (the removed file is absent; four pre-existing acceptance setup/config entries remain)
  • pnpm --dir apps/admin lint
  • pnpm --dir apps/admin typecheck
  • pnpm --dir apps/admin test:unit (135 files, 1,604 tests)
  • pnpm nx run @tryghost/admin:build
  • pnpm nx run-many -t test --exclude @tryghost/e2e --exclude ghost-admin --exclude @tryghost/koenig-lexical (35 projects, including 8,000 Ghost tests)

pnpm check completed repository-wide lint and documentation checks, but its aggregate test phase could not run Koenig Lexical's browser suite in this environment: Chromium was denied Mach port registration and the configured Firefox executable is absent. The broader test run above excludes only that environment-blocked package and passed.

no ref

Newsletter analytics has rendered directly since it was promoted from alpha. The later dead-code cleanup deleted the component's sole importer but left this file behind.
@cmraible cmraible added the codex label Aug 20, 2026
@coderabbitai

coderabbitai Bot commented Aug 20, 2026 •

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: QUIET

Plan: Pro Plus

Run ID: cd14c631-def2-46ea-8e64-140128ce5433

📥 Commits

Reviewing files that changed from the base of the PR and between 3580c2d and 0e81ea6.

📒 Files selected for processing (1)
  • apps/admin/src/posts/analytics/components/post-analytics-view.tsx
💤 Files with no reviewable changes (1)
  • apps/admin/src/posts/analytics/components/post-analytics-view.tsx

Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.


Walkthrough

The pull request deletes PostAnalyticsView, its props interface, loading and empty-state rendering, and the PostAnalyticsContent wrapper.

Possibly related PRs

  • TryGhost/Ghost#29685: Directly overlaps with the removal of PostAnalyticsView and related analytics cleanup.
  • TryGhost/Ghost#29686: Removes obsolete code from apps/admin, including related analytics cleanup.
  • TryGhost/Ghost#30142: Deletes unused React components and public exports in separate files.

Merge Risk: ⚪ Minimal · up to 0e81e

This removes an unused analytics component without changing live behavior, and the supplied checks pass; no actionable merge-blocking risk remains.

🚥 Pre-merge checks | ✅ 6
✅ Passed checks (6 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the deletion of the unused PostAnalyticsView component.
Description check ✅ Passed The description directly explains the component removal, its history, supporting evidence, and verification results.
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.
Type-Safe Boundaries ✅ Passed The PR changes only by deleting the unused component; it adds no boundary reads, schemas, type bypasses, or duplicated schema types.
New Files Are Typescript ✅ Passed The PR diff contains one deletion of a .tsx file and no added files, so it does not add any .js/.jsx/.cjs/.mjs source file.
✨ 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 codex/remove-unused-code-2026-08-20

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.

@nx-cloud

nx-cloud Bot commented Aug 20, 2026 •

Copy link
Copy Markdown

🤖 Nx Cloud AI Fix

Ensure the fix-ci command is configured to always run in your CI pipeline to get automatic fixes in future runs. For more information, please see https://nx.dev/ci/features/self-healing-ci


View your CI Pipeline Execution ↗ for commit 0e81ea6

Command Status Duration Result
nx run @tryghost/admin:test:acceptance ✅ Succeeded 7m 4s View ↗
nx run-many -t test:unit -p @tryghost/admin ✅ Succeeded 2m 26s View ↗
nx run ghost-monorepo:lint:boundaries ✅ Succeeded <1s View ↗
nx run-many -t lint -p @tryghost/admin,ghost-mo... ✅ Succeeded 2s View ↗
nx run-many --target=build --projects=tag:publi... ✅ Succeeded <1s View ↗
nx run @tryghost/admin:build ✅ Succeeded 4s View ↗

💡 Verify your cache is correct by running tasks in a sandbox. Read docs ↗


☁️ Nx Cloud last updated this comment at 2026-08-20 07:26:28 UTC

@cmraible
cmraible marked this pull request as ready for review August 20, 2026 15:37
@cmraible
cmraible merged commit 77a3a7b into main Aug 20, 2026
54 checks passed
@cmraible
cmraible deleted the codex/remove-unused-code-2026-08-20 branch August 20, 2026 19:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant