How to use the @sentry/utils.getEventDescription 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 / core / src / integrations / inboundfilters.ts View on Github external
private _getEventFilterUrl(event: Event): string | null {
    try {
      if (event.stacktrace) {
        // tslint:disable:no-unsafe-any
        const frames = (event as any).stacktrace.frames;
        return frames[frames.length - 1].filename;
      }
      if (event.exception) {
        // tslint:disable:no-unsafe-any
        const frames = (event as any).exception.values[0].stacktrace.frames;
        return frames[frames.length - 1].filename;
      }
      return null;
    } catch (oO) {
      logger.error(`Cannot extract url for event ${getEventDescription(event)}`);
      return null;
    }
  }
}
github getsentry / sentry-javascript / packages / core / src / integrations / inboundfilters.ts View on Github external
private _getPossibleEventMessages(event: Event): string[] {
    if (event.message) {
      return [event.message];
    }
    if (event.exception) {
      try {
        // tslint:disable-next-line:no-unsafe-any
        const { type, value } = (event as any).exception.values[0];
        return [`${value}`, `${type}: ${value}`];
      } catch (oO) {
        logger.error(`Cannot extract message for event ${getEventDescription(event)}`);
        return [];
      }
    }
    return [];
  }
github getsentry / sentry-javascript / packages / browser / src / integrations / instrumenthandlers.ts View on Github external
function addSentryBreadcrumb(serializedData: string): void {
  // There's always something that can go wrong with deserialization...
  try {
    const event = JSON.parse(serializedData);
    getCurrentHub().addBreadcrumb(
      {
        category: 'sentry',
        event_id: event.event_id,
        level: event.level || Severity.fromString('error'),
        message: getEventDescription(event),
      },
      {
        event,
      },
    );
  } catch (_oO) {
    logger.error('Error while adding sentry type breadcrumb');
  }
}
github getsentry / sentry-javascript / packages / core / src / integrations / inboundfilters.ts View on Github external
private _getEventFilterUrl(event: Event): string | null {
    try {
      if (event.stacktrace) {
        const frames = event.stacktrace.frames;
        return (frames && frames[frames.length - 1].filename) || null;
      }
      if (event.exception) {
        const frames =
          event.exception.values && event.exception.values[0].stacktrace && event.exception.values[0].stacktrace.frames;
        return (frames && frames[frames.length - 1].filename) || null;
      }
      return null;
    } catch (oO) {
      logger.error(`Cannot extract url for event ${getEventDescription(event)}`);
      return null;
    }
  }
}
github getsentry / sentry-javascript / packages / core / src / integrations / inboundfilters.ts View on Github external
private _getPossibleEventMessages(event: Event): string[] {
    if (event.message) {
      return [event.message];
    }
    if (event.exception) {
      try {
        const { type = '', value = '' } = (event.exception.values && event.exception.values[0]) || {};
        return [`${value}`, `${type}: ${value}`];
      } catch (oO) {
        logger.error(`Cannot extract message for event ${getEventDescription(event)}`);
        return [];
      }
    }
    return [];
  }
github getsentry / sentry-javascript / packages / core / src / integrations / inboundfilters.ts View on Github external
private _shouldDropEvent(event: Event, options: InboundFiltersOptions): boolean {
    if (this._isSentryError(event, options)) {
      logger.warn(`Event dropped due to being internal Sentry Error.\nEvent: ${getEventDescription(event)}`);
      return true;
    }
    if (this._isIgnoredError(event, options)) {
      logger.warn(
        `Event dropped due to being matched by \`ignoreErrors\` option.\nEvent: ${getEventDescription(event)}`,
      );
      return true;
    }
    if (this._isBlacklistedUrl(event, options)) {
      logger.warn(
        `Event dropped due to being matched by \`blacklistUrls\` option.\nEvent: ${getEventDescription(
          event,
        )}.\nUrl: ${this._getEventFilterUrl(event)}`,
      );
      return true;
    }
    if (!this._isWhitelistedUrl(event, options)) {
      logger.warn(
        `Event dropped due to not being matched by \`whitelistUrls\` option.\nEvent: ${getEventDescription(
          event,
        )}.\nUrl: ${this._getEventFilterUrl(event)}`,
      );
      return true;
    }
    return false;
  }