File tree Expand file tree Collapse file tree 4 files changed +33
-32
lines changed Expand file tree Collapse file tree 4 files changed +33
-32
lines changed Original file line number Diff line number Diff line change @@ -32,13 +32,15 @@ export {
3232 SessionFlusherLike ,
3333} from './session' ;
3434
35- /* eslint-disable deprecation/deprecation */
35+ /* eslint-disable-next-line deprecation/deprecation */
3636export { Severity } from './severity' ;
3737export { SeverityLevel , SeverityLevels } from './severity' ;
3838export { Span , SpanContext } from './span' ;
3939export { StackFrame } from './stackframe' ;
4040export { Stacktrace } from './stacktrace' ;
41+ /* eslint-disable-next-line deprecation/deprecation */
4142export { Status } from './status' ;
43+ export { StatusType } from './status' ;
4244export {
4345 CustomSamplingContext ,
4446 Measurements ,
Original file line number Diff line number Diff line change 11/** JSDoc
22 * @deprecated Use string literals - if you require type casting, cast to SeverityLevel type
33 */
4- // eslint-disable-next-line import/export
54export enum Severity {
65 /** JSDoc */
76 Fatal = 'fatal' ,
Original file line number Diff line number Diff line change 1- /** The status of an event. */
2- // eslint-disable-next-line import/export
1+ /** JSDoc
2+ * @deprecated Use string literals - if you require type casting, cast to StatusType type
3+ */
34export enum Status {
45 /** The status could not be determined. */
56 Unknown = 'unknown' ,
@@ -15,31 +16,4 @@ export enum Status {
1516 Failed = 'failed' ,
1617}
1718
18- // eslint-disable-next-line @typescript-eslint/no-namespace, import/export
19- export namespace Status {
20- /**
21- * Converts a HTTP status code into a {@link Status}.
22- *
23- * @param code The HTTP response status code.
24- * @returns The send status or {@link Status.Unknown}.
25- */
26- export function fromHttpCode ( code : number ) : Status {
27- if ( code >= 200 && code < 300 ) {
28- return Status . Success ;
29- }
30-
31- if ( code === 429 ) {
32- return Status . RateLimit ;
33- }
34-
35- if ( code >= 400 && code < 500 ) {
36- return Status . Invalid ;
37- }
38-
39- if ( code >= 500 ) {
40- return Status . Failed ;
41- }
42-
43- return Status . Unknown ;
44- }
45- }
19+ export type StatusType = 'unknown' | 'skipped' | 'rate_limit' | 'invalid' | 'failed' | 'success' ;
Original file line number Diff line number Diff line change 1+ import { StatusType } from '@sentry/types' ;
2+ /**
3+ * Converts an HTTP status code to sentry status {@link StatusType}.
4+ *
5+ * @param code number HTTP status code
6+ * @returns StatusType
7+ */
8+ export function fromHttpCode ( code : number ) : StatusType {
9+ if ( code >= 200 && code < 300 ) {
10+ return 'success' ;
11+ }
12+
13+ if ( code === 429 ) {
14+ return 'rate_limit' ;
15+ }
16+
17+ if ( code >= 400 && code < 500 ) {
18+ return 'invalid' ;
19+ }
20+
21+ if ( code >= 500 ) {
22+ return 'failed' ;
23+ }
24+
25+ return 'unknown' ;
26+ }
You can’t perform that action at this time.
0 commit comments