import type { RumEvent, RumEventDomainContext } from '@datadog/browser-rum'; import { datadogRum } from '@datadog/browser-rum'; /** * Invokes the `beforeSend` captured on the most recent `datadogRum.init` call * with the given event partial. Returns whatever `beforeSend` returns (false * drops, true/void proceeds). The helper mutates `event` in place, so callers * that need to inspect mutations should hold a reference to the event they * pass in. */ export const processEvent = ( event: Partial, context: RumEventDomainContext = {} ): boolean | void => { const beforeSend = jest.mocked(datadogRum.init).mock.calls.at(-1)?.[0].beforeSend as ( e: RumEvent, c: RumEventDomainContext ) => boolean | void; return beforeSend(event as RumEvent, context); };