public final class FlurryAgent
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
FlurryAgent.Builder
Builder Pattern class for FlurryAgent.
|
static class |
FlurryAgent.UserProperties
User Properties class for FlurryAgent.
|
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
VERSION_STRING |
Modifier and Type | Method and Description |
---|---|
static void |
addOrigin(java.lang.String originName,
java.lang.String originVersion)
Add origin attribution.
|
static void |
addOrigin(java.lang.String originName,
java.lang.String originVersion,
java.util.Map<java.lang.String,java.lang.String> originParameters)
Add origin attribution with parameters.
|
static void |
addSessionProperty(java.lang.String name,
java.lang.String value)
This method allows you to associate parameters with an session.
|
static void |
deleteData()
This api allows you to delete data collected by Flurry
|
static void |
endTimedEvent(java.lang.String eventId)
End a timed event.
|
static void |
endTimedEvent(java.lang.String eventId,
java.util.Map<java.lang.String,java.lang.String> parameters)
End a timed event.Only up to 10 unique parameters total can be passed for an event, including those
passed when the event was initiated.
|
static java.util.List<FlurryModule> |
getAddOnModules()
Returns a list of the Flurry add-on modules
|
static int |
getAgentVersion()
Get the version of the Flurry SDK.
|
static Consent |
getFlurryConsent()
Return Flurry consent set by
updateFlurryConsent(Consent) or FlurryAgent.Builder.withConsent(Consent) |
static java.lang.String |
getInstantAppName()
Return instant app name.
|
static java.lang.String |
getReleaseVersion()
Get the release version of the Flurry SDK.
|
static java.lang.String |
getSessionId()
Check to see if there is an active session.
|
static boolean |
isInitialized()
Check to see if FlurryAgent is initialized or not.
|
static boolean |
isSessionActive()
Check to see if there is an active session.
|
static void |
logBreadcrumb(java.lang.String crashBreadcrumb) |
static FlurryEventRecordStatus |
logEvent(FlurryEvent event,
FlurryEvent.Params parameters)
Log a standard event with suggested parameters and user defined parameters.
|
static FlurryEventRecordStatus |
logEvent(java.lang.String eventId)
Log an event.
|
static FlurryEventRecordStatus |
logEvent(java.lang.String eventId,
boolean timed)
Log a timed event.
|
static FlurryEventRecordStatus |
logEvent(java.lang.String eventId,
java.util.Map<java.lang.String,java.lang.String> parameters)
Log an event with parameters.
|
static FlurryEventRecordStatus |
logEvent(java.lang.String eventId,
java.util.Map<java.lang.String,java.lang.String> parameters,
boolean timed)
Log a timed event with parameters.
|
static void |
logPayment(int resultCode,
android.content.Intent data,
java.util.Map<java.lang.String,java.lang.String> parameters)
Log a payment from Google.
|
static FlurryEventRecordStatus |
logPayment(java.lang.String productName,
java.lang.String productId,
int quantity,
double price,
java.lang.String currency,
java.lang.String transactionId,
java.util.Map<java.lang.String,java.lang.String> parameters)
Log a payment.
|
static void |
onEndSession(android.content.Context context)
End a Flurry session for the given Context.
|
static void |
onError(java.lang.String errorId,
java.lang.String message,
java.lang.String errorClass)
Report errors that your app catches.
|
static void |
onError(java.lang.String errorId,
java.lang.String message,
java.lang.String errorClass,
java.util.Map<java.lang.String,java.lang.String> errorParams)
Report errors that your app catches.
|
static void |
onError(java.lang.String errorId,
java.lang.String message,
java.lang.Throwable exception)
Report errors that your app catches.
|
static void |
onError(java.lang.String errorId,
java.lang.String message,
java.lang.Throwable exception,
java.util.Map<java.lang.String,java.lang.String> errorParams)
Report errors that your app catches.
|
static void |
onStartSession(android.content.Context context)
Start or continue a Flurry session for the project on the given Context.
|
static void |
openPrivacyDashboard(FlurryPrivacySession.Request request)
This api opens privacy dashboard in Chrome CustomTab (if its dependency's been included in the gradle and device support it as well),
otherwise will open it in the external browser.
|
static void |
registerListener(FlurryAgentListener listener)
Registers the listener.
|
static void |
setAge(int age)
Sets the age of the user at the time of this session.
|
static void |
setCaptureUncaughtExceptions(boolean captureExceptions)
True to enable or false to disable the ability to catch all uncaught exceptions
and have them reported back to Flurry.
|
static void |
setContinueSessionMillis(long sessionMillis)
Set the timeout for expiring a Flurry session.
|
static void |
setDataSaleOptOut(boolean isOptOut)
This api allows you to set opt-out/opt-in for data sale
|
static void |
setGender(byte gender)
Sets the gender of the user.
|
static void |
setIncludeBackgroundSessionsInMetrics(boolean includeBackgroundSessionsInMetrics)
True if this session should be added to total sessions/DAUs when applicationstate is inactive or background.
|
static void |
setInstantAppName(java.lang.String instantAppName)
Set instant app name if it's an instant app.
|
static void |
setLogEnabled(boolean enableLog)
True to enable or false to disable the internal logging for the Flurry SDK.
|
static void |
setLogLevel(int logLevel)
Set the log level of the internal Flurry SDK logging.
|
static void |
setReportLocation(boolean reportLocation)
Set whether Flurry should record location via GPS.
|
static void |
setSessionOrigin(java.lang.String originName,
java.lang.String deepLink)
This method allows you to specify session origin and deep link for each session.
|
static void |
setSslPinningEnabled(boolean sslPinningEnabled)
True to enable or false to disable SSL Pinning for Flurry Analytics connection.
|
static void |
setUserId(java.lang.String userId)
Sets the Flurry userId for this session.
|
static void |
setVersionName(java.lang.String versionName)
Set the version name of the app.
|
static void |
unregisterListener(FlurryAgentListener listener)
Unregisters the listener.
|
static boolean |
updateFlurryConsent(Consent flurryConsent)
Update Flurry consent.
|
public static boolean isInitialized()
public static int getAgentVersion()
public static java.lang.String getReleaseVersion()
public static java.util.List<FlurryModule> getAddOnModules()
public static void setVersionName(java.lang.String versionName)
versionName
- The version of the app.public static void setReportLocation(boolean reportLocation)
reportLocation
- True to allow Flurry to record location via GPS, false otherwisepublic static void addOrigin(java.lang.String originName, java.lang.String originVersion)
FlurryAgent.addOrigin("An Origin without Params", "Origin Version");
originName
- The name/id of the origin you wish to attribute.originVersion
- The version of the origin you wish to attribute.addOrigin(String, String, Map)
public static void addOrigin(java.lang.String originName, java.lang.String originVersion, java.util.Map<java.lang.String,java.lang.String> originParameters)
// Add an origin with params, where param1=value1 and param2=value2 Map<String, String>
params = new HashMap<String, String>(); params.put("param1", "value1");
params.put("param2", "value2"); FlurryAgent.addOrigin("An Origin with Params", "Origin Version",
params);
originName
- The name/id of the origin you wish to attribute.originVersion
- The version of the origin you wish to attribute.originParameters
- A Map<String, String>
of the parameters which should be submitted with this
origin attribution.addOrigin(String, String)
public static void setInstantAppName(java.lang.String instantAppName)
instantAppName
- The name for your instant apppublic static java.lang.String getInstantAppName()
public static Consent getFlurryConsent()
updateFlurryConsent(Consent)
or FlurryAgent.Builder.withConsent(Consent)
public static boolean updateFlurryConsent(Consent flurryConsent)
FlurryConsent
flurryConsent
- Flurry consentpublic static void onStartSession(android.content.Context context)
// The Activity's onStart method
protected void onStart() { // Start the Flurry session
FlurryAgent.onStartSession(this); }
So long as there is any Context that has called #onStartSession(Context)
but not onEndSession(Context)
, the session will be continued. Also, if a new Context
calls #onStartSession(Context) within 10 seconds (the default session timeout
length) of the last Context calling onEndSession, then the session will be resumed,
instead of a new session being created. Session length, usage frequency, events and
errors will continue to be tracked as part of the same session. This ensures that as a
user transitions from one Activity to another in your application they will not have a
separate session tracked for each Activity, but will have a single session that spans
many activities. #onStartSession should be called from within the onStart method of
the activity in question. The first call to onStartSession will set up the
configuration for all later occurring calls to onStartSession.
There is no need to call this method unless you wish to track another type of Context.
context
- A reference to a android.content.Context object such as an android.app.Activity or an android.app.Service.public static void onEndSession(android.content.Context context)
// The Activity's onStop method
protected void onStop() {
FlurryAgent.onEndSession(this);
}
Pop a session off the stack for this Activity. If no sessions remain after the
call to onEndSession(Context) and no new calls to onStartSession(Context)
are made within the timeout specified (which defaults to 10 seconds) then the session
will truly end. Calls to #onEndSession should be made from the Activity's onStop
method in order to assure a complete analytics lifecycle for the Activity.
There is no need to call this method unless you wish to track another
type of Context.context
- A reference to a android.content.Context object such as an android.app.Activity or an android.app.Service.public static boolean isSessionActive()
onStartSession(Context)
in the Android onStart method with a call to onEndSession(Context)
in the Android onEnd
method. At any point, you can call this method to find if there is an active running session.public static java.lang.String getSessionId()
onStartSession(Context)
in the Android onStart
method with a call to onEndSession(Context)
in the Android onEnd method. At any point,
you can call this method to get the active session id.public static FlurryEventRecordStatus logEvent(java.lang.String eventId)
FlurryAgent.logEvent("An Event without Params");
eventId
- The name/id of the event.logEvent(String, Map)
,
logEvent(String, Map, boolean)
public static FlurryEventRecordStatus logEvent(java.lang.String eventId, java.util.Map<java.lang.String,java.lang.String> parameters)
// Log an event with params, where param1=value1 and param2=value2 Map<String, String>
params = new HashMap<String, String>(); params.put("param1", "value1");
params.put("param2", "value2"); FlurryAgent.logEvent("Event with params", params);
Log an event with parameters with the Flurry service. The event is identified by the
eventId, which is a String. A Map<String, String>
of parameters can be passed in where
the key is the parameter name, and the value is the value.eventId
- The name/id of the event.parameters
- A Map<String, String>
of the parameters which should be submitted
with this event.logEvent(String)
,
logEvent(String, Map, boolean)
public static FlurryEventRecordStatus logEvent(java.lang.String eventId, boolean timed)
eventId
- The name/id of the event.timed
- True if the event should be timed, false otherwise.FlurryEventRecordStatus
endTimedEvent(String)
,
logEvent(String)
public static FlurryEventRecordStatus logEvent(java.lang.String eventId, java.util.Map<java.lang.String,java.lang.String> parameters, boolean timed)
eventId
- The name/id of the event.parameters
- A Map<String, String>
of parameters to log with this event.timed
- True if this event is timed, false otherwise.logEvent(String, Map)
public static FlurryEventRecordStatus logEvent(FlurryEvent event, FlurryEvent.Params parameters)
// Log a standard event with suggested params and user defined params, where parameters = FlurryEvent.Params
params = new FlurryEvent.Params();
params.put(param1, "value1"); params.put(param2, "value2");
FlurryAgent.logEvent(flurryEvent, params);
Log a standard event with suggested parameters and user defined parameters with the Flurry service.
The event is identified by the event, which is a FlurryEvent Enum.
A FlurryEvent.Params
of parameters can be passed in where
the key is the event parameter enum or user defined string, and the value is the value.event
- The enum type of the event.parameters
- A Map<FlurryEvent.Param, String>
of the suggested parameters which should be submitted
with this event.public static void logPayment(int resultCode, android.content.Intent data, java.util.Map<java.lang.String,java.lang.String> parameters)
resultCode
- The resultCode given in the call to onActivityResult() from Google Play.data
- The Intent given in the call to onActivityResult() from Google Play.parameters
- A Map<String, String>
of the parameters which should be submitted
with this event.logEvent(String, Map)
public static FlurryEventRecordStatus logPayment(java.lang.String productName, java.lang.String productId, int quantity, double price, java.lang.String currency, java.lang.String transactionId, java.util.Map<java.lang.String,java.lang.String> parameters)
productName
- The name of the product purchased.productId
- The id of the product purchased.quantity
- The number of products purchased.price
- The price of the the products purchased in the given currency.currency
- The currency for the price argument.transactionId
- A unique identifier for the transaction used to make the purchase.parameters
- A Map<String, String>
of the parameters which should be submitted
with this event.logEvent(String, Map)
public static void endTimedEvent(java.lang.String eventId)
eventId
- The name/id of the event to end the timer on.for more details.
public static void endTimedEvent(java.lang.String eventId, java.util.Map<java.lang.String,java.lang.String> parameters)
eventId
- The name/id of the event to end the timer on.parameters
- A Map<String, String>
of parameters to log with this event.logEvent(String, Map)
public static void onError(java.lang.String errorId, java.lang.String message, java.lang.String errorClass)
errorId
- Unique ID for reported error.message
- Message for the error reported.errorClass
- Class in which the error is reported.public static void onError(java.lang.String errorId, java.lang.String message, java.lang.String errorClass, java.util.Map<java.lang.String,java.lang.String> errorParams)
errorId
- Unique ID for reported error.message
- Message for the error reported.errorClass
- Class in which the error is reported.errorParams
- Map of params to be logged with this errorpublic static void onError(java.lang.String errorId, java.lang.String message, java.lang.Throwable exception)
errorId
- Unique ID for reported error.message
- Message for the error reported.exception
- Thrown error to be reported.public static void onError(java.lang.String errorId, java.lang.String message, java.lang.Throwable exception, java.util.Map<java.lang.String,java.lang.String> errorParams)
errorId
- Unique ID for reported error.message
- Message for the error reported.exception
- Thrown error to be reported.errorParams
- Map of params to be logged with this errorpublic static void logBreadcrumb(java.lang.String crashBreadcrumb)
public static void setAge(int age)
age
- valid values are 0-110public static void setGender(byte gender)
gender
- One of the values among Constants.MALE
,Constants.FEMALE
and Constants.UNKNOWN
as defined in Constants.public static void setUserId(java.lang.String userId)
userId
- Unique user id for session.public static void setSessionOrigin(java.lang.String originName, java.lang.String deepLink)
originName
- Name of the origin.deepLink
- Url of the deep Link.public static void addSessionProperty(java.lang.String name, java.lang.String value)
name
- Property name.value
- Property value.public static void openPrivacyDashboard(FlurryPrivacySession.Request request)
FlurryPrivacySession.Callback
in request class which notify you when opening dashboard failed or succeed.
Note: Since this api is asynchronous, would recommend you to show spinner while we are loading Privacy Dashboard. you can dismiss it in callback.request
- object to request privacy dashboard uripublic static void setDataSaleOptOut(boolean isOptOut)
isOptOut
- true to opt-out data sale, false to opt-inpublic static void deleteData()
public static void setCaptureUncaughtExceptions(boolean captureExceptions)
captureExceptions
- true to enable, false to disable.public static void setContinueSessionMillis(long sessionMillis)
sessionMillis
- The time in milliseconds to set the session timeout to. Minimum value of 5000.public static void setIncludeBackgroundSessionsInMetrics(boolean includeBackgroundSessionsInMetrics)
includeBackgroundSessionsInMetrics
- if background and inactive session should be counted toward daupublic static void registerListener(FlurryAgentListener listener)
listener
- Your implementation of the Flurry agent listener.public static void unregisterListener(FlurryAgentListener listener)
listener
- Your implementation of the Flurry agent listener.public static void setLogEnabled(boolean enableLog)
enableLog
- true to enable logging, false to disable it.public static void setLogLevel(int logLevel)
logLevel
- The level to set it to.public static void setSslPinningEnabled(boolean sslPinningEnabled)
sslPinningEnabled
- true to enable SSL Pinning for Flurry Analytics connection, false to disable it.Copyright © 2009-2022, Flurry, Inc. All Rights Reserved. Flurry Publisher Support Site.