Skip to content

Commit

Permalink
support image pixel type for user sync (prebid#3326)
Browse files Browse the repository at this point in the history
  • Loading branch information
lu-ruo authored and Pedro López Jiménez committed Mar 18, 2019
1 parent 39c6baf commit 1fbdf04
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 19 deletions.
7 changes: 4 additions & 3 deletions modules/openxBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {parse} from 'src/url';
const SUPPORTED_AD_TYPES = [BANNER, VIDEO];
const BIDDER_CODE = 'openx';
const BIDDER_CONFIG = 'hb_pb';
const BIDDER_VERSION = '2.1.5';
const BIDDER_VERSION = '2.1.6';

let shouldSendBoPixel = true;

Expand Down Expand Up @@ -55,12 +55,13 @@ export const spec = {
: createBannerBidResponses(oxResponseObj, serverRequest.payload);
},
getUserSyncs: function (syncOptions, responses) {
if (syncOptions.iframeEnabled) {
if (syncOptions.iframeEnabled || syncOptions.pixelEnabled) {
let pixelType = syncOptions.iframeEnabled ? 'iframe' : 'image';
let url = utils.deepAccess(responses, '0.body.ads.pixels') ||
utils.deepAccess(responses, '0.body.pixels') ||
'//u.openx.net/w/1.0/pd';
return [{
type: 'iframe',
type: pixelType,
url: url
}];
}
Expand Down
68 changes: 52 additions & 16 deletions test/spec/modules/openxBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1450,28 +1450,64 @@ describe('OpenxAdapter', function () {
describe('user sync', function () {
const syncUrl = 'http://testpixels.net';

it('should register the pixel iframe from banner ad response', function () {
let syncs = spec.getUserSyncs(
{iframeEnabled: true},
[{body: {ads: {pixels: syncUrl}}}]
);
expect(syncs).to.deep.equal([{type: 'iframe', url: syncUrl}]);
describe('iframe sync', function () {
it('should register the pixel iframe from banner ad response', function () {
let syncs = spec.getUserSyncs(
{iframeEnabled: true},
[{body: {ads: {pixels: syncUrl}}}]
);
expect(syncs).to.deep.equal([{type: 'iframe', url: syncUrl}]);
});

it('should register the pixel iframe from video ad response', function () {
let syncs = spec.getUserSyncs(
{iframeEnabled: true},
[{body: {pixels: syncUrl}}]
);
expect(syncs).to.deep.equal([{type: 'iframe', url: syncUrl}]);
});

it('should register the default iframe if no pixels available', function () {
let syncs = spec.getUserSyncs(
{iframeEnabled: true},
[]
);
expect(syncs).to.deep.equal([{type: 'iframe', url: '//u.openx.net/w/1.0/pd'}]);
});
});

it('should register the pixel iframe from video ad response', function () {
let syncs = spec.getUserSyncs(
{iframeEnabled: true},
[{body: {pixels: syncUrl}}]
);
expect(syncs).to.deep.equal([{type: 'iframe', url: syncUrl}]);
describe('pixel sync', function () {
it('should register the image pixel from banner ad response', function () {
let syncs = spec.getUserSyncs(
{pixelEnabled: true},
[{body: {ads: {pixels: syncUrl}}}]
);
expect(syncs).to.deep.equal([{type: 'image', url: syncUrl}]);
});

it('should register the image pixel from video ad response', function () {
let syncs = spec.getUserSyncs(
{pixelEnabled: true},
[{body: {pixels: syncUrl}}]
);
expect(syncs).to.deep.equal([{type: 'image', url: syncUrl}]);
});

it('should register the default image pixel if no pixels available', function () {
let syncs = spec.getUserSyncs(
{pixelEnabled: true},
[]
);
expect(syncs).to.deep.equal([{type: 'image', url: '//u.openx.net/w/1.0/pd'}]);
});
});

it('should register the default iframe if no pixels available', function () {
it('should prioritize iframe over image for user sync', function () {
let syncs = spec.getUserSyncs(
{iframeEnabled: true},
[]
{iframeEnabled: true, pixelEnabled: true},
[{body: {ads: {pixels: syncUrl}}}]
);
expect(syncs).to.deep.equal([{type: 'iframe', url: '//u.openx.net/w/1.0/pd'}]);
expect(syncs).to.deep.equal([{type: 'iframe', url: syncUrl}]);
});
});

Expand Down

0 comments on commit 1fbdf04

Please sign in to comment.