clipwright/dashboard/src/lib/analytics.js
pedro-bento edcfeaf9d5 refactor: remove cloud/ billing mode and flatten to self-hosted-only
- Delete the entire cloud/ package (Stripe billing, auth/OAuth, metering, API keys,
  account erasure, lifecycle/digest emails, R2 archive, autopilot, MCP OAuth,
  proxy ledger, managed keys) and all BILLING_ENABLED branches in app.py
- Keep self-host behavior via no-op shims; /api/config now returns
  {youtubeUrlEnabled, jobRetentionSeconds, localLlm}
- Remove cloud tests (31 files), alembic/, log_view.py, requirements-billing.txt,
  docker-compose.cloud.yml; update CLI to Postiz + /api/config; clean docs/skills
- Flatten dashboard: remove auth/billing/pricing/history chrome, inert config-only AuthContext
- Fix residual test drift; lint + build + compile all green
2026-10-04 17:02:55 +01:00

29 lines
1.3 KiB
JavaScript

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 */
}
}