Skip to content

Commit 1fbdf04

Browse files
lu-ruoPedro López Jiménez
authored and
Pedro López Jiménez
committed
support image pixel type for user sync (prebid#3326)
1 parent 39c6baf commit 1fbdf04

File tree

2 files changed

+56
-19
lines changed

2 files changed

+56
-19
lines changed

modules/openxBidAdapter.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {parse} from 'src/url';
88
const SUPPORTED_AD_TYPES = [BANNER, VIDEO];
99
const BIDDER_CODE = 'openx';
1010
const BIDDER_CONFIG = 'hb_pb';
11-
const BIDDER_VERSION = '2.1.5';
11+
const BIDDER_VERSION = '2.1.6';
1212

1313
let shouldSendBoPixel = true;
1414

@@ -55,12 +55,13 @@ export const spec = {
5555
: createBannerBidResponses(oxResponseObj, serverRequest.payload);
5656
},
5757
getUserSyncs: function (syncOptions, responses) {
58-
if (syncOptions.iframeEnabled) {
58+
if (syncOptions.iframeEnabled || syncOptions.pixelEnabled) {
59+
let pixelType = syncOptions.iframeEnabled ? 'iframe' : 'image';
5960
let url = utils.deepAccess(responses, '0.body.ads.pixels') ||
6061
utils.deepAccess(responses, '0.body.pixels') ||
6162
'//u.openx.net/w/1.0/pd';
6263
return [{
63-
type: 'iframe',
64+
type: pixelType,
6465
url: url
6566
}];
6667
}

test/spec/modules/openxBidAdapter_spec.js

Lines changed: 52 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1450,28 +1450,64 @@ describe('OpenxAdapter', function () {
14501450
describe('user sync', function () {
14511451
const syncUrl = 'http://testpixels.net';
14521452

1453-
it('should register the pixel iframe from banner ad response', function () {
1454-
let syncs = spec.getUserSyncs(
1455-
{iframeEnabled: true},
1456-
[{body: {ads: {pixels: syncUrl}}}]
1457-
);
1458-
expect(syncs).to.deep.equal([{type: 'iframe', url: syncUrl}]);
1453+
describe('iframe sync', function () {
1454+
it('should register the pixel iframe from banner ad response', function () {
1455+
let syncs = spec.getUserSyncs(
1456+
{iframeEnabled: true},
1457+
[{body: {ads: {pixels: syncUrl}}}]
1458+
);
1459+
expect(syncs).to.deep.equal([{type: 'iframe', url: syncUrl}]);
1460+
});
1461+
1462+
it('should register the pixel iframe from video ad response', function () {
1463+
let syncs = spec.getUserSyncs(
1464+
{iframeEnabled: true},
1465+
[{body: {pixels: syncUrl}}]
1466+
);
1467+
expect(syncs).to.deep.equal([{type: 'iframe', url: syncUrl}]);
1468+
});
1469+
1470+
it('should register the default iframe if no pixels available', function () {
1471+
let syncs = spec.getUserSyncs(
1472+
{iframeEnabled: true},
1473+
[]
1474+
);
1475+
expect(syncs).to.deep.equal([{type: 'iframe', url: '//u.openx.net/w/1.0/pd'}]);
1476+
});
14591477
});
14601478

1461-
it('should register the pixel iframe from video ad response', function () {
1462-
let syncs = spec.getUserSyncs(
1463-
{iframeEnabled: true},
1464-
[{body: {pixels: syncUrl}}]
1465-
);
1466-
expect(syncs).to.deep.equal([{type: 'iframe', url: syncUrl}]);
1479+
describe('pixel sync', function () {
1480+
it('should register the image pixel from banner ad response', function () {
1481+
let syncs = spec.getUserSyncs(
1482+
{pixelEnabled: true},
1483+
[{body: {ads: {pixels: syncUrl}}}]
1484+
);
1485+
expect(syncs).to.deep.equal([{type: 'image', url: syncUrl}]);
1486+
});
1487+
1488+
it('should register the image pixel from video ad response', function () {
1489+
let syncs = spec.getUserSyncs(
1490+
{pixelEnabled: true},
1491+
[{body: {pixels: syncUrl}}]
1492+
);
1493+
expect(syncs).to.deep.equal([{type: 'image', url: syncUrl}]);
1494+
});
1495+
1496+
it('should register the default image pixel if no pixels available', function () {
1497+
let syncs = spec.getUserSyncs(
1498+
{pixelEnabled: true},
1499+
[]
1500+
);
1501+
expect(syncs).to.deep.equal([{type: 'image', url: '//u.openx.net/w/1.0/pd'}]);
1502+
});
14671503
});
14681504

1469-
it('should register the default iframe if no pixels available', function () {
1505+
it('should prioritize iframe over image for user sync', function () {
14701506
let syncs = spec.getUserSyncs(
1471-
{iframeEnabled: true},
1472-
[]
1507+
{iframeEnabled: true, pixelEnabled: true},
1508+
[{body: {ads: {pixels: syncUrl}}}]
14731509
);
1474-
expect(syncs).to.deep.equal([{type: 'iframe', url: '//u.openx.net/w/1.0/pd'}]);
1510+
expect(syncs).to.deep.equal([{type: 'iframe', url: syncUrl}]);
14751511
});
14761512
});
14771513

0 commit comments

Comments
 (0)