-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
ref(issue-details): Allows replays section to reflect filters #81128
Draft
leeandher
wants to merge
10
commits into
master
Choose a base branch
from
leander/replay-use-query
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+136
−15
Draft
Changes from 6 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
f7501a6
♻️ Allow replay dropdown to use query
leeandher 24281af
🚧 WIP get replays simplified
leeandher a4561bd
✨ Better hooks and replay loading
leeandher ca30f22
:hammer_and_wrench: apply pre-commit fixes
getsantry[bot] ed87fe2
✨ Use the correct event counts
leeandher 829085b
✨ Use the correct event counts
leeandher c33460a
:hammer_and_wrench: apply pre-commit fixes
getsantry[bot] 3e25925
Merge branch 'master' into leander/replay-use-query
leeandher d953aac
✅ Fix groupReplays
leeandher 44eb248
Merge branch 'master' into leander/replay-use-query
leeandher File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
static/app/views/issueDetails/streamline/useIssueDetailsEventCount.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import {type Group} from 'sentry/types/group'; | ||
import { | ||
useIssueDetailsDiscoverQuery, | ||
useIssueDetailsEventView, | ||
} from 'sentry/views/issueDetails/streamline/useIssueDetailsDiscoverQuery'; | ||
import {MultiSeriesEventsStats} from 'sentry/types/organization'; | ||
import {useMemo} from 'react'; | ||
|
||
export function useIssueDetailsEventCount({group}: {group: Group}) { | ||
const eventView = useIssueDetailsEventView({group}); | ||
const {data: groupStats} = useIssueDetailsDiscoverQuery<MultiSeriesEventsStats>({ | ||
params: { | ||
route: 'events-stats', | ||
eventView, | ||
referrer: 'issue_details.streamline_graph', | ||
}, | ||
}); | ||
const eventCount = useMemo(() => { | ||
if (!groupStats?.['count()']) { | ||
return 0; | ||
} | ||
return groupStats['count()']?.data?.reduce((count, [_timestamp, countData]) => { | ||
return count + (countData?.[0]?.count ?? 0); | ||
}, 0); | ||
}, [groupStats]); | ||
return eventCount; | ||
} | ||
58 changes: 58 additions & 0 deletions
58
static/app/views/issueDetails/streamline/useIssueDetailsReplayCount.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import {type Group, IssueCategory} from 'sentry/types/group'; | ||
import { | ||
type ApiQueryKey, | ||
useApiQuery, | ||
type UseApiQueryOptions, | ||
} from 'sentry/utils/queryClient'; | ||
import useOrganization from 'sentry/utils/useOrganization'; | ||
import {useEventQuery} from 'sentry/views/issueDetails/streamline/eventSearch'; | ||
import {useIssueDetailsEventView} from 'sentry/views/issueDetails/streamline/useIssueDetailsDiscoverQuery'; | ||
|
||
interface ReplayIdsParameters { | ||
orgSlug: string; | ||
query: { | ||
data_source: 'discover' | 'search_issues'; | ||
query: string; | ||
statsPeriod: string; | ||
environment?: string[]; | ||
returnIds?: boolean; | ||
}; | ||
} | ||
|
||
export type ReplayCount = Record<string, number>; | ||
export type ReplayIds = Record<string, string[]>; | ||
|
||
function makeReplayCountQueryKey({orgSlug, query}: ReplayIdsParameters): ApiQueryKey { | ||
return [`/organizations/${orgSlug}/replay-count/`, {query}]; | ||
} | ||
|
||
function useReplayCount<T>( | ||
params: ReplayIdsParameters, | ||
options: Partial<UseApiQueryOptions<T>> = {} | ||
) { | ||
return useApiQuery<T>(makeReplayCountQueryKey(params), { | ||
staleTime: Infinity, | ||
retry: false, | ||
...options, | ||
}); | ||
} | ||
|
||
export function useIssueDetailsReplayCount<T extends ReplayCount | ReplayIds>({ | ||
group, | ||
}: { | ||
group: Group; | ||
}) { | ||
const organization = useOrganization(); | ||
const searchQuery = useEventQuery({group}); | ||
const eventView = useIssueDetailsEventView({group}); | ||
return useReplayCount<T>({ | ||
orgSlug: organization.slug, | ||
query: { | ||
data_source: | ||
group.issueCategory === IssueCategory.ERROR ? 'discover' : 'search_issues', | ||
statsPeriod: eventView.statsPeriod ?? '90d', | ||
environment: [...eventView.environment], | ||
query: `issue.id:[${group.id}] ${searchQuery}`, | ||
}, | ||
}); | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This kinda sucks it's the entire query for a timeseries that I iterate over to create a count.
There is definitely an easier way, but I couldn't figure out the discover syntax to get there.