feat(http): send x-mise-ci header for CI environment tracking#7875
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds CI environment detection and tracking to HTTP requests sent to mise-versions. When running in CI environments (GitHub Actions, GitLab CI, CircleCI, Jenkins, etc.), an x-mise-ci: true header is included in tracking requests, enabling server-side filtering to exclude CI requests from MAU calculations.
Changes:
- Adds
post_json_with_headersmethod to HTTP client for sending custom headers - Detects CI environments using
ci_info::is_ci()and includesx-mise-ciheader in tracking requests
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/http.rs | Adds new post_json_with_headers method that accepts custom headers, refactors existing post_json to use it |
| src/versions_host.rs | Detects CI environment and passes x-mise-ci: true header when tracking installs |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
src/versions_host.rs
Outdated
| match HTTP_FETCH.post_json(url, &body).await { | ||
| let mut headers = HeaderMap::new(); | ||
| if ci_info::is_ci() { | ||
| headers.insert("x-mise-ci", "true".parse().unwrap()); |
There was a problem hiding this comment.
Using unwrap() on a header value parse could panic. While 'true' is a valid header value, consider using HeaderValue::from_static('true') which is infallible for static strings and avoids the runtime parse overhead.
5c5bd5b to
7e0b797
Compare
When running in a CI environment (detected via ci_info::is_ci()), both tracking requests and version listing requests now include an x-mise-ci: true header. This allows mise-versions to filter out CI requests from MAU calculations while still collecting the metrics. Changes: - Add post_json_with_headers method for POST requests with custom headers - Add get_text_with_headers method for GET requests with custom headers - Merge GitHub headers with custom headers in get_text_with_headers - Use lazy static VERSIONS_HOST_HEADERS for CI header injection - Send x-mise-ci header in track_install_async (download tracking) - Send x-mise-ci header in list_versions (version requests) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
7e0b797 to
0576f89
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.
| ) -> Result<bool> { | ||
| self.post_json_with_headers(url, body, &HeaderMap::new()) | ||
| .await | ||
| } |
There was a problem hiding this comment.
Unused post_json function marked with dead code suppression
Low Severity
The post_json function is now unused after this PR, since its only caller (track_install_async) now calls post_json_with_headers directly. Searching for .post_json( returns no matches in the codebase. Instead of removing this dead code, the PR adds #[allow(dead_code)] to suppress the compiler warning. Dead code with suppressed warnings clutters the codebase and adds maintenance burden.
## Summary - Skip database storage for requests with `x-mise-ci: true` header - CI requests still emit telemetry (with `is_ci` flag) for analysis - Excludes CI environments from MAU calculations ## Affected endpoints - `POST /api/track` - download tracking - `GET /tools/[tool].toml` - version requests - `GET /[...tool].toml` - legacy version requests ## Behavior When `x-mise-ci: true` header is present: - Telemetry is still emitted with `is_ci: true` for analytics - Database storage is skipped (excludes from MAU/DAU) - Response indicates `ci: true` for download tracking ## Related - jdx/mise#7875 - Client-side changes to send the header 🤖 Generated with [Claude Code](https://claude.com/claude-code) <!-- CURSOR_SUMMARY --> --- > [!NOTE] > Filters CI-originated requests from MAU/DAU while retaining telemetry. > > - Adds `x-mise-ci` header handling to `POST /api/track`, `GET /tools/[tool].toml`, and `GET /[...tool].toml` > - Always emits telemetry with `is_ci` in payload; skips DB writes for CI to avoid counting in MAU/DAU > - `POST /api/track` now returns `{ ci: true }` when CI is detected > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit b6b86e9. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY --> Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
Hyperfine Performance
|
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|---|---|---|---|---|
mise-2026.1.8 x -- echo |
15.4 ± 0.3 | 14.5 | 16.6 | 1.00 |
mise x -- echo |
16.0 ± 0.4 | 15.1 | 17.4 | 1.04 ± 0.03 |
mise env
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|---|---|---|---|---|
mise-2026.1.8 env |
15.1 ± 0.5 | 14.0 | 17.2 | 1.00 |
mise env |
15.7 ± 0.6 | 14.6 | 20.5 | 1.04 ± 0.05 |
mise hook-env
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|---|---|---|---|---|
mise-2026.1.8 hook-env |
15.1 ± 0.3 | 14.2 | 16.2 | 1.00 |
mise hook-env |
15.7 ± 0.3 | 14.9 | 16.7 | 1.04 ± 0.03 |
mise ls
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|---|---|---|---|---|
mise-2026.1.8 ls |
14.0 ± 0.3 | 13.0 | 14.8 | 1.00 |
mise ls |
14.5 ± 0.3 | 13.7 | 15.9 | 1.04 ± 0.03 |
xtasks/test/perf
| Command | mise-2026.1.8 | mise | Variance |
|---|---|---|---|
| install (cached) | 83ms | 83ms | +0% |
| ls (cached) | 54ms | 55ms | -1% |
| bin-paths (cached) | 56ms | 57ms | -1% |
| task-ls (cached) | 233ms | 235ms | +0% |
### 🚀 Features - **(doctor)** add backend mismatch warnings by @jdx in [#7847](#7847) - **(http)** add rename_exe support for archive extraction by @jdx in [#7874](#7874) - **(http)** send x-mise-ci header for CI environment tracking by @jdx in [#7875](#7875) - **(install)** auto-install plugins from [plugins] config section by @jdx in [#7856](#7856) - **(registry)** add vercel by @mikecurtis in [#7844](#7844) - **(task)** support glob patterns in task_config.includes by @jdx in [#7870](#7870) - **(task)** add task templates for reusable task definitions by @jdx in [#7873](#7873) ### 🐛 Bug Fixes - **(backend)** change registry mismatch log from info to debug by @jdx in [#7858](#7858) - **(ci)** use squash merge for auto-merge-release workflow by @jdx in [7e5e71e](7e5e71e) - **(ci)** remove --auto flag to merge immediately when CI passes by @jdx in [23ed2ed](23ed2ed) - **(github)** select platform-matching provenance file for SLSA verification by @jdx in [#7853](#7853) - **(go)** filter out version "1" from available versions by @jdx in [#7871](#7871) - **(install)** skip CurDir components when detecting archive structure by @jdx in [#7868](#7868) - **(pipx)** ensure Python minor version symlink exists for postinstall hooks by @jdx in [#7869](#7869) - **(registry)** prevent duplicate -stable suffix in Flutter download URLs by @jdx in [#7872](#7872) - **(task)** pass env to usage parser for env-backed arguments by @jdx in [#7848](#7848) - **(task)** propagate MISE_ENV to child tasks when using -E flag by @jdx in [06ee776](06ee776) - **(vfox-dotnet)** use os.execute() to fix Windows installation by @prodrigues1912 in [#7843](#7843) ### 📚 Documentation - update cache-behavior with env_cache information by @jdx in [#7849](#7849) ###◀️ Revert - remove task inheritance from parent configs in monorepos by @jdx in [#7851](#7851) - Revert "fix(ci): remove --auto flag to merge immediately when CI passes" by @jdx in [0606187](0606187) ### 📦 Registry - add mago ([aqua:carthage-software/mago](https://github.com/carthage-software/mago)) by @scop in [#7845](#7845) ### Chore - **(ci)** auto-merge release branch into main daily at 4am CST by @jdx in [#7852](#7852) ### New Contributors - @mikecurtis made their first contribution in [#7844](#7844) - @prodrigues1912 made their first contribution in [#7843](#7843)
Summary
x-mise-ci: trueheader to requests when running in CI environmentsci_info::is_ci()to detect CI environments (GitHub Actions, GitLab CI, CircleCI, Jenkins, etc.)post_json_with_headersandget_text_with_headersmethods to http clientAffected requests
POST /api/track) - when installing toolsGET /tools/{tool}.toml) - when listing available versionsThis allows mise-versions to filter out CI requests from MAU calculations while still collecting metrics data.
Test plan
🤖 Generated with Claude Code
Note
Adds CI-aware request headers and exposes header-capable HTTP helpers.
get_text_with_headersandpost_json_with_headersinsrc/http.rs; existingget_text/post_jsondelegate to these. Extra headers are merged with GitHub headers.VERSIONS_HOST_HEADERS(addsx-mise-ci: truewhenci_info::is_ci()), applied toGET https://mise-versions.jdx.dev/tools/{tool}.tomlandPOST /api/trackinsrc/versions_host.rs.Written by Cursor Bugbot for commit 0576f89. This will update automatically on new commits. Configure here.