File

src/rpiWebClient.ts

Description

RpiWebClient is a Javascript library that encapsulates RedPoint's Realtime capabilities for web-based consumption

Index

Properties
Methods

Constructor

Public constructor()

Constructor for RpiWebClient.

Properties

Public config
Type : RpiWebClientConfig
Default value : {}

The current RpiWebClient configuration parameters.

Public visitor
Type : VisitorCookie
Default value : { profile: { VisitorID: "", IsMasterKey: false, HasAlternativeKey: false, Keys: [] }, geolocationExpiry: 0 }

The Realtime visitor profile for the current web visitor.

Methods

Public flushRealtimeParameters
flushRealtimeParameters(callback?: (data?: string) => void)

Flushes queued visitor parameters to the Realtime visitor cache.

Parameters :
Name Type Optional Description
callback function Yes
  • The callback function to execute when complete.
Returns : void

void

Public getCachedVisitor
getCachedVisitor(callback: (data: string) => void)

Gets the cached visitor from the RPI Realtime services.

Parameters :
Name Type Optional Description
callback function No
  • The callback function to execute when complete.
Returns : void

void

Public getContextDecision
getContextDecision(contextPath: string, callback: (data: Array) => void, returnAll?: boolean)

Gets decision results for the specified context path from RPI Realtime services.

Parameters :
Name Type Optional Description
contextPath string No
  • The decision context name to be requested.
callback function No
  • The callback function to execute when complete.
returnAll boolean Yes
  • Flag to specify whether decision content for all slots will be returned. Defaults to true.
Returns : void

void

Public getContextDecisions
getContextDecisions(contextPaths: Array, callback: (data: Array) => void, returnAll?: boolean)

Gets decision results for the specified array of context paths from RPI Realtime services.

Parameters :
Name Type Optional Description
contextPaths Array<string> No
  • The decision context paths to be requested.
callback function No
  • The callback function to execute when complete.
returnAll boolean Yes
  • Flag to specify whether decision content for all slots will be returned. Defaults to true.
Returns : void

void

Public getDecision
since version 6.3
getDecision(publishId: string, isMasterMessage: boolean, callback: (data: Array) => void)

Gets the decision result for a specified content id from the RPI Realtime services.

Parameters :
Name Type Optional Description
publishId string No
  • The published content id to be requested.
isMasterMessage boolean No
callback function No
  • The callback function to execute when complete.
Returns : void

void

Public getDecisionContent
getDecisionContent(result: ApiDecisionResult, callback: (content: string) => void, lookupRequest?: string)

Gets the decision content from an ApiDecisionResult object. Retrieves the content from the returned content path for decisions published using the "web publish site" option in RPI.

Parameters :
Name Type Optional Description
result ApiDecisionResult No
  • The ApiDecisionResult object returned by RPI Realtime services.
callback function No
  • The callback function to execute when complete.
lookupRequest string Yes
  • The lookup request for the decision result.
Returns : void
Public getDecisions
since version 6.3
getDecisions(publishIds: Array, callback: (data: Array,contentDecisions: Array) => void)

Gets decision results for the specified publish ids from RPI Realtime services.

Parameters :
Name Type Optional Description
publishIds Array<string> No
  • The publish ids to be requested.
callback function No
  • The callback function to execute when complete.
Returns : void

void

Public getSmartAssetDecisions
getSmartAssetDecisions(smartAssetDecisions: Array<SmartAssetDecision>, callback: (data: SmartAssetResponse) => void, isMasterMessage?: boolean)

Gets decision results for the specified array of SmartAssetDecision from RPI Realtime services.

Parameters :
Name Type Optional Description
smartAssetDecisions Array<SmartAssetDecision> No
  • The decision context name to be requested.
callback function No
  • The callback function to execute when complete.
isMasterMessage boolean Yes
Returns : void

void

Public getVisitorView
getVisitorView(viewName: string, callback: (data: ApiVisitorView) => void)

Gets the visitor view for a specified view name from the RPI Realtime services.

Parameters :
Name Type Optional Description
viewName string No
callback function No
  • The callback function to execute when complete.
Returns : void

void

Public init
init(opts?: RpiWebClientConfig, callback?: () => void)

Initializes the RpiWebClient. The initialization process includes registering page to collect link click events; submits any Realtime parameters for the current page visit to the RPI Realtime visitor cache; parses the returning Realtime visitor profile details; submits the pageVisit event; renders content for any specified contexts and/or smartAssetDecisions. Triggers rpiWebClientInit event.

rpiWebClient.init({
debug: true,
clientId: "11111111-1111-1111-1111-111111111111",
serverUrl: "rpirealtime.example.net",
enableClickTracking: false,
enablePageVisitTracking: false,
visitorCookieDuration: 365,
realtimeCookieDomain: ".example.net",
realtimeCookieSameSite: "Lax",
serverCookieEnabled: false,
enableUrlParameterCaching: false,
urlParameterCachingOverrides: ["urlParam1", "urlParam2"],
requestGeolocation: false,
geolocationCookieDuration: 5,
context: "home-page",
smartAssetDecisions: [{PublishID: "e5fab7d8-e744-4ff6-82ed-735afd58543d", ElementID: "someDivName"}],
enableCrossDomainTracking: false,
trackingDomains: [],
realtimeListParameters: ["param1", "param2"],
visitorProfileMergeMode: 1,
realtimeContextSearchMode: 0,
enableDoNotTrack: false,
isPreview: false
});
Parameters :
Name Type Optional Description
opts RpiWebClientConfig Yes
  • The configuration options for initializing RpiWebClient. Any parameters passed in opts will override the value set in rpiWebClientDefaults.
callback function Yes
  • The code to be executed after RpiWebClient initializes. Use this callback to execute any custom code to ensure the Realtime visitor profile is properly configured.
Returns : void

void

Public pushRealtimeParameter
pushRealtimeParameter(name: string, value: string, isListParam?: boolean, listOperator?: string)

Queues a visitor parameter to be submit to the RPI Realtime visitor cache

Parameters :
Name Type Optional Description
name string No
  • The visitor parameter name.
value string No
  • The visitor parameter value (or comma separated list for array parameters).
isListParam boolean Yes
  • Boolean to specify if the parameter is a list.
listOperator string Yes
  • The list operator value - Set, Delete, PushToArray or PullFromArray.
Returns : void
Public pushWebEvent
pushWebEvent(state: string, stateValue: string | null, extraParam?: string | null, contentId?: string | null, metadata?: Array)

Pushes event data to RPI Realtime web events or queues the event until an visitor id is present.

Parameters :
Name Type Optional Description
state string No
  • The name of the event.
stateValue string | null No
  • The value or count to assign to the event.
extraParam string | null Yes
  • The additional details to assign to the event.
contentId string | null Yes
  • The content ID to register the metric for (Goal Drive Assets only).
metadata Array<ApiEventMetadata> Yes
  • The metadata to assign to the event.
Returns : void

void

Public renderContextDecision
renderContextDecision(contextPath: string)

Renders decision results for a decision context path. Triggers rpiWebClientContextDecisionRender event.

Parameters :
Name Type Optional Description
contextPath string No
  • The decision context path to be render.
Returns : void

void

Public renderContextDecisions
renderContextDecisions(contextPaths: Array)

Renders decision results for an array of decision context paths. Triggers rpiWebClientContextDecisionRender event for each context.

Parameters :
Name Type Optional Description
contextPaths Array<string> No
  • The decision context paths to be render.
Returns : void

void

Public renderDecision
since version 6.3
renderDecision(contentId: string, elementId: string)

Renders decision results for a specified content id and element (DOM) id. Triggers rpiWebClientDecisionRender event.

Parameters :
Name Type Optional Description
contentId string No
  • The published content id to be requested.
elementId string No
  • The DOM element id that will be replaced by the decision result
Returns : void

void

Public renderDecisionContent
renderDecisionContent(result: ApiDecisionResult, elementId?: string | null, lookupRequest?: string)

Renders decision content by replacing the inner HTML of the element (DOM) id specified in the decision result or by optionally specifying an elementId.

Parameters :
Name Type Optional Description
result ApiDecisionResult No
  • The ApiDecisionResult object returned by RPI Realtime services.
elementId string | null Yes
  • The DOM element id that will be replaced by the decision result
lookupRequest string Yes
  • The lookup request for the decision result.
Returns : void

void

Public renderDecisions
since version 6.3
renderDecisions(contentDecisions: Array<ContentDecision>)

Renders multiple decisions as defined by an array of ContentDecision (content id and element id) objects. Triggers rpiWebClientDecisionRender event for each ContentDecision.

Parameters :
Name Type Optional Description
contentDecisions Array<ContentDecision> No
  • The content and element ids to be rendered
Returns : void

void

Public renderSmartAssetDecisions
renderSmartAssetDecisions(smartAssetDecisions: Array<SmartAssetDecision>, callback?: (data?: SmartAssetResponse) => void)

Renders decision results for an array of decision SmartAssetDecision. Triggers rpiWebClientSmartAssetDecisionRender event for each result.

Parameters :
Name Type Optional Description
smartAssetDecisions Array<SmartAssetDecision> No
  • The decision context name to be requested.
callback function Yes
  • The callback function to execute when complete.
Returns : void

void

Public submitVisitorDetails
submitVisitorDetails(callback?: (data?: string) => void)

Submits any Realtime parameters for the current page visit to the RPI Realtime visitor cache. This function also submits a pageVisit event and flushes any queued (pending Realtime visitor id) events to RPI Realtime web events.

Parameters :
Name Type Optional Description
callback function Yes
  • The callback function to execute when complete.
Returns : void

void

results matching ""

    No results matching ""