Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JW Player RTD Adapter: 9.0 migration #11692

Merged
merged 4 commits into from
Jun 4, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions modules/jwplayerRtdProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,7 @@ const playlistItemCache = {};
const pendingRequests = {};
let activeRequestCount = 0;
let resumeBidRequest;
// defaults to 'always' for backwards compatibility
// TODO: Prebid 9 - replace with ENRICH_WHEN_EMPTY
let overrideContentId = ENRICH_ALWAYS;
let overrideContentId = ENRICH_WHEN_EMPTY;
let overrideContentUrl = ENRICH_WHEN_EMPTY;
let overrideContentTitle = ENRICH_WHEN_EMPTY;
let overrideContentDescription = ENRICH_WHEN_EMPTY;
Expand Down Expand Up @@ -83,9 +81,7 @@ export function fetchTargetingInformation(jwTargeting) {
}

export function setOverrides(params) {
// For backwards compatibility, default to always unless overridden by Publisher.
// TODO: Prebid 9 - replace with ENRICH_WHEN_EMPTY
overrideContentId = sanitizeOverrideParam(params.overrideContentId, ENRICH_ALWAYS);
overrideContentId = sanitizeOverrideParam(params.overrideContentId, ENRICH_WHEN_EMPTY);
overrideContentUrl = sanitizeOverrideParam(params.overrideContentUrl, ENRICH_WHEN_EMPTY);
overrideContentTitle = sanitizeOverrideParam(params.overrideContentTitle, ENRICH_WHEN_EMPTY);
overrideContentDescription = sanitizeOverrideParam(params.overrideContentDescription, ENRICH_WHEN_EMPTY);
Expand Down
2 changes: 1 addition & 1 deletion modules/jwplayerRtdProvider.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ realTimeData = {
| waitForIt | Boolean | Required to ensure that the auction is delayed until prefetch is complete | Optional. Defaults to false |
| params | Object | | |
| params.mediaIDs | Array of Strings | Media Ids for prefetching | Optional |
| params.overrideContentId | String enum: 'always', 'whenEmpty' or 'never' | Determines when the module should update the oRTB site.content.id | Defaults to 'always' |
| params.overrideContentId | String enum: 'always', 'whenEmpty' or 'never' | Determines when the module should update the oRTB site.content.id | Defaults to 'whenEmpty' |
| params.overrideContentUrl | String enum: 'always', 'whenEmpty' or 'never' | Determines when the module should update the oRTB site.content.url | Defaults to 'whenEmpty' |
| params.overrideContentTitle | String enum: 'always', 'whenEmpty' or 'never' | Determines when the module should update the oRTB site.content.title | Defaults to 'whenEmpty' |
| params.overrideContentDescription | String enum: 'always', 'whenEmpty' or 'never' | Determines when the module should update the oRTB site.content.ext.description | Defaults to 'whenEmpty' |
Expand Down
17 changes: 8 additions & 9 deletions test/spec/modules/jwplayerRtdProvider_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -629,7 +629,7 @@ describe('jwplayerRtdProvider', function() {

expect(ortb2Fragments.global).to.have.property('site');
expect(ortb2Fragments.global.site).to.have.property('content');
expect(ortb2Fragments.global.site.content).to.have.property('id', 'jw_' + testIdForSuccess);
expect(ortb2Fragments.global.site.content).to.have.property('id', 'randomContentId');
expect(ortb2Fragments.global.site.content).to.have.property('data');
const data = ortb2Fragments.global.site.content.data;
expect(data).to.have.length(3);
Expand Down Expand Up @@ -801,7 +801,7 @@ describe('jwplayerRtdProvider', function() {
describe(' Add Ortb Site Content', function () {
beforeEach(() => {
setOverrides({
overrideContentId: 'always',
overrideContentId: 'whenEmpty',
overrideContentUrl: 'whenEmpty',
overrideContentTitle: 'whenEmpty',
overrideContentDescription: 'whenEmpty'
Expand Down Expand Up @@ -865,16 +865,16 @@ describe('jwplayerRtdProvider', function() {
}
};

const expectedId = 'expectedId';
const newId = 'newId';
const expectedUrl = 'expectedUrl';
const expectedTitle = 'expectedTitle';
const expectedDescription = 'expectedDescription';
const expectedData = { datum: 'datum' };
addOrtbSiteContent(ortb2, expectedId, expectedData, expectedTitle, expectedDescription, expectedUrl);
addOrtbSiteContent(ortb2, newId, expectedData, expectedTitle, expectedDescription, expectedUrl);
expect(ortb2).to.have.nested.property('site.random.random_sub', 'randomSub');
expect(ortb2).to.have.nested.property('app.content.id', 'appId');
expect(ortb2).to.have.nested.property('site.content.ext.random_field', 'randomField');
expect(ortb2).to.have.nested.property('site.content.id', expectedId);
expect(ortb2).to.have.nested.property('site.content.id', 'oldId');
expect(ortb2).to.have.nested.property('site.content.url', expectedUrl);
expect(ortb2).to.have.nested.property('site.content.title', expectedTitle);
expect(ortb2).to.have.nested.property('site.content.ext.description', expectedDescription);
Expand All @@ -889,7 +889,7 @@ describe('jwplayerRtdProvider', function() {
expect(ortb2).to.have.nested.property('site.content.id', expectedId);
});

it('should override content id by default', function () {
it('should keep old content id by default', function () {
const ortb2 = {
site: {
content: {
Expand All @@ -898,9 +898,8 @@ describe('jwplayerRtdProvider', function() {
}
};

const expectedId = 'expectedId';
addOrtbSiteContent(ortb2, expectedId);
expect(ortb2).to.have.nested.property('site.content.id', expectedId);
addOrtbSiteContent(ortb2, 'newId');
expect(ortb2).to.have.nested.property('site.content.id', 'oldId');
});

it('should keep previous content id when new value is not available', function () {
Expand Down