@@ -43,18 +43,18 @@ import {
4343 PROFILING_FIELDS ,
4444 TRACING_FIELDS ,
4545} from 'sentry/utils/discover/fields' ;
46- import type { DisplayModes } from 'sentry/utils/discover/types' ;
47- import { TOP_N } from 'sentry/utils/discover/types' ;
46+ import { type DisplayModes , SavedQueryDatasets , TOP_N } from 'sentry/utils/discover/types' ;
4847import { getTitle } from 'sentry/utils/events' ;
4948import { DISCOVER_FIELDS , FieldValueType , getFieldDefinition } from 'sentry/utils/fields' ;
5049import localStorage from 'sentry/utils/localStorage' ;
5150import { MutableSearch } from 'sentry/utils/tokenizeSearch' ;
51+ import { DataSet } from 'sentry/views/dashboards/widgetBuilder/utils' ;
5252
5353import type { WidgetQuery } from '../dashboards/types' ;
5454import { DashboardWidgetSource , DisplayType } from '../dashboards/types' ;
5555import { transactionSummaryRouteWithQuery } from '../performance/transactionSummary/utils' ;
5656
57- import { displayModeToDisplayType } from './savedQuery/utils' ;
57+ import { displayModeToDisplayType , getSavedQueryDataset } from './savedQuery/utils' ;
5858import type { FieldValue , TableColumn } from './table/types' ;
5959import { FieldValueKind } from './table/types' ;
6060import { ALL_VIEWS , TRANSACTION_VIEWS , WEB_VITALS_VIEWS } from './data' ;
@@ -695,6 +695,8 @@ export function handleAddQueryToDashboard({
695695 yAxis,
696696 } ) ;
697697
698+ const dataset = getSavedQueryDataset ( location , query ) ;
699+
698700 const { query : widgetAsQueryParams } = constructAddQueryToDashboardLink ( {
699701 eventView,
700702 query,
@@ -728,6 +730,9 @@ export function handleAddQueryToDashboard({
728730 displayType === DisplayType . TOP_N
729731 ? Number ( eventView . topEvents ) || TOP_N
730732 : undefined ,
733+ widgetType : organization . features . includes ( 'performance-discover-dataset-selector' )
734+ ? getWidgetDataset ( dataset )
735+ : undefined ,
731736 } ,
732737 router,
733738 widgetAsQueryParams,
@@ -793,6 +798,8 @@ export function constructAddQueryToDashboardLink({
793798 displayType,
794799 yAxis,
795800 } ) ;
801+ const dataset = getSavedQueryDataset ( location , query ) ;
802+
796803 const defaultTitle =
797804 query ?. name ?? ( eventView . name !== 'All Events' ? eventView . name : undefined ) ;
798805
@@ -808,10 +815,25 @@ export function constructAddQueryToDashboardLink({
808815 defaultTableColumns : defaultTableFields ,
809816 defaultTitle,
810817 displayType : displayType === DisplayType . TOP_N ? DisplayType . AREA : displayType ,
818+ dataset : organization . features . includes ( 'performance-discover-dataset-selector' )
819+ ? getWidgetDataset ( dataset )
820+ : undefined ,
811821 limit :
812822 displayType === DisplayType . TOP_N
813823 ? Number ( eventView . topEvents ) || TOP_N
814824 : undefined ,
815825 } ,
816826 } ;
817827}
828+ function getWidgetDataset ( dataset : SavedQueryDatasets ) {
829+ switch ( dataset ) {
830+ case SavedQueryDatasets . TRANSACTIONS :
831+ return DataSet . TRANSACTIONS ;
832+
833+ case SavedQueryDatasets . ERRORS :
834+ return DataSet . ERRORS ;
835+
836+ default :
837+ return undefined ;
838+ }
839+ }
0 commit comments