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

sspBC Bid Adapter: update to v4.8, bugfixes, & support for sending params.publisherId #6575

Merged
merged 27 commits into from
Apr 21, 2021
Merged
Show file tree
Hide file tree
Changes from 26 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
59a3934
add sspbc adapter
Jul 22, 2020
a28b263
tests for sspbc adapter
Jul 22, 2020
2350cc8
sspBC adapter v4.5: set correct creativeId, add adomain to bid.meta, …
Aug 4, 2020
dc4d0c4
sspBC adapter v4.5: set meta.advertiserDomains, update test to expect…
Aug 4, 2020
7672bbc
sspBC Adapter: add ajax tests (test ad with & without gdpr)
Aug 17, 2020
a569a8d
sspBC Adapter: remove ajax tests
Aug 17, 2020
72269fd
Merge pull request #2 from prebid/master
wojciech-bialy-wpm Aug 18, 2020
e87dd78
Merge pull request #3 from prebid/master
wojciech-bialy-wpm Aug 24, 2020
1c85801
Merge pull request #4 from prebid/master
wojciech-bialy-wpm Oct 20, 2020
f86b9b8
Merge pull request #5 from prebid/master
wojciech-bialy-wpm Nov 9, 2020
f504216
Update adapter to v4.6
wojciech-bialy-wpm Nov 9, 2020
bd4301a
Remove console logs for notification events
wojciech-bialy-wpm Nov 9, 2020
b3c7de9
Change payload data in onTimeout event
wojciech-bialy-wpm Nov 16, 2020
67e2916
Merge pull request #6 from prebid/master
wojciech-bialy-wpm Nov 16, 2020
ca418d3
Update tests for sspBC adapter
wojciech-bialy-wpm Nov 18, 2020
d565abd
Merge pull request #7 from prebid/master
wojciech-bialy-wpm Dec 11, 2020
e440009
Update sspBC adapter to v4.7; enable oneCodeId mode; change module na…
Dec 11, 2020
18237ab
sspBc adapter: Bug fixes in v4.7 - change notification format, fix on…
Dec 17, 2020
f0cd384
update remote fork with Prebid.js master
Apr 8, 2021
7c2bd1a
sspbc adapter: fix creating bid.crid, when not present in server resp…
Apr 8, 2021
67896c2
sspbc adapter: add publisher id to payload
Apr 9, 2021
04a65f2
sspbc adapter: fix onecode issues (when bid.params is present, but in…
Apr 9, 2021
57637fb
sspbc adapter: code cleanup
Apr 9, 2021
2f06fbb
sspbc adapter: ver up (4.8)
Apr 9, 2021
a868ace
Merge branch 'master' of https://github.com/prebid/Prebid.js into ssp…
Apr 13, 2021
563604c
sspbc-adapter: update doc
Apr 13, 2021
d2bfb68
[sspbc-adapter] update test settings
Apr 20, 2021
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
77 changes: 52 additions & 25 deletions modules/sspBCBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,13 @@ import * as utils from '../src/utils.js';
import { ajax } from '../src/ajax.js';
import { registerBidder } from '../src/adapters/bidderFactory.js';
import { BANNER } from '../src/mediaTypes.js';
import strIncludes from 'core-js-pure/features/string/includes.js';

const BIDDER_CODE = 'sspBC';
const BIDDER_URL = 'https://ssp.wp.pl/bidder/';
const SYNC_URL = 'https://ssp.wp.pl/bidder/usersync';
const NOTIFY_URL = 'https://ssp.wp.pl/bidder/notify';
const TMAX = 450;
const BIDDER_VERSION = '4.7';
const BIDDER_VERSION = '4.8';
const W = window;
const { navigator } = W;
const oneCodeDetection = {};
Expand Down Expand Up @@ -151,11 +150,13 @@ function mapBanner(slot) {
}

function mapImpression(slot) {
const { adUnitCode, bidId, params } = slot;
const { id, siteId } = params || {};
const imp = {
id: (slot.params && slot.params.id) ? slot.params.id : 'bidid-' + slot.bidId,
id: id && siteId ? id : 'bidid-' + bidId,
banner: mapBanner(slot),
/* native: mapNative(slot), */
tagid: slot.adUnitCode,
tagid: adUnitCode,
};

const bidfloor = (slot.params && slot.params.bidFloor) ? parseFloat(slot.params.bidFloor) : undefined;
Expand Down Expand Up @@ -255,6 +256,7 @@ const spec = {
}

const siteId = setOnAny(validBidRequests, 'params.siteId');
const publisherId = setOnAny(validBidRequests, 'params.publisherId');
const page = setOnAny(validBidRequests, 'params.page') || bidderRequest.refererInfo.referer;
const domain = setOnAny(validBidRequests, 'params.domain') || utils.parseUrl(page).hostname;
const tmax = setOnAny(validBidRequests, 'params.tmax') ? parseInt(setOnAny(validBidRequests, 'params.tmax'), 10) : TMAX;
Expand All @@ -270,7 +272,13 @@ const spec = {

const payload = {
id: bidderRequest.auctionId,
site: { id: siteId, page, domain, ref },
site: {
id: siteId,
publisher: publisherId ? { id: publisherId } : undefined,
page,
domain,
ref
},
imp: validBidRequests.map(slot => mapImpression(slot)),
tmax,
user: {},
Expand All @@ -290,57 +298,76 @@ const spec = {
},

interpretResponse(serverResponse, request) {
const { bidderRequest } = request;
const response = serverResponse.body;
const bids = [];
const site = JSON.parse(request.data).site; // get page and referer data from request
site.sn = response.sn || 'mc_adapter'; // WPM site name (wp_sn)
let seat;

if (response.seatbid !== undefined) {
/*
Match response to request, by comparing bid id's
'bidid-' prefix indicates oneCode (parameterless) request and response
*/
response.seatbid.forEach(seatbid => {
seat = seatbid.seat;
seatbid.bid.forEach(serverBid => {
const bidRequest = request.bidderRequest.bids.filter(b => {
const bidId = b.params ? b.params.id : 'bidid-' + b.bidId;
return bidId === serverBid.impid;
// get data from bid response
const { adomain, crid, impid, exp, ext, price, w, h } = serverBid;

const bidRequest = bidderRequest.bids.filter(b => {
const { bidId, params } = b;
const { id, siteId } = params || {};
const currentBidId = id && siteId ? id : 'bidid-' + bidId;
return currentBidId === impid;
})[0];
site.slot = bidRequest && bidRequest.params ? bidRequest.params.slotid : undefined;

if (serverBid.ext) {
// get data from linked bidRequest
const { bidId, params } = bidRequest || {};

// get slot id for current bid
site.slot = params && params.id;

if (ext) {
/*
bid response might include ext object containing siteId / slotId, as detected by OneCode
update site / slot data in this case
*/
site.id = serverBid.ext.siteid || site.id;
site.slot = serverBid.ext.slotid || site.slot;
const { siteid, slotid } = ext;
site.id = siteid || site.id;
site.slot = slotid || site.slot;
}

if (bidRequest && site.id && !strIncludes(site.id, 'bidid')) {
// store site data for future notification
oneCodeDetection[bidRequest.bidId] = [site.id, site.slot];
if (bidRequest && site.id && !site.id.includes('bidid')) {
// found a matching request; add this bid

const bidFloor = (bidRequest.params && bidRequest.params.bidFloor) ? bidRequest.params.bidFloor : 0;
// store site data for future notification
oneCodeDetection[bidId] = [site.id, site.slot];

const bid = {
requestId: bidRequest.bidId,
creativeId: serverBid.crid || 'mcad_' + request.bidderRequest.auctionId + '_' + request.bidderRequest.params.id,
cpm: serverBid.price,
requestId: bidId,
creativeId: crid || 'mcad_' + bidderRequest.auctionId + '_' + site.slot,
cpm: price,
currency: response.cur,
ttl: serverBid.exp || 300,
width: serverBid.w,
height: serverBid.h,
ttl: exp || 300,
width: w,
height: h,
bidderCode: BIDDER_CODE,
mediaType: 'banner',
meta: {
advertiserDomains: serverBid.adomain,
advertiserDomains: adomain,
networkName: seat,
},
netRevenue: true,
ad: renderCreative(site, response.id, serverBid, seat, request.bidderRequest),
ad: renderCreative(site, response.id, serverBid, seat, bidderRequest),
};

if (bid.cpm > 0) {
if (bid.cpm >= bidFloor) {
// check bidFloor (if present in params)
const { bidFloor } = params || {};

if (!bidFloor || bid.cpm >= bidFloor) {
bids.push(bid);
} else {
utils.logWarn('Discarding bid due to bidFloor setting', bid.cpm, bidFloor);
Expand Down
2 changes: 2 additions & 0 deletions modules/sspBCBidAdapter.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Required parameters:
Optional parameters:
- site id
- adslot id
- publisher id
- domain
- page
- tmax
Expand All @@ -37,6 +38,7 @@ var adUnits = [
params: {
id: '006', // optional
siteId: '235911', // optional
publisherId: '728' // optional
domain: 'somesite.pl', // optional
page: 'somesite.pl/somepage.html', // optional
tmax: 250, // optional
Expand Down