Skip to content

feat: filter CI requests from MAU calculations#73

Merged
jdx merged 1 commit into
mainfrom
feat/filter-ci-from-mau
Jan 28, 2026
Merged

feat: filter CI requests from MAU calculations#73
jdx merged 1 commit into
mainfrom
feat/filter-ci-from-mau

Conversation

@jdx

@jdx jdx commented Jan 28, 2026

Copy link
Copy Markdown
Owner

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

🤖 Generated with Claude Code


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

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

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>
Copilot AI review requested due to automatic review settings January 28, 2026 16:06

Copilot AI left a comment

Copy link
Copy Markdown

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 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-ci header and conditionally skip database tracking
  • Telemetry emission now includes an is_ci flag for all requests regardless of CI status
  • Download tracking endpoint returns a ci: true indicator 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.

Comment on lines 40 to 42
runtime.ctx.waitUntil(
emitTelemetry(runtime.env, {
schema_version: 1,

Copilot AI Jan 28, 2026

Copy link

Choose a reason for hiding this comment

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

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

Copilot uses AI. Check for mistakes.
return new Response(
JSON.stringify({
success: true,
deduplicated: false,

Copilot AI Jan 28, 2026

Copy link

Choose a reason for hiding this comment

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

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.

Suggested change
deduplicated: false,

Copilot uses AI. Check for mistakes.
@jdx jdx merged commit 7fccd45 into main Jan 28, 2026
5 checks passed
@jdx jdx deleted the feat/filter-ci-from-mau branch January 28, 2026 16:36
jdx added a commit to jdx/mise that referenced this pull request 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
- [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>
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.

2 participants