Skip to content

Commit 3e77fcc

Browse files
author
mi.chen
committed
Remove condition on enableSendAllBids and re-enable ad building while mediation mode off
1 parent 892fd93 commit 3e77fcc

File tree

2 files changed

+85
-62
lines changed

2 files changed

+85
-62
lines changed

modules/criteoBidAdapter.js

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,6 @@ export const spec = {
7979
if (publisherTagAvailable()) {
8080
// eslint-disable-next-line no-undef
8181
const adapter = new Criteo.PubTag.Adapters.Prebid(PROFILE_ID_PUBLISHERTAG, ADAPTER_VERSION, bidRequests, bidderRequest, '$prebid.version$');
82-
const enableSendAllBids = config.getConfig('enableSendAllBids');
83-
if (adapter.setEnableSendAllBids && typeof adapter.setEnableSendAllBids === 'function' && typeof enableSendAllBids === 'boolean') {
84-
adapter.setEnableSendAllBids(enableSendAllBids);
85-
}
8682
url = adapter.buildCdbUrl();
8783
data = adapter.buildCdbRequest();
8884
} else {
@@ -133,8 +129,6 @@ export const spec = {
133129
if (slot.native) {
134130
if (bidRequest.params.nativeCallback) {
135131
bid.ad = createNativeAd(bidId, slot.native, bidRequest.params.nativeCallback);
136-
} else if (config.getConfig('enableSendAllBids') === true) {
137-
return;
138132
} else {
139133
bid.native = createPrebidNativeAd(slot.native);
140134
bid.mediaType = NATIVE;
@@ -253,12 +247,14 @@ function buildCdbUrl(context) {
253247

254248
function checkNativeSendId(bidRequest) {
255249
return !(bidRequest.nativeParams &&
256-
((bidRequest.nativeParams.image && bidRequest.nativeParams.image.sendId !== true) ||
257-
(bidRequest.nativeParams.icon && bidRequest.nativeParams.icon.sendId !== true) ||
258-
(bidRequest.nativeParams.clickUrl && bidRequest.nativeParams.clickUrl.sendId !== true) ||
259-
(bidRequest.nativeParams.displayUrl && bidRequest.nativeParams.displayUrl.sendId !== true) ||
260-
(bidRequest.nativeParams.privacyLink && bidRequest.nativeParams.privacyLink.sendId !== true) ||
261-
(bidRequest.nativeParams.privacyIcon && bidRequest.nativeParams.privacyIcon.sendId !== true)));
250+
(
251+
(bidRequest.nativeParams.image && ((bidRequest.nativeParams.image.sendId !== true || bidRequest.nativeParams.image.sendTargetingKeys === true))) ||
252+
(bidRequest.nativeParams.icon && ((bidRequest.nativeParams.icon.sendId !== true || bidRequest.nativeParams.icon.sendTargetingKeys === true))) ||
253+
(bidRequest.nativeParams.clickUrl && ((bidRequest.nativeParams.clickUrl.sendId !== true || bidRequest.nativeParams.clickUrl.sendTargetingKeys === true))) ||
254+
(bidRequest.nativeParams.displayUrl && ((bidRequest.nativeParams.displayUrl.sendId !== true || bidRequest.nativeParams.displayUrl.sendTargetingKeys === true))) ||
255+
(bidRequest.nativeParams.privacyLink && ((bidRequest.nativeParams.privacyLink.sendId !== true || bidRequest.nativeParams.privacyLink.sendTargetingKeys === true))) ||
256+
(bidRequest.nativeParams.privacyIcon && ((bidRequest.nativeParams.privacyIcon.sendId !== true || bidRequest.nativeParams.privacyIcon.sendTargetingKeys === true)))
257+
));
262258
}
263259

264260
/**
@@ -416,6 +412,7 @@ function hasValidVideoMediaType(bidRequest) {
416412
*/
417413
function createPrebidNativeAd(payload) {
418414
return {
415+
sendTargetingKeys: false, // no key is added to KV by default
419416
title: payload.products[0].title,
420417
body: payload.products[0].description,
421418
sponsoredBy: payload.advertiser.description,

test/spec/modules/criteoBidAdapter_spec.js

Lines changed: 76 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -992,6 +992,7 @@ describe('The Criteo bidding adapter', function () {
992992
zoneid: 123,
993993
native: {
994994
'products': [{
995+
'sendTargetingKeys': false,
995996
'title': 'Product title',
996997
'description': 'Product desc',
997998
'price': '100',
@@ -1027,7 +1028,6 @@ describe('The Criteo bidding adapter', function () {
10271028
native: true,
10281029
}]
10291030
};
1030-
config.setConfig({'enableSendAllBids': false});
10311031
const bids = spec.interpretResponse(response, request);
10321032
expect(bids).to.have.lengthOf(1);
10331033
expect(bids[0].requestId).to.equal('test-bidId');
@@ -1036,61 +1036,87 @@ describe('The Criteo bidding adapter', function () {
10361036
expect(bids[0].mediaType).to.equal(NATIVE);
10371037
});
10381038

1039-
it('should not parse bid response with native when enableSendAllBids is true', function () {
1040-
const response = {
1041-
body: {
1042-
slots: [{
1043-
impid: 'test-requestId',
1044-
bidId: 'abc123',
1045-
cpm: 1.23,
1046-
width: 728,
1047-
height: 90,
1048-
zoneid: 123,
1049-
native: {}
1050-
}],
1051-
},
1052-
};
1053-
const request = {
1054-
bidRequests: [{
1055-
adUnitCode: 'test-requestId',
1056-
bidId: 'test-bidId',
1039+
it('should warn only once if sendTargetingKeys set to true on required fields for native bidRequest', () => {
1040+
const bidderRequest = { };
1041+
const bidRequests = [
1042+
{
1043+
bidder: 'criteo',
1044+
adUnitCode: 'bid-123',
1045+
transactionId: 'transaction-123',
1046+
sizes: [[728, 90]],
10571047
params: {
10581048
zoneId: 123,
1049+
publisherSubId: '123',
1050+
nativeCallback: function() {}
10591051
},
1060-
native: true,
1061-
}]
1062-
};
1063-
config.setConfig({'enableSendAllBids': true});
1064-
const bids = spec.interpretResponse(response, request);
1065-
expect(bids).to.have.lengthOf(0);
1066-
});
1067-
1068-
it('should not parse bid response with native when enableSendAllBids is not set', function () {
1069-
const response = {
1070-
body: {
1071-
slots: [{
1072-
impid: 'test-requestId',
1073-
bidId: 'abc123',
1074-
cpm: 1.23,
1075-
width: 728,
1076-
height: 90,
1077-
zoneid: 123,
1078-
native: {}
1079-
}],
10801052
},
1081-
};
1082-
const request = {
1083-
bidRequests: [{
1084-
adUnitCode: 'test-requestId',
1085-
bidId: 'test-bidId',
1053+
{
1054+
bidder: 'criteo',
1055+
adUnitCode: 'bid-456',
1056+
transactionId: 'transaction-456',
1057+
sizes: [[728, 90]],
10861058
params: {
1087-
zoneId: 123,
1059+
zoneId: 456,
1060+
publisherSubId: '456',
1061+
nativeCallback: function() {}
10881062
},
1089-
native: true,
1090-
}]
1091-
};
1092-
const bids = spec.interpretResponse(response, request);
1093-
expect(bids).to.have.lengthOf(0);
1063+
},
1064+
];
1065+
1066+
const nativeParamsWithSendTargetingKeys = [
1067+
{
1068+
nativeParams: {
1069+
image: {
1070+
sendTargetingKeys: true
1071+
},
1072+
}
1073+
},
1074+
{
1075+
nativeParams: {
1076+
icon: {
1077+
sendTargetingKeys: true
1078+
},
1079+
}
1080+
},
1081+
{
1082+
nativeParams: {
1083+
clickUrl: {
1084+
sendTargetingKeys: true
1085+
},
1086+
}
1087+
},
1088+
{
1089+
nativeParams: {
1090+
displayUrl: {
1091+
sendTargetingKeys: true
1092+
},
1093+
}
1094+
},
1095+
{
1096+
nativeParams: {
1097+
privacyLink: {
1098+
sendTargetingKeys: true
1099+
},
1100+
}
1101+
},
1102+
{
1103+
nativeParams: {
1104+
privacyIcon: {
1105+
sendTargetingKeys: true
1106+
},
1107+
}
1108+
}
1109+
];
1110+
1111+
utilsMock.expects('logWarn')
1112+
.withArgs('Criteo: all native assets containing URL should be sent as placeholders with sendId(icon, image, clickUrl, displayUrl, privacyLink, privacyIcon)')
1113+
.exactly(nativeParamsWithSendTargetingKeys.length * bidRequests.length);
1114+
nativeParamsWithSendTargetingKeys.forEach(nativeParams => {
1115+
let transformedBidRequests = {...bidRequests};
1116+
transformedBidRequests = [Object.assign(transformedBidRequests[0], nativeParams), Object.assign(transformedBidRequests[1], nativeParams)];
1117+
spec.buildRequests(transformedBidRequests, bidderRequest);
1118+
});
1119+
utilsMock.verify();
10941120
});
10951121

10961122
it('should properly parse a bid response with a zoneId passed as a string', function () {

0 commit comments

Comments
 (0)