Nagra OTV Analytics Javascript Agent

Index

Nagra OTV Analytics Javascript Agent

The file otvaa.js contains a minified build of the agent. The module is exported to the global variable otvaa and you can call all the methods described in the api on this object.

OTVAa supports two different API:

  • otvaa.agent

  • otvaa.wrapper

The OTVAa agent API will support only UAV activities. Client applications using this API will be required to identify analytics activities but can use the agent API to forward the activities to UAV. The agent API is useful for clients who do not use a Nagra Connect secure player.

The OTVAa wrapper API is useful for clients who use a Nagra Connect secure player. It supports both UAV activities, and Insight Analytics. It will automatically identify some analytics activities from the player thereby reducing the integration effort on the client application (though the client application will still be required to generate some activities).

NOTE: Client applications should use the agent API or the wrapper API, but not a mixture.

User Activities

User Activities may be referenced using the otvaa.OtvActivity class. For example, otvaa.OtvActivity.PlaybackStop in:

const playbackStopMetadata = {
  Position: getPlaybackPosition(),
};
otvaa.agent.submitActivity(otvaa.OtvActivity.PlaybackStop, playbackStopMetadata);

Errors

The Agent and Wrapper can report error scenarios during its functioning, these come from the following set of defined errors:

export const ALREADY_INITIALISED = {
  code: 100,
  description: "OtvAnalyticsAgent is already initialised. Close the agent before re-initialising",
};
export const AGENT_NOT_INITIALISED = {
  code: 101,
  description: "OtvAnalyticsAgent is not yet initialised.",
};
export const APP_NOT_STARTED = {
  code: 102,
  description: 'must call "appStart" before activities can be submitted',
};
export const CAN_ONLY_UPDATE_EXISTING_DESTINATION = {
  code: 103,
  description: "Destination does not exist. New destinations cannot be added after initialisation",
};
export const INVALID_ACTIVITY = {
  code: 104,
  description: 'Invalid activity. Only submit activities of type "OtvActivity"',
};
export const INVALID_DESTINATION_CONFIGURATION = {
  code: 105,
  description:
    "Invalid configuration of destinations. Please see API documentation for description of configuration object",
};

export const INVALID_CONFIGURATION = {
  code: 106,
  description: "Invalid configuration. Please see API documentation for description of configuration object",
};

export const WRAPPER_ALREADY_INITIALISED = {
  code: 200,
  description: "OtvAnalyticsWrapper is already initialised. Close the wrapper before re-initialising",
};

export const WRAPPER_NOT_INITIALISED = {
  code: 201,
  description: "OtvAnalyticsWrapper is not yet initialised.",
};

export const INVALID_POSITION_CALLBACK = {
  code: 202,
  description: "Invalid wrapper position callback. Position callback must be a function",
};

export const PLAYER_CHANGED_DURING_PLAYBACK = {
  code: 203,
  description:
    "Player reference changed before PlaybackStop activity submitted. No further player activities will be detected for this playback session",
};

export const PLAYER_NOT_SET = {
  code: 204,
  description:
    "Player reference must be set before submitting PlaybackStart activity. Activities will not be detected for this playback session",
};

export const USE_WRAPPER_METHOD = {
  code: 205,
  description:
    "AppStart and PlaybackStart activities must be submitted using the appropriate wrapper methods (not submitActivity)",
};

export const CANT_POPULATE_METADATA_WITHOUT_PLAYER = {
  code: 206,
  description:
    "An activity was submitted whose metadata should be populated from the player, but no player reference has been provided",
};

export const INVALID_URL_FOR_UAV = {
  code: 300,
  description: "No URL or invalid URL for UAV configuration",
};

export const NO_TOKEN_FOR_UAV = {
  code: 301,
  description: "No token provided for UAV configuration",
};

export const ONLY_TOKEN_CAN_BE_UPDATED_FOR_UAV = {
  code: 302,
  description: "Only the token may be update for UAV",
};

export const UAV_HTTP_ERROR = {
  code: 303,
  description: "HTTP error sending activity to UAV",
};

export const UNABLE_TO_SEND_TO_UAV = {
  code: 304,
  description: "Unable to send activity to UAV",
};

export const UAV_TIMEOUT = {
  code: 305,
  description: "Timeout sending activity to UAV",
};

export const INSIGHT_CANT_CREATE_WRAPPER = {
  code: 400,
  description: "Unable to create Insight wrapper. See extra field for more details",
};

export const INSIGHT_CANT_START_SESSION = {
  code: 401,
  description:
    "Unable to start Insight session. See extra field for more details. No activities will be generated for this playback session",
};