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

voidpauseSession()

Pauses the user session.

voidreportError(@NonNull String message, @Nullable Throwable error)

Sends a custom error message.

voidreportEvent(@NonNull String eventName)

Sends an event message.

voidreportEvent(@NonNull String eventName, @Nullable String jsonValue)

Sends an event message as a string in JSON format.

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

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

voidreportRevenue(@NonNull Revenue revenue)

Sends information about a purchase.

voidreportUnhandledException(@NonNull Throwable exception)

Sends a report about app crashes.

voidreportUserProfile(@NonNull UserProfile profile)

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

voidresumeSession()

Resumes the user session.

voidsendEventsBuffer()

Sends stored events from the buffer.

voidsetStatisticsSending(boolean enabled)

Enables/disables sending statistics to the AppMetrica server.

voidsetUserProfileID(@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:
messageError description.

Can't be empty.

errorError class.

reportEvent

void reportEvent(@NonNull String eventName)

Sends an event message.

Parameters:
eventNameShort 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:
eventNameShort name or description of the event

Can't be empty.

jsonValueA 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:
eventNameShort name or description of the event

Can't be empty.

attributesA 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:
exceptionThe instance of the Throwable class.

reportUserProfile

void reportUserProfile(@NonNull UserProfile profile)

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

Parameters:
profileThe 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.