Repository navigation
Send the workspace's first successful call when cancelling - #1319
Merged
Merged
Conversation
"Cancel subscription" opens Stripe's cancellation page through the licence site, which offers a discount to keep the customer. The site now picks the offer by segment, and a card trial that never got a tool call through gets no discount: a cheaper price does not fix a product that never worked for them. On the cancel flow only, the Cloud adds usage.firstSuccessfulCallAt (from OrgSettings first_successful_call_at, or the workspace's earliest SUCCESS invocation; null when there is none). Self-hosted sends nothing, and a failed lookup omits the field so cancelling never waits on it. The offer logic itself stays on the licence site.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
"Cancel subscription" opens Stripe's cancellation page through the licence site, which shows a discount to keep the customer. Until now everyone got the same offer (30% for 3 months), including card trials that never made a single tool call, where a discount does not address why they leave. The licence site now picks the offer by segment (paid / card trial that used the product / card trial that never did / yearly plan). To tell the two card-trial cases apart it needs to know whether the workspace ever made a successful tool call; this PR sends that, and nothing else. The offer logic stays on the licence site.
Changes
LicenseService.createBillingPortalSession: onflow: 'cancel'only, the body to/api/billing/portalcarriesusage: { firstSuccessfulCallAt }— read from OrgSettingsfirst_successful_call_at, or the workspace's earliestSUCCESStool invocation,nullwhen there is none.Type
Testing
Run in
packages/backendafternpm ciandnpx prisma generate:npx jest src/license: 8 suites, 175 tests passed (5 new: recorded first success, fallback to the earliest invocation, never used →null, failed lookup → nousageand the portal still opens, no usage for other flows nor on self-hosted).npx tsc --noEmit -p tsconfig.json: no errors.npm run lint: 0 errors, 11 existing warnings in other files;eslint --fixchanged no file.npm test: 0 failed, 23690 passed. The first full run had 1 failure that did not reproduce in two re-runs.Checklist
npm test)Related Issues
The segmented offer itself is in the licence site (private repository).