This repository has been archived by the owner on Nov 3, 2019. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathGAI.h
166 lines (134 loc) · 6.2 KB
/
GAI.h
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
/*!
@header GAI.h
@abstract Google Analytics iOS SDK Header
@version 3.0
@copyright Copyright 2013 Google Inc. All rights reserved.
*/
#import <Foundation/Foundation.h>
#import "GAILogger.h"
#import "GAITracker.h"
#import "GAITrackedViewController.h"
/*! Google Analytics product string. */
extern NSString *const kGAIProduct;
/*! Google Analytics version string. */
extern NSString *const kGAIVersion;
/*!
NSError objects returned by the Google Analytics SDK may have this error domain
to indicate that the error originated in the Google Analytics SDK.
*/
extern NSString *const kGAIErrorDomain;
/*! Google Analytics error codes. */
typedef enum {
// This error code indicates that there was no error. Never used.
kGAINoError = 0,
// This error code indicates that there was a database-related error.
kGAIDatabaseError,
// This error code indicates that there was a network-related error.
kGAINetworkError,
} GAIErrorCode;
/*!
Google Analytics iOS top-level class. Provides facilities to create trackers
and set behaviorial flags.
*/
@interface GAI : NSObject
/*!
For convenience, this class exposes a default tracker instance.
This is initialized to `nil` and will be set to the first tracker that is
instantiated in trackerWithTrackingId:. It may be overridden as desired.
The GAITrackedViewController class will, by default, use this tracker instance.
*/
@property(nonatomic, assign) id<GAITracker> defaultTracker;
/*!
The GAILogger to use.
*/
@property(nonatomic, retain) id<GAILogger> logger;
/*!
When this is true, no tracking information will be gathered; tracking calls
will effectively become no-ops. When set to true, all tracking information that
has not yet been submitted. The value of this flag will be persisted
automatically by the SDK. Developers can optionally use this flag to implement
an opt-out setting in the app to allows users to opt out of Google Analytics
tracking.
This is set to `NO` the first time the Google Analytics SDK is used on a
device, and is persisted thereafter.
*/
@property(nonatomic, assign) BOOL optOut;
/*!
If this value is positive, tracking information will be automatically
dispatched every dispatchInterval seconds. Otherwise, tracking information must
be sent manually by calling dispatch.
By default, this is set to `120`, which indicates tracking information should
be dispatched automatically every 120 seconds.
*/
@property(nonatomic, assign) NSTimeInterval dispatchInterval;
/*!
When set to true, the SDK will record the currently registered uncaught
exception handler, and then register an uncaught exception handler which tracks
the exceptions that occurred using defaultTracker. If defaultTracker is not
`nil`, this function will track the exception on the tracker and attempt to
dispatch any outstanding tracking information for 5 seconds. It will then call
the previously registered exception handler, if any. When set back to false,
the previously registered uncaught exception handler will be restored.
*/
@property(nonatomic, assign) BOOL trackUncaughtExceptions;
/*!
When this is 'YES', no tracking information will be sent. Defaults to 'NO'.
*/
@property(nonatomic, assign) BOOL dryRun;
/*! Get the shared instance of the Google Analytics for iOS class. */
+ (GAI *)sharedInstance;
/*!
Creates or retrieves a GAITracker implementation with the specified name and
tracking ID. If the tracker for the specified name does not already exist, then
it will be created and returned; otherwise, the existing tracker will be
returned. If the existing tracker for the respective name has a different
tracking ID, that tracking ID is not changed by this method. If defaultTracker
is not set, it will be set to the tracker instance returned here.
@param name The name of this tracker. Must not be `nil` or empty.
@param trackingID The tracking ID to use for this tracker. It should be of
the form `UA-xxxxx-y`.
@return A GAITracker associated with the specified name. The tracker
can be used to send tracking data to Google Analytics. The first time this
method is called with a particular name, the tracker for that name will be
returned, and subsequent calls with the same name will return the same
instance. It is not necessary to retain the tracker because the tracker will be
retained internally by the library.
If an error occurs or the name is not valid, this method will return
`nil`.
*/
- (id<GAITracker>)trackerWithName:(NSString *)name
trackingId:(NSString *)trackingId;
/*!
Creates or retrieves a GAITracker implementation with name equal to
the specified tracking ID. If the tracker for the respective name does not
already exist, it is created, has it's tracking ID set to |trackingId|,
and is returned; otherwise, the existing tracker is returned. If the existing
tracker for the respective name has a different tracking ID, that tracking ID
is not changed by this method. If defaultTracker is not set, it is set to the
tracker instance returned here.
@param trackingID The tracking ID to use for this tracker. It should be of
the form `UA-xxxxx-y`. The name of the tracker will be the same as trackingID.
@return A GAITracker associated with the specified trackingID. The tracker
can be used to send tracking data to Google Analytics. The first time this
method is called with a particular trackingID, the tracker for the respective
name will be returned, and subsequent calls with the same trackingID
will return the same instance. It is not necessary to retain the tracker
because the tracker will be retained internally by the library.
If an error occurs or the trackingId is not valid, this method will return
`nil`.
*/
- (id<GAITracker>)trackerWithTrackingId:(NSString *)trackingId;
/*!
Remove a tracker from the trackers dictionary. If it is the default tracker,
clears the default tracker as well.
@param name The name of the tracker.
*/
- (void)removeTrackerByName:(NSString *)name;
/*!
Dispatches any pending tracking information.
It would be wise to call this when application is exiting to initiate the
submission of any unsubmitted tracking information. Note that this does not
have any effect on dispatchInterval, and can be used in conjuntion with
periodic dispatch. */
- (void)dispatch;
@end