Skip to content

Commit 55d147f

Browse files
committed
QC adapter. support usersyncs
1 parent bd5408c commit 55d147f

File tree

3 files changed

+54
-2
lines changed

3 files changed

+54
-2
lines changed

modules/quantcastBidAdapter.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import * as utils from '../src/utils.js';
22
import { ajax } from '../src/ajax.js';
33
import { config } from '../src/config.js';
44
import { registerBidder } from '../src/adapters/bidderFactory.js';
5+
import find from 'core-js/library/fn/array/find.js';
56

67
const BIDDER_CODE = 'quantcast';
78
const DEFAULT_BID_FLOOR = 0.0000000001;
@@ -221,6 +222,23 @@ export const spec = {
221222
onTimeout(timeoutData) {
222223
const url = `${QUANTCAST_PROTOCOL}://${QUANTCAST_DOMAIN}:${QUANTCAST_PORT}/qchb_notify?type=timeout`;
223224
ajax(url, null, null);
225+
},
226+
getUserSyncs(syncOptions, serverResponses) {
227+
const syncs = []
228+
if (syncOptions.pixelEnabled) {
229+
const responseWithUrl = find(serverResponses, serverResponse =>
230+
utils.deepAccess(serverResponse.body, 'userSync.url')
231+
);
232+
233+
if (responseWithUrl) {
234+
const url = utils.deepAccess(responseWithUrl.body, 'userSync.url')
235+
syncs.push({
236+
type: 'image',
237+
url: url
238+
});
239+
}
240+
}
241+
return syncs;
224242
}
225243
};
226244

modules/quantcastBidAdapter.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,10 @@ const adUnits = [{
2727
battr: [1, 2] // OPTIONAL - Array of blocked creative attributes as per OpenRTB Spec List 5.3
2828
}
2929
}
30-
]
30+
],
31+
userSync: {
32+
url: 'https://quantcast.com/pixelUrl'
33+
}
3134
}];
3235
```
3336

@@ -63,6 +66,9 @@ var adUnits = [{
6366
}
6467
}
6568
}
66-
]
69+
],
70+
userSync: {
71+
url: 'https://quantcast.com/pixelUrl'
72+
}
6773
}];
6874
```

test/spec/modules/quantcastBidAdapter_spec.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -492,5 +492,33 @@ describe('Quantcast adapter', function () {
492492

493493
expect(interpretedResponse.length).to.equal(0);
494494
});
495+
496+
it('should return pixel url when available userSync available', function () {
497+
const syncOptions = {
498+
pixelEnabled: true
499+
};
500+
const serverResponses = [
501+
{
502+
body: {
503+
userSync: {
504+
url: 'http://quantcast.com/pixelUrl'
505+
}
506+
}
507+
},
508+
{
509+
body: {
510+
511+
}
512+
}
513+
];
514+
515+
const actualSyncs = qcSpec.getUserSyncs(syncOptions, serverResponses);
516+
const expectedSync = {
517+
type: 'image',
518+
url: 'http://quantcast.com/pixelUrl'
519+
};
520+
expect(actualSyncs.length).to.equal(1);
521+
expect(actualSyncs[0]).to.deep.equal(expectedSync);
522+
});
495523
});
496524
});

0 commit comments

Comments
 (0)