@@ -9,6 +9,23 @@ import styles from './styles.module.scss';
9
9
10
10
import { CodeContext } from '../codeContext' ;
11
11
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
+
12
29
const optionDetails : Record <
13
30
OptionId ,
14
31
{
@@ -21,6 +38,24 @@ const optionDetails: Record<
21
38
name : 'Error Monitoring' ,
22
39
description : "Let's admit it, we all have errors." ,
23
40
} ,
41
+ logs : {
42
+ name : 'Logs' ,
43
+ description : (
44
+ < span >
45
+ Send text-based log information from your applications to Sentry for viewing
46
+ alongside relevant errors and searching by text-string or individual attributes.
47
+ </ span >
48
+ ) ,
49
+ } ,
50
+ 'session-replay' : {
51
+ name : 'Session Replay' ,
52
+ description : (
53
+ < span >
54
+ Video-like reproductions of user sessions with debugging context to help you
55
+ confirm issue impact and troubleshoot faster.
56
+ </ span >
57
+ ) ,
58
+ } ,
24
59
performance : {
25
60
name : 'Tracing' ,
26
61
description : (
@@ -41,12 +76,12 @@ const optionDetails: Record<
41
76
) ,
42
77
deps : [ 'performance' ] ,
43
78
} ,
44
- 'session-replay ' : {
45
- name : 'Session Replay ' ,
79
+ 'source-maps ' : {
80
+ name : 'Source Maps ' ,
46
81
description : (
47
82
< span >
48
- Video-like reproductions of user sessions with debugging context to help you
49
- confirm issue impact and troubleshoot faster .
83
+ Source maps for web applications that help translate minified code back to the
84
+ original source for better error reporting .
50
85
</ span >
51
86
) ,
52
87
} ,
@@ -59,15 +94,6 @@ const optionDetails: Record<
59
94
</ span >
60
95
) ,
61
96
} ,
62
- logs : {
63
- name : 'Logs (Beta)' ,
64
- description : (
65
- < span >
66
- Send text-based log information from your applications to Sentry for viewing
67
- alongside relevant errors and searching by text-string or individual attributes.
68
- </ span >
69
- ) ,
70
- } ,
71
97
'source-context' : {
72
98
name : 'Source Context' ,
73
99
description : (
@@ -86,36 +112,12 @@ const optionDetails: Record<
86
112
</ span >
87
113
) ,
88
114
} ,
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
- } ,
98
115
opentelemetry : {
99
116
name : 'OpenTelemetry' ,
100
117
description : < span > Combine Sentry with OpenTelemetry.</ span > ,
101
118
} ,
102
119
} ;
103
120
104
- const OPTION_IDS = [
105
- 'error-monitoring' ,
106
- 'performance' ,
107
- 'profiling' ,
108
- 'session-replay' ,
109
- 'user-feedback' ,
110
- 'logs' ,
111
- 'source-context' ,
112
- 'dsym' ,
113
- 'source-maps' ,
114
- 'opentelemetry' ,
115
- ] as const ;
116
-
117
- type OptionId = ( typeof OPTION_IDS ) [ number ] ;
118
-
119
121
export type OnboardingOptionType = {
120
122
/**
121
123
* Unique identifier for the option, will control the visibility
@@ -132,7 +134,7 @@ export type OnboardingOptionType = {
132
134
133
135
const validateOptionIds = ( options : Pick < OnboardingOptionType , 'id' > [ ] ) => {
134
136
options . forEach ( option => {
135
- if ( ! OPTION_IDS . includes ( option . id ) ) {
137
+ if ( ! OPTION_IDS_SET . has ( option . id ) ) {
136
138
throw new Error (
137
139
`Invalid option id: ${ option . id } .\nValid options are: ${ OPTION_IDS . map ( opt => `"${ opt } "` ) . join ( ', ' ) } `
138
140
) ;
@@ -237,17 +239,26 @@ export function OnboardingOptionButtons({
237
239
} ) {
238
240
const codeContext = useContext ( CodeContext ) ;
239
241
240
- const normalizedOptions = initialOptions . map ( option => {
241
- if ( typeof option === 'string' ) {
242
- return {
243
- id : option ,
244
- // error monitoring is always needs to be checked and disabled
245
- disabled : option === 'error-monitoring' ,
246
- checked : option === 'error-monitoring' ,
247
- } ;
248
- }
249
- return option ;
250
- } ) ;
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 options by their index in OPTION_IDS
255
+ // so that the order of the options is consistent
256
+ // regardless of how the user passes them in
257
+ . sort ( ( a , b ) => {
258
+ const indexA = OPTION_IDS . indexOf ( a . id ) ;
259
+ const indexB = OPTION_IDS . indexOf ( b . id ) ;
260
+ return indexA - indexB ;
261
+ } ) ;
251
262
252
263
validateOptionIds ( normalizedOptions ) ;
253
264
0 commit comments