Skip to content

fix(volumes): analyse a brand's keywords when its setup finishes, not only after checkout - #765

Merged
gkhngyk merged 1 commit into
mainfrom
fix/brand-setup-volume-bootstrap
Aug 21, 2026
Merged

gkhngyk merged 1 commit into
mainfrom
fix/brand-setup-volume-bootstrap

Conversation

@gkhngyk

@gkhngyk gkhngyk commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

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-batch stays 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-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.

Out of scope

  • The daily cron is untouched. It has never run volume analysis and still doesn't.
  • Prompts added one at a time later still use the Analyze button.
  • stripe/success picks 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 feature
  • fix — Bug fix
  • chore — Maintenance / dependencies
  • docs — Documentation only
  • refactor — Code change that neither fixes a bug nor adds a feature
  • test — Adding or updating tests

How to test

Requires a server deploy — the endpoint is new.

  1. Add a brand from the dashboard and finish its setup. Open the Prompts page: volume and competition fill in on their own, with no Analyze click. Tracking still starts as before.
  2. Finish setup for a brand a second time, or let two setups land together: only one run starts, and the plan's remaining analyses are unchanged in both cases.
  3. Press Analyze on a brand that has volumes and confirm it still bills the quota as it always did.
  4. Stop the server mid-setup: the brand is created, tracking still starts, and no error reaches the user.

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

  • Branch follows the naming convention (feature/, fix/, chore/, docs/) — see CONTRIBUTING.md
  • Commits follow Conventional Commits
  • yarn lint passes (run from web/)
  • yarn build passes (run from web/)
  • yarn format:check passes (run from web/)
  • yarn test / yarn lint / yarn format:check pass (run from server/) — 372 tests
  • Changes are focused — one concern per PR

… 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.
@gkhngyk
gkhngyk merged commit 9736b2d into main Aug 21, 2026
5 checks passed
@gkhngyk
gkhngyk deleted the fix/brand-setup-volume-bootstrap branch August 21, 2026 13:29
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.

1 participant