public interface IReporter
IReporter can send events to an alternative api key, differ from
api key, passed to YandexMetrica.activate(android.content.Context, com.yandex.metrica.YandexMetricaConfig)
IReporter, can be obtained via
YandexMetrica.getReporter(android.content.Context, String) method call.
For every api key only one IReporter instance is created.
You can either query it each time you need it, or save the reference by yourself.
| Modifier and Type | Method and Description |
|---|---|
void |
pauseSession()
Helper method for sessions tracking.
|
void |
reportECommerce(ECommerceEvent event)
Sends e-commerce event.
|
void |
reportError(java.lang.String identifier,
java.lang.String message)
Sends an error.
|
void |
reportError(java.lang.String identifier,
java.lang.String message,
java.lang.Throwable error)
Sends an error.
|
void |
reportError(java.lang.String message,
java.lang.Throwable error)
Sends an error.
|
void |
reportEvent(java.lang.String eventName)
Sends report by event name.
|
void |
reportEvent(java.lang.String eventName,
java.util.Map<java.lang.String,java.lang.Object> attributes)
Sends report by dictionary.
|
void |
reportEvent(java.lang.String eventName,
java.lang.String jsonValue)
Sends report by event name and event value.
|
void |
reportRevenue(Revenue revenue)
Sends information about the purchase.
|
void |
reportUnhandledException(java.lang.Throwable exception)
Sends unhandled exception by
Throwable object. |
void |
reportUserProfile(UserProfile profile)
Sends information about the user profile.
|
void |
resumeSession()
Helper method for sessions tracking.
|
void |
sendEventsBuffer()
Initiates forced sending of all stored events from the buffer.
|
void |
setStatisticsSending(boolean enabled)
Enables/disables statistics sending to the AppMetrica server.
|
void |
setUserProfileID(java.lang.String profileID)
Sets the ID of the user profile.
|
void sendEventsBuffer()
AppMetrica SDK doesn't send events immediately after they occurred. It stores events data in the buffer. This method forcibly initiates sending all the data from the buffer and flushes it.
Use the method after important checkpoints of user scenarios.
WARNING: Frequent use of the method can lead to increasing outgoing internet traffic and energy consumption.
void reportEvent(@NonNull
java.lang.String eventName)
eventName - Event name. In the eventName parameter,
pass a short name or description of the event.java.lang.IllegalArgumentException - If eventName is null.reportEvent(String)void reportEvent(@NonNull
java.lang.String eventName,
@Nullable
java.lang.String jsonValue)
eventName - Event name. In the eventName parameter,
pass a short name or description of the event.jsonValue - Event value. In the eventValue parameter,
pass a JSONObject represented as a String object or
pass a String object represented in the Java JSON format.
Maximum level of nesting (for JSON object) - 5.
EXAMPLE:
{
"firstName": "John",
"lastName": "Smith",
"age": 25,
"nickname": "JS"
"address": {
"streetAddress": "21 2nd Street",
"city": "New York",
"state": "NY",
},
"phoneNumbers": [
{
"type": "HOME",
"number": "212 555-1234"
},
{
"type": "FAX",
"number": "646 555-4567"
}
]
}
java.lang.IllegalArgumentException - If eventName or jsonValue is null.reportEvent(String, String),
JSONObject.toString()void reportEvent(@NonNull
java.lang.String eventName,
@Nullable
java.util.Map<java.lang.String,java.lang.Object> attributes)
eventName - Event name. In the eventName parameter,
pass a short name or description of the event.attributes - Event value. In the attributes parameter,
pass a Map whose keys are of type String
and whose values are of supported types:
Boolean, String,
and the wrappers for the primitive number types
Double, Integer, ...java.lang.IllegalArgumentException - If eventName or attributes is null.reportEvent(String, java.util.Map)void reportError(@NonNull
java.lang.String message,
@Nullable
java.lang.Throwable error)
error stacktrace.
If you want to influence the way errors are grouped use
reportError(String, String, Throwable) or
reportError(String, String)message - Short description or name of the error.error - Throwable object for the error. Can be null.java.lang.IllegalArgumentException - If message is null.reportUnhandledException(Throwable)void reportError(@NonNull
java.lang.String identifier,
@Nullable
java.lang.String message)
reportError(String, Throwable)identifier - An identifier used for grouping errors.
Errors that have the same identifiers will belong in one group.
Do not use dynamically formed strings or exception messages as identifiers
to avoid having too many small crash groups.
Cannot be null.message - Short description or name of the error. Can be null.java.lang.IllegalArgumentException - If identifier is null.void reportError(@NonNull
java.lang.String identifier,
@Nullable
java.lang.String message,
@Nullable
java.lang.Throwable error)
reportError(String, Throwable)
error stacktrace will NOT be used for grouping, only identifier.identifier - An identifier used for grouping errors.
Errors that have the same identifiers will belong in one group.
Do not use dynamically formed strings or exception messages as identifiers
to avoid having too many small crash groups.
Cannot be null.message - Short description or name of the error. Can be null.error - Throwable object for the error.
Its stacktrace will not be considered for error grouping. Can be null.java.lang.IllegalArgumentException - If identifier is null.void reportUnhandledException(@NonNull
java.lang.Throwable exception)
Throwable object.exception - Throwable object for the unhandled exception.java.lang.IllegalArgumentException - If exception is null.reportUnhandledException(Throwable)void resumeSession()
Helper method for sessions tracking.
Usually, it should be called intoActivity.onResume().Activity.onResume(),
pauseSession()void pauseSession()
Helper method for sessions tracking.
Usually, it should be called intoActivity.onPause().Activity.onPause(),
resumeSession()void setUserProfileID(@Nullable
java.lang.String profileID)
profileID - The custom user profile ID.void reportUserProfile(@NonNull
UserProfile profile)
profile - The UserProfile object. Contains user profile information.void reportRevenue(@NonNull
Revenue revenue)
revenue - The Revenue object. It contains purchase information.void reportECommerce(@NonNull
ECommerceEvent event)
event - The ECommerceEvent object to be sent.ECommerceEventvoid setStatisticsSending(boolean enabled)
NOTE: Disabling this option doesn't affect data sending from the main apiKey and other reporters.
enabled - true to allow AppMetrica sending statistics, otherwise false.