Skip to content

ref(errors): Use enum for stacktrace order #96723

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jul 30, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions static/app/components/events/interfaces/utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import type {EntryRequest, EntryThreads, Event, Frame, Thread} from 'sentry/type
import {EntryType} from 'sentry/types/event';
import type {PlatformKey} from 'sentry/types/project';
import type {StacktraceType} from 'sentry/types/stacktrace';
import type {AvatarUser} from 'sentry/types/user';
import {type AvatarUser, StacktraceOrder} from 'sentry/types/user';
import {defined} from 'sentry/utils';
import {fileExtensionToPlatform, getFileExtension} from 'sentry/utils/fileExtension';

Expand Down Expand Up @@ -382,11 +382,11 @@ export function isStacktraceNewestFirst() {
}

switch (user.options.stacktraceOrder) {
case 2:
case StacktraceOrder.MOST_RECENT_FIRST:
return true;
case 1:
case StacktraceOrder.MOST_RECENT_LAST:
return false;
case -1:
case StacktraceOrder.DEFAULT:
default:
return true;
}
Expand Down
10 changes: 7 additions & 3 deletions static/app/data/forms/accountPreferences.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import type {JsonFormObject} from 'sentry/components/forms/types';
import languages from 'sentry/data/languages';
import {timezoneOptions} from 'sentry/data/timezones';
import {t} from 'sentry/locale';
import {StacktraceOrder} from 'sentry/types/user';
import {removeBodyTheme} from 'sentry/utils/removeBodyTheme';

// Export route to make these forms searchable by label/help
Expand Down Expand Up @@ -58,9 +59,12 @@ const formGroups: JsonFormObject[] = [
type: 'select',
required: false,
options: [
{value: -1, label: t('Default')},
{value: 1, label: t('Oldest')},
{value: 2, label: t('Newest')},
// TODO: If we eliminate the special-casing as discussed in
// https://github.com/getsentry/sentry/pull/96719, consider changing the label here to
// `Default (newest first)` and removing the separate `Newest first` option.
{value: StacktraceOrder.DEFAULT, label: t('Default')},
{value: StacktraceOrder.MOST_RECENT_LAST, label: t('Oldest first')},
{value: StacktraceOrder.MOST_RECENT_FIRST, label: t('Newest first')},
],
label: t('Stack Trace Order'),
help: t('Choose the default ordering of frames in stack traces'),
Expand Down
8 changes: 7 additions & 1 deletion static/app/types/user.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ export type AvatarUser = {
};
};

export enum StacktraceOrder {
DEFAULT = -1, // Equivalent to `MOST_RECENT_FIRST`
MOST_RECENT_LAST = 1,
MOST_RECENT_FIRST = 2,
}

export interface User extends Omit<AvatarUser, 'options'> {
canReset2fa: boolean;
dateJoined: string;
Expand Down Expand Up @@ -50,7 +56,7 @@ export interface User extends Omit<AvatarUser, 'options'> {
prefersIssueDetailsStreamlinedUI: boolean | null;
prefersNextjsInsightsOverview: boolean;
prefersStackedNavigation: boolean | null;
stacktraceOrder: number;
stacktraceOrder: StacktraceOrder;
theme: 'system' | 'light' | 'dark';
timezone: string;
};
Expand Down
Loading