Skip to content

fix(auth): free trial duplicate reminder emails#20402

Merged
StaberindeZA merged 1 commit intomainfrom
pay-3652-dup-free-email
Apr 20, 2026
Merged

fix(auth): free trial duplicate reminder emails#20402
StaberindeZA merged 1 commit intomainfrom
pay-3652-dup-free-email

Conversation

@StaberindeZA
Copy link
Copy Markdown
Contributor

Because

  • Free trial reminder emails are sending duplicate emails.

This pull request

  • Update call of alreadySentEmail, by free trial logic, to pass in required current_period_start instead of current_period_end.

Issue that this pull request solves

Closes: #PAY-3652

Checklist

Put an x in the boxes that apply

  • My commit is GPG signed.
  • If applicable, I have modified or added tests which pass locally.
  • I have added necessary documentation (if appropriate).
  • I have verified that my changes render correctly in RTL (if appropriate).
  • I have manually reviewed all AI generated code.

How to review (Optional)

  • Subscribe to a free trial
  • Run the reminder script with the following parameters. Note the reminder length might need to change depending on trial reminder.
CONFIG_FILES='config/secrets.json' NODE_ENV=dev FIRESTORE_EMULATOR_HOST=localhost:9090 yarn workspace fxa-auth-server subscription-reminders -t true --free-trial-ending-reminder-length=13

Screenshots (Optional)

Please attach the screenshots of the changes made in case of change in user interface.

Other information (Optional)

Any other information that is important to this pull request.

Because:

- Free trial reminder emails are sending duplicate emails.

This commit:

- Update call of alreadySentEmail, by free trial logic, to pass in
  required current_period_start instead of current_period_end.

Closes #PAY-3652
@StaberindeZA StaberindeZA requested a review from a team as a code owner April 17, 2026 21:19
Copilot AI review requested due to automatic review settings April 17, 2026 21:19
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Fixes duplicate free-trial reminder emails by aligning the “already sent” de-duplication check with the subscription’s current billing/trial cycle start time.

Changes:

  • Pass subscription.current_period_start (ms) into alreadySentEmail for freeTrialEndingReminder instead of current_period_end.
  • Minor formatting change for freeTrialEndingReminderEnabled assignment.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 315 to 320
await this.alreadySentEmail(
uid,
Math.floor(subscription.current_period_end * 1000),
Math.floor(subscription.current_period_start * 1000),
emailParams,
'freeTrialEndingReminder'
)
Copy link

Copilot AI Apr 17, 2026

Choose a reason for hiding this comment

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

This change fixes the de-dupe key for free-trial reminders, but there’s no regression test covering sendFreeTrialEndingReminderEmail/sendFreeTrialEndingReminders to ensure it de-dupes within the same current_period_start and doesn’t send duplicates on repeated runs. Please add a unit test (in subscription-reminders.spec.ts) that sets up a trialing subscription, stubs SentEmail.findLatestSentEmailByType with sentAt after the period start, and asserts the method returns false (and/or that alreadySentEmail is invoked with current_period_start).

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Contributor

@xlisachan xlisachan left a comment

Choose a reason for hiding this comment

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

Thanks Reino!

@StaberindeZA StaberindeZA merged commit 8d386b8 into main Apr 20, 2026
24 checks passed
@StaberindeZA StaberindeZA deleted the pay-3652-dup-free-email branch April 20, 2026 13:43
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.

3 participants