Added staff email notification for gift subscription purchases#27197
Added staff email notification for gift subscription purchases#27197
Conversation
WalkthroughGiftServiceWrapper 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)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
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
0f183ff to
f9936d1
Compare
|
There was a problem hiding this comment.
🧹 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
📒 Files selected for processing (7)
ghost/core/core/server/services/gifts/gift-service-wrapper.jsghost/core/core/server/services/gifts/gift-service.tsghost/core/core/server/services/staff/email-templates/gift.hbsghost/core/core/server/services/staff/email-templates/gift.txt.jsghost/core/core/server/services/staff/staff-service-emails.jsghost/core/test/unit/server/services/gifts/gift-service.test.tsghost/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



ref https://linear.app/ghost/issue/BER-3484
After a gift is purchased, the
GiftServicesends a staff notification email to all admin / owner users with the purchaser info and amount