Skip to content

Moved post-analytics into apps/admin and removed the posts package - #29217

Merged
9larsons merged 1 commit into
mainfrom
slars/pla-222-move-post-analytics
Jul 9, 2026
Merged

Moved post-analytics into apps/admin and removed the posts package#29217
9larsons merged 1 commit into
mainfrom
slars/pla-222-move-post-analytics

Conversation

@9larsons

@9larsons 9larsons commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

ref https://linear.app/ghost/issue/PLA-222/posts-admin-move-post-analytics-srcpostsanalytics-last

The finale of the posts→admin dissolution (PLA-222): post-analytics — the last domain — moves into apps/admin, PostsAppContext dissolves, and the now-empty @tryghost/posts package is removed entirely.

What changed

  • PostAnalytics + its post-analytics-only utils/hooks/providers → apps/admin/src/posts/analytics. Hook/util tests colocate; MSW helpers land in apps/admin/test-utils/posts-analytics.
  • PostsAppContext dissolved. The 7 useAppContext consumers now read appSettings from the framework AppContext (admin's AppProvider supplies it). fromAnalytics was always true in admin, so the header breadcrumb is hardcoded to "Analytics"; the provider + wrapper are deleted. The data provider file was split (context/hook .ts, component .tsx) for react-refresh.
  • buildMembersUrl reunified onto the members domain (now in admin), deleting the temporary copy.
  • Post-analytics routes fold into the shell table with their own PostAnalyticsProvider; gift-link-modal-host points at the moved modal; MainLayout → shade Box + Container.

Package teardown

With every domain migrated, apps/posts is empty and removed:

  • deleted apps/posts; dropped the @tryghost/posts dependency from apps/admin, the @source scan in index.css, and the tsconfig project reference
  • removed posts from asset-delivery's adminXApps, the @tryghost/posts ghost/admin nx dependency, and neutralised the obsolete Ember posts mock

Verification

  • tsc -b, eslint . (admin) — exit 0
  • vitest run (admin) — 758 tests pass
  • nx build @tryghost/admin — exit 0, now 14 dependency tasks (was 15 — posts left the graph); post-analytics code-splits into its own lazy chunks
  • pnpm install --frozen-lockfile — clean

ref https://linear.app/ghost/issue/PLA-222/posts-admin-move-post-analytics-srcpostsanalytics-last

- last domain to leave the posts package: post-analytics moves to apps/admin/src/posts/analytics, PostsAppContext dissolves, and with tags/comments/automations/members already migrated the @tryghost/posts package is now empty and removed entirely
- the seven useAppContext consumers read appSettings from the framework AppContext directly; the header's fromAnalytics breadcrumb is always "Analytics" in admin, so it is hardcoded and the PostsAppContext wrapper is deleted
- buildMembersUrl reunifies onto the members domain (now in admin); the post-analytics routes fold into the shell's route table with their own PostAnalyticsProvider; the gift-link modal host points at the moved modal; MainLayout becomes shade Box + Container
- teardown: deletes apps/posts, drops the @tryghost/posts admin dependency, the index.css @source and tsconfig project reference, the asset-delivery entry, the ghost/admin nx dependency, and neutralises the now-obsolete Ember posts mock
- migrated hook/util tests colocate beside their source with their MSW helpers under apps/admin/test-utils/posts-analytics
@nx-cloud

nx-cloud Bot commented Jul 9, 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 e673df5

Command Status Duration Result
nx run @tryghost/admin-x-settings:test:acceptance ✅ Succeeded 10m 40s View ↗
nx run ghost:test:ci:integration ✅ Succeeded 2m 39s View ↗
nx run-many --target=build --projects=tag:publi... ✅ Succeeded <1s View ↗
nx run ghost:test:integration ✅ Succeeded 2m 55s View ↗
nx run-many -t test:unit -p @tryghost/admin,@tr... ✅ Succeeded 5m 13s View ↗
nx run ghost:test:legacy ✅ Succeeded 3m 5s View ↗
nx run ghost:test:e2e ✅ Succeeded 2m 44s View ↗
nx run @tryghost/koenig-lexical:test:acceptance ✅ Succeeded 2m 34s View ↗
Additional runs (10) ✅ Succeeded ... View ↗

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


☁️ Nx Cloud last updated this comment at 2026-07-09 19:28:50 UTC

@coderabbitai

coderabbitai Bot commented Jul 9, 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

Run ID: 2d1c1354-3416-4a42-9742-0a6bbe197c10

📥 Commits

Reviewing files that changed from the base of the PR and between b966169 and e673df5.

⛔ Files ignored due to path filters (3)
  • apps/posts/src/assets/members/members-1.jpg is excluded by !**/*.jpg
  • apps/posts/src/assets/members/members-2.jpg is excluded by !**/*.jpg
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (97)
  • apps/admin/package.json
  • apps/admin/src/gift-link-modal-host.tsx
  • apps/admin/src/index.css
  • apps/admin/src/posts/analytics/Growth/components/growth-sources.tsx
  • apps/admin/src/posts/analytics/Growth/growth-helpers.ts
  • apps/admin/src/posts/analytics/Growth/growth.tsx
  • apps/admin/src/posts/analytics/Newsletter/components/feedback.tsx
  • apps/admin/src/posts/analytics/Newsletter/components/newsletter-radial-chart.tsx
  • apps/admin/src/posts/analytics/Newsletter/newsletter.tsx
  • apps/admin/src/posts/analytics/Overview/components/newsletter-overview.tsx
  • apps/admin/src/posts/analytics/Overview/components/web-overview.tsx
  • apps/admin/src/posts/analytics/Overview/overview.tsx
  • apps/admin/src/posts/analytics/Web/components/kpi-metrics.ts
  • apps/admin/src/posts/analytics/Web/components/kpis.tsx
  • apps/admin/src/posts/analytics/Web/components/locations.tsx
  • apps/admin/src/posts/analytics/Web/components/sources.tsx
  • apps/admin/src/posts/analytics/Web/web.tsx
  • apps/admin/src/posts/analytics/components/date-range-select.tsx
  • apps/admin/src/posts/analytics/components/disabled-sources-indicator.tsx
  • apps/admin/src/posts/analytics/components/empty-stat-view.tsx
  • apps/admin/src/posts/analytics/components/kpi-card.tsx
  • apps/admin/src/posts/analytics/components/layout/post-analytics-layout.tsx
  • apps/admin/src/posts/analytics/components/post-analytics-content.tsx
  • apps/admin/src/posts/analytics/components/post-analytics-header.tsx
  • apps/admin/src/posts/analytics/components/post-analytics-view.tsx
  • apps/admin/src/posts/analytics/components/sidebar.tsx
  • apps/admin/src/posts/analytics/components/source-icon.tsx
  • apps/admin/src/posts/analytics/components/stats-filter.tsx
  • apps/admin/src/posts/analytics/hooks/use-can-manage-gift-link.ts
  • 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/use-filter-params.ts
  • apps/admin/src/posts/analytics/hooks/use-gift-link-usage.test.tsx
  • apps/admin/src/posts/analytics/hooks/use-gift-link-usage.ts
  • apps/admin/src/posts/analytics/hooks/use-post-details.ts
  • apps/admin/src/posts/analytics/hooks/use-post-feedback.test.tsx
  • apps/admin/src/posts/analytics/hooks/use-post-feedback.ts
  • apps/admin/src/posts/analytics/hooks/use-post-newsletter-stats.test.tsx
  • apps/admin/src/posts/analytics/hooks/use-post-newsletter-stats.ts
  • apps/admin/src/posts/analytics/hooks/use-post-referrers.test.tsx
  • apps/admin/src/posts/analytics/hooks/use-post-referrers.ts
  • apps/admin/src/posts/analytics/hooks/use-post-success-modal.test.tsx
  • apps/admin/src/posts/analytics/hooks/use-post-success-modal.ts
  • apps/admin/src/posts/analytics/hooks/use-responsive-chart-size.test.tsx
  • apps/admin/src/posts/analytics/hooks/use-responsive-chart-size.ts
  • 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/gift-link-modal.test.tsx
  • apps/admin/src/posts/analytics/modals/gift-link-modal.tsx
  • apps/admin/src/posts/analytics/modals/share-modal.tsx
  • apps/admin/src/posts/analytics/post-analytics.tsx
  • apps/admin/src/posts/analytics/providers/post-analytics-context.ts
  • apps/admin/src/posts/analytics/providers/post-analytics-provider.tsx
  • apps/admin/src/posts/analytics/utils/audience.ts
  • apps/admin/src/posts/analytics/utils/chart-helpers.test.tsx
  • apps/admin/src/posts/analytics/utils/chart-helpers.ts
  • apps/admin/src/posts/analytics/utils/constants.ts
  • apps/admin/src/posts/analytics/utils/gift-link.test.ts
  • apps/admin/src/posts/analytics/utils/gift-link.ts
  • apps/admin/src/posts/analytics/utils/kpi-helpers.test.tsx
  • apps/admin/src/posts/analytics/utils/kpi-helpers.ts
  • apps/admin/src/posts/analytics/utils/link-helpers.test.tsx
  • apps/admin/src/posts/analytics/utils/link-helpers.ts
  • apps/admin/src/routes.tsx
  • apps/admin/test-utils/posts-analytics/MSW_USAGE_GUIDE.md
  • apps/admin/test-utils/posts-analytics/msw-helpers.ts
  • apps/admin/test-utils/posts-analytics/test-helpers.ts
  • apps/admin/tsconfig.app.json
  • apps/posts/.gitignore
  • apps/posts/eslint.config.js
  • apps/posts/index.html
  • apps/posts/package.json
  • apps/posts/playwright.config.mjs
  • apps/posts/src/api.ts
  • apps/posts/src/app.tsx
  • apps/posts/src/components/errors/posts-error-boundary.tsx
  • apps/posts/src/components/errors/posts-error-page.tsx
  • apps/posts/src/components/layout/main-layout.tsx
  • apps/posts/src/index.tsx
  • apps/posts/src/nql-lang.d.ts
  • apps/posts/src/providers/posts-app-context.tsx
  • apps/posts/src/routes.tsx
  • apps/posts/src/standalone.tsx
  • apps/posts/src/styles/index.css
  • apps/posts/src/views/PostAnalytics/components/layout/post-analytics-layout.tsx
  • apps/posts/src/views/PostAnalytics/members-url.ts
  • apps/posts/test/acceptance/posts.test.ts
  • apps/posts/test/setup.ts
  • apps/posts/tsconfig.declaration.json
  • apps/posts/tsconfig.json
  • apps/posts/vite.config.mjs
  • apps/posts/vitest.config.ts
  • ghost/admin/lib/asset-delivery/index.js
  • ghost/admin/package.json
  • ghost/admin/tests/helpers/mock-analytics-apps.js
💤 Files with no reviewable changes (25)
  • apps/posts/src/views/PostAnalytics/components/layout/post-analytics-layout.tsx
  • apps/posts/.gitignore
  • apps/posts/index.html
  • apps/posts/src/styles/index.css
  • apps/posts/test/acceptance/posts.test.ts
  • apps/posts/vite.config.mjs
  • apps/posts/tsconfig.json
  • apps/posts/src/nql-lang.d.ts
  • apps/posts/test/setup.ts
  • apps/posts/src/app.tsx
  • apps/posts/src/index.tsx
  • apps/posts/playwright.config.mjs
  • apps/posts/package.json
  • apps/posts/src/providers/posts-app-context.tsx
  • apps/posts/src/components/layout/main-layout.tsx
  • apps/posts/tsconfig.declaration.json
  • apps/posts/eslint.config.js
  • apps/posts/src/components/errors/posts-error-page.tsx
  • apps/posts/src/components/errors/posts-error-boundary.tsx
  • apps/posts/src/routes.tsx
  • apps/posts/src/views/PostAnalytics/members-url.ts
  • apps/posts/src/standalone.tsx
  • apps/posts/vitest.config.ts
  • apps/admin/src/index.css
  • apps/posts/src/api.ts

Walkthrough

This change removes the standalone apps/posts application entirely (package, configs, routes, providers, tests, styles) and relocates its post-analytics functionality into apps/admin under new @/posts/analytics/... path aliases. A new PostAnalyticsContext/Provider and PostAnalyticsLayout are introduced, admin routing is rewired to lazy-load these directly, and KPI metric metadata is centralized. Build wiring (package.json, tsconfig, Nx dependsOn, asset-delivery) drops posts references, and numerous component, hook, and test files update import paths, apply type-only imports, and remove now-redundant type casts.

Possibly related PRs

  • TryGhost/Ghost#28895: Related through the index.css Tailwind content glob change now pointing to shade/src, aligning with Shade styling changes there.
  • TryGhost/Ghost#28897: Related through the gift-link-modal-host.tsx lazy import path change touching the same GiftLinkModal wiring.
  • TryGhost/Ghost#29174: Related through changes at the same GiftLinkModalHost integration point in admin.

Suggested reviewers: kevinansfield, jonatansberg

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: post analytics moved into apps/admin and the posts package was removed.
Description check ✅ Passed The description is clearly related to the changeset and matches the migration, context removal, routing updates, and package teardown.
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/pla-222-move-post-analytics

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.

@9larsons
9larsons enabled auto-merge (squash) July 9, 2026 19:26
@codecov

codecov Bot commented Jul 9, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 74.04%. Comparing base (b966169) to head (e673df5).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #29217      +/-   ##
==========================================
- Coverage   74.07%   74.04%   -0.04%     
==========================================
  Files        1570     1570              
  Lines      136624   136624              
  Branches    16531    16516      -15     
==========================================
- Hits       101203   101160      -43     
- Misses      34385    34460      +75     
+ Partials     1036     1004      -32     
Flag Coverage Δ
admin-tests 55.20% <ø> (+0.01%) ⬆️
e2e-tests 76.14% <ø> (-0.04%) ⬇️

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.

@9larsons
9larsons merged commit d7fe4e9 into main Jul 9, 2026
52 checks passed
@9larsons
9larsons deleted the slars/pla-222-move-post-analytics branch July 9, 2026 19:29
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