Files
openhuman/app/.env.example
T
CodeGhost21andGitHub bdbb83772e feat(observability): Sentry release tracking, source maps, and end-to-end DSN plumbing (#734)
* ci(release): bake Sentry DSN into shipped tauri bundle

Released builds weren't reporting anything to Sentry. Root cause: the
tauri.conf.json `beforeBuildCommand` re-runs `vite build` inside
`cargo tauri build`. The prior `yarn build` step set `VITE_SENTRY_DSN`
for its own run, but the tauri step did not — so the rebuild produced
a DSN-less `dist/` that overwrote the good one, and the shipped web UI
initialized Sentry with an empty DSN (`initSentry` returns early when
`!SENTRY_DSN`).

Fix:

- `release.yml` / `build-desktop` — declare `VITE_SENTRY_DSN` and
  `VITE_DEBUG` on the tauri-build step so the `beforeBuildCommand`
  rebuild bakes them into the final bundle.
- `release-packages.yml` / `build-cli-linux-arm64` — guard against a
  missing `vars.OPENHUMAN_SENTRY_DSN` so the Linux arm64 CLI tarball
  cannot ship without error reporting baked in via `option_env!`.

The core sidecar's `option_env!("OPENHUMAN_SENTRY_DSN")` already gets
the value from the dedicated "Build sidecar core binary" step; the
tauri shell doesn't rebuild it (separate crate, not a workspace dep),
so the baked DSN survives into the bundled installer.

* feat(observability): Sentry release tracking + source maps (#405)

Tags every Sentry event with a canonical release identifier shared by
the frontend and Rust core, uploads source maps so stack traces are
symbolicated in the dashboard, and adds a CLI probe for repeatable
verification of any future release.

Release identifier

  openhuman@<semver>[+<short_git_sha>]

- Frontend (`app/src/utils/config.ts::SENTRY_RELEASE`) builds the tag
  from `VITE_BUILD_SHA`.
- Core sidecar (`src/main.rs::build_release_tag`) builds the same tag
  from `option_env!("OPENHUMAN_BUILD_SHA")`, so events from both
  surfaces group under one release. Cargo's fingerprint already tracks
  `option_env!` changes.

Environment separation

- Frontend: new `APP_ENVIRONMENT` export (`development` | `staging` |
  `production`) derived from `VITE_OPENHUMAN_APP_ENV`, passed to
  `Sentry.init`.
- Core: `resolve_environment` honors `OPENHUMAN_APP_ENV` at runtime,
  falling back to `debug_assertions` detection.

Source-map upload

- `@sentry/vite-plugin` added as an app devDependency.
- `vite.config.ts` emits source maps unconditionally and registers the
  plugin only when `SENTRY_AUTH_TOKEN` is present, so local dev skips
  silently. The plugin uploads `dist/**/*.js{,.map}` under the
  canonical release name and then deletes the on-disk `.map` files so
  they never ship to end users.

CI wiring (`release.yml` + `release-packages.yml`)

- `Build frontend` and `Build and package Tauri app` both receive
  `VITE_BUILD_SHA`, `SENTRY_RELEASE`, `SENTRY_AUTH_TOKEN`, `SENTRY_ORG`,
  `SENTRY_PROJECT_FRONTEND`. The tauri step needs the same env because
  its `beforeBuildCommand` re-runs `vite build`.
- `Build sidecar core binary` receives `OPENHUMAN_BUILD_SHA` so
  `option_env!` bakes the short SHA into the release tag.
- `build-cli-linux-arm64` mirrors `OPENHUMAN_BUILD_SHA` and
  `OPENHUMAN_APP_ENV` for the arm64 CLI tarball.

Verification support

- New `openhuman sentry-test` CLI subcommand captures an `Error`-level
  event against the currently-initialized client, flushes, and prints
  the event UUID. Optional `--panic` flag exercises the panic
  integration. Requires a DSN resolvable at runtime or baked in at
  compile time; exits non-zero otherwise so misconfiguration is loud.
- `src/main.rs` now loads `.env` before `sentry::init`, so a DSN
  defined only in the repo-local dotenv file (common dev case) is
  honored by the startup-time Sentry client.

Docs

- `docs/sentry.md` covers the release identifier, environment table,
  source-map pipeline, required CI variables, and a verification
  runbook with troubleshooting tips.
- `.env.example` + `app/.env.example` document the new build-time vars.
2026-04-21 22:48:20 -07:00

53 lines
2.2 KiB
Bash

# Frontend (Vite) environment variables
# Copy to app/.env.local and fill in values as needed.
# Only VITE_-prefixed vars are exposed to the browser.
#
# Tags: [required] must be set, [optional] has a sensible default or can be blank
# [optional] App environment selector for default backend fallback: production | staging
VITE_OPENHUMAN_APP_ENV=staging
# [optional] Core RPC endpoint (Tauri sets this automatically; override for web-only dev)
VITE_OPENHUMAN_CORE_RPC_URL=http://127.0.0.1:7788/rpc
# [required] Backend API URL (web fallback when core RPC is unavailable)
VITE_BACKEND_URL=https://staging-api.tinyhumans.ai
# [optional] Telegram bot username used for managed DM linking fallback (default: openhuman_bot)
VITE_TELEGRAM_BOT_USERNAME=openhuman_bot
# [optional] Skills GitHub repository slug (default: tinyhumansai/openhuman-skills)
VITE_SKILLS_GITHUB_REPO=tinyhumansai/openhuman-skills
# [optional] Sentry DSN for error reporting (leave blank to disable)
VITE_SENTRY_DSN=
# [optional] Short git SHA baked into the frontend bundle for the canonical
# Sentry release tag `openhuman@<version>+<sha>`. CI sets this automatically
# from `needs.prepare-build.outputs.sha`; leave blank locally (release tag
# falls back to `openhuman@<version>`).
VITE_BUILD_SHA=
# [CI-only] Sentry source-map upload — set on CI to enable
# `@sentry/vite-plugin`. Leave blank locally; the plugin skips when
# `SENTRY_AUTH_TOKEN` is empty.
# SENTRY_AUTH_TOKEN=
# SENTRY_ORG=
# SENTRY_PROJECT=
# SENTRY_RELEASE=
# [optional] Dev-only: auto-inject JWT token to skip login flow
VITE_DEV_JWT_TOKEN=
# [optional] Dev-only: force onboarding flow to always show
VITE_DEV_FORCE_ONBOARDING=false
# [optional] Client-side timeout for skill callTool/triggerSync (seconds; default 120, max 3600).
# Should match OPENHUMAN_TOOL_TIMEOUT_SECS on the core when set.
# VITE_TOOL_TIMEOUT_SECS=
# [optional] Minimum desktop app semver to complete OAuth deep links (openhuman://oauth/success). Leave unset in dev.
# VITE_MINIMUM_SUPPORTED_APP_VERSION=0.51.0
# [optional] Download page when OAuth is blocked due to an outdated build (default: GitHub releases/latest).
# VITE_LATEST_APP_DOWNLOAD_URL=https://github.com/tinyhumansai/openhuman/releases/latest