import { allows } from './consent'; // Lightweight custom-event helper (OpenPanel). // // The hosted openshorts.app build loads OpenPanel (see index.html), which // exposes `window.op`. Self-hosted builds, ad-blockers or offline dev simply // won't have it — every call here is a safe no-op in that case, so analytics // can never break the app or leak into the open-source experience. // // Events (name — meaning): // - SocialNudgeSeen — post-generation "connect socials" banner rendered // - SocialNudgeConnect — its connect button clicked (opens the Postiz UI) // - SocialNudgeDismissed — its X clicked (persisted, never shown again) // - ClipTutorialStarted — first-login tutorial: user hit Start // - ClipTutorialSkipped — first-login tutorial dismissed (intro or coach) // - ClipTutorialCompleted— first Clip Generator job finished with clips export function track(event, options) { try { // `op` is a queueing stub until consent loads op1.js, so a call made before // the visitor accepted would be flushed the moment they did. Check first. if (!allows('analytics')) return; if (typeof window !== 'undefined' && typeof window.op === 'function') { const props = (options && options.props) || {}; window.op('track', event, props); } } catch (_) { /* analytics must never throw into the app */ } }