Skip to content

Commit 60f41ee

Browse files
authored
fix(replay): Filter empty querystring params from replay list api call (#69007)
Following up on #68849 This filters empty query params, which don't need to be sent to the server. Also in #68849 i missed a few important fields in the list.
1 parent 594a67c commit 60f41ee

File tree

3 files changed

+28
-4
lines changed

3 files changed

+28
-4
lines changed

static/app/utils/queryClient.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export const DEFAULT_QUERY_CLIENT_CONFIG: QueryClientConfig = {
4040
// [0]: https://tanstack.com/query/v4/docs/guides/query-cancellation#default-behavior
4141
const PERSIST_IN_FLIGHT = true;
4242

43-
type QueryKeyEndpointOptions<
43+
export type QueryKeyEndpointOptions<
4444
Headers = Record<string, string>,
4545
Query = Record<string, any>,
4646
Data = Record<string, any>,

static/app/utils/replays/hooks/useFetchReplayList.ts

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,32 @@ import {useMemo} from 'react';
33
import {ALL_ACCESS_PROJECTS} from 'sentry/constants/pageFilters';
44
import type {Organization} from 'sentry/types';
55
import {uniq} from 'sentry/utils/array/uniq';
6-
import {type ApiQueryKey, useApiQuery} from 'sentry/utils/queryClient';
6+
import {
7+
type ApiQueryKey,
8+
type QueryKeyEndpointOptions,
9+
useApiQuery,
10+
} from 'sentry/utils/queryClient';
711
import {mapResponseToReplayRecord} from 'sentry/utils/replays/replayDataUtils';
812
import {
913
REPLAY_LIST_FIELDS,
1014
type ReplayListQueryReferrer,
1115
type ReplayListRecord,
1216
} from 'sentry/views/replays/types';
1317

18+
interface QueryOptions {
19+
cursor?: string;
20+
end?: string;
21+
environment?: string[];
22+
project?: string[];
23+
query?: string;
24+
sort?: string;
25+
start?: string;
26+
statsPeriod?: string;
27+
utc?: string;
28+
}
29+
1430
type Options = {
15-
options: ApiQueryKey[1];
31+
options: QueryKeyEndpointOptions<Record<string, string>, QueryOptions, never>;
1632
organization: Organization;
1733
queryReferrer: ReplayListQueryReferrer;
1834
};
@@ -40,13 +56,17 @@ export default function useFetchReplayList({
4056
queryReferrer === 'issueReplays' || queryReferrer === 'transactionReplays'
4157
? ALL_ACCESS_PROJECTS
4258
: originalProject;
59+
60+
const query = Object.fromEntries(
61+
Object.entries(options.query).filter(([_key, val]) => val !== '')
62+
);
4363
return [
4464
url,
4565
{
4666
...options,
4767
query: {
4868
per_page: 50,
49-
...options.query,
69+
...query,
5070
fields,
5171
project,
5272
queryReferrer,

static/app/views/replays/list/replaysList.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,14 @@ function ReplaysList() {
2424
const query = useLocationQuery({
2525
fields: {
2626
cursor: decodeScalar,
27+
end: decodeScalar,
28+
environment: decodeList,
2729
project: decodeList,
2830
query: decodeScalar,
2931
sort: value => decodeScalar(value, '-started_at'),
32+
start: decodeScalar,
3033
statsPeriod: decodeScalar,
34+
utc: decodeScalar,
3135
},
3236
});
3337

0 commit comments

Comments
 (0)