LivepersonMonitoring.java class
Note: If you want to use the Monitoring API, you must initialize the SDK with MonitoringParams. Once initialization is completed (onInitSucceed
), you can call LivePerson methods.
getEngagement
Use to get an engagement for a consumer in an appInstallationId context. When calculating eligibility, the decision is based on the SDEs and other parameters based on the messaging campaign concept.
As an optional parameter, you can pass SDE Data which includes Entry Points and Engagement Attributes for routing the conversation.
public static void getEngagement(Context context, @Nullable List<LPMonitoringIdentity> identities, MonitoringParams monitoringParams, EngagementCallback callback)
Parameter | Description | Required |
---|---|---|
context | A context from the host app | Yes |
identities | A list of LPMonitoringIdentity objects with the consumer identities | No |
monitoringParams | An optional object with optional pageId, Entry Points array and Engagement Attributes | No |
callback | A callback of type EngagementCallback. This response include SessionId, VisitorId and a list of EngagementDetails objects | Yes |
Please refer to the Interface and Class Definitions section for parameter classes.
When trying to fetch an Authenticated Engagement, the LPMonitoringIdentity parameter containing the ConsumerId is required.
sendSde
Use to report on engagement attributes (SDEs) for a consumer in an appInstallationId context including show and accept impressions.
public static void sendSde(Context context, @NonNull List<LPMonitoringIdentity> identities, @NonNull MonitoringParams monitoringParams, SdeCallback callback)
Parameter | Description | Required |
---|---|---|
context | A context from the host app | Yes |
identities | A list of LPMonitoringIdentity objects with the consumer identities | Yes |
monitoringParams | An mandatory MonitoringParams with mandatory Engagement Attributes and optional PageId and entry points array | Yes |
callback | A callback of type SdeCallback. This response includes SessionId, VisitorId and PageId for future use | Yes |
Monitoring API Related Classes
EngagementCallback
public interface EngagementCallback {
void onSuccess(LPEngagementResponse engagementResponse);
void onError(MonitoringErrorType errorType, Exception e);
}
EngagementDetails
public final class EngagementDetails {
@NotNull
private String campaignId;
@NotNull
private String engagementId;
@NotNull
private String engagementRevision;
@NotNull
private String contextId;
@Nullable
private String conversationId;
@Nullable
private String status;
}
LPEngagementResponse
public final class LPEngagementResponse {
@NotNull
private String pageId;
@Nullable
private String sessionId;
@Nullable
private String visitorId;
@Nullable
private List<EngagementDetails> engagementDetailsList;
}
LPMonitoringIdentity (Kotlin syntax)
A class that contains data on the consumer identity.
consumerId: unique and non-guessable identifier of the consumer (email and phone number are not good candidates since they can be guessed by an attacker, and might be recycled and move between consumers).
issuer: Issuer, who identified the consumer — usually the brand.
class LPMonitoringIdentity(val consumerId: String? = "", val issuer: String? = ""){
}
LPSdeResponse
public class LPSdeResponse {
@NotNull
private String pageId;
@Nullable
private final String sessionId;
@Nullable
private final String visitorId;
}
MonitoringErrorType
enum class MonitoringErrorType {
NOT_INITIALIZED,
INITIALIZATION_ERROR,
LOGOUT_ERROR,
PARAMETER_MISSING,
NO_NETWORK,
REQUEST_ERROR,
CSDS_ERROR
}
MonitoringInitParams
public class MonitoringInitParams {
private String mAppInstallId;
}
MonitoringParams
public class MonitoringParams {
private String pageId;
private JSONArray entryPoints;
private JSONArray engagementAttributes;
}
SdeCallback
public interface SdeCallback {
void onSuccess(LPSdeResponse sdeResponse);
void onError(MonitoringErrorType errorType, Exception e);
}