All Downloads are FREE. Search and download functionalities are using the official Maven repository.

package.build.esm.eventProcessors.js Maven / Gradle / Ivy

There is a newer version: 8.39.0
Show newest version
import { SyncPromise, logger, isThenable } from '@sentry/utils';
import { DEBUG_BUILD } from './debug-build.js';

/**
 * Process an array of event processors, returning the processed event (or `null` if the event was dropped).
 */
function notifyEventProcessors(
  processors,
  event,
  hint,
  index = 0,
) {
  return new SyncPromise((resolve, reject) => {
    const processor = processors[index];
    if (event === null || typeof processor !== 'function') {
      resolve(event);
    } else {
      const result = processor({ ...event }, hint) ;

      DEBUG_BUILD && processor.id && result === null && logger.log(`Event processor "${processor.id}" dropped event`);

      if (isThenable(result)) {
        void result
          .then(final => notifyEventProcessors(processors, final, hint, index + 1).then(resolve))
          .then(null, reject);
      } else {
        void notifyEventProcessors(processors, result, hint, index + 1)
          .then(resolve)
          .then(null, reject);
      }
    }
  });
}

export { notifyEventProcessors };
//# sourceMappingURL=eventProcessors.js.map




© 2015 - 2024 Weber Informatics LLC | Privacy Policy