Repository navigation
fix(react-native): fall back to Platform for $os_name and $os_version - #5294
Conversation
Bare apps without expo-device or react-native-device-info sent JS events without OS properties.
Coherence2 spec problems · 0 failing chokepoints · 2 spec gaps · 0 guard failures 44 components, 5 bullets (5 invariants, 0 requirements), 2 problems Spec problems (spec --check)
Chokepoints: none declared. Spec gaps: 2 entrances with outside or unknown trust and no traced control, and 10 more held by the adoption baseline
Close one with |
|
This PR hasn't seen activity in a week! Should it be merged, closed, or further worked on? If you want to keep it open, post a comment or remove the |
marandaneto
left a comment
There was a problem hiding this comment.
The code looks good; no qualifying findings. Verdict: correct.
Problem
In a React Native app that installs neither
expo-devicenorreact-native-device-info, every event the JS SDK sends lacks$os_nameand$os_version.getAppPropertiesonly reads them from those optional libraries and has no fallback.Found while testing bare RN 0.79 and 0.76 apps (Release, Android and iOS) for #5271 / #5293. Every JS-sent event from those apps (custom events,
$screen, non-fatal$exception) had no OS properties. Fatal$exceptionevents from the same apps did have them, because they go through the native SDK, which adds its own device properties. The Expo example (withexpo-device) has them on every event.Impact:
$os_namefeeds the default person properties used for flag targeting, so OS-targeted flags never match these users.The posthog.com install command for bare RN includes
react-native-device-info, but nothing says what is lost without it. The SDK's own logs already read the OS fromPlatform.Changes
$os_name,getAppPropertiesfills$os_nameand$os_versionfrom React Native'sPlatform:'Android'andPlatform.constants.Release(the user-facing version, not the API level).Platform.constants.systemName(falls back to'iOS') andPlatform.Version.expo-deviceorreact-native-device-infostill win when either is installed.$app_version,$app_namespace,$device_manufacturer, …) still need a device-info library. A docs note saying so is worth adding separately.$os_name(sdk-specs lists$osas collected from the host environment). No earlier issues or PRs found.Test plan
test/native-deps-os.spec.ts(4 cases): 3 fail before the change and all pass after.posthog-react-nativevitest suite (1248 tests), build, lint and format pass.Release info Sub-libraries affected
Libraries affected
Checklist
If releasing new changes
pnpm changesetto generate a changeset file🤖 Agent context
Autonomy: Human-driven (agent-assisted)
getAppProperties, not in the boundary.🤖 Generated with Claude Code