initialization - Events API

This is a lower-level API. Lower-level APIs are not recommended for most projects, and may not be available on all plans.

See our page on recommended deployment patterns for more information.

Events API Initialization

This is a premium feature and may not be included in your product license. For more information, reach out to your Learnosity Account Manager.

This article details the properties that are passed as parameters to the window.LearnosityEvents.init() method to initialize Events API.

This method is the starting point to initializing and rendering Events API.

Example

var initializationOptions = {
    "security": {
        "consumer_key": "INSERT_CONSUMER_KEY_HERE",
        "domain": "my.domain.com",
        "timestamp": "20250408-1234",
        "signature": "SHA256-HASH - See Security",
        "user_id": "INSERT_USER_ID"
    },
    "config": {
        "users": {
            "learner001": "7224f1cd26c7eaac4f30c16ccf8e143005734089724affe0dd9cbf008b941e2d",
            "learner002": "1e94cba9c43295121a8c93c476601f4f54ce1ee93ddc7f6fb681729c90979b7f",
            "learner003": "ca2d79d6e1c6c926f2b49f3d6052c060bed6b45e42786ff6c5293b9f3c723bdf",
            "learner004": "fd1888ffc8cf87efb4ab620401130c76fc8dff5ca04f139e23a7437c56f8f310"
        },
        "ignore_past_events": false,
    }
};

var callbacks = {
    readyListener: function () {
        console.log("Learnosity Events API is ready");
    },
    errorListener: function (e) {
        console.log('error', e);
    }
};

var eventsApp = window.LearnosityEvents.init(initializationOptions, callbacks);
    

Initialization Object

The Initialization object is a JSON object which is passed as the first parameter into the window.LearnosityEvents.init() method. It includes all the information needed to initialize the API.

It contains the following two top-level properties:

The Security object is a property generated by the Learnosity serverside SDKs to ensure that any of the APIs are only initialized from a secured, allowed source, using your consumer key and secret.

This is handled by our SDKs in:

For other languages, please see our Security & Authentication page on how to sign your requests.

Request Object

The Request object contains all of the configuration properties for user & session identification, user interface look and feel.

Properties

  • users object

    A definition list of users (learners) to receive events from.

  • ignore_past_events boolean

    Controls whether to ignore events that happened before initialization.

The Callbacks object contains optional callback functions that allow detection of the ready status of an Events API instance and any errors encountered.

The readyListener callback in particular is very important for the correct functioning of Events API. Most of the methods provided by the returned object from window.LearnosityEvents.init() will not be fully available until after the readyListener callback has triggered.

Properties

  • errorListener function

    This function is called when one of the preset Learnosity API errors are thrown.

  • readyListener function

    This function is called when the API has been successfully initialized.

Was this article helpful?

Did you arrive here by accident? If so, learn more about Learnosity.