Repository navigation
fix(onboarding): align prompts to selected plan's engine set on Stripe success - #111
Merged
Merged
Conversation
…e success Onboarding saves prompts at step 4 with the current (pre-checkout, default Starter) plan's allowedScrapers — `['chatgpt-web', 'perplexity-web']`. The plan/trial is only chosen at step 6, so a user who starts a Growth trial still ends up tracking 2 engines instead of the 8 Growth allows. Fix: in /api/stripe/success, right after the org's plan is confirmed and before the first tracking run is triggered, walk every prompt in the org's brands and rewrite its platforms + models arrays to match the just-confirmed plan's allowedScrapers + allowedModels. Mirrors the same gating logic the onboarding wizard uses, extracted into a reusable helper at web/src/lib/plan-engines.ts so the upgrade path (separate issue) can lean on it too. Starter onboarding is unaffected — the new platforms set equals the old one for that plan, so the UPDATE is a no-op. The realignment runs only on the initial checkout-success redirect, not on existing-org plan changes (those flow through subscription update and stay out of scope for #78). Closes #78.
This branch was successfully deployed
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Bug
Onboarding step order is:
`1. brand_setup → 2. brand_details → 3. topics → 4. prompts → 5. competitors → 6. plan`
Prompts are saved at step 4 but the plan is only chosen at step 6, so at step 4 the org is still on its `'free'` default (which falls back to Starter limits) and prompts get `platforms: ['chatgpt-web', 'perplexity-web']` baked in. A user who picks a Growth trial at step 6 still ends up tracking only 2 engines instead of the 8 Growth allows.
Fix
In `/api/stripe/success`, right after the org's `plan` / `subscription_status` is confirmed and before the first tracking run is triggered, walk every prompt in the org's brands and rewrite its `platforms` + `models` arrays to match the just-confirmed plan's `allowedScrapers` + `allowedModels`. Same gating logic the onboarding wizard uses, extracted into a small reusable helper.
Files
Why a helper, not inline
The same gating shape will be needed for the plan-upgrade engine-expansion gap (separate issue referenced in #78's footer — existing Starter org upgrades to Growth, prompts stay on 2 engines). Centralizing the logic now means that issue is just "call the helper from the subscription-update path" rather than re-deriving the gating in a second place.
Scope guardrails
How verified
Local e2e against cloud Stripe test mode:
```
[stripe/success] DB updated for org: ...
[stripe/success] Aligned prompts to plan=growth engines (8 scrapers, N models) for org ...
```
Acceptance (from #78)
Closes #78.