Add AI bot classification for event enrichment#76
Open
jaredmixpanel wants to merge 5 commits intomainfrom
Open
Add AI bot classification for event enrichment#76jaredmixpanel wants to merge 5 commits intomainfrom
jaredmixpanel wants to merge 5 commits intomainfrom
Conversation
Part of AI bot classification feature for Go SDK.
Part of AI bot classification feature for Go SDK.
Part of AI bot classification feature for Go SDK.
Fix golangci errcheck lint failure.
There was a problem hiding this comment.
Pull request overview
Adds AI bot detection to the Mixpanel Go client so HTTP requests and/or Track() calls can classify known AI crawlers by User-Agent and enrich events with standardized bot metadata.
Changes:
- Introduces an AI bot user-agent classifier with a built-in database and optional custom overrides.
- Adds HTTP middleware + helper utilities to store bot classification in request context and to copy request UA/IP into events.
- Adds optional automatic event enrichment on
ApiClient.Track()via new client options.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
ai_bot_classifier.go |
Adds classifier types, built-in bot database, and classification helpers. |
ai_bot_classifier_test.go |
Adds unit tests for built-in detection, negative cases, and custom overrides. |
ai_bot_middleware.go |
Adds BotClassifyingIngestion, HTTP middleware, and TrackRequest helper. |
ai_bot_middleware_test.go |
Adds tests for ingestion wrapper enrichment, middleware context behavior, and TrackRequest. |
ingestion.go |
Enriches ApiClient.Track() events with bot classification when enabled via options. |
mixpanel.go |
Adds botClassifier to ApiClient and new options to enable classification. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Add nil receiver guard in Classify() - Default nil classifier to built-in in constructor
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
Adds AI bot classification with HTTP middleware that automatically detects AI crawler requests and enriches tracked events with classification properties.
What it does
$is_ai_bot,$ai_bot_name,$ai_bot_provider, and$ai_bot_categorypropertiesAI Bots Detected
GPTBot, ChatGPT-User, OAI-SearchBot, ClaudeBot, Claude-User, Google-Extended, PerplexityBot, Bytespider, CCBot, Applebot-Extended, Meta-ExternalAgent, cohere-ai
Files Added
ai_bot_classifier.goai_bot_classifier_test.goai_bot_middleware.goai_bot_middleware_test.goFiles Modified
ingestion.gomixpanel.goTest Plan
$is_ai_bot: false(Chrome, Googlebot, curl, etc.)