Repository navigation
fix(tracking): say how the first run is going: answers saved, time left, no stale copy - #1774
Merged
Merged
Conversation
The first run after a payment only started when the Stripe return page loaded. A person who closed the tab before it did had the prompts saved in onboarding wait for the nightly run, up to a day. The return page and the checkout.session.completed webhook now share one helper (web/src/lib/billing/first-run.ts) that starts the first run for the organization's first brand, after the plan alignment, and only for an active or trialing subscription. The API keeps it to one run per checkout (server/src/lib/first-run.js): calls for a brand are taken one at a time, and one that finds a full run already waiting or running, or one started since the checkout began, gets that run's id back with created: false. The return page carries that id to the dashboard as before, and only the caller that started the run also starts the volume analysis. A failure in the webhook is logged and Stripe still gets its 200. Deploy the API before the web app: an older API starts a run for every call, so the two callers would start two. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ne run per purchase Review follow-ups to the first run after a payment: - A delayed payment (SEPA, for one) leaves the checkout's subscription incomplete, so nothing started the first run. The webhook now starts it on customer.subscription.updated when the status was incomplete, since the subscription's creation; never on renewals or other changes. - The volume analysis starts in the API, with the run it creates (routes/internal-trigger-tracking.js, moved out of server.js and tested), not from the web app, so a caller that gives up waiting still gets it. The analyze-volumes endpoint had no other caller and is gone. - The jobs read for an existing run go back to the purchase when it is older than 20 hours, so a return page opened again a day later finds the finished run instead of starting a second one. - The first brand is the first active one: a paused brand is skipped. - The job's flag is afterPayment, not firstRun. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The first run after a payment is the customer's first look at the product, and three things kept it slow: - The job queue had no order. A first run started during the nightly cycle waited for a free slot like any other job, and each nightly run holds its slot through a Cloro drain that can last an hour. The first run (firstRun in the job's data) now goes ahead: it may take one slot beyond TRACKING_CONCURRENCY (TRACKING_PRIORITY_SLOTS, default 1), checks for a slot every second, and regular jobs step aside while one waits. The recovery sweep keeps that place. - The daily rollups take a run's days only once it stamps, so until then Citations, Mentions and Visibility's 7/30/90-day ranges showed nothing for a brand whose first run it is. A brand's first full run now refreshes its days as answers land, at most every 2 minutes and one refresh at a time, then once more before the stamp, which waits for it. Later runs are unchanged: their mid-run counts still never show. - A first run that ends short of complete checked for its stamp every 2 minutes; the stamp is what fills the Action Center. It now checks every 30 seconds. No change to what is sent to Cloro or how often. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…e answers Review follow-ups to the first run's progressive rollups and queue place: - A first run's refreshes are at least max(2 min, 5 × the last refresh's duration) apart, so a brand whose refresh is slow does not refresh back to back. - The stamp now waits for a refresh still running itself (run-settlement.js, given the refresher). A run that stamps at once needs no refresh of its own, as the stamp's covers it; one that has to wait for late answers refreshes once when the wait starts, then on the late polls as answers land, so they show before the stamp. - The comment on why refreshes go one at a time: the SQL functions already take a per-brand advisory lock; starting them one at a time keeps refreshes from sitting on connections while they wait for it. - The job flag that orders the queue is afterPayment; the worker's firstRun (no run of the brand ever stamped) says how it differs. - Tests: the run after a payment keeps its extra slot on a retry, the trigger endpoint asks for priority, the stamp waits for the refresher, and the worker hands a first run's refresher and 30 s poll to the stamp (tracking-worker.first-run.test.js). Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ft, and no stale copy Found in the first-tracking review. - "Analysis complete — 0 results saved": on the cloud, Cloro's answers are stored by its webhook, never counted by the worker. The run's settlement now hands back the answers it counted in the table, and the job reports them, with whether late ones are still arriving. The toast says the count, "so far" while answers still arrive, or no number at all. - The saved job was dropped after 60 minutes while the worker may wait 150 (90 for a first answer, 60 for the rest), so a long first run lost its progress banner. It is kept for 150 minutes now. - The ledger banner said "showing the latest completed results" on a first run, which has none; it says the results appear when it finishes. - A rough "about N min left" from the pace the checks finish at while the page watches, once there is enough to go on; the general range before. - The Action Center's first-run note counts checks, not answers (a task can end without one), reads again every 12 seconds instead of 30, and shows the time left too. - The progress banner's and the toasts' strings move to en.json (insights.tracking). Co-Authored-By: Claude Opus 5.5 <[email protected]>
Stripe doesn't order its events, so the subscription's incomplete to active update can come before the checkout's, whose alignment then hasn't run. Align here too before the first run starts, so it tracks only the plan's engines.
gkhngyk
approved these changes
Oct 29, 2026
gkhngyk
left a comment
Contributor
There was a problem hiding this comment.
Looks good. Branch take-1774 (bb2c27b) is this PR's head 2ee2366 merged with take-1773, carrying #1772's fix. It merges on main 3b7611c without conflicts.
Checked
- Result count:
resultCountnow comes from the settlement's table count (webhook answers included) and falls back toinsertedCount.doneMessagehandles an older server (no count means "Analysis complete."). - ETA: a pure function with reasonable guards (1 min, 5 checks, hidden after 10 min of no progress). Hooks run before the early return.
- Copy: every key the code uses exists in
insights.trackingandactionCenter.firstRun. There is no duplicatetrackingkey; en.json is the only locale. - Keep time: 150 min matches the worker's longest first-answer wait plus the tail.
- Embeds: none. Read-only gate: no new action or route. Migrations: none.
Follow-up (not blocking): the settlement count is every answer for the brand since the run started, so a single-prompt run that overlaps it adds to the toast's number.
Deploy: API before web is best, though the web works with either.
Tests: at the tip merged with main: tracking-eta, tracking-job-store, first-run-note, the insights page, stripe and billing (137 tests) pass; tsc is clean; eslint and prettier are clean on the touched files. Server results as in #1773.
gkhngyk
added a commit
that referenced
this pull request
Oct 30, 2026
…th Details (#1811) The panel under the Action Center tabs took several lines while a new brand's first tracking ran: a title, the count, a link and a paragraph. People saw it on every section and asked for something simpler and smaller. - It is one line now, at most 36px: "First tracking running · 18 of 40 checks · ~6 min left · Details". Details unfolds what was there before (what the run means, or that it waits for a slot, and the way to Brand Visibility) and folds it again. Still gone once the brand has a completed run. - The run's reading moves to a hook (hooks/use-first-run.ts): one read loop per brand however many parts of the page show the run, so the Getting started steps can read the same in the next change. Same sources and 12 s pace as before; the time left is kept per brand. - The count still says checks, not answers: a check can end without an answer (#1774). - Help (action-center-overview) and the Action Center guide describe the line. Co-authored-by: Cihan <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]> Co-authored-by: Gökhan Geyik <[email protected]>
gkhngyk
added a commit
that referenced
this pull request
Oct 30, 2026
…ng run goes on (#1814) * feat(action-center): show the first tracking run as one thin line, with Details The panel under the Action Center tabs took several lines while a new brand's first tracking ran: a title, the count, a link and a paragraph. People saw it on every section and asked for something simpler and smaller. - It is one line now, at most 36px: "First tracking running · 18 of 40 checks · ~6 min left · Details". Details unfolds what was there before (what the run means, or that it waits for a slot, and the way to Brand Visibility) and folds it again. Still gone once the brand has a completed run. - The run's reading moves to a hook (hooks/use-first-run.ts): one read loop per brand however many parts of the page show the run, so the Getting started steps can read the same in the next change. Same sources and 12 s pace as before; the time left is kept per brand. - The count still says checks, not answers: a check can end without an answer (#1774). - Help (action-center-overview) and the Action Center guide describe the line. Co-Authored-By: Claude Opus 5.5 <[email protected]> * feat(action-center): put the steps that are ready now first while the first run goes on A new brand's first tracking takes 30 to 65 minutes. Clicking a step or a page that needs its data meanwhile showed an empty page or a 0, which reads as a product that doesn't work; asking people to wait loses them. - Getting started: while the first run goes on, the steps that need none of its data and aren't done (set-up steps: KPIs, competitors, topics, prompts, Search Console, Analytics, the snippet; and the high-value prompts once Search Console's suggestions are in) come first, marked "Ready now". The explore steps, whose pages show the first answers, say "Arriving now" and open their card, which says "Your first answers are arriving (18 of 40) · ~6 min. This fills in when tracking finishes." instead of opening an empty page. The act steps wait for the suggestions after the run, as before. Back to the usual order once it's done (steps.ts: needsFirstAnswers, needsTrackingData, firstRunOrder). - The same message (FirstRunEmptyState, from useFirstRun) replaces Brand Visibility's empty state and "No results for the period" during the first run, and sits above the Tracked Prompts table. - When the first run finishes: "Your first results are ready" as a toast, on whatever page (FirstRunReady in the dashboard layout reads the run there while this browser holds its job; the Action Center, Brand Visibility and Prompts read it anyway). The Actions page reads its list and steps again then, and once more 90 s later for the first signal pass's actions. - Help: getting-started-steps and first-results-after-setup. Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(prompts): one first-run message on Brand Visibility, ~1h, and "Arriving now" in Tracked Prompts From the first look at the Ready now change: - Brand Visibility said it twice during the first run: its own "First tracking in progress" band, and the new arriving card under it. The band stays alone: no empty state under it while the first run goes on ("Or test a single prompt" stays). Tracked Prompts keeps the card, as it has no band. - Getting started's explore steps said "First answers · ~3h"; a first run usually takes 30 to 65 minutes, so ~1h. - Tracked Prompts' rows said "Within 24h" under the card's "~6 min". While the brand's first run goes on, a new prompt's row (and a location column) says "Arriving now", with why on hover; without a first run, "Within 24h" as before. - Help: getting-started-steps, first-results-after-setup, tracked-prompts and prompt-locations; the guides too. Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(action-center): read the first run less often with nothing going on, and not in a hidden tab The first run's read loop now runs on Brand Visibility, Prompts and the Action Center, which stay open for long. After five reads in a row with no run going, read every minute instead of every 12 seconds; a run showing up brings back the usual pace. A hidden tab reads nothing and reads at once when it is shown again. --------- Co-authored-by: Cihan <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]> Co-authored-by: Gökhan Geyik <[email protected]>
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
What the tracking progress UI says during and after a run, especially the first one.
/cloro/callbackand never reached the worker'sinsertedCount, so the count was always 0.settleTrackingRunnow returnsresultCountread from the table (or null), and the job result carriesresultCountandstillArriving.TRACKING_JOB_KEEP_MS, the worker's longest first-answer wait plus the queue tail). On a first run the ledger banner says "First tracking in progress — your results appear here as soon as it finishes. You can leave this page." The "latest completed results" copy shows only when there is a previous run.lib/tracking-eta.ts, pure): from the pace of finished checks over the last 10 minutes.en.json(insights.tracking): banners, Stop, queued and active bodies, ETA bodies, the ledger banner and the toasts.Related issue
None.
Stacked on #1773 (first-run speed), which touches the same
run-settlement.js. The diff against it holds only this change.Type of change
fix— Bug fixHow to test
tracking-eta.test.tstracking-job-store.test.tsfirst-run-note.test.tsxrun-settlement.test.jsChecklist
_before-publish.test.tsxfailed on the focus race that test(content): wait for the dialog's first focus before opening the JSON-LD code #1753 fixes (untouched here).🤖 Generated with Claude Code