@@ -12,12 +12,29 @@ import useOrganization from 'sentry/utils/useOrganization';
1212interface UseDetectorsQueryKeyOptions {
1313 cursor ?: string ;
1414 ids ?: string [ ] ;
15+ /**
16+ * By default, issue stream detectors are excluded from the query,
17+ * because they are opaque to the user in the UI and only used to
18+ * make connections to alerts.
19+ */
20+ includeIssueStreamDetectors ?: boolean ;
1521 limit ?: number ;
1622 projects ?: number [ ] ;
1723 query ?: string ;
1824 sortBy ?: string ;
1925}
2026
27+ const createDetectorQuery = (
28+ query : string | undefined ,
29+ options : { includeIssueStreamDetectors : boolean }
30+ ) => {
31+ if ( options . includeIssueStreamDetectors ) {
32+ return query ;
33+ }
34+
35+ return `!type:issue_stream ${ query ?? '' } ` . trim ( ) ;
36+ } ;
37+
2138export const makeDetectorListQueryKey = ( {
2239 orgSlug,
2340 query,
@@ -26,21 +43,40 @@ export const makeDetectorListQueryKey = ({
2643 limit,
2744 cursor,
2845 ids,
46+ includeIssueStreamDetectors = false ,
2947} : {
3048 orgSlug : string ;
3149 cursor ?: string ;
3250 ids ?: string [ ] ;
51+ includeIssueStreamDetectors ?: boolean ;
3352 limit ?: number ;
3453 projects ?: number [ ] ;
3554 query ?: string ;
3655 sortBy ?: string ;
3756} ) : ApiQueryKey => [
3857 `/organizations/${ orgSlug } /detectors/` ,
39- { query : { query, sortBy, project : projects , per_page : limit , cursor, id : ids } } ,
58+ {
59+ query : {
60+ query : createDetectorQuery ( query , { includeIssueStreamDetectors} ) ,
61+ sortBy,
62+ project : projects ,
63+ per_page : limit ,
64+ cursor,
65+ id : ids ,
66+ } ,
67+ } ,
4068] ;
4169
4270export function useDetectorsQuery < T extends Detector = Detector > (
43- { ids, query, sortBy, projects, limit, cursor} : UseDetectorsQueryKeyOptions = { } ,
71+ {
72+ ids,
73+ query,
74+ sortBy,
75+ projects,
76+ limit,
77+ cursor,
78+ includeIssueStreamDetectors,
79+ } : UseDetectorsQueryKeyOptions = { } ,
4480 queryOptions : Partial < UseApiQueryOptions < T [ ] > > = { }
4581) {
4682 const org = useOrganization ( ) ;
@@ -54,6 +90,7 @@ export function useDetectorsQuery<T extends Detector = Detector>(
5490 limit,
5591 cursor,
5692 ids,
93+ includeIssueStreamDetectors,
5794 } ) ,
5895 {
5996 staleTime : 0 ,
0 commit comments