From 695e142215b26995d7ec576098c8a4c693b1b322 Mon Sep 17 00:00:00 2001 From: Manoel Aranda Neto <5731772+marandaneto@users.noreply.github.com> Date: Tue, 17 Dec 2024 09:55:32 +0100 Subject: [PATCH] fix: os_name was not being set correctly for some devices using expo-device (#330) --- posthog-react-native/CHANGELOG.md | 4 ++++ posthog-react-native/package.json | 2 +- posthog-react-native/src/native-deps.tsx | 11 ++++++++++- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/posthog-react-native/CHANGELOG.md b/posthog-react-native/CHANGELOG.md index 16438175..447d3290 100644 --- a/posthog-react-native/CHANGELOG.md +++ b/posthog-react-native/CHANGELOG.md @@ -1,5 +1,9 @@ # Next +# 3.6.1 - 2024-12-17 + +1. fix: os_name was not being set correctly for some devices using expo-device + # 3.6.0 - 2024-12-12 1. Add new debugging property `$feature_flag_bootstrapped_response`, `$feature_flag_bootstrapped_payload` and `$used_bootstrap_value` to `$feature_flag_called` event diff --git a/posthog-react-native/package.json b/posthog-react-native/package.json index 991986d7..27ead4de 100644 --- a/posthog-react-native/package.json +++ b/posthog-react-native/package.json @@ -1,6 +1,6 @@ { "name": "posthog-react-native", - "version": "3.6.0", + "version": "3.6.1", "main": "lib/posthog-react-native/index.js", "files": [ "lib/" diff --git a/posthog-react-native/src/native-deps.tsx b/posthog-react-native/src/native-deps.tsx index 21b2f9a1..62ee425b 100644 --- a/posthog-react-native/src/native-deps.tsx +++ b/posthog-react-native/src/native-deps.tsx @@ -36,7 +36,16 @@ export const getAppProperties = (): PostHogCustomAppProperties => { properties.$device_manufacturer = OptionalExpoDevice.manufacturer // expo-device already maps the device model identifier to a human readable name properties.$device_name = OptionalExpoDevice.modelName - properties.$os_name = OptionalExpoDevice.osName + + // https://github.com/expo/expo/issues/6990 + // some devices return a value similar to: + // HUAWEI/SNE-LX1/HWSNE:8.1.0/HUAWEISNE-LX1/131(C432):user/release-keys + if (Platform.OS === 'android') { + properties.$os_name = 'Android' + } else { + properties.$os_name = OptionalExpoDevice.osName + } + properties.$os_version = OptionalExpoDevice.osVersion } else if (OptionalReactNativeDeviceInfo) { properties.$device_manufacturer = returnPropertyIfNotUnknown(OptionalReactNativeDeviceInfo.getManufacturerSync())