Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NoBid Bid Adapter: Support for GPP 1.1 #10287

Merged
merged 45 commits into from
Aug 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
0eba11e
Enable supplyChain support
redaguermas Mar 4, 2020
c0fb8ee
Added support for COPPA
redaguermas Mar 5, 2020
36fab76
Merge branch 'master' of https://github.com/prebid/Prebid.js
redaguermas Mar 13, 2020
51525d7
Merge branch 'master' of https://github.com/prebid/Prebid.js
redaguermas Apr 13, 2020
c473780
Merge remote-tracking branch 'upstream/master'
Jun 1, 2020
33757b8
Merge branch 'master' of https://github.com/prebid/Prebid.js
Jun 4, 2020
9e1758b
Merge branch 'master' of https://github.com/prebid/Prebid.js
Jun 19, 2020
1d7db5d
Merge branch 'master' of https://github.com/prebid/Prebid.js
Aug 18, 2020
8fca715
Merge branch 'master' of https://github.com/prebid/Prebid.js
Aug 26, 2020
c11a5b3
rebuilt
Sep 27, 2020
c44bd3f
Merge branch 'master' of https://github.com/prebid/Prebid.js
Sep 27, 2020
9c8440c
Added support for Extended User IDs.
Sep 28, 2020
ec5cde7
Merge branch 'master' of https://github.com/prebid/Prebid.js
May 28, 2021
ff10bbe
Added support for the "meta" attribute in bid response.
May 28, 2021
4a4c253
Merge branch 'master' of https://github.com/prebid/Prebid.js
Jul 13, 2021
01a2d94
Merge branch 'master' of https://github.com/prebid/Prebid.js
Sep 27, 2021
61583a2
Merge branch 'master' of https://github.com/prebid/Prebid.js
Mar 7, 2023
00142cc
Merge branch 'master' of https://github.com/prebid/Prebid.js
Mar 31, 2023
d6160fa
Merge branch 'master' of https://github.com/prebid/Prebid.js
Jul 4, 2023
a87a1e2
Added video context to ad unit request.
Jul 4, 2023
c2f84c6
Merge branch 'master' of https://github.com/prebid/Prebid.js into NoB…
Jul 26, 2023
7e4d723
Added GPP support to NoBid Bid Adapter.
Jul 27, 2023
5faa816
package-lock.json update
Jul 27, 2023
b7d3a86
Added gpp_supported: true to the mark down file.
Jul 27, 2023
8d88942
Added GPP related tests.
Jul 28, 2023
897698c
Merge branch 'master' of https://github.com/prebid/Prebid.js into NoB…
Jul 28, 2023
f31c144
Delete .project
redaguermas Jul 28, 2023
6e52f5b
Delete .jsdtscope
redaguermas Jul 28, 2023
ab333f0
Delete org.eclipse.wst.jsdt.ui.superType.container
redaguermas Jul 28, 2023
b4e9e46
Delete org.eclipse.wst.jsdt.ui.superType.name
redaguermas Jul 28, 2023
58fbc8b
Delete a
redaguermas Jul 28, 2023
e09d445
Delete nobidBidAdapter.js.orig
redaguermas Jul 28, 2023
388d3e0
Delete nobidBidAdapter.js.orig
redaguermas Jul 28, 2023
1c3f853
Delete a
redaguermas Jul 28, 2023
38dc58a
Delete .jsdtscope
redaguermas Jul 28, 2023
2818cbe
Delete org.eclipse.wst.jsdt.ui.superType.container
redaguermas Jul 28, 2023
ad8662d
Delete org.eclipse.wst.jsdt.ui.superType.name
redaguermas Jul 28, 2023
8ddb9a9
Delete .project
redaguermas Jul 28, 2023
f7eb056
Delete package-lock.json
redaguermas Aug 3, 2023
a164194
Merge branch 'master' of https://github.com/redaguermas/Prebid.js
Aug 7, 2023
39abc2d
package.json
Aug 7, 2023
757ed98
putting back package=lock.json
Aug 7, 2023
e029482
package.json
Aug 7, 2023
0a5fbc6
Merge branch 'master' of https://github.com/prebid/Prebid.js
Aug 10, 2023
f2529d6
Merge branch 'master' into NoBid-version-1.4.0
Aug 10, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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