@@ -86,6 +86,7 @@ import {DiscoverQueryPageSource} from 'sentry/views/performance/utils';
8686
8787import { PrebuiltDashboardOnboardingGate } from './components/prebuiltDashboardOnboardingGate' ;
8888import { Controls } from './controls' ;
89+ import { validateDashboardAndRecordMetrics } from './createFromSeerUtils' ;
8990import { Dashboard } from './dashboard' ;
9091import { DashboardEditSeerChat } from './dashboardEditSeerChat' ;
9192import { DEFAULT_STATS_PERIOD } from './data' ;
@@ -158,6 +159,8 @@ type State = {
158159 isSavingDashboardFilters : boolean ;
159160 isWidgetBuilderOpen : boolean ;
160161 modifiedDashboard : DashboardDetails | null ;
162+ seerEditApplied : boolean ;
163+ seerRunId : number | null ;
161164 widgetLegendState : WidgetLegendSelectionState ;
162165 widgetLimitReached : boolean ;
163166 newlyAddedWidget ?: Widget ;
@@ -214,6 +217,8 @@ class DashboardDetail extends Component<Props, State> {
214217 openWidgetTemplates : undefined ,
215218 newlyAddedWidget : undefined ,
216219 isCommittingChanges : false ,
220+ seerEditApplied : false ,
221+ seerRunId : null ,
217222 } ;
218223
219224 componentDidMount ( ) {
@@ -856,6 +861,18 @@ class DashboardDetail extends Component<Props, State> {
856861 ( newDashboard : DashboardDetails ) => {
857862 addSuccessMessage ( t ( 'Dashboard created' ) ) ;
858863 trackAnalytics ( 'dashboards2.create.complete' , { organization} ) ;
864+ const seerRunId = location . query ?. seerRunId
865+ ? Number ( location . query . seerRunId )
866+ : null ;
867+ if ( seerRunId ) {
868+ Sentry . metrics . count ( 'dashboards.seer.create.save' , 1 , {
869+ attributes : {
870+ organization_slug : organization . slug ,
871+ dashboard_id : newDashboard . id ,
872+ seer_run_id : seerRunId ,
873+ } ,
874+ } ) ;
875+ }
859876 this . setState (
860877 {
861878 dashboardState : DashboardState . VIEW ,
@@ -899,6 +916,8 @@ class DashboardDetail extends Component<Props, State> {
899916 this . setState ( {
900917 dashboardState : DashboardState . VIEW ,
901918 modifiedDashboard : null ,
919+ seerEditApplied : false ,
920+ seerRunId : null ,
902921 } ) ;
903922 return ;
904923 }
@@ -912,11 +931,22 @@ class DashboardDetail extends Component<Props, State> {
912931 }
913932 addSuccessMessage ( t ( 'Dashboard updated' ) ) ;
914933 trackAnalytics ( 'dashboards2.edit.complete' , { organization} ) ;
934+ if ( this . state . seerEditApplied && this . state . seerRunId ) {
935+ Sentry . metrics . count ( 'dashboards.seer.edit.save' , 1 , {
936+ attributes : {
937+ organization_slug : organization . slug ,
938+ dashboard_id : newDashboard . id ,
939+ seer_run_id : this . state . seerRunId ,
940+ } ,
941+ } ) ;
942+ }
915943 this . setState (
916944 {
917945 dashboardState : DashboardState . VIEW ,
918946 modifiedDashboard : null ,
919947 isCommittingChanges : false ,
948+ seerEditApplied : false ,
949+ seerRunId : null ,
920950 } ,
921951 ( ) => {
922952 if ( dashboard && newDashboard . id !== dashboard . id ) {
@@ -941,6 +971,8 @@ class DashboardDetail extends Component<Props, State> {
941971 this . setState ( {
942972 dashboardState : DashboardState . VIEW ,
943973 modifiedDashboard : null ,
974+ seerEditApplied : false ,
975+ seerRunId : null ,
944976 } ) ;
945977 break ;
946978 }
@@ -949,6 +981,8 @@ class DashboardDetail extends Component<Props, State> {
949981 this . setState ( {
950982 dashboardState : DashboardState . VIEW ,
951983 modifiedDashboard : null ,
984+ seerEditApplied : false ,
985+ seerRunId : null ,
952986 } ) ;
953987 break ;
954988 }
@@ -961,21 +995,37 @@ class DashboardDetail extends Component<Props, State> {
961995 } ) ;
962996 } ;
963997
964- handleSeerDashboardUpdate = ( {
965- title,
966- widgets ,
967- } : Pick < DashboardDetails , 'title' | 'widgets' > ) => {
968- this . setState ( state => {
969- const dashboard = cloneDashboard ( state . modifiedDashboard ?? this . props . dashboard ) ;
970- return {
971- widgetLimitReached : widgets . length >= MAX_WIDGETS ,
972- modifiedDashboard : {
998+ handleSeerDashboardUpdate = (
999+ { title, widgets } : Pick < DashboardDetails , 'title' | 'widgets' > ,
1000+ seerRunId : number | null
1001+ ) => {
1002+ const { organization } = this . props ;
1003+ this . setState (
1004+ state => {
1005+ const dashboard = cloneDashboard ( state . modifiedDashboard ?? this . props . dashboard ) ;
1006+ const updatedDashboard = {
9731007 ...dashboard ,
9741008 widgets,
9751009 ...( title === undefined ? { } : { title} ) ,
976- } ,
977- } ;
978- } ) ;
1010+ } ;
1011+ return {
1012+ widgetLimitReached : widgets . length >= MAX_WIDGETS ,
1013+ seerEditApplied : true ,
1014+ seerRunId,
1015+ modifiedDashboard : updatedDashboard ,
1016+ } ;
1017+ } ,
1018+ ( ) => {
1019+ if ( this . state . modifiedDashboard ) {
1020+ validateDashboardAndRecordMetrics ( {
1021+ organization,
1022+ dashboard : this . state . modifiedDashboard ,
1023+ seerRunId,
1024+ source : 'edit' ,
1025+ } ) ;
1026+ }
1027+ }
1028+ ) ;
9791029 } ;
9801030
9811031 handleUpdateEditStateWidgets = ( widgets : Widget [ ] ) => {
0 commit comments