Skip to content

fix(replay): Filter empty querystring params from replay list api call #69007

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion static/app/utils/queryClient.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export const DEFAULT_QUERY_CLIENT_CONFIG: QueryClientConfig = {
// [0]: https://tanstack.com/query/v4/docs/guides/query-cancellation#default-behavior
const PERSIST_IN_FLIGHT = true;

type QueryKeyEndpointOptions<
export type QueryKeyEndpointOptions<
Headers = Record<string, string>,
Query = Record<string, any>,
Data = Record<string, any>,
Expand Down
26 changes: 23 additions & 3 deletions static/app/utils/replays/hooks/useFetchReplayList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,32 @@ import {useMemo} from 'react';
import {ALL_ACCESS_PROJECTS} from 'sentry/constants/pageFilters';
import type {Organization} from 'sentry/types';
import {uniq} from 'sentry/utils/array/uniq';
import {type ApiQueryKey, useApiQuery} from 'sentry/utils/queryClient';
import {
type ApiQueryKey,
type QueryKeyEndpointOptions,
useApiQuery,
} from 'sentry/utils/queryClient';
import {mapResponseToReplayRecord} from 'sentry/utils/replays/replayDataUtils';
import {
REPLAY_LIST_FIELDS,
type ReplayListQueryReferrer,
type ReplayListRecord,
} from 'sentry/views/replays/types';

interface QueryOptions {
cursor?: string;
end?: string;
environment?: string[];
project?: string[];
query?: string;
sort?: string;
start?: string;
statsPeriod?: string;
utc?: string;
}

type Options = {
options: ApiQueryKey[1];
options: QueryKeyEndpointOptions<Record<string, string>, QueryOptions, never>;
organization: Organization;
queryReferrer: ReplayListQueryReferrer;
};
Expand Down Expand Up @@ -40,13 +56,17 @@ export default function useFetchReplayList({
queryReferrer === 'issueReplays' || queryReferrer === 'transactionReplays'
? ALL_ACCESS_PROJECTS
: originalProject;

const query = Object.fromEntries(
Object.entries(options.query).filter(([_key, val]) => val !== '')
);
return [
url,
{
...options,
query: {
per_page: 50,
...options.query,
...query,
fields,
project,
queryReferrer,
Expand Down
4 changes: 4 additions & 0 deletions static/app/views/replays/list/replaysList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,14 @@ function ReplaysList() {
const query = useLocationQuery({
fields: {
cursor: decodeScalar,
end: decodeScalar,
environment: decodeList,
project: decodeList,
query: decodeScalar,
sort: value => decodeScalar(value, '-started_at'),
start: decodeScalar,
statsPeriod: decodeScalar,
utc: decodeScalar,
},
});

Expand Down