Skip to content

Added staff email notification for gift subscription purchases#27197

Merged
mike182uk merged 1 commit intomainfrom
BER-3484-send-staff-notification
Apr 7, 2026
Merged

Added staff email notification for gift subscription purchases#27197
mike182uk merged 1 commit intomainfrom
BER-3484-send-staff-notification

Conversation

@mike182uk
Copy link
Copy Markdown
Member

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

After a gift is purchased, the GiftService sends a staff notification email to all admin / owner users with the purchaser info and amount

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 7, 2026

Walkthrough

GiftServiceWrapper now requires the staff service and injects a staffServiceEmails accessor into GiftService. GiftService constructor accepts staffServiceEmails and, after creating a gift in recordPurchase, calls staffServiceEmails.notifyGiftReceived(...) (mapped from member or buyer data) inside a try/catch that logs failures. StaffServiceEmails gained notifyGiftReceived(...) and a sendToStaff(...) helper to render and send gift email templates. New email templates (HTML and plain-text) were added for gift notifications. Unit tests were updated to assert notifyGiftReceived is invoked with expected payloads and to validate rendered email content.

🚥 Pre-merge checks | ✅ 2 | ❌ 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 (2 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: adding staff email notifications for gift subscription purchases, which aligns with all code changes in the PR.
Description check ✅ Passed The description is related to the changeset, mentioning that GiftService sends staff notifications with purchaser info and amount after a gift is purchased.

✏️ 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-3484-send-staff-notification

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

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

After a gift is purchased, the `GiftService` sends a staff notification
email to all admin / owner users with the purchaser info and amount
@mike182uk mike182uk force-pushed the BER-3484-send-staff-notification branch from 0f183ff to f9936d1 Compare April 7, 2026 10:31
@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud bot commented Apr 7, 2026

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.

🧹 Nitpick comments (1)
ghost/core/core/server/services/gifts/gift-service.ts (1)

76-78: Add contextual metadata to notification failure logs.

logging.error(err) alone makes incident triage harder. Please include safe identifiers (for example, checkout session ID and member ID) so failures can be correlated quickly.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@ghost/core/core/server/services/gifts/gift-service.ts` around lines 76 - 78,
Replace the lone logging.error(err) in the catch block in gift-service.ts with a
structured log that includes safe contextual identifiers (e.g., checkout session
id and member id) alongside the error; locate the catch where logging.error(err)
is called and add the checkoutSessionId and memberId (or equivalent local
variables available in that scope) to the log entry and a short message like
"failed to send gift notification", ensuring you do not log PII and keep the
error object included for full stack/context.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@ghost/core/core/server/services/gifts/gift-service.ts`:
- Around line 76-78: Replace the lone logging.error(err) in the catch block in
gift-service.ts with a structured log that includes safe contextual identifiers
(e.g., checkout session id and member id) alongside the error; locate the catch
where logging.error(err) is called and add the checkoutSessionId and memberId
(or equivalent local variables available in that scope) to the log entry and a
short message like "failed to send gift notification", ensuring you do not log
PII and keep the error object included for full stack/context.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 55920b73-01a6-4b16-9ffd-e38c7c2399b4

📥 Commits

Reviewing files that changed from the base of the PR and between 0f183ff and f9936d1.

📒 Files selected for processing (7)
  • ghost/core/core/server/services/gifts/gift-service-wrapper.js
  • ghost/core/core/server/services/gifts/gift-service.ts
  • ghost/core/core/server/services/staff/email-templates/gift.hbs
  • ghost/core/core/server/services/staff/email-templates/gift.txt.js
  • ghost/core/core/server/services/staff/staff-service-emails.js
  • ghost/core/test/unit/server/services/gifts/gift-service.test.ts
  • ghost/core/test/unit/server/services/staff/staff-service.test.js
✅ Files skipped from review due to trivial changes (2)
  • ghost/core/core/server/services/staff/email-templates/gift.hbs
  • ghost/core/test/unit/server/services/staff/staff-service.test.js
🚧 Files skipped from review as they are similar to previous changes (4)
  • ghost/core/core/server/services/gifts/gift-service-wrapper.js
  • ghost/core/core/server/services/staff/email-templates/gift.txt.js
  • ghost/core/test/unit/server/services/gifts/gift-service.test.ts
  • ghost/core/core/server/services/staff/staff-service-emails.js

@mike182uk mike182uk merged commit a17ca41 into main Apr 7, 2026
39 checks passed
@mike182uk mike182uk deleted the BER-3484-send-staff-notification branch April 7, 2026 13:51
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