@@ -11,6 +11,7 @@ import {tabsShouldForwardProp} from 'sentry/components/tabs/utils';
1111import { t } from 'sentry/locale' ;
1212import type { InjectedRouter } from 'sentry/types/legacyReactRouter' ;
1313import { defined } from 'sentry/utils' ;
14+ import { trackAnalytics } from 'sentry/utils/analytics' ;
1415import normalizeUrl from 'sentry/utils/url/normalizeUrl' ;
1516import { useNavigate } from 'sentry/utils/useNavigate' ;
1617import useOrganization from 'sentry/utils/useOrganization' ;
@@ -129,6 +130,18 @@ export type IssueViewsActions =
129130 | SetViewsAction
130131 | SyncViewsToBackendAction ;
131132
133+ const ACTION_ANALYTICS_MAP : Partial < Record < IssueViewsActions [ 'type' ] , string > > = {
134+ REORDER_TABS : 'issue_views.reordered_views' ,
135+ SAVE_CHANGES : 'issue_views.saved_changes' ,
136+ DISCARD_CHANGES : 'issue_views.discarded_changes' ,
137+ RENAME_TAB : 'issue_views.renamed_view' ,
138+ DUPLICATE_VIEW : 'issue_views.duplicated_view' ,
139+ DELETE_VIEW : 'issue_views.deleted_view' ,
140+ SAVE_TEMP_VIEW : 'issue_views.temp_view_saved' ,
141+ DISCARD_TEMP_VIEW : 'issue_views.temp_view_discarded' ,
142+ CREATE_NEW_VIEW : 'issue_views.add_view.clicked' ,
143+ } ;
144+
132145export interface IssueViewsState {
133146 views : IssueView [ ] ;
134147 tempView ?: IssueView ;
@@ -494,9 +507,17 @@ export function IssueViewsStateProvider({
494507 const dispatchWrapper = ( action : IssueViewsActions ) => {
495508 const newState = reducer ( state , action ) ;
496509 dispatch ( action ) ;
510+
497511 if ( action . type === 'SYNC_VIEWS_TO_BACKEND' || action . syncViews ) {
498512 debounceUpdateViews ( newState . views ) ;
499513 }
514+
515+ const actionAnalyticsKey = ACTION_ANALYTICS_MAP [ action . type ] ;
516+ if ( actionAnalyticsKey ) {
517+ trackAnalytics ( actionAnalyticsKey , {
518+ organization,
519+ } ) ;
520+ }
500521 } ;
501522
502523 return (
0 commit comments