Skip to content

Removed dead code from admin and ember-admin - #29686

Merged
9larsons merged 2 commits into
mainfrom
slars/admin-dead-code-sweep
Jul 30, 2026
Merged

9larsons merged 2 commits into
mainfrom
slars/admin-dead-code-sweep

Conversation

@9larsons

Copy link
Copy Markdown
Contributor

Summary

Deletes modules in apps/admin and apps/ember-admin that have no live importers, plus two labs-flag declarations in the Ember feature service that nothing consumes.

  • apps/admin/src/index.tsx — zero-byte file; the Vite entry is src/main.tsx and no config or import references it.
  • Orphaned automations welcome-email chain — automations/hooks/use-welcome-email-sender-details.ts, automations/utils/welcome-email-sender-details.ts, and automations/utils/newsletter-emails.ts only imported each other; nothing else imports any of them. The live copy at automations/components/email-modal/newsletter-emails.ts is untouched.
  • posts/analytics feature-flag pair — posts/analytics/hooks/use-feature-flag.tsx and with-feature-flag.tsx (plus their tests) duplicated the canonical src/hooks/use-feature-flag.ts; every live useFeatureFlag import already resolves to the canonical hook.
  • Unused analytics files — analytics/hooks/use-labs-flag.ts, analytics/views/Stats/components/post-menu.tsx, analytics/views/Stats/components/section-header.tsx (already empty), posts/analytics/components/sidebar.tsx, posts/analytics/modals/share-modal.tsx, and the unused barrel whats-new/components/index.ts. Zero references to each: the onboarding ShareModal comes from @tryghost/shade/patterns, and all whats-new imports go directly to the component files rather than the barrel.
  • posts/analytics/hooks/use-edit-links.ts (plus test) — a property-renaming wrapper around useBulkEditLinks whose own header comment says to remove it; its single caller (posts/analytics/Newsletter/newsletter.tsx) now calls useBulkEditLinks from @tryghost/admin-x-framework/api/links directly.
  • apps/ember-admin/tests/helpers/mock-analytics-apps.js — reduced to two no-op functions when the analytics apps moved into the React admin; removed along with its imports and call sites in the 10 acceptance test files, dropping beforeEach/afterEach hooks that would otherwise be empty.
  • Ember feature service flags — the tagsX and commentModeration declarations in app/services/feature.js have no consumers anywhere in apps/ember-admin; flag registration in ghost/core labs is untouched.

Every deletion was verified with repo-wide greps for the module path/basename and exported symbols before removal.

Verification

  • cd apps/admin && pnpm lint — pass
  • cd apps/admin && pnpm test:unit — 97 files, 1074 tests, pass
  • cd apps/admin && pnpm typecheck — pass
  • pnpm nx run ghost-admin:test — pass

no ref

- traced every module for live importers before deleting: the empty
  src/index.tsx, the orphaned automations welcome-email chain, the
  posts-analytics feature-flag hook/HOC pair duplicating the canonical
  src/hooks/use-feature-flag, and five unused analytics components and
  hooks referenced by nothing or only by each other
- use-edit-links was a property-renaming wrapper around useBulkEditLinks
  already flagged for removal in its own header, so its single caller
  uses the framework hook directly now
- mock-analytics-apps became a no-op when the analytics apps moved into
  the React admin, so the helper and its imports and call sites go too
- the tagsX and commentModeration labs flags have no remaining consumers
  in ember-admin, so their feature service declarations are dropped
@coderabbitai

coderabbitai Bot commented Jul 30, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: afbae2ea-fdb9-4d44-99e5-bdde54786504

📥 Commits

Reviewing files that changed from the base of the PR and between 197bb7d and 39d4184.

📒 Files selected for processing (3)
  • apps/admin-x-settings/src/hooks/use-welcome-email-sender-details.ts
  • apps/admin-x-settings/src/utils/newsletter-emails.ts
  • apps/admin-x-settings/src/utils/welcome-email-sender-details.ts

Walkthrough

Obsolete Admin analytics hooks, components, utilities, and tests are removed. Newsletter analytics link editing now uses the bulk-edit mutation directly. Ember feature declarations replace two flags with three new flags. Ember acceptance tests stop configuring no-op analytics mocks, while setup authentication flows are centralized in helpers. Sender-detail implementation notes are updated to reference current counterpart modules.

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: removing dead code from admin and ember-admin.
Description check ✅ Passed The description is clearly related to the changeset and matches the removed modules, test cleanup, and flag updates.
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 slars/admin-dead-code-sweep

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 Jul 30, 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 197bb7d

Command Status Duration Result
nx run @tryghost/admin:test:acceptance ✅ Succeeded 5m 45s View ↗
nx run-many -t test:unit -p @tryghost/admin-x-s... ✅ Succeeded 2m 32s View ↗
nx run ghost-monorepo:lint:boundaries ✅ Succeeded 22s View ↗
nx run-many -t lint -p @tryghost/admin-x-settin... ✅ Succeeded 1m 7s View ↗
nx run-many --target=build --projects=tag:publi... ✅ Succeeded 1s View ↗
nx run @tryghost/admin:build ✅ Succeeded 21s View ↗
nx run ghost-admin:test ✅ Succeeded 3s 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:39:35 UTC

@codecov

codecov Bot commented Jul 30, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 75.42%. Comparing base (2b013ae) to head (197bb7d).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #29686   +/-   ##
=======================================
  Coverage   75.42%   75.42%           
=======================================
  Files        1608     1609    +1     
  Lines      141408   141448   +40     
  Branches    17471    17486   +15     
=======================================
+ Hits       106654   106692   +38     
+ Misses      33683    33682    -1     
- Partials     1071     1074    +3     
Flag Coverage Δ
admin-tests 55.77% <ø> (+0.11%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
apps/admin/src/posts/analytics/Newsletter/newsletter.tsx (1)

150-159: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Send the trimmed URL to the mutation.

trimmedUrl is used for validation, but the request sends the original editedUrl. Leading or trailing whitespace can therefore be persisted in the link target.

Proposed fix
        void editLinks({
            originalUrl: link.link.originalTo,
-           editedUrl: editedUrl,
+           editedUrl: trimmedUrl,
            postId: postId
🤖 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 `@apps/admin/src/posts/analytics/Newsletter/newsletter.tsx` around lines 150 -
159, Update the editLinks call in the link-edit handler to pass trimmedUrl as
editedUrl instead of the untrimmed editedUrl, while preserving the existing
validation and early-return behavior.
🤖 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.

Outside diff comments:
In `@apps/admin/src/posts/analytics/Newsletter/newsletter.tsx`:
- Around line 150-159: Update the editLinks call in the link-edit handler to
pass trimmedUrl as editedUrl instead of the untrimmed editedUrl, while
preserving the existing validation and early-return behavior.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 60e98068-9daa-4c67-b40c-7f6110876beb

📥 Commits

Reviewing files that changed from the base of the PR and between 1938a05 and 197bb7d.

📒 Files selected for processing (29)
  • apps/admin/src/analytics/hooks/use-labs-flag.ts
  • apps/admin/src/analytics/views/Stats/components/post-menu.tsx
  • apps/admin/src/analytics/views/Stats/components/section-header.tsx
  • apps/admin/src/automations/hooks/use-welcome-email-sender-details.ts
  • apps/admin/src/automations/utils/newsletter-emails.ts
  • apps/admin/src/automations/utils/welcome-email-sender-details.ts
  • apps/admin/src/index.tsx
  • apps/admin/src/posts/analytics/Newsletter/newsletter.tsx
  • apps/admin/src/posts/analytics/components/sidebar.tsx
  • apps/admin/src/posts/analytics/hooks/use-edit-links.test.tsx
  • apps/admin/src/posts/analytics/hooks/use-edit-links.ts
  • apps/admin/src/posts/analytics/hooks/use-feature-flag.test.tsx
  • apps/admin/src/posts/analytics/hooks/use-feature-flag.tsx
  • apps/admin/src/posts/analytics/hooks/with-feature-flag.test.tsx
  • apps/admin/src/posts/analytics/hooks/with-feature-flag.tsx
  • apps/admin/src/posts/analytics/modals/share-modal.tsx
  • apps/admin/src/whats-new/components/index.ts
  • apps/ember-admin/app/services/feature.js
  • apps/ember-admin/tests/acceptance/authentication-test.js
  • apps/ember-admin/tests/acceptance/dashboard-test.js
  • apps/ember-admin/tests/acceptance/editor-test.js
  • apps/ember-admin/tests/acceptance/editor/post-settings-menu-test.js
  • apps/ember-admin/tests/acceptance/editor/publish-flow-test.js
  • apps/ember-admin/tests/acceptance/editor/visibility-test.js
  • apps/ember-admin/tests/acceptance/search-test.js
  • apps/ember-admin/tests/acceptance/setup-test.js
  • apps/ember-admin/tests/acceptance/signin-test.js
  • apps/ember-admin/tests/acceptance/signup-test.js
  • apps/ember-admin/tests/helpers/mock-analytics-apps.js
💤 Files with no reviewable changes (25)
  • apps/admin/src/posts/analytics/components/sidebar.tsx
  • apps/admin/src/posts/analytics/modals/share-modal.tsx
  • apps/admin/src/posts/analytics/hooks/with-feature-flag.test.tsx
  • apps/admin/src/automations/hooks/use-welcome-email-sender-details.ts
  • apps/admin/src/posts/analytics/hooks/use-feature-flag.tsx
  • apps/admin/src/posts/analytics/hooks/use-feature-flag.test.tsx
  • apps/admin/src/posts/analytics/hooks/use-edit-links.ts
  • apps/admin/src/whats-new/components/index.ts
  • apps/admin/src/automations/utils/welcome-email-sender-details.ts
  • apps/admin/src/posts/analytics/hooks/with-feature-flag.tsx
  • apps/admin/src/posts/analytics/hooks/use-edit-links.test.tsx
  • apps/admin/src/analytics/views/Stats/components/post-menu.tsx
  • apps/ember-admin/tests/acceptance/signup-test.js
  • apps/admin/src/automations/utils/newsletter-emails.ts
  • apps/ember-admin/tests/acceptance/editor/visibility-test.js
  • apps/admin/src/analytics/hooks/use-labs-flag.ts
  • apps/ember-admin/tests/helpers/mock-analytics-apps.js
  • apps/ember-admin/tests/acceptance/editor/publish-flow-test.js
  • apps/ember-admin/app/services/feature.js
  • apps/ember-admin/tests/acceptance/authentication-test.js
  • apps/ember-admin/tests/acceptance/editor-test.js
  • apps/ember-admin/tests/acceptance/dashboard-test.js
  • apps/ember-admin/tests/acceptance/search-test.js
  • apps/ember-admin/tests/acceptance/editor/post-settings-menu-test.js
  • apps/ember-admin/tests/acceptance/signin-test.js

ref #29686

The dead-code cleanup left counterpart comments pointing to obsolete paths. Keeping the notes aligned preserves the cross-app maintenance contract.
@9larsons
9larsons enabled auto-merge (squash) July 30, 2026 14:33
@9larsons
9larsons merged commit 566f8a9 into main Jul 30, 2026
45 checks passed
@9larsons
9larsons deleted the slars/admin-dead-code-sweep branch July 30, 2026 14:46
cmraible added a commit that referenced this pull request Aug 20, 2026
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.
#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. #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. #23270
documents that the wrapper prevented the Newsletter tab from redirecting
before the alpha setting had loaded, and explicitly called the
duplication temporary.
- #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;
#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.
#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.
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