IReporter interface

com.yandex.metrica

public interface IReporter

This interface is used for sending statistics using a different API key instead of the app's API key.

Methods

void pauseSession()

Pauses the user session.

void reportError(@NonNull String message, @Nullable Throwable error)

Sends a custom error message.

void reportEvent(@NonNull String eventName)

Sends an event message.

void reportEvent(@NonNull String eventName, @Nullable String jsonValue)

Sends an event message as a string in JSON format.

void reportEvent(@NonNull String eventName, @Nullable Map<String, Object> attributes)

Sends an event message as a set of attributes (Map).

void reportRevenue(@NonNull Revenue revenue)

Sends information about a purchase.

void reportUnhandledException(@NonNull Throwable exception)

Sends a report about app crashes.

void reportUserProfile(@NonNull UserProfile profile)

Sends information about the user profile update to the AppMetrica server.

void resumeSession()

Resumes the user session.

void sendEventsBuffer()

Sends stored events from the buffer.

void setStatisticsSending(boolean enabled)

Enables/disables sending statistics to the AppMetrica server.

void setUserProfileID(@Nullable String profileID)

Sets the ID of the user profile.

Method descriptions

pauseSession

void pauseSession()

Pauses the user session.

For more information, see Tracking user activity.

reportError

void reportError(@NonNull String message, @Nullable Throwable error)

Sends a custom error message.

Parameters:
message Error description.

Can't be empty.

error Error class.

reportEvent

void reportEvent(@NonNull String eventName)

Sends an event message.

Parameters:
eventName Short name or description of the event

Can't be empty.

reportEvent

void reportEvent(@NonNull String eventName, @Nullable String jsonValue)

Sends an event message as a string in JSON format.

Parameters:
eventName Short name or description of the event

Can't be empty.

jsonValue A valid JSON string with custom content.

reportEvent

void reportEvent(@NonNull String eventName, @Nullable Map<String, Object> attributes)

Sends an event message as a set of attributes (Map).

Parameters:
eventName Short name or description of the event

Can't be empty.

attributes A set of attributes (Map).

reportRevenue

void reportRevenue(@NonNull Revenue revenue)

Sends information about a purchase.

Parameters:
revenue

The instance of the Revenue class which contains information about a purchase.

reportUnhandledException

void reportUnhandledException(@NonNull Throwable exception)

Sends a report about app crashes.

Parameters:
exception The instance of the Throwable class.

reportUserProfile

void reportUserProfile(@NonNull UserProfile profile)

Sends information about the user profile update to the AppMetrica server.

Parameters:
profile The instance of the UserProfile class which contains information about the user profile.

resumeSession

void resumeSession()

Resumes the user session.

For more information, see Tracking user activity.

sendEventsBuffer

void sendEventsBuffer()

Sends stored events from the buffer.

AppMetrica SDK does not send an event immediately after it occurred. The library stores event data in the buffer. The sendEventsBuffer() method sends data from the buffer and flushes it. Use the method to force sending stored events after passing important checkpoints of user scenarios.

Attention. Frequent use of the method can lead to increased outgoing internet traffic and energy consumption.

setStatisticsSending

void setStatisticsSending(boolean enabled)

Enables/disables sending statistics to the AppMetrica server.

For more information about using the method, see Disable and enable sending statistics.

Note. Disable sending statistics to the reporter does not affect the sending of data from the main API key. But disabling data sending for the main API key stops sending statistics from all reporters.
Parameters:
enabled

A flag indicating that sending statistics is enabled.

The default value is true.

Possible values:
  • true — Sending statistics is enabled.
  • false — Sending statistics is disabled.

setUserProfileID

void setUserProfileID(@Nullable String profileID)

Sets the ID of the user profile.

Parameters:
userProfileID

User profile ID.