import { isSanitizedJourneyEvent, sanitizeJourneyEvent } from '../core/sanitize'; import { isJourneyDebugEnabled } from '../global'; import type { JourneyEvent } from '../core/types'; /** * Log a terminal journey to the browser console when debugging is enabled. * No-op unless `__stJourney.enableDebugging()` / `enableJourneyDebugging()` was used * (reload after enabling from DevTools). * * There is no reliable cross-browser API to detect an open DevTools console; * use the explicit debug flag instead. */ export function sendToConsole(event: JourneyEvent): void { if (!isJourneyDebugEnabled()) { return; } const j = isSanitizedJourneyEvent(event) ? event.journey : sanitizeJourneyEvent(event).journey; // eslint-disable-next-line no-console -- intentional debug sink console.debug(`[journey] ${j.name} → ${j.outcome}`, j); }