前往主控台

firebase::analytics

Firebase Analytics API.

Summary

See the developer guides for general information on using Firebase Analytics in your apps.

Functions

GetAnalyticsInstanceId()
Future< std::string >
Get the instance ID from the analytics service.
GetAnalyticsInstanceIdLastResult()
Future< std::string >
Get the result of the most recent GetAnalyticsInstanceId() call.
Initialize(const App & app)
void
Initialize the Analytics API.
LogEvent(const char *name, const char *parameter_name, const char *parameter_value)
void
Log an event with one string parameter.
LogEvent(const char *name, const char *parameter_name, const double parameter_value)
void
Log an event with one float parameter.
LogEvent(const char *name, const char *parameter_name, const int64_t parameter_value)
void
Log an event with one 64-bit integer parameter.
LogEvent(const char *name, const char *parameter_name, const int parameter_value)
void
Log an event with one integer parameter (stored as a 64-bit integer).
LogEvent(const char *name)
void
Log an event with no parameters.
LogEvent(const char *name, const Parameter *parameters, size_t number_of_parameters)
void
Log an event with associated parameters.
ResetAnalyticsData()
void
Clears all analytics data for this app from the device and resets the app instance id.
SetAnalyticsCollectionEnabled(bool enabled)
void
Sets whether analytics collection is enabled for this app on this device.
SetCurrentScreen(const char *screen_name, const char *screen_class)
void
Sets the current screen name and screen class, which specifies the current visual context in your app.
SetMinimumSessionDuration(int64_t milliseconds)
void
Deprecated. SetMinimumSessionDuration is deprecated and no longer functional.
Sets the minimum engagement time required before starting a session.
SetSessionTimeoutDuration(int64_t milliseconds)
void
Sets the duration of inactivity that terminates the current session.
SetUserId(const char *user_id)
void
Sets the user ID property.
SetUserProperty(const char *name, const char *property)
void
Set a user property to the given value.
Terminate()
void
Terminate the Analytics API.

Structs

firebase::analytics::Parameter

Event parameter.

Functions

GetAnalyticsInstanceId

Future< std::string > GetAnalyticsInstanceId()

Get the instance ID from the analytics service.

Note:This is not the same ID as the ID returned by firebase::instance_id::InstanceId.

Details
Returns
Object which can be used to retrieve the analytics instance ID.

GetAnalyticsInstanceIdLastResult

Future< std::string > GetAnalyticsInstanceIdLastResult()

Get the result of the most recent GetAnalyticsInstanceId() call.

Details
Returns
Object which can be used to retrieve the analytics instance ID.

Initialize

void Initialize(
  const App & app
)

Initialize the Analytics API.

This must be called prior to calling any other methods in the firebase::analytics namespace.

See also:firebase::App::GetInstance().

Details
Parameters
app
Default firebase::App instance.

LogEvent

void LogEvent(
  const char *name,
  const char *parameter_name,
  const char *parameter_value
)

Log an event with one string parameter.

See also: LogEvent(const char*, const Parameter*, size_t)

Details
Parameters
name
Name of the event to log. Should contain 1 to 40 alphanumeric characters or underscores. The name must start with an alphabetic character. Some event names are reserved. See Analytics Events (event_names.h) for the list of reserved event names. The "firebase_" prefix is 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.
parameter_name
Name of the parameter to log. For more information, see Parameter.
parameter_value
Value of the parameter to log.

LogEvent

void LogEvent(
  const char *name,
  const char *parameter_name,
  const double parameter_value
)

Log an event with one float parameter.

See also: LogEvent(const char*, const Parameter*, size_t)

Details
Parameters
name
Name of the event to log. Should contain 1 to 40 alphanumeric characters or underscores. The name must start with an alphabetic character. Some event names are reserved. See Analytics Events (event_names.h) for the list of reserved event names. The "firebase_" prefix is 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.
parameter_name
Name of the parameter to log. For more information, see Parameter.
parameter_value
Value of the parameter to log.

LogEvent

void LogEvent(
  const char *name,
  const char *parameter_name,
  const int64_t parameter_value
)

Log an event with one 64-bit integer parameter.

See also: LogEvent(const char*, const Parameter*, size_t)

Details
Parameters
name
Name of the event to log. Should contain 1 to 40 alphanumeric characters or underscores. The name must start with an alphabetic character. Some event names are reserved. See Analytics Events (event_names.h) for the list of reserved event names. The "firebase_" prefix is 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.
parameter_name
Name of the parameter to log. For more information, see Parameter.
parameter_value
Value of the parameter to log.

LogEvent

void LogEvent(
  const char *name,
  const char *parameter_name,
  const int parameter_value
)

Log an event with one integer parameter (stored as a 64-bit integer).

See also: LogEvent(const char*, const Parameter*, size_t)

Details
Parameters
name
Name of the event to log. Should contain 1 to 40 alphanumeric characters or underscores. The name must start with an alphabetic character. Some event names are reserved. See Analytics Events (event_names.h) for the list of reserved event names. The "firebase_" prefix is 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.
parameter_name
Name of the parameter to log. For more information, see Parameter.
parameter_value
Value of the parameter to log.

LogEvent

void LogEvent(
  const char *name
)

Log an event with no parameters.

See also: LogEvent(const char*, const Parameter*, size_t)

Details
Parameters
name
Name of the event to log. Should contain 1 to 40 alphanumeric characters or underscores. The name must start with an alphabetic character. Some event names are reserved. See Analytics Events (event_names.h) for the list of reserved event names. The "firebase_" prefix is 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.

LogEvent

void LogEvent(
  const char *name,
  const Parameter *parameters,
  size_t number_of_parameters
)

Log an event with associated parameters.

An Event is an important occurrence in your app that you want to measure. You can report up to 500 different types of events per app and you can associate up to 25 unique parameters with each Event type.

Some common events are documented in Analytics Events (event_names.h), but you may also choose to specify custom event types that are associated with your specific app.

Details
Parameters
name
Name of the event to log. Should contain 1 to 40 alphanumeric characters or underscores. The name must start with an alphabetic character. Some event names are reserved. See Analytics Events (event_names.h) for the list of reserved event names. The "firebase_" prefix is 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.
parameters
Array of Parameter structures.
number_of_parameters
Number of elements in the parameters array.

ResetAnalyticsData

void ResetAnalyticsData()

Clears all analytics data for this app from the device and resets the app instance id.

SetAnalyticsCollectionEnabled

void SetAnalyticsCollectionEnabled(
  bool enabled
)

Sets whether analytics collection is enabled for this app on this device.

This setting is persisted across app sessions. By default it is enabled.

Details
Parameters
enabled
true to enable analytics collection, false to disable.

SetCurrentScreen

void SetCurrentScreen(
  const char *screen_name,
  const char *screen_class
)

Sets the current screen name and screen class, 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.

Details
Parameters
screen_name
The name of the current screen. Set to nullptr to clear the current screen name. Limited to 100 characters.
screen_class
The name of the screen class. If you specify nullptr for this, it will use the default. On Android, the default is the class name of the current Activity. On iOS, the default is the class name of the current UIViewController. Limited to 100 characters.

SetMinimumSessionDuration

void SetMinimumSessionDuration(
  int64_t milliseconds
)

Sets the minimum engagement time required before starting a session.

Note:The default value is 10000 (10 seconds). Deprecated. SetMinimumSessionDuration is deprecated and no longer functional.

Details
Parameters
milliseconds
The minimum engagement time required to start a new session.

SetSessionTimeoutDuration

void SetSessionTimeoutDuration(
  int64_t milliseconds
)

Sets the duration of inactivity that terminates the current session.

Note:The default value is 1800000 (30 minutes).

Details
Parameters
milliseconds