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

support image pixel type for user sync #3326

Merged
merged 1 commit into from
Nov 28, 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
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