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

Dailymotion Bid Adapter: send user sync status in request #32

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
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');

jeremy-le-dev marked this conversation as resolved.
Show resolved Hide resolved
if (!syncEnabled) return false;

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

return !!(canSyncWithIframe || canSyncWithPixel);
jeremy-le-dev marked this conversation as resolved.
Show resolved Hide resolved
}

export const spec = {
code: 'dailymotion',
gvlid: 573,
Expand Down Expand Up @@ -170,6 +188,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