fix: also send device user agent as $raw_user_agent#604
Draft
lricoy wants to merge 1 commit into
Draft
Conversation
|
Reviews (1): Last reviewed commit: "fix: also send device user agent as $raw..." | Re-trigger Greptile |
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.
💡 Motivation and Context
The SDK attaches the device user agent (
http.agent) to every event as$user_agent, but PostHog's server-side classification — web analytics bot detection ($virt_is_botand friends) and the materialized-column fast path — keys on the standardized$raw_user_agentproperty (the one posthog-js sends). posthog-android is the only mobile SDK putting a real device UA in$user_agentwhile omitting$raw_user_agent, so its events can't be classified without an expensive fallback.PostHog/posthog#68253 removes that fallback for performance (it forced a full properties-blob read on every classification query — see the PR for production measurements), so this change mirrors the user agent into
$raw_user_agent, aligning Android with the standardized property. Related: PostHog/posthog#68232.$user_agentis still sent for backwards compatibility.💚 How did you test it?
Agent-authored. Extended the existing
PostHogAndroidContextTestdynamic-context test to assert$raw_user_agentcarries the same value as$user_agent; relying on CI to run the suite (no local Android toolchain in this session).📝 Checklist
If releasing new changes
pnpm changesetto generate a changeset file (changeset file added manually with the same format)🤖 Agent context
Autonomy: Human-driven (agent-assisted)
Built with Claude Code as part of a cross-repo effort to standardize on
$raw_user_agent(PostHog/posthog#68232, PostHog/posthog#68253, with sibling PRs to posthog-python and posthog-ruby). The value duplicated is the existinghttp.agentstring; no truncation added since the current$user_agentisn't truncated either.