Skip to content

Commit 23155d0

Browse files
brennanbriemcnallyBrie
authored
[DEST-1703] Nielsen DTVR Feature Updates/Bump to v1.0.0 (#420)
* [Nielsen DTVR] Only send events to DTVR when load_type is linear. * [Nielsen DTVR] Bump Nielsen to version 1.0.0 and add release history. * [Nielsen DTVR] Correct HISTORY.md. * [Nielsen DTVR] Add parameter for recoverable interrupts. * [Nielsen DTVR] Add beta flag. * Remove beta flag for RT Co-authored-by: Brie McNally <31782219+briemcnally@users.noreply.github.com> Co-authored-by: Brie <brienne.mcnally@segment.com>
1 parent 8af674d commit 23155d0

File tree

4 files changed

+77
-86
lines changed

4 files changed

+77
-86
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
1.0.0 / 2020-05-18
2+
==================
3+
4+
* Events are mapped to Nielsen DTVR only when `load_type` property is 'linear'.
5+
6+
0.0.4 / 2020-01-07
7+
==================
8+
9+
* Sends unix timestamp in seconds (rather than milliseconds) when livestreams end.
10+
11+
0.0.3 / 2019-09-03
12+
==================
13+
14+
* Supports loading Nielsen tag via `https`.
15+
16+
0.0.2 / 2019-07-15
17+
==================
18+
19+
* Fixes casing issue preventing customers from choosing a custom key name for mapping `ID3` tag properties.
20+
21+
0.0.1 / 2019-07-11
22+
==================
23+
24+
* Initial scaffold :sparkles:

integrations/nielsen-dtvr/lib/index.js

Lines changed: 37 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ NielsenDTVR.prototype.initialize = function() {
4141
var config = {};
4242
this.ID3 = null;
4343
this.previousEvent = null;
44+
this.isDTVRStream = false;
4445

4546
// Modified Nielsen snippet. It shouldn't load the Nielsen tag, but it should
4647
// still successfully queue events fired before the tag loads.
@@ -136,107 +137,52 @@ NielsenDTVR.prototype.videoContentStarted = function(track) {
136137

137138
/**
138139
* Video Content Completed
140+
* Video Playback Completed
139141
*
140142
* @api public
141143
*/
142144

143-
NielsenDTVR.prototype.videoContentCompleted = function(track) {
145+
NielsenDTVR.prototype.videoContentCompleted = NielsenDTVR.prototype.videoPlaybackCompleted = function(
146+
track
147+
) {
148+
if (!this.isDTVRStream) return;
144149
this.end(track);
145150
};
146151

147152
/**
148153
* Video Playback Interrupted
149-
*
150-
* @api public
151-
*/
152-
153-
NielsenDTVR.prototype.videoPlaybackInterrupted = function(track) {
154-
this.sendID3(track);
155-
this.end(track);
156-
};
157-
158-
/**
159154
* Video Playback Seek Started
160-
*
161-
* @api public
162-
*/
163-
164-
NielsenDTVR.prototype.videoPlaybackSeekStarted = function(track) {
165-
this.sendID3(track);
166-
this.end(track);
167-
};
168-
169-
/**
170-
* Video Playback Seek Completed
171-
*
172-
* @api public
173-
*/
174-
175-
NielsenDTVR.prototype.videoPlaybackSeekCompleted = function(track) {
176-
var metadata = this.mapMetadata(track);
177-
if (!metadata) return;
178-
this.client.ggPM('loadMetadata', metadata);
179-
this.sendID3(track);
180-
};
181-
182-
/**
183155
* Video Playback Buffer Started
184-
*
185-
* @api public
186-
*/
187-
188-
NielsenDTVR.prototype.videoPlaybackBufferStarted = function(track) {
189-
this.sendID3(track);
190-
this.end(track);
191-
};
192-
193-
/**
194-
* Video Playback Buffer Completed
195-
*
196-
* @api public
197-
*/
198-
199-
NielsenDTVR.prototype.videoPlaybackBufferCompleted = function(track) {
200-
var metadata = this.mapMetadata(track);
201-
if (!metadata) return;
202-
this.client.ggPM('loadMetadata', metadata);
203-
this.sendID3(track);
204-
};
205-
206-
/**
207156
* Video Playback Paused
208157
*
209158
* @api public
210159
*/
211160

212-
NielsenDTVR.prototype.videoPlaybackPaused = function(track) {
161+
NielsenDTVR.prototype.videoPlaybackInterrupted = NielsenDTVR.prototype.videoPlaybackSeekStarted = NielsenDTVR.prototype.videoPlaybackBufferStarted = NielsenDTVR.prototype.videoPlaybackPaused = function(
162+
track
163+
) {
164+
if (!this.isDTVRStream) return;
213165
this.sendID3(track);
214-
this.end(track);
166+
this.end(track, 'recoverable');
215167
};
216168

217169
/**
170+
* Video Playback Seek Completed
171+
* Video Playback Buffer Completed
218172
* Video Playback Resumed
219173
*
220174
* @api public
221175
*/
222176

223-
NielsenDTVR.prototype.videoPlaybackResumed = function(track) {
177+
NielsenDTVR.prototype.videoPlaybackSeekCompleted = NielsenDTVR.prototype.videoPlaybackBufferCompleted = NielsenDTVR.prototype.videoPlaybackResumed = function(
178+
track
179+
) {
224180
var metadata = this.mapMetadata(track);
225-
if (!metadata) return;
181+
if (!metadata || !this.isDTVRStream) return;
226182
this.client.ggPM('loadMetadata', metadata);
227183
this.sendID3(track);
228184
};
229185

230-
/**
231-
* Video Playback Completed
232-
*
233-
* @api public
234-
*/
235-
236-
NielsenDTVR.prototype.videoPlaybackCompleted = function(track) {
237-
this.end(track);
238-
};
239-
240186
/**
241187
* Send ID3 tags to Nielsen
242188
*
@@ -277,7 +223,7 @@ NielsenDTVR.prototype.sendID3 = function(event) {
277223
* @api private
278224
*/
279225

280-
NielsenDTVR.prototype.end = function(event) {
226+
NielsenDTVR.prototype.end = function(event, interruptType) {
281227
var livestream = event.proxy('properties.livestream');
282228
var position = event.proxy('properties.position');
283229
var time;
@@ -291,8 +237,11 @@ NielsenDTVR.prototype.end = function(event) {
291237
this.client.ggPM('end', time);
292238
}
293239

294-
this.ID3 = null;
295-
this.previousEvent = null;
240+
if (interruptType !== 'recoverable') {
241+
this.ID3 = null;
242+
this.previousEvent = null;
243+
this.isDTVRStream = null;
244+
}
296245
};
297246

298247
/**
@@ -325,19 +274,25 @@ function validate(metadata) {
325274
*/
326275

327276
NielsenDTVR.prototype.mapMetadata = function(event) {
328-
var adModel;
329277
var loadType =
330-
event.proxy('properties.loadType') || event.proxy('properties.load_type');
331-
332-
if (loadType === 'linear') {
333-
adModel = '1';
334-
} else if (loadType === 'dynamic') {
335-
adModel = '2';
278+
event.proxy('properties.loadType') ||
279+
event.proxy('properties.load_type') ||
280+
event.proxy('properties.content.loadType') ||
281+
event.proxy('properties.content.load_type');
282+
283+
// only video streams of load_type "linear" should be mapped to Nielsen DTVR
284+
// we need to persist the fact that a stream is/isn't a DTVR stream for events
285+
// that may not contain a `load_type` k:v pair, such as "Video Playback" events
286+
if (loadType !== 'linear') {
287+
this.isDTVRStream = false;
288+
return false;
336289
}
337290

291+
this.isDTVRStream = true;
292+
338293
return validate({
339294
type: 'content',
340295
channelName: event.proxy('properties.channel'),
341-
adModel: adModel
296+
adModel: '1'
342297
});
343298
};

integrations/nielsen-dtvr/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@segment/analytics.js-integration-nielsen-dtvr",
33
"description": "The Nielsen DTVR analytics.js integration.",
4-
"version": "0.0.4",
4+
"version": "1.0.0",
55
"keywords": [
66
"analytics.js",
77
"analytics.js-integration",

integrations/nielsen-dtvr/test/index.test.js

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ describe('NielsenDTVR', function() {
9090
beforeEach(function(done) {
9191
analytics.once('ready', done);
9292
analytics.initialize();
93+
analytics.track('Video Content Started', { load_type: 'linear' });
9394
});
9495

9596
describe('options', function() {
@@ -224,7 +225,7 @@ describe('NielsenDTVR', function() {
224225
asset_id: '123',
225226
ad_asset_id: null,
226227
channel: 'segment',
227-
load_type: 'dynamic',
228+
load_type: 'linear',
228229
position: 1,
229230
id3: '1',
230231
livestream: false
@@ -241,17 +242,28 @@ describe('NielsenDTVR', function() {
241242
analytics.called(nielsenDTVR.client.ggPM, 'loadMetadata', {
242243
type: 'content',
243244
channelName: 'segment',
244-
adModel: '2'
245+
adModel: '1'
245246
});
246247
analytics.called(nielsenDTVR.client.ggPM, 'sendID3', props.id3);
247248
});
248249

250+
it('should NOT send video content started if `load_type` is `dynamic`', function() {
251+
props.load_type = 'dynamic';
252+
analytics.track('Video Content Started', props);
253+
analytics.didNotCall(nielsenDTVR.client.ggPM, 'loadMetadata', {
254+
type: 'content',
255+
channelName: 'segment',
256+
adModel: '1'
257+
});
258+
analytics.didNotCall(nielsenDTVR.client.ggPM, 'sendID3', props.id3);
259+
});
260+
249261
it('should call end before starting a new content stream if the previous stream was not ended correctly', function() {
250262
var previousEvent = {
251263
asset_id: '123',
252264
ad_asset_id: null,
253265
channel: 'segment',
254-
load_type: 'dynamic',
266+
load_type: 'linear',
255267
position: 1,
256268
id3: '1',
257269
livestream: true

0 commit comments

Comments
 (0)