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

chore: $device_type is now set to Mobile, Desktop or Web for all events #152

Merged
merged 2 commits into from
Jan 9, 2024
Merged
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,3 +1,7 @@
# 2.10.0 - 2024-01-08

1. `$device_type` is now set to `Mobile`, `Desktop`, or `Web` for all events

# 2.9.2 - 2023-12-21

1. If `async-storage` or `expo-file-system` is not installed, the SDK will fallback to `persistence: memory` and log a warning
10 changes: 9 additions & 1 deletion posthog-react-native/src/native-deps.tsx
Original file line number Diff line number Diff line change
@@ -8,8 +8,16 @@ import { OptionalReactNativeDeviceInfo } from './optional/OptionalReactNativeDev
import { PostHogCustomAppProperties, PostHogCustomAsyncStorage } from './types'

export const getAppProperties = (): PostHogCustomAppProperties => {
var deviceType = 'Mobile'

if (Platform.OS === 'macos' || Platform.OS === 'windows') {
deviceType = 'Desktop'
} else if (Platform.OS === 'web') {
deviceType = 'Web'
}

const properties: PostHogCustomAppProperties = {
$device_type: Platform.OS,
$device_type: deviceType,
}

if (OptionalExpoApplication) {
2 changes: 1 addition & 1 deletion posthog-react-native/src/types.ts
Original file line number Diff line number Diff line change
@@ -33,7 +33,7 @@ export interface PostHogCustomAppProperties {
$device_manufacturer?: string | null
/** Readable model name like "iPhone 12" */
$device_name?: string | null
/** Same as Platform.OS ("android" | "ios") */
/** Device type ("Mobile" | "Desktop" | "Web") */
$device_type?: string | null
/** Operating system name like iOS or Android */
$os_name?: string | null
2 changes: 1 addition & 1 deletion posthog-react-native/test/posthog.spec.ts
Original file line number Diff line number Diff line change
@@ -108,7 +108,7 @@ describe('PostHog React Native', () => {
$app_namespace: 'mock',
$app_version: 'mock',
$device_manufacturer: 'mock',
$device_type: 'ios',
$device_type: 'Mobile',
// $device_name: 'mock', (deleted)
$os_name: 'mock',
$os_version: 'mock',