Skip to content

Commit 92d0295

Browse files
authored
ref(errors): Use enum for stacktrace order (#96723)
This is a follow-up to #96719, which added a backend `StacktraceOrder` enum, doing the same in the front end. It also clarifies the labels for the `Newest` (now `Newest first`) and `Oldest` (now `Oldest first`) options in user preferences.
1 parent 31c7269 commit 92d0295

File tree

3 files changed

+18
-8
lines changed

3 files changed

+18
-8
lines changed

static/app/components/events/interfaces/utils.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import type {EntryRequest, EntryThreads, Event, Frame, Thread} from 'sentry/type
99
import {EntryType} from 'sentry/types/event';
1010
import type {PlatformKey} from 'sentry/types/project';
1111
import type {StacktraceType} from 'sentry/types/stacktrace';
12-
import type {AvatarUser} from 'sentry/types/user';
12+
import {type AvatarUser, StacktraceOrder} from 'sentry/types/user';
1313
import {defined} from 'sentry/utils';
1414
import {fileExtensionToPlatform, getFileExtension} from 'sentry/utils/fileExtension';
1515

@@ -382,11 +382,11 @@ export function isStacktraceNewestFirst() {
382382
}
383383

384384
switch (user.options.stacktraceOrder) {
385-
case 2:
385+
case StacktraceOrder.MOST_RECENT_FIRST:
386386
return true;
387-
case 1:
387+
case StacktraceOrder.MOST_RECENT_LAST:
388388
return false;
389-
case -1:
389+
case StacktraceOrder.DEFAULT:
390390
default:
391391
return true;
392392
}

static/app/data/forms/accountPreferences.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import type {JsonFormObject} from 'sentry/components/forms/types';
22
import languages from 'sentry/data/languages';
33
import {timezoneOptions} from 'sentry/data/timezones';
44
import {t} from 'sentry/locale';
5+
import {StacktraceOrder} from 'sentry/types/user';
56
import {removeBodyTheme} from 'sentry/utils/removeBodyTheme';
67

78
// Export route to make these forms searchable by label/help
@@ -58,9 +59,12 @@ const formGroups: JsonFormObject[] = [
5859
type: 'select',
5960
required: false,
6061
options: [
61-
{value: -1, label: t('Default')},
62-
{value: 1, label: t('Oldest')},
63-
{value: 2, label: t('Newest')},
62+
// TODO: If we eliminate the special-casing as discussed in
63+
// https://github.com/getsentry/sentry/pull/96719, consider changing the label here to
64+
// `Default (newest first)` and removing the separate `Newest first` option.
65+
{value: StacktraceOrder.DEFAULT, label: t('Default')},
66+
{value: StacktraceOrder.MOST_RECENT_LAST, label: t('Oldest first')},
67+
{value: StacktraceOrder.MOST_RECENT_FIRST, label: t('Newest first')},
6468
],
6569
label: t('Stack Trace Order'),
6670
help: t('Choose the default ordering of frames in stack traces'),

static/app/types/user.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,12 @@ export type AvatarUser = {
2121
};
2222
};
2323

24+
export enum StacktraceOrder {
25+
DEFAULT = -1, // Equivalent to `MOST_RECENT_FIRST`
26+
MOST_RECENT_LAST = 1,
27+
MOST_RECENT_FIRST = 2,
28+
}
29+
2430
export interface User extends Omit<AvatarUser, 'options'> {
2531
canReset2fa: boolean;
2632
dateJoined: string;
@@ -50,7 +56,7 @@ export interface User extends Omit<AvatarUser, 'options'> {
5056
prefersIssueDetailsStreamlinedUI: boolean | null;
5157
prefersNextjsInsightsOverview: boolean;
5258
prefersStackedNavigation: boolean | null;
53-
stacktraceOrder: number;
59+
stacktraceOrder: StacktraceOrder;
5460
theme: 'system' | 'light' | 'dark';
5561
timezone: string;
5662
};

0 commit comments

Comments
 (0)