Skip to content

Excluded gift subscriptions from paid subscription charts#27759

Merged
mike182uk merged 1 commit intomainfrom
BER-3615-analytics-remove-gift-subs-from-charts
May 7, 2026
Merged

Excluded gift subscriptions from paid subscription charts#27759
mike182uk merged 1 commit intomainfrom
BER-3615-analytics-remove-gift-subs-from-charts

Conversation

@mike182uk
Copy link
Copy Markdown
Member

ref https://linear.app/ghost/issue/BER-3615
ref #27624
ref #27703

  • the "Paid subscriptions" bar chart and "Paid subscription breakdown" pie chart were counting gift redemptions as signups and gift end-of-life events as cancellations, which mixed gift activity into charts that are meant to track paid Stripe activity only
  • gifts now flow through their own member status (gift) and surface in the Paid members KPI tooltip instead, so duplicating them in the per- cadence/per-tier breakdowns double-counted activity and made the bar and pie charts disagree
  • reverted the gift-aware additions to subscription-stats-service so /stats/subscriptions returns paid Stripe deltas and counts only; giftpaid upgrades still appear via the regular paid subscription event flow once the trial converts and MRR begins

ref https://linear.app/ghost/issue/BER-3615/

- the "Paid subscriptions" bar chart and "Paid subscription breakdown" pie
chart were counting gift redemptions as signups and gift end-of-life
events as cancellations, which mixed gift activity into charts that are
meant to track paid Stripe activity only
- gifts now flow through their own member status (`gift`) and surface in
the Paid members KPI tooltip instead, so duplicating them in the per-
cadence/per-tier breakdowns double-counted activity and made the bar and
pie charts disagree
- reverted the gift-aware additions to subscription-stats-service so
`/stats/subscriptions` returns paid Stripe deltas and counts only;
`gift`→`paid` upgrades still appear via the regular paid subscription event
flow once the trial converts and MRR begins
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 7, 2026

Review Change Stack

Walkthrough

This PR removes gift-handling functionality from the subscription statistics service. The SubscriptionStatsService.getSubscriptionHistory() method now derives subscription delta entries solely from fetchAllSubscriptionDeltas(), eliminating separate paid and gift delta fetching and aggregation paths. The fetchSubscriptionCounts() method is simplified to query only paid subscriptions from members_stripe_customers_subscriptions without gift augmentation. The aggregateCounts() helper is no longer used. Corresponding test changes remove the gifts table from the test schema and delete a unit test case that verified gift signups folding into cadence buckets.

Possibly related PRs

  • TryGhost/Ghost#27703: Modifies gift-handling logic in subscription-stats-service and related unit tests for counting redeemed or consumed gifts.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: excluding gift subscriptions from paid subscription charts, which aligns with the primary objective of removing gift activity from charts meant for paid Stripe activity only.
Description check ✅ Passed The description is directly related to the changeset, providing context about why gift subscriptions are being excluded, referencing related issues and PRs, and explaining the impact on charts and member status flows.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ 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 BER-3615-analytics-remove-gift-subs-from-charts

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 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.

Inline comments:
In `@ghost/core/core/server/services/stats/subscription-stats-service.js`:
- Around line 15-16: The reverse-walk seeded from paid-only totals (seeded by
fetchSubscriptionCounts() and iterating subscription deltas from
fetchAllSubscriptionDeltas()) fails to decrement paid counts for same-plan
gift/trial → paid "updated" events with mrr_delta > 0, so the pre-conversion
period still shows the user as paid; update the delta handling to detect
same-plan conversion events (in the code that iterates/normalizes deltas
returned by fetchAllSubscriptionDeltas() / where you apply those deltas
backwards) and treat an "updated" event with mrr_delta > 0 that represents a
conversion from gift/trial to paid as a -1 paid subscriber when walking back
before the conversion timestamp (i.e., subtract one from paid count during
rewind), add logic to distinguish true MRR adjustments from conversion-promoting
updates, and add a regression test that simulates a same-plan gift/trial → paid
conversion to assert pre-conversion paid totals decrement correctly.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 7a3f33fb-65ba-42be-9cdc-71f010fada6a

📥 Commits

Reviewing files that changed from the base of the PR and between 29f8ab3 and 14abcd1.

📒 Files selected for processing (3)
  • apps/stats/test/unit/components/growth/new-subscribers-cadence.test.tsx
  • ghost/core/core/server/services/stats/subscription-stats-service.js
  • ghost/core/test/unit/server/services/stats/subscriptions.test.js
💤 Files with no reviewable changes (2)
  • apps/stats/test/unit/components/growth/new-subscribers-cadence.test.tsx
  • ghost/core/test/unit/server/services/stats/subscriptions.test.js

Comment thread ghost/core/core/server/services/stats/subscription-stats-service.js
@mike182uk mike182uk merged commit 59b314d into main May 7, 2026
44 checks passed
@mike182uk mike182uk deleted the BER-3615-analytics-remove-gift-subs-from-charts branch May 7, 2026 12:32
mike182uk added a commit that referenced this pull request May 7, 2026
ref https://linear.app/ghost/issue/BER-3614/
ref #27759

- the "Paid subscription breakdown" pie chart was rendering a
Complimentary slice derived from the comped delta, which mixed
member-status semantics into a chart meant to track paid Stripe
subscription activity only
- this also caused the pie chart's total to disagree with the "Paid
subscriptions" bar chart (which has always been paid-only); with this
change the two charts tie out as the issue requires
- comp activity is still surfaced in the Paid members KPI tooltip, so no
signal is lost for sites that grant complimentary access
- removed the now-pointless `calculateStatusSignups` helper that was
generalised to support `gift`+`comped` during the gift work but only
ever took `'comped'` after gifts moved to the backend
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.

2 participants