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: remove dependence on auctionId, improve notifications #10222

Merged
merged 39 commits into from
Jul 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
1a37b62
Merge pull request #1 from prebid/master
wojciech-bialy-wpm Aug 18, 2020
5a90ba4
Update tests for sspBC adapter
wojciech-bialy-wpm Nov 16, 2020
2183a85
Merge pull request #9 from prebid/master
wojciech-bialy-wpm May 20, 2021
767334b
Merge pull request #11 from prebid/master
wojciech-bialy-wpm Jun 1, 2021
97d7ccf
Merge pull request #13 from prebid/master
wojciech-bialy-wpm Jul 29, 2021
8856c36
Merge pull request #15 from prebid/master
wojciech-bialy-wpm Sep 21, 2021
754df70
Merge pull request #16 from prebid/master
wojciech-bialy-wpm Oct 7, 2021
273e7db
[sspbc-adapter] 5.3 updates: content-type for notifications
Oct 8, 2021
08c90fb
[sspbc-adapter] pass CTA to native bid
Oct 14, 2021
363d342
[sspbc-5.3] keep pbsize for detected adunits
Oct 14, 2021
9f9cc49
[maintenance] - remove old test for sspBc bid adaptor
Oct 14, 2021
22b2afc
[sspbc-5.3] increment adaptor ver
Oct 14, 2021
62dad10
[sspbc-adapter] maintenance update to sspBCBidAdapter
Oct 14, 2021
65a7738
remove yarn.lock
Oct 14, 2021
d224072
Merge pull request #17 from prebid/master
wojciech-bialy-wpm Oct 14, 2021
cf9f3e0
Delete package-lock.json
wojciech-bialy-wpm Oct 25, 2021
1721574
remove package-lock.jsonfrom pull request
Oct 25, 2021
ee21d84
update sspbc-5.3 branch
Oct 25, 2021
170fdcd
Merge branch 'master' of https://github.com/prebid/Prebid.js into ssp…
Oct 25, 2021
26ca477
[sspbc-adapter] send pageViewId in request
Oct 25, 2021
2a8278b
[sspbc-adapter] update pageViewId test
Oct 25, 2021
14ac217
Merge pull request #19 from prebid/master
wojciech-bialy-wpm Nov 16, 2021
6d5bbd3
[sspbc-adapter] add viewabiility tracker to native ads
Nov 16, 2021
75174f6
[sspbc-adapter] add support for bid.admNative property
Nov 16, 2021
7891a9e
[sspbc-adapter] ensure that placement id length is always 3 (improves…
Nov 18, 2021
ad6a21a
[sspbc-adapter] read publisher id and custom ad label, then send them…
Nov 18, 2021
e422156
[sspbc-adapter] adlabel and pubid are set as empty strings, if not pr…
Nov 18, 2021
9a792f0
[sspbc-adapter] jstracker data fix
Nov 22, 2021
9ea4c7c
[sspbc-adapter] jstracker data fix
Nov 22, 2021
4461f6f
[sspbc-adapter] send tagid in notifications
Nov 24, 2021
ca7c5b4
[sspbc-adapter] add gvlid to spec; prepare getUserSyncs for iframe + …
Nov 26, 2021
e419627
update remote repo
wojciech-bialy-wpm Sep 20, 2022
af81f6f
update remote repo
wojciech-bialy-wpm Sep 20, 2022
cb7eed2
update remote repo
wojciech-bialy-wpm Sep 20, 2022
99801d1
Merge pull request #28 from prebid/master
wojciech-bialy-wpm Jul 3, 2023
7bb7efa
Merge pull request #29 from prebid/master
wojciech-bialy-wpm Jul 12, 2023
ac9e623
cleanup of grupawp/prebid master branch
wojciech-bialy-wpm Jul 12, 2023
5a206fd
update sspBC adapter to v 5.9
wojciech-bialy-wpm Jul 12, 2023
6d1f2a8
update tests for sspBC bid adapter
wojciech-bialy-wpm Jul 13, 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
49 changes: 36 additions & 13 deletions modules/sspBCBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,14 @@ const SYNC_URL = 'https://ssp.wp.pl/bidder/usersync';
const NOTIFY_URL = 'https://ssp.wp.pl/bidder/notify';
const GVLID = 676;
const TMAX = 450;
const BIDDER_VERSION = '5.8';
const BIDDER_VERSION = '5.9';
const DEFAULT_CURRENCY = 'PLN';
const W = window;
const { navigator } = W;
const oneCodeDetection = {};
const adUnitsCalled = {};
const adSizesCalled = {};
const bidderRequestsMap = {};
const pageView = {};
var consentApiVersion;

Expand Down Expand Up @@ -93,19 +94,17 @@ const getNotificationPayload = bidData => {
const bids = isArray(bidData) ? bidData : [bidData];
if (bids.length > 0) {
let result = {
requestId: undefined,
siteId: [],
slotId: [],
tagid: [],
}
bids.forEach(bid => {
const { adUnitCode, auctionId, cpm, creativeId, meta, params: bidParams, requestId, timeout } = bid;
const { adUnitCode, cpm, creativeId, meta, mediaType, params: bidParams, bidderRequestId, requestId, timeout } = bid;
const params = unpackParams(bidParams);

// basic notification data
const bidBasicData = {
// TODO: fix auctionId leak: https://github.com/prebid/Prebid.js/issues/9781
requestId: auctionId || result.requestId,
requestId: bidderRequestId || bidderRequestsMap[requestId],
timeout: timeout || result.timeout,
pvid: pageView.id,
}
Expand All @@ -127,12 +126,14 @@ const getNotificationPayload = bidData => {

if (cpm) {
// non-empty bid data
const { advertiserDomains = [], networkName, pricepl } = meta;
const bidNonEmptyData = {
cpm,
cpmpl: meta && meta.pricepl,
cpmpl: pricepl,
creativeId,
adomain: meta && meta.advertiserDomains && meta.advertiserDomains[0],
networkName: meta && meta.networkName,
adomain: advertiserDomains[0],
adtype: mediaType,
networkName,
}
result = { ...result, ...bidNonEmptyData }
}
Expand Down Expand Up @@ -447,10 +448,15 @@ var mapVideo = (slot, videoFromBid) => {
};

const mapImpression = slot => {
const { adUnitCode, bidId, params = {}, ortb2Imp = {} } = slot;
const { adUnitCode, bidderRequestId, bidId, params = {}, ortb2Imp = {} } = slot;
const { id, siteId, video } = params;
const { ext = {} } = ortb2Imp;

/*
store bidId <-> bidderRequestId mapping for bidWon notification
*/
bidderRequestsMap[bidId] = bidderRequestId;

/*
check max size for this imp, and check/store number this size was called (for current view)
send this info as ext.pbsize
Expand Down Expand Up @@ -494,15 +500,20 @@ const isNativeAd = bid => {
return bid.admNative || (bid.adm && bid.adm.match(xmlTester));
}

const parseNative = (nativeData) => {
const parseNative = (nativeData, adUnitCode) => {
const { link = {}, imptrackers: impressionTrackers, jstracker } = nativeData;
const { url: clickUrl, clicktrackers: clickTrackers = [] } = link;
const macroReplacer = tracker => tracker.replace(new RegExp('%native_dom_id%', 'g'), adUnitCode);
let javascriptTrackers = isArray(jstracker) ? jstracker : jstracker && [jstracker];

// replace known macros in js trackers
javascriptTrackers = javascriptTrackers && javascriptTrackers.map(macroReplacer);

const result = {
clickUrl,
clickTrackers,
impressionTrackers,
javascriptTrackers: isArray(jstracker) ? jstracker : jstracker && [jstracker],
javascriptTrackers,
};

nativeData.assets.forEach(asset => {
Expand Down Expand Up @@ -627,6 +638,8 @@ const spec = {
return true;
},
buildRequests(validBidRequests, bidderRequest) {
logWarn('DEBUG: buildRequests', bidderRequest.auctionId, bidderRequest.bidderRequestId);

// convert Native ORTB definition to old-style prebid native definition
validBidRequests = convertOrtbRequestToProprietaryNative(validBidRequests);

Expand All @@ -644,7 +657,7 @@ const spec = {
const ref = bidderRequest.refererInfo.ref;

const payload = {
id: bidderRequest.auctionId,
id: bidderRequest.bidderRequestId,
site: {
id: siteId ? `${siteId}` : undefined,
publisher: publisherId ? { id: publisherId } : undefined,
Expand Down Expand Up @@ -725,6 +738,7 @@ const spec = {

if (bidRequest && site.id && !strIncludes(site.id, 'bidid')) {
// found a matching request; add this bid
const { adUnitCode } = bidRequest;

// store site data for future notification
oneCodeDetection[bidId] = [site.id, site.slot];
Expand Down Expand Up @@ -760,7 +774,7 @@ const spec = {
// check native object
try {
const nativeData = serverBid.admNative || JSON.parse(serverBid.adm).native;
bid.native = parseNative(nativeData);
bid.native = parseNative(nativeData, adUnitCode);
bid.width = 1;
bid.height = 1;
} catch (err) {
Expand Down Expand Up @@ -807,6 +821,15 @@ const spec = {
}
},

onBidViewable(bid) {
const payload = getNotificationPayload(bid);
if (payload) {
payload.event = 'bidViewable';
sendNotification(payload);
return payload;
}
},

onBidWon(bid) {
const payload = getNotificationPayload(bid);
if (payload) {
Expand Down
37 changes: 18 additions & 19 deletions test/spec/modules/sspBCBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ describe('SSPBC adapter', function () {
},
auctionId,
bidderRequestId,
bidId: auctionId + '1',
bidId: bidderRequestId + '1',
transactionId,
},
{
Expand All @@ -60,7 +60,7 @@ describe('SSPBC adapter', function () {
},
auctionId,
bidderRequestId,
bidId: auctionId + '2',
bidId: bidderRequestId + '2',
transactionId,
}
];
Expand All @@ -83,7 +83,7 @@ describe('SSPBC adapter', function () {
],
auctionId,
bidderRequestId,
bidId: auctionId + '1',
bidId: bidderRequestId + '1',
transactionId,
};
const bid_native = {
Expand Down Expand Up @@ -122,7 +122,7 @@ describe('SSPBC adapter', function () {
],
auctionId,
bidderRequestId,
bidId: auctionId + '1',
bidId: bidderRequestId + '1',
transactionId,
};
const bid_video = {
Expand All @@ -144,7 +144,7 @@ describe('SSPBC adapter', function () {
],
auctionId,
bidderRequestId,
bidId: auctionId + '1',
bidId: bidderRequestId + '1',
transactionId,
};
const bids_timeouted = [{
Expand All @@ -155,7 +155,7 @@ describe('SSPBC adapter', function () {
siteId: '8816',
}],
auctionId,
bidId: auctionId + '1',
bidId: bidderRequestId + '1',
timeout: 100,
},
{
Expand All @@ -166,7 +166,7 @@ describe('SSPBC adapter', function () {
siteId: '8816',
}],
auctionId,
bidId: auctionId + '2',
bidId: bidderRequestId + '2',
timeout: 100,
}
];
Expand Down Expand Up @@ -198,7 +198,7 @@ describe('SSPBC adapter', function () {
},
auctionId,
bidderRequestId,
bidId: auctionId + '1',
bidId: bidderRequestId + '1',
transactionId,
}];
const bidRequest = {
Expand Down Expand Up @@ -293,7 +293,7 @@ describe('SSPBC adapter', function () {
};
const serverResponse = {
'body': {
'id': auctionId,
'id': bidderRequestId,
'seatbid': [{
'bid': [{
'id': '3347324c-6889-46d2-a800-ae78a5214c06',
Expand Down Expand Up @@ -333,7 +333,7 @@ describe('SSPBC adapter', function () {
};
const serverResponseSingle = {
'body': {
'id': auctionId,
'id': bidderRequestId,
'seatbid': [{
'bid': [{
'id': '3347324c-6889-46d2-a800-ae78a5214c06',
Expand All @@ -358,11 +358,11 @@ describe('SSPBC adapter', function () {
};
const serverResponseOneCode = {
'body': {
'id': auctionId,
'id': bidderRequestId,
'seatbid': [{
'bid': [{
'id': '3347324c-6889-46d2-a800-ae78a5214c06',
'impid': 'bidid-' + auctionId + '1',
'impid': 'bidid-' + bidderRequestId + '1',
'price': 1,
'adid': 'lxHWkB7OnZeso3QiN1N4',
'nurl': '',
Expand All @@ -385,11 +385,11 @@ describe('SSPBC adapter', function () {
};
const serverResponseVideo = {
'body': {
'id': auctionId,
'id': bidderRequestId,
'seatbid': [{
'bid': [{
'id': '3347324c-6889-46d2-a800-ae78a5214c06',
'impid': 'bidid-' + auctionId + '1',
'impid': 'bidid-' + bidderRequestId + '1',
'price': 1,
'adid': 'lxHWkB7OnZeso3QiN1N4',
'nurl': '',
Expand All @@ -413,11 +413,11 @@ describe('SSPBC adapter', function () {
};
const serverResponseNative = {
'body': {
'id': auctionId,
'id': bidderRequestId,
'seatbid': [{
'bid': [{
'id': '3347324c-6889-46d2-a800-ae78a5214c06',
'impid': 'bidid-' + auctionId + '1',
'impid': 'bidid-' + bidderRequestId + '1',
'price': 1,
'adid': 'lxHWkB7OnZeso3QiN1N4',
'nurl': '',
Expand All @@ -438,7 +438,7 @@ describe('SSPBC adapter', function () {
};
const emptyResponse = {
'body': {
'id': auctionId,
'id': bidderRequestId,
}
}
return {
Expand Down Expand Up @@ -696,7 +696,7 @@ describe('SSPBC adapter', function () {

let notificationPayload = spec.onBidWon(bid);
expect(notificationPayload).to.have.property('event').that.equals('bidWon');
expect(notificationPayload).to.have.property('requestId').that.equals(bid.auctionId);
expect(notificationPayload).to.have.property('requestId').that.equals(bid.bidderRequestId);
expect(notificationPayload).to.have.property('tagid').that.deep.equals([bid.adUnitCode]);
expect(notificationPayload).to.have.property('siteId').that.is.an('array');
expect(notificationPayload).to.have.property('slotId').that.is.an('array');
Expand All @@ -717,7 +717,6 @@ describe('SSPBC adapter', function () {
let notificationPayload = spec.onTimeout(bids_timeouted);

expect(notificationPayload).to.have.property('event').that.equals('timeout');
expect(notificationPayload).to.have.property('requestId').that.equals(bids_timeouted[0].auctionId);
expect(notificationPayload).to.have.property('tagid').that.deep.equals([bids_timeouted[0].adUnitCode, bids_timeouted[1].adUnitCode]);
});
});
Expand Down