feat(client): add AI agent detection to user agent#19
Merged
Conversation
Implement automatic detection of AI coding assistants: - Detect CLAUDECODE/CLAUDE_CODE environment variables - Detect CURSOR_AGENT environment variable - Append agent identifier to user agent string - Create dedicated pkg/useragent package for better organization User agent format: - Without agent: pup/v0.1.0 (go go1.25.0; os darwin; arch arm64) - With agent: pup/v0.1.0 (go go1.25.0; os darwin; arch arm64) claude-code Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Add documentation for user agent format and AI agent detection mechanism. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
platinummonkey
approved these changes
Feb 10, 2026
📊 Test Coverage ReportThreshold: 80% ✅ Coverage by Package📈 Coverage Status: ✅ PASSED - Coverage meets minimum threshold Updated for commit ff3cb6c |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add automatic detection of AI coding assistants to the user agent string sent in HTTP requests to Datadog API.
Changes
pkg/useragent/useragent.go- New package with user agent generation and AI agent detectionpkg/useragent/useragent_test.go- Comprehensive tests with 100% coveragepkg/client/client.go- Use new useragent package, remove old getUserAgent() functionpkg/client/client_test.go- Update tests to use useragent.Get()docs/ARCHITECTURE.md- Document user agent implementationUser Agent Format
Without AI agent:
With Claude Code:
With Cursor:
AI Agent Detection
Automatically detects AI agents via environment variables:
CLAUDECODE=1orCLAUDE_CODE=1→ appendsclaude-codeCURSOR_AGENT=trueorCURSOR_AGENT=1→ appendscursorTesting
pkg/useragentpackage: 100% test coverageArchitecture
Created dedicated
pkg/useragentpackage (instead of keeping inpkg/client) for:🤖 Generated with Claude Code