Skip to content

Commit

Permalink
Prebid 8: Enforcement, lat and long can only come from the request (#…
Browse files Browse the repository at this point in the history
…10041)

* Update apacdexBidAdapter.js

* Update ebdrBidAdapter.js

* Update mediafuseBidAdapter.js

* Update microadBidAdapter.js

* Update zetaBidAdapter.js

* Update pubwiseBidAdapter.js

* Update pubmaticBidAdapter.js

* Update ebdrBidAdapter.js

* Update microadBidAdapter.js

* Update apacdexBidAdapter.js

* Update apacdexBidAdapter_spec.js

* Update mediafuseBidAdapter_spec.js

* Update pubmaticBidAdapter_spec.js

* Update microadBidAdapter_spec.js

* Update pubmaticBidAdapter_spec.js

* Update pubmaticBidAdapter_spec.js
  • Loading branch information
patmmccann authored Jun 6, 2023
1 parent a8dedb7 commit a1a9689
Show file tree
Hide file tree
Showing 11 changed files with 42 additions and 53 deletions.
4 changes: 2 additions & 2 deletions modules/apacdexBidAdapter.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { deepAccess, isPlainObject, isArray, replaceAuctionPrice, isFn } from '../src/utils.js';
import { deepAccess, isPlainObject, isArray, replaceAuctionPrice, isFn, logError } from '../src/utils.js';
import { config } from '../src/config.js';
import { registerBidder } from '../src/adapters/bidderFactory.js';
import {hasPurpose1Consent} from '../src/utils/gpdr.js';
Expand Down Expand Up @@ -134,7 +134,7 @@ export const spec = {

// Apply geo
if (geo) {
payload.geo = geo;
logError('apacdex adapter: Precise lat and long must be set on config; not on bidder parameters');
}

payload.bids = bids.map(function (bid) {
Expand Down
5 changes: 3 additions & 2 deletions modules/ebdrBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,9 @@ export const spec = {
w: whArr[0],
h: whArr[1]
};
ebdrParams['latitude'] = getBidIdParameter('latitude', bid.params);
ebdrParams['longitude'] = getBidIdParameter('longitude', bid.params);
// TODO: fix lat and long to only come from request
ebdrParams['latitude'] = '0';
ebdrParams['longitude'] = '0';
ebdrParams['ifa'] = (getBidIdParameter('IDFA', bid.params).length > getBidIdParameter('ADID', bid.params).length) ? getBidIdParameter('IDFA', bid.params) : getBidIdParameter('ADID', bid.params);
});
let ebdrBidReq = {
Expand Down
2 changes: 1 addition & 1 deletion modules/mediafuseBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ const VIDEO_TARGETING = ['id', 'minduration', 'maxduration',
'skippable', 'playback_method', 'frameworks', 'context', 'skipoffset'];
const VIDEO_RTB_TARGETING = ['minduration', 'maxduration', 'skip', 'skipafter', 'playbackmethod', 'api'];
const USER_PARAMS = ['age', 'externalUid', 'segments', 'gender', 'dnt', 'language'];
const APP_DEVICE_PARAMS = ['geo', 'device_id']; // appid is collected separately
const APP_DEVICE_PARAMS = ['device_id']; // appid is collected separately
const DEBUG_PARAMS = ['enabled', 'dongle', 'member_id', 'debug_timeout'];
const VIDEO_MAPPING = {
playback_method: {
Expand Down
8 changes: 0 additions & 8 deletions modules/microadBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ const EXT_URL_STRING = '${COMPASS_EXT_URL}';
const EXT_REF_STRING = '${COMPASS_EXT_REF}';
const EXT_IFA_STRING = '${COMPASS_EXT_IFA}';
const EXT_APPID_STRING = '${COMPASS_EXT_APPID}';
const EXT_GEO_STRING = '${COMPASS_EXT_GEO}';
/* eslint-enable no-template-curly-in-string */

const BANNER_CODE = 1;
Expand Down Expand Up @@ -94,13 +93,6 @@ export const spec = {
params['appid'] = bidParams.appid.replace(EXT_APPID_STRING, '');
}

if (bidParams.geo) {
const geo = bidParams.geo.replace(EXT_GEO_STRING, '');
if (/^[0-9.\-]+,[0-9.\-]+$/.test(geo)) {
params['geo'] = geo;
}
}

const aidsParams = []
const userIdAsEids = bid.userIdAsEids;
AUDIENCE_IDS.forEach((audienceId) => {
Expand Down
5 changes: 3 additions & 2 deletions modules/pubmaticBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -1133,8 +1133,9 @@ export const spec = {

payload.user.gender = (conf.gender ? conf.gender.trim() : UNDEFINED);
payload.user.geo = {};
payload.user.geo.lat = _parseSlotParam('lat', conf.lat);
payload.user.geo.lon = _parseSlotParam('lon', conf.lon);
// TODO: fix lat and long to only come from request object, not params
payload.user.geo.lat = _parseSlotParam('lat', 0);
payload.user.geo.lon = _parseSlotParam('lon', 0);
payload.user.yob = _parseSlotParam('yob', conf.yob);
payload.device.geo = payload.user.geo;
payload.site.page = conf.kadpageurl.trim() || payload.site.page.trim();
Expand Down
5 changes: 3 additions & 2 deletions modules/pubwiseBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -224,8 +224,9 @@ export const spec = {
payload.site.publisher.id = bid.params.siteId.trim();
payload.user.gender = (conf.gender ? conf.gender.trim() : UNDEFINED);
payload.user.geo = {};
payload.user.geo.lat = _parseSlotParam('lat', conf.lat);
payload.user.geo.lon = _parseSlotParam('lon', conf.lon);
// TODO: fix lat and long to only come from ortb2 object so publishers can control precise location
payload.user.geo.lat = _parseSlotParam('lat', 0);
payload.user.geo.lon = _parseSlotParam('lon', 0);
payload.user.yob = _parseSlotParam('yob', conf.yob);
payload.device.geo = payload.user.geo;
payload.site.page = payload.site?.page?.trim();
Expand Down
6 changes: 0 additions & 6 deletions modules/zetaBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,6 @@ export const spec = {
return false;
}

if (!(bid.params.device.geo &&
bid.params.device.geo.country)) {
logWarn('Invalid bid request - missing required geo data');
return false;
}

if (!bid.params.definerId) {
logWarn('Invalid bid request - missing required definer data');
return false;
Expand Down
4 changes: 2 additions & 2 deletions test/spec/modules/apacdexBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -321,9 +321,9 @@ describe('ApacdexBidAdapter', function () {
const bidRequests = spec.buildRequests(bidRequest, bidderRequests);
expect(bidRequests.data.eids).to.deep.equal(bidRequest[0].userIdAsEids)
});
it('should return a properly formatted request with geo defined', function () {
it('should fail to return a properly formatted request with geo defined', function () {
const bidRequests = spec.buildRequests(bidRequest, bidderRequests);
expect(bidRequests.data.geo).to.deep.equal(bidRequest[0].params.geo)
expect(bidRequests.data.geo).to.not.deep.equal(bidRequest[0].params.geo)
});
it('should return a properly formatted request with us_privacy included', function () {
const bidRequests = spec.buildRequests(bidRequest, bidderRequests);
Expand Down
4 changes: 2 additions & 2 deletions test/spec/modules/mediafuseBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -811,8 +811,8 @@ describe('MediaFuseAdapter', function () {
sha1udid: '4DFAA92388699AC6539885AEF1719293879985BF',
windowsadid: '750c6be243f1c4b5c9912b95a5742fc5'
});
expect(payload.device.geo).to.exist;
expect(payload.device.geo).to.deep.equal({
expect(payload.device.geo).to.not.exist;
expect(payload.device.geo).to.not.deep.equal({
lat: 40.0964439,
lng: -75.3009142
});
Expand Down
4 changes: 2 additions & 2 deletions test/spec/modules/microadBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ describe('microadBidAdapter', () => {
});
});

it('should add geo parameter to response if request parameters contain geo', () => {
it('should not add geo parameter to response even if request parameters contain geo', () => {
const bidRequestWithGeo = Object.assign({}, bidRequestTemplate, {
params: {
spot: 'spot-code',
Expand All @@ -237,7 +237,7 @@ describe('microadBidAdapter', () => {
});
const requests = spec.buildRequests([bidRequestWithGeo], bidderRequest);
requests.forEach(request => {
expect(request.data).to.deep.equal(
expect(request.data).to.not.deep.equal(
Object.assign({}, expectedResultTemplate, {
cbt: request.data.cbt,
geo: '35.655275,139.693771'
Expand Down
48 changes: 24 additions & 24 deletions test/spec/modules/pubmaticBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1144,10 +1144,10 @@ describe('PubMatic adapter', function () {
expect(data.site.publisher.id).to.equal(bidRequests[0].params.publisherId); // publisher Id
expect(data.user.yob).to.equal(parseInt(bidRequests[0].params.yob)); // YOB
expect(data.user.gender).to.equal(bidRequests[0].params.gender); // Gender
expect(data.device.geo.lat).to.equal(parseFloat(bidRequests[0].params.lat)); // Latitude
expect(data.device.geo.lon).to.equal(parseFloat(bidRequests[0].params.lon)); // Lognitude
expect(data.user.geo.lat).to.equal(parseFloat(bidRequests[0].params.lat)); // Latitude
expect(data.user.geo.lon).to.equal(parseFloat(bidRequests[0].params.lon)); // Lognitude
expect(data.device.geo.lat).to.not.equal(parseFloat(bidRequests[0].params.lat)); // Latitude
expect(data.device.geo.lon).to.not.equal(parseFloat(bidRequests[0].params.lon)); // Lognitude
expect(data.user.geo.lat).to.not.equal(parseFloat(bidRequests[0].params.lat)); // Latitude
expect(data.user.geo.lon).to.not.equal(parseFloat(bidRequests[0].params.lon)); // Lognitude
expect(data.ext.wrapper.wv).to.equal($$REPO_AND_VERSION$$); // Wrapper Version
expect(data.ext.wrapper.transactionId).to.equal(bidRequests[0].ortb2Imp.ext.tid); // Prebid TransactionId
expect(data.source.tid).to.equal('source-tid'); // Prebid TransactionId
Expand Down Expand Up @@ -1397,10 +1397,10 @@ describe('PubMatic adapter', function () {
expect(data.site.publisher.id).to.equal(bidRequests[0].params.publisherId); // publisher Id
expect(data.user.yob).to.equal(parseInt(bidRequests[0].params.yob)); // YOB
expect(data.user.gender).to.equal(bidRequests[0].params.gender); // Gender
expect(data.device.geo.lat).to.equal(parseFloat(bidRequests[0].params.lat)); // Latitude
expect(data.device.geo.lon).to.equal(parseFloat(bidRequests[0].params.lon)); // Lognitude
expect(data.user.geo.lat).to.equal(parseFloat(bidRequests[0].params.lat)); // Latitude
expect(data.user.geo.lon).to.equal(parseFloat(bidRequests[0].params.lon)); // Lognitude
expect(data.device.geo.lat).to.not.equal(parseFloat(bidRequests[0].params.lat)); // Latitude
expect(data.device.geo.lon).to.not.equal(parseFloat(bidRequests[0].params.lon)); // Lognitude
expect(data.user.geo.lat).to.not.equal(parseFloat(bidRequests[0].params.lat)); // Latitude
expect(data.user.geo.lon).to.not.equal(parseFloat(bidRequests[0].params.lon)); // Lognitude
expect(data.ext.wrapper.wv).to.equal($$REPO_AND_VERSION$$); // Wrapper Version
expect(data.ext.wrapper.transactionId).to.equal(bidRequests[0].ortb2Imp.ext.tid); // Prebid TransactionId
expect(data.ext.wrapper.wiid).to.equal(bidRequests[0].params.wiid); // OpenWrap: Wrapper Impression ID
Expand Down Expand Up @@ -1608,10 +1608,10 @@ describe('PubMatic adapter', function () {
expect(data.site.publisher.id).to.equal(bidRequests[0].params.publisherId); // publisher Id
expect(data.user.yob).to.equal(parseInt(bidRequests[0].params.yob)); // YOB
expect(data.user.gender).to.equal(bidRequests[0].params.gender); // Gender
expect(data.device.geo.lat).to.equal(parseFloat(bidRequests[0].params.lat)); // Latitude
expect(data.device.geo.lon).to.equal(parseFloat(bidRequests[0].params.lon)); // Lognitude
expect(data.user.geo.lat).to.equal(parseFloat(bidRequests[0].params.lat)); // Latitude
expect(data.user.geo.lon).to.equal(parseFloat(bidRequests[0].params.lon)); // Lognitude
expect(data.device.geo.lat).to.not.equal(parseFloat(bidRequests[0].params.lat)); // Latitude
expect(data.device.geo.lon).to.not.equal(parseFloat(bidRequests[0].params.lon)); // Longitude
expect(data.user.geo.lat).to.not.equal(parseFloat(bidRequests[0].params.lat)); // Latitude
expect(data.user.geo.lon).to.not.equal(parseFloat(bidRequests[0].params.lon)); // Longitude
expect(data.ext.wrapper.wv).to.equal($$REPO_AND_VERSION$$); // Wrapper Version
expect(data.ext.wrapper.transactionId).to.equal(bidRequests[0].ortb2Imp.ext.tid); // Prebid TransactionId
expect(data.ext.wrapper.wiid).to.equal('new-auction-id'); // OpenWrap: Wrapper Impression ID
Expand Down Expand Up @@ -1644,10 +1644,10 @@ describe('PubMatic adapter', function () {
expect(data.site.publisher.id).to.equal(bidRequests[0].params.publisherId); // publisher Id
expect(data.user.yob).to.equal(parseInt(bidRequests[0].params.yob)); // YOB
expect(data.user.gender).to.equal(bidRequests[0].params.gender); // Gender
expect(data.device.geo.lat).to.equal(parseFloat(bidRequests[0].params.lat)); // Latitude
expect(data.device.geo.lon).to.equal(parseFloat(bidRequests[0].params.lon)); // Lognitude
expect(data.user.geo.lat).to.equal(parseFloat(bidRequests[0].params.lat)); // Latitude
expect(data.user.geo.lon).to.equal(parseFloat(bidRequests[0].params.lon)); // Lognitude
expect(data.device.geo.lat).to.not.equal(parseFloat(bidRequests[0].params.lat)); // Latitude
expect(data.device.geo.lon).to.not.equal(parseFloat(bidRequests[0].params.lon)); // Lognitude
expect(data.user.geo.lat).to.not.equal(parseFloat(bidRequests[0].params.lat)); // Latitude
expect(data.user.geo.lon).to.not.equal(parseFloat(bidRequests[0].params.lon)); // Lognitude
expect(data.ext.wrapper.wv).to.equal($$REPO_AND_VERSION$$); // Wrapper Version
expect(data.ext.wrapper.transactionId).to.equal(bidRequests[0].ortb2Imp.ext.tid); // Prebid TransactionId
expect(data.ext.wrapper.wiid).to.equal(bidRequests[0].params.wiid); // OpenWrap: Wrapper Impression ID
Expand Down Expand Up @@ -1676,10 +1676,10 @@ describe('PubMatic adapter', function () {
expect(data.site.publisher.id).to.equal(bidRequests[0].params.publisherId); // publisher Id
expect(data.user.yob).to.equal(parseInt(bidRequests[0].params.yob)); // YOB
expect(data.user.gender).to.equal(bidRequests[0].params.gender); // Gender
expect(data.device.geo.lat).to.equal(parseFloat(bidRequests[0].params.lat)); // Latitude
expect(data.device.geo.lon).to.equal(parseFloat(bidRequests[0].params.lon)); // Lognitude
expect(data.user.geo.lat).to.equal(parseFloat(bidRequests[0].params.lat)); // Latitude
expect(data.user.geo.lon).to.equal(parseFloat(bidRequests[0].params.lon)); // Lognitude
expect(data.device.geo.lat).to.not.equal(parseFloat(bidRequests[0].params.lat)); // Latitude
expect(data.device.geo.lon).to.not.equal(parseFloat(bidRequests[0].params.lon)); // Lognitude
expect(data.user.geo.lat).to.not.equal(parseFloat(bidRequests[0].params.lat)); // Latitude
expect(data.user.geo.lon).to.not.equal(parseFloat(bidRequests[0].params.lon)); // Lognitude
expect(data.ext.wrapper.wv).to.equal($$REPO_AND_VERSION$$); // Wrapper Version
expect(data.ext.wrapper.transactionId).to.equal(bidRequests[0].ortb2Imp.ext.tid); // Prebid TransactionId
expect(data.ext.wrapper.wiid).to.equal(bidRequests[0].params.wiid); // OpenWrap: Wrapper Impression ID
Expand Down Expand Up @@ -2706,10 +2706,10 @@ describe('PubMatic adapter', function () {
expect(data.site.publisher.id).to.equal(multipleMediaRequests[0].params.publisherId); // publisher Id
expect(data.user.yob).to.equal(parseInt(multipleMediaRequests[0].params.yob)); // YOB
expect(data.user.gender).to.equal(multipleMediaRequests[0].params.gender); // Gender
expect(data.device.geo.lat).to.equal(parseFloat(multipleMediaRequests[0].params.lat)); // Latitude
expect(data.device.geo.lon).to.equal(parseFloat(multipleMediaRequests[0].params.lon)); // Lognitude
expect(data.user.geo.lat).to.equal(parseFloat(multipleMediaRequests[0].params.lat)); // Latitude
expect(data.user.geo.lon).to.equal(parseFloat(multipleMediaRequests[0].params.lon)); // Lognitude
expect(data.device.geo.lat).to.not.equal(parseFloat(multipleMediaRequests[0].params.lat)); // Latitude
expect(data.device.geo.lon).to.not.equal(parseFloat(multipleMediaRequests[0].params.lon)); // Lognitude
expect(data.user.geo.lat).to.not.equal(parseFloat(multipleMediaRequests[0].params.lat)); // Latitude
expect(data.user.geo.lon).to.not.equal(parseFloat(multipleMediaRequests[0].params.lon)); // Lognitude
expect(data.ext.wrapper.wv).to.equal($$REPO_AND_VERSION$$); // Wrapper Version
expect(data.ext.wrapper.transactionId).to.equal(multipleMediaRequests[0].transactionId); // Prebid TransactionId
expect(data.ext.wrapper.wiid).to.equal(multipleMediaRequests[0].params.wiid); // OpenWrap: Wrapper Impression ID
Expand Down

0 comments on commit a1a9689

Please sign in to comment.