Skip to content

feat(tracking): ask Google AI Overview and AI Mode from a US state, by its name - #1730

Merged
gkhngyk merged 2 commits into
ansvisor:mainfrom
cihan-gyk:feature/google-state-location
Oct 29, 2026
Merged

gkhngyk merged 2 commits into
ansvisor:mainfrom
cihan-gyk:feature/google-state-location

Conversation

@cihan-gyk

Copy link
Copy Markdown
Collaborator

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/google and /v1/monitor/aimode) take a Google canonical location name as location, a state included: "States and regions also work, e.g., California,United States". The AI endpoints take a state as state.

  • Server:
    • locations.js: locationsForScraper keeps a state for Google's engines (COUNTRY_ONLY_SCRAPERS goes).
    • New googleLocationFor(code): a city's google name (cities.js), or "<State name>,United States" for a state ("District of Columbia,United States" for DC); undefined for a country.
    • The tracking worker sends it as location. Google's requests never carry state, and the AI endpoints' requests never carry location; cloro-scraper.test.js locks both.
    • Google's answers in a state are recorded under the state (US-CA), not the country.
  • Web:
    • A state now counts Google's engines (COUNTRY_ONLY_MODELS goes), so the Locations view waits for their first run there ("Within 24h") instead of "No engine here".
    • The location picker's hard-coded state note goes, along with the platforms prop that only fed it, from both call sites.
  • Docs: the prompts guide says how each engine asks from a US state, and that Google's earlier state answers are under the country.

For the maintainer

  1. Cost. A prompt tracked in California and Texas ran Google once (US). It now runs Google once per state, so Cloro's Google credits grow with the number of tracked states. The plan's location quota already counts each state as a location, so nothing changes for the user. Whether to ship as is, cap it, or limit it to some plans is your call.
  2. Not verified live. I haven't confirmed with a real request that Cloro accepts state names (California,United States), or the Turkiye spelling in cities.js. One monitor/google (+ aioverview) and one monitor/aimode request with each would confirm them; the API key is yours.
  3. No backfill. Earlier Google answers for state-tracked prompts stay under 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 feature

How to test

  1. Track a prompt in a US state only (e.g. US-CA) with Google AI Overview / AI Mode on.
  2. Run tracking. The Google tasks are submitted with location: "California,United States" and no state; ChatGPT etc. with state: "CA" and no location. The server log or cloro-scraper test fixtures show the bodies.
  3. The answers land under US-CA; Tracked Prompts › Locations shows Google in the California column. Before the first run it says "Within 24h", not "No engine here".
  4. A prompt tracked in a city still sends the city's name; one tracked in a country sends country only.

Checklist

  • Branch follows the naming convention
  • Commits follow Conventional Commits
  • Server: npm run format, npm run lint, npm test pass (279/279 files, 3,912 tests)
  • Web: yarn format, yarn lint (0 errors), yarn typecheck, yarn build pass; yarn test 554/555 files, the Content Editor page test timed out under load and passes alone (284/284)
  • Tests updated: locations (state kept for Google, googleLocationFor), cloro-scraper (location vs state per engine), cities, cloro-countries, tracking-countries, Locations view
  • The embed guard from test(web): fail on an embed between twice-joined tables that doesn't name its foreign key #1714 passes on this branch
  • Docs updated
  • Browser check of the picker / Locations view: not done (the visible change is the removed state note and the Google state cell)
  • Live Cloro request with a state name: the maintainer's

🤖 Generated with Claude Code

…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]>
@mintlify

mintlify Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

Preview approval required

This pull request comes from a fork, so Mintlify won't build a preview until someone with write access approves commit f19ca0f.

Approve preview

@cihan-gyk

Copy link
Copy Markdown
Collaborator Author

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 (org_prompt_location_usage / promptLocationCount: every region code, country, state or city, is one unit). So this gives no new allowance: a prompt tracked in California and Texas already used 2 units, while Google ran only once, country-wide. With this PR, each unit the customer pays for gets every engine, as countries and cities already do. The plan's location quota stays the only limit; no separate state rule.

@cihan-gyk

Copy link
Copy Markdown
Collaborator Author

Live check with a Cloro key (4 requests, synchronous /v1/monitor/google + /v1/monitor/aimode): location: "California,United States" (country US) and location: "Istanbul,Istanbul,Turkiye" (country TR) were both accepted — HTTP 200, success: true, an AI Overview (~12.5–13k chars) on monitor/google and an AI Mode answer on monitor/aimode for each. So state names work for Google's engines, and the Turkiye spelling in cities.js is right. (Cloro doesn't echo the location back, so this confirms the names are accepted, not how far the answers differ.)

@gkhngyk gkhngyk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, with follow-ups

What I checked

  • Provider calls. locationsForScraper now keeps every code for Google's engines, so a prompt tracked in US-CA alone sends one Google AI Overview and one AI Mode task, with country: "US" and location: "California,United States"; there is no extra country-wide US task. A prompt tracked in US and US-CA sends 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. buildRequestBody only spreads location on the two Google branches, and state only on the AI-endpoint branches, so neither side gets the other's field. Cloro's monitor/google docs say location takes "any Google canonical location name, including states and regions", with California,United States as the example. The AI Mode page says to "pair location with country to target a city or region". The new cloro-scraper.test.js case pins both bodies.
  • State names. googleLocationFor only builds a name for a state that parseLocation accepts, so US-XX, or a code for a non-US subdivision, sends no location and runs country-wide. That is what the other engines already do with it. The server's US_STATE_NAMES and the web's US_STATES list the same 51 codes, and both write paths (updatePromptLocations and bulkUpdatePromptLocations) still refuse a code that isValidLocation doesn'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, and org_prompt_location_usage in 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.region when polling, cloro_pending_tasks.region for 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 under US, 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-countries and 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. Web tracking-countries, _location-matrix and location-picker pass (the picker test needs more than the 5 s default under load). tsc passes, and prettier/eslint pass on the touched files.

Follow-ups

  1. Before the API deploy, send one live monitor/aimode request with location: "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.
  2. tracking-worker.js still 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.
  3. The docs' list of engines that take a state leaves out Grok (and ChatGPT Shopping), which also get state.

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.

2 participants