Package 

Class Composer


  • 
    public final class Composer
    
                        

    Main entry point for the Piano Composer SDK.

    The Composer class is the main entry point for the Piano Composer SDK. It provides methods to interact with the Piano Composer API and handle the display of templates. It allows setting user tokens, tracking events, and retrieving experiences from the server.

    • Method Detail

      • browserIdProvider

         final <ERROR CLASS> browserIdProvider(Function0<String> browserIdProvider)

        Sets the browser ID provider for the Composer.

        This function allows setting a custom browser ID provider, which provides the browser ID to be sent with the experience request. The provider should return a string containing the browser ID or null if the browser ID is not available.

        Parameters:
        browserIdProvider - The custom browser ID provider function.
      • userToken

         final <ERROR CLASS> userToken(String userToken)

        Sets the user token to be sent with each experience request.

        This function sets the user token, which will be included in each experience request to the server. The user token is used for personalization purposes.

        Parameters:
        userToken - The user token to be set.
      • gaClientId

         final <ERROR CLASS> gaClientId(String gaClientId)

        Sets the Google Analytics client ID.

        This function sets the Google Analytics client ID to be included in the experience request. The client ID is used for tracking user interactions and events related to the Composer.

        Parameters:
        gaClientId - The Google Analytics client ID to be set.
      • getExperience

         final Unit getExperience(ExperienceRequest request, Collection<EventTypeListener<out EventType>> eventTypeListeners, ExceptionListener exceptionListener)

        Gets an experience from the server.

        This function is used to retrieve an experience from the server based on the provided request. It also takes a collection of eventTypeListeners to handle events received from the server and an exceptionListener to handle any exceptions that may occur during the request.

        Parameters:
        request - The prepared ExperienceRequest to be sent to the server.
        eventTypeListeners - Collection of event listeners for handling received events separately.
        exceptionListener - Listener for handling exceptions that may occur during the request.
      • getExperience

         final Unit getExperience(ExperienceRequest request, Function1<List<Event<EventType>>, Unit> eventsListener, ExceptionListener exceptionListener)

        Gets an experience from server

        This function is used to retrieve an experience from the server based on the provided request. It also takes a eventsListener to handle all events received from the server as one list and an exceptionListener to handle any exceptions that may occur during the request.

        Parameters:
        request - The prepared ExperienceRequest to be sent to the server.
        eventsListener - Listener for handling received list of events.
        exceptionListener - Listener for handling exceptions that may occur during the request.
      • trackExternalEvent

        @Deprecated(message = Renamed due to introducing other external events, replaceWith = @ReplaceWith(imports = {}, expression = trackCloseEvent(trackingId))) final Unit trackExternalEvent(String trackingId)

        Tracks an external event by ID.

        Parameters:
        trackingId - The tracking ID of the external event.
      • trackCloseEvent

         final Unit trackCloseEvent(String trackingId)

        Tracks a close event by ID.

        Parameters:
        trackingId - The tracking ID of the close event.
      • trackRecommendationsDisplay

         final Unit trackRecommendationsDisplay(String trackingId)

        Tracks the display of recommendations by ID.

        Parameters:
        trackingId - The tracking ID of the recommendations display event.
      • trackRecommendationsClick

         final Unit trackRecommendationsClick(String trackingId, String url)

        Tracks a click on a recommendation event by ID.

        Parameters:
        trackingId - The tracking ID of the recommendation click event.
        url - The URL of the clicked recommendation.
      • trackCustomFormImpression

         final Unit trackCustomFormImpression(String customFormName, String trackingId)

        Tracks a custom form impression by name.

        Parameters:
        customFormName - The name of the custom form.
        trackingId - The tracking ID of the custom form impression.
      • trackCustomFormSubmission

         final Unit trackCustomFormSubmission(String customFormName, String trackingId)

        Tracks a custom form submission by name.

        Parameters:
        customFormName - The name of the custom form.
        trackingId - The tracking ID of the custom form submission.
      • clearStoredData

         final Unit clearStoredData()

        Clears stored data, like cookies and visit data.