Skip to content

Commit 8569926

Browse files
committed
move around code
1 parent f4737b0 commit 8569926

File tree

1 file changed

+45
-39
lines changed

1 file changed

+45
-39
lines changed

src/components/onboarding/index.tsx

Lines changed: 45 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,23 @@ import styles from './styles.module.scss';
99

1010
import {CodeContext} from '../codeContext';
1111

12+
const OPTION_IDS = [
13+
'error-monitoring',
14+
'logs',
15+
'session-replay',
16+
'performance',
17+
'profiling',
18+
'source-maps',
19+
'user-feedback',
20+
'source-context',
21+
'dsym',
22+
'opentelemetry',
23+
] as const;
24+
25+
const OPTION_IDS_SET = new Set(OPTION_IDS);
26+
27+
type OptionId = (typeof OPTION_IDS)[number];
28+
1229
const optionDetails: Record<
1330
OptionId,
1431
{
@@ -59,6 +76,15 @@ const optionDetails: Record<
5976
),
6077
deps: ['performance'],
6178
},
79+
'source-maps': {
80+
name: 'Source Maps',
81+
description: (
82+
<span>
83+
Source maps for web applications that help translate minified code back to the
84+
original source for better error reporting.
85+
</span>
86+
),
87+
},
6288
'user-feedback': {
6389
name: 'User Feedback',
6490
description: (
@@ -86,36 +112,12 @@ const optionDetails: Record<
86112
</span>
87113
),
88114
},
89-
'source-maps': {
90-
name: 'Source Maps',
91-
description: (
92-
<span>
93-
Source maps for web applications that help translate minified code back to the
94-
original source for better error reporting.
95-
</span>
96-
),
97-
},
98115
opentelemetry: {
99116
name: 'OpenTelemetry',
100117
description: <span>Combine Sentry with OpenTelemetry.</span>,
101118
},
102119
};
103120

104-
const OPTION_IDS = new Set([
105-
'error-monitoring',
106-
'logs',
107-
'session-replay',
108-
'performance',
109-
'profiling',
110-
'source-maps',
111-
'user-feedback',
112-
'source-context',
113-
'dsym',
114-
'opentelemetry',
115-
] as const);
116-
117-
type OptionId = typeof OPTION_IDS extends Set<infer T> ? T : never;
118-
119121
export type OnboardingOptionType = {
120122
/**
121123
* Unique identifier for the option, will control the visibility
@@ -132,11 +134,9 @@ export type OnboardingOptionType = {
132134

133135
const validateOptionIds = (options: Pick<OnboardingOptionType, 'id'>[]) => {
134136
options.forEach(option => {
135-
if (!OPTION_IDS.has(option.id)) {
137+
if (!OPTION_IDS_SET.has(option.id)) {
136138
throw new Error(
137-
`Invalid option id: ${option.id}.\nValid options are: ${Array.from(OPTION_IDS)
138-
.map(opt => `"${opt}"`)
139-
.join(', ')}`
139+
`Invalid option id: ${option.id}.\nValid options are: ${OPTION_IDS.map(opt => `"${opt}"`).join(', ')}`
140140
);
141141
}
142142
});
@@ -239,17 +239,23 @@ export function OnboardingOptionButtons({
239239
}) {
240240
const codeContext = useContext(CodeContext);
241241

242-
const normalizedOptions = initialOptions.map(option => {
243-
if (typeof option === 'string') {
244-
return {
245-
id: option,
246-
// error monitoring is always needs to be checked and disabled
247-
disabled: option === 'error-monitoring',
248-
checked: option === 'error-monitoring',
249-
};
250-
}
251-
return option;
252-
});
242+
const normalizedOptions = initialOptions
243+
.map(option => {
244+
if (typeof option === 'string') {
245+
return {
246+
id: option,
247+
// error monitoring is always needs to be checked and disabled
248+
disabled: option === 'error-monitoring',
249+
checked: option === 'error-monitoring',
250+
};
251+
}
252+
return option;
253+
})
254+
.sort((a, b) => {
255+
const indexA = OPTION_IDS.indexOf(a.id);
256+
const indexB = OPTION_IDS.indexOf(b.id);
257+
return indexA - indexB;
258+
});
253259

254260
validateOptionIds(normalizedOptions);
255261

0 commit comments

Comments
 (0)