Interface IReporter
IReporter
can send events to an alternative api key, differ from
api key, passed to AppMetrica.activate(android.content.Context, AppMetricaConfig)
IReporter
, can be obtained via
AppMetrica.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 TypeMethodDescriptionvoid
Clears app environment and removes it from storage.Creates anIPluginReporter
that can send plugin events to this reporter.void
Helper method for sessions tracking.void
putAppEnvironmentValue
(String key, String value) Sets key - value pair to be used as additional information, associated with your application runtime's environment.void
reportAdRevenue
(AdRevenue adRevenue) Sends information about ad revenue.void
reportAnr
(Map<Thread, StackTraceElement[]> allThreads) Sends an ANR event (the application is not responding) manually.void
reportECommerce
(ECommerceEvent event) Sends e-commerce event.void
reportError
(String identifier, String message) Sends an error.void
reportError
(String identifier, String message, Throwable error) Sends an error.void
reportError
(String message, Throwable error) Sends an error.void
reportEvent
(String eventName) Sends report by event name.void
reportEvent
(String eventName, String jsonValue) Sends report by event name and event value.void
reportEvent
(String eventName, Map<String, Object> attributes) Sends report by dictionary.void
reportRevenue
(Revenue revenue) Sends information about the purchase.void
reportUnhandledException
(Throwable exception) Sends unhandled exception byThrowable
object.void
reportUserProfile
(UserProfile profile) Sends information about the user profile.void
Helper method for sessions tracking.void
Initiates forced sending of all stored events from the buffer.void
setDataSendingEnabled
(boolean enabled) Enables/disables data sending to the AppMetrica server.void
setUserProfileID
(String profileID) Sets the ID of the user profile.
-
Method Details
-
sendEventsBuffer
void sendEventsBuffer()Initiates forced sending of all stored events from the buffer.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
Sends report by event name.- Parameters:
eventName
- Event name. In theeventName
parameter, pass a short name or description of the event.- Throws:
IllegalArgumentException
- IfeventName
is null.- See Also:
-
reportEvent
Sends report by event name and event value.- 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:
IllegalArgumentException
- IfeventName
orjsonValue
is null.- See Also:
-
reportEvent(String, String)
JSONObject.toString()
-
reportEvent
Sends report by dictionary.- 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:
IllegalArgumentException
- IfeventName
orattributes
is null.- See Also:
-
reportError
Sends an error. Use this method to report un unexpected situation. If you use this method errors will be grouped byerror
stacktrace. If you want to influence the way errors are grouped usereportError(String, String, Throwable)
orreportError(String, String)
- Parameters:
message
- Short description or name of the error.error
-Throwable
object for the error. Can be null.- Throws:
IllegalArgumentException
- Ifmessage
is null.- See Also:
-
reportError
Sends an error. Use this method to report un unexpected situation. This method should be used if you want to customize error grouping. If not usereportError(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:
IllegalArgumentException
- Ifidentifier
is null.
-
reportError
Sends an error. Use this method to report un unexpected situation. This method should be used if you want to customize error grouping. If not usereportError(String, Throwable)
error
stacktrace will NOT be used for grouping, onlyidentifier
.- 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:
IllegalArgumentException
- Ifidentifier
is null.
-
reportUnhandledException
Sends unhandled exception byThrowable
object.- Parameters:
exception
-Throwable
object for the unhandled exception.- Throws:
IllegalArgumentException
- Ifexception
is null.- See Also:
-
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
Sets the ID of the user profile. NOTE: The string value can contain up to 200 characters.- Parameters:
profileID
- The custom user profile ID.
-
reportUserProfile
Sends information about the user profile.- Parameters:
profile
- TheUserProfile
object. Contains user profile information.
-
reportRevenue
Sends information about the purchase.- Parameters:
revenue
- TheRevenue
object. It contains purchase information.
-
reportECommerce
Sends e-commerce event.- Parameters:
event
- TheECommerceEvent
object to be sent.- See Also:
-
setDataSendingEnabled
void setDataSendingEnabled(boolean enabled) Enables/disables data sending to the AppMetrica server. By default, the sending is enabled.NOTE: Disabling this option doesn't affect data sending from the main apiKey and other reporters.
- Parameters:
enabled
-true
to allow AppMetrica sending data, otherwisefalse
.
-
getPluginExtension
Creates an
For every reporter only oneIPluginReporter
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
-
reportAdRevenue
Sends information about ad revenue.- Parameters:
adRevenue
- Object containing the information about ad revenue.- See Also:
-
putAppEnvironmentValue
Sets key - value pair to be used as additional information, associated with your application runtime's environment. This environment is unique for every unique APIKey and shared between processes. Application's environment persists to storage and retained between application launches. To reset environment useAppMetrica.clearAppEnvironment()
If called before metrica initialization, environment will be added right after metrica initialize
WARNING: Application's environment is a global permanent state and can't be changed too often. For frequently changed parameters use extended reportMessage methods.
- Parameters:
key
- the environment key.value
- the environment value. To remove pair from environment passnull
value.- See Also:
-
clearAppEnvironment
void clearAppEnvironment()Clears app environment and removes it from storage.If called before metrica initialization, app environment will be cleared right after init
-
reportAnr
Sends an ANR event (the application is not responding) manually.- Parameters:
allThreads
- A snapshot of all streams with stack traces. Can be received by callingThread.getAllStackTraces()
.
-