Skip to content

Added member activity entry when gift subscription ends#27649

Merged
sagzy merged 2 commits intomainfrom
gift-subscriptions/member-activity-when-gift-ends
May 6, 2026
Merged

Added member activity entry when gift subscription ends#27649
sagzy merged 2 commits intomainfrom
gift-subscriptions/member-activity-when-gift-ends

Conversation

@sagzy
Copy link
Copy Markdown
Contributor

@sagzy sagzy commented May 1, 2026

closes https://linear.app/ghost/issue/BER-3596

Summary

  • When a gift subscription's validity period ends and the member drops
    back to free, the admin member-activity feed now renders an "ended paid
    subscription" entry
  • Backend reads from the existing members_status_events rows
    (from_status: gift, to_status: free), so no new write path or schema
    change is needed
  • Copy and icon match the paid-subscription expired event so the
    lifecycle reads consistently to publishers
CleanShot 2026-05-06 at 09 29 01@2x

Test plan

  • Verify unit tests pass: cd ghost/core && pnpm test:single test/unit/server/services/members/members-api/repositories/event-repository.test.js
  • Verify admin helper tests pass for parse-member-event
  • Manual verification: redeem a gift, force-consume it (set consumes_at in the past, run processConsumed()), confirm the member's activity feed shows "ended paid subscription" at the consume time
  • Negative test: redeem a gift, upgrade to paid before consume → activity feed shows "continued paid subscription after gift" but no "ended paid subscription"

- when a gift subscription's validity period runs out and the member drops back to free, the admin member-activity feed now shows an "ended paid subscription" entry alongside the existing "redeemed gift" entry
- backend reads from the existing members_status_events rows (gift→free), so no new write path or schema change is needed; the gift→paid case is intentionally excluded since it is already covered by "continued paid subscription after gift"
- copy and icon match the paid-subscription "expired" event so the lifecycle reads consistently to publishers
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 1, 2026

Walkthrough

Adds support for a new event type, gift_ended_event, across members components. The admin helper now maps this event to the subscriptions icon and the action label "ended paid subscription". EventRepository gains getGiftEndedEvents, which queries member status events for gift→free transitions, paginates results, and maps them to the standardized event shape; the timeline includes the new event type and tie-ordering. Admin utilities synchronize gift_ended_event with subscription-related toggles. Unit tests were added/updated for the helper, repository, and toggle behavior.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
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.
Description check ✅ Passed The PR description clearly relates to the changeset by explaining the new 'gift_ended_event' feature added across multiple files and layers of the application.
Title check ✅ Passed The title 'Added member activity entry when gift subscription ends' directly and clearly describes the main change: introducing an activity entry for ended gift subscriptions in the member feed.

✏️ 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 gift-subscriptions/member-activity-when-gift-ends

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.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 29ec779df0

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@codecov
Copy link
Copy Markdown

codecov Bot commented May 1, 2026

Codecov Report

❌ Patch coverage is 75.51020% with 12 lines in your changes missing coverage. Please review.
✅ Project coverage is 73.20%. Comparing base (0c4d441) to head (14a73eb).
⚠️ Report is 32 commits behind head on main.

Files with missing lines Patch % Lines
...mbers/members-api/repositories/event-repository.js 74.41% 11 Missing ⚠️
ghost/admin/app/helpers/parse-member-event.js 75.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #27649      +/-   ##
==========================================
+ Coverage   73.17%   73.20%   +0.02%     
==========================================
  Files        1561     1561              
  Lines      127051   127116      +65     
  Branches    15383    15397      +14     
==========================================
+ Hits        92970    93050      +80     
+ Misses      33105    33087      -18     
- Partials      976      979       +3     
Flag Coverage Δ
admin-tests 49.91% <83.33%> (+0.03%) ⬆️
e2e-tests 73.20% <75.51%> (+0.02%) ⬆️

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

☔ View full report in Codecov by Sentry.
📢 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.

@sagzy sagzy changed the title Added member activity entry for ended gift subscriptions Added member activity entry when gift subscription ends May 6, 2026
Comment on lines +571 to +572
'data.created_at': 'created_at',
'data.member_id': 'member_id'
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Do we need this re-mapping if we are using the same named keys?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Still needed to strip the data prefix (also what we do in getPaymentEvents, getLoginEvents, getNewsletterSubscriptionEvents, etc.)

}

if (event.type === 'gift_ended_event') {
return 'ended paid subscription';
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This ok being the same as subscription_event.expired? I don't think we can end up with the same event twice right?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Correct, it's either a gift or a paid subscription, so won't be logged twice for the same subscription. The copy / icon for the event are intentionally the same as with a paid subscription:

Image

@sagzy sagzy merged commit fcc6516 into main May 6, 2026
45 checks passed
@sagzy sagzy deleted the gift-subscriptions/member-activity-when-gift-ends branch May 6, 2026 08:30
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