From 1f0945138f9a613ef0b62243c5c619840d201478 Mon Sep 17 00:00:00 2001 From: Ryan Albrecht Date: Tue, 12 May 2026 14:26:26 -0700 Subject: [PATCH 1/3] ref(explore): Remove getQueryFromLocation and inline at callsites --- static/app/views/explore/logs/logsQueryParams.tsx | 3 +-- static/app/views/explore/queryParams/query.ts | 8 -------- .../explore/replays/list/replayQueryParamsProvider.tsx | 4 ++-- static/app/views/explore/spans/spansQueryParams.tsx | 4 ++-- 4 files changed, 5 insertions(+), 14 deletions(-) diff --git a/static/app/views/explore/logs/logsQueryParams.tsx b/static/app/views/explore/logs/logsQueryParams.tsx index 8a7f82212388..bb05588f3e9d 100644 --- a/static/app/views/explore/logs/logsQueryParams.tsx +++ b/static/app/views/explore/logs/logsQueryParams.tsx @@ -31,7 +31,6 @@ import { isGroupBy, } from 'sentry/views/explore/queryParams/groupBy'; import {getModeFromLocation} from 'sentry/views/explore/queryParams/mode'; -import {getQueryFromLocation} from 'sentry/views/explore/queryParams/query'; import {ReadableQueryParams} from 'sentry/views/explore/queryParams/readableQueryParams'; import { getIdFromLocation, @@ -58,7 +57,7 @@ export function getReadableQueryParamsFromLocation( location: Location ): ReadableQueryParams { const mode = getModeFromLocation(location, LOGS_MODE_KEY); - const query = getQueryFromLocation(location, LOGS_QUERY_KEY) ?? ''; + const query = decodeScalar(location.query?.[LOGS_QUERY_KEY]) ?? ''; const cursor = getCursorFromLocation(location, LOGS_CURSOR_KEY); const fields = getFieldsFromLocation(location, LOGS_FIELDS_KEY) ?? defaultLogFields(); diff --git a/static/app/views/explore/queryParams/query.ts b/static/app/views/explore/queryParams/query.ts index c5e5c536fae2..4c32413d6214 100644 --- a/static/app/views/explore/queryParams/query.ts +++ b/static/app/views/explore/queryParams/query.ts @@ -1,11 +1,3 @@ -import type {Location} from 'history'; - -import {decodeScalar} from 'sentry/utils/queryString'; - export function defaultQuery(): string { return ''; } - -export function getQueryFromLocation(location: Location, key: string) { - return decodeScalar(location.query?.[key]); -} diff --git a/static/app/views/explore/replays/list/replayQueryParamsProvider.tsx b/static/app/views/explore/replays/list/replayQueryParamsProvider.tsx index afbb2087199b..421c363088f7 100644 --- a/static/app/views/explore/replays/list/replayQueryParamsProvider.tsx +++ b/static/app/views/explore/replays/list/replayQueryParamsProvider.tsx @@ -2,12 +2,12 @@ import type {ReactNode} from 'react'; import {useCallback, useMemo} from 'react'; import type {Location} from 'history'; +import {decodeScalar} from 'sentry/utils/queryString'; import {updateNullableLocation} from 'sentry/utils/url/updateNullableLocation'; import {useLocation} from 'sentry/utils/useLocation'; import {useNavigate} from 'sentry/utils/useNavigate'; import {Mode} from 'sentry/views/explore/contexts/pageParamsContext/mode'; import {QueryParamsContextProvider} from 'sentry/views/explore/queryParams/context'; -import {getQueryFromLocation} from 'sentry/views/explore/queryParams/query'; import {ReadableQueryParams} from 'sentry/views/explore/queryParams/readableQueryParams'; import { getIdFromLocation, @@ -20,7 +20,7 @@ import type {WritableQueryParams} from 'sentry/views/explore/queryParams/writabl const REPLAY_QUERY_KEY = 'query'; function getReadableQueryParamsFromLocation(location: Location): ReadableQueryParams { - const query = getQueryFromLocation(location, REPLAY_QUERY_KEY) ?? ''; + const query = decodeScalar(location.query?.[REPLAY_QUERY_KEY]) ?? ''; const id = getIdFromLocation(location, ID_KEY); const title = getTitleFromLocation(location, TITLE_KEY); diff --git a/static/app/views/explore/spans/spansQueryParams.tsx b/static/app/views/explore/spans/spansQueryParams.tsx index 5975529a579d..2e66edf50c53 100644 --- a/static/app/views/explore/spans/spansQueryParams.tsx +++ b/static/app/views/explore/spans/spansQueryParams.tsx @@ -3,6 +3,7 @@ import type {Location} from 'history'; import {defined} from 'sentry/utils'; import type {Sort} from 'sentry/utils/discover/fields'; import {DiscoverDatasets} from 'sentry/utils/discover/types'; +import {decodeScalar} from 'sentry/utils/queryString'; import {updateNullableLocation} from 'sentry/utils/url/updateNullableLocation'; import {DEFAULT_VISUALIZATION} from 'sentry/views/explore/contexts/pageParamsContext/visualizes'; import type {AggregateField} from 'sentry/views/explore/queryParams/aggregateField'; @@ -18,7 +19,6 @@ import { isGroupBy, } from 'sentry/views/explore/queryParams/groupBy'; import {getModeFromLocation} from 'sentry/views/explore/queryParams/mode'; -import {getQueryFromLocation} from 'sentry/views/explore/queryParams/query'; import {ReadableQueryParams} from 'sentry/views/explore/queryParams/readableQueryParams'; import { getIdFromLocation, @@ -64,7 +64,7 @@ export function getReadableQueryParamsFromLocation( ): ReadableQueryParams { const extrapolate = getExtrapolateFromLocation(location, SPANS_EXTRAPOLATE_KEY); const mode = getModeFromLocation(location, SPANS_MODE_KEY); - const query = getQueryFromLocation(location, SPANS_QUERY_KEY) ?? ''; + const query = decodeScalar(location.query?.[SPANS_QUERY_KEY]) ?? ''; const cursor = getCursorFromLocation(location, SPANS_CURSOR_KEY); const fields = getFieldsFromLocation(location, SPANS_FIELD_KEY) ?? defaultFields(); From c1e47e63c962818750414589546563668cc8d4cd Mon Sep 17 00:00:00 2001 From: Ryan Albrecht Date: Tue, 12 May 2026 14:54:39 -0700 Subject: [PATCH 2/3] ref(explore): Remove query.ts entirely, inline defaultQuery at callsite --- static/app/views/explore/exploreStateQueryParamsProvider.tsx | 3 +-- static/app/views/explore/queryParams/query.ts | 3 --- 2 files changed, 1 insertion(+), 5 deletions(-) delete mode 100644 static/app/views/explore/queryParams/query.ts diff --git a/static/app/views/explore/exploreStateQueryParamsProvider.tsx b/static/app/views/explore/exploreStateQueryParamsProvider.tsx index dcd887e3bac1..2af31ca090bc 100644 --- a/static/app/views/explore/exploreStateQueryParamsProvider.tsx +++ b/static/app/views/explore/exploreStateQueryParamsProvider.tsx @@ -7,7 +7,6 @@ import type {AggregateField} from 'sentry/views/explore/queryParams/aggregateFie import {QueryParamsContextProvider} from 'sentry/views/explore/queryParams/context'; import {defaultCursor} from 'sentry/views/explore/queryParams/cursor'; import {defaultMode} from 'sentry/views/explore/queryParams/mode'; -import {defaultQuery} from 'sentry/views/explore/queryParams/query'; import { ReadableQueryParams, type ReadableQueryParamsOptions, @@ -32,7 +31,7 @@ export function ExploreStateQueryParamsProvider({ frozenParams, }: ExploreStateQueryParamsProviderProps) { const [mode, _setMode] = useState(defaultMode()); - const [query, setQuery] = useResettableState(defaultQuery); + const [query, setQuery] = useResettableState(() => ''); const [cursor, _setCursor] = useState(defaultCursor()); const [fields, _setFields] = useState(defaultFields()); diff --git a/static/app/views/explore/queryParams/query.ts b/static/app/views/explore/queryParams/query.ts deleted file mode 100644 index 4c32413d6214..000000000000 --- a/static/app/views/explore/queryParams/query.ts +++ /dev/null @@ -1,3 +0,0 @@ -export function defaultQuery(): string { - return ''; -} From eb71862e537b83199c2767a83f7ac0843c10e9b8 Mon Sep 17 00:00:00 2001 From: Ryan Albrecht Date: Wed, 13 May 2026 09:04:12 -0700 Subject: [PATCH 3/3] Apply suggestions from code review Co-authored-by: Ryan Albrecht --- static/app/views/explore/logs/logsQueryParams.tsx | 2 +- .../views/explore/replays/list/replayQueryParamsProvider.tsx | 2 +- static/app/views/explore/spans/spansQueryParams.tsx | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/static/app/views/explore/logs/logsQueryParams.tsx b/static/app/views/explore/logs/logsQueryParams.tsx index bb05588f3e9d..914849c4acf4 100644 --- a/static/app/views/explore/logs/logsQueryParams.tsx +++ b/static/app/views/explore/logs/logsQueryParams.tsx @@ -57,7 +57,7 @@ export function getReadableQueryParamsFromLocation( location: Location ): ReadableQueryParams { const mode = getModeFromLocation(location, LOGS_MODE_KEY); - const query = decodeScalar(location.query?.[LOGS_QUERY_KEY]) ?? ''; + const query = decodeScalar(location.query[LOGS_QUERY_KEY]) ?? ''; const cursor = getCursorFromLocation(location, LOGS_CURSOR_KEY); const fields = getFieldsFromLocation(location, LOGS_FIELDS_KEY) ?? defaultLogFields(); diff --git a/static/app/views/explore/replays/list/replayQueryParamsProvider.tsx b/static/app/views/explore/replays/list/replayQueryParamsProvider.tsx index 421c363088f7..1093ff61666e 100644 --- a/static/app/views/explore/replays/list/replayQueryParamsProvider.tsx +++ b/static/app/views/explore/replays/list/replayQueryParamsProvider.tsx @@ -20,7 +20,7 @@ import type {WritableQueryParams} from 'sentry/views/explore/queryParams/writabl const REPLAY_QUERY_KEY = 'query'; function getReadableQueryParamsFromLocation(location: Location): ReadableQueryParams { - const query = decodeScalar(location.query?.[REPLAY_QUERY_KEY]) ?? ''; + const query = decodeScalar(location.query[REPLAY_QUERY_KEY]) ?? ''; const id = getIdFromLocation(location, ID_KEY); const title = getTitleFromLocation(location, TITLE_KEY); diff --git a/static/app/views/explore/spans/spansQueryParams.tsx b/static/app/views/explore/spans/spansQueryParams.tsx index 2e66edf50c53..bdf968ab86ce 100644 --- a/static/app/views/explore/spans/spansQueryParams.tsx +++ b/static/app/views/explore/spans/spansQueryParams.tsx @@ -64,7 +64,7 @@ export function getReadableQueryParamsFromLocation( ): ReadableQueryParams { const extrapolate = getExtrapolateFromLocation(location, SPANS_EXTRAPOLATE_KEY); const mode = getModeFromLocation(location, SPANS_MODE_KEY); - const query = decodeScalar(location.query?.[SPANS_QUERY_KEY]) ?? ''; + const query = decodeScalar(location.query[SPANS_QUERY_KEY]) ?? ''; const cursor = getCursorFromLocation(location, SPANS_CURSOR_KEY); const fields = getFieldsFromLocation(location, SPANS_FIELD_KEY) ?? defaultFields();