commit | author | age
|
a6c014
|
1 |
#import <Foundation/Foundation.h> |
L |
2 |
|
|
3 |
#import "FIREventNames.h" |
|
4 |
#import "FIRParameterNames.h" |
|
5 |
#import "FIRUserPropertyNames.h" |
|
6 |
|
|
7 |
NS_ASSUME_NONNULL_BEGIN |
|
8 |
|
|
9 |
/// The top level Firebase Analytics singleton that provides methods for logging events and setting |
|
10 |
/// user properties. See <a href="http://goo.gl/gz8SLz">the developer guides</a> for general |
|
11 |
/// information on using Firebase Analytics in your apps. |
|
12 |
/// |
|
13 |
/// @note The Analytics SDK uses SQLite to persist events and other app-specific data. Calling |
|
14 |
/// certain thread-unsafe global SQLite methods like `sqlite3_shutdown()` can result in |
|
15 |
/// unexpected crashes at runtime. |
|
16 |
NS_SWIFT_NAME(Analytics) |
|
17 |
@interface FIRAnalytics : NSObject |
|
18 |
|
|
19 |
/// Logs an app event. The event can have up to 25 parameters. Events with the same name must have |
|
20 |
/// the same parameters. Up to 500 event names are supported. Using predefined events and/or |
|
21 |
/// parameters is recommended for optimal reporting. |
|
22 |
/// |
|
23 |
/// The following event names are reserved and cannot be used: |
|
24 |
/// <ul> |
|
25 |
/// <li>ad_activeview</li> |
|
26 |
/// <li>ad_click</li> |
|
27 |
/// <li>ad_exposure</li> |
|
28 |
/// <li>ad_query</li> |
454098
|
29 |
/// <li>ad_reward</li> |
a6c014
|
30 |
/// <li>adunit_exposure</li> |
L |
31 |
/// <li>app_clear_data</li> |
454098
|
32 |
/// <li>app_exception</li> |
a6c014
|
33 |
/// <li>app_remove</li> |
454098
|
34 |
/// <li>app_store_refund</li> |
L |
35 |
/// <li>app_store_subscription_cancel</li> |
|
36 |
/// <li>app_store_subscription_convert</li> |
|
37 |
/// <li>app_store_subscription_renew</li> |
a6c014
|
38 |
/// <li>app_update</li> |
454098
|
39 |
/// <li>app_upgrade</li> |
L |
40 |
/// <li>dynamic_link_app_open</li> |
|
41 |
/// <li>dynamic_link_app_update</li> |
|
42 |
/// <li>dynamic_link_first_open</li> |
a6c014
|
43 |
/// <li>error</li> |
454098
|
44 |
/// <li>firebase_campaign</li> |
a6c014
|
45 |
/// <li>first_open</li> |
454098
|
46 |
/// <li>first_visit</li> |
a6c014
|
47 |
/// <li>in_app_purchase</li> |
L |
48 |
/// <li>notification_dismiss</li> |
|
49 |
/// <li>notification_foreground</li> |
|
50 |
/// <li>notification_open</li> |
|
51 |
/// <li>notification_receive</li> |
|
52 |
/// <li>os_update</li> |
|
53 |
/// <li>session_start</li> |
454098
|
54 |
/// <li>session_start_with_rollout</li> |
a6c014
|
55 |
/// <li>user_engagement</li> |
L |
56 |
/// </ul> |
|
57 |
/// |
|
58 |
/// @param name The name of the event. Should contain 1 to 40 alphanumeric characters or |
|
59 |
/// underscores. The name must start with an alphabetic character. Some event names are |
|
60 |
/// reserved. See FIREventNames.h for the list of reserved event names. The "firebase_", |
|
61 |
/// "google_", and "ga_" prefixes are reserved and should not be used. Note that event names are |
|
62 |
/// case-sensitive and that logging two events whose names differ only in case will result in |
|
63 |
/// two distinct events. To manually log screen view events, use the `screen_view` event name. |
aca600
|
64 |
/// @param parameters The dictionary of event parameters. Passing `nil` indicates that the event has |
a6c014
|
65 |
/// no parameters. Parameter names can be up to 40 characters long and must start with an |
aca600
|
66 |
/// alphabetic character and contain only alphanumeric characters and underscores. Only String, |
L |
67 |
/// Int, and Double parameter types are supported. String parameter values can be up to 100 |
|
68 |
/// characters long. The "firebase_", "google_", and "ga_" prefixes are reserved and should not |
|
69 |
/// be used for parameter names. |
a6c014
|
70 |
+ (void)logEventWithName:(NSString *)name |
L |
71 |
parameters:(nullable NSDictionary<NSString *, id> *)parameters |
|
72 |
NS_SWIFT_NAME(logEvent(_:parameters:)); |
|
73 |
|
|
74 |
/// Sets a user property to a given value. Up to 25 user property names are supported. Once set, |
|
75 |
/// user property values persist throughout the app lifecycle and across sessions. |
|
76 |
/// |
|
77 |
/// The following user property names are reserved and cannot be used: |
|
78 |
/// <ul> |
|
79 |
/// <li>first_open_time</li> |
|
80 |
/// <li>last_deep_link_referrer</li> |
|
81 |
/// <li>user_id</li> |
|
82 |
/// </ul> |
|
83 |
/// |
|
84 |
/// @param value The value of the user property. Values can be up to 36 characters long. Setting the |
aca600
|
85 |
/// value to `nil` removes the user property. |
a6c014
|
86 |
/// @param name The name of the user property to set. Should contain 1 to 24 alphanumeric characters |
L |
87 |
/// or underscores and must start with an alphabetic character. The "firebase_", "google_", and |
|
88 |
/// "ga_" prefixes are reserved and should not be used for user property names. |
|
89 |
+ (void)setUserPropertyString:(nullable NSString *)value forName:(NSString *)name |
|
90 |
NS_SWIFT_NAME(setUserProperty(_:forName:)); |
|
91 |
|
|
92 |
/// Sets the user ID property. This feature must be used in accordance with |
|
93 |
/// <a href="https://www.google.com/policies/privacy">Google's Privacy Policy</a> |
|
94 |
/// |
|
95 |
/// @param userID The user ID to ascribe to the user of this app on this device, which must be |
aca600
|
96 |
/// non-empty and no more than 256 characters long. Setting userID to `nil` removes the user ID. |
a6c014
|
97 |
+ (void)setUserID:(nullable NSString *)userID; |
L |
98 |
|
|
99 |
/// Sets whether analytics collection is enabled for this app on this device. This setting is |
|
100 |
/// persisted across app sessions. By default it is enabled. |
|
101 |
/// |
|
102 |
/// @param analyticsCollectionEnabled A flag that enables or disables Analytics collection. |
|
103 |
+ (void)setAnalyticsCollectionEnabled:(BOOL)analyticsCollectionEnabled; |
|
104 |
|
|
105 |
/// Sets the interval of inactivity in seconds that terminates the current session. The default |
|
106 |
/// value is 1800 seconds (30 minutes). |
|
107 |
/// |
|
108 |
/// @param sessionTimeoutInterval The custom time of inactivity in seconds before the current |
|
109 |
/// session terminates. |
|
110 |
+ (void)setSessionTimeoutInterval:(NSTimeInterval)sessionTimeoutInterval; |
|
111 |
|
aca600
|
112 |
/// Asynchronously retrieves the identifier of the current app session. |
L |
113 |
/// |
|
114 |
/// The session ID retrieval could fail due to Analytics collection disabled, app session expired, |
|
115 |
/// etc. |
|
116 |
/// |
|
117 |
/// @param completion The completion handler to call when the session ID retrieval is complete. This |
|
118 |
/// handler is executed on a system-defined global concurrent queue. |
|
119 |
/// This completion handler takes the following parameters: |
|
120 |
/// <b>sessionID</b> The identifier of the current app session. The value is undefined if the |
|
121 |
/// request failed. |
|
122 |
/// <b>error</b> An error object that indicates why the request failed, or `nil` if the request |
|
123 |
/// was successful. |
|
124 |
+ (void)sessionIDWithCompletion:(void (^)(int64_t sessionID, NSError *_Nullable error))completion; |
|
125 |
|
|
126 |
/// Returns the unique ID for this instance of the application or `nil` if |
454098
|
127 |
/// `ConsentType.analyticsStorage` has been set to `ConsentStatus.denied`. |
L |
128 |
/// |
|
129 |
/// @see `FIRAnalytics+Consent.h` |
|
130 |
+ (nullable NSString *)appInstanceID; |
a6c014
|
131 |
|
L |
132 |
/// Clears all analytics data for this instance from the device and resets the app instance ID. |
|
133 |
+ (void)resetAnalyticsData; |
|
134 |
|
|
135 |
/// Adds parameters that will be set on every event logged from the SDK, including automatic ones. |
|
136 |
/// The values passed in the parameters dictionary will be added to the dictionary of default event |
|
137 |
/// parameters. These parameters persist across app runs. They are of lower precedence than event |
|
138 |
/// parameters, so if an event parameter and a parameter set using this API have the same name, the |
|
139 |
/// value of the event parameter will be used. The same limitations on event parameters apply to |
|
140 |
/// default event parameters. |
|
141 |
/// |
|
142 |
/// @param parameters Parameters to be added to the dictionary of parameters added to every event. |
|
143 |
/// They will be added to the dictionary of default event parameters, replacing any existing |
aca600
|
144 |
/// parameter with the same name. Valid parameters are String, Int, and Double. Setting a key's |
L |
145 |
/// value to `NSNull()` will clear that parameter. Passing in a `nil` dictionary will clear all |
|
146 |
/// parameters. |
a6c014
|
147 |
+ (void)setDefaultEventParameters:(nullable NSDictionary<NSString *, id> *)parameters; |
L |
148 |
|
454098
|
149 |
/// Unavailable. |
L |
150 |
- (instancetype)init NS_UNAVAILABLE; |
|
151 |
|
a6c014
|
152 |
@end |
L |
153 |
|
|
154 |
NS_ASSUME_NONNULL_END |