Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Add readableNameWithDeviceName: on MPDeviceNamer to do proper naming. #113

Closed
wants to merge 1 commit into from

3 participants

@seivan

No description provided.

@seivan

I'd probably recommend doing this server side - but... it's a start.

@yas375 yas375 commented on the diff
Mixpanel/MPDeviceNamer.m
((29 lines not shown))
+ else if ([deviceName isEqualToString:@"iPad2,4"]) readableName = @"iPad 2 (WiFi)";
+ else if ([deviceName isEqualToString:@"iPad2,5"]) readableName = @"iPad Mini (WiFi)";
+ else if ([deviceName isEqualToString:@"iPad2,6"]) readableName = @"iPad Mini (GSM)";
+ else if ([deviceName isEqualToString:@"iPad2,7"]) readableName = @"iPad Mini (GSM+CDMA)";
+ else if ([deviceName isEqualToString:@"iPad3,1"]) readableName = @"iPad 3 (WiFi)";
+ else if ([deviceName isEqualToString:@"iPad3,2"]) readableName = @"iPad 3 (GSM+CDMA)";
+ else if ([deviceName isEqualToString:@"iPad3,3"]) readableName = @"iPad 3 (GSM)";
+ else if ([deviceName isEqualToString:@"iPad3,4"]) readableName = @"iPad 4 (WiFi)";
+ else if ([deviceName isEqualToString:@"iPad3,5"]) readableName = @"iPad 4 (GSM)";
+ else if ([deviceName isEqualToString:@"iPad3,6"]) readableName = @"iPad 4 (GSM+CDMA)";
+ else if ([deviceName isEqualToString:@"iPad4,1"]) readableName = @"iPad Air (WiFi)";
+ else if ([deviceName isEqualToString:@"iPad4,2"]) readableName = @"iPad Air (GSM)";
+ else if ([deviceName isEqualToString:@"iPad4,4"]) readableName = @"iPad Mini Retina (WiFi)";
+ else if ([deviceName isEqualToString:@"iPad4,5"]) readableName = @"iPad Mini Retina (GSM)";
+ else if ([deviceName isEqualToString:@"i386"]) readableName = @"Simulator";
+ else if ([deviceName isEqualToString:@"x86_64"]) readableName = @"Simulator";
@yas375
yas375 added a note

I think the use of dictionary would be more appropriate here.
But better to do such things on the server, imo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@alex-hofsteede
Collaborator

Hi @seivan

We will be doing this translation on the server, so we can update more easily as new devices become available. I don't have an ETA for this at the moment unfortunately.

@seivan seivan deleted the unknown repository branch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
View
3  Mixpanel/MPDeviceNamer.h
@@ -0,0 +1,3 @@
+@interface MPDeviceNamer : NSObject
++(NSString *)readableNameWithDeviceName:(NSString *)deviceName
+@end
View
49 Mixpanel/MPDeviceNamer.m
@@ -0,0 +1,49 @@
+#import "MPDeviceNamer.h"
+
+@implementation MPDeviceNamer
++(NSString *)readableNameWithDeviceName:(NSString *)deviceName
+{
+ NSString *readableName = nil;
+
+ if ([deviceName isEqualToString:@"iPhone1,1"]) readableName = @"iPhone 1G";
+ else if ([deviceName isEqualToString:@"iPhone1,2"]) readableName = @"iPhone 3G";
+ else if ([deviceName isEqualToString:@"iPhone2,1"]) readableName = @"iPhone 3GS";
+ else if ([deviceName isEqualToString:@"iPhone3,1"]) readableName = @"iPhone 4";
+ else if ([deviceName isEqualToString:@"iPhone3,3"]) readableName = @"Verizon iPhone 4";
+ else if ([deviceName isEqualToString:@"iPhone4,1"]) readableName = @"iPhone 4S";
+ else if ([deviceName isEqualToString:@"iPhone5,1"]) readableName = @"iPhone 5 (GSM)";
+ else if ([deviceName isEqualToString:@"iPhone5,2"]) readableName = @"iPhone 5 (GSM+CDMA)";
+ else if ([deviceName isEqualToString:@"iPhone5,3"]) readableName = @"iPhone 5c (GSM)";
+ else if ([deviceName isEqualToString:@"iPhone5,4"]) readableName = @"iPhone 5c (Global)";
+ else if ([deviceName isEqualToString:@"iPhone6,1"]) readableName = @"iPhone 5s (GSM)";
+ else if ([deviceName isEqualToString:@"iPhone6,2"]) readableName = @"iPhone 5s (Global)";
+ else if ([deviceName isEqualToString:@"iPod1,1"]) readableName = @"iPod Touch 1G";
+ else if ([deviceName isEqualToString:@"iPod2,1"]) readableName = @"iPod Touch 2G";
+ else if ([deviceName isEqualToString:@"iPod3,1"]) readableName = @"iPod Touch 3G";
+ else if ([deviceName isEqualToString:@"iPod4,1"]) readableName = @"iPod Touch 4G";
+ else if ([deviceName isEqualToString:@"iPod5,1"]) readableName = @"iPod Touch 5G";
+ else if ([deviceName isEqualToString:@"iPad1,1"]) readableName = @"iPad";
+ else if ([deviceName isEqualToString:@"iPad2,1"]) readableName = @"iPad 2 (WiFi)";
+ else if ([deviceName isEqualToString:@"iPad2,2"]) readableName = @"iPad 2 (GSM)";
+ else if ([deviceName isEqualToString:@"iPad2,3"]) readableName = @"iPad 2 (CDMA)";
+ else if ([deviceName isEqualToString:@"iPad2,4"]) readableName = @"iPad 2 (WiFi)";
+ else if ([deviceName isEqualToString:@"iPad2,5"]) readableName = @"iPad Mini (WiFi)";
+ else if ([deviceName isEqualToString:@"iPad2,6"]) readableName = @"iPad Mini (GSM)";
+ else if ([deviceName isEqualToString:@"iPad2,7"]) readableName = @"iPad Mini (GSM+CDMA)";
+ else if ([deviceName isEqualToString:@"iPad3,1"]) readableName = @"iPad 3 (WiFi)";
+ else if ([deviceName isEqualToString:@"iPad3,2"]) readableName = @"iPad 3 (GSM+CDMA)";
+ else if ([deviceName isEqualToString:@"iPad3,3"]) readableName = @"iPad 3 (GSM)";
+ else if ([deviceName isEqualToString:@"iPad3,4"]) readableName = @"iPad 4 (WiFi)";
+ else if ([deviceName isEqualToString:@"iPad3,5"]) readableName = @"iPad 4 (GSM)";
+ else if ([deviceName isEqualToString:@"iPad3,6"]) readableName = @"iPad 4 (GSM+CDMA)";
+ else if ([deviceName isEqualToString:@"iPad4,1"]) readableName = @"iPad Air (WiFi)";
+ else if ([deviceName isEqualToString:@"iPad4,2"]) readableName = @"iPad Air (GSM)";
+ else if ([deviceName isEqualToString:@"iPad4,4"]) readableName = @"iPad Mini Retina (WiFi)";
+ else if ([deviceName isEqualToString:@"iPad4,5"]) readableName = @"iPad Mini Retina (GSM)";
+ else if ([deviceName isEqualToString:@"i386"]) readableName = @"Simulator";
+ else if ([deviceName isEqualToString:@"x86_64"]) readableName = @"Simulator";
@yas375
yas375 added a note

I think the use of dictionary would be more appropriate here.
But better to do such things on the server, imo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+ else readableName = name
+
+ return readableName;
+}
+@end
View
5 Mixpanel/Mixpanel.m
@@ -20,6 +20,7 @@
#import "Mixpanel.h"
#import "NSData+MPBase64.h"
#import "UIView+MPSnapshotImage.h"
+#import "MPDeviceNamer.h"
#define VERSION @"2.3.2"
@@ -286,8 +287,8 @@ - (NSMutableDictionary *)collectAutomaticProperties
[p setValue:@"Apple" forKey:@"$manufacturer"];
[p setValue:[device systemName] forKey:@"$os"];
[p setValue:[device systemVersion] forKey:@"$os_version"];
- [p setValue:deviceModel forKey:@"$model"];
- [p setValue:deviceModel forKey:@"mp_device_model"]; // legacy
+ [p setValue:[MPDeviceNamer readableNameWithDeviceName:deviceModel] forKey:@"$model"];
+ [p setValue:[MPDeviceNamer readableNameWithDeviceName:deviceModel] forKey:@"mp_device_model"]; // legacy
CGSize size = [UIScreen mainScreen].bounds.size;
[p setValue:@((NSInteger)size.height) forKey:@"$screen_height"];
[p setValue:@((NSInteger)size.width) forKey:@"$screen_width"];
Something went wrong with that request. Please try again.