diff --git a/modules/yieldmoBidAdapter.js b/modules/yieldmoBidAdapter.js index bc29f4822c8..f495727577c 100644 --- a/modules/yieldmoBidAdapter.js +++ b/modules/yieldmoBidAdapter.js @@ -25,6 +25,7 @@ const TIME_TO_LIVE = 300; const NET_REVENUE = true; const BANNER_SERVER_ENDPOINT = 'https://ads.yieldmo.com/exchange/prebid'; const VIDEO_SERVER_ENDPOINT = 'https://ads.yieldmo.com/exchange/prebidvideo'; +const PB_COOKIE_ASSIST_SYNC_ENDPOINT = `https://ads.yieldmo.com/pbcas`; const OUTSTREAM_VIDEO_PLAYER_URL = 'https://prebid-outstream.yieldmo.com/bundle.js'; const OPENRTB_VIDEO_BIDPARAMS = ['mimes', 'startdelay', 'placement', 'startdelay', 'skipafter', 'protocols', 'api', 'playbackmethod', 'maxduration', 'minduration', 'pos', 'skip', 'skippable']; @@ -176,8 +177,25 @@ export const spec = { return bids; }, - getUserSyncs: function () { - return []; + getUserSyncs: function(syncOptions, serverResponses, gdprConsent = {}, uspConsent = '') { + const syncs = []; + const gdprFlag = `&gdpr=${gdprConsent.gdprApplies ? 1 : 0}`; + const gdprString = `&gdpr_consent=${encodeURIComponent((gdprConsent.consentString || ''))}`; + const usPrivacy = `us_privacy=${encodeURIComponent(uspConsent)}`; + const pbCookieAssistSyncUrl = `${PB_COOKIE_ASSIST_SYNC_ENDPOINT}?${usPrivacy}${gdprFlag}${gdprString}`; + + if (syncOptions.iframeEnabled) { + syncs.push({ + type: 'iframe', + url: pbCookieAssistSyncUrl + '&type=iframe' + }); + } else if (syncOptions.pixelEnabled) { + syncs.push({ + type: 'image', + url: pbCookieAssistSyncUrl + '&type=image' + }); + } + return syncs; } }; registerBidder(spec); diff --git a/test/spec/modules/yieldmoBidAdapter_spec.js b/test/spec/modules/yieldmoBidAdapter_spec.js index f72705a79ac..f36c804a18b 100644 --- a/test/spec/modules/yieldmoBidAdapter_spec.js +++ b/test/spec/modules/yieldmoBidAdapter_spec.js @@ -5,6 +5,7 @@ import * as utils from 'src/utils.js'; describe('YieldmoAdapter', function () { const BANNER_ENDPOINT = 'https://ads.yieldmo.com/exchange/prebid'; const VIDEO_ENDPOINT = 'https://ads.yieldmo.com/exchange/prebidvideo'; + const PB_COOKIE_ASSIST_SYNC_ENDPOINT = `https://ads.yieldmo.com/pbcas`; const mockBannerBid = (rootParams = {}, params = {}) => ({ bidder: 'yieldmo', @@ -606,8 +607,20 @@ describe('YieldmoAdapter', function () { }); describe('getUserSync', function () { - it('should return a tracker with type and url as parameters', function () { - expect(spec.getUserSyncs()).to.deep.equal([]); + const gdprFlag = `&gdpr=0`; + const usPrivacy = `us_privacy=`; + const gdprString = `&gdpr_consent=`; + const pbCookieAssistSyncUrl = `${PB_COOKIE_ASSIST_SYNC_ENDPOINT}?${usPrivacy}${gdprFlag}${gdprString}`; + it('should use type iframe when iframeEnabled', function() { + const syncs = spec.getUserSyncs({iframeEnabled: true}); + expect(syncs).to.deep.equal([{type: 'iframe', url: pbCookieAssistSyncUrl + '&type=iframe'}]) + }); + it('should use type image when pixelEnabled', function() { + const syncs = spec.getUserSyncs({pixelEnabled: true}); + expect(syncs).to.deep.equal([{type: 'image', url: pbCookieAssistSyncUrl + '&type=image'}]) + }); + it('should register no syncs', function () { + expect(spec.getUserSyncs({})).to.deep.equal([]); }); }); });