Skip to content

Commit cf6524e

Browse files
committed
ref(types): fix fromHttpCode usage to statusFromHttpCode
1 parent 6ee2c82 commit cf6524e

File tree

7 files changed

+12
-10
lines changed

7 files changed

+12
-10
lines changed

packages/browser/src/transports/base.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import {
2020
parseRetryAfterHeader,
2121
PromiseBuffer,
2222
SentryError,
23+
statusFromHttpCode,
2324
} from '@sentry/utils';
2425

2526
import { sendReport } from './utils';
@@ -159,7 +160,7 @@ export abstract class BaseTransport implements Transport {
159160
resolve: (value?: SentryResponse | PromiseLike<SentryResponse> | null | undefined) => void;
160161
reject: (reason?: unknown) => void;
161162
}): void {
162-
const status = Status.fromHttpCode(response.status);
163+
const status = statusFromHttpCode(response.status);
163164
/**
164165
* "The name is case-insensitive."
165166
* https://developer.mozilla.org/en-US/docs/Web/API/Headers/get

packages/browser/test/unit/mocks/simpletransport.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
import { SyncPromise } from '@sentry/utils';
1+
import { SyncPromise, statusFromHttpCode } from '@sentry/utils';
22

3-
import { Event, Response, Status } from '../../../src';
3+
import { Event, Response } from '../../../src';
44
import { BaseTransport } from '../../../src/transports';
55

66
export class SimpleTransport extends BaseTransport {
77
public sendEvent(_: Event): PromiseLike<Response> {
88
return this._buffer.add(() =>
99
SyncPromise.resolve({
10-
status: Status.fromHttpCode(200),
10+
status: statusFromHttpCode(200),
1111
}),
1212
);
1313
}

packages/node/src/transports/base/index.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import {
1111
Transport,
1212
TransportOptions,
1313
} from '@sentry/types';
14-
import { logger, parseRetryAfterHeader, PromiseBuffer, SentryError } from '@sentry/utils';
14+
import { logger, parseRetryAfterHeader, PromiseBuffer, SentryError, statusFromHttpCode } from '@sentry/utils';
1515
import * as fs from 'fs';
1616
import * as http from 'http';
1717
import * as https from 'https';
@@ -209,7 +209,7 @@ export abstract class BaseTransport implements Transport {
209209
const options = this._getRequestOptions(this.urlParser(sentryRequest.url));
210210
const req = this.module.request(options, res => {
211211
const statusCode = res.statusCode || 500;
212-
const status = Status.fromHttpCode(statusCode);
212+
const status = statusFromHttpCode(statusCode);
213213

214214
res.setEncoding('utf8');
215215

packages/tracing/src/span.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ export class Span implements SpanInterface {
214214
*/
215215
public setHttpStatus(httpStatus: number): this {
216216
this.setTag('http.status_code', String(httpStatus));
217-
const spanStatus = SpanStatus.fromHttpCode(httpStatus);
217+
const spanStatus = statusFromHttpCode(httpStatus);
218218
if (spanStatus !== SpanStatus.UnknownError) {
219219
this.setStatus(spanStatus);
220220
}

packages/types/src/response.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import { Event, EventType } from './event';
22
import { Session } from './session';
3-
import { Status } from './status';
3+
import { StatusType } from './status';
44

55
/** JSDoc */
66
export interface Response {
7-
status: Status;
7+
status: StatusType;
88
event?: Event | Session;
99
type?: EventType;
1010
reason?: string;

packages/utils/src/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ export * from './path';
1414
export * from './promisebuffer';
1515
export * from './severity';
1616
export * from './stacktrace';
17+
export * from './status';
1718
export * from './string';
1819
export * from './supports';
1920
export * from './syncpromise';

packages/utils/src/status.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { StatusType } from '@sentry/types';
55
* @param code number HTTP status code
66
* @returns StatusType
77
*/
8-
export function fromHttpCode(code: number): StatusType {
8+
export function statusFromHttpCode(code: number): StatusType {
99
if (code >= 200 && code < 300) {
1010
return 'success';
1111
}

0 commit comments

Comments
 (0)