How to use the @sentry/utils.SyncPromise.reject 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 / baseclient.ts View on Github external
protected _processEvent(event: Event, hint?: EventHint, scope?: Scope): PromiseLike {
    const { beforeSend, sampleRate } = this.getOptions();

    if (!this._isEnabled()) {
      return SyncPromise.reject('SDK not enabled, will not send event.');
    }

    // 1.0 === 100% events are sent
    // 0.0 === 0% events are sent
    if (typeof sampleRate === 'number' && Math.random() > sampleRate) {
      return SyncPromise.reject('This event has been sampled, will not send event.');
    }

    return new SyncPromise((resolve, reject) => {
      this._prepareEvent(event, scope, hint)
        .then(prepared => {
          if (prepared === null) {
            reject('An event processor returned null, will not send event.');
            return;
          }
github getsentry / sentry-javascript / packages / core / src / baseclient.ts View on Github external
protected _processEvent(event: Event, hint?: EventHint, scope?: Scope): PromiseLike {
    const { beforeSend, sampleRate } = this.getOptions();

    if (!this._isEnabled()) {
      return SyncPromise.reject('SDK not enabled, will not send event.');
    }

    // 1.0 === 100% events are sent
    // 0.0 === 0% events are sent
    if (typeof sampleRate === 'number' && Math.random() > sampleRate) {
      return SyncPromise.reject('This event has been sampled, will not send event.');
    }

    return new SyncPromise((resolve, reject) => {
      this._prepareEvent(event, scope, hint)
        .then(prepared => {
          if (prepared === null) {
            reject('An event processor returned null, will not send event.');
            return;
          }

          let finalEvent: Event | null = prepared;

          try {
            const isInternalException = hint && hint.data && (hint.data as { [key: string]: any }).__sentry__ === true;
            if (isInternalException || !beforeSend) {
              this._getBackend().sendEvent(finalEvent);