Class UsageBroker
-
- All Implemented Interfaces:
public class UsageBroker
Collect, store and upload client usage events in a flexible way and send it to an analytics server.
-
-
Field Summary
Fields Modifier and Type Field Description public final static String
AUTO_USAGE_STORE
public final static String
CONSENT_KEY
public static boolean
retainLastUnattributedSession
public static boolean
dataCollectionEnabled
-
Method Summary
Modifier and Type Method Description static boolean
getRetainLastUnattributedSession()
Getter for retainLastUnattributedSession retrainLastUnattributedSession controls whether or not to move the last unattributed session to the attributed store static boolean
getDataCollectionEnabled()
Getter for dataCollectionEnabled flag If this flag is set to false usage collection will be disabled static void
setDataCollectionEnabled(boolean dataCollectionEnabled)
Sets the dataCollectionEnabled flag If this flag is set to false usage collection will be disabled static void
start(@NonNull() Application app, @NonNull() Context context, @NonNull() String applicationVersion)
Starts the UsageBroker static void
stop()
Stops the UsageBroker without deleting the current usage store. static boolean
isInitialized()
Check if UsageBroker has been initialized static boolean
isStarted()
Is the UsageBroker started and capturing event data static int
getDaysToWaitBetweenUpload()
Getter for DaysToWaitBetweenUpload Upload can be called repeatedly ( in onResume for example ), but the upload will only occur after the expressed number of days static void
setDaysToWaitBetweenUpload(int daysToWait)
Setter for DaysToWaitBetweenUpload Upload can be called repeatedly ( in onResume for example ), but the upload will only occur after the expressed number of days, if it is greater than zero static void
upload(@NonNull() Context context, @NonNull() SettingsParameters settingsParameters, boolean force, boolean sendUnattributed)
Upload event data to the server static void
upload(boolean force, boolean sendUnattributed, @NonNull() Context context)
Upload event data to the server. static void
upload(@NonNull() Context context, @NonNull() SettingsParameters settingsParameters, boolean force)
Upload event data to the server static void
upload(@NonNull() Context context, boolean force)
Upload event data to the server. static void
deleteStore(@NonNull() Context context)
Delete the event storage container and all associated data static void
configure(@NonNull() Context context)
Restarts the UsageBroker static void
configure(@NonNull() Context context, @NonNull() UUID uuid)
Restarts the UsageBroker static void
configure(@NonNull() Context context, @NonNull() UUID uuid, @NonNull() Array<byte> encryptionKey)
Restarts the UsageBroker static void
configure(@NonNull() Context context, @NonNull() UUID uuid, boolean retainLastUnattributedSession)
Restarts the UsageBroker static void
configure(@NonNull() Context context, boolean retainLastUnattributedSession)
Restarts the UsageBroker static void
configure(@NonNull() Context context, @NonNull() UUID uuid, @NonNull() Array<byte> encryptionKey, boolean retainLastUnattributedSession)
Restarts the UsageBroker static void
consentForUser(@NonNull() Context context, @NonNull() UUID userId)
Deny consent for the specified user. static void
consentForUser(@NonNull() Context context, @NonNull() UUID userId, boolean consent)
Record consent value for the specified user. static boolean
hasConsentForUser(@NonNull() Context context, @NonNull() UUID uuid)
Obtain consent value for a specified value. -
-
Method Detail
-
getRetainLastUnattributedSession
static boolean getRetainLastUnattributedSession()
Getter for retainLastUnattributedSession retrainLastUnattributedSession controls whether or not to move the last unattributed session to the attributed store
- Returns:
retainLastUnattributedSession
-
getDataCollectionEnabled
static boolean getDataCollectionEnabled()
Getter for dataCollectionEnabled flag If this flag is set to false usage collection will be disabled
- Returns:
dataCollectionEnabled
-
setDataCollectionEnabled
static void setDataCollectionEnabled(boolean dataCollectionEnabled)
Sets the dataCollectionEnabled flag If this flag is set to false usage collection will be disabled
-
start
static void start(@NonNull() Application app, @NonNull() Context context, @NonNull() String applicationVersion)
Starts the UsageBroker
- Parameters:
app
- Application referencecontext
- Android contextapplicationVersion
- The version of the application being run, which should be the same value used in com.sap.cloud.mobile.foundation.common.SettingsParameters
-
stop
static void stop()
Stops the UsageBroker without deleting the current usage store.
-
isInitialized
static boolean isInitialized()
Check if UsageBroker has been initialized
- Returns:
true if it is initialized
-
isStarted
static boolean isStarted()
Is the UsageBroker started and capturing event data
- Returns:
true if it's started
-
getDaysToWaitBetweenUpload
static int getDaysToWaitBetweenUpload()
Getter for DaysToWaitBetweenUpload Upload can be called repeatedly ( in onResume for example ), but the upload will only occur after the expressed number of days
- Returns:
number of days.
-
setDaysToWaitBetweenUpload
static void setDaysToWaitBetweenUpload(int daysToWait)
Setter for DaysToWaitBetweenUpload Upload can be called repeatedly ( in onResume for example ), but the upload will only occur after the expressed number of days, if it is greater than zero
- Parameters:
daysToWait
- Zero means no delay, 1 or higher is delay in days before next upload
-
upload
@Deprecated() static void upload(@NonNull() Context context, @NonNull() SettingsParameters settingsParameters, boolean force, boolean sendUnattributed)
Upload event data to the server
- Parameters:
context
- An android Context providing access to the resourcesforce
- override any potential optimizations, use "true" to upload now.sendUnattributed
- whether the upload should upload the unattributed store if an attributed store is currently open.
-
upload
@Deprecated() static void upload(boolean force, boolean sendUnattributed, @NonNull() Context context)
Upload event data to the server. The SettingsParameters will be retrieved from SettingsProvider, so make sure it has a parameter set.
- Parameters:
force
- override any potential optimizations, use "true" to upload now.sendUnattributed
- whether the upload should upload the unattributed store if an attributed store is currently open.context
- An android Context providing access to the resources Deprecated since 4.
-
upload
@Deprecated() static void upload(@NonNull() Context context, @NonNull() SettingsParameters settingsParameters, boolean force)
Upload event data to the server
- Parameters:
context
- An android Context providing access to the resources Deprecated since 4.force
- override any potential optimizations, use "true" to upload now.
-
upload
@Deprecated() static void upload(@NonNull() Context context, boolean force)
Upload event data to the server. The SettingsParameters will be retrieved from SettingsProvider, so make sure it has a parameter set.
- Parameters:
context
- An android Context providing access to the resources Deprecated since 4.force
- override any potential optimizations, use "true" to upload now.
-
deleteStore
static void deleteStore(@NonNull() Context context)
Delete the event storage container and all associated data
-
configure
static void configure(@NonNull() Context context)
Restarts the UsageBroker
- Parameters:
context
- An android Context providing access to resources
-
configure
static void configure(@NonNull() Context context, @NonNull() UUID uuid)
Restarts the UsageBroker
- Parameters:
context
- An android Context providing access to resourcesuuid
- a unique identifier which identifies a given user's store
-
configure
static void configure(@NonNull() Context context, @NonNull() UUID uuid, @NonNull() Array<byte> encryptionKey)
Restarts the UsageBroker
- Parameters:
context
- An android Context providing access to resourcesuuid
- a unique identifier which identifies a given user's storeencryptionKey
- encryption key used to secure the usage store (MUST remain constant after initial creation)
-
configure
static void configure(@NonNull() Context context, @NonNull() UUID uuid, boolean retainLastUnattributedSession)
Restarts the UsageBroker
- Parameters:
context
- An android Context providing access to resourcesuuid
- a unique identifier which identifies a given user's storeretainLastUnattributedSession
- if true, temporarily save last unattributed session in memory to inject into attributed store, else leave unattributed data in place.
-
configure
static void configure(@NonNull() Context context, boolean retainLastUnattributedSession)
Restarts the UsageBroker
- Parameters:
context
- An android Context providing access to resourcesretainLastUnattributedSession
- if true, temporarily save last unattributed session in memory to inject into attributed store, else leave unattributed data in place.
-
configure
static void configure(@NonNull() Context context, @NonNull() UUID uuid, @NonNull() Array<byte> encryptionKey, boolean retainLastUnattributedSession)
Restarts the UsageBroker
- Parameters:
context
- An android Context providing access to resourcesuuid
- a unique identifier which identifies a given user's storeencryptionKey
- encryption key used to secure the usage store (MUST remain constant after initial creation)retainLastUnattributedSession
- if true, temporarily save last unattributed session in memory to inject into attributed store, else leave unattributed data in place.
-
consentForUser
static void consentForUser(@NonNull() Context context, @NonNull() UUID userId)
Deny consent for the specified user.
- Parameters:
context
- context to access SharedPreferencesuserId
- specified user ID
-
consentForUser
static void consentForUser(@NonNull() Context context, @NonNull() UUID userId, boolean consent)
Record consent value for the specified user.
- Parameters:
context
- context to access SharedPreferencesuserId
- specified user IDconsent
- value to record for the specified user
-
hasConsentForUser
static boolean hasConsentForUser(@NonNull() Context context, @NonNull() UUID uuid)
Obtain consent value for a specified value. Defaults to true for new users
- Parameters:
context
- android context to access SharedPreferencesuuid
- User Id whom to query consent for- Returns:
The associated consent value
-
-
-
-