1. Home
  2. Docs
  3. JavaScript API
  4. Data collection

Data collection

The Mind-Trace online test designer (accessible through the customer portal) supports the creation of simple Mind-Trace experiments. It is possible to create more elaborate experiments using your own or third-party applications by using our Data collection components.

Before you start, please make sure you have created an empty experiment in the online portal. Make sure to copy the unique identifier of the experiment as well as the participation password.

Note that anyone who has access to the participation password can start a new session. Take this under consideration when designing your application. In the future we will allow starting of experiments using cryptographically signed single-use tokens. These tokens will then replace the password.

The following example code demonstrates how to start a new Mind-Trace session:

/**
 * These variables define the unique experiment 
 * identifier and password that are provided in
 * the customer portal.
 */
const experimentId = 1;
const experimentPassword = '82775048-a9dd-4a7e-849c-a5056a9dd36d';

/**
 * If you want to associate your own unique identifier
 * with this session, you can set it here.
 * We use a random GUID as an example.
 */
const yourSessionId = 'unique-identifier-' + mindtrace.getUuid();

/**
 * The next line attempts to continue an open session,
 * if none exists a new session is created.
 */
mindtrace.connect(experimentId, yourSessionId, experimentPassword).then(async session => {
     await mindtrace.runCalibration(session.calibration);
     // You should perform your own test here.
     await mindtrace.close();
}, error => {
     // You should handle errors here.
});