Skip to content
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 CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## Next

- Update device type [#63](https://github.com/PostHog/posthog-ios/pull/63)

## 2.0.4 - 2023-10-05

- CoreTelephony should not be added to tvOS builds [#67](https://github.com/PostHog/posthog-ios/pull/67)
Expand Down
23 changes: 22 additions & 1 deletion PostHog/Internal/PHGPostHogIntegration.m
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,29 @@ - (NSDictionary *)staticContext

UIDevice *device = [UIDevice currentDevice];

NSString *deviceType = nil;
switch (device.userInterfaceIdiom) {
case UIUserInterfaceIdiomUnspecified:
break;
case UIUserInterfaceIdiomPhone:
deviceType = @"Mobile";
break;
case UIUserInterfaceIdiomPad:
deviceType = @"Tablet";
break;
case UIUserInterfaceIdiomTV:
deviceType = @"TV";
break;
case UIUserInterfaceIdiomCarPlay:
deviceType = @"CarPlay";
break;
case UIUserInterfaceIdiomMac:
deviceType = @"Desktop";
break;
}

dict[@"$device_manufacturer"] = @"Apple";
dict[@"$device_type"] = @"ios";
if (deviceType != nil) dict[@"$device_type"] = deviceType;
dict[@"$device_model"] = GetDeviceModel();
dict[@"$device_id"] = self.configuration.shouldSendDeviceID ? [[device identifierForVendor] UUIDString] : nil;
dict[@"$device_name"] = [device model];
Expand Down