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 15, 2024
1 parent 6a85621 commit 893141d
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 0 deletions.
19 changes: 19 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,22 @@ 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');

if (!syncEnabled) return false;

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

return !!(canSyncWithIframe || canSyncWithPixel);
}

export const spec = {
code: 'dailymotion',
gvlid: 573,
Expand Down Expand Up @@ -189,6 +207,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
50 changes: 50 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 @@ -169,6 +181,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 @@ -790,6 +803,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 @@ -800,6 +825,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 @@ -942,6 +968,22 @@ describe('dailymotionBidAdapterTests', () => {
},
};

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

const [request] = config.runWithBidder(
'dailymotion',
() => spec.buildRequests(bidRequestData, bidderRequestData),
Expand All @@ -952,6 +994,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 @@ -1012,6 +1055,12 @@ describe('dailymotionBidAdapterTests', () => {
},
}];

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

const [request] = config.runWithBidder(
'dailymotion',
() => spec.buildRequests(bidRequestDataWithApi, {}),
Expand All @@ -1025,6 +1074,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 893141d

Please sign in to comment.