Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: only tries to read device context from react-native-device-info if expo libs are not available #287

Merged
merged 2 commits into from
Oct 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions posthog-react-native/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Next

# 3.3.5 - 2024-10-15

1. fix: only tries to read device context from react-native-device-info if expo libs are not available

# 3.3.4 - 2024-10-14

1. fix: only log messages if debug is enabled
Expand Down
2 changes: 1 addition & 1 deletion posthog-react-native/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "posthog-react-native",
"version": "3.3.4",
"version": "3.3.5",
"main": "lib/posthog-react-native/index.js",
"files": [
"lib/"
Expand Down
23 changes: 11 additions & 12 deletions posthog-react-native/src/native-deps.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ export const getAppProperties = (): PostHogCustomAppProperties => {
properties.$app_name = OptionalExpoApplication.applicationName
properties.$app_namespace = OptionalExpoApplication.applicationId
properties.$app_version = OptionalExpoApplication.nativeApplicationVersion
} else if (OptionalReactNativeDeviceInfo) {
properties.$app_build = returnPropertyIfNotUnknown(OptionalReactNativeDeviceInfo.getBuildNumber())
properties.$app_name = returnPropertyIfNotUnknown(OptionalReactNativeDeviceInfo.getApplicationName())
properties.$app_namespace = returnPropertyIfNotUnknown(OptionalReactNativeDeviceInfo.getBundleId())
properties.$app_version = returnPropertyIfNotUnknown(OptionalReactNativeDeviceInfo.getVersion())
}

if (OptionalExpoDevice) {
Expand All @@ -33,25 +38,19 @@ export const getAppProperties = (): PostHogCustomAppProperties => {
properties.$device_name = OptionalExpoDevice.modelName
properties.$os_name = OptionalExpoDevice.osName
properties.$os_version = OptionalExpoDevice.osVersion
}

if (OptionalExpoLocalization) {
properties.$locale = OptionalExpoLocalization.locale
properties.$timezone = OptionalExpoLocalization.timezone
}

if (OptionalReactNativeDeviceInfo) {
properties.$app_build = returnPropertyIfNotUnknown(OptionalReactNativeDeviceInfo.getBuildNumber())
properties.$app_name = returnPropertyIfNotUnknown(OptionalReactNativeDeviceInfo.getApplicationName())
properties.$app_namespace = returnPropertyIfNotUnknown(OptionalReactNativeDeviceInfo.getBundleId())
properties.$app_version = returnPropertyIfNotUnknown(OptionalReactNativeDeviceInfo.getVersion())
} else if (OptionalReactNativeDeviceInfo) {
properties.$device_manufacturer = returnPropertyIfNotUnknown(OptionalReactNativeDeviceInfo.getManufacturerSync())
// react-native-device-info already maps the device model identifier to a human readable name
properties.$device_name = returnPropertyIfNotUnknown(OptionalReactNativeDeviceInfo.getModel())
properties.$os_name = returnPropertyIfNotUnknown(OptionalReactNativeDeviceInfo.getSystemName())
properties.$os_version = returnPropertyIfNotUnknown(OptionalReactNativeDeviceInfo.getSystemVersion())
}

if (OptionalExpoLocalization) {
properties.$locale = OptionalExpoLocalization.locale
properties.$timezone = OptionalExpoLocalization.timezone
}

return properties
}

Expand Down