Skip to content

Commit

Permalink
Improve Digital adapter: custom creative renderer (prebid#7975)
Browse files Browse the repository at this point in the history
* Feature Prebid First Party Data (#2)

* HBT-166: Added PageCategory and Genre to request object from First-Party-Data

* HBT-166: Added PageCategory and Genre to request object from First-Party-Data and Rewrite Test Cases

* Update improvedigitalBidAdapter.js

Version increased

* Improve Digital COPPA support

* Feature/razr integration (#3)

Integrated RAZR rich creative renderer

* Use renderer interface for Razr

Co-authored-by: Faisal Islam <93644923+faisalvs@users.noreply.github.com>
Co-authored-by: Samiul Amin Shanto <93644987+samiul-shanto@users.noreply.github.com>
Co-authored-by: Faisal Islam <faisal.islam@vivacomsolutions.com>
  • Loading branch information
4 people authored Mar 2, 2022
1 parent 69de981 commit efbeaf0
Show file tree
Hide file tree
Showing 2 changed files with 80 additions and 2 deletions.
45 changes: 43 additions & 2 deletions modules/improvedigitalBidAdapter.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { deepSetValue, logError, _each, getBidRequest, isNumber, isArray, deepAccess, isFn, isPlainObject, logWarn, getBidIdParameter, getUniqueIdentifierStr, isEmpty, isInteger, isStr } from '../src/utils.js';
import { deepSetValue, logError, _each, getBidRequest, isNumber, isArray, deepAccess, isFn, isPlainObject, logWarn, getBidIdParameter, getUniqueIdentifierStr, isEmpty, isInteger, isStr, mergeDeep } from '../src/utils.js';
import { registerBidder } from '../src/adapters/bidderFactory.js';
import { config } from '../src/config.js';
import { BANNER, NATIVE, VIDEO } from '../src/mediaTypes.js';
Expand All @@ -10,8 +10,44 @@ const BIDDER_CODE = 'improvedigital';
const RENDERER_URL = 'https://acdn.adnxs.com/video/outstream/ANOutstreamVideo.js';
const VIDEO_TARGETING = ['skip', 'skipmin', 'skipafter'];

const ID_RAZR = {
RENDERER_URL: 'https://razr.improvedigital.com/renderer.js',
addBidData({bid, bidRequest}) {
if (this.isValidBid(bid)) {
bid.renderer = Renderer.install({
url: this.RENDERER_URL,
config: {bidRequest}
});
bid.renderer.setRender(this.render);
}
},

isValidBid(bid) {
return bid && /razr:\\?\/\\?\//.test(bid.ad);
},

render(bid) {
const {bidRequest} = bid.renderer.getConfig();

const payload = {
type: 'prebid',
bidRequest,
bid,
config: mergeDeep(
{},
config.getConfig('improvedigital.rendererConfig'),
deepAccess(bidRequest, 'params.rendererConfig')
)
};

const razr = window.razr = window.razr || {};
razr.queue = razr.queue || [];
razr.queue.push(payload);
}
};

export const spec = {
version: '7.6.0',
version: '7.7.0',
code: BIDDER_CODE,
gvlid: 253,
aliases: ['id'],
Expand Down Expand Up @@ -197,6 +233,11 @@ export const spec = {
};
}

ID_RAZR.addBidData({
bidRequest,
bid
});

bids.push(bid);
});
return bids;
Expand Down
37 changes: 37 additions & 0 deletions test/spec/modules/improvedigitalBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -605,6 +605,33 @@ describe('Improve Digital Adapter Tests', function () {
}
};

const serverResponseRazr = {
'body': {
'id': '687a06c541d8d1',
'site_id': 191642,
'bid': [
{
'isNet': false,
'id': '33e9500b21129f',
'advid': '5279',
'price': 1.45888594164456,
'nurl': 'https://ice.360yield.com/imp_pixel?ic=wVmhKI07hCVyGC1sNdFp.6buOSiGYOw8jPyZLlcMY2RCwD4ek3Fy6.xUI7U002skGBs3objMBoNU-Frpvmb9js3NKIG0YZJgWaNdcpXY9gOXE9hY4-wxybCjVSNzhOQB-zic73hzcnJnKeoGgcfvt8fMy18-yD0aVdYWt4zbqdoITOkKNCPBEgbPFu1rcje-o7a64yZ7H3dKvtnIixXQYc1Ep86xGSBGXY6xW2KfUOMT6vnkemxO72divMkMdhR8cAuqIubbx-ZID8-xf5c9k7p6DseeBW0I8ionrlTHx.rGosgxhiFaMqtr7HiA7PBzKvPdeEYN0hQ8RYo8JzYL82hA91A3V2m9Ij6y0DfIJnnrKN8YORffhxmJ6DzwEl1zjrVFbD01bqB3Vdww8w8PQJSkKQkd313tr-atU8LS26fnBmOngEkVHwAr2WCKxuUvxHmuVBTA-Lgz7wKwMoOJCA3hFxMavVb0ZFB7CK0BUTVU6z0De92Q.FJKNCHLMbjX3vcAQ90=',
'h': 290,
'pid': 1053688,
'sync': [
'https://link1',
'https://link2'
],
'crid': '422031',
'w': 600,
'cid': '99006',
'adm': 'document.writeln("<script async src=\"https:\/\/cdn.inskinad.com\/isfe\/tags\/dsp.js\"><\/script>\n<script type=\"text\/javascript\">\n (function() {\n var ns = window.inskin = window.inskin || {};\n ns.dsp = ns.dsp || [];\n ns.dsp.push({\n uri: \"razr:\/\/provider\/format\"\n });\n })();\n<\/script>");document.writeln("<improvedigital_ad_output_information tp_id=\"\" buyer_id=\"0\" rtb_advertiser=\"\" campaign_id=\"123456\" line_item_id=\"123456\" creative_id=\"123456\" crid=\"0\" placement_id=\"123456\"><\/improvedigital_ad_output_information>");'
}
],
'debug': ''
}
};

const serverResponseTwoBids = {
'body': {
'id': '687a06c541d8d1',
Expand Down Expand Up @@ -1072,6 +1099,16 @@ describe('Improve Digital Adapter Tests', function () {
delete (bids[0].renderer);
expect(bids).to.deep.equal(expectedBidOutstreamVideo);
});

it('should not affect non-RAZR bids', function () {
const bids = spec.interpretResponse(serverResponse, {bidderRequest});
expect(bids[0].renderer).to.not.exist;
});

it('should detect RAZR bids', function () {
const bids = spec.interpretResponse(serverResponseRazr, {bidderRequest});
expect(bids[0].renderer).to.exist;
});
});

describe('getUserSyncs', function () {
Expand Down

0 comments on commit efbeaf0

Please sign in to comment.