Skip to content

Commit e2214e2

Browse files
authored
SPM - Initial Analytics (#6215)
1 parent 2e02813 commit e2214e2

File tree

11 files changed

+1467
-5
lines changed

11 files changed

+1467
-5
lines changed

.github/workflows/spm.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@ jobs:
2727
- uses: actions/checkout@v2
2828
- name: Xcode 12
2929
run: sudo xcode-select -s /Applications/Xcode_12_beta.app/Contents/Developer
30-
- name: Build
31-
run: swift build
3230
- name: Initialize xcodebuild
3331
run: xcodebuild -list
3432
- name: Core ObjC Unit Tests iOS
@@ -44,8 +42,6 @@ jobs:
4442
- uses: actions/checkout@v2
4543
- name: Xcode 12
4644
run: sudo xcode-select -s /Applications/Xcode_12_beta.app/Contents/Developer
47-
- name: Build
48-
run: swift build
4945
- name: Initialize xcodebuild
5046
run: xcodebuild -list
5147
- name: Core ObjC Unit Tests macOS
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
#import <Foundation/Foundation.h>
2+
3+
#import "FIRAnalytics.h"
4+
5+
NS_ASSUME_NONNULL_BEGIN
6+
7+
/**
8+
* Provides App Delegate handlers to be used in your App Delegate.
9+
*
10+
* To save time integrating Firebase Analytics in an application, Firebase Analytics does not
11+
* require delegation implementation from the AppDelegate. Instead this is automatically done by
12+
* Firebase Analytics. Should you choose instead to delegate manually, you can turn off the App
13+
* Delegate Proxy by adding FirebaseAppDelegateProxyEnabled into your app's Info.plist and setting
14+
* it to NO, and adding the methods in this category to corresponding delegation handlers.
15+
*
16+
* To handle Universal Links, you must return YES in
17+
* [UIApplicationDelegate application:didFinishLaunchingWithOptions:].
18+
*/
19+
@interface FIRAnalytics (AppDelegate)
20+
21+
/**
22+
* Handles events related to a URL session that are waiting to be processed.
23+
*
24+
* For optimal use of Firebase Analytics, call this method from the
25+
* [UIApplicationDelegate application:handleEventsForBackgroundURLSession:completionHandler]
26+
* method of the app delegate in your app.
27+
*
28+
* @param identifier The identifier of the URL session requiring attention.
29+
* @param completionHandler The completion handler to call when you finish processing the events.
30+
* Calling this completion handler lets the system know that your app's user interface is
31+
* updated and a new snapshot can be taken.
32+
*/
33+
+ (void)handleEventsForBackgroundURLSession:(NSString *)identifier
34+
completionHandler:(nullable void (^)(void))completionHandler;
35+
36+
/**
37+
* Handles the event when the app is launched by a URL.
38+
*
39+
* Call this method from [UIApplicationDelegate application:openURL:options:] &#40;on iOS 9.0 and
40+
* above&#41;, or [UIApplicationDelegate application:openURL:sourceApplication:annotation:] &#40;on
41+
* iOS 8.x and below&#41; in your app.
42+
*
43+
* @param url The URL resource to open. This resource can be a network resource or a file.
44+
*/
45+
+ (void)handleOpenURL:(NSURL *)url;
46+
47+
/**
48+
* Handles the event when the app receives data associated with user activity that includes a
49+
* Universal Link (on iOS 9.0 and above).
50+
*
51+
* Call this method from [UIApplication continueUserActivity:restorationHandler:] in your app
52+
* delegate (on iOS 9.0 and above).
53+
*
54+
* @param userActivity The activity object containing the data associated with the task the user
55+
* was performing.
56+
*/
57+
+ (void)handleUserActivity:(id)userActivity;
58+
59+
@end
60+
61+
NS_ASSUME_NONNULL_END
62+
Lines changed: 154 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,154 @@
1+
#import <Foundation/Foundation.h>
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_impression</li>
29+
/// <li>ad_query</li>
30+
/// <li>adunit_exposure</li>
31+
/// <li>app_clear_data</li>
32+
/// <li>app_remove</li>
33+
/// <li>app_update</li>
34+
/// <li>error</li>
35+
/// <li>first_open</li>
36+
/// <li>in_app_purchase</li>
37+
/// <li>notification_dismiss</li>
38+
/// <li>notification_foreground</li>
39+
/// <li>notification_open</li>
40+
/// <li>notification_receive</li>
41+
/// <li>os_update</li>
42+
/// <li>session_start</li>
43+
/// <li>user_engagement</li>
44+
/// </ul>
45+
///
46+
/// @param name The name of the event. Should contain 1 to 40 alphanumeric characters or
47+
/// underscores. The name must start with an alphabetic character. Some event names are
48+
/// reserved. See FIREventNames.h for the list of reserved event names. The "firebase_",
49+
/// "google_", and "ga_" prefixes are reserved and should not be used. Note that event names are
50+
/// case-sensitive and that logging two events whose names differ only in case will result in
51+
/// two distinct events. To manually log screen view events, use the `screen_view` event name.
52+
/// @param parameters The dictionary of event parameters. Passing nil indicates that the event has
53+
/// no parameters. Parameter names can be up to 40 characters long and must start with an
54+
/// alphabetic character and contain only alphanumeric characters and underscores. Only NSString
55+
/// and NSNumber (signed 64-bit integer and 64-bit floating-point number) parameter types are
56+
/// supported. NSString parameter values can be up to 100 characters long. The "firebase_",
57+
/// "google_", and "ga_" prefixes are reserved and should not be used for parameter names.
58+
+ (void)logEventWithName:(NSString *)name
59+
parameters:(nullable NSDictionary<NSString *, id> *)parameters
60+
NS_SWIFT_NAME(logEvent(_:parameters:));
61+
62+
/// Sets a user property to a given value. Up to 25 user property names are supported. Once set,
63+
/// user property values persist throughout the app lifecycle and across sessions.
64+
///
65+
/// The following user property names are reserved and cannot be used:
66+
/// <ul>
67+
/// <li>first_open_time</li>
68+
/// <li>last_deep_link_referrer</li>
69+
/// <li>user_id</li>
70+
/// </ul>
71+
///
72+
/// @param value The value of the user property. Values can be up to 36 characters long. Setting the
73+
/// value to nil removes the user property.
74+
/// @param name The name of the user property to set. Should contain 1 to 24 alphanumeric characters
75+
/// or underscores and must start with an alphabetic character. The "firebase_", "google_", and
76+
/// "ga_" prefixes are reserved and should not be used for user property names.
77+
+ (void)setUserPropertyString:(nullable NSString *)value forName:(NSString *)name
78+
NS_SWIFT_NAME(setUserProperty(_:forName:));
79+
80+
/// Sets the user ID property. This feature must be used in accordance with
81+
/// <a href="https://www.google.com/policies/privacy">Google's Privacy Policy</a>
82+
///
83+
/// @param userID The user ID to ascribe to the user of this app on this device, which must be
84+
/// non-empty and no more than 256 characters long. Setting userID to nil removes the user ID.
85+
+ (void)setUserID:(nullable NSString *)userID;
86+
87+
/// This method was deprecated in Firebase 6.29.0.
88+
///
89+
/// Sets the current screen name, which specifies the current visual context in your app. This helps
90+
/// identify the areas in your app where users spend their time and how they interact with your app.
91+
/// Must be called on the main thread.
92+
///
93+
/// Note that screen reporting is enabled automatically and records the class name of the current
94+
/// UIViewController for you without requiring you to call this method. The class name can
95+
/// optionally be overridden by calling this method in the viewDidAppear callback of your
96+
/// UIViewController and specifying the screenClassOverride parameter.
97+
/// `setScreenName:screenClass:` must be called after `[super viewDidAppear:]`.
98+
///
99+
/// If your app does not use a distinct UIViewController for each screen, you should call this
100+
/// method and specify a distinct screenName each time a new screen is presented to the user.
101+
///
102+
/// The screen name and screen class remain in effect until the current UIViewController changes or
103+
/// a new call to setScreenName:screenClass: is made.
104+
///
105+
/// @warning If you override `viewDidAppear:` in your UIViewController but do not call
106+
/// `[super viewDidAppear:]`, that screen class will not be tracked.
107+
///
108+
/// @param screenName The name of the current screen. Should contain 1 to 100 characters. Set to nil
109+
/// to clear the current screen name.
110+
/// @param screenClassOverride The name of the screen class. Should contain 1 to 100 characters. By
111+
/// default this is the class name of the current UIViewController. Set to nil to revert to the
112+
/// default class name.
113+
+ (void)setScreenName:(nullable NSString *)screenName
114+
screenClass:(nullable NSString *)screenClassOverride
115+
DEPRECATED_MSG_ATTRIBUTE(
116+
"Use +[FIRAnalytics logEventWithName:kFIREventScreenView parameters:] instead.");
117+
118+
/// Sets whether analytics collection is enabled for this app on this device. This setting is
119+
/// persisted across app sessions. By default it is enabled.
120+
///
121+
/// @param analyticsCollectionEnabled A flag that enables or disables Analytics collection.
122+
+ (void)setAnalyticsCollectionEnabled:(BOOL)analyticsCollectionEnabled;
123+
124+
/// Sets the interval of inactivity in seconds that terminates the current session. The default
125+
/// value is 1800 seconds (30 minutes).
126+
///
127+
/// @param sessionTimeoutInterval The custom time of inactivity in seconds before the current
128+
/// session terminates.
129+
+ (void)setSessionTimeoutInterval:(NSTimeInterval)sessionTimeoutInterval;
130+
131+
/// The unique ID for this instance of the application.
132+
+ (NSString *)appInstanceID;
133+
134+
/// Clears all analytics data for this instance from the device and resets the app instance ID.
135+
/// FIRAnalyticsConfiguration values will be reset to the default values.
136+
+ (void)resetAnalyticsData;
137+
138+
/// Adds parameters that will be set on every event logged from the SDK, including automatic ones.
139+
/// The values passed in the parameters dictionary will be added to the dictionary of default event
140+
/// parameters. These parameters persist across app runs. They are of lower precedence than event
141+
/// parameters, so if an event parameter and a parameter set using this API have the same name, the
142+
/// value of the event parameter will be used. The same limitations on event parameters apply to
143+
/// default event parameters.
144+
///
145+
/// @param parameters Parameters to be added to the dictionary of parameters added to every event.
146+
/// They will be added to the dictionary of default event parameters, replacing any existing
147+
/// parameter with the same name. Valid parameters are NSString and NSNumber (signed 64-bit
148+
/// integer and 64-bit floating-point number). Setting a key's value to [NSNull null] will clear
149+
/// that parameter. Passing in a nil dictionary will clear all parameters.
150+
+ (void)setDefaultEventParameters:(nullable NSDictionary<NSString *, id> *)parameters;
151+
152+
@end
153+
154+
NS_ASSUME_NONNULL_END

0 commit comments

Comments
 (0)