How to use the @sentry/types.Status.Success function in @sentry/types

To help you get started, we’ve selected a few @sentry/types examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github getsentry / sentry-javascript / packages / node / src / transports / base.ts View on Github external
const req = httpModule.request(this._getRequestOptions(), (res: http.IncomingMessage) => {
          const statusCode = res.statusCode || 500;
          const status = Status.fromHttpCode(statusCode);

          res.setEncoding('utf8');

          if (status === Status.Success) {
            resolve({ status });
          } else {
            if (status === Status.RateLimit) {
              const now = Date.now();
              let header = res.headers ? res.headers['Retry-After'] : '';
              header = Array.isArray(header) ? header[0] : header;
              this._disabledUntil = new Date(now + parseRetryAfterHeader(now, header));
              logger.warn(`Too many requests, backing off till: ${this._disabledUntil}`);
            }

            let rejectionMessage = `HTTP Error (${statusCode})`;
            if (res.headers && res.headers['x-sentry-error']) {
              rejectionMessage += `: ${res.headers['x-sentry-error']}`;
            }

            reject(new SentryError(rejectionMessage));
github getsentry / sentry-javascript / packages / browser / src / transports / fetch.ts View on Github external
.then(response => {
            const status = Status.fromHttpCode(response.status);

            if (status === Status.Success) {
              resolve({ status });
              return;
            }

            if (status === Status.RateLimit) {
              const now = Date.now();
              this._disabledUntil = new Date(now + parseRetryAfterHeader(now, response.headers.get('Retry-After')));
              logger.warn(`Too many requests, backing off till: ${this._disabledUntil}`);
            }

            reject(response);
          })
          .catch(reject);
github getsentry / sentry-javascript / packages / browser / src / transports / xhr.ts View on Github external
request.onreadystatechange = () => {
          if (request.readyState !== 4) {
            return;
          }

          const status = Status.fromHttpCode(request.status);

          if (status === Status.Success) {
            resolve({ status });
            return;
          }

          if (status === Status.RateLimit) {
            const now = Date.now();
            this._disabledUntil = new Date(now + parseRetryAfterHeader(now, request.getResponseHeader('Retry-After')));
            logger.warn(`Too many requests, backing off till: ${this._disabledUntil}`);
          }

          reject(request);
        };