Repository navigation
feat(tracking): ask Google AI Overview and AI Mode from a US state, by its name - #1730
Conversation
…y its name Google's engines ran a US state country-wide, once per country (ansvisor#691): the provider's AI endpoints take a state, and Google's took only a city as `location`. Google's endpoints take a state's canonical name as `location` too ("California,United States"), so a state is now asked from the state itself on every engine: - locations.js: locationsForScraper keeps a state for Google's engines (COUNTRY_ONLY_SCRAPERS goes), and googleLocationFor names a city or a state as Google does. The worker sends it as `location`; Google's requests never carry `state`, the AI endpoints' requests never carry `location` (tests lock both). - Google's answers in a state are recorded under the state (US-CA), not the country. Earlier ones stay under the country; no backfill. - Web: a state counts Google's engines (COUNTRY_ONLY_MODELS goes), so the Locations view waits for them there instead of "No engine here"; the location picker's state note, and the prop it read, go. - Docs: the prompts guide says how each engine asks from a state. Cost: Google's credits grow with the states tracked (one task per state where there was one per country). The plan's quota already counts each state as a location, so nothing changes for the workspace. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Preview approval requiredThis pull request comes from a fork, so Mintlify won't build a preview until someone with write access approves commit |
|
Product decision on the cost note (Cihan): ship as is. A US state already counts as one location against the plan's tracked prompt-location quota ( |
|
Live check with a Cloro key (4 requests, synchronous |
gkhngyk
left a comment
There was a problem hiding this comment.
Looks good, with follow-ups
What I checked
- Provider calls.
locationsForScrapernow keeps every code for Google's engines, so a prompt tracked inUS-CAalone sends one Google AI Overview and one AI Mode task, withcountry: "US"andlocation: "California,United States"; there is no extra country-wideUStask. A prompt tracked inUSandUS-CAsends two, as it does for every other engine. The progress total (totalTasks) counts the same list the run submits, so the bar still reaches the end. - Request bodies.
buildRequestBodyonly spreadslocationon the two Google branches, andstateonly on the AI-endpoint branches, so neither side gets the other's field. Cloro'smonitor/googledocs saylocationtakes "any Google canonical location name, including states and regions", withCalifornia,United Statesas the example. The AI Mode page says to "pairlocationwithcountryto target a city or region". The newcloro-scraper.test.jscase pins both bodies. - State names.
googleLocationForonly builds a name for a state thatparseLocationaccepts, soUS-XX, or a code for a non-US subdivision, sends nolocationand runs country-wide. That is what the other engines already do with it. The server'sUS_STATE_NAMESand the web'sUS_STATESlist the same 51 codes, and both write paths (updatePromptLocationsandbulkUpdatePromptLocations) still refuse a code thatisValidLocationdoesn't accept. "District of Columbia,United States" is Google's canonical name for DC. - Plan locations. Nothing changes. Each state was already one plan location (
promptLocationCount, andorg_prompt_location_usagein SQL). What changes is our side: Google credits now grow with the number of tracked states instead of the number of countries. - Where answers are saved. The row's region comes from the task's own
region(meta.regionwhen polling,cloro_pending_tasks.regionfor webhooks), not from re-reading the prompt. So if the API is deployed while a run is in flight, tasks the old worker submitted country-wide still land underUS, and the new worker's tasks land under the state. No answer is saved under a place it wasn't asked from. - Deploy order. The web goes out on merge, and the API later. In between, the Locations view counts Google in a state ("Within 24h") and the picker's note is gone, but the old API still asks Google country-wide and saves the answers under
US. Google's state cells stay at "Within 24h" until the API is deployed. That only affects what the view shows; nothing is saved under the wrong place. Deploying the API on the same day as the merge closes the gap. - No migration. No PostgREST embeds, server actions or routes are added.
- Tests: server
locations,cloro-scraper,cities,cloro-countriesand the worker tests pass (118). In the full server suite, the only failures are the known timing tests under load, plus the Framer CMS files, which fail locally on a package missing from my local install and not touched here. Webtracking-countries,_location-matrixandlocation-pickerpass (the picker test needs more than the 5 s default under load).tscpasses, and prettier/eslint pass on the touched files.
Follow-ups
- Before the API deploy, send one live
monitor/aimoderequest withlocation: "California,United States"to confirm AI Mode honours a state the way the Google search endpoint documents it. If it rejects the request, each Google state task fails at submit and the cell stays empty. tracking-worker.jsstill says, above the task loop, that "a Google run collapsed to its country is recorded as the country it actually ran in". That no longer happens; the comment could go.- The docs' list of engines that take a state leaves out Grok (and ChatGPT Shopping), which also get
state.
Summary
Google AI Overview and AI Mode now ask from a US state itself, by its name, the way the other engines already do. Until now they ran a state country-wide, once per country (#691).
Cloro's Google endpoints (
/v1/monitor/googleand/v1/monitor/aimode) take a Google canonical location name aslocation, a state included: "States and regions also work, e.g.,California,United States". The AI endpoints take a state asstate.locations.js:locationsForScraperkeeps a state for Google's engines (COUNTRY_ONLY_SCRAPERSgoes).googleLocationFor(code): a city'sgooglename (cities.js), or"<State name>,United States"for a state ("District of Columbia,United States" for DC);undefinedfor a country.location. Google's requests never carrystate, and the AI endpoints' requests never carrylocation;cloro-scraper.test.jslocks both.US-CA), not the country.COUNTRY_ONLY_MODELSgoes), so the Locations view waits for their first run there ("Within 24h") instead of "No engine here".platformsprop that only fed it, from both call sites.For the maintainer
California,United States), or theTurkiyespelling incities.js. Onemonitor/google(+aioverview) and onemonitor/aimoderequest with each would confirm them; the API key is yours.US. The state columns fill from the first run after deploy.Related issue
None (follow-up to #691 and PROMPT-015).
Type of change
feat— New featureHow to test
US-CA) with Google AI Overview / AI Mode on.location: "California,United States"and nostate; ChatGPT etc. withstate: "CA"and nolocation. The server log orcloro-scrapertest fixtures show the bodies.US-CA; Tracked Prompts › Locations shows Google in the California column. Before the first run it says "Within 24h", not "No engine here".countryonly.Checklist
npm run format,npm run lint,npm testpass (279/279 files, 3,912 tests)yarn format,yarn lint(0 errors),yarn typecheck,yarn buildpass;yarn test554/555 files, the Content Editor page test timed out under load and passes alone (284/284)googleLocationFor), cloro-scraper (location vs state per engine), cities, cloro-countries, tracking-countries, Locations view🤖 Generated with Claude Code