Skip to content

Conversation

emma-sg
Copy link
Member

@emma-sg emma-sg commented Aug 12, 2025

Closes #2685
Closes #2798

Changes

  • Adds subscription info (specifically days until trial ends) to invite emails
  • Adds new endpoint for sending a "trial ending soon" email to all admins based on subscription id

Testing

Tested in dev alongside https://github.com/webrecorder/cashew/pull/57! All seems to work.

Tested locally by doing the following:

  1. Rebuild the backend and emails images with scripts/build-backend.sh and scripts/build-emails.sh
  2. Set a value for BTRIX_SUBS_APP_API_KEY in the btrix-subs-app-secret secret by doing the following:
    1. Choose a secret and write it down — I just used uuidgen to generate one
    2. Base64-encode the secret, I used cat '<my secret>' | base64
    3. Run kubectl edit secrets btrix-subs-app-secret and paste your encoded secret in the BTRIX_SUBS_APP_API_KEY field, and save and exit
  3. Redeploy your local Browsertrix with helm upgrade --install -f ./chart/values.yaml -f ./chart/local.yaml btrix ./chart/ && kubectl wait --for=condition=ready pod --all --timeout=300s
  4. Manually modify the subscription field on the org document in MongoDB
    I used the following data in MongoDB Compass connected to my local Browsertrix instance:
    "subscription": {
      "subId": "stripe:sub_abc123",
      "planId": "starter",
      "status": "trialing",
      "futureCancelDate": {
        "$date": "2025-08-14T21:14:29.000Z"
      },
      "readOnlyOnCancel": false
    },
    Pick some date a bit into the future for the futureCancelDate.
  5. Add an admin user or two to an org, and follow the sign-up process
    • Verify that the "Manage Your Billing and Plan" section on the sign-up emails mentions when the trial ends
  6. Set up smtp4dev or something similar to receive emails sent from Browsertrix (see Testing Email Sending from Browsertrix)
  7. Run the following to get Browsertrix to send trial ending soon emails to all the admins of your org:
    curl -X 'POST' \
      'http://browsertrix-cloud-backend.default.svc.cluster.local:8000/api/subscriptions/trial-end-reminder' \
      -H 'Content-Type: application/json' \
      -d '{
      "subId": "stripe:sub_abc123",
      "behavior_on_trial_end": "cancel"
    }' -H 'Authorization: bearer <your secret from step 2.i>'
    Try with behavior_on_trial_end set to both "cancel" and "continue".
    • Verify that the dates & durations are accurate
    • Verify that the links to the org all work
    • Verify that all admins receive emails

Follow-ups

Once this is deployed, we should turn off trial end reminder emails from Stripe.

@emma-sg emma-sg force-pushed the invite-emails-with-trial-info branch from 28b21b2 to d07d0ab Compare August 12, 2025 23:18
@emma-sg emma-sg requested a review from ikreymer August 12, 2025 23:18
@emma-sg emma-sg marked this pull request as ready for review August 12, 2025 23:18
@emma-sg emma-sg requested a review from tw4l August 14, 2025 20:09
Copy link
Member

@tw4l tw4l left a comment

Choose a reason for hiding this comment

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

Tested on dev, working well. Left a few small suggestions.

also swaps the more explicit org subscription check, since we just
fetched an org by its subscription id
]
)

return SubscriptionReminderResponse(sent=True)
Copy link
Member

Choose a reason for hiding this comment

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

Small nitpick: I think should just use SuccessResponse(success=True) rather than adding a new API response type?

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh sure, yeah

- resuse SuccessResponse instead of adding new model
- change endpoint to /send-trial-end-reminder for clarity
@ikreymer ikreymer merged commit 74047bb into main Aug 23, 2025
28 of 30 checks passed
@ikreymer ikreymer deleted the invite-emails-with-trial-info branch August 23, 2025 17:14
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.

[Feature]: Backend support for sending "trial ending soon" emails [Feature]: Differentiate trial emails
3 participants