Hid growth tab on posts when member sources disabled#25817
Conversation
|
Cursor Agent can help with this pull request. Just |
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
WalkthroughGates the Growth analytics UI behind 🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 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 |
d9a396b to
006913f
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.
This PR is being reviewed by Cursor Bugbot
Details
Your team is on the Bugbot Free tier. On this plan, Bugbot will review limited PRs each billing cycle for each member of your team.
To receive Bugbot reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.
| if (!isPostLoading && post && isPublishedOnly(post as Post) && !appSettings?.analytics.webAnalytics) { | ||
| navigate(`/posts/analytics/${postId}/growth`); | ||
| if (!isPostLoading && post && isPublishedOnly(post as Post) && !appSettings?.analytics.webAnalytics && showGrowthSection) { | ||
| navigate(`/posts/analytics/${postId}/growth`, {replace: true}); |
There was a problem hiding this comment.
It was possible to get into a scenario where the back button "stops working", because it tries to bring you to /<postId>, which then redirects you right back to /<postId>/growth.
So with replace: true, now when you click the back button while on /<postId>/growth it'll bring you to wherever you were before, like /analytics
7cb3943 to
91182d1
Compare
91182d1 to
0f11622
Compare
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
apps/stats/src/views/Stats/Overview/components/latest-post.tsx (1)
107-111:⚠️ Potential issue | 🟡 MinorPost title click still hardcodes the analytics route, bypassing the new destination logic.
The button at Line 146 correctly uses
postDestination, but clicking the post title on Line 109 always navigates to/posts/analytics/${latestPostStats.id}— even when analytics are disabled andshouldGoToEditoris true. This creates an inconsistent experience where the title and button navigate to different destinations.Proposed fix
<div className='text-lg font-semibold leading-tighter tracking-tight hover:cursor-pointer hover:opacity-75' onClick={() => { if (!isLoading && latestPostStats) { - navigate(`/posts/analytics/${latestPostStats.id}`, {crossApp: true}); + navigate(postDestination, {crossApp: true}); } }}>
🧹 Nitpick comments (1)
apps/stats/test/unit/utils/url-helpers.test.ts (1)
328-370: Good coverage of the key scenarios.One minor gap: there's no test for
analyticsSettings === undefinedwithhasEmailData = true. This would confirm that email data alone is sufficient to route to analytics even when settings are missing. Consider adding it for completeness.Suggested additional test case
it('returns editor route when analytics settings are unavailable and the post has no email data', () => { const destination = getPostDestination('post-1', false, undefined); expect(destination).toBe('/editor/post/post-1'); }); + + it('returns post analytics route when analytics settings are unavailable but the post has email data', () => { + const destination = getPostDestination('post-1', true, undefined); + + expect(destination).toBe('/posts/analytics/post-1'); + }); });
0f11622 to
5a70fc7
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@e2e/tests/admin/analytics/post-analytics/overview.test.ts`:
- Around line 49-82: The test disables members tracking with
settingsService.setMembersTrackSources(false) but only re-enables it later, so
if an assertion fails the setting remains disabled and breaks other tests; wrap
the disable/enable sequence in a try/finally (or move the test into its own
test.describe with setup/teardown) so that
settingsService.setMembersTrackSources(true) is always called (and page.reload()
applied) in the finally block or afterEach hook to guarantee restoration even on
failure.
78df8ba to
2f2042c
Compare
apps/stats/src/utils/url-helpers.ts
Outdated
| membersTrackSources?: boolean; | ||
| } | ||
|
|
||
| export const getPostDestination = (postId: string, hasEmailData: boolean, analyticsSettings?: AnalyticsSettings) => { |
There was a problem hiding this comment.
fwiw i usually use an object as the param when it's 3+ (or even 2+) but the shape of the data that gets passed in where this gets used makes it really cumbersome to read when i do that, so i went with this
There was a problem hiding this comment.
just kidding, decided to update it 😝
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@e2e/tests/admin/analytics/post-analytics/overview.test.ts`:
- Around line 49-84: Rename the test title to follow lowercase "what is tested -
expected outcome" (e.g., "growth tab - hidden when member sources tracking
disabled") and restructure the body into clear Arrange/Act/Assert blocks:
Arrange by instantiating SettingsService(page.request) and
PostAnalyticsPage(page) and asserting the initial visible state using
postAnalyticsPage.growthButton and postAnalyticsPage.growthSection.card; Act by
calling settingsService.setMembersTrackSources(false) and await page.reload();
Assert by checking postAnalyticsPage.growthButton and
postAnalyticsPage.growthSection.card are hidden and
postAnalyticsPage.overviewButton and postAnalyticsPage.webTrafficButton remain
visible; keep the cleanup in a finally block that calls
settingsService.setMembersTrackSources(true) and page.reload(); remove inline
commentary and rely on the clear AAA structure and descriptive test name to
convey intent.
Co-authored-by: peter <peter@ghost.org>
Co-authored-by: peter <peter@ghost.org>
This reverts commit d9a396b.
c8cbd13 to
758574e
Compare
|
I think the links in top posts aren't working as expected - might be misunderstanding something though. In this scenario:
I think the link in Top Posts should go to the editor (and it looks like that's what Screenshare.-.2026-02-12.5_20_34.PM.mp4 |
Ignore me, I didn't |
Closes https://linear.app/ghost/issue/NY-382
members_track_sourcessetting is enabled. An e2e test has been added to verify this behavior.getPostDestinationhelper so we can link posts to the correct location based on analytics settings. For example, if there is no analytics data to display because everything is turned off and the post wasn't emailed, clicking the post should go straight to the editor.Note
Growthtab in header andGrowthsection onOverviewnow only appear whenappSettings.analytics.membersTrackSourcesis true.growthfor published-only posts occurs only if Growth is available; usesreplace: true.DisabledSourcesIndicatorwhen Web, Newsletter, and Growth are all unavailable.SettingsService.setMembersTrackSourcesand an e2e test verifying Growth visibility toggles when the setting is disabled/enabled.Written by Cursor Bugbot for commit 91182d1. This will update automatically on new commits. Configure here.