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

fix for not syncing bidders. #1598

Merged
merged 2 commits into from
Sep 19, 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
5 changes: 3 additions & 2 deletions modules/prebidServerBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -212,10 +212,11 @@ function PrebidServer() {
*/
baseAdapter.queueSync = function({bidderCodes}) {
let syncedList = StorageManager.get(pbjsSyncsKey) || [];
if (_cookiesQueued || syncedList.length === bidderCodes.length) {
// filter synced bidders - https://github.com/prebid/Prebid.js/issues/1582
syncedList = bidderCodes.filter(bidder => !syncedList.includes(bidder));
if (syncedList.length === 0) {
return;
}
_cookiesQueued = true;
const payload = JSON.stringify({
uuid: utils.generateUUID(),
bidders: bidderCodes
Expand Down
32 changes: 32 additions & 0 deletions test/spec/modules/prebidServerBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ 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 @@ -157,6 +158,37 @@ 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