Skip to content

Commit

Permalink
Revert changes for switch between client side and server side. (prebi…
Browse files Browse the repository at this point in the history
…d#1653)

* Revert changes for switch between client side and server side.

* remove accidental change

* double comma

* update sync flag
  • Loading branch information
Matt Kendall authored and dluxemburg committed Jul 17, 2018
1 parent cfeebf1 commit cbc37d2
Show file tree
Hide file tree
Showing 6 changed files with 4 additions and 104 deletions.
8 changes: 3 additions & 5 deletions modules/prebidServerBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ import { STATUS, S2S } from 'src/constants';
import { cookieSet } from 'src/cookie.js';
import adaptermanager from 'src/adaptermanager';
import { config } from 'src/config';
import { StorageManager, pbjsSyncsKey } from 'src/storagemanager';

const getConfig = config.getConfig;

const TYPE = S2S.SRC;
const cookieSetUrl = 'https://acdn.adnxs.com/cookieset/cs.js';
let _synced = false;

/**
* Try to convert a value to a type.
Expand Down Expand Up @@ -234,12 +234,10 @@ function PrebidServer() {
* @param {} {bidders} list of bidders to request user syncs for.
*/
baseAdapter.queueSync = function({bidderCodes}) {
let syncedList = StorageManager.get(pbjsSyncsKey) || [];
// filter synced bidders - https://github.com/prebid/Prebid.js/issues/1582
syncedList = bidderCodes.filter(bidder => !syncedList.includes(bidder));
if (syncedList.length === 0) {
if (_synced) {
return;
}
_synced = true;
const payload = JSON.stringify({
uuid: utils.generateUUID(),
bidders: bidderCodes
Expand Down
4 changes: 1 addition & 3 deletions src/adaptermanager.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import { flatten, getBidderCodes, getDefinedParams, shuffle } from './utils';
import { mapSizes } from './sizeMapping';
import { processNativeAdUnitParams, nativeAdapters } from './native';
import { StorageManager, pbjsSyncsKey } from './storagemanager';

var utils = require('./utils.js');
var CONSTANTS = require('./constants.json');
Expand Down Expand Up @@ -88,7 +87,6 @@ exports.callBids = ({adUnits, cbTimeout}) => {
events.emit(CONSTANTS.EVENTS.AUCTION_INIT, auctionInit);

let bidderCodes = getBidderCodes(adUnits);
const syncedBidders = StorageManager.get(pbjsSyncsKey);
if (_bidderSequence === RANDOM) {
bidderCodes = shuffle(bidderCodes);
}
Expand All @@ -101,7 +99,7 @@ exports.callBids = ({adUnits, cbTimeout}) => {

if (_s2sConfig.enabled) {
// these are called on the s2s adapter
let adaptersServerSide = _s2sConfig.bidders.filter(bidder => syncedBidders.includes(bidder));
let adaptersServerSide = _s2sConfig.bidders;

// don't call these client side
bidderCodes = bidderCodes.filter((elm) => {
Expand Down
48 changes: 0 additions & 48 deletions src/storagemanager.js

This file was deleted.

32 changes: 0 additions & 32 deletions test/spec/modules/prebidServerBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import CONSTANTS from 'src/constants.json';
import * as utils from 'src/utils';
import cookie from 'src/cookie';
import { userSync } from 'src/userSync';
import { StorageManager } from 'src/storagemanager';

let CONFIG = {
accountId: '1',
Expand Down Expand Up @@ -178,37 +177,6 @@ describe('S2S Adapter', () => {

beforeEach(() => adapter = new Adapter());

describe('queue sync function', () => {
let server;
let storageManagerAddStub;

beforeEach(() => {
server = sinon.fakeServer.create();
storageManagerAddStub = sinon.stub(StorageManager, 'add');
});

afterEach(() => {
server.restore();
storageManagerAddStub.restore();
localStorage.removeItem('pbjsSyncs');
});

it('exists and is a function', () => {
expect(adapter.queueSync).to.exist.and.to.be.a('function');
});

it('requests only bidders that are not already synced', () => {
server.respondWith(JSON.stringify({status: 'ok', bidderCodes: ['rubicon'] }));
const reqBidderCodes = ['appnexus', 'newBidder'];
const syncedBidders = ['appnexus', 'rubicon'];
localStorage.setItem('pbjsSyncs', JSON.stringify(syncedBidders));
adapter.setConfig(CONFIG);
adapter.queueSync({bidderCodes: reqBidderCodes});
server.respond();
sinon.assert.calledTwice(storageManagerAddStub);
});
});

describe('request function', () => {
let xhr;
let requests;
Expand Down
15 changes: 0 additions & 15 deletions test/spec/unit/core/adapterManager_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import AdapterManager from 'src/adaptermanager';
import { getAdUnits } from 'test/fixtures/fixtures';
import CONSTANTS from 'src/constants.json';
import * as utils from 'src/utils';
import { StorageManager } from 'src/storagemanager';

const CONFIG = {
enabled: true,
Expand All @@ -29,23 +28,9 @@ describe('adapterManager tests', () => {
AdapterManager.setS2SConfig(CONFIG);
AdapterManager.bidderRegistry['prebidServer'] = prebidServerAdapterMock;

stubGetStorageItem = sinon.stub(StorageManager, 'get');
stubSetStorageItem = sinon.stub(StorageManager, 'set');
stubSetStorageItem = sinon.stub(StorageManager, 'add');
stubSetStorageItem = sinon.stub(StorageManager, 'remove');

stubGetStorageItem.returns(['appnexus']);

prebidServerAdapterMock.callBids.reset();
});

afterEach(() => {
StorageManager.get.restore();
StorageManager.set.restore();
StorageManager.add.restore();
StorageManager.remove.restore();
});

it('invokes callBids on the S2S adapter', () => {
AdapterManager.callBids({adUnits: getAdUnits()});
sinon.assert.calledOnce(prebidServerAdapterMock.callBids);
Expand Down
1 change: 0 additions & 1 deletion test/spec/userSync_spec.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { expect } from 'chai';
import { config } from 'src/config';
import { StorageManager, pbjsSyncsKey } from 'src/storagemanager';
// Use require since we need to be able to write to these vars
const utils = require('../../src/utils');
let { newUserSync } = require('../../src/userSync');
Expand Down

0 comments on commit cbc37d2

Please sign in to comment.