How to use the @sentry/core.addGlobalEventProcessor function in @sentry/core

To help you get started, we’ve selected a few @sentry/core 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-react-native / src / js / integrations / devicecontext.ts View on Github external
public setupOnce(): void {
    addGlobalEventProcessor(async (event: Event) => {
      const self = getCurrentHub().getIntegration(DeviceContext);
      if (!self) {
        return event;
      }

      try {
        // tslint:disable-next-line: no-unsafe-any
        const deviceContexts = await RNSentry.deviceContexts();
        event.contexts = { ...deviceContexts, ...event.contexts };
      } catch (_Oo) {
        // Something went wrong, we just continue
      }

      return event;
    });
  }
github getsentry / sentry-react-native / src / js / integrations / reactnative.ts View on Github external
public setupOnce(): void {
    this._handleUnhandledRejections();
    this._handleOnError();

    addGlobalEventProcessor((event: Event) => {
      const self = getCurrentHub().getIntegration(ReactNative);
      if (self) {
        // getCurrentHub().configureScope(scope => {
        //   scope.addScopeListener();
        // });
      }
      return event;
    });
  }
github getsentry / sentry-react-native / src / js / integrations / debugsymbolicator.ts View on Github external
public setupOnce(): void {
    // tslint:disable-next-line: cyclomatic-complexity
    addGlobalEventProcessor(async (event: Event, hint?: EventHint) => {
      const self = getCurrentHub().getIntegration(DebugSymbolicator);
      // tslint:disable: strict-comparisons
      if (!self || hint === undefined || hint.originalException === undefined) {
        return event;
      }

      const reactError = hint.originalException as ReactNativeError;

      // tslint:disable: no-unsafe-any
      const parseErrorStack = require("react-native/Libraries/Core/Devtools/parseErrorStack");
      const stack = parseErrorStack(reactError);

      // Ideally this should go into contexts but android sdk doesn't support it
      event.extra = {
        ...event.extra,
        componentStack: reactError.componentStack,
github getsentry / sentry-javascript / packages / browser / src / integrations / useragent.ts View on Github external
public setupOnce(): void {
    addGlobalEventProcessor((event: Event) => {
      if (getCurrentHub().getIntegration(UserAgent)) {
        if (!global.navigator || !global.location) {
          return event;
        }

        // Request Interface: https://docs.sentry.io/development/sdk-dev/event-payloads/request/
        const request = event.request || {};
        request.url = request.url || global.location.href;
        request.headers = request.headers || {};
        request.headers['User-Agent'] = global.navigator.userAgent;

        return {
          ...event,
          request,
        };
      }
github getsentry / sentry-react-native / src / js / integrations / release.ts View on Github external
public setupOnce(): void {
    addGlobalEventProcessor(async (event: Event) => {
      const self = getCurrentHub().getIntegration(Release);
      if (!self) {
        return event;
      }

      try {
        // tslint:disable-next-line: no-unsafe-any
        const release = (await RNSentry.fetchRelease()) as {
          build: string;
          id: string;
          version: string;
        };
        if (release) {
          event.release = `${release.id}-${release.version}`;
          event.dist = `${release.build}`;
        }
github getsentry / sentry-javascript / packages / browser / src / integrations / linkederrors.ts View on Github external
public setupOnce(): void {
    addGlobalEventProcessor((event: Event, hint?: EventHint) => {
      const self = getCurrentHub().getIntegration(LinkedErrors);
      if (self) {
        return self._handler(event, hint);
      }
      return event;
    });
  }
github getsentry / sentry-javascript / packages / node / src / integrations / linkederrors.ts View on Github external
public setupOnce(): void {
    addGlobalEventProcessor((event: Event, hint?: EventHint) => {
      const self = getCurrentHub().getIntegration(LinkedErrors);
      if (self) {
        return (self.handler(event, hint) as unknown) as PromiseLike;
      }
      return event;
    });
  }