Skip to content

feat(prompts): break the per-prompt health columns down by location - #784

Merged
gkhngyk merged 1 commit into
mainfrom
feature/691-location-discovery
Aug 24, 2026
Merged

gkhngyk merged 1 commit into
mainfrom
feature/691-location-discovery

Conversation

@gkhngyk

@gkhngyk gkhngyk commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

Summary

Multi-location tracking (#691) started producing data that no page could read at the level that made it worth buying. "What is our visibility in Germany?" was answerable brand-wide from Visibility's region filter. "…for this prompt?" was not: the All Prompts health columns blended every location a prompt runs in into a single figure, so a prompt that is strong at home and invisible abroad looked merely mediocre, with nothing on screen to split the two.

prompt_visibility_summaries gains p_region (migration 00072, already applied to the hosted DB). NULL keeps the blended whole-brand behaviour exactly, so callers that don't pass it are unchanged. The 3-argument signature is dropped rather than left alongside the new one: with both installed, a 3-argument call matches the old function and the new one through its default, which Postgres rejects as ambiguous. Dropping is safe across the deploy window because PostgREST binds arguments by name — the running app's 3-name call takes the default.

The Prompts page gets a Location control beside the date range — same shape and vocabulary as Visibility, fed by the same whole-brand insights_filter_options RPC so the two pages cannot disagree about where a brand is tracked. Two deliberate behaviours:

  • it appears only when the brand has produced results in more than one location (a filter with a single option is noise);
  • a location that stops producing results falls back to the blended view instead of filtering the table to nothing.

The prompt detail page renders its per-run group locations through formatRegionDisplay. It printed the raw code, which was harmless while every code was a country and actively confusing the moment states arrived: DE and US-DE side by side are Germany and Delaware.

Verified against production: for a brand whose results are all one location, filtering by that location returns figures identical to unfiltered, and filtering by any other returns empty. No brand has multi-location results yet — targeting only became possible in #783 — so cross-location behaviour is exercised by construction rather than by existing data.

Related issue

Follow-up to #691 (closed by #783), from the discovery gap found while reviewing what shipped.

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

  1. cd web && yarn test — 134 pass.
  2. Prompts page, brand tracked in one location: no Location control appears; the table is exactly as before.
  3. Prompts page, brand tracked in several: pick one — the visibility, mentions, citations and runs columns re-read for that location only. Sorting by visibility then ranks prompts within that location, which is the "where are we weak abroad" question.
  4. "All Locations" returns the blended figures the table has always shown.
  5. Prompt detail: per-run groups show "🇩🇪 Germany" / "🇺🇸 Delaware" rather than DE / US-DE.

Checklist

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

Multi-location tracking (#691) produced data no page could read at the
level that made it worth buying. "What is our visibility in Germany?"
was answerable brand-wide from Visibility's region filter, but "…for
this prompt?" was not: the All Prompts health columns averaged every
location a prompt runs in into one figure, so a prompt that is strong at
home and invisible abroad looked merely mediocre, with no way to split
the two.

prompt_visibility_summaries gains p_region (00072, applied). NULL keeps
the blended whole-brand behaviour exactly, so nothing changes for
callers that don't pass it. The 3-argument signature is dropped rather
than kept alongside: with both installed a 3-argument call matches the
old function and the new one through its default, which Postgres rejects
as ambiguous. Dropping is safe across the deploy window because
PostgREST binds arguments by name.

The Prompts page gets the Location control next to the date range —
same shape and vocabulary as Visibility, fed by the same whole-brand
filter-options RPC so the two pages cannot disagree about where a brand
is tracked. It only appears when a brand has produced results in more
than one location; a filter with one option is noise. A location that
stops producing results falls back to the blended view rather than
filtering the table to nothing.

The prompt detail page's per-run groups now render their location
through formatRegionDisplay. It printed the raw code, which was harmless
while every code was a country and actively confusing the moment states
arrived: "DE" and "US-DE" side by side are Germany and Delaware.
@gkhngyk gkhngyk added prompts Prompt management, suggestions, query fan-out needs-migration Adds or edits a migration — apply it to the hosted database labels Aug 24, 2026
@gkhngyk
gkhngyk merged commit 385df84 into main Aug 24, 2026
5 checks passed
@gkhngyk
gkhngyk deleted the feature/691-location-discovery branch August 24, 2026 18:28
@gkhngyk gkhngyk mentioned this pull request Aug 24, 2026
7 of 12 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-migration Adds or edits a migration — apply it to the hosted database prompts Prompt management, suggestions, query fan-out

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant