Skip to content

Commit

Permalink
Revert "Sspbc Bid Adapter: update version and bugfixes (#7584)"
Browse files Browse the repository at this point in the history
This reverts commit d22b740.
  • Loading branch information
Rothalack committed Nov 3, 2021
1 parent 906e8c4 commit af82a6e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 67 deletions.
37 changes: 3 additions & 34 deletions modules/sspBCBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,11 @@ 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 = '5.3';
const BIDDER_VERSION = '5.2';
const W = window;
const { navigator } = W;
const oneCodeDetection = {};
const adUnitsCalled = {};
const adSizesCalled = {};
const pageView = {};
var consentApiVersion;

/**
Expand Down Expand Up @@ -72,7 +70,6 @@ const cookieSupport = () => {
};

const applyClientHints = ortbRequest => {
const { location } = document;
const { connection = {}, deviceMemory, userAgentData = {} } = navigator;
const viewport = W.visualViewport || false;
const segments = [];
Expand All @@ -88,16 +85,6 @@ const applyClientHints = ortbRequest => {
'CH-isMobile': userAgentData.mobile,
};

/**
Check / generate page view id
Should be generated dureing first call to applyClientHints(),
and re-generated if pathname has changed
*/
if (!pageView.id || location.pathname !== pageView.path) {
pageView.path = location.pathname;
pageView.id = Math.floor(1E20 * Math.random());
}

Object.keys(hints).forEach(key => {
const hint = hints[key];

Expand All @@ -113,14 +100,6 @@ const applyClientHints = ortbRequest => {
id: '12',
name: 'NetInfo',
segment: segments,
}, {
id: '7',
name: 'pvid',
segment: [
{
value: `${pageView.id}`
}
]
}];

ortbRequest.user = Object.assign(ortbRequest.user, { data });
Expand Down Expand Up @@ -150,7 +129,6 @@ const setOnAny = (collection, key) => collection.reduce((prev, next) => prev ||
*/
const sendNotification = payload => {
ajax(NOTIFY_URL, null, JSON.stringify(payload), {
contentType: 'application/json',
withCredentials: false,
method: 'POST',
crossOrigin: true
Expand Down Expand Up @@ -289,14 +267,8 @@ const mapImpression = slot => {
send this info as ext.pbsize
*/
const slotSize = slot.sizes.length ? slot.sizes.reduce((prev, next) => prev[0] * prev[1] <= next[0] * next[1] ? next : prev).join('x') : '1x1';

if (!adUnitsCalled[adUnitCode]) {
// this is a new adunit - assign & save pbsize
adSizesCalled[slotSize] = adSizesCalled[slotSize] ? adSizesCalled[slotSize] += 1 : 1;
adUnitsCalled[adUnitCode] = `${slotSize}_${adSizesCalled[slotSize]}`
}

ext.data = Object.assign({ pbsize: adUnitsCalled[adUnitCode] }, ext.data);
adSizesCalled[slotSize] = adSizesCalled[slotSize] ? adSizesCalled[slotSize] += 1 : 1;
ext.data = Object.assign({ pbsize: `${slotSize}_${adSizesCalled[slotSize]}` }, ext.data);

const imp = {
id: id && siteId ? id : 'bidid-' + bidId,
Expand Down Expand Up @@ -353,9 +325,6 @@ const parseNative = nativeData => {
case 0:
result.title = asset.title.text;
break;
case 1:
result.cta = asset.data.value;
break;
case 2:
result.icon = {
url: asset.img.url,
Expand Down
36 changes: 3 additions & 33 deletions test/spec/modules/sspBCBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -518,33 +518,6 @@ describe('SSPBC adapter', function () {
expect(payload.user).to.be.an('object').and.to.have.property('[ortb_extensions.consent]', bidRequest.gdprConsent.consentString);
});

it('should send net info and pvid', function () {
expect(payload.user).to.be.an('object').and.to.have.property('data').that.is.an('array');

const userData = payload.user.data;
expect(userData.length).to.equal(2);

const netInfo = userData[0];
expect(netInfo.id).to.equal('12');
expect(netInfo.name).to.equal('NetInfo');
expect(netInfo).to.have.property('segment').that.is.an('array');

const pvid = userData[1];
expect(pvid.id).to.equal('7');
expect(pvid.name).to.equal('pvid');
expect(pvid).to.have.property('segment').that.is.an('array');
expect(pvid.segment[0]).to.have.property('value');
});

it('pvid should be constant on a single page view', function () {
const userData1 = payload.user.data;
const userData2 = payloadNative.user.data;
const pvid1 = userData1[1];
const pvid2 = userData2[1];

expect(pvid1.segment[0].value).to.equal(pvid2.segment[0].value);
});

it('should build correct native payload', function () {
const nativeAssets = payloadNative.imp && payloadNative.imp[0].native.request;

Expand All @@ -570,16 +543,13 @@ describe('SSPBC adapter', function () {
expect(videoAssets).to.have.property('api').that.is.an('array');
});

it('should create auxilary placement identifier (size_numUsed), that is constant for a given adUnit', function () {
it('should create auxilary placement identifier (size_numUsed)', function () {
const extAssets1 = payload.imp && payload.imp[0].ext.data;
const extAssets2 = payloadSingle.imp && payloadSingle.imp[0].ext.data;

/*
note that payload comes from first, and payloadSingle from second auction in the test run
also, since both have same adUnitName, value of pbsize property should be the same
*/
// note that payload comes from first, and payloadSingle from second auction in the test run
expect(extAssets1).to.have.property('pbsize').that.equals('750x200_1')
expect(extAssets2).to.have.property('pbsize').that.equals('750x200_1')
expect(extAssets2).to.have.property('pbsize').that.equals('750x200_2')
});
});

Expand Down

0 comments on commit af82a6e

Please sign in to comment.