Commit Graph
19 Commits
Author SHA1 Message Date
Lovehsigure_520 78ec4dd8ba fix(ui-server-auth): trust new Go backend origin (#2043)
## Summary
- trust the new Railway Go backend in the standalone Auth UI
- preserve exact-origin validation for untrusted redirects
- document the root cause, delivery plan, and production validation path

## Root cause
The Auth UI rejected
`api_server_url=https://airi-server-next.up.railway.app`, fell back to
the legacy API, and surfaced `Load failed` at the browser CORS boundary.

## Test plan
- focused bootstrap-context tests: 6/6
- complete Auth UI suite: 27/27
- `vue-tsc --noEmit`
- production Vite build
- emitted bundle contains the exact new backend origin
2026-07-10 15:03:10 +00:00
RainbowBird 0e4dc69ec0 fix(analytics): normalize PostHog event semantics (#2041) 2026-07-10 13:54:23 +08:00
RainbowBird 0642ede8d1 feat(analytics): expand PostHog coverage and forward server business facts (#2038)
## What

Closes the three structural gaps in AIRI's product analytics: the signup
surface had zero instrumentation, the payment funnel had no terminator
in PostHog, and SPA route changes emitted no pageviews. Also adds
semantic events for character cards, desktop-only features, and
data-maintenance actions.

## User paths

- User signs up / logs in / verifies email / resets password / links
OAuth / deletes account → each step now emits a PostHog event from
`apps/ui-server-auth` (previously fully uninstrumented), with
`identify()` wired on session load so anonymous funnel events merge into
the user person.
- User pays via Stripe → webhook writes `product_events` as before, and
the product-events service now forwards `payment_completed` (plus signup
and subscription lifecycle facts) to PostHog via posthog-node
`captureImmediate`, keyed by the Better Auth user id → the
`checkout_started → payment_completed` funnel closes end-to-end.
Per-request LLM/TTS volume is explicitly not forwarded.
- User navigates between routes in any surface (web / desktop / pocket /
docs) → `$pageview` + `$pageleave` fire per route change via the
posthog-js `defaults: '2025-05-24'` preset in the shared
`posthog.config.ts`.
- User creates / imports / duplicates / edits a ccv3 card, switches
stage background, runs destructive data actions (export / import / clear
chats, reset providers, wipe app data), or uses desktop differentiators
(Spotlight send, widget windows, in-app updater, MCP server management,
pairing QR) → dedicated low-cardinality events.

## Notable decisions

- Server forwarding defaults on: `POSTHOG_PROJECT_KEY` defaults to the
shared browser-safe phc_* project key; set it to an empty string to
disable. Postgres `product_events` remains the source of truth.
- Cross-surface events (`oauth_callback_failed`, account lifecycle)
share one stage vocabulary exported from stage-ui so the two emitters
cannot drift silently.
- Events captured right before full-page navigation use `sendBeacon` so
they survive the redirect (checkout, OAuth consent handoff, login
redirect).
- Removed dead wrappers (`trackSignup`, `trackFirstModelSelected`,
`trackModelChanged`) that duplicated live event streams under second
names.

## How tested

- `pnpm -F @proj-airi/server exec vitest run
src/services/domain/product-events.test.ts` — 6 passed, covering the
forwarding allowlist, the `user_signed_up → signup_completed` mapping,
non-forwarded per-request actions, and a throwing sink not failing the
webhook path nor losing the DB row.
- stage-ui suites (`use-analytics`, `use-linked-accounts`, exports
contract) — 22 passed, including new account/card/data/desktop event
assertions.
- Real transport smoke: posthog-node `captureImmediate` against
`us.i.posthog.com` with the production key resolved in 1380ms (one
`server_forwarding_smoke_test` event left in the project; filter by
event name).
- Browser-tested pageviews: `VITE_ENABLE_POSTHOG=true` dev build, two
`history.pushState` route changes each produced a `$pageview` with
`$pathname`, `navigation_type: pushState`, previous-page dwell time, and
the `surface` super property; batched POST to `us.i.posthog.com/e/`
returned 200. Note: posthog-js drops events from automated browsers
(`navigator.webdriver`) by default — the verification session bypassed
the bot filter locally; production config is untouched.
- Typecheck and lint pass for server, stage-ui, stage-pages, stage-web,
stage-tamagotchi, ui-server-auth.

Full verification record:
`apps/server/docs/ai-context/verifications/posthog-forwarding-and-pageview.md`

## Follow-ups (not in this PR)

- Bot channel usage stats (Discord / Telegram) once they route through
server-runtime counters.
- Main-process desktop events (tray menu, global shortcut fire) need
renderer relay plumbing.
- Confirm `payment_completed` arrives in PostHog after the first real
Stripe payment post-deploy.

https://claude.ai/code/session_01Q1yGavkQ1P41YhTWE4XKex
2026-07-08 15:33:39 +08:00
RainbowBird 4f80affcd3 feat(admin-dashboard): add support for Bedrock and OpenAI-compatible LLM slices in admin router config
- Implemented `buildBedrockSlice` function to handle multi-kilobyte Bedrock bearer tokens.
- Enhanced `createAdminRouterConfigService` to classify Bedrock and OpenAI-compatible LLM upstreams by baseURL.
- Added new interfaces for `AdminRouterBedrockSlice` and `AdminRouterOpenAICompatibleSlice`.
- Updated router config form to support Bedrock and OpenAI-compatible slices.
- Created tests for Bedrock and OpenAI-compatible slice compilation and behavior.
- Modified UI components to accommodate new slice types and improve user experience.
- Ensured proper normalization of API server URLs to HTTPS when necessary.
2026-07-01 02:14:12 +08:00
RainbowBird 8518c65aa4 feat(auth): enhance trusted admin redirect handling and add local patterns 2026-06-11 22:26:39 +08:00
RainbowBird a331d3a42a feat(auth): update AUTH_UI_URL to point to accounts.airi.build 2026-06-09 18:01:34 +08:00
RainbowBird 57ba232432 feat(auth): migrate auth ui to unique domain 2026-06-09 00:15:34 +08:00
Lulu d91dab7bf0 fix(ui-server-auth): clarify social-only email sign-in hint (#1879) 2026-06-08 13:47:52 +08:00
Liet Blue dc6807a21f feat(server-dashboard): add admin UI for AIRI operations (#1942) 2026-06-04 16:16:19 +08:00
RainbowBird 6f0b7e0b9b feat(auth): delete account (#1756) 2026-04-28 20:53:00 +08:00
RainbowBirdandLiet Blue 0af7d294a8 feat(auth): oidc jwt bearer plugin & linked social accounts (#1753)
Co-authored-by: Liet Blue <127093491+lietblue@users.noreply.github.com>
2026-04-28 16:56:51 +08:00
RainbowBirdandLiet Blue 172e4ce59c feat(auth): email login & profile (#1745)
Co-authored-by: Liet Blue <127093491+lietblue@users.noreply.github.com>
2026-04-28 00:07:38 +08:00
Neko Ayaka 6d68cfbd92 refactor(stage-web,ui-server-auth): better ui of auth 2026-04-15 04:32:19 +08:00
Neko Ayaka 9fe3abdf5b chore(ci): publishes ui-server-auth as assets image 2026-04-10 19:36:53 +08:00
Neko Ayaka abc0cb0bc7 refactor(ui-server-auth,server): use better design of signin page 2026-04-10 16:25:11 +08:00
Neko Ayaka ffb7c2e05d refactor(stage-web,ui-server-auth): rollback sign in design 2026-04-07 18:18:55 +08:00
LemonNeko 883ec945d2 feat(stage-pocket): WebSocket status indicator + shared i18n (#1586) 2026-04-06 19:54:21 +08:00
Neko Ayaka 248e28412a wip(ui-server-auth): basic ui, not yet finalized 2026-04-03 15:43:28 +08:00
Neko Ayaka af63c26649 feat(ui-server-auth): init server auth page 2026-04-03 01:26:38 +08:00