forked from twobitlabs/AnalyticsKit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
AnalyticsKit.m
125 lines (102 loc) · 3.38 KB
/
AnalyticsKit.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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
//
// AnalyticsKit.m
// AnalyticsKit
//
// Created by Christopher Pickslay on 9/8/11.
// Copyright (c) 2011 Two Bit Labs. All rights reserved.
//
#import "AnalyticsKit.h"
@implementation AnalyticsKit
static NSArray *_loggers = nil;
+(void)initialize {
_loggers = [[NSArray alloc] init];
}
+(void)initializeLoggers:(NSArray *)loggers {
#if !__has_feature(objc_arc)
[loggers retain];
[_loggers release];
#endif
_loggers = loggers;
}
+(NSArray *)loggers {
return _loggers;
}
+(void)applicationWillEnterForeground {
AKINFO(@"");
for (id<AnalyticsKitProvider> logger in _loggers) {
[logger applicationWillEnterForeground];
}
}
+(void)applicationDidEnterBackground {
AKINFO(@"");
for (id<AnalyticsKitProvider> logger in _loggers) {
[logger applicationDidEnterBackground];
}
}
+(void)applicationWillTerminate {
AKINFO(@"");
for (id<AnalyticsKitProvider> logger in _loggers) {
[logger applicationWillTerminate];
}
}
+(void)uncaughtException:(NSException *)exception {
AKINFO(@"");
for (id<AnalyticsKitProvider> logger in _loggers) {
[logger uncaughtException:exception];
}
}
+(void)logScreen:(NSString *)screenName {
AKINFO(@"%@", screenName);
for (id<AnalyticsKitProvider> logger in _loggers) {
[logger logScreen:screenName];
}
}
+(void)logEvent:(NSString *)event {
AKINFO(@"%@", event);
for (id<AnalyticsKitProvider> logger in _loggers) {
[logger logEvent:event];
}
}
+(void)logEvent:(NSString *)event withProperties:(NSDictionary *)dict {
AKINFO(@"%@ withProperties: %@", event, dict);
for (id<AnalyticsKitProvider> logger in _loggers) {
[logger logEvent:event withProperties:dict];
}
}
+(void)logEvent:(NSString *)event withProperty:(NSString *)property andValue:(NSString *)value {
AKINFO(@"%@ withProperty: %@ andValue: %@", event, property, value);
for (id<AnalyticsKitProvider> logger in _loggers) {
[logger logEvent:event withProperty:property andValue:value];
}
}
+(void)logEvent:(NSString *)eventName timed:(BOOL)timed{
AKINFO(@"%@ timed: %@", eventName, timed ? @"YES" : @"NO");
for (id<AnalyticsKitProvider> logger in _loggers) {
[logger logEvent:eventName timed:timed];
}
}
+(void)logEvent:(NSString *)eventName withProperties:(NSDictionary *)dict timed:(BOOL)timed{
AKINFO(@"%@ withProperties: %@ timed: %@", eventName, dict, timed ? @"YES" : @"NO");
for (id<AnalyticsKitProvider> logger in _loggers) {
[logger logEvent:eventName withProperties:dict timed:timed];
}
}
+(void)endTimedEvent:(NSString *)eventName withProperties:(NSDictionary *)dict{
AKINFO(@"%@ withProperties: %@ ended", eventName, dict);
for (id<AnalyticsKitProvider> logger in _loggers) {
[logger endTimedEvent:eventName withProperties:dict];
}
}
+(void)logError:(NSString *)name message:(NSString *)message exception:(NSException *)exception {
AKERROR(@"%@: %@", name, message);
for (id<AnalyticsKitProvider> logger in _loggers) {
[logger logError:name message:message exception:exception];
}
}
+(void)logError:(NSString *)name message:(NSString *)message error:(NSError *)error {
AKERROR(@"%@: %@", name, message);
for (id<AnalyticsKitProvider> logger in _loggers) {
[logger logError:name message:message error:error];
}
}
@end