Conviva JavaScript SDK API Mapping for Migration from Conviva JavaScript SDK 2.x Version to Conviva JavaScript SDK 4.x Version

Maps the Conviva JavaScript SDK 2.x API methods to their 4.x equivalents to guide migration to the simplified 4.x sensor.

Updated 2026-05-29 javascript, sdk, migration, sensor developer center, sensor integration

The Conviva SDK 4.x version is significantly simplified when compared to the Conviva SDK 2.x version. It reduces integration time and effort, and enables solid foundation for future Conviva Sensor implementation on devices using JavaScript. Conviva strongly recommends migrating to Conviva SDK 4.x version. Only the Conviva SDK 4.x version will have new features implemented going forward.

The below table prescribes mapping of old 2.x API to the new 4.x API, as well as denotes the API methods that are not applicable anymore in Conviva SDK 4.x version. Full integration instructions can be found here.

**OLD (2.x)** **NEW (4.x)**
Conviva.Client Conviva.Analytics
var client = 
new Conviva.Client(clientSettings, systemFactory);
Conviva.Analytics.init(customerKey, callbackFunctions, settings);
// Conviva.Analytics is a global object, not return object like 'client' was.
// Note that the most important parameter – CUSTOMER_KEY – 
//now becomes separate argument, not part of 'settings'
Conviva.SystemSettings

Not applicable. The settings are just defined as an object "var settings = { }", which can take values of pre-defined constants as keys:

settings[Conviva.Constants.GATEWAY_URL] = "Touchstone Service URL";
settings[Conviva.Constants.LOG_LEVEL] = Conviva.Constants.LogLevel.DEBUG;
Conviva.SystemInterface
TimeInterfaceImplementation
TimerInterfaceImplementation
HttpInterfaceImplementation
StorageInterfaceImplementation
LoggingInterfaceImplementation

Not needed. Conviva SDK provides default implementation of all system interfaces that are working on browsers. If customization is required to adopt for a custom JavaScript platform, implement "callback functions" with appropriate keys:

Example:

callbackFunctions[Conviva.Constants.CallbackFunctions.CONSOLE_LOG] =
 function (message, logLevel) {
 log(message, logLevel);
 };
MetadataInterfaceImplementation

No interface anymore.

Instead, use the method of Conviva.Analytics and the corresponding keys instead of methods:

var deviceMetadata = { };
deviceMetadata[Conviva.Constants.DeviceMetadata.CATEGORY]
deviceMetadata[Conviva.Constants.DeviceMetadata.MODEL]
etc

Conviva.Analytics.setDeviceMetadata(deviceMetadata)
Conviva.SystemFactory
Not needed anymore.
PlayerStateManager
VideoAnalytics for main video content and AdAnalytics for advertisement content.
client.getPlayerStateManager()
var convivaVideoAnalytics = Conviva.Analytics.buildVideoAnalytics();

var convivaAdAnalytics = Conviva.Analytics.buildAdAnalytics();
```javascript ClientMeasureInterface() ```

or

playerStateManager
setClientMeasureInterface()

Implement a callback function and pass the callback function to videoAnalytics.setCallback() method. In the callback function, report values for the individual metrics using generic videoAnalytics.reportPlaybackMetric() API.

videoAnalytics.setCallback(function() {
videoAnalytics.reportPlaybackMetric(Conviva.Constants.Playback.BUFFER_LENGTH,
                                    bufferLength);
videoAnalytics.reportPlaybackMetric(Conviva.Constants.Playback.PLAY_HEAD_TIME,
                                    playheadTimeMs);
videoAnalytics.reportPlaybackMetric(Conviva.Constants.Playback.RENDERED_FRAMERATE,
                                    renderedFramerate);
});
Client.attachPlayer()

Not needed. Report metrics directly to videoAnalytics. In case of "module" integration, for example, HTML5 module, use :

videoAnalytics.setPlayer(/* HTML5VideoElement */ videoElement);
Client.createSession(contentInfo)
videoAnalytics.reportPlaybackRequested(ContentInfo)
```javascript Client.reportError() ```

or

playerStateManager.sendError()

There are two alternate methods:

  1. The method which does 3 actions in one – create session, report error, and cleanup session:
videoAnalytics.reportPlaybackFailed(message, contentInfo=);
  1. The method which reports an error and creates a session if reportPlaybackRequested() is not called before:
videoAnalytics.reportPlaybackError(message, severity);

If you have retry logic, then use the second method.

playerStateManager.setPlayerState()
videoAnalytics.reportPlaybackMetric(metric_key, metric_value)

For player state, use the parameter metric_key Conviva.Constants.Playback.PLAYER_STATE.

playerStateManager.setVideoResolutionWidth(w)
playerStateManager.setVideoResolutionHeight(h)
videoAnalytics.reportPlaybackMetric(Conviva.Constants.Playback.RESOLUTION, w, h);
playerStateManager
videoAnalytics.reportPlaybackMetric
setPlayerSeekStart(pos);
(Conviva.Constants.Playback.SEEK_STARTED, pos=);
playerStateManager.setPlayerSeekEnd();
videoAnalytics.reportPlaybackMetric(Conviva.Constants.Playback.SEEK_ENDED, pos=)
playerStateManager.setBitrateKbps(currentRenderingBitrateKbps);
//Value should be integer
videoAnalytics.reportPlaybackMetric
(Conviva.Constants.Playback.BITRATE, bitrateKb);
Clean up session when the application is backgrounded.
Conviva.Analytics.reportAppBackgrounded();
Re-create a new session when the application is foregrounded.
Conviva.Analytics.reportAppForegrounded();
Client.updateContentMetadata(contentSessionKey,contentMetadata);
videoAnalytics.setContentInfo(contentInfo);
On events such as bumper video or pop up requiring user wait, the solution was to call Client.adStart() or Client.adEnd().

We introduced dedicated API calls for these use cases.

//To report start user dialog pop up displayed:
videoAnalytics.reportPlaybackEvent(Conviva.Constants.USER_WAIT_STARTED);

//To report dismiss of user dialog popup
videoAnalytics.reportPlaybackEvent(Conviva.Constants.USER_WAIT_ENDED);

// To report bumper video start:
videoAnalytics.reportPlaybackEvent(Conviva.Constants.BUMPER_VIDEO_STARTED);

// To report completion of bumper video:
videoAnalytics.reportPlaybackEvent(Conviva.Constants.BUMPER_VIDEO_ENDED);
Client.cleanupSession(contentSessionKey);
videoAnalytics.reportPlaybackEnded();
mPlayerInterface.cleanup();

Client.releasePlayerStateManager(playerStateManager);

Client.release();
videoAnalytics.release();

Conviva.Analytics.release();
//SET framework name
playerStateManager.setPlayerType("FRAMEWORK_NAME");

//SET PLAYER FRAMEWORK VERSION
playerStateManager.setPlayerVersion("1.2.3.4");
Map<String, Object> playerInfo = new HashMap<String, Object>();
playerInfo.put(ConvivaSdkConstants.FRAMEWORK_NAME,"FRAMEWORK_NAME");

// SET PLAYER FRAMEWORK VERSION
playerInfo.put(ConvivaSdkConstants.FRAMEWORK_VERSION, "1.2.3.4");

videoAnalytics.setPlayerInfo(playerInfo);

Handle Ads:

Client.adStart(contentSessionKey, Client.AdStream.SEPARATE,
Client.AdPlayer.SEPARATE, Client.AdPosition.PREROLL);

Client.adEnd(contentSessionKey);
// On ad break start
videoAnalytics.reportAdBreakStarted(/* Conviva.Constants.AdType */ adType,
        /* Conviva.Constants.AdPlayer */ adPlayer);

// on ad break end
videoAnalytics.reportAdBreakEnded();

"Pod" Events:

String eventName = "Conviva.PodStart";

Client.sendCustomEvent(contentSessionKey, eventName, attributes);
No need to explicitly send Pod Events. It is covered by the reportAdBreakStarted() and reportAdBreakEnded() API calls.
client.sendCustomEvent (Conviva.Client.NO_SESSION_KEY, "share-click",
{"location": "Toolbar", "assetName": "Sample Video",
 "shareService": "Facebook"});
// New code uses ConvivaAnalytics to send the event
String eventType = "share-click";

Map<String, Object> attr = new HashMap<> ();

attr.put("location", "Toolbar");
attr.put("assetName", "Sample Video");
attr.put("shareService", "Facebook");

Conviva.Analytics.reportAppEvent(eventType, attr);