java.lang.Object | |
↳ | com.google.firebase.analytics.FirebaseAnalytics |
The top level Firebase Analytics singleton that provides methods for logging events and setting user properties. See the developer guides for general information on using Firebase Analytics in your apps.
Applications can get an instance of this class by callinggetInstance(Context)
.
getInstance(Context)
is thread safe and can be called from any thread.
Nested Classes | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
FirebaseAnalytics.Event | An Event is an important occurrence in your app that you want to measure. | ||||||||||
FirebaseAnalytics.Param | Params supply information that contextualize Events. | ||||||||||
FirebaseAnalytics.UserProperty | A UserProperty is an attribute that describes the app-user. |
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Retrieves the app instance id from the service.
| |||||||||||
Returns the singleton FirebaseAnalytics interface.
| |||||||||||
Logs an app event.
| |||||||||||
Sets whether analytics collection is enabled for this app on this device.
| |||||||||||
Sets the current screen name, which specifies the current visual context in your app.
| |||||||||||
Sets the minimum engagement time required before starting a session. The default value
is 10000 (10 seconds).
| |||||||||||
Sets the duration of inactivity that terminates the current session. The default value
is 1800000 (30 minutes).
| |||||||||||
Sets the user ID property.
| |||||||||||
Sets a user property to a given value.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
![]() |
Returns the singleton FirebaseAnalytics interface.
Parameters | |
---|---|
context |
Context :
the context used to initialize Firebase Analytics. Must not be null .
|
Returns | |
---|---|
FirebaseAnalytics |
Logs an app event. The event can have up to 25 parameters. Events with the same name must
have the same parameters. Up to 500 event names are supported. Using predefined FirebaseAnalytics.Event
and/or FirebaseAnalytics.Param
is recommended for optimal reporting.
Parameters | |
---|---|
name |
String :
The name of the event. Should contain 1 to 40 alphanumeric
characters or underscores. The name must start with an alphabetic
character. Some event names are reserved. See FirebaseAnalytics.Event for the list of
reserved event names. The "firebase_", "google_" and "ga_" prefixes are
reserved and should not be used. Note that event names are case-sensitive and
that logging two events whose names differ only in case will result in two
distinct events. |
params |
Bundle :
The map of event parameters. Passing null indicates that the event has
no parameters. Parameter names can be up to 40 characters long and must start
with an alphabetic
character and contain only alphanumeric characters
and underscores. String, long and double param types are supported. String
parameter values can be up to 100 characters long. The "firebase_", "google_"
and "ga_" prefixes are reserved and should not be used for parameter names.
|
Sets whether analytics collection is enabled for this app on this device. This setting is persisted across app sessions. By default it is enabled.
Parameters | |
---|---|
enabled |
boolean :
Whether analytics collection is enabled for this app on this device.
|
Sets the current screen name, which specifies the current visual context in your app. This helps identify the areas in your app where users spend their time and how they interact with your app.
Note that screen reporting is enabled automatically and records the class name of the current Activity for you without requiring you to call this function. The class name can optionally be overridden by calling this function in the onResume callback of your Activity and specifying the screenClassOverride parameter.
If your app does not use a distinct Activity for each screen, you should call this function and specify a distinct screenName each time a new screen is presented to the user.
The name and classOverride remain in effect until the current Activity changes or a new call to setCurrentScreen is made.
Parameters | |
---|---|
activity |
Activity :
The activity to which the screen name and class name apply. |
screenName |
String :
The name of the current screen. Set to null to clear the current screen
name. |
screenClassOverride |
String :
The name of the screen class. By default this is the class name of
the current Activity. Set to null to revert to the default class
name.
|
Sets the minimum engagement time required before starting a session. The default value is 10000 (10 seconds).
Parameters | |
---|---|
milliseconds |
long :
The minimum engagement time required to start a new session.
|
Sets the duration of inactivity that terminates the current session. The default value is 1800000 (30 minutes).
Parameters | |
---|---|
milliseconds |
long :
Session timeout duration in milliseconds
|
Sets the user ID property. This feature must be used in accordance with Google's Privacy Policy.
Parameters | |
---|---|
id |
String :
The user ID to ascribe to the user of this app on this device, which must be
non-empty and no more than 36 characters long. Setting the ID to null removes the
user ID.
|
Sets a user property to a given value. Up to 25 user property names are supported. Once set, user property values persist throughout the app lifecycle and across sessions.
Parameters | |
---|---|
name |
String :
The name of the user property to set. Should contain 1 to 24 alphanumeric
characters or underscores and must start with an alphabetic
character. The "firebase_", "google_" and "ga_" prefixes are reserved and should
not be used for user property names. |
value |
String :
The value of the user property. Values can be up to 36 characters long. Setting
the value to null removes the user property.
|