onBeforeCommand

This callback function is triggered by Web SDK before any other command is executed. You can use this function to retrieve the configuration options of a specific command. See the sample below for details about the function parameters.

onBeforeCommand(data) {
    // data.instanceName
    // data.commandName
    // data.options
}
ParameterTypeDescription
data.instanceNameStringThe name of the global variable where the Web SDK instance is stored.
data.commandNameStringThe name of the Web SDK command before which this function is executed.
data.optionsObjectAn object containing the options passed to the Web SDK command.

onCommandResolved

This callback function is triggered when resolving command promises. You can use this function to see the command options and result. See the sample below for details about the function parameters.

onCommandResolved(data) {
    // data.instanceName
    // data.commandName
    // data.options
    // data.result
},
ParameterTypeDescription
data.instanceNameStringThe name of the global variable where the Web SDK instance is stored.
data.commandNameStringThe name of the executed Web SDK command.
data.optionsObjectAn object containing the options passed to the Web SDK command.
data.resultObjectAn object containing the result of the Web SDK command.

onCommandRejected

This callback function is triggered before a command promise is rejected and it contains information about the reason why the command was rejected. See the sample below for details about the function parameters.

onCommandRejected(data) {
    // data.instanceName
    // data.commandName
    // data.options
    // data.error
}
ParameterTypeDescription
data.instanceNameStringThe name of the global variable where the Web SDK instance is stored.
data.commandNameStringThe name of the executed Web SDK command.
data.optionsObjectAn object containing the options passed to the Web SDK command.
data.errorObjectAn object containing the error message returned from the browser’s network call (fetch in most cases), along with the reason why the command was rejected.

onBeforeNetworkRequest

This callback function is triggered before a network request is executed. See the sample below for details about the function parameters.

onBeforeNetworkRequest(data) {
    // data.instanceName
    // data.requestId
    // data.url
    // data.payload
}
ParameterTypeDescription
data.instanceNameStringThe name of the global variable where the Web SDK instance is stored.
data.requestIdStringThe requestId generated by Web SDK to enable debugging.
data.urlStringThe requested URL.
data.payloadObjectThe network request payload object that will be converted to JSON format and sent in the body of the request, through a POST method.

onNetworkResponse

This callback function is triggered when the browser receives a response. See the sample below for details about the function parameters.

onNetworkResponse(data) {
    // data.instanceName
    // data.requestId
    // data.url
    // data.payload
    // data.body
    // data.parsedBody
    // data.status
    // data.retriesAttempted
}
ParameterTypeDescription
data.instanceNameStringThe name of the global variable where the Web SDK instance is stored.
data.requestIdStringThe requestId generated by Web SDK to enable debugging.
data.urlStringThe requested URL.
data.payloadObjectThe payload object that will be converted to JSON format and sent in the body of the request, through a POST method.
data.bodyStringThe response body in string format.
data.parsedBodyObjectAn object containing the parsed response body. If an error occurs while parsing the response body, this parameter is undefined.
data.statusStringThe response code in integer format.
data.retriesAttemptedIntegerThe number of retries attempted when sending the request. Zero means the request was successful on the first try.

onNetworkError

This callback function is triggered when the network request failed. See the sample below for details about the function parameters.

onNetworkError(data) {
    // data.instanceName
    // data.requestId
    // data.url
    // data.payload
    // data.error
},
ParameterTypeDescription
data.instanceNameStringThe name of the global variable where the Web SDK instance is stored.
data.requestIdStringThe requestId generated by Web SDK to enable debugging.
data.urlStringThe requested URL.
data.payloadObjectThe payload object that will be converted to JSON format and sent in the body of the request, through a POST method.
data.errorObjectAn object containing the error message returned from the browser’s network call (fetch in most cases), along with the reason why the command was rejected.

onBeforeLog

This callback function is triggered before the Web SDK logs anything to the console. See the sample below for details about the function parameters.

onBeforeLog(data) {
    // data.instanceName
    // data.componentName
    // data.level
    // data.arguments
}
ParameterTypeDescription
data.instanceNameStringThe name of the global variable where the Web SDK instance is stored.
data.componentNameStringThe name of the component that generated the log message.
data.levelStringThe logging level. Supported levels: log, info, warn, error.
data.argumentsString arrayThe arguments of the log message.

onContentRendering

This callback function is triggered by the personalization component at various stages of rendering. The payload can differ, depending on the status parameter. See the sample below for details about the function parameters.

 onContentRendering(data) {
     // data.instanceName
     // data.componentName
     // data.payload
     // data.status
}
ParameterTypeDescription
data.instanceNameStringThe name of the global variable where the Web SDK instance is stored.
data.componentNameStringThe name of the component that generated the log message.
data.payloadObjectThe payload object that will be converted to JSON format and sent in the body of the request, through a POST method.
data.statusString

The personalization component notifies the Web SDK of the status of rendering. Supported values:

  • rendering-started: Indicates that the Web SDK is about to render propositions. Before the Web SDK starts to render a decision scope or a view, in the data object you can see the propositions that are about to be rendered by the personalization component and the scope name.
  • no-offers: Indicates that no payload was received for the requested parameters.
  • rendering-failed: Indicates that Web SDK failed to render a proposition.
  • rendering-succeeded: Indicates that rendering has completed for a decision scope.
  • rendering-redirect: Indicates that Web SDK will render a redirect proposition.