Skip to content

Commit

Permalink
QC adapter. support usersyncs
Browse files Browse the repository at this point in the history
  • Loading branch information
SleimanJneidi committed Mar 3, 2020
1 parent bd5408c commit 55d147f
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 2 deletions.
18 changes: 18 additions & 0 deletions modules/quantcastBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import * as utils from '../src/utils.js';
import { ajax } from '../src/ajax.js';
import { config } from '../src/config.js';
import { registerBidder } from '../src/adapters/bidderFactory.js';
import find from 'core-js/library/fn/array/find.js';

const BIDDER_CODE = 'quantcast';
const DEFAULT_BID_FLOOR = 0.0000000001;
Expand Down Expand Up @@ -221,6 +222,23 @@ export const spec = {
onTimeout(timeoutData) {
const url = `${QUANTCAST_PROTOCOL}://${QUANTCAST_DOMAIN}:${QUANTCAST_PORT}/qchb_notify?type=timeout`;
ajax(url, null, null);
},
getUserSyncs(syncOptions, serverResponses) {
const syncs = []
if (syncOptions.pixelEnabled) {
const responseWithUrl = find(serverResponses, serverResponse =>
utils.deepAccess(serverResponse.body, 'userSync.url')
);

if (responseWithUrl) {
const url = utils.deepAccess(responseWithUrl.body, 'userSync.url')
syncs.push({
type: 'image',
url: url
});
}
}
return syncs;
}
};

Expand Down
10 changes: 8 additions & 2 deletions modules/quantcastBidAdapter.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@ const adUnits = [{
battr: [1, 2] // OPTIONAL - Array of blocked creative attributes as per OpenRTB Spec List 5.3
}
}
]
],
userSync: {
url: 'https://quantcast.com/pixelUrl'
}
}];
```

Expand Down Expand Up @@ -63,6 +66,9 @@ var adUnits = [{
}
}
}
]
],
userSync: {
url: 'https://quantcast.com/pixelUrl'
}
}];
```
28 changes: 28 additions & 0 deletions test/spec/modules/quantcastBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -492,5 +492,33 @@ describe('Quantcast adapter', function () {

expect(interpretedResponse.length).to.equal(0);
});

it('should return pixel url when available userSync available', function () {
const syncOptions = {
pixelEnabled: true
};
const serverResponses = [
{
body: {
userSync: {
url: 'http://quantcast.com/pixelUrl'
}
}
},
{
body: {

}
}
];

const actualSyncs = qcSpec.getUserSyncs(syncOptions, serverResponses);
const expectedSync = {
type: 'image',
url: 'http://quantcast.com/pixelUrl'
};
expect(actualSyncs.length).to.equal(1);
expect(actualSyncs[0]).to.deep.equal(expectedSync);
});
});
});

0 comments on commit 55d147f

Please sign in to comment.