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

Add new s2s config option #3643

Merged
merged 3 commits into from
Mar 25, 2019
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
22 changes: 20 additions & 2 deletions modules/prebidServerBidAdapter/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ const s2sDefaultConfig = {
timeout: 1000,
maxBids: 1,
adapter: 'prebidServer',
adapterOptions: {}
adapterOptions: {},
syncUrlModifier: {}
};

config.setDefaults({
Expand Down Expand Up @@ -170,12 +171,29 @@ function doAllSyncs(bidders) {

const thisSync = bidders.pop();
if (thisSync.no_cookie) {
doBidderSync(thisSync.usersync.type, thisSync.usersync.url, thisSync.bidder, utils.bind.call(doAllSyncs, null, bidders));
doPreBidderSync(thisSync.usersync.type, thisSync.usersync.url, thisSync.bidder, utils.bind.call(doAllSyncs, null, bidders));
} else {
doAllSyncs(bidders);
}
}

/**
* Modify the cookie sync url from prebid server to add new params.
*
* @param {string} type the type of sync, "image", "redirect", "iframe"
* @param {string} url the url to sync
* @param {string} bidder name of bidder doing sync for
* @param {function} done an exit callback; to signify this pixel has either: finished rendering or something went wrong
*/
function doPreBidderSync(type, url, bidder, done) {
if (_s2sConfig.syncUrlModifier && typeof _s2sConfig.syncUrlModifier[bidder] === 'function') {
const newSyncUrl = _s2sConfig.syncUrlModifier[bidder](type, url, bidder);
doBidderSync(type, newSyncUrl, bidder, done)
} else {
doBidderSync(type, url, bidder, done)
}
}

/**
* Run a cookie sync for the given type, url, and bidder
*
Expand Down
11 changes: 11 additions & 0 deletions test/spec/modules/prebidServerBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1460,5 +1460,16 @@ describe('S2S Adapter', function () {
}
})
});

it('should set syncUrlModifier', function () {
config.setConfig({
s2sConfig: {
syncUrlModifier: {
appnexus: () => {}
}
}
});
expect(typeof config.getConfig('s2sConfig').syncUrlModifier.appnexus).to.equal('function')
});
});
});