mirror of
https://github.com/hyperdxio/hyperdx
synced 2026-04-21 13:37:15 +00:00
## Summary Migrates the CLI from using API URLs (`-s, --server`) to app URLs (`-a, --app-url`), and adds interactive login prompts on expired/missing sessions. Linear: https://linear.app/clickhouse/issue/HDX-3976 --- ## Breaking Change **The `-s` / `--server` flag has been removed.** All commands (except `upload-sourcemaps`) now use `-a` / `--app-url` instead. The URL semantics have changed: users should now provide the **HyperDX app URL** (e.g. `http://localhost:8080`), not the API URL. The CLI derives the API URL internally by appending `/api`. | Before | After | |---|---| | `hdx auth login -s http://localhost:8080/api` | `hdx auth login -a http://localhost:8080` | | `hdx tui -s http://localhost:8080/api` | `hdx tui -a http://localhost:8080` | | `hdx sources -s http://localhost:8080/api` | `hdx sources -a http://localhost:8080` | > **Note:** `upload-sourcemaps` is unchanged — it still uses `--apiUrl` / `-u` as before. **Existing saved sessions are auto-migrated** — old `session.json` files with `apiUrl` are converted to `appUrl` on first load. --- ## Changes ### `apiUrl` → `appUrl` migration - `ApiClient` now accepts `appUrl` and derives `apiUrl` by appending `/api` - `SessionConfig` stores `appUrl`; legacy sessions with `apiUrl` auto-migrate on load - All commands use `-a, --app-url` instead of `-s, --server` ### Interactive login flow (HDX-3976) - `hdx auth login` no longer requires `-a` — it prompts interactively for login method, app URL, then credentials - Login method selector is extensible (currently Email/Password, designed for future OAuth support) - **Expired sessions now prompt for re-login** instead of printing an error and exiting - The app URL field is autofilled with the last used value so users can just hit Enter - No longer requires manual deletion of `~/.config/hyperdx/cli/session.json` to recover from expired sessions - Non-TUI commands (`sources`, `dashboards`, `query`) also launch interactive login on expired/missing sessions via `ensureSession()` helper ### TUI (`App.tsx`) - Detects expired session on mount and shows "Session expired" message with editable URL field - If the user changes the URL during re-login, the client is recreated - 401/403 errors during data loading bounce back to the login screen instead of showing raw error messages ### Input validation & error handling - App URL inputs are validated — rejects non-`http://` or `https://` URLs with a clear inline error - `ApiClient.login()` catches network/URL errors and returns `false` instead of crashing - `ApiClient.login()` verifies the session after a 302/200 response by calling `checkSession()` — prevents false "Logged in" messages from servers that return 302 without a valid session (e.g. SSO redirects) - Login failure messages now mention both credentials and server URL --- ## Files changed - `packages/cli/src/api/client.ts` — accepts `appUrl`, derives `apiUrl`, exposes `getAppUrl()`, login validation - `packages/cli/src/utils/config.ts` — `SessionConfig.appUrl`, backward-compat migration - `packages/cli/src/cli.tsx` — `-a` flag, `LoginPrompt`, `ReLoginPrompt`, `ensureSession()`, URL validation - `packages/cli/src/App.tsx` — expired session detection, editable URL on re-login, 401/403 handling - `packages/cli/src/components/LoginForm.tsx` — app URL prompt field, `message` prop, URL validation |
||
|---|---|---|
| .. | ||
| src | ||
| .gitignore | ||
| AGENTS.md | ||
| CHANGELOG.md | ||
| CONTRIBUTING.md | ||
| eslint.config.mjs | ||
| package.json | ||
| README.md | ||
| tsconfig.json | ||
| tsup.config.ts | ||
@hyperdx/cli
Command line interface for HyperDX.
Uploading Source Maps
Upload JavaScript source maps to HyperDX for stack trace de-obfuscation.
In your build pipeline, run the CLI tool:
npx @hyperdx/cli upload-sourcemaps \
--serviceKey "$HYPERDX_API_ACCESS_KEY" \
--apiUrl "$HYPERDX_API_URL" \
--path .next \
--releaseId "$RELEASE_ID"
You can also add this as an npm script:
{
"scripts": {
"upload-sourcemaps": "npx @hyperdx/cli upload-sourcemaps --path=\".next\""
}
}
Options
| Flag | Description | Default |
|---|---|---|
-k, --serviceKey <key> |
HyperDX service account API key | |
-p, --path <dir> |
Directory containing sourcemaps | . |
-u, --apiUrl <url> |
HyperDX API URL (required for self-hosted deployments) | |
-rid, --releaseId <id> |
Release ID to associate with the sourcemaps | |
-bp, --basePath <path> |
Base path for the uploaded sourcemaps |
Optionally, set the HYPERDX_SERVICE_KEY environment variable to avoid passing
the --serviceKey flag.