jslibrary

Need

The purpose of a standalone JS library for telemetry is to facilitate capture and distribution of telemetry data by users who would like to use their own apps, content players or portals.

We chose to use a JS library for the following reasons:

  • All the telemetry events that are generated and synced to the server have the same format (field data types and time zone value)

  • It is easy to upgrade to new versions, in case of major changes in telemetry

  • There is effortless backward compatibility, as changes are handled within the telemetry library. Any upgrade of the telemetry library does not require code changes in the content

  • There are reduced number of API calls

  • There are simple API methods to generate the complete telemetry event as only the required fields are passed

Prerequisites

The following are prerequisites to use or integrate the JS library:

  • JQuery library should be available

  • Valid Authtoken and Key to make API calls

  • The telemetry.min.js{:target="_blank"} file

Note: For details on generating and using the Authtoken and Key, refer to the section

  • Device ID value

Note: For details on how to get the device ID value, refer to website

Configure

This JS library helps to generate telemetry events. These events sync to the server or data-pipeline in a batch as defined in the configuration. To log telemetry events, the user has to call the start method by passing the configuration along with other parameters.

Note: All telemetry events sync only to the server or data-pipeline, when connected to the Internet.

Telemetry events are generated based on the configuration of the telemetry library.

Required Configuration (Context)

Property

Description

Required

Default Value

pdata

Producer data. It is an object containing id, version and pid.

true

Defaults to genie ex : {"id": "genie", "ver": "6.5.2567" pid:""}

channel

It is an string containing unique channel name.

true

Defaults to in.ekstep

uid

It is an string containing user id.

true

defaults to "anonymous"

did

It is an string containing unique device id.

  • To generate did value for android refer to here ANDROID_ID is generally used for mobiles

  • To generate did value for web client refer here. If consumer is not sending any did value then by default library will generate did using fingerPrintJs2.

  • For server side it's mandtory to pass did value

true

Default to fingerPrintjs2(Note: Only for web client)

authtoken

It is an string containing consumer token to access the API

true

Property

Description

Required

Default Value

env

It is an string containing Unique environment where the event has occurred

true

defaults to "ContentPlayer"

Additional Configuration

Property

Description

Required

Default Value

sid

It is an string containing user session id.

optional

batchsize

It is an int containing number of events count to sync at a time. Can be configured from min value 10 to max value 1000.

optional

defaults to 20

mode

It is an string which defines to identify preview used by the user to play/edit/preview.

optional

defaults to "play"

host

It is an string containing API endpoint host.

optional

defaults to "https://api.ekstep.in"

endpoint

It is an string containing API endpoint. Please don't change default value. Update this only when the data is proxied

optional

Defaults to "/v3/telemetry"

tags

It is an array. It can be used to tag devices so that summaries/metrics can be derived via specific tags. Helpful during analysis

optional

Defaults to []

cdata

It is an array. Correlation data. Can be used to correlate multiple events. Generally used to track user flow

optional

Defaults to []

dispatcher

Sample:

Dispatcher:

User can define custom dispatcher to override the default functionality of telemetry sync. By default telemetry events will send to default server/host. User can override this default functionality by defining his own "dispatcher" object to handle telemetry events.

Send this object as dispatcher in the above sample configuration ("dispatcher":customDispatcher).

How to use telemetry JS library

Download the telemetry-sdk npm module from here

Example:

To use the telemetry JS libraries, add the following to your HTML/application. The file path is a relative path, for example; assets/js to the associated files within the html content.

Telemetry API methods

Every API method has an associated event. The following API methods log details of the associated telemetry event.

  • Start - This method initializes capture of telemetric data associated to the start of user action

  • Impression - This method is used to capture telemetry for user visits to a specific page.

  • Interact - This method is used to capture user interactions on a page. For example, search, click, preview, move, resize, configure

  • Assess - This method is used to capture user assessments that happen while playing content.

  • Response - This method is used to capture user responses. For example; response to a poll, calendar event or a question.

  • Interrupt - This method is used to capture interrupts triggered during user activity. For example; mobile app sent to background, call on the mobile, etc.

  • End - This method is used to capture closure after all the activities are completed

  • Feedback - This method is used to capture user feedback

  • Share - This method is used to capture everything associated with sharing. For example; Share content, telemetry data, link, file etc.

  • Audit - This method is used when an object is changed to know previous and current state. This includes lifecycle changes as well.

  • Error - This method is used to capture when users face an error

  • Heartbeat - This method is used to know is process is running or not.

  • Log - This method is used to capture generic logging of events. For example; capturing logs for API calls, service calls, app updates etc.

  • Search - This method is used to capture the search state i.e. when search is triggered for content, item, assets etc.

  • Metrics - Service business metrics (also accessible via health API)

  • Summary - Summary event

  • Exdata - This method is used as a generic wrapper event to capture encrypted or serialized data

Start

This API is used to log telemetry when users view content or initiate game play

Request Arguments:

Impression

This API is used to log telemetry when users visit a specific page.

Request Arguments:

Interact

This API is used to log telemetry of user interactions on the page. For example, search, click, preview, move, resize, configure

Request Arguments:

Assess

This API is used to log telemetry of assessments that have occured when the user is viewing content

Request Arguments:

Response

This API is used to log telemetry of user response. For example; Responded to assessments.

Request Arguments:

Interrupt

This API is used to log telemetry for any interruptions that have occurred when a user is viewing content or playing games. For example; screen lock, incoming call, etc.

Request Arguments:

Feedback

This API is used to log telemetry of feedback provided by the user.

Request Arguments:

Share

This API is used to log telemetry when a user shares any content with other users.

Request Arguments:

Audit

This API is used to log telemetry when an object is changed. This includes life-cycle changes as well.

Request Arguments:

Error

This API is used to log telemetry of any error that has occurred when a user is viewing content or playing games.

Request Arguments:

Heartbeat

This API is used to log telemetry for heartbeat event to denote that the process is running.

Request Arguments:

Log

This API is used to log telemetry of generic log events. For example; API calls, service calls, app updates, etc.

Request Arguments:

This API is used to log telemetry when a user triggers a search for any content, item or asset

Request Arguments:

Metrics

This API is used to log telemetry for service business metrics (also accessible via health API).

Request Arguments:

Summary

This API is used to log telemetry summary event

Request Arguments:

Exdata

This API is used to log telemetry for external data, while playing content

Request Arguments:

End

This API is used to log telemetry while the user is closing or exiting the content or game

Request Arguments:

ResetContext

This is used to reset the current context value with new context object.

ResetObject

Which is used reset the current object value with new obj

ResetActor

Which is used reset the current actor value with new actor

ResetTags

Which is used to reset the current tag's value with new tag's

ChangeLog

Jan 2018

  • For the start event, Changed the both contentId and contentVer to an optional parameters from mandtory.

  • Decoupling of the both init and start methods.

  • Introduced new initialize method, Where user can initialize the telemetry without calling start event. More details

  • Introduced new context parameter in all telemetry event methods, Where user can easily update the context value for each event.

  • Introduced resetContext method, Which is used to reset the context to new context value/global context. More details

  • Introduced resetObject method, Which is used to reset the current object value. More details

  • Introduced resetTags method, Which is used to reset the current tags value. More details

  • Introduced resetActor method, Which is used to reset the current actor value. More details

  • Previously if the user invokes an end event then the user must and should invoke start event to initialize the telemetry. but in the updated on no need to invoke start event because telemetry is initialized globally.

  • Bug fixes

Last updated

Was this helpful?