forked from twobitlabs/AnalyticsKit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
AnalyticsKitLocalyitcsProvider.m
96 lines (78 loc) · 3.1 KB
/
AnalyticsKitLocalyitcsProvider.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
85
86
87
88
89
90
91
92
93
94
95
96
//
// AnalyticsKitLocalyitcsProvider.m
// AnalyticsKit
//
// Created by Todd Huss on 10/17/11.
// Copyright (c) 2011 Two Bit Labs. All rights reserved.
//
#import "AnalyticsKitLocalyitcsProvider.h"
#import "LocalyticsSession.h"
@implementation AnalyticsKitLocalyitcsProvider
-(id<AnalyticsKitProvider>)initWithAPIKey:(NSString *)localyticsKey {
self = [super init];
if (self) {
[[LocalyticsSession sharedLocalyticsSession] startSession:localyticsKey];
}
return self;
}
-(void)applicationWillEnterForeground {
[[LocalyticsSession sharedLocalyticsSession] resume];
[[LocalyticsSession sharedLocalyticsSession] upload];
}
-(void)applicationDidEnterBackground {
[[LocalyticsSession sharedLocalyticsSession] close];
[[LocalyticsSession sharedLocalyticsSession] upload];
}
-(void)applicationWillTerminate {
[[LocalyticsSession sharedLocalyticsSession] close];
[[LocalyticsSession sharedLocalyticsSession] upload];
}
-(void)uncaughtException:(NSException *)exception {
[[LocalyticsSession sharedLocalyticsSession] tagEvent:@"Uncaught Exceptions" attributes:
[NSDictionary dictionaryWithObjectsAndKeys:
[exception name], @"ename",
[exception reason], @"reason",
[exception userInfo], @"userInfo",
nil]];
}
-(void)logScreen:(NSString *)screenName {
[[LocalyticsSession sharedLocalyticsSession] tagScreen:screenName];
}
-(void)logEvent:(NSString *)event {
[[LocalyticsSession sharedLocalyticsSession] tagEvent:event];
}
-(void)logEvent:(NSString *)event withProperties:(NSDictionary *)dict {
[[LocalyticsSession sharedLocalyticsSession] tagEvent:event attributes:dict];
}
-(void)logEvent:(NSString *)event withProperty:(NSString *)key andValue:(NSString *)value {
[[LocalyticsSession sharedLocalyticsSession] tagEvent:event attributes:[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 {
[[LocalyticsSession sharedLocalyticsSession] tagEvent:@"Exceptions" attributes:
[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 {
[[LocalyticsSession sharedLocalyticsSession] tagEvent:@"Errors" attributes:
[NSDictionary dictionaryWithObjectsAndKeys:
name, @"name",
message, @"message",
[error localizedDescription], @"description",
[NSString stringWithFormat:@"%d", [error code]], @"code",
[error domain], @"domain",
[[error userInfo] description], @"userInfo",
nil]];
}
@end