Skip to content

🎨 Made pages clickable in analytics Top content#28707

Draft
peterzimon wants to merge 5 commits into
mainfrom
NY-1366/add-link-to-analytics-pages
Draft

🎨 Made pages clickable in analytics Top content#28707
peterzimon wants to merge 5 commits into
mainfrom
NY-1366/add-link-to-analytics-pages

Conversation

@peterzimon

Copy link
Copy Markdown
Contributor

Summary

ref https://linear.app/tryghost/issue/NY-1366

Previously only post rows in the Web and Growth tab Top content lists were clickable — clicking a post navigates to its per-post analytics view. Page rows and the homepage row had no link, so there was no quick way to jump from analytics to the live page.

This PR makes those rows clickable. Posts still go to the internal analytics view; pages and the homepage open the live frontend URL in a new tab.

How it works

Server (ghost/core/core/server/services/stats/)

  • content-stats-service.js (Web tab) and posts-stats-service.js (Growth tab) now resolve an absolute frontend URL for posts and pages via urlService.getUrlByResourceId(id, {absolute: true}). Result is exposed as a new url field on each row.
  • For the homepage attribution row (Growth tab attribution_type='url', path /) and the Web tab homepage row that doesn't match a posts resource, the URL is built from urlUtils.urlFor('home', true).
  • getResourceTitle() also retries the opposite trailing-slash form to catch pathnames recorded by Tinybird without a canonical slash.

Client (apps/stats/)

  • getClickHandler in url-helpers.ts gained an optional absoluteUrl arg and prefers it over reconstructing from pathname when present.
  • Web tab top-content.tsx and Growth tab growth.tsx: clickable gate relaxed — any row with a server-resolved url becomes a link button.

Notes / open questions

  • Marked draft because I'd like a second pair of eyes before merging — the URL-resolution paths in the stats services are non-trivial and the test coverage on posts-stats-service.js doesn't run locally (pre-existing beforeAll is not defined issue on main).
  • The retry-with-slash logic is a pragmatic fix for Tinybird pathnames that lack canonical slashes. Open to feedback on whether to push that normalization further upstream (e.g. into the Tinybird ingestion pipe).

Test plan

  • On the Web traffic tab, switch Top content between Posts & pages / Posts / Pages — confirm post titles still navigate to per-post analytics, and page titles + the Homepage row open the live page in a new tab.
  • On the Growth tab, same thing for the Top content table — Homepage and page rows should render as link buttons.
  • Confirm rows for tags/authors/system URLs that don't map to a posts row remain non-clickable.
  • pnpm --filter ghost test:single test/unit/server/services/stats/content.test.js should pass (25/25).

ref https://linear.app/tryghost/issue/NY-1366

- previously only post rows in the Web and Growth tab Top content lists
  were clickable (they linked to the per-post analytics view); page rows
  and the homepage row had no link, so there was no quick way to jump
  from analytics to the live page
- the stats services now resolve an absolute frontend URL for posts and
  pages via the URL service (and fall back to the site URL for the
  homepage attribution row), exposing it as a new `url` field
- the Web and Growth tab tables make those rows clickable: posts still
  navigate to the internal analytics view, while pages and the homepage
  open the live frontend URL in a new tab
@coderabbitai

coderabbitai Bot commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 4bf0b075-6c58-4cef-aefa-e3201600875c

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch NY-1366/add-link-to-analytics-pages

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 and usage tips.

@nx-cloud

nx-cloud Bot commented Jun 18, 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 30c5af4

Command Status Duration Result
nx build @tryghost/comments-ui ✅ Succeeded <1s View ↗
nx build @tryghost/announcement-bar ✅ Succeeded <1s View ↗
nx build @tryghost/activitypub ✅ Succeeded 1s View ↗
nx build @tryghost/signup-form ✅ Succeeded <1s View ↗
nx build @tryghost/admin-toolbar ✅ Succeeded <1s View ↗
nx build @tryghost/portal ✅ Succeeded <1s View ↗
nx build @tryghost/sodo-search ✅ Succeeded <1s View ↗
nx run @tryghost/admin-x-settings:test:acceptance ✅ Succeeded 9m 58s View ↗
Additional runs (13) ✅ Succeeded ... View ↗

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


☁️ Nx Cloud last updated this comment at 2026-06-22 12:59:01 UTC

@peterzimon peterzimon changed the title 🎨 Made page and homepage rows clickable in analytics Top content 🎨 Made pages clickable in analytics Top content Jun 22, 2026
ref https://linear.app/tryghost/issue/NY-1366

- the prior commit always set `url` on the row (potentially `undefined`),
  which broke `assert.deepEqual` against fixtures that don't list `url`
- only spread `url` into the response when it actually resolved, so the
  response shape stays minimal and existing fixtures keep working
@codecov

codecov Bot commented Jun 22, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 29.46429% with 79 lines in your changes missing coverage. Please review.
✅ Project coverage is 73.73%. Comparing base (624d136) to head (30c5af4).
⚠️ Report is 9 commits behind head on main.

Files with missing lines Patch % Lines
...ore/server/services/stats/content-stats-service.js 23.17% 63 Missing ⚠️
.../core/server/services/stats/posts-stats-service.js 46.66% 16 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #28707      +/-   ##
==========================================
- Coverage   73.76%   73.73%   -0.04%     
==========================================
  Files        1552     1552              
  Lines      134208   134309     +101     
  Branches    16108    16117       +9     
==========================================
+ Hits        99004    99036      +32     
- Misses      34225    34294      +69     
  Partials      979      979              
Flag Coverage Δ
admin-tests 55.16% <ø> (ø)
e2e-tests 75.83% <29.46%> (-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.

@github-actions

Copy link
Copy Markdown
Contributor

E2E Tests Failed

To view the Playwright test report locally, run:

REPORT_DIR=$(mktemp -d) && gh run download 27940032840 -n playwright-report -D "$REPORT_DIR" && npx playwright show-report "$REPORT_DIR"

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