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

Revert changes for switch between client side and server side. #1653

Merged
merged 4 commits into from
Oct 3, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
8 changes: 3 additions & 5 deletions modules/prebidServerBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ import { userSync } from 'src/userSync.js';
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 @@ -214,12 +214,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 @@ -158,37 +157,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