diff --git a/static/app/views/issueList/groupSearchViewTabs/issueViews.tsx b/static/app/views/issueList/groupSearchViewTabs/issueViews.tsx index 965a1e6c7ab717..d9e477533878b1 100644 --- a/static/app/views/issueList/groupSearchViewTabs/issueViews.tsx +++ b/static/app/views/issueList/groupSearchViewTabs/issueViews.tsx @@ -11,6 +11,7 @@ import {tabsShouldForwardProp} from 'sentry/components/tabs/utils'; import {t} from 'sentry/locale'; import type {InjectedRouter} from 'sentry/types/legacyReactRouter'; import {defined} from 'sentry/utils'; +import {trackAnalytics} from 'sentry/utils/analytics'; import normalizeUrl from 'sentry/utils/url/normalizeUrl'; import {useNavigate} from 'sentry/utils/useNavigate'; import useOrganization from 'sentry/utils/useOrganization'; @@ -129,6 +130,18 @@ export type IssueViewsActions = | SetViewsAction | SyncViewsToBackendAction; +const ACTION_ANALYTICS_MAP: Partial> = { + REORDER_TABS: 'issue_views.reordered_views', + SAVE_CHANGES: 'issue_views.saved_changes', + DISCARD_CHANGES: 'issue_views.discarded_changes', + RENAME_TAB: 'issue_views.renamed_view', + DUPLICATE_VIEW: 'issue_views.duplicated_view', + DELETE_VIEW: 'issue_views.deleted_view', + SAVE_TEMP_VIEW: 'issue_views.temp_view_saved', + DISCARD_TEMP_VIEW: 'issue_views.temp_view_discarded', + CREATE_NEW_VIEW: 'issue_views.add_view.clicked', +}; + export interface IssueViewsState { views: IssueView[]; tempView?: IssueView; @@ -494,9 +507,17 @@ export function IssueViewsStateProvider({ const dispatchWrapper = (action: IssueViewsActions) => { const newState = reducer(state, action); dispatch(action); + if (action.type === 'SYNC_VIEWS_TO_BACKEND' || action.syncViews) { debounceUpdateViews(newState.views); } + + const actionAnalyticsKey = ACTION_ANALYTICS_MAP[action.type]; + if (actionAnalyticsKey) { + trackAnalytics(actionAnalyticsKey, { + organization, + }); + } }; return (