From 1766eb6786cde16ff6437bdfb1de94ca4f89b91d Mon Sep 17 00:00:00 2001 From: Karim Mourra Date: Fri, 29 Apr 2022 16:49:23 +0200 Subject: [PATCH 1/2] supports cids --- modules/jwplayerRtdProvider.js | 36 ++++++++--- test/spec/modules/jwplayerRtdProvider_spec.js | 64 +++++++++++++++---- 2 files changed, 77 insertions(+), 23 deletions(-) diff --git a/modules/jwplayerRtdProvider.js b/modules/jwplayerRtdProvider.js index 814aed59d85..400ee1a5f8a 100644 --- a/modules/jwplayerRtdProvider.js +++ b/modules/jwplayerRtdProvider.js @@ -155,8 +155,10 @@ export function enrichAdUnits(adUnits) { if (!vat) { return; } - const contentId = getContentId(vat.mediaID); - const contentData = getContentData(vat.segments); + const mediaId = vat.mediaID; + const contentId = getContentId(mediaId); + const contentSegments = getContentSegments(vat.segments); + const contentData = getContentData(mediaId, contentSegments); const targeting = formatTargetingResponse(vat); enrichBids(adUnit.bids, targeting, contentId, contentData); }; @@ -263,7 +265,7 @@ export function getContentId(mediaID) { return 'jw_' + mediaID; } -export function getContentData(segments) { +export function getContentSegments(segments) { if (!segments || !segments.length) { return; } @@ -276,13 +278,29 @@ export function getContentData(segments) { return convertedSegments; }, []); - return { - name: 'jwplayer', - ext: { - segtax: 502 - }, - segment: formattedSegments + return formattedSegments; +} + +export function getContentData(mediaId, segments) { + if (!mediaId && !segments) { + return; + } + + const contentData = { + name: 'jwplayer.com', + ext: {} }; + + if (mediaId) { + contentData.ext.cids = [mediaId]; + } + + if (segments) { + contentData.segment = segments; + contentData.ext.segtax = 502; + } + + return contentData; } export function addOrtbSiteContent(bid, contentId, contentData) { diff --git a/test/spec/modules/jwplayerRtdProvider_spec.js b/test/spec/modules/jwplayerRtdProvider_spec.js index db17d18864b..0775676aefe 100644 --- a/test/spec/modules/jwplayerRtdProvider_spec.js +++ b/test/spec/modules/jwplayerRtdProvider_spec.js @@ -1,6 +1,6 @@ import { fetchTargetingForMediaId, getVatFromCache, extractPublisherParams, formatTargetingResponse, getVatFromPlayer, enrichAdUnits, addTargetingToBid, - fetchTargetingInformation, jwplayerSubmodule, getContentId, getContentData } from 'modules/jwplayerRtdProvider.js'; + fetchTargetingInformation, jwplayerSubmodule, getContentId, getContentSegments, getContentData } from 'modules/jwplayerRtdProvider.js'; import { server } from 'test/mocks/xhr.js'; import {addOrtbSiteContent} from '../../../modules/jwplayerRtdProvider'; @@ -498,26 +498,62 @@ describe('jwplayerRtdProvider', function() { }); }); - describe('Get Content Data', function () { + describe('Get Content Segments', function () { it('returns undefined when segments are empty', function () { - let data = getContentData(null); - expect(data).to.be.undefined; - data = getContentData(undefined); - expect(data).to.be.undefined; - data = getContentData([]); - expect(data).to.be.undefined; + let contentSegments = getContentSegments(null); + expect(contentSegments).to.be.undefined; + contentSegments = getContentSegments(undefined); + expect(contentSegments).to.be.undefined; + contentSegments = getContentSegments([]); + expect(contentSegments).to.be.undefined; }); it('returns proper format', function () { const segment1 = 'segment1'; const segment2 = 'segment2'; const segment3 = 'segment3'; - const data = getContentData([segment1, segment2, segment3]); - expect(data).to.have.property('name', 'jwplayer'); - expect(data.ext).to.have.property('segtax', 502); - expect(data.segment[0]).to.deep.equal({ id: segment1, value: segment1 }); - expect(data.segment[1]).to.deep.equal({ id: segment2, value: segment2 }); - expect(data.segment[2]).to.deep.equal({ id: segment3, value: segment3 }); + const contentSegments = getContentSegments([segment1, segment2, segment3]); + expect(contentSegments[0]).to.deep.equal({ id: segment1, value: segment1 }); + expect(contentSegments[1]).to.deep.equal({ id: segment2, value: segment2 }); + expect(contentSegments[2]).to.deep.equal({ id: segment3, value: segment3 }); + }); + }); + + describe('Get Content Data', function () { + it('should return proper format', function () { + const testMediaId = 'test_media_id'; + const testSegments = [{ id: 1 }, { id: 2 }]; + const contentData = getContentData(testMediaId, testSegments); + expect(contentData).to.have.property('name', 'jwplayer.com'); + expect(contentData.ext).to.have.property('segtax', 502); + expect(contentData.ext).to.have.property('cids'); + expect(contentData.ext.cids).to.have.length(1); + expect(contentData.ext.cids[0]).to.equal(testMediaId); + expect(contentData.segment).to.deep.equal(testSegments); + }); + + it('should only set segtax and segment when segments are provided', function () { + const testMediaId = 'test_media_id'; + const contentData = getContentData(testMediaId); + expect(contentData).to.have.property('name', 'jwplayer.com'); + expect(contentData.ext.segtax).to.be.undefined; + expect(contentData.ext).to.have.property('cids'); + expect(contentData.ext.cids).to.have.length(1); + expect(contentData.ext.cids[0]).to.equal(testMediaId); + expect(contentData.segment).to.be.undefined; + }); + + it('should only set cids when a media id is provided', function () { + const testSegments = [{ id: 1 }, { id: 2 }]; + const contentData = getContentData(null, testSegments); + expect(contentData).to.have.property('name', 'jwplayer.com'); + expect(contentData.ext).to.have.property('segtax', 502); + expect(contentData.ext).to.not.have.property('cids'); + expect(contentData.segment).to.deep.equal(testSegments); + }); + + it('should return undefined when no params are provided', function () { + expect(getContentData()).to.be.undefined; }); }); From c62b54a45cc52463cfa9da199fe0dd5f92f65bd4 Mon Sep 17 00:00:00 2001 From: Karim Mourra Date: Fri, 29 Apr 2022 17:13:55 +0200 Subject: [PATCH 2/2] updates documentation --- modules/jwplayerRtdProvider.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/modules/jwplayerRtdProvider.md b/modules/jwplayerRtdProvider.md index 77f65909040..479829196ed 100644 --- a/modules/jwplayerRtdProvider.md +++ b/modules/jwplayerRtdProvider.md @@ -95,9 +95,10 @@ Example: content: { id: 'jw_abc123', data: [{ - name: 'jwplayer', + name: 'jwplayer.com', ext: { - segtax: 502 + segtax: 502, + cids: ['abc123'] }, segment: [{ id: '123' @@ -117,8 +118,9 @@ where: - `content` is an object containing metadata for the media. It may contain the following information: - `id` is a unique identifier for the specific media asset - `data` is an array containing segment taxonomy objects that have the following parameters: - - `name` is the `jwplayer` string indicating the provider name + - `name` is the `jwplayer.com` string indicating the provider name - `ext.segtax` whose `502` value is the unique identifier for JW Player's proprietary taxonomy + - `ext.cids` is an array containing the list of extended content ids as defined in [oRTB's community extensions](https://github.com/InteractiveAdvertisingBureau/openrtb/blob/master/extensions/community_extensions/extended-content-ids.md#example---content-id-and-seller-defined-context). - `segment` is an array containing the segment taxonomy values as an object where: - `id` is the string representation of the data segment value.