Module: jsApone

JS APONE Module (jsApone) returns the functions the client needs to interact with APONE. When the module is created, the information of the experimental unit (if not set by the user), the variant assigned and the values of the variables in PlanOut scripts (if exist) are set. This is done synchronously if JS Promises are not supported, and asynchronously if they are supported. An event 'exposure' for that experimental unit is automatically registered in APONE.
Parameters:
Name Type Attributes Description
aponeURL string URL where APONE is hosted
idExperiment string Identifier of the experiment running in APONE
idUnit * <optional>
Identifier of the experimental unit. If not included, cookies are used instead.
overrides object <optional>
Only if PlanOut scripts are used in the experiment: values of the variables in the scripts we want to override before calculating the value of the rest of them.
Source:
Returns:
Interface to interact with APONE from the client.
Type
object
Example
myExperiment = jsApone("http://localhost:8080/APONE", "5a7894f5da0ed16e95180701");
myExperiment.getExperimentalConditions(function(expCond){console.log(expCond);});
function registerEvents(){
	myExperiment.registerString("myEventName", "myEventValue", function(info){console.log("string event registered")}, function(status){console.log(status);});
	myExperiment.registerJSON("myEventName", {myvar1:"value1", myvar2:2}, function(info){console.log("JSON event registered")}, function(status){console.log(status);});
}
myExperiment.isCompleted(function(completed){if (!completed) registerEvents();});

Classes

ExperimentalConditions

Methods

(static) getExperimentalConditions(callback)

Get the experimental conditions set for this experiment and call the callback function with them. Note that the experimental conditions can not be modified once created the module.
Parameters:
Name Type Description
callback function Callback function which receives the experimental conditions (see [ExperimentalConditions]).
Source:

(async, static) isCompleted(cbSuccessopt, cbErroropt)

Check if the experiment has already been completed for the current experimental unit.
Parameters:
Name Type Attributes Description
cbSuccess function <optional>
Callback function in case of success. Receives a boolean indicating if the experiment was completed by the experimental unit.
cbError function <optional>
Callback function in case of error. Receives the status property of XMLHttpRequest.
Source:

(async, static) registerBinaryStream(eName, eValue, cbSuccessopt, cbErroropt)

Register an event with BINARY contents (contained in a stream).
Parameters:
Name Type Attributes Description
eName string Name of the event
eValue stream Contents to be saved: binary stream (eg. file).
cbSuccess function <optional>
Callback function in case of success. Receives no contents. Note: errors from the message broker are not captured.
cbError function <optional>
Callback function in case of error. Receives the status property of XMLHttpRequest.
Source:

(async, static) registerBinaryString(eName, eValue, cbSuccessopt, cbErroropt)

Register an event with BINARY contents (contained in a string).
Parameters:
Name Type Attributes Description
eName string Name of the event
eValue string Contents to be saved: binary string.
cbSuccess function <optional>
Callback function in case of success. Receives no contents. Note: errors from the message broker are not captured.
cbError function <optional>
Callback function in case of error. Receives the status property of XMLHttpRequest.
Source:

(async, static) registerCompleted(cbSuccessopt, cbErroropt)

Register the 'completed' event so APONE can keep track of those experimental units which already completed the experiment. APONE uses this information to monitor the data registered and to prevent users from being redirected from the participating interface to experiments which they already completed. Experimenters may use the function [isCompleted] in this library to check if the current experimental unit already completed the experiment.
Parameters:
Name Type Attributes Description
cbSuccess function <optional>
Callback function in case of success. Receives no contents. Note: errors from the message broker are not captured.
cbError function <optional>
Callback function in case of error. Receives the status property of XMLHttpRequest.
Source:

(async, static) registerExposure(cbSuccessopt, cbErroropt)

Register the 'exposure' event so the different experimental units being exposed to the experiment can be monitored in APONE. Note: this is automatically done when the module is created.
Parameters:
Name Type Attributes Description
cbSuccess function <optional>
Callback function in case of success. Receives no contents. Note: errors from the message broker are not captured.
cbError function <optional>
Callback function in case of error. Receives the status property of XMLHttpRequest.
Source:

(async, static) registerJSON(eName, eValue, cbSuccessopt, cbErroropt)

Register an event with JSON contents.
Parameters:
Name Type Attributes Description
eName string Name of the event
eValue object Contents to be saved: the JavaScript object received will be converted to JSON.
cbSuccess function <optional>
Callback function in case of success. Receives no contents. Note: errors from the message broker are not captured.
cbError function <optional>
Callback function in case of error. Receives the status property of XMLHttpRequest.
Source:

(async, static) registerString(eName, eValue, cbSuccessopt, cbErroropt)

Register an event with String contents.
Parameters:
Name Type Attributes Description
eName string Name of the event
eValue string Contents to be saved
cbSuccess function <optional>
Callback function in case of success. Receives no contents. Note: errors from the message broker are not captured.
cbError function <optional>
Callback function in case of error. Receives the status property of XMLHttpRequest.
Source: