1 #import <Foundation/Foundation.h>
3 #import "FIREventNames.h"
4 #import "FIRParameterNames.h"
5 #import "FIRUserPropertyNames.h"
7 NS_ASSUME_NONNULL_BEGIN
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 NS_SWIFT_NAME(Analytics)
13 @interface FIRAnalytics : NSObject
15 /// Logs an app event. The event can have up to 25 parameters. Events with the same name must have
16 /// the same parameters. Up to 500 event names are supported. Using predefined events and/or
17 /// parameters is recommended for optimal reporting.
19 /// The following event names are reserved and cannot be used:
21 /// <li>ad_activeview</li>
23 /// <li>ad_exposure</li>
24 /// <li>ad_impression</li>
26 /// <li>adunit_exposure</li>
27 /// <li>app_clear_data</li>
28 /// <li>app_remove</li>
29 /// <li>app_update</li>
31 /// <li>first_open</li>
32 /// <li>in_app_purchase</li>
33 /// <li>notification_dismiss</li>
34 /// <li>notification_foreground</li>
35 /// <li>notification_open</li>
36 /// <li>notification_receive</li>
37 /// <li>os_update</li>
38 /// <li>screen_view</li>
39 /// <li>session_start</li>
40 /// <li>user_engagement</li>
43 /// @param name The name of the event. Should contain 1 to 40 alphanumeric characters or
44 /// underscores. The name must start with an alphabetic character. Some event names are
45 /// reserved. See FIREventNames.h for the list of reserved event names. The "firebase_",
46 /// "google_", and "ga_" prefixes are reserved and should not be used. Note that event names are
47 /// case-sensitive and that logging two events whose names differ only in case will result in
48 /// two distinct events.
49 /// @param parameters The dictionary of event parameters. Passing nil indicates that the event has
50 /// no parameters. Parameter names can be up to 40 characters long and must start with an
51 /// alphabetic character and contain only alphanumeric characters and underscores. Only NSString
52 /// and NSNumber (signed 64-bit integer and 64-bit floating-point number) parameter types are
53 /// supported. NSString parameter values can be up to 100 characters long. The "firebase_",
54 /// "google_", and "ga_" prefixes are reserved and should not be used for parameter names.
55 + (void)logEventWithName:(NSString *)name
56 parameters:(nullable NSDictionary<NSString *, id> *)parameters
57 NS_SWIFT_NAME(logEvent(_:parameters:));
59 /// Sets a user property to a given value. Up to 25 user property names are supported. Once set,
60 /// user property values persist throughout the app lifecycle and across sessions.
62 /// The following user property names are reserved and cannot be used:
64 /// <li>first_open_time</li>
65 /// <li>last_deep_link_referrer</li>
69 /// @param value The value of the user property. Values can be up to 36 characters long. Setting the
70 /// value to nil removes the user property.
71 /// @param name The name of the user property to set. Should contain 1 to 24 alphanumeric characters
72 /// or underscores and must start with an alphabetic character. The "firebase_", "google_", and
73 /// "ga_" prefixes are reserved and should not be used for user property names.
74 + (void)setUserPropertyString:(nullable NSString *)value forName:(NSString *)name
75 NS_SWIFT_NAME(setUserProperty(_:forName:));
77 /// Sets the user ID property. This feature must be used in accordance with
78 /// <a href="https://www.google.com/policies/privacy">Google's Privacy Policy</a>
80 /// @param userID The user ID to ascribe to the user of this app on this device, which must be
81 /// non-empty and no more than 256 characters long. Setting userID to nil removes the user ID.
82 + (void)setUserID:(nullable NSString *)userID;
84 /// Sets the current screen name, which specifies the current visual context in your app. This helps
85 /// identify the areas in your app where users spend their time and how they interact with your app.
86 /// Must be called on the main thread.
88 /// Note that screen reporting is enabled automatically and records the class name of the current
89 /// UIViewController for you without requiring you to call this method. If you implement
90 /// viewDidAppear in your UIViewController but do not call [super viewDidAppear:], that screen class
91 /// will not be automatically tracked. The class name can optionally be overridden by calling this
92 /// method in the viewDidAppear callback of your UIViewController and specifying the
93 /// screenClassOverride parameter. setScreenName:screenClass: must be called after
94 /// [super viewDidAppear:].
96 /// If your app does not use a distinct UIViewController for each screen, you should call this
97 /// method and specify a distinct screenName each time a new screen is presented to the user.
99 /// The screen name and screen class remain in effect until the current UIViewController changes or
100 /// a new call to setScreenName:screenClass: is made.
102 /// @param screenName The name of the current screen. Should contain 1 to 100 characters. Set to nil
103 /// to clear the current screen name.
104 /// @param screenClassOverride The name of the screen class. Should contain 1 to 100 characters. By
105 /// default this is the class name of the current UIViewController. Set to nil to revert to the
106 /// default class name.
107 + (void)setScreenName:(nullable NSString *)screenName
108 screenClass:(nullable NSString *)screenClassOverride;
110 /// The unique ID for this instance of the application.
111 + (NSString *)appInstanceID;
113 /// Clears all analytics data for this instance from the device and resets the app instance ID.
114 /// FIRAnalyticsConfiguration values will be reset to the default values.
115 + (void)resetAnalyticsData;
119 NS_ASSUME_NONNULL_END