Repository navigation
fix(volumes): analyse a brand's keywords when its setup finishes, not only after checkout - #765
Merged
Merged
Conversation
… only after checkout Finishing a brand's setup starts tracking, so the scrapers run while the user watches the bar. The other half of the picture — search volume and competition from DataForSEO — was wired to the Stripe success route alone, which meant a paying organisation's first brand got its numbers and every brand added afterwards sat at zero until someone found the Analyze button on the Prompts page. A brand added today ran 296 scrapes and recorded no volumes at all. Give the brand one automatic run at the end of setup, from the two paths that already start tracking: the dashboard's new-brand flow and self-hosted onboarding. The cloud flow still gets its run from the Stripe route, where the plan is confirmed. The run is deliberately outside the quota. Nobody asked for it, so spending one of a Starter plan's four analyses on it would take an allowance that was never offered. What bounds it instead is the brand's own state: a brand that already has volumes has had its free run, and the endpoint declines it, so this cannot be called in a loop. The quota-bearing /analyze-batch stays the only way to ask for more. The claim on the brand is taken before the counts are read rather than after. The read is awaited, and a check that finishes before the claim leaves a gap two calls can both pass through — which for a free run means paying DataForSEO twice for the same brand. Sharing the claim with /analyze-batch also keeps the Analyze button and this run from overlapping, and lets the existing status endpoint report the progress of either. Nothing is said to the user when the request cannot be reached. The brand exists and its tracking has started; a volume run that did not begin is not worth an error in front of someone who has just finished setting up. The daily cron is untouched — it has never run volume analysis and still doesn't.
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.
Summary
Finishing a brand's setup starts tracking, so the scrapers run while the user watches the bar. The other half of the picture — search volume and competition from DataForSEO — was wired to the Stripe success route alone. A paying organisation's first brand got its numbers; every brand added afterwards sat at zero until someone found the Analyze button on the Prompts page.
Current production bears this out. Organisations that completed checkout have volumes on every prompt. A brand added to an existing organisation this morning ran 296 scrapes and recorded no volumes at all, because no payment step ever fired.
Give the brand one automatic run at the end of setup, from the two paths that already start tracking: the dashboard's new-brand flow and self-hosted onboarding. The cloud onboarding flow is untouched — it still gets its run from the Stripe route, where the plan is confirmed.
The run is outside the quota, on purpose
Nobody asked for it, so spending one of a Starter plan's four analyses on it would take an allowance that was never offered. What bounds it instead is the brand's own state: a brand that already has volumes has had its free run, and the endpoint declines it. There is no loop that yields free analyses. The quota-bearing
/analyze-batchstays the only way to ask for more.Two details worth the review
The claim on the brand is taken before the counts are read rather than after. The read is awaited, and a check that finishes before the claim leaves a gap two calls can both pass through — which for a free run means paying DataForSEO twice for the same brand. Sharing that claim with
/analyze-batchalso keeps the Analyze button and this run from overlapping, and lets the existing status endpoint report the progress of either.Nothing is said to the user when the request cannot be reached. The brand exists and its tracking has started; a volume run that did not begin is not worth an error in front of someone who has just finished setting up.
Out of scope
stripe/successpicks the organisation's oldest brand, so a second checkout would analyse the wrong one. Real, but a separate concern.Related issue
None — reported directly.
Type of change
feat— New featurefix— Bug fixchore— Maintenance / dependenciesdocs— Documentation onlyrefactor— Code change that neither fixes a bug nor adds a featuretest— Adding or updating testsHow to test
Requires a server deploy — the endpoint is new.
Ten route tests cover the new endpoint: that it starts a fresh brand, that it touches neither the quota check nor the usage ledger, that it declines a brand with volumes without holding the claim afterwards, that two simultaneous calls start one run, and that it refuses a brand the caller cannot reach.
Checklist
feature/,fix/,chore/,docs/) — see CONTRIBUTING.mdyarn lintpasses (run fromweb/)yarn buildpasses (run fromweb/)yarn format:checkpasses (run fromweb/)yarn test/yarn lint/yarn format:checkpass (run fromserver/) — 372 tests