forked from twobitlabs/AnalyticsKit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
AnalyticsKitMixpanelProvider.m
84 lines (69 loc) · 2.52 KB
/
AnalyticsKitMixpanelProvider.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
//
// AnalyticsKitMixpanelProvider.m
//
//
// Created by Zac Shenker on 5/11/12.
// Copyright (c) 2012 Collusion. All rights reserved.
//
#import "Mixpanel.h"
#import "AnalyticsKitMixpanelProvider.h"
@implementation AnalyticsKitMixpanelProvider
-(id<AnalyticsKitProvider>)initWithAPIKey:(NSString *)apiKey {
self = [super init];
if (self) {
[Mixpanel sharedInstanceWithToken:apiKey];
}
return self;
}
-(void)applicationWillEnterForeground {}
-(void)applicationDidEnterBackground {}
-(void)applicationWillTerminate {}
-(void)uncaughtException:(NSException *)exception {
[[Mixpanel sharedInstance]track:@"Uncaught Exceptions" properties:
[NSDictionary dictionaryWithObjectsAndKeys:
[exception name], @"ename",
[exception reason], @"reason",
[exception userInfo], @"userInfo",
nil]];
}
-(void)logScreen:(NSString *)screenName {
[[Mixpanel sharedInstance] track:[@"Screen - " stringByAppendingString:screenName]];
}
-(void)logEvent:(NSString *)event {
[[Mixpanel sharedInstance] track:event];
}
-(void)logEvent:(NSString *)event withProperties:(NSDictionary *)dict {
[[Mixpanel sharedInstance] track:event properties:dict];
}
-(void)logEvent:(NSString *)event withProperty:(NSString *)key andValue:(NSString *)value {
[[Mixpanel sharedInstance] track:event properties:[NSDictionary dictionaryWithObject:value forKey:key]];
}
- (void)logEvent:(NSString *)eventName timed:(BOOL)timed{
[self logEvent:eventName];
}
- (void)logEvent:(NSString *)eventName withProperties:(NSDictionary *)dict timed:(BOOL)timed{
[self logEvent:eventName withProperties:dict];
}
-(void)endTimedEvent:(NSString *)eventName withProperties:(NSDictionary *)dict{}
-(void)logError:(NSString *)name message:(NSString *)message exception:(NSException *)exception {
[[Mixpanel sharedInstance] track:@"Exceptions" properties:
[NSDictionary dictionaryWithObjectsAndKeys:
name, @"name",
message, @"message",
[exception name], @"ename",
[exception reason], @"reason",
[exception userInfo], @"userInfo",
nil]];
}
-(void)logError:(NSString *)name message:(NSString *)message error:(NSError *)error {
[[Mixpanel sharedInstance] track:@"Errors" properties:
[NSDictionary dictionaryWithObjectsAndKeys:
name, @"name",
message, @"message",
[error localizedDescription], @"description",
[NSString stringWithFormat:@"%d", [error code]], @"code",
[error domain], @"domain",
[[error userInfo] description], @"userInfo",
nil]];
}
@end