Skip to content

Commit

Permalink
chore(issue-views): Add analytics back to tab actions (#82504)
Browse files Browse the repository at this point in the history
I deleted some of the analytics calls in [this refactoring
change](#82429) and forgot to
add them back. This PR adds them back.

I found what the old analytics keys were
[here](https://github.com/getsentry/sentry/blob/7cb3a89c7a0737ea5c53ab0a1e85b03c7d8dd4ee/static/app/views/issueList/groupSearchViewTabs/draggableTabBar.tsx)
  • Loading branch information
MichaelSun48 authored Dec 20, 2024
1 parent 5739b53 commit 5bd1b24
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions static/app/views/issueList/groupSearchViewTabs/issueViews.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -129,6 +130,18 @@ export type IssueViewsActions =
| SetViewsAction
| SyncViewsToBackendAction;

const ACTION_ANALYTICS_MAP: Partial<Record<IssueViewsActions['type'], string>> = {
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;
Expand Down Expand Up @@ -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 (
Expand Down

0 comments on commit 5bd1b24

Please sign in to comment.