Interface IReporter
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.
Method Summary
Modifier and Type | Method and Description |
---|---|
IPluginReporter | getPluginExtension()
Creates an
IPluginReporter that can send plugin events to this reporter. |
void | pauseSession()
Helper method for sessions tracking.
|
void | reportAdRevenue(AdRevenue adRevenue)
Sends information about ad revenue.
|
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.
|
Method Detail
sendEventsBuffer
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.
reportEvent
void reportEvent(@NonNull java.lang.String eventName)
- Parameters:
eventName
- Event name. In theeventName
parameter, pass a short name or description of the event.- Throws:
java.lang.IllegalArgumentException
- IfeventName
is null.- See Also:
reportEvent(String)
reportEvent
void reportEvent(@NonNull java.lang.String eventName, @Nullable java.lang.String jsonValue)
- Parameters:
eventName
- Event name. In theeventName
parameter, pass a short name or description of the event.jsonValue
- Event value. In theeventValue
parameter, pass aJSONObject
represented as aString
object or pass aString
object represented in theJava 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" } ] }
- Throws:
java.lang.IllegalArgumentException
- IfeventName
orjsonValue
is null.- See Also:
reportEvent(String, String)
,JSONObject.toString()
reportEvent
void reportEvent(@NonNull java.lang.String eventName, @Nullable java.util.Map<java.lang.String,java.lang.Object> attributes)
- Parameters:
eventName
- Event name. In theeventName
parameter, pass a short name or description of the event.attributes
- Event value. In theattributes
parameter, pass aMap
whose keys are of typeString
and whose values are of supported types:Boolean
,String
, and the wrappers for the primitive number typesDouble
,Integer
, ...- Throws:
java.lang.IllegalArgumentException
- IfeventName
orattributes
is null.- See Also:
reportEvent(String, java.util.Map)
reportError
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)
- Parameters:
message
- Short description or name of the error.error
-Throwable
object for the error. Can be null.- Throws:
java.lang.IllegalArgumentException
- Ifmessage
is null.- See Also:
reportUnhandledException(Throwable)
reportError
void reportError(@NonNull java.lang.String identifier, @Nullable java.lang.String message)
reportError(String, Throwable)
- Parameters:
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.- Throws:
java.lang.IllegalArgumentException
- Ifidentifier
is null.
reportError
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
.- Parameters:
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.- Throws:
java.lang.IllegalArgumentException
- Ifidentifier
is null.
reportUnhandledException
void reportUnhandledException(@NonNull java.lang.Throwable exception)
Throwable
object.- Parameters:
exception
-Throwable
object for the unhandled exception.- Throws:
java.lang.IllegalArgumentException
- Ifexception
is null.- See Also:
reportUnhandledException(Throwable)
resumeSession
void resumeSession()
Helper method for sessions tracking.
Usually, it should be called intoActivity.onResume()
.- See Also:
Activity.onResume()
,pauseSession()
pauseSession
void pauseSession()
Helper method for sessions tracking.
Usually, it should be called intoActivity.onPause()
.- See Also:
Activity.onPause()
,resumeSession()
setUserProfileID
void setUserProfileID(@Nullable java.lang.String profileID)
- Parameters:
profileID
- The custom user profile ID.
reportUserProfile
void reportUserProfile(@NonNull UserProfile profile)
- Parameters:
profile
- TheUserProfile
object. Contains user profile information.
reportECommerce
void reportECommerce(@NonNull ECommerceEvent event)
- Parameters:
event
- TheECommerceEvent
object to be sent.- See Also:
ECommerceEvent
setStatisticsSending
void setStatisticsSending(boolean enabled)
NOTE: Disabling this option doesn't affect data sending from the main apiKey and other reporters.
- Parameters:
enabled
-true
to allow AppMetrica sending statistics, otherwisefalse
.
getPluginExtension
@NonNull IPluginReporter getPluginExtension()
Creates an IPluginReporter
that can send plugin events to this reporter.
IPluginReporter
instance is created. You can either query it each time you need it, or save the reference by yourself.- Returns:
- plugin extension instance for this reporter