Skip to content

Comments

feat(http): send x-mise-ci header for CI environment tracking#7875

Merged
jdx merged 1 commit intomainfrom
feat/ci-tracking-header
Jan 28, 2026
Merged

feat(http): send x-mise-ci header for CI environment tracking#7875
jdx merged 1 commit intomainfrom
feat/ci-tracking-header

Conversation

@jdx
Copy link
Owner

@jdx jdx commented Jan 28, 2026

Summary

  • Adds x-mise-ci: true header to requests when running in CI environments
  • Uses ci_info::is_ci() to detect CI environments (GitHub Actions, GitLab CI, CircleCI, Jenkins, etc.)
  • Adds post_json_with_headers and get_text_with_headers methods to http client

Affected requests

  • Download tracking (POST /api/track) - when installing tools
  • Version listing (GET /tools/{tool}.toml) - when listing available versions

This 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.

  • New get_text_with_headers and post_json_with_headers in src/http.rs; existing get_text/post_json delegate to these. Extra headers are merged with GitHub headers.
  • Introduces VERSIONS_HOST_HEADERS (adds x-mise-ci: true when ci_info::is_ci()), applied to GET https://mise-versions.jdx.dev/tools/{tool}.toml and POST /api/track in src/versions_host.rs.
  • No functional changes outside versions host fetch/track paths; other behavior unchanged.

Written by Cursor Bugbot for commit 0576f89. This will update automatically on new commits. Configure here.

Copilot AI review requested due to automatic review settings January 28, 2026 16:03
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_headers method to HTTP client for sending custom headers
  • Detects CI environments using ci_info::is_ci() and includes x-mise-ci header 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.

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());
Copy link

Copilot AI Jan 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
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>
@jdx jdx force-pushed the feat/ci-tracking-header branch from 7e0b797 to 0576f89 Compare January 28, 2026 16:21
Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Fix in Cursor Fix in Web

@jdx jdx enabled auto-merge (squash) January 28, 2026 16:35
jdx added a commit to jdx/mise-versions that referenced this pull request Jan 28, 2026
## 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>
@github-actions
Copy link

Hyperfine Performance

mise x -- echo

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%

@jdx jdx merged commit 27be3de into main Jan 28, 2026
35 checks passed
@jdx jdx deleted the feat/ci-tracking-header branch January 28, 2026 16:50
mise-en-dev added a commit that referenced this pull request Jan 28, 2026
### 🚀 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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant