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.

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
    • Constructor Summary

      Constructors 
      Constructor Description
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
    • 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.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

    • Method Detail

      • getRetainLastUnattributedSession

         static boolean getRetainLastUnattributedSession()

        Getter for retainLastUnattributedSession retrainLastUnattributedSession controls whether or not to move the last unattributed session to the attributed store

      • getDataCollectionEnabled

         static boolean getDataCollectionEnabled()

        Getter for dataCollectionEnabled flag If this flag is set to false usage collection will be disabled

      • 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 reference
        context - Android context
        applicationVersion - 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

      • isStarted

         static boolean isStarted()

        Is the UsageBroker started and capturing event data

      • 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

      • 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 resources
        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.
      • 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 resources
        uuid - 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 resources
        uuid - a unique identifier which identifies a given user's store
        encryptionKey - 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 resources
        uuid - a unique identifier which identifies a given user's store
        retainLastUnattributedSession - 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 resources
        retainLastUnattributedSession - 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 resources
        uuid - a unique identifier which identifies a given user's store
        encryptionKey - 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 SharedPreferences
        userId - 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 SharedPreferences
        userId - specified user ID
        consent - 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 SharedPreferences
        uuid - User Id whom to query consent for