Skip to content

Commit

Permalink
NoBid Bid Adapter: Support for GPP 1.1 (#10287)
Browse files Browse the repository at this point in the history
* Enable supplyChain support

* Added support for COPPA

* rebuilt

* Added support for Extended User IDs.

* Added support for the "meta" attribute in bid response.

* Added video context to ad unit request.

* Added GPP support to NoBid Bid Adapter.

* package-lock.json update

* Added gpp_supported: true to the mark down file.

* Added GPP related tests.

* Delete .project

* Delete .jsdtscope

* Delete org.eclipse.wst.jsdt.ui.superType.container

* Delete org.eclipse.wst.jsdt.ui.superType.name

* Delete a

* Delete nobidBidAdapter.js.orig

* Delete nobidBidAdapter.js.orig

* Delete a

* Delete .jsdtscope

* Delete org.eclipse.wst.jsdt.ui.superType.container

* Delete org.eclipse.wst.jsdt.ui.superType.name

* Delete .project

* Delete package-lock.json

* package.json

* putting back package=lock.json

* package.json

---------

Co-authored-by: Reda Guermas <reda.guermas@nobid.io>
  • Loading branch information
redaguermas and Reda Guermas authored Aug 22, 2023
1 parent 18183f0 commit ddd6a3b
Show file tree
Hide file tree
Showing 3 changed files with 85 additions and 7 deletions.
34 changes: 29 additions & 5 deletions modules/nobidBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { config } from '../src/config.js';
import { registerBidder } from '../src/adapters/bidderFactory.js';
import { BANNER, VIDEO } from '../src/mediaTypes.js';
import { getStorageManager } from '../src/storageManager.js';
import {hasPurpose1Consent} from '../src/utils/gpdr.js';
import { hasPurpose1Consent } from '../src/utils/gpdr.js';

const GVLID = 816;
const BIDDER_CODE = 'nobid';
Expand Down Expand Up @@ -63,6 +63,19 @@ function nobidBuildRequests(bids, bidderRequest) {
}
return uspConsent;
}
var gppConsent = function(bidderRequest) {
let gppConsent = null;
if (bidderRequest?.gppConsent?.gppString && bidderRequest?.gppConsent?.applicableSections) {
gppConsent = {};
gppConsent.gpp = bidderRequest.gppConsent.gppString;
gppConsent.gpp_sid = Array.isArray(bidderRequest.gppConsent.applicableSections) ? bidderRequest.gppConsent.applicableSections : [];
} else if (bidderRequest?.ortb2?.regs?.gpp && bidderRequest?.ortb2.regs?.gpp_sid) {
gppConsent = {};
gppConsent.gpp = bidderRequest.ortb2.regs.gpp;
gppConsent.gpp_sid = Array.isArray(bidderRequest.ortb2.regs.gpp_sid) ? bidderRequest.ortb2.regs.gpp_sid : [];
}
return gppConsent;
}
var schain = function(bids) {
if (bids && bids.length > 0) {
return bids[0].schain
Expand Down Expand Up @@ -145,6 +158,9 @@ function nobidBuildRequests(bids, bidderRequest) {
if (cop) state['coppa'] = cop;
const eids = getEIDs(deepAccess(bids, '0.userIdAsEids'));
if (eids && eids.length > 0) state['eids'] = eids;
const gpp = gppConsent(bidderRequest);
if (gpp?.gpp) state['gpp'] = gpp.gpp;
if (gpp?.gpp_sid) state['gpp_sid'] = gpp.gpp_sid;
if (bidderRequest && bidderRequest.ortb2) state['ortb2'] = bidderRequest.ortb2;
return state;
};
Expand Down Expand Up @@ -230,9 +246,9 @@ function nobidBuildRequests(bids, bidderRequest) {
siteId = (typeof bid.params['siteId'] != 'undefined' && bid.params['siteId']) ? bid.params['siteId'] : siteId;
var placementId = bid.params['placementId'];

var adType = 'banner';
let adType = 'banner';
const videoMediaType = deepAccess(bid, 'mediaTypes.video');
const context = deepAccess(bid, 'mediaTypes.video.context');
const context = deepAccess(bid, 'mediaTypes.video.context') || '';
if (bid.mediaType === VIDEO || (videoMediaType && (context === 'instream' || context === 'outstream'))) {
adType = 'video';
}
Expand All @@ -246,7 +262,8 @@ function nobidBuildRequests(bids, bidderRequest) {
placementId: placementId,
ad_type: adType,
params: bid.params,
floor: floor
floor: floor,
ctx: context
},
adunits);
}
Expand Down Expand Up @@ -369,6 +386,7 @@ export const spec = {
function resolveEndpoint() {
var ret = 'https://ads.servenobid.com/';
var env = (typeof getParameterByName === 'function') && (getParameterByName('nobid-env'));
env = window.location.href.indexOf('nobid-env=dev') > 0 ? 'dev' : env;
if (!env) ret = 'https://ads.servenobid.com/';
else if (env == 'beta') ret = 'https://beta.servenobid.com/';
else if (env == 'dev') ret = '//localhost:8282/';
Expand Down Expand Up @@ -421,7 +439,7 @@ export const spec = {
* @param {ServerResponse[]} serverResponses List of server's responses.
* @return {UserSync[]} The user syncs which should be dropped.
*/
getUserSyncs: function(syncOptions, serverResponses, gdprConsent, usPrivacy) {
getUserSyncs: function(syncOptions, serverResponses, gdprConsent, usPrivacy, gppConsent) {
if (syncOptions.iframeEnabled) {
let params = '';
if (gdprConsent && typeof gdprConsent.consentString === 'string') {
Expand All @@ -437,6 +455,12 @@ export const spec = {
else params += '?';
params += 'usp_consent=' + usPrivacy;
}
if (gppConsent?.gppString && gppConsent?.applicableSections?.length) {
if (params.length > 0) params += '&';
else params += '?';
params += 'gpp=' + encodeURIComponent(gppConsent.gppString);
params += 'gpp_sid=' + encodeURIComponent(gppConsent.applicableSections.join(','));
}
return [{
type: 'iframe',
url: 'https://public.servenobid.com/sync.html' + params
Expand Down
1 change: 1 addition & 0 deletions modules/nobidBidAdapter.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ hide: true
media_types: banner, video
gdpr_supported: true
usp_supported: true
gpp_supported: true
---

### Bid Params
Expand Down
57 changes: 55 additions & 2 deletions test/spec/modules/nobidBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@ describe('Nobid Adapter', function () {
it('should FLoor = 1', function () {
spec.buildRequests(bidRequests, bidderRequest);
const request = spec.buildRequests(bidRequests, bidderRequest);
/* eslint-disable no-console */
console.log('request.data:', request.data);
const payload = JSON.parse(request.data);
expect(payload.a[0].floor).to.equal(1);
});
Expand Down Expand Up @@ -145,6 +143,61 @@ describe('Nobid Adapter', function () {
});
});

describe('Request with GPP', function () {
const SITE_ID = 2;
const REFERER = 'https://www.examplereferer.com';
const BIDDER_CODE = 'duration';
let bidRequests = [
{
'bidder': BIDDER_CODE,
'params': {
'siteId': SITE_ID
},
'adUnitCode': 'adunit-code',
'sizes': [[300, 250]],
'bidId': '30b31c1838de1e',
'bidderRequestId': '22edbae2733bf6',
'auctionId': '1d1a030790a475'
}
];

const GPP = 'DBACNYA~CPXxRfAPXxRfAAfKABENB-CgAAAAAAAAAAYgAAAAAAAA~1YNN';
const GPP_SID = [1, 3];

const bidderRequest = {
refererInfo: {page: REFERER},
bidderCode: BIDDER_CODE,
gppConsent: {gppString: GPP, applicableSections: GPP_SID}
}

it('gpp should match', function () {
const request = spec.buildRequests(bidRequests, bidderRequest);
let payload = JSON.parse(request.data);
payload = JSON.parse(JSON.stringify(payload));
expect(payload.gpp).to.equal(GPP);
expect(payload.gpp_sid.join(',')).to.equal(GPP_SID.join(','));
});

it('gpp should not be set', function () {
delete bidderRequest.gppConsent.applicableSections;
const request = spec.buildRequests(bidRequests, bidderRequest);
let payload = JSON.parse(request.data);
payload = JSON.parse(JSON.stringify(payload));
expect(typeof payload.gpp).to.equal('undefined');
expect(typeof payload.gpp_sid).to.equal('undefined');
});

it('gpp ortb2 should match', function () {
delete bidderRequest.gppConsent;
bidderRequest.ortb2 = {regs: {gpp: GPP, gpp_sid: GPP_SID}};
const request = spec.buildRequests(bidRequests, bidderRequest);
let payload = JSON.parse(request.data);
payload = JSON.parse(JSON.stringify(payload));
expect(payload.gpp).to.equal(GPP);
expect(payload.gpp_sid.join(',')).to.equal(GPP_SID.join(','));
});
});

describe('isDurationBidRequestValid', function () {
const SITE_ID = 2;
const REFERER = 'https://www.examplereferer.com';
Expand Down

0 comments on commit ddd6a3b

Please sign in to comment.