Some checks failed
build-images / web (push) Has been cancelled
vision2026-ci / Python SDK resource tests (push) Has been cancelled
build-images / api (push) Has been cancelled
build-images / worker-gpu (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (comfy-workflow-schema) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (effects-core) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (eventbus-types) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (growth-analytics) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (provider-adapter-kit) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (publishing-connectors) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (render-core) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (shot-template-schema) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (trends-schema) (push) Has been cancelled
vision2026-ci / Desktop engine crates (test + clippy + fmt) (push) Has been cancelled
codeql / Analyze (javascript-typescript) (push) Has been cancelled
codeql / Analyze (python) (push) Has been cancelled
perf / API hot-path micro-smoke (budgeted) (push) Has been cancelled
perf / Desktop engine crates (release build check) (push) Has been cancelled
vision2026-ci / API phase modules (ruff + pytest) (push) Has been cancelled
vision2026-ci / Alembic upgrade + drift check (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (caption-engine) (push) Has been cancelled
Paid, hosted product at menivor.com, now retired as a company project. Fresh squashed history of the cleaned working tree (secret-scanned, no .env, no customer data, no outreach logs). Built on MoneyPrinterTurbo (MIT, harry0703) — see NOTICE.
50 lines
1.9 KiB
Python
50 lines
1.9 KiB
Python
"""Post-render conversion funnel: client-fired steps with no other DB trace.
|
|
|
|
POST /funnel/pricing-viewed the signed-in caller viewed /pricing
|
|
|
|
``share_page_viewed`` and ``checkout_started`` are recorded inline where they
|
|
already happen server-side (``app.controllers.v1.share.create_share_endpoint``
|
|
and the four checkout-session endpoints in ``billing.py`` / ``credit_packs.py``
|
|
/ ``monthly_plans.py`` / ``premium_credits.py``). A pricing-page *view* leaves
|
|
no other row anywhere, so it needs its own tiny endpoint, pinged once by the
|
|
`/pricing` page's client for signed-in visitors. Authenticated (the funnel
|
|
only tracks per-user firsts); rate-limited generously since it is a pure page
|
|
view, not a write with side effects.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
from fastapi import Request
|
|
from loguru import logger
|
|
|
|
from app.controllers import base
|
|
from app.controllers.v1.base import new_router
|
|
from app.core.auth import resolve_principal
|
|
from app.models.db.base import get_session
|
|
from app.services.ratelimit import enforce_rate_limit
|
|
from app.utils import utils
|
|
|
|
router = new_router()
|
|
|
|
_RATE_LIMIT = 30
|
|
_RATE_WINDOW_S = 3600
|
|
|
|
|
|
@router.post("/funnel/pricing-viewed", summary="Record the signed-in caller viewed /pricing")
|
|
def pricing_viewed(request: Request):
|
|
request_id = base.get_task_id(request)
|
|
with get_session() as session:
|
|
user = resolve_principal(request, session, request_id)
|
|
user_id = str(user.id)
|
|
enforce_rate_limit(request, f"funnel:pricing_viewed:{user_id}", limit=_RATE_LIMIT, window_s=_RATE_WINDOW_S)
|
|
try:
|
|
from app.services.funnel.store import record_step
|
|
|
|
record_step(user_id, "pricing_viewed", session_factory=get_session)
|
|
except Exception as exc: # noqa: BLE001 - instrumentation only, never fails the request
|
|
logger.warning(f"funnel_events: pricing_viewed record skipped: {type(exc).__name__}")
|
|
return utils.get_response(200, {"recorded": True})
|
|
|
|
|
|
__all__ = ["router"]
|