-
Notifications
You must be signed in to change notification settings - Fork 112
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Proactively cancel inactive trials 3 days before end #4553
Conversation
front/lib/workspace_usage.ts
Outdated
const sevenDaysAgo = new Date(); | ||
sevenDaysAgo.setDate(sevenDaysAgo.getDate() - 7); | ||
|
||
const hasConnectedDataSource = await DataSource.findOne({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We want to consider as active if there's a Connection or if there's a Connection or a Folder?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Connection and folder do create a data source 🙃.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seen IRL, fixed.
/** | ||
* Proactively cancel inactive trials. | ||
*/ | ||
export async function maybeCancelInactiveTrials( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NIT suggestion: Since this will I believe not be reusable anywhere else I would kill and do that directly on the webhook. ff we want to keep here I would just rename to be clearer -> cancelSubscriptionIfInactiveTrial
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I plan to use it in a script to cancel the trials that won't be captured by this change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would be nice to add visibility on that event by sending a message on our #user_workspace-event-logs
.
Example here: github
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
* Proactively cancel inactive trials 3 days before end * ✂️ * ✨ * Send email when canceling trial proactively * ✂️ * Log in Slack
Description
Fixes https://github.com/dust-tt/tasks/issues/608.
This PR introduces a listener for Stripe's
customer.subscription.trial_will_end
event, which is triggered 3 days before a trial ends. On this event, we assess whether the trial has been active, based on the following criteria:If none of the above criteria are met, we will proactively cancel the subscription.
We will also send an email when proactively canceling a trial, this will be done in a follow up PR.
Risk
Deploy Plan