-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPFAnalytics.h
More file actions
167 lines (127 loc) · 6.7 KB
/
PFAnalytics.h
File metadata and controls
167 lines (127 loc) · 6.7 KB
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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
//
// PFAnalytics.h
//
// Copyright 2011-present Parse Inc. All rights reserved.
//
#import <Foundation/Foundation.h>
#if TARGET_OS_IPHONE
#import <Parse/PFConstants.h>
#else
#import <ParseOSX/PFConstants.h>
#endif
PF_ASSUME_NONNULL_BEGIN
@class BFTask;
/*!
`PFAnalytics` provides an interface to Parse's logging and analytics backend.
Methods will return immediately and cache the request (+ timestamp) to be
handled "eventually." That is, the request will be sent immediately if possible
or the next time a network connection is available.
*/
@interface PFAnalytics : NSObject
///--------------------------------------
/// @name App-Open / Push Analytics
///--------------------------------------
/*!
@abstract Tracks this application being launched. If this happened as the result of the
user opening a push notification, this method sends along information to
correlate this open with that push.
@discussion Pass in `nil` to track a standard "application opened" event.
@param launchOptions The `NSDictionary` indicating the reason the application was
launched, if any. This value can be found as a parameter to various
`UIApplicationDelegate` methods, and can be empty or `nil`.
@returns Returns the task encapsulating the work being done.
*/
+ (BFTask *)trackAppOpenedWithLaunchOptions:(PF_NULLABLE NSDictionary *)launchOptions;
/*!
@abstract Tracks this application being launched.
If this happened as the result of the user opening a push notification,
this method sends along information to correlate this open with that push.
@discussion Pass in `nil` to track a standard "application opened" event.
@param launchOptions The dictionary indicating the reason the application was
launched, if any. This value can be found as a parameter to various
`UIApplicationDelegate` methods, and can be empty or `nil`.
@param block The block to execute on server response.
It should have the following argument signature: `^(BOOL succeeded, NSError *error)`
*/
+ (void)trackAppOpenedWithLaunchOptionsInBackground:(PF_NULLABLE NSDictionary *)launchOptions
block:(PF_NULLABLE PFBooleanResultBlock)block;
/*!
@abstract Tracks this application being launched. If this happened as the result of the
user opening a push notification, this method sends along information to
correlate this open with that push.
@param userInfo The Remote Notification payload, if any. This value can be
found either under `UIApplicationLaunchOptionsRemoteNotificationKey` on `launchOptions`,
or as a parameter to `application:didReceiveRemoteNotification:`.
This can be empty or `nil`.
@returns Returns the task encapsulating the work being done.
*/
+ (BFTask *)trackAppOpenedWithRemoteNotificationPayload:(PF_NULLABLE NSDictionary *)userInfo;
/*!
@abstract Tracks this application being launched. If this happened as the result of the
user opening a push notification, this method sends along information to
correlate this open with that push.
@param userInfo The Remote Notification payload, if any. This value can be
found either under `UIApplicationLaunchOptionsRemoteNotificationKey` on `launchOptions`,
or as a parameter to `application:didReceiveRemoteNotification:`. This can be empty or `nil`.
@param block The block to execute on server response.
It should have the following argument signature: `^(BOOL succeeded, NSError *error)`
*/
+ (void)trackAppOpenedWithRemoteNotificationPayloadInBackground:(PF_NULLABLE NSDictionary *)userInfo
block:(PF_NULLABLE PFBooleanResultBlock)block;
///--------------------------------------
/// @name Custom Analytics
///--------------------------------------
/*!
@abstract Tracks the occurrence of a custom event.
@discussion Parse will store a data point at the time of invocation with the given event name.
@param name The name of the custom event to report to Parse as having happened.
@returns Returns the task encapsulating the work being done.
*/
+ (BFTask *)trackEvent:(NSString *)name;
/*!
@abstract Tracks the occurrence of a custom event. Parse will store a data point at the
time of invocation with the given event name. The event will be sent at some
unspecified time in the future, even if Parse is currently inaccessible.
@param name The name of the custom event to report to Parse as having happened.
@param block The block to execute on server response.
It should have the following argument signature: `^(BOOL succeeded, NSError *error)`
*/
+ (void)trackEventInBackground:(NSString *)name block:(PF_NULLABLE PFBooleanResultBlock)block;
/*!
@abstract Tracks the occurrence of a custom event with additional dimensions. Parse will
store a data point at the time of invocation with the given event name.
@discussion Dimensions will allow segmentation of the occurrences of this custom event.
Keys and values should be NSStrings, and will throw otherwise.
To track a user signup along with additional metadata, consider the following:
NSDictionary *dimensions = @{ @"gender": @"m",
@"source": @"web",
@"dayType": @"weekend" };
[PFAnalytics trackEvent:@"signup" dimensions:dimensions];
@warning There is a default limit of 8 dimensions per event tracked.
@param name The name of the custom event to report to Parse as having happened.
@param dimensions The `NSDictionary` of information by which to segment this event.
@returns Returns the task encapsulating the work being done.
*/
+ (BFTask *)trackEvent:(NSString *)name dimensions:(PF_NULLABLE NSDictionary *)dimensions;
/*!
@abstract Tracks the occurrence of a custom event with additional dimensions. Parse will
store a data point at the time of invocation with the given event name. The
event will be sent at some unspecified time in the future, even if Parse is currently inaccessible.
@discussionDimensions will allow segmentation of the occurrences of this custom event.
Keys and values should be NSStrings, and will throw otherwise.
To track a user signup along with additional metadata, consider the following:
NSDictionary *dimensions = @{ @"gender": @"m",
@"source": @"web",
@"dayType": @"weekend" };
[PFAnalytics trackEvent:@"signup" dimensions:dimensions];
There is a default limit of 8 dimensions per event tracked.
@param name The name of the custom event to report to Parse as having happened.
@param dimensions The `NSDictionary` of information by which to segment this event.
@param block The block to execute on server response.
It should have the following argument signature: `^(BOOL succeeded, NSError *error)`
*/
+ (void)trackEventInBackground:(NSString *)name
dimensions:(PF_NULLABLE NSDictionary *)dimensions
block:(PF_NULLABLE PFBooleanResultBlock)block;
@end
PF_ASSUME_NONNULL_END