Browse Source

ref(sort): Remove a/b test for priority sort (#51481)

Remove usage of the experiment feature flag and logic for A/B testing
priority sort on the front end.

Backend PR: https://github.com/getsentry/sentry/pull/51478
getsentry PR: https://github.com/getsentry/getsentry/pull/10937
Colleen O'Rourke 1 year ago
parent
commit
22bd754b22

+ 3 - 2
static/app/components/modals/savedSearchModal/createSavedSearchModal.tsx

@@ -9,7 +9,6 @@ import {SavedSearchModalContent} from 'sentry/components/modals/savedSearchModal
 import {t} from 'sentry/locale';
 import {Organization, SavedSearchType, SavedSearchVisibility} from 'sentry/types';
 import {trackAnalytics} from 'sentry/utils/analytics';
-import {enablePrioritySortByDefault} from 'sentry/utils/prioritySort';
 import {useCreateSavedSearch} from 'sentry/views/issueList/mutations/useCreateSavedSearch';
 import {IssueSortOptions} from 'sentry/views/issueList/utils';
 
@@ -26,7 +25,9 @@ function validateSortOption({
   organization: Organization;
   sort?: string;
 }) {
-  const hasBetterPrioritySort = enablePrioritySortByDefault(organization);
+  const hasBetterPrioritySort = organization.features.includes(
+    'issue-list-better-priority-sort'
+  );
   const sortOptions = [
     ...(hasBetterPrioritySort ? [IssueSortOptions.BETTER_PRIORITY] : []), // show better priority for EA orgs
     IssueSortOptions.DATE,

+ 3 - 2
static/app/components/modals/savedSearchModal/savedSearchModalContent.tsx

@@ -4,7 +4,6 @@ import {SelectField, TextField} from 'sentry/components/forms';
 import FormField from 'sentry/components/forms/formField';
 import {t} from 'sentry/locale';
 import {Organization, SavedSearchVisibility} from 'sentry/types';
-import {enablePrioritySortByDefault} from 'sentry/utils/prioritySort';
 import IssueListSearchBar from 'sentry/views/issueList/searchBar';
 import {getSortLabel, IssueSortOptions} from 'sentry/views/issueList/utils';
 
@@ -19,7 +18,9 @@ const SELECT_FIELD_VISIBILITY_OPTIONS = [
 
 export function SavedSearchModalContent({organization}: SavedSearchModalContentProps) {
   const canChangeVisibility = organization.access.includes('org:write');
-  const hasBetterPrioritySort = enablePrioritySortByDefault(organization);
+  const hasBetterPrioritySort = organization.features.includes(
+    'issue-list-better-priority-sort'
+  );
 
   const sortOptions = [
     ...(hasBetterPrioritySort ? [IssueSortOptions.BETTER_PRIORITY] : []), // show better priority for EA orgs

+ 0 - 6
static/app/data/experimentConfig.tsx

@@ -30,12 +30,6 @@ export const experimentList = [
     parameter: 'exposed',
     assignments: [0, 1],
   },
-  {
-    key: 'PrioritySortExperiment',
-    type: ExperimentType.USER,
-    parameter: 'variant',
-    assignments: ['baseline', 'variant1', 'variant2'],
-  },
 ] as const;
 
 export const experimentConfig = experimentList.reduce(

+ 0 - 40
static/app/utils/prioritySort.tsx

@@ -1,40 +0,0 @@
-import ConfigStore from 'sentry/stores/configStore';
-import {Organization} from 'sentry/types';
-
-export function prioritySortExperimentEnabled(organization: Organization) {
-  /**
-   * Return true if the experiment is enabled for this organization and that we should log the experiment
-   */
-  return (
-    organization.isEarlyAdopter &&
-    organization.features.includes('better-priority-sort-experiment') &&
-    !organization.features.includes('issue-list-better-priority-sort') // exclude orgs explicitly on
-  );
-}
-
-export function getPrioritySortVariant(organization: Organization) {
-  /**
-   * Return the priority variant for this organization.
-   * If the experiment is not enabled, return undefined
-   */
-  const user = ConfigStore.get('user');
-  const _variant = user.experiments?.PrioritySortExperiment || 'baseline';
-
-  // check if the experiment is active
-  const isInExperiment = prioritySortExperimentEnabled(organization);
-
-  // feature flag override to force variant1
-  // otherwise let the experiment decide
-  return organization.features.includes('issue-list-better-priority-sort')
-    ? 'variant1'
-    : isInExperiment
-    ? _variant
-    : undefined;
-}
-
-export function enablePrioritySortByDefault(organization: Organization) {
-  /**
-   * Returns true if the new priority sort should be enabled by default
-   */
-  return getPrioritySortVariant(organization) !== undefined;
-}

+ 3 - 2
static/app/views/dashboards/datasetConfig/issues.tsx

@@ -6,7 +6,6 @@ import {Group, Organization, PageFilters} from 'sentry/types';
 import {getIssueFieldRenderer} from 'sentry/utils/dashboards/issueFieldRenderers';
 import {getUtcDateString} from 'sentry/utils/dates';
 import {TableData, TableDataRow} from 'sentry/utils/discover/discoverQuery';
-import {enablePrioritySortByDefault} from 'sentry/utils/prioritySort';
 import {
   DISCOVER_EXCLUSION_FIELDS,
   getSortLabel,
@@ -71,7 +70,9 @@ function disableSortOptions(_widgetQuery: WidgetQuery) {
 }
 
 function getTableSortOptions(organization: Organization, _widgetQuery: WidgetQuery) {
-  const hasBetterPrioritySort = enablePrioritySortByDefault(organization);
+  const hasBetterPrioritySort = organization.features.includes(
+    'issue-list-better-priority-sort'
+  );
   const sortOptions = [
     ...(hasBetterPrioritySort ? [IssueSortOptions.BETTER_PRIORITY] : []), // show better priority for EA orgs
     IssueSortOptions.DATE,

+ 3 - 2
static/app/views/dashboards/widgetLibrary/data.tsx

@@ -1,7 +1,6 @@
 import {t} from 'sentry/locale';
 import {Organization} from 'sentry/types';
 import {TOP_N} from 'sentry/utils/discover/types';
-import {enablePrioritySortByDefault} from 'sentry/utils/prioritySort';
 
 import {DisplayType, Widget, WidgetType} from '../types';
 
@@ -168,7 +167,9 @@ export const getDefaultWidgets = (organization: Organization) => {
           fields: ['issue', 'assignee', 'events', 'title'],
           aggregates: [],
           columns: ['issue', 'assignee', 'events', 'title'],
-          orderby: enablePrioritySortByDefault(organization) ? 'betterPriority' : 'date',
+          orderby: organization.features.includes('issue-list-better-priority-sort')
+            ? 'betterPriority'
+            : 'date',
         },
       ],
     },

+ 3 - 2
static/app/views/issueList/actions/sortOptions.tsx

@@ -1,7 +1,6 @@
 import {CompactSelect} from 'sentry/components/compactSelect';
 import {IconSort} from 'sentry/icons/iconSort';
 import {t} from 'sentry/locale';
-import {enablePrioritySortByDefault} from 'sentry/utils/prioritySort';
 import useOrganization from 'sentry/utils/useOrganization';
 import {getSortLabel, IssueSortOptions, Query} from 'sentry/views/issueList/utils';
 
@@ -33,7 +32,9 @@ function getSortTooltip(key: IssueSortOptions) {
 
 function IssueListSortOptions({onSelect, sort, query}: Props) {
   const organization = useOrganization();
-  const hasBetterPrioritySort = enablePrioritySortByDefault(organization);
+  const hasBetterPrioritySort = organization.features.includes(
+    'issue-list-better-priority-sort'
+  );
   const sortKey = sort || IssueSortOptions.DATE;
   const sortKeys = [
     ...(hasBetterPrioritySort ? [IssueSortOptions.BETTER_PRIORITY] : []), // show better priority for EA orgs

+ 0 - 49
static/app/views/issueList/overview.spec.jsx

@@ -13,13 +13,11 @@ import {
 import {textWithMarkupMatcher} from 'sentry-test/utils';
 
 import StreamGroup from 'sentry/components/stream/group';
-import ConfigStore from 'sentry/stores/configStore';
 import ProjectsStore from 'sentry/stores/projectsStore';
 import TagStore from 'sentry/stores/tagStore';
 import {SavedSearchVisibility} from 'sentry/types';
 import localStorageWrapper from 'sentry/utils/localStorage';
 import * as parseLinkHeader from 'sentry/utils/parseLinkHeader';
-import * as useExperiment from 'sentry/utils/useExperiment';
 import IssueListWithStores, {IssueListOverview} from 'sentry/views/issueList/overview';
 
 // Mock <IssueListActions>
@@ -1462,51 +1460,4 @@ describe('IssueList', function () {
       });
     });
   });
-  describe('better priority sort', function () {
-    it('log experiment when active', function () {
-      const logExperiment = jest.fn();
-      jest.spyOn(useExperiment, 'useExperiment').mockReturnValue({
-        experimentAssignment: 'variant2',
-        logExperiment,
-      });
-
-      ConfigStore.config.user = TestStubs.User({
-        experiments: {
-          PrioritySortExperiment: 'variant2',
-        },
-      });
-      const {routerContext: newRouterContext} = initializeOrg({
-        organization: {
-          features: ['better-priority-sort-experiment'],
-          isEarlyAdopter: true,
-        },
-      });
-      render(<IssueListWithStores {...routerProps} />, {
-        context: newRouterContext,
-      });
-      expect(logExperiment).toHaveBeenCalledWith();
-    });
-    it('do not log experiment if not active', function () {
-      const logExperiment = jest.fn();
-      jest.spyOn(useExperiment, 'useExperiment').mockReturnValue({
-        experimentAssignment: 'variant2',
-        logExperiment,
-      });
-
-      ConfigStore.config.user = TestStubs.User({
-        experiments: {
-          PrioritySortExperiment: 'variant2',
-        },
-      });
-      const {routerContext: newRouterContext} = initializeOrg({
-        organization: {
-          isEarlyAdopter: true,
-        },
-      });
-      render(<IssueListWithStores {...routerProps} />, {
-        context: newRouterContext,
-      });
-      expect(logExperiment).not.toHaveBeenCalledWith();
-    });
-  });
 });

+ 4 - 32
static/app/views/issueList/overview.tsx

@@ -37,7 +37,6 @@ import {
   SavedSearch,
   TagCollection,
 } from 'sentry/types';
-import {ExperimentAssignment} from 'sentry/types/experiments';
 import {defined} from 'sentry/utils';
 import {trackAnalytics} from 'sentry/utils/analytics';
 import CursorPoller from 'sentry/utils/cursorPoller';
@@ -46,18 +45,12 @@ import getCurrentSentryReactTransaction from 'sentry/utils/getCurrentSentryReact
 import parseApiError from 'sentry/utils/parseApiError';
 import parseLinkHeader from 'sentry/utils/parseLinkHeader';
 import {VisuallyCompleteWithData} from 'sentry/utils/performanceForSentry';
-import {
-  enablePrioritySortByDefault,
-  getPrioritySortVariant,
-  prioritySortExperimentEnabled,
-} from 'sentry/utils/prioritySort';
 import {decodeScalar} from 'sentry/utils/queryString';
 import withRouteAnalytics, {
   WithRouteAnalyticsProps,
 } from 'sentry/utils/routeAnalytics/withRouteAnalytics';
 import withApi from 'sentry/utils/withApi';
 import {normalizeUrl} from 'sentry/utils/withDomainRequired';
-import withExperiment from 'sentry/utils/withExperiment';
 import withIssueTags from 'sentry/utils/withIssueTags';
 import withOrganization from 'sentry/utils/withOrganization';
 import withPageFilters from 'sentry/utils/withPageFilters';
@@ -92,9 +85,7 @@ type Params = {
 
 type Props = {
   api: Client;
-  experimentAssignment: ExperimentAssignment['PrioritySortExperiment'];
   location: Location;
-  logExperiment: () => void;
   organization: Organization;
   params: Params;
   savedSearch: SavedSearch;
@@ -158,7 +149,6 @@ type BetterPriorityEndpointParams = Partial<EndpointParams> & {
   norm?: boolean;
   relativeVolume?: number;
   v2?: boolean;
-  variant?: string;
 };
 
 class IssueListOverview extends Component<Props, State> {
@@ -205,7 +195,6 @@ class IssueListOverview extends Component<Props, State> {
     this.fetchMemberList();
     // let custom analytics take control
     this.props.setDisableRouteAnalytics?.();
-    this.logExperiment();
   }
 
   componentDidUpdate(prevProps: Props, prevState: State) {
@@ -286,12 +275,6 @@ class IssueListOverview extends Component<Props, State> {
   private _lastStatsRequest: any;
   private _lastFetchCountsRequest: any;
 
-  logExperiment() {
-    if (prioritySortExperimentEnabled(this.props.organization)) {
-      this.props.logExperiment();
-    }
-  }
-
   getQueryFromSavedSearchOrLocation({
     savedSearch,
     location,
@@ -321,7 +304,9 @@ class IssueListOverview extends Component<Props, State> {
       return location.query.sort as string;
     }
 
-    const hasBetterPrioritySort = enablePrioritySortByDefault(this.props.organization);
+    const hasBetterPrioritySort = this.props.organization.features.includes(
+      'issue-list-better-priority-sort'
+    );
     return hasBetterPrioritySort
       ? IssueSortOptions.BETTER_PRIORITY
       : DEFAULT_ISSUE_STREAM_SORT;
@@ -355,7 +340,6 @@ class IssueListOverview extends Component<Props, State> {
   }
 
   getBetterPriorityParams(): BetterPriorityEndpointParams {
-    const variant = getPrioritySortVariant(this.props.organization);
     const query = this.props.location.query ?? {};
     const {
       eventHalflifeHours,
@@ -375,7 +359,6 @@ class IssueListOverview extends Component<Props, State> {
       norm,
       v2,
       relativeVolume,
-      variant,
     };
   }
 
@@ -1290,18 +1273,7 @@ class IssueListOverview extends Component<Props, State> {
 export default withRouteAnalytics(
   withApi(
     withPageFilters(
-      withSavedSearches(
-        withOrganization(
-          withIssueTags(
-            withProfiler(
-              withExperiment(IssueListOverview, {
-                experiment: 'PrioritySortExperiment',
-                injectLogExperiment: true,
-              })
-            )
-          )
-        )
-      )
+      withSavedSearches(withOrganization(withIssueTags(withProfiler(IssueListOverview))))
     )
   )
 );