Skip to content

Commit

Permalink
Dailymotion Bid Adapter: send user sync status in request
Browse files Browse the repository at this point in the history
  • Loading branch information
Kevin Siow committed Jul 3, 2024
1 parent 9529ae3 commit 3edefca
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 0 deletions.
17 changes: 17 additions & 0 deletions modules/dailymotionBidAdapter.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { registerBidder } from '../src/adapters/bidderFactory.js';
import { VIDEO } from '../src/mediaTypes.js';
import { deepAccess } from '../src/utils.js';
import { config } from '../src/config.js';
import { userSync } from '../src/userSync.js';

/**
* Get video metadata from bid request
Expand Down Expand Up @@ -90,6 +92,20 @@ function getVideoMetadata(bidRequest, bidderRequest) {
return videoMetadata;
}

/**
* Check if user sync is enabled for Dailymotion
*
* @return boolean True if user sync is enabled
*/
function isUserSyncEnabled() {
const syncEnabled = deepAccess(config.getConfig('userSync'), 'syncEnabled');

const canSyncWithIframe = syncEnabled && userSync.canBidderRegisterSync('iframe', 'dailymotion');
const canSyncWithPixel = syncEnabled && userSync.canBidderRegisterSync('image', 'dailymotion');

return !!(canSyncWithIframe || canSyncWithPixel);
}

export const spec = {
code: 'dailymotion',
gvlid: 573,
Expand Down Expand Up @@ -170,6 +186,7 @@ export const spec = {
atts: deepAccess(bidderRequest, 'ortb2.device.ext.atts', 0),
},
} : {}),
userSyncEnabled: isUserSyncEnabled(),
request: {
adUnitCode: deepAccess(bid, 'adUnitCode', ''),
auctionId: deepAccess(bid, 'auctionId', ''),
Expand Down
46 changes: 46 additions & 0 deletions test/spec/modules/dailymotionBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,18 @@ describe('dailymotionBidAdapterTests', () => {
},
};

config.setConfig({
userSync: {
syncEnabled: true,
filterSettings: {
all: {
bidders: '*',
filter: 'include'
}
}
}
});

const [request] = config.runWithBidder(
'dailymotion',
() => spec.buildRequests(bidRequestData, bidderRequestData),
Expand All @@ -168,6 +180,7 @@ describe('dailymotionBidAdapterTests', () => {
expect(request.url).to.equal('https://pb.dmxleo.com');

expect(reqData.pbv).to.eql('$prebid.version$');
expect(reqData.userSyncEnabled).to.be.true;
expect(reqData.bidder_request).to.eql({
refererInfo: bidderRequestData.refererInfo,
uspConsent: bidderRequestData.uspConsent,
Expand Down Expand Up @@ -297,6 +310,18 @@ describe('dailymotionBidAdapterTests', () => {
},
};

config.setConfig({
userSync: {
syncEnabled: true,
filterSettings: {
iframe: {
bidders: ['dailymotion'],
filter: 'include'
}
}
}
});

const [request] = config.runWithBidder(
'dailymotion',
() => spec.buildRequests(bidRequestData, bidderRequestData),
Expand All @@ -307,6 +332,7 @@ describe('dailymotionBidAdapterTests', () => {
expect(request.url).to.equal('https://pb.dmxleo.com');

expect(reqData.pbv).to.eql('$prebid.version$');
expect(reqData.userSyncEnabled).to.be.true;
expect(reqData.bidder_request).to.eql({
refererInfo: bidderRequestData.refererInfo,
uspConsent: bidderRequestData.uspConsent,
Expand Down Expand Up @@ -449,6 +475,18 @@ describe('dailymotionBidAdapterTests', () => {
},
};

config.setConfig({
userSync: {
syncEnabled: true,
filterSettings: {
image: {
bidders: ['dailymotion'],
filter: 'include'
}
}
}
});

const [request] = config.runWithBidder(
'dailymotion',
() => spec.buildRequests(bidRequestData, bidderRequestData),
Expand All @@ -459,6 +497,7 @@ describe('dailymotionBidAdapterTests', () => {
expect(request.url).to.equal('https://pb.dmxleo.com');

expect(reqData.pbv).to.eql('$prebid.version$');
expect(reqData.userSyncEnabled).to.be.true;
expect(reqData.bidder_request).to.eql({
refererInfo: bidderRequestData.refererInfo,
uspConsent: bidderRequestData.uspConsent,
Expand Down Expand Up @@ -519,6 +558,12 @@ describe('dailymotionBidAdapterTests', () => {
},
}];

config.setConfig({
userSync: {
syncEnabled: false,
}
});

const [request] = config.runWithBidder(
'dailymotion',
() => spec.buildRequests(bidRequestDataWithApi, {}),
Expand All @@ -532,6 +577,7 @@ describe('dailymotionBidAdapterTests', () => {
expect(reqData.coppa).to.be.false;

expect(reqData.pbv).to.eql('$prebid.version$');
expect(reqData.userSyncEnabled).to.be.false;
expect(reqData.bidder_request).to.eql({
gdprConsent: {
apiVersion: 1,
Expand Down

0 comments on commit 3edefca

Please sign in to comment.