Skip to content

Fix every Expo device reporting as a tablet when expo-device is absent - #69

Merged
yosriady merged 1 commit into
mainfrom
fix/expo-device-type-tablet
Jul 31, 2026
Merged

Fix every Expo device reporting as a tablet when expo-device is absent#69
yosriady merged 1 commit into
mainfrom
fix/expo-device-type-tablet

Conversation

@yosriady

@yosriady yosriady commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

The bug

getDeviceInfo()'s Expo branch is entered when either expo-device or expo-application is installed, so ExpoDevice can be null inside it. The tablet check was:

const isTablet = ExpoDevice?.deviceType === ExpoDevice?.DeviceType?.TABLET;

With ExpoDevice missing that is undefined === undefinedtrue, so every such device reports device_type: "tablet".

It also flips synthesizeUserAgent() to emit an iPad/Tablet UA, so the structured field and the user agent agree on the wrong answer and nothing downstream can recover the real form factor.

Evidence

Visible in production raw_events: a cohort with os_name: "ios", device_manufacturer: "Unknown", device_model: "Unknown", device_type: "tablet" — every value the ExpoDevice-null fallback. Real iPhones are showing under Tablet in the dashboard's device breakdown.

The fix

Extracted as an exported resolveExpoDeviceType() so the null case is testable, matching the existing exported synthesizeUserAgent() helper. An unknown form factor now resolves to "mobile" — the safe default for a React Native app.

8 new unit tests cover: both args absent, either arm absent, real tablet, phone, DeviceType.UNKNOWN (0, which must not be treated as missing), desktop/TV, and null vs undefined.

Full suite: 239 passing.

🤖 Generated with Claude Code


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.

getDeviceInfo()'s Expo branch runs when EITHER expo-device or
expo-application is installed, so ExpoDevice can be null inside it. The
tablet check was `ExpoDevice?.deviceType === ExpoDevice?.DeviceType?.TABLET`
— with ExpoDevice missing that is `undefined === undefined`, which is true,
so every such device reported device_type: "tablet". That also flipped the
synthesized user agent to iPad/Tablet, so both the structured field and the
UA agreed on the wrong answer and nothing downstream could recover it.

Visible in production: a cohort of events with os_name="ios",
device_manufacturer="Unknown", device_model="Unknown", device_type="tablet"
— every field the ExpoDevice-null fallback, and real iPhones shown under
Tablet in the device breakdown.

Extracted as resolveExpoDeviceType() so the null case is testable, matching
the existing exported synthesizeUserAgent() helper. Unknown form factor now
resolves to "mobile", the safe default for a React Native app.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

@yosriady
yosriady merged commit ed83f55 into main Jul 31, 2026
11 checks passed
@yosriady
yosriady deleted the fix/expo-device-type-tablet branch July 31, 2026 13:24
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.

1 participant