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.

    • 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

        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

      • 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 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
        Returns:

        The associated consent value