fix(common): don't drop device overrides when the user agent looks like a server - #467
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
Included review availability: Your plan provides up to 8 included reviews per hour; 7 remain after this review. 📝 WalkthroughWalkthroughThe user-agent parser now preserves device overrides for server-like non-browser SDK user agents. It still returns the server result when no device overrides are present. Tests cover both paths. ChangesUser-agent override handling
Estimated code review effort: 2 (Simple) | ~10 minutes Merge Risk: 🔵 Low · up to This change preserves device overrides for native SDK events, but events without an explicit device ID may use a fallback based on project, IP address, and user agent, allowing same-project profiles with matching values to share or overwrite session attribution. The PR is mergeable with explicit owner awareness and follow-up to require a stable device identifier or strengthen the fallback. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Full details: Linked Issues checkExplanation The changes satisfy issue
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
fixes #466
parseUserAgentreturnedparsedServerUabefore it ever looked atoverrides, so__os,__model,__brandand__devicewere silently dropped for any sdk whose user agent matches the server heuristic. that is every non-browser sdk, since a plainname/versionstring is whatSINGLE_NAME_VERSION_REGEXmatches.the shortcut is now taken only when the caller has not said what the device is.
behaviour change worth flagging: events from native sdks that send device overrides are no longer treated as server events, so in
events.incoming-event.tsthey open their own session with a realdeviceIdinstead of riding along on an existing one with an empty one. that is the point of the fix, but it does change what lands in clickhouse for anyone already sending overrides from a non-browser sdk.two tests added to
parser-user-agent.test.ts: a native sdk ua plus overrides resolves to the real device (fails on main), and the same ua with no device overrides is still a server (passes on main, there to show the shortcut is intact).@openpanel/commonsuite: 63 passed. typecheck clean.Summary by CodeRabbit