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

Audience Network: add 'cb' and 'pbv' query params #2252

Merged
merged 1 commit into from
Mar 17, 2018
Merged
Show file tree
Hide file tree
Changes from all 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
9 changes: 7 additions & 2 deletions modules/audienceNetworkBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import { registerBidder } from 'src/adapters/bidderFactory';
import { config } from 'src/config';
import { formatQS } from 'src/url';
import { getTopWindowUrl } from 'src/utils';
import { generateUUID, getTopWindowUrl, isSafariBrowser } from 'src/utils';
import findIndex from 'core-js/library/fn/array/find-index';
import includes from 'core-js/library/fn/array/includes';

Expand All @@ -15,6 +15,7 @@ const url = 'https://an.facebook.com/v2/placementbid.json';
const supportedMediaTypes = ['banner', 'video'];
const netRevenue = true;
const hb_bidder = 'fan';
const pbv = '$prebid.version$';

/**
* Does this bid request contain valid parameters?
Expand Down Expand Up @@ -164,12 +165,16 @@ const buildRequests = bids => {
adformats,
testmode,
pageurl,
sdk
sdk,
pbv
};
const video = findIndex(adformats, isVideo);
if (video !== -1) {
[search.playerwidth, search.playerheight] = expandSize(sizes[video]);
}
if (isSafariBrowser()) {
search.cb = generateUUID();
}
const data = formatQS(search);

return [{ adformats, data, method, requestIds, sizes, url }];
Expand Down
29 changes: 25 additions & 4 deletions test/spec/modules/audienceNetworkBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ const placementId = 'test-placement-id';
const playerwidth = 320;
const playerheight = 180;
const requestId = 'test-request-id';
const pbv = '$prebid.version$';

describe('AudienceNetwork adapter', () => {
describe('Public API', () => {
Expand Down Expand Up @@ -128,7 +129,7 @@ describe('AudienceNetwork adapter', () => {
requestIds: [requestId],
sizes: ['300x250'],
url: 'https://an.facebook.com/v2/placementbid.json',
data: 'placementids[]=test-placement-id&adformats[]=300x250&testmode=false&pageurl=&sdk[]=5.5.web'
data: `placementids[]=test-placement-id&adformats[]=300x250&testmode=false&pageurl=&sdk[]=5.5.web&pbv=${pbv}`
}]);
});

Expand All @@ -147,7 +148,7 @@ describe('AudienceNetwork adapter', () => {
requestIds: [requestId],
sizes: ['640x480'],
url: 'https://an.facebook.com/v2/placementbid.json',
data: 'placementids[]=test-placement-id&adformats[]=video&testmode=false&pageurl=&sdk[]=&playerwidth=640&playerheight=480'
data: `placementids[]=test-placement-id&adformats[]=video&testmode=false&pageurl=&sdk[]=&pbv=${pbv}&playerwidth=640&playerheight=480`
}]);
});

Expand All @@ -166,7 +167,7 @@ describe('AudienceNetwork adapter', () => {
requestIds: [requestId],
sizes: ['728x90'],
url: 'https://an.facebook.com/v2/placementbid.json',
data: 'placementids[]=test-placement-id&adformats[]=native&testmode=false&pageurl=&sdk[]=5.5.web'
data: `placementids[]=test-placement-id&adformats[]=native&testmode=false&pageurl=&sdk[]=5.5.web&pbv=${pbv}`
}]);
});

Expand All @@ -185,9 +186,29 @@ describe('AudienceNetwork adapter', () => {
requestIds: [requestId],
sizes: ['300x250'],
url: 'https://an.facebook.com/v2/placementbid.json',
data: 'placementids[]=test-placement-id&adformats[]=fullwidth&testmode=false&pageurl=&sdk[]=5.5.web'
data: `placementids[]=test-placement-id&adformats[]=fullwidth&testmode=false&pageurl=&sdk[]=5.5.web&pbv=${pbv}`
}]);
});

it('can build URL on Safari that includes a cachebuster param', () => {
const { userAgent } = navigator;
Object.defineProperty(navigator, 'userAgent', {
value: 'safari',
writable: true
});

expect(buildRequests([{
bidder,
bidId: requestId,
sizes: [[300, 250]],
params: { placementId }
}])[0].data).to.contain('&cb=');

Object.defineProperty(navigator, 'userAgent', {
value: userAgent,
writable: false
});
});
});

describe('interpretResponse', () => {
Expand Down