How to use the @sentry/utils.isString function in @sentry/utils

To help you get started, we’ve selected a few @sentry/utils 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 / browser / src / integrations / breadcrumbs.ts View on Github external
function(this: SentryWrappedXMLHttpRequest, ...args: any[]): void {
          const url = args[1];
          this.__sentry_xhr__ = {
            method: isString(args[0]) ? args[0].toUpperCase() : args[0],
            url: args[1],
          };

          const client = getCurrentHub().getClient();
          const dsn = client && client.getDsn();
          if (dsn) {
            const filterUrl = new API(dsn).getStoreEndpoint();
            // if Sentry key appears in URL, don't capture it as a request
            // but rather as our own 'sentry' type breadcrumb
            if (isString(url) && (filterUrl && url.indexOf(filterUrl) !== -1)) {
              this.__sentry_own_request__ = true;
            }
          }

          return originalOpen.apply(this, args);
        },
    );
github getsentry / sentry-javascript / packages / browser / src / integrations / globalhandlers.ts View on Github external
private _eventFromIncompleteOnError(msg: any, url: any, line: any, column: any): Event {
    const ERROR_TYPES_RE = /^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i;

    // If 'message' is ErrorEvent, get real message from inside
    let message = isErrorEvent(msg) ? msg.message : msg;
    let name;

    if (isString(message)) {
      const groups = message.match(ERROR_TYPES_RE);
      if (groups) {
        name = groups[1];
        message = groups[2];
      }
    }

    const event = {
      exception: {
        values: [
          {
            type: name || 'Error',
            value: message,
          },
        ],
      },
github getsentry / sentry-javascript / packages / node / src / handlers.ts View on Github external
case 'query_string':
        // query string:
        //   node: req.url (raw)
        //   express, koa: req.query
        request.query_string = url.parse(originalUrl || '', false).query;
        break;
      case 'data':
        // body data:
        //   node, express, koa: req.body
        let data = req.body;
        if (method === 'GET' || method === 'HEAD') {
          if (typeof data === 'undefined') {
            data = '';
          }
        }
        if (data && !isString(data)) {
          // Make sure the request body is a string
          data = JSON.stringify(normalize(data));
        }
        request.data = data;
        break;
      default:
        if ({}.hasOwnProperty.call(req, key)) {
          request[key] = (req as { [key: string]: any })[key];
        }
    }
  });
github getsentry / sentry-javascript / packages / browser / src / integrations / breadcrumbs.ts View on Github external
function(this: SentryWrappedXMLHttpRequest, ...args: any[]): void {
          const url = args[1];
          this.__sentry_xhr__ = {
            method: isString(args[0]) ? args[0].toUpperCase() : args[0],
            url: args[1],
          };

          const client = getCurrentHub().getClient();
          const dsn = client && client.getDsn();
          if (dsn) {
            const filterUrl = new API(dsn).getStoreEndpoint();
            // if Sentry key appears in URL, don't capture it as a request
            // but rather as our own 'sentry' type breadcrumb
            if (isString(url) && (filterUrl && url.indexOf(filterUrl) !== -1)) {
              this.__sentry_own_request__ = true;
            }
          }

          return originalOpen.apply(this, args);
        },
github getsentry / sentry-javascript / packages / browser / src / integrations / globalhandlers.ts View on Github external
private _enhanceEventWithInitialFrame(event: Event, url: any, line: any, column: any): Event {
    event.exception = event.exception || {};
    event.exception.values = event.exception.values || [];
    event.exception.values[0] = event.exception.values[0] || {};
    event.exception.values[0].stacktrace = event.exception.values[0].stacktrace || {};
    event.exception.values[0].stacktrace.frames = event.exception.values[0].stacktrace.frames || [];

    const colno = isNaN(parseInt(column, 10)) ? undefined : column;
    const lineno = isNaN(parseInt(line, 10)) ? undefined : line;
    const filename = isString(url) && url.length > 0 ? url : getLocationHref();

    if (event.exception.values[0].stacktrace.frames.length === 0) {
      event.exception.values[0].stacktrace.frames.push({
        colno,
        filename,
        function: '?',
        in_app: true,
        lineno,
      });
    }

    return event;
  }
}
github getsentry / sentry-javascript / packages / node / src / handlers.ts View on Github external
withScope(scope => {
        if (_req.headers && isString(_req.headers['sentry-trace'])) {
          const span = Span.fromTraceparent(_req.headers['sentry-trace'] as string);
          scope.setSpan(span);
        }
        const eventId = captureException(error);
        (_res as any).sentry = eventId;
        next(error);
      });