Skip to content

Commit 6b446e6

Browse files
authored
IQzone Bid Adapter : update placement to plcmt and move coppa from getConfig (#11562)
* add IQZone adapter * add endpointId param * add user sync * added gpp support * added support of transanctionId and eids * updated tests * changed placement to plcmt
1 parent f6040c4 commit 6b446e6

File tree

2 files changed

+111
-22
lines changed

2 files changed

+111
-22
lines changed

modules/iqzoneBidAdapter.js

Lines changed: 43 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { isFn, deepAccess, logMessage } from '../src/utils.js';
1+
import { logMessage, logError, deepAccess } from '../src/utils.js';
22
import { registerBidder } from '../src/adapters/bidderFactory.js';
33
import { BANNER, NATIVE, VIDEO } from '../src/mediaTypes.js';
44
import { config } from '../src/config.js';
@@ -9,8 +9,7 @@ const AD_URL = 'https://smartssp-us-east.iqzone.com/pbjs';
99
const SYNC_URL = 'https://cs.smartssp.iqzone.com';
1010

1111
function isBidResponseValid(bid) {
12-
if (!bid.requestId || !bid.cpm || !bid.creativeId ||
13-
!bid.ttl || !bid.currency) {
12+
if (!bid.requestId || !bid.cpm || !bid.creativeId || !bid.ttl || !bid.currency) {
1413
return false;
1514
}
1615

@@ -27,7 +26,7 @@ function isBidResponseValid(bid) {
2726
}
2827

2928
function getPlacementReqData(bid) {
30-
const { params, bidId, mediaTypes } = bid;
29+
const { params, bidId, mediaTypes, transactionId, userIdAsEids } = bid;
3130
const schain = bid.schain || {};
3231
const { placementId, endpointId } = params;
3332
const bidfloor = getBidFloor(bid);
@@ -57,7 +56,7 @@ function getPlacementReqData(bid) {
5756
placement.mimes = mediaTypes[VIDEO].mimes;
5857
placement.protocols = mediaTypes[VIDEO].protocols;
5958
placement.startdelay = mediaTypes[VIDEO].startdelay;
60-
placement.placement = mediaTypes[VIDEO].placement;
59+
placement.plcmt = mediaTypes[VIDEO].plcmt;
6160
placement.skip = mediaTypes[VIDEO].skip;
6261
placement.skipafter = mediaTypes[VIDEO].skipafter;
6362
placement.minbitrate = mediaTypes[VIDEO].minbitrate;
@@ -71,23 +70,29 @@ function getPlacementReqData(bid) {
7170
placement.adFormat = NATIVE;
7271
}
7372

73+
if (transactionId) {
74+
placement.ext = placement.ext || {};
75+
placement.ext.tid = transactionId;
76+
}
77+
78+
if (userIdAsEids && userIdAsEids.length) {
79+
placement.eids = userIdAsEids;
80+
}
81+
7482
return placement;
7583
}
7684

7785
function getBidFloor(bid) {
78-
if (!isFn(bid.getFloor)) {
79-
return deepAccess(bid, 'params.bidfloor', 0);
80-
}
81-
8286
try {
8387
const bidFloor = bid.getFloor({
8488
currency: 'USD',
8589
mediaType: '*',
8690
size: '*',
8791
});
8892
return bidFloor.floor;
89-
} catch (_) {
90-
return 0
93+
} catch (err) {
94+
logError(err);
95+
return 0;
9196
}
9297
}
9398

@@ -151,12 +156,28 @@ export const spec = {
151156
host,
152157
page,
153158
placements,
154-
coppa: config.getConfig('coppa') === true ? 1 : 0,
155-
ccpa: bidderRequest.uspConsent || undefined,
156-
gdpr: bidderRequest.gdprConsent || undefined,
159+
coppa: deepAccess(bidderRequest, 'ortb2.regs.coppa') ? 1 : 0,
157160
tmax: bidderRequest.timeout
158161
};
159162

163+
if (bidderRequest.uspConsent) {
164+
request.ccpa = bidderRequest.uspConsent;
165+
}
166+
167+
if (bidderRequest.gdprConsent) {
168+
request.gdpr = {
169+
consentString: bidderRequest.gdprConsent.consentString
170+
};
171+
}
172+
173+
if (bidderRequest.gppConsent) {
174+
request.gpp = bidderRequest.gppConsent.gppString;
175+
request.gpp_sid = bidderRequest.gppConsent.applicableSections;
176+
} else if (bidderRequest.ortb2?.regs?.gpp) {
177+
request.gpp = bidderRequest.ortb2.regs.gpp;
178+
request.gpp_sid = bidderRequest.ortb2.regs.gpp_sid;
179+
}
180+
160181
const len = validBidRequests.length;
161182
for (let i = 0; i < len; i++) {
162183
const bid = validBidRequests[i];
@@ -184,20 +205,27 @@ export const spec = {
184205
return response;
185206
},
186207

187-
getUserSyncs: (syncOptions, serverResponses, gdprConsent, uspConsent) => {
208+
getUserSyncs: (syncOptions, serverResponses, gdprConsent, uspConsent, gppConsent) => {
188209
let syncType = syncOptions.iframeEnabled ? 'iframe' : 'image';
189210
let syncUrl = SYNC_URL + `/${syncType}?pbjs=1`;
211+
190212
if (gdprConsent && gdprConsent.consentString) {
191213
if (typeof gdprConsent.gdprApplies === 'boolean') {
192214
syncUrl += `&gdpr=${Number(gdprConsent.gdprApplies)}&gdpr_consent=${gdprConsent.consentString}`;
193215
} else {
194216
syncUrl += `&gdpr=0&gdpr_consent=${gdprConsent.consentString}`;
195217
}
196218
}
219+
197220
if (uspConsent && uspConsent.consentString) {
198221
syncUrl += `&ccpa_consent=${uspConsent.consentString}`;
199222
}
200223

224+
if (gppConsent?.gppString && gppConsent?.applicableSections?.length) {
225+
syncUrl += '&gpp=' + gppConsent.gppString;
226+
syncUrl += '&gpp_sid=' + gppConsent.applicableSections.join(',');
227+
}
228+
201229
const coppa = config.getConfig('coppa') ? 1 : 0;
202230
syncUrl += `&coppa=${coppa}`;
203231

test/spec/modules/iqzoneBidAdapter_spec.js

Lines changed: 68 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,16 @@ import { getUniqueIdentifierStr } from '../../../src/utils.js';
66
const bidder = 'iqzone'
77

88
describe('IQZoneBidAdapter', function () {
9+
const userIdAsEids = [{
10+
source: 'test.org',
11+
uids: [{
12+
id: '01**********',
13+
atype: 1,
14+
ext: {
15+
third: '01***********'
16+
}
17+
}]
18+
}];
919
const bids = [
1020
{
1121
bidId: getUniqueIdentifierStr(),
@@ -17,7 +27,8 @@ describe('IQZoneBidAdapter', function () {
1727
},
1828
params: {
1929
placementId: 'testBanner',
20-
}
30+
},
31+
userIdAsEids
2132
},
2233
{
2334
bidId: getUniqueIdentifierStr(),
@@ -31,7 +42,8 @@ describe('IQZoneBidAdapter', function () {
3142
},
3243
params: {
3344
placementId: 'testVideo',
34-
}
45+
},
46+
userIdAsEids
3547
},
3648
{
3749
bidId: getUniqueIdentifierStr(),
@@ -54,7 +66,8 @@ describe('IQZoneBidAdapter', function () {
5466
},
5567
params: {
5668
placementId: 'testNative',
57-
}
69+
},
70+
userIdAsEids
5871
}
5972
];
6073

@@ -73,7 +86,9 @@ describe('IQZoneBidAdapter', function () {
7386

7487
const bidderRequest = {
7588
uspConsent: '1---',
76-
gdprConsent: 'COvFyGBOvFyGBAbAAAENAPCAAOAAAAAAAAAAAEEUACCKAAA.IFoEUQQgAIQwgIwQABAEAAAAOIAACAIAAAAQAIAgEAACEAAAAAgAQBAAAAAAAGBAAgAAAAAAAFAAECAAAgAAQARAEQAAAAAJAAIAAgAAAYQEAAAQmAgBC3ZAYzUw',
89+
gdprConsent: {
90+
consentString: 'COvFyGBOvFyGBAbAAAENAPCAAOAAAAAAAAAAAEEUACCKAAA.IFoEUQQgAIQwgIwQABAEAAAAOIAACAIAAAAQAIAgEAACEAAAAAgAQBAAAAAAAGBAAgAAAAAAAFAAECAAAgAAQARAEQAAAAAJAAIAAgAAAYQEAAAQmAgBC3ZAYzUw'
91+
},
7792
refererInfo: {
7893
referer: 'https://test.com'
7994
},
@@ -129,7 +144,7 @@ describe('IQZoneBidAdapter', function () {
129144
expect(data.host).to.be.a('string');
130145
expect(data.page).to.be.a('string');
131146
expect(data.coppa).to.be.a('number');
132-
expect(data.gdpr).to.be.a('string');
147+
expect(data.gdpr).to.be.a('object');
133148
expect(data.ccpa).to.be.a('string');
134149
expect(data.tmax).to.be.a('number');
135150
expect(data.placements).to.have.lengthOf(3);
@@ -145,6 +160,7 @@ describe('IQZoneBidAdapter', function () {
145160
expect(placement.schain).to.be.an('object');
146161
expect(placement.bidfloor).to.exist.and.to.equal(0);
147162
expect(placement.type).to.exist.and.to.equal('publisher');
163+
expect(placement.eids).to.exist.and.to.be.deep.equal(userIdAsEids);
148164

149165
if (placement.adFormat === BANNER) {
150166
expect(placement.sizes).to.be.an('array');
@@ -170,8 +186,8 @@ describe('IQZoneBidAdapter', function () {
170186
serverRequest = spec.buildRequests(bids, bidderRequest);
171187
let data = serverRequest.data;
172188
expect(data.gdpr).to.exist;
173-
expect(data.gdpr).to.be.a('string');
174-
expect(data.gdpr).to.equal(bidderRequest.gdprConsent);
189+
expect(data.gdpr).to.be.a('object');
190+
expect(data.gdpr.consentString).to.equal(bidderRequest.gdprConsent.consentString);
175191
expect(data.ccpa).to.not.exist;
176192
delete bidderRequest.gdprConsent;
177193
});
@@ -194,6 +210,38 @@ describe('IQZoneBidAdapter', function () {
194210
});
195211
});
196212

213+
describe('gpp consent', function () {
214+
it('bidderRequest.gppConsent', () => {
215+
bidderRequest.gppConsent = {
216+
gppString: 'abc123',
217+
applicableSections: [8]
218+
};
219+
220+
let serverRequest = spec.buildRequests(bids, bidderRequest);
221+
let data = serverRequest.data;
222+
expect(data).to.be.an('object');
223+
expect(data).to.have.property('gpp');
224+
expect(data).to.have.property('gpp_sid');
225+
226+
delete bidderRequest.gppConsent;
227+
})
228+
229+
it('bidderRequest.ortb2.regs.gpp', () => {
230+
bidderRequest.ortb2 = bidderRequest.ortb2 || {};
231+
bidderRequest.ortb2.regs = bidderRequest.ortb2.regs || {};
232+
bidderRequest.ortb2.regs.gpp = 'abc123';
233+
bidderRequest.ortb2.regs.gpp_sid = [8];
234+
235+
let serverRequest = spec.buildRequests(bids, bidderRequest);
236+
let data = serverRequest.data;
237+
expect(data).to.be.an('object');
238+
expect(data).to.have.property('gpp');
239+
expect(data).to.have.property('gpp_sid');
240+
241+
bidderRequest.ortb2;
242+
})
243+
});
244+
197245
describe('interpretResponse', function () {
198246
it('Should interpret banner response', function () {
199247
const banner = {
@@ -370,6 +418,7 @@ describe('IQZoneBidAdapter', function () {
370418
expect(serverResponses).to.be.an('array').that.is.empty;
371419
});
372420
});
421+
373422
describe('getUserSyncs', function() {
374423
it('Should return array of objects with proper sync config , include GDPR', function() {
375424
const syncData = spec.getUserSyncs({}, {}, {
@@ -394,5 +443,17 @@ describe('IQZoneBidAdapter', function () {
394443
expect(syncData[0].url).to.be.a('string')
395444
expect(syncData[0].url).to.equal('https://cs.smartssp.iqzone.com/image?pbjs=1&ccpa_consent=1---&coppa=0')
396445
});
446+
it('Should return array of objects with proper sync config , include GPP', function() {
447+
const syncData = spec.getUserSyncs({}, {}, {}, {}, {
448+
gppString: 'abc123',
449+
applicableSections: [8]
450+
});
451+
expect(syncData).to.be.an('array').which.is.not.empty;
452+
expect(syncData[0]).to.be.an('object')
453+
expect(syncData[0].type).to.be.a('string')
454+
expect(syncData[0].type).to.equal('image')
455+
expect(syncData[0].url).to.be.a('string')
456+
expect(syncData[0].url).to.equal('https://cs.smartssp.iqzone.com/image?pbjs=1&gpp=abc123&gpp_sid=8&coppa=0')
457+
});
397458
});
398459
});

0 commit comments

Comments
 (0)