feat: filter CI requests from MAU calculations#73
Conversation
Skip database storage for requests with x-mise-ci: true header. These requests still emit telemetry (with is_ci flag) for analysis, but are excluded from MAU calculations. Affected endpoints: - POST /api/track - download tracking - GET /tools/[tool].toml - version requests - GET /[...tool].toml - legacy version requests Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
This PR implements filtering of CI environment requests from Monthly Active User (MAU) calculations while preserving telemetry data for analytics purposes. When clients send the x-mise-ci: true header, the system skips database storage but continues to emit telemetry events with an is_ci flag.
Changes:
- Modified three endpoints to check for the
x-mise-ciheader and conditionally skip database tracking - Telemetry emission now includes an
is_ciflag for all requests regardless of CI status - Download tracking endpoint returns a
ci: trueindicator in the response for CI requests
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| web/src/pages/tools/[tool].toml.ts | Adds CI detection and conditional database tracking for tool version requests |
| web/src/pages/api/track.ts | Implements CI filtering for download tracking with early return for CI requests |
| web/src/pages/[...tool].toml.ts | Adds CI detection and conditional database tracking for legacy tool version requests |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| runtime.ctx.waitUntil( | ||
| emitTelemetry(runtime.env, { | ||
| schema_version: 1, |
There was a problem hiding this comment.
The telemetry emission has been moved outside of the conditional CI check, but it's no longer wrapped in error handling. If emitTelemetry fails, it could cause the waitUntil promise to reject. Consider wrapping the telemetry call in a try-catch block similar to how it's handled in the other two files (lines 85-87 in tools/[tool].toml.ts and lines 87-89 in [...tool].toml.ts).
| return new Response( | ||
| JSON.stringify({ | ||
| success: true, | ||
| deduplicated: false, |
There was a problem hiding this comment.
The deduplicated: false field in the CI response may be misleading since no deduplication check occurs for CI requests. Consider either removing this field from the CI response or documenting why it's always false for CI requests, as it could confuse API consumers who expect this field to reflect actual deduplication logic.
| deduplicated: false, |
## 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
- [x] Build passes
- [ ] Verify header is sent in CI environment (e.g., GitHub Actions)
- [ ] Server-side filtering in mise-versions (jdx/mise-versions#73)
🤖 Generated with [Claude Code](https://claude.com/claude-code)
<!-- CURSOR_SUMMARY -->
---
> [!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.
>
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
0576f89. 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>
Summary
x-mise-ci: trueheaderis_ciflag) for analysisAffected endpoints
POST /api/track- download trackingGET /tools/[tool].toml- version requestsGET /[...tool].toml- legacy version requestsBehavior
When
x-mise-ci: trueheader is present:is_ci: truefor analyticsci: truefor download trackingRelated
🤖 Generated with Claude Code
Note
Filters CI-originated requests from MAU/DAU while retaining telemetry.
x-mise-ciheader handling toPOST /api/track,GET /tools/[tool].toml, andGET /[...tool].tomlis_ciin payload; skips DB writes for CI to avoid counting in MAU/DAUPOST /api/tracknow returns{ ci: true }when CI is detectedWritten by Cursor Bugbot for commit b6b86e9. This will update automatically on new commits. Configure here.