Skip to content

Migrate Locations to POST /query API#6415

Open
apata wants to merge 2 commits into
masterfrom
query/migrate-locations
Open

Migrate Locations to POST /query API#6415
apata wants to merge 2 commits into
masterfrom
query/migrate-locations

Conversation

@apata
Copy link
Copy Markdown
Contributor

@apata apata commented May 28, 2026

Changes

Refactors Locations block and modals to /query endpoint.
Map tab now also shows imported data excluded warning.

Tests

  • Automated tests have been added
  • This PR does not require tests

Changelog

  • Entry has been added to changelog
  • This PR does not make a user-facing change

Documentation

  • Docs have been updated
  • This change does not need a documentation update

Dark mode

  • The UI has been tested both in dark and light mode
  • This PR does not change the UI

@apata apata force-pushed the query/migrate-locations branch from 52072fb to 4802199 Compare June 1, 2026 10:08
@apata apata added bug Something isn't working preview and removed bug Something isn't working labels Jun 1, 2026
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 1, 2026

Preview environment👷🏼‍♀️🏗️
PR-6415

@apata apata force-pushed the query/migrate-locations branch from 4802199 to 800e92e Compare June 1, 2026 11:22
@apata apata changed the title WIP: Migrate Locations to POST /query API Migrate Locations to POST /query API Jun 1, 2026
@apata apata marked this pull request as ready for review June 1, 2026 11:49
@apata apata requested a review from a team June 1, 2026 11:50
@@ -0,0 +1 @@
{"YE":{"flag":"🇾🇪","alpha_3":"YEM"},"QA":{"flag":"🇶🇦","alpha_3":"QAT"},"MR":{"flag":"🇲🇷","alpha_3":"MRT"},"CH":{"flag":"🇨🇭","alpha_3":"CHE"},"AF":{"flag":"🇦🇫","alpha_3":"AFG"},"AO":{"flag":"🇦🇴","alpha_3":"AGO"},"BT":{"flag":"🇧🇹","alpha_3":"BTN"},"HK":{"flag":"🇭🇰","alpha_3":"HKG"},"CU":{"flag":"🇨🇺","alpha_3":"CUB"},"HU":{"flag":"🇭🇺","alpha_3":"HUN"},"AZ":{"flag":"🇦🇿","alpha_3":"AZE"},"SS":{"flag":"🇸🇸","alpha_3":"SSD"},"BY":{"flag":"🇧🇾","alpha_3":"BLR"},"MA":{"flag":"🇲🇦","alpha_3":"MAR"},"MZ":{"flag":"🇲🇿","alpha_3":"MOZ"},"TR":{"flag":"🇹🇷","alpha_3":"TUR"},"PL":{"flag":"🇵🇱","alpha_3":"POL"},"US":{"flag":"🇺🇸","alpha_3":"USA"},"SR":{"flag":"🇸🇷","alpha_3":"SUR"},"LR":{"flag":"🇱🇷","alpha_3":"LBR"},"OM":{"flag":"🇴🇲","alpha_3":"OMN"},"MH":{"flag":"🇲🇭","alpha_3":"MHL"},"TG":{"flag":"🇹🇬","alpha_3":"TGO"},"CW":{"flag":"🇨🇼","alpha_3":"CUW"},"AT":{"flag":"🇦🇹","alpha_3":"AUT"},"CO":{"flag":"🇨🇴","alpha_3":"COL"},"SV":{"flag":"🇸🇻","alpha_3":"SLV"},"RE":{"flag":"🇷🇪","alpha_3":"REU"},"LI":{"flag":"🇱🇮","alpha_3":"LIE"},"PR":{"flag":"🇵🇷","alpha_3":"PRI"},"GI":{"flag":"🇬🇮","alpha_3":"GIB"},"CV":{"flag":"🇨🇻","alpha_3":"CPV"},"KG":{"flag":"🇰🇬","alpha_3":"KGZ"},"SK":{"flag":"🇸🇰","alpha_3":"SVK"},"LT":{"flag":"🇱🇹","alpha_3":"LTU"},"AL":{"flag":"🇦🇱","alpha_3":"ALB"},"BL":{"flag":"🇧🇱","alpha_3":"BLM"},"FK":{"flag":"🇫🇰","alpha_3":"FLK"},"TV":{"flag":"🇹🇻","alpha_3":"TUV"},"SJ":{"flag":"🇸🇯","alpha_3":"SJM"},"CX":{"flag":"🇨🇽","alpha_3":"CXR"},"VG":{"flag":"🇻🇬","alpha_3":"VGB"},"VI":{"flag":"🇻🇮","alpha_3":"VIR"},"TT":{"flag":"🇹🇹","alpha_3":"TTO"},"AI":{"flag":"🇦🇮","alpha_3":"AIA"},"GE":{"flag":"🇬🇪","alpha_3":"GEO"},"GB":{"flag":"🇬🇧","alpha_3":"GBR"},"TW":{"flag":"🇹🇼","alpha_3":"TWN"},"BV":{"flag":"🇧🇻","alpha_3":"BVT"},"AU":{"flag":"🇦🇺","alpha_3":"AUS"},"CD":{"flag":"🇨🇩","alpha_3":"COD"},"IL":{"flag":"🇮🇱","alpha_3":"ISR"},"FJ":{"flag":"🇫🇯","alpha_3":"FJI"},"HM":{"flag":"🇭🇲","alpha_3":"HMD"},"MO":{"flag":"🇲🇴","alpha_3":"MAC"},"LU":{"flag":"🇱🇺","alpha_3":"LUX"},"TH":{"flag":"🇹🇭","alpha_3":"THA"},"TZ":{"flag":"🇹🇿","alpha_3":"TZA"},"MC":{"flag":"🇲🇨","alpha_3":"MCO"},"AD":{"flag":"🇦🇩","alpha_3":"AND"},"IQ":{"flag":"🇮🇶","alpha_3":"IRQ"},"NI":{"flag":"🇳🇮","alpha_3":"NIC"},"KW":{"flag":"🇰🇼","alpha_3":"KWT"},"MW":{"flag":"🇲🇼","alpha_3":"MWI"},"GH":{"flag":"🇬🇭","alpha_3":"GHA"},"DM":{"flag":"🇩🇲","alpha_3":"DMA"},"EE":{"flag":"🇪🇪","alpha_3":"EST"},"IS":{"flag":"🇮🇸","alpha_3":"ISL"},"BM":{"flag":"🇧🇲","alpha_3":"BMU"},"EC":{"flag":"🇪🇨","alpha_3":"ECU"},"KM":{"flag":"🇰🇲","alpha_3":"COM"},"SB":{"flag":"🇸🇧","alpha_3":"SLB"},"AE":{"flag":"🇦🇪","alpha_3":"ARE"},"CM":{"flag":"🇨🇲","alpha_3":"CMR"},"EH":{"flag":"🇪🇭","alpha_3":"ESH"},"CC":{"flag":"🇨🇨","alpha_3":"CCK"},"AS":{"flag":"🇦🇸","alpha_3":"ASM"},"KH":{"flag":"🇰🇭","alpha_3":"KHM"},"MD":{"flag":"🇲🇩","alpha_3":"MDA"},"NA":{"flag":"🇳🇦","alpha_3":"NAM"},"SA":{"flag":"🇸🇦","alpha_3":"SAU"},"HN":{"flag":"🇭🇳","alpha_3":"HND"},"MK":{"flag":"🇲🇰","alpha_3":"MKD"},"LC":{"flag":"🇱🇨","alpha_3":"LCA"},"PA":{"flag":"🇵🇦","alpha_3":"PAN"},"VC":{"flag":"🇻🇨","alpha_3":"VCT"},"TM":{"flag":"🇹🇲","alpha_3":"TKM"},"SI":{"flag":"🇸🇮","alpha_3":"SVN"},"GQ":{"flag":"🇬🇶","alpha_3":"GNQ"},"PH":{"flag":"🇵🇭","alpha_3":"PHL"},"CZ":{"flag":"🇨🇿","alpha_3":"CZE"},"BO":{"flag":"🇧🇴","alpha_3":"BOL"},"SY":{"flag":"🇸🇾","alpha_3":"SYR"},"NO":{"flag":"🇳🇴","alpha_3":"NOR"},"IM":{"flag":"🇮🇲","alpha_3":"IMN"},"SX":{"flag":"🇸🇽","alpha_3":"SXM"},"GG":{"flag":"🇬🇬","alpha_3":"GGY"},"GW":{"flag":"🇬🇼","alpha_3":"GNB"},"SH":{"flag":"🇸🇭","alpha_3":"SHN"},"NC":{"flag":"🇳🇨","alpha_3":"NCL"},"BE":{"flag":"🇧🇪","alpha_3":"BEL"},"JP":{"flag":"🇯🇵","alpha_3":"JPN"},"LV":{"flag":"🇱🇻","alpha_3":"LVA"},"AM":{"flag":"🇦🇲","alpha_3":"ARM"},"SD":{"flag":"🇸🇩","alpha_3":"SDN"},"GT":{"flag":"🇬🇹","alpha_3":"GTM"},"PY":{"flag":"🇵🇾","alpha_3":"PRY"},"MN":{"flag":"🇲🇳","alpha_3":"MNG"},"TK":{"flag":"🇹🇰","alpha_3":"TKL"},"DZ":{"flag":"🇩🇿","alpha_3":"DZA"},"KZ":{"flag":"🇰🇿","alpha_3":"KAZ"},"LY":{"flag":"🇱🇾","alpha_3":"LBY"},"AW":{"flag":"🇦🇼","alpha_3":"ABW"},"UY":{"flag":"🇺🇾","alpha_3":"URY"},"GL":{"flag":"🇬🇱","alpha_3":"GRL"},"SN":{"flag":"🇸🇳","alpha_3":"SEN"},"UM":{"flag":"🇺🇲","alpha_3":"UMI"},"JO":{"flag":"🇯🇴","alpha_3":"JOR"},"MT":{"flag":"🇲🇹","alpha_3":"MLT"},"BS":{"flag":"🇧🇸","alpha_3":"BHS"},"BI":{"flag":"🇧🇮","alpha_3":"BDI"},"BA":{"flag":"🇧🇦","alpha_3":"BIH"},"MQ":{"flag":"🇲🇶","alpha_3":"MTQ"},"MU":{"flag":"🇲🇺","alpha_3":"MUS"},"MS":{"flag":"🇲🇸","alpha_3":"MSR"},"BW":{"flag":"🇧🇼","alpha_3":"BWA"},"YT":{"flag":"🇾🇹","alpha_3":"MYT"},"PN":{"flag":"🇵🇳","alpha_3":"PCN"},"MP":{"flag":"🇲🇵","alpha_3":"MNP"},"ML":{"flag":"🇲🇱","alpha_3":"MLI"},"BH":{"flag":"🇧🇭","alpha_3":"BHR"},"LB":{"flag":"🇱🇧","alpha_3":"LBN"},"AR":{"flag":"🇦🇷","alpha_3":"ARG"},"PG":{"flag":"🇵🇬","alpha_3":"PNG"},"GR":{"flag":"🇬🇷","alpha_3":"GRC"},"HT":{"flag":"🇭🇹","alpha_3":"HTI"},"WS":{"flag":"🇼🇸","alpha_3":"WSM"},"SG":{"flag":"🇸🇬","alpha_3":"SGP"},"GP":{"flag":"🇬🇵","alpha_3":"GLP"},"BF":{"flag":"🇧🇫","alpha_3":"BFA"},"ME":{"flag":"🇲🇪","alpha_3":"MNE"},"AQ":{"flag":"🇦🇶","alpha_3":"ATA"},"PK":{"flag":"🇵🇰","alpha_3":"PAK"},"FM":{"flag":"🇫🇲","alpha_3":"FSM"},"MV":{"flag":"🇲🇻","alpha_3":"MDV"},"GS":{"flag":"🇬🇸","alpha_3":"SGS"},"BN":{"flag":"🇧🇳","alpha_3":"BRN"},"CK":{"flag":"🇨🇰","alpha_3":"COK"},"IO":{"flag":"🇮🇴","alpha_3":"IOT"},"SE":{"flag":"🇸🇪","alpha_3":"SWE"},"SC":{"flag":"🇸🇨","alpha_3":"SYC"},"ZW":{"flag":"🇿🇼","alpha_3":"ZWE"},"SL":{"flag":"🇸🇱","alpha_3":"SLE"},"AG":{"flag":"🇦🇬","alpha_3":"ATG"},"PF":{"flag":"🇵🇫","alpha_3":"PYF"},"CF":{"flag":"🇨🇫","alpha_3":"CAF"},"BD":{"flag":"🇧🇩","alpha_3":"BGD"},"AX":{"flag":"🇦🇽","alpha_3":"ALA"},"SZ":{"flag":"🇸🇿","alpha_3":"SWZ"},"HR":{"flag":"🇭🇷","alpha_3":"HRV"},"RS":{"flag":"🇷🇸","alpha_3":"SRB"},"NF":{"flag":"🇳🇫","alpha_3":"NFK"},"IE":{"flag":"🇮🇪","alpha_3":"IRL"},"NR":{"flag":"🇳🇷","alpha_3":"NRU"},"ZA":{"flag":"🇿🇦","alpha_3":"ZAF"},"CA":{"flag":"🇨🇦","alpha_3":"CAN"},"KR":{"flag":"🇰🇷","alpha_3":"KOR"},"A1":{"flag":"🏳️","alpha_3":null},"VA":{"flag":"🇻🇦","alpha_3":"VAT"},"NU":{"flag":"🇳🇺","alpha_3":"NIU"},"JE":{"flag":"🇯🇪","alpha_3":"JEY"},"TD":{"flag":"🇹🇩","alpha_3":"TCD"},"IR":{"flag":"🇮🇷","alpha_3":"IRN"},"NL":{"flag":"🇳🇱","alpha_3":"NLD"},"BB":{"flag":"🇧🇧","alpha_3":"BRB"},"FI":{"flag":"🇫🇮","alpha_3":"FIN"},"UA":{"flag":"🇺🇦","alpha_3":"UKR"},"ID":{"flag":"🇮🇩","alpha_3":"IDN"},"ST":{"flag":"🇸🇹","alpha_3":"STP"},"VU":{"flag":"🇻🇺","alpha_3":"VUT"},"RU":{"flag":"🇷🇺","alpha_3":"RUS"},"NE":{"flag":"🇳🇪","alpha_3":"NER"},"TO":{"flag":"🇹🇴","alpha_3":"TON"},"UZ":{"flag":"🇺🇿","alpha_3":"UZB"},"GN":{"flag":"🇬🇳","alpha_3":"GIN"},"JM":{"flag":"🇯🇲","alpha_3":"JAM"},"FR":{"flag":"🇫🇷","alpha_3":"FRA"},"TL":{"flag":"🇹🇱","alpha_3":"TLS"},"ET":{"flag":"🇪🇹","alpha_3":"ETH"},"KI":{"flag":"🇰🇮","alpha_3":"KIR"},"CG":{"flag":"🇨🇬","alpha_3":"COG"},"DE":{"flag":"🇩🇪","alpha_3":"DEU"},"RW":{"flag":"🇷🇼","alpha_3":"RWA"},"DO":{"flag":"🇩🇴","alpha_3":"DOM"},"VE":{"flag":"🇻🇪","alpha_3":"VEN"},"PW":{"flag":"🇵🇼","alpha_3":"PLW"},"TC":{"flag":"🇹🇨","alpha_3":"TCA"},"ZM":{"flag":"🇿🇲","alpha_3":"ZMB"},"NG":{"flag":"🇳🇬","alpha_3":"NGA"},"WF":{"flag":"🇼🇫","alpha_3":"WLF"},"GF":{"flag":"🇬🇫","alpha_3":"GUF"},"KN":{"flag":"🇰🇳","alpha_3":"KNA"},"ES":{"flag":"🇪🇸","alpha_3":"ESP"},"GM":{"flag":"🇬🇲","alpha_3":"GMB"},"KP":{"flag":"🇰🇵","alpha_3":"PRK"},"GY":{"flag":"🇬🇾","alpha_3":"GUY"},"MX":{"flag":"🇲🇽","alpha_3":"MEX"},"IN":{"flag":"🇮🇳","alpha_3":"IND"},"SM":{"flag":"🇸🇲","alpha_3":"SMR"},"BG":{"flag":"🇧🇬","alpha_3":"BGR"},"MF":{"flag":"🇲🇫","alpha_3":"MAF"},"CL":{"flag":"🇨🇱","alpha_3":"CHL"},"VN":{"flag":"🇻🇳","alpha_3":"VNM"},"NP":{"flag":"🇳🇵","alpha_3":"NPL"},"CR":{"flag":"🇨🇷","alpha_3":"CRI"},"ER":{"flag":"🇪🇷","alpha_3":"ERI"},"LK":{"flag":"🇱🇰","alpha_3":"LKA"},"CI":{"flag":"🇨🇮","alpha_3":"CIV"},"PT":{"flag":"🇵🇹","alpha_3":"PRT"},"TJ":{"flag":"🇹🇯","alpha_3":"TJK"},"MY":{"flag":"🇲🇾","alpha_3":"MYS"},"PS":{"flag":"🇵🇸","alpha_3":"PSE"},"PE":{"flag":"🇵🇪","alpha_3":"PER"},"LS":{"flag":"🇱🇸","alpha_3":"LSO"},"CY":{"flag":"🇨🇾","alpha_3":"CYP"},"TN":{"flag":"🇹🇳","alpha_3":"TUN"},"XK":{"flag":"🇽🇰","alpha_3":"XKX"},"KY":{"flag":"🇰🇾","alpha_3":"CYM"},"DK":{"flag":"🇩🇰","alpha_3":"DNK"},"BZ":{"flag":"🇧🇿","alpha_3":"BLZ"},"FO":{"flag":"🇫🇴","alpha_3":"FRO"},"LA":{"flag":"🇱🇦","alpha_3":"LAO"},"RO":{"flag":"🇷🇴","alpha_3":"ROU"},"DJ":{"flag":"🇩🇯","alpha_3":"DJI"},"EG":{"flag":"🇪🇬","alpha_3":"EGY"},"KE":{"flag":"🇰🇪","alpha_3":"KEN"},"UG":{"flag":"🇺🇬","alpha_3":"UGA"},"MM":{"flag":"🇲🇲","alpha_3":"MMR"},"BQ":{"flag":"🇧🇶","alpha_3":"BES"},"PM":{"flag":"🇵🇲","alpha_3":"SPM"},"GD":{"flag":"🇬🇩","alpha_3":"GRD"},"GU":{"flag":"🇬🇺","alpha_3":"GUM"},"CN":{"flag":"🇨🇳","alpha_3":"CHN"},"SO":{"flag":"🇸🇴","alpha_3":"SOM"},"BJ":{"flag":"🇧🇯","alpha_3":"BEN"},"BR":{"flag":"🇧🇷","alpha_3":"BRA"},"GA":{"flag":"🇬🇦","alpha_3":"GAB"},"NZ":{"flag":"🇳🇿","alpha_3":"NZL"},"MG":{"flag":"🇲🇬","alpha_3":"MDG"},"IT":{"flag":"🇮🇹","alpha_3":"ITA"},"TF":{"flag":"🇹🇫","alpha_3":"ATF"}} No newline at end of file
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.

Some formatting would be nice.

dimensions={reportConfig.dimensions}
metrics={metrics}
defaultOrderBy={[['visitors', 'desc']]}
searchEnabled={false}
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.

Should implement search.

import React from 'react'
import { COUNTRIES_BY_TWO_LETTER_CODE } from './countries'

export const FlagEmoji = ({ countryCode }: { countryCode: string | null }) => {
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.

Let's make sure that this is never underlined when the filter link is hovered.

hasConversionGoalFilter: hasConversionGoalFilter(dashboardState),
isRealtime: isRealTimeDashboard(dashboardState),
isDetailed: true,
isRevenueAvailable: false
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.

It looks like we missed this from DevicesDetails too. Should use:

/*global BUILD_EXTRA*/
const isRevenueAvailable =
  BUILD_EXTRA && revenueAvailable(dashboardState, site)

Index views never show revenue metrics, so it's correct to just send isRevenueAvailable: false, all details views do show revenue metrics though, as long as there's a goal filter.

Comment on lines +103 to +110
if (
(currentTab === BreakdownReportKey.regions ||
currentTab === BreakdownReportKey.cities) &&
prev.countryFiltersApplied &&
!countryFiltersApplied
) {
return prefersCountriesList ? BreakdownReportKey.countries : 'map'
}
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.

I believe this is different than on prod:

Scenario: Add country filter -> add region filter -> remove country filter
This PR: tab switches to Countries (probably containing the single country whose region we're still filtering by)
Master: tab remains Cities (much more useful information there)

While in practice it's pretty rare for a user to filter like that, I think we should not jump tabs unless there's a very specific reason for that.

That said though, I also see how your implemented approach might have a benefit:

Scenario: Add country filter -> switch tab to cities -> Remove country filter
This PR: tab changes back to Countries (would probably feel useful as the same happens with regions)
Master: tab remains Cities

But perhaps let's keep it simple for now and leave this PR a pure refactor?IMHO completely fine for this automatic tab switch to stop triggering if the user manually selects a tab.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants