DCR Video Domless SDK: Difference between revisions

From Engineering Client Portal

Line 34: Line 34:
<syntaxhighlight lang="javascript">
<syntaxhighlight lang="javascript">
  `import { BsdkInstance } from 'bsdk-domless'
  `import { BsdkInstance } from 'bsdk-domless'
</syntaxhighlight>
====== status.ok() ======
Initialization of the instance can be done with <code>status.ok()</code> function or use Promise handling approach
<syntaxhighlight lang="javascript">
const instance = await new BsdkInstance(appID, instanceName, instanceMetadata, implementationHooks);
if (instance && instance.status.ok()) {
    expect(instance).not.toBe(undefined);
    expect(instance.status.ok()).toBe(true);
}
</syntaxhighlight>
</syntaxhighlight>
==== Exposed Interface ====
==== Exposed Interface ====
Line 59: Line 75:
|instanceName
|instanceName
|DOM-less SDK instance name  
|DOM-less SDK instance name  
|
|Client provided
|Yes
|Yes
|String eg. abcdefg
|String eg. abcdefg
|-
|-
|metadataObject
|appName
|Object containing the metadata for SDK initialization. The parameters are:
|Application name
 
|Client provided
#
|Yes
|
|appName: 'BSDK RN Sample App'
|-
|deviceId
|Device ID
|Client provided
|Yes
|deviceId: '38400000-8cf0-11bd-b23e-10b96e40000d'
|-
|nol_sdkDebug
|Enables Nielsen console logging. Only required for testing
|Client-provided
|No
|nol_sdkDebug: 'debug'
|-
|domlessEnv
|Specify the domless environment.
"1" for ReactNative
"2" for Amazon
"3" for NodeJS
"4" for Custom
|Client-provided
|Yes
|Yes
|
|domlessEnv: '1'
|}
|}


=== DOM-less SDK DCR Video Step 3 - Create DCR Video Content Metadata Object ===
=== DOM-less SDK DCR Video Step 3 - Create DCR Video Content Metadata Object ===
==== Events that can be passed to `ggPM` method ====
1. <code>loadmetadata</code> - This event is used to send DCR Video metadata to the Nielsen SDK. This event should be called when the video metadata is loaded.
<syntaxhighlight lang="javascript">
    instance.ggPM('loadmetadata', {
        'type': 'content',
        'length': '300',
        'censuscategory': 'Enlisted',
        'title': 'Channel1',
        'assetid': '204558915991',
        'section': 'ProgramAsset8',
        'tv': 'true',
        'adModel': '0',
        'dataSrc': 'cms'
    });
</syntaxhighlight>
2. <code>setplayheadposition</code> - This event is used to send the current playhead position to the Nielsen SDK. This event should be called when the video is playing.
<syntaxhighlight lang="javascript">
    instance.ggPM('setplayheadposition', 10);
</syntaxhighlight>
3. <code>end</code> - This event is used to send the end event to the Nielsen SDK. This event should be called when the video playback is finished, passing the playhead at that time.
<syntaxhighlight lang="javascript">
    instance.ggPM('end', 300);
</syntaxhighlight>
4. <code>pause</code> - This event is used to send the pause event to the Nielsen SDK. This event should be called when the video is paused, passing the playhead at that time.
<syntaxhighlight lang="javascript">
    instance.ggPM('pause', 15);
</syntaxhighlight>
5. <code>play</code> - This event is used to send the play event to the Nielsen SDK. This event should be called when the video is played; often used when resuming from pause, passing the playhead at that time.
<syntaxhighlight lang="javascript">
    instance.ggPM('play', 30);
</syntaxhighlight>
6. <code>stop</code> - This event is used to send the stop event to the Nielsen SDK. This event should be called when transitioning from ads to content and content to ads, passing the playhead at that time.
<syntaxhighlight lang="javascript">
    instance.ggPM('stop', 120);
</syntaxhighlight>
7. <code>sendid3</code> - This event is used to send the id3 event to the Nielsen SDK. This event should be called when the id3 event is triggered, passing the id3 data from the stream.
<syntaxhighlight lang="javascript">
    instance.ggPM('sendid3', '<id3 metadata received>');
</syntaxhighlight>
<nowiki>###</nowiki> Events that can be passed to and processed by <code>processEvent</code> method
1. <code>`Blur`</code> - This event should be passed to processEvent when the app goes to the background.
<syntaxhighlight lang="javascript">
    instance.processEvent({'type': 'Blur', 'timestamp': Date.now()});
</syntaxhighlight>
2. <code>`Focus`</code> - This event should be passed to processEvent when the app goes to the foreground.
<syntaxhighlight lang="javascript">
    instance.processEvent({'type': 'Focus', 'timestamp': Date.now()});
</syntaxhighlight>
3. <code>`AppClose`</code> - This event should be passed prior to closing the app.
<syntaxhighlight lang="javascript">
    instance.processEvent({'type': 'AppClose', 'timestamp': Date.now()});
</syntaxhighlight>


=== DOM-less SDK DCR Video Step 4 - Basic Set of Events - Sample Playback ===
=== DOM-less SDK DCR Video Step 4 - Basic Set of Events - Sample Playback ===

Revision as of 20:22, 24 July 2024

DOM-less SDK DCR Video Introduction

The Nielsen DOM-less SDK is a Javascript based cross-platform library that clients can use to integrate the Nielsen Digital Content Rating or Digital TV Rating measurement in ReactNative or NodeJS apps.

The Digital Content Ratings (DCR) Video product provides content consumption measurement on client mobile apps or webpages. This measurement includes insight into the total time a user spent watching the tracked content, video player events, and much more. This example provides the steps to implement the DCR Video product in a sample NodeJS app. It includes:

  • DOM-less SDK Initialization
  • DCR Video Metadata: information about the content being tracked
  • DCR Video Events/API calls

By the end of this guide you will have the needed steps to integrate Nielsen's DOM-less SDK in your app.

DOM-less SDK DCR Video Step 1 - Obtain AppID

To begin using the DOM-less SDK you will need to obtain an Application ID (AppId)

Item Description Source
App ID (appid) Unique ID assigned to the player/site and configured by product Contact your Nielsen TAM

The appid is a 37 character unique ID assigned to the player/site and configured by product and is required when creating a new instance of the DOM-less SDK on the app.

Example: PXXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXX

DOM-less SDK DCR Video Step 2 - SDK Initialization

This project is an API that allows clients to integrate the Nielsen SDK in DOM-less environments like React Native, NodeJS, etc.

Installation

Install with npm install https://github.com/NielsenDigitalSDK??????????????? and import the BsdkInstance into video player component

 `import { BsdkInstance } from 'bsdk-domless'
status.ok()

Initialization of the instance can be done with status.ok() function or use Promise handling approach

const instance = await new BsdkInstance(appID, instanceName, instanceMetadata, implementationHooks);

if (instance && instance.status.ok()) {

    expect(instance).not.toBe(undefined);

    expect(instance.status.ok()).toBe(true);

}

Exposed Interface

The exposed interface is as follows:

1. `ggPM` - method to send messages to the Nielsen SDK

2. `processEvent` - method to send app state to the Nielsen SDK, e.g., Focus, Blur, AppClose

SDK Initialization

The following table contains the list of arguments that can be passed

Parameter / Argument Description Source Required? Example
appid Unique Nielsen ID for the application. The ID is a GUID data type. If you did not receive your App ID, let us know and we will provide you. Nielsen-specified Yes PXXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
instanceName DOM-less SDK instance name Client provided Yes String eg. abcdefg
appName Application name Client provided Yes appName: 'BSDK RN Sample App'
deviceId Device ID Client provided Yes deviceId: '38400000-8cf0-11bd-b23e-10b96e40000d'
nol_sdkDebug Enables Nielsen console logging. Only required for testing Client-provided No nol_sdkDebug: 'debug'
domlessEnv Specify the domless environment.

"1" for ReactNative "2" for Amazon "3" for NodeJS "4" for Custom

Client-provided Yes domlessEnv: '1'

DOM-less SDK DCR Video Step 3 - Create DCR Video Content Metadata Object

Events that can be passed to `ggPM` method

1. loadmetadata - This event is used to send DCR Video metadata to the Nielsen SDK. This event should be called when the video metadata is loaded.

    instance.ggPM('loadmetadata', {

        'type': 'content',

        'length': '300',

        'censuscategory': 'Enlisted',

        'title': 'Channel1',

        'assetid': '204558915991',

        'section': 'ProgramAsset8',

        'tv': 'true',

        'adModel': '0',

        'dataSrc': 'cms'

    });


2. setplayheadposition - This event is used to send the current playhead position to the Nielsen SDK. This event should be called when the video is playing.

    instance.ggPM('setplayheadposition', 10);


3. end - This event is used to send the end event to the Nielsen SDK. This event should be called when the video playback is finished, passing the playhead at that time.

    instance.ggPM('end', 300);


4. pause - This event is used to send the pause event to the Nielsen SDK. This event should be called when the video is paused, passing the playhead at that time.

    instance.ggPM('pause', 15);


5. play - This event is used to send the play event to the Nielsen SDK. This event should be called when the video is played; often used when resuming from pause, passing the playhead at that time.

    instance.ggPM('play', 30);


6. stop - This event is used to send the stop event to the Nielsen SDK. This event should be called when transitioning from ads to content and content to ads, passing the playhead at that time.

    instance.ggPM('stop', 120);


7. sendid3 - This event is used to send the id3 event to the Nielsen SDK. This event should be called when the id3 event is triggered, passing the id3 data from the stream.

    instance.ggPM('sendid3', '<id3 metadata received>');


### Events that can be passed to and processed by processEvent method

1. `Blur` - This event should be passed to processEvent when the app goes to the background.

    instance.processEvent({'type': 'Blur', 'timestamp': Date.now()});

2. `Focus` - This event should be passed to processEvent when the app goes to the foreground.

    instance.processEvent({'type': 'Focus', 'timestamp': Date.now()});

3. `AppClose` - This event should be passed prior to closing the app.

    instance.processEvent({'type': 'AppClose', 'timestamp': Date.now()});


DOM-less SDK DCR Video Step 4 - Basic Set of Events - Sample Playback