-
public final class ComposerMain entry point for the Piano Composer SDK.
The
Composerclass 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.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public final classComposer.EndpointRepresents the endpoints for the Composer SDK.
The
Endpointclass represents the various predefined endpoints for the Composer SDK. It provides endpoints for different regions, such as sandbox, production, Australia, Asia/Pacific, and Europe.public classComposer.Companion
-
Field Summary
Fields Modifier and Type Field Description private final StringaccessTokenprivate final PianoConsentspianoConsents
-
Method Summary
Modifier and Type Method Description final StringgetAccessToken()final PianoConsentsgetPianoConsents()final <ERROR CLASS>addExperienceInterceptor(ExperienceInterceptor interceptor)Adds an experience interceptor to the Composer. final <ERROR CLASS>browserIdProvider(Function0<String> browserIdProvider)Sets the browser ID provider for the Composer. final <ERROR CLASS>userToken(String userToken)Sets the user token to be sent with each experience request. final <ERROR CLASS>gaClientId(String gaClientId)Sets the Google Analytics client ID. final UnitgetExperience(ExperienceRequest request, Collection<EventTypeListener<out EventType>> eventTypeListeners, ExceptionListener exceptionListener)Gets an experience from the server. final UnitgetExperience(ExperienceRequest request, Function1<List<Event<EventType>>, Unit> eventsListener, ExceptionListener exceptionListener)Gets an experience from serverThis function is used to retrieve an experience from the server based on the provided request. final UnittrackExternalEvent(String trackingId)Tracks an external event by ID. final UnittrackCloseEvent(String trackingId)Tracks a close event by ID. final UnittrackRecommendationsDisplay(String trackingId)Tracks the display of recommendations by ID. final UnittrackRecommendationsClick(String trackingId, String url)Tracks a click on a recommendation event by ID. final UnittrackCustomFormImpression(String customFormName, String trackingId)Tracks a custom form impression by name. final UnittrackCustomFormSubmission(String customFormName, String trackingId)Tracks a custom form submission by name. final UnitclearStoredData()Clears stored data, like cookies and visit data. -
-
Method Detail
-
getAccessToken
final String getAccessToken()
-
getPianoConsents
final PianoConsents getPianoConsents()
-
addExperienceInterceptor
final <ERROR CLASS> addExperienceInterceptor(ExperienceInterceptor interceptor)
Adds an experience interceptor to the Composer.
This function adds a custom ExperienceInterceptor to the list of interceptors. Interceptors can verify the experience request before it is sent to the server and handle the response.
- Parameters:
interceptor- The custom ExperienceInterceptor to be added.
-
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.
-
-
-
-