Skip to content

Commit 2c7decb

Browse files
authored
Feature/adshield (#95)
* adshield * adshield
1 parent aeecbe3 commit 2c7decb

2 files changed

Lines changed: 32 additions & 0 deletions

File tree

modules/dasBidAdapter.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,13 @@ function buildOpenRTBRequest(bidRequests, bidderRequest) {
248248
request.ext.adbeta = customParams.adbeta;
249249
}
250250

251+
// AdShield anti-adblock recovery signal (set by dlApi as customParams.asd, like adbeta).
252+
// Sent as a plain ext field (not a key-value) so das-bidder serves only
253+
// adblock-compatible demand (adblock_compability == 2).
254+
if (customParams.asd) {
255+
request.ext.asd = customParams.asd;
256+
}
257+
251258
if (bidderRequest.device) {
252259
request.device = bidderRequest.device;
253260
}

test/spec/modules/dasBidAdapter_spec.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,31 @@ describe('dasBidAdapter', function () {
179179
expect(payload.imp[0].banner.format[0]).to.deep.equal({ w: 300, h: 250 });
180180
});
181181

182+
it('should route customParams.asd into ext.asd for AdShield recovery', function () {
183+
const asdBidRequests = [{
184+
...bidRequests[0],
185+
params: {
186+
...bidRequests[0].params,
187+
customParams: { asd: 1 }
188+
}
189+
}];
190+
191+
const request = spec.buildRequests(asdBidRequests, bidderRequest);
192+
const params = new URLSearchParams(request.url.split('?')[1]);
193+
const payload = JSON.parse(decodeURIComponent(params.get('data')));
194+
195+
expect(payload.ext.asd).to.equal(1);
196+
expect(payload.ext.keyvalues.asd).to.be.undefined;
197+
});
198+
199+
it('should not set ext.asd without customParams.asd', function () {
200+
const request = spec.buildRequests(bidRequests, bidderRequest);
201+
const params = new URLSearchParams(request.url.split('?')[1]);
202+
const payload = JSON.parse(decodeURIComponent(params.get('data')));
203+
204+
expect(payload.ext.asd).to.be.undefined;
205+
});
206+
182207
it('should use GET method when URL is under 8192 characters', function () {
183208
const request = spec.buildRequests(bidRequests, bidderRequest);
184209
expect(request.method).to.equal('GET');

0 commit comments

Comments
 (0)