Commit Graph
114 Commits
Author SHA1 Message Date
Neko Ayaka 089ca99108 release: v0.11.1 2026-07-17 03:35:49 +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
Neko Ayaka 3779eb6103 release: v0.11.0 2026-07-08 01:20:12 +08:00
RainbowBird cf5ed0766b fix(server): make analytics best-effort
Remove server-side PostHog wiring so request handlers no longer wait on third-party analytics delivery.

Keep auth activity and product event writes best-effort so degraded analytics do not fail session creation.

Signed-off-by: RainbowBird <git@luoling.moe>

Commit-Message-Assisted-by: Codex (via Codex)
2026-06-05 16:27:10 +08:00
RainbowBird 7841df28f8 build(deps): migrate workspace dependencies to catalogs
Move direct external dependency versions into pnpm catalogs and update workspace packages to reference catalog entries.

Signed-off-by: RainbowBird <git@luoling.moe>

Commit-Message-Assisted-by: Codex
2026-06-03 17:12:13 +08:00
RainbowBird ee3ae8fc31 refactor(server): tts migrate to unspeech 2026-06-02 17:34:08 +08:00
RainbowBird c64e48c233 refactor(server): nanoid 2026-06-02 15:40:05 +08:00
RainbowBird 1936a22c95 refactor(server): split openai v1 route pipeline
Separate OpenAI-compatible route wiring from chat, speech, catalog, billing, and telemetry pipeline code.

Signed-off-by: RainbowBird <git@luoling.moe>

Commit-Message-Assisted-by: Claude (via Claude Code)
2026-06-02 15:39:25 +08:00
RainbowBird 03018a6a1e refactor(server): use es-toolkit clamp for query bounds (#1923) 2026-06-02 15:00:37 +08:00
RainbowBird 6e871253e7 feat(server): langfuse 2026-05-30 19:35:37 +08:00
RainbowBird 6abd813cfd chore(server): tracing undici 2026-05-27 18:00:39 +08:00
RainbowBird bf1aba757c feat(server): stream tts provider 2026-05-18 23:33:24 +08:00
RainbowBird af17e9cbc2 feat(server): llm & tts gateway (#1837) 2026-05-18 23:31:07 +08:00
RainbowBird 3984677b01 feat(analytics): integrate PostHog for server-side event tracking
- Added a new PostHog client for capturing server-side business events such as Stripe webhooks and subscription state changes.
- Implemented various tracking functions for pricing funnel steps, character creation, and chat session starts.
- Enhanced the flux meter tests to handle partial charges and report unbilled flux correctly.
- Updated the CharacterDialog and Flux settings pages to track user interactions with analytics events.
- Introduced a mechanism to identify users on PostHog based on authentication state to ensure accurate funnel tracking.
- Added necessary dependencies for PostHog integration in the project.
2026-05-15 16:20:47 +08:00
RainbowBird 272cdae03b feat(server/otel): restructure observability metrics and add active sessions gauge
- Moved RateLimitMetrics import path to a more centralized location.
- Introduced a new file for active sessions gauge to track user sessions in the database.
- Updated index.ts to include new metrics and ensure proper initialization of observability metrics.
- Modified various routes and services to utilize the new observability structure.
- Added smoke tests for HTTP and WebSocket metrics to ensure proper metric registration and functionality.
- Enhanced error handling for metrics reading failures to improve observability.
2026-05-12 23:10:13 +08:00
RainbowBird d24b22a561 refactor(server/otel): hono otel integrate 2026-05-11 12:01:57 +08:00
Neko Ayaka 6d61699d10 release: v0.10.2 2026-05-07 19:36:33 +08:00
Neko Ayaka 6dd370433a release: v0.10.1 2026-05-05 14:10:55 +08:00
Neko Ayaka ca722f69b7 release: v0.10.0 2026-05-03 23:17:03 +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 2ab21879dd chore(deps): bump dependencies 2026-04-18 19:18:17 +08:00
Neko Ayaka f286464e03 chore(deps): bump dependencies 2026-04-15 14:44:59 +08:00
Neko Ayaka 67398494c7 fix(server): zod is required 2026-04-11 04:19:28 +08:00
Neko Ayaka 95eac8e41c chore(deps): bump dependencies 2026-04-11 04:00:49 +08:00
Neko Ayaka dd284f0f27 release: v0.9.0 2026-04-10 14:48:30 +08:00
Neko Ayaka a0caaf3214 release: v0.9.0-rc.1 2026-04-10 03:40:59 +08:00
Neko Ayaka dc7132bb91 release: v0.9.0-beta.7 2026-04-08 04:17:03 +08:00
Neko Ayaka 7f7f50b462 release: v0.9.0-beta.6 2026-04-07 04:58:46 +08:00
Neko Ayaka 389388820f release: v0.9.0-beta.5 2026-04-06 02:10:21 +08:00
RainbowBird 9451cd7cc0 feat(otel): server instrumentation script 2026-04-02 18:21:30 +08:00
RainbowBird d782313464 feat(auth): jwt sign 2026-04-02 17:48:12 +08:00
RainbowBird f1fe161bc0 feat(auth): OIDC (#1531) 2026-04-02 04:24:04 +08:00
LemonNeko 60112eaa85 release: v0.9.0-beta.4 2026-04-01 19:19:22 +08:00
Makito e9be0cf98c release: v0.9.0-beta.3 and ios build 8 2026-04-01 15:35:07 +09:00
Neko Ayaka 497524a22f release: v0.9.0-beta.2 2026-03-31 17:33:53 +08:00
Neko Ayaka c751f48401 release: v0.9.0-beta.1 2026-03-31 14:35:19 +08:00
Neko Ayaka 21a092be71 release: v0.9.0-alpha.36 2026-03-30 22:49:38 +08:00
Makito 0e9122b5ac release: v0.9.0-alpha.35 2026-03-30 14:44:33 +09:00
Neko Ayaka fbf6a05f1e release: v0.9.0-alpha.34 2026-03-29 15:28:42 +08:00
Neko Ayaka d5f24107b7 release: v0.9.0-alpha.32 2026-03-29 02:44:08 +08:00
Neko Ayaka 06570b4dde release: v0.9.0-alpha.31 2026-03-28 12:57:31 +08:00
Makito c0e499b044 release: v0.9.0-alpha.30 2026-03-28 11:52:22 +09:00
Ayaka Neko 129fbf3fcb release: v0.9.0-alpha.29 2026-03-28 04:06:59 +08:00
RainbowBird 45bc5fef22 feat(server/otel): integrate OpenTelemetry logging and emit logs with context 2026-03-28 03:59:09 +08:00
RainbowBird 2f730ef93a feat(server): refactor flux auditing to transaction logging 2026-03-28 02:25:44 +08:00
RainbowBird 405904183f refactor(server): revert a8f445a17985a90d7eb5d981b4231114c3066e94 2026-03-28 02:25:44 +08:00
RainbowBird 2b3721b3ac fix(server/docker): remove apply .env.example 2026-03-28 02:25:44 +08:00
RainbowBird ba3d66de86 feat(server-protocol): introduce shared protocol types for AIRI server clients and frontends
- Added package.json for @proj-airi/server-protocol with necessary configurations.
- Implemented chat event types including WireMessage, SendMessagesRequest, and PullMessagesRequest.
- Defined WebSocket event types and structures for better integration with AIRI components.
- Updated server-runtime and server-sdk to utilize the new server-protocol package.
- Refactored imports across various packages to replace server-shared types with server-protocol types.
- Enhanced type definitions and added TypeScript configurations for better development experience.
2026-03-28 02:25:44 +08:00
RainbowBird ef18772798 feat(server): message queue 2026-03-28 02:25:44 +08:00
RainbowBird 0f9ea751e5 feat(server): official provider router (#1117) 2026-03-28 02:25:44 +08:00