Skip to main content
Skip table of contents

Insight data collection

The NAGRA Insight tool allows data collection for device and network profiling purposes. The OtvInsightAgent class abstracts the NAGRA Insight library functionality that provides the data collection mechanism to the SDK.

Integrating the Insight library

Download the opy-sdk-js-<version>-insight.zip file; see Downloading the SDK.

Include the NAGRA Insight ni-agent.js module in the HTML file before the opy-sdk-js-all.js SDK file:

XML
<script src="../ni-agent.js"></script>
<script src="../opy-sdk-js-all.js"></script>

Replace opy-sdk-js-all.js with opy-sdk-js-all-no-ui.js when using the Reduced Size SDK.

Instantiation

Create an instance of the OtvInsightAgent class, providing it with the necessary configuration.

JS
const insightConfig = {
	collectorURL: "https://collector.insight-stats.com/api/v1",
	reportingInterval: 1, // minutes (1-60, default 30)
	samplingInterval: 20, // seconds (15-reportingInterval, default 30)
	appName: "OpenTV Player Sample App",
	appVersion: "5.x",
	deviceType: "desktop",
	operatorId: "TBD",
	deviceId: "TBD",
};

agent = new OTV.OtvInsightAgent(insightConfig);

Starting a session

Immediately before setting the source stream, the instance of the agent needs the startSession() method called providing the player instance, details of the stream to be played, and the user's profile.

JS
const vodContentInfo = {
	contentId: "9876543",
	contentName: "Big Buck Bunny",
	genre: ["animation"], // optional
	scrambled: false, // optional
};

const userInfo = {
	userId: "User001",
	accountId: "account001",
	fullName: "Homer J Simpson",
	gender: "male",
	age: 37,
	ageRange: "AlwaysTheSame",
	category: "D'oh",
	street: "Evergreen Terrace",
	city: "Springfield",
	state: "Idono",
	postCode: "1DK",
	country: "US",
};

agent.startSession(window.player, vodContentInfo, userInfo);
window.player.src(stream.source);

From that point, event-based analytic data will be collected in the background and periodically uploaded to the Insight server.

Stopping a session

The session is completed by calling stopSession() immediately before stopping playback of the current content (for example, switching to new content). A session must be stopped before a new session can be started.

JS
agent.stopSession(); 
agent.startSession(window.player, vodContentInfo, userInfo);
window.player.src(stream.source);

Termination

Calling terminate() will clean up the agent and upload any pending collected data to the Insight server. Termination is typically done when the application must shut down (e.g. before navigation from the page). If terminate() is not called, it is possible that the most recently collected data will not be uploaded. After calling terminate() all other calls to this instance of the OtvInsightAgent object are unsupported.

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.