Skip to content

Commit 8b463d4

Browse files
KamorisAdSpacesDevelopers
authored and
AdSpacesDevelopers
committed
rtbhouseBidAdapter changes (prebid#3241)
* Add transactionId support * Change site getting method * Add bidfloor param
1 parent f4b7246 commit 8b463d4

File tree

3 files changed

+69
-21
lines changed

3 files changed

+69
-21
lines changed

modules/rtbhouseBidAdapter.js

+16-5
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,12 @@ export const spec = {
4343
const request = {
4444
id: validBidRequests[0].auctionId,
4545
imp: validBidRequests.map(slot => mapImpression(slot)),
46-
site: mapSite(validBidRequests),
46+
site: mapSite(validBidRequests, bidderRequest),
4747
cur: DEFAULT_CURRENCY_ARR,
48-
test: validBidRequests[0].params.test || 0
48+
test: validBidRequests[0].params.test || 0,
49+
source: {
50+
tid: validBidRequests[0].transactionId
51+
}
4952
};
5053
if (bidderRequest && bidderRequest.gdprConsent && bidderRequest.gdprConsent.gdprApplies) {
5154
const consentStr = (bidderRequest.gdprConsent.consentString)
@@ -89,12 +92,19 @@ registerBidder(spec);
8992
* @returns {object} Imp by OpenRTB 2.5 §3.2.4
9093
*/
9194
function mapImpression(slot) {
92-
return {
95+
const imp = {
9396
id: slot.bidId,
9497
banner: mapBanner(slot),
9598
native: mapNative(slot),
9699
tagid: slot.adUnitCode.toString()
97100
};
101+
102+
const bidfloor = parseFloat(slot.params.bidfloor);
103+
if (bidfloor) {
104+
imp.bidfloor = bidfloor
105+
}
106+
107+
return imp;
98108
}
99109

100110
/**
@@ -118,17 +128,18 @@ function mapBanner(slot) {
118128

119129
/**
120130
* @param {object} slot Ad Unit Params by Prebid
131+
* @param {object} bidderRequest by Prebid
121132
* @returns {object} Site by OpenRTB 2.5 §3.2.13
122133
*/
123-
function mapSite(slot) {
134+
function mapSite(slot, bidderRequest) {
124135
const pubId = slot && slot.length > 0
125136
? slot[0].params.publisherId
126137
: 'unknown';
127138
return {
128139
publisher: {
129140
id: pubId.toString(),
130141
},
131-
page: utils.getTopWindowUrl(),
142+
page: bidderRequest.refererInfo.referer,
132143
name: utils.getOrigin()
133144
}
134145
}

modules/rtbhouseBidAdapter.md

+4-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Maintainer: [email protected]
77
# Description
88

99
Connects to RTB House unique demand.
10-
Banner formats are supported.
10+
Banner and native formats are supported.
1111
Unique publisherId is required.
1212
Please reach out to [email protected] to receive your own
1313

@@ -23,7 +23,8 @@ Please reach out to [email protected] to receive your own
2323
bidder: "rtbhouse",
2424
params: {
2525
region: 'prebid-eu',
26-
publisherId: 'PREBID_TEST_ID'
26+
publisherId: 'PREBID_TEST_ID',
27+
bidfloor: 0.01 // optional
2728
}
2829
}
2930
]
@@ -50,6 +51,7 @@ Please reach out to [email protected] to receive your own
5051
params: {
5152
region: 'prebid-eu',
5253
publisherId: 'PREBID_TEST_ID'
54+
bidfloor: 0.01 // optional
5355
}
5456
}
5557
]

test/spec/modules/rtbhouseBidAdapter_spec.js

+49-14
Original file line numberDiff line numberDiff line change
@@ -52,17 +52,26 @@ describe('RTBHouseAdapter', () => {
5252
'sizes': [[300, 250], [300, 600]],
5353
'bidId': '30b31c1838de1e',
5454
'bidderRequestId': '22edbae2733bf6',
55-
'auctionId': '1d1a030790a475'
55+
'auctionId': '1d1a030790a475',
56+
'transactionId': 'example-transaction-id',
5657
}
5758
];
59+
const bidderRequest = {
60+
'refererInfo': {
61+
'numIframes': 0,
62+
'reachedTop': true,
63+
'referer': 'http://example.com',
64+
'stack': ['http://example.com']
65+
}
66+
};
5867

5968
it('should build test param into the request', () => {
60-
let builtTestRequest = spec.buildRequests(bidRequests).data;
69+
let builtTestRequest = spec.buildRequests(bidRequests, bidderRequest).data;
6170
expect(JSON.parse(builtTestRequest).test).to.equal(1);
6271
});
6372

6473
it('should build valid OpenRTB banner object', () => {
65-
const request = JSON.parse(spec.buildRequests((bidRequests)).data);
74+
const request = JSON.parse(spec.buildRequests(bidRequests, bidderRequest).data);
6675
const imp = request.imp[0];
6776
expect(imp.banner).to.deep.equal({
6877
w: 300,
@@ -80,15 +89,15 @@ describe('RTBHouseAdapter', () => {
8089
it('sends bid request to ENDPOINT via POST', function () {
8190
let bidRequest = Object.assign([], bidRequests);
8291
delete bidRequest[0].params.test;
83-
const request = spec.buildRequests(bidRequest);
92+
const request = spec.buildRequests(bidRequest, bidderRequest);
8493
expect(request.url).to.equal('https://prebid-eu.creativecdn.com/bidder/prebid/bids');
8594
expect(request.method).to.equal('POST');
8695
});
8796

8897
it('should not populate GDPR if for non-EEA users', function () {
8998
let bidRequest = Object.assign([], bidRequests);
9099
delete bidRequest[0].params.test;
91-
const request = spec.buildRequests(bidRequest);
100+
const request = spec.buildRequests(bidRequest, bidderRequest);
92101
let data = JSON.parse(request.data);
93102
expect(data).to.not.have.property('regs');
94103
expect(data).to.not.have.property('user');
@@ -97,12 +106,15 @@ describe('RTBHouseAdapter', () => {
97106
it('should populate GDPR and consent string if available for EEA users', function () {
98107
let bidRequest = Object.assign([], bidRequests);
99108
delete bidRequest[0].params.test;
100-
const request = spec.buildRequests(bidRequest, {
101-
gdprConsent: {
102-
gdprApplies: true,
103-
consentString: 'BOJ8RZsOJ8RZsABAB8AAAAAZ+A=='
104-
}
105-
});
109+
const request = spec.buildRequests(
110+
bidRequest,
111+
Object.assign({}, bidderRequest, {
112+
gdprConsent: {
113+
gdprApplies: true,
114+
consentString: 'BOJ8RZsOJ8RZsABAB8AAAAAZ+A=='
115+
}
116+
})
117+
);
106118
let data = JSON.parse(request.data);
107119
expect(data.regs.ext.gdpr).to.equal(1);
108120
expect(data.user.ext.consent).to.equal('BOJ8RZsOJ8RZsABAB8AAAAAZ-A');
@@ -111,19 +123,41 @@ describe('RTBHouseAdapter', () => {
111123
it('should populate GDPR and empty consent string if available for EEA users without consent string but with consent', function () {
112124
let bidRequest = Object.assign([], bidRequests);
113125
delete bidRequest[0].params.test;
114-
const request = spec.buildRequests(bidRequest, {gdprConsent: {gdprApplies: true}});
126+
const request = spec.buildRequests(
127+
bidRequest,
128+
Object.assign({}, bidderRequest, {
129+
gdprConsent: {
130+
gdprApplies: true
131+
}
132+
})
133+
);
115134
let data = JSON.parse(request.data);
116135
expect(data.regs.ext.gdpr).to.equal(1);
117136
expect(data.user.ext.consent).to.equal('');
118137
});
119138

120139
it('should include banner imp in request', () => {
121140
const bidRequest = Object.assign([], bidRequests);
122-
const request = spec.buildRequests(bidRequest);
141+
const request = spec.buildRequests(bidRequest, bidderRequest);
123142
const data = JSON.parse(request.data);
124143
expect(data.imp[0].banner).to.not.be.empty;
125144
});
126145

146+
it('should include source.tid in request', () => {
147+
const bidRequest = Object.assign([], bidRequests);
148+
const request = spec.buildRequests(bidRequest, bidderRequest);
149+
const data = JSON.parse(request.data);
150+
expect(data.source.tid).to.equal('example-transaction-id');
151+
});
152+
153+
it('should include bidfloor in request if available', () => {
154+
const bidRequest = Object.assign([], bidRequests);
155+
bidRequest[0].params.bidfloor = 0.01;
156+
const request = spec.buildRequests(bidRequest, bidderRequest);
157+
const data = JSON.parse(request.data);
158+
expect(data.imp[0].bidfloor).to.equal(0.01)
159+
});
160+
127161
describe('native imp', () => {
128162
function basicRequest(extension) {
129163
return Object.assign({
@@ -139,7 +173,8 @@ describe('RTBHouseAdapter', () => {
139173
}
140174

141175
function buildImp(request) {
142-
return JSON.parse(spec.buildRequests([request]).data).imp[0];
176+
const resultRequest = spec.buildRequests([request], bidderRequest);
177+
return JSON.parse(resultRequest.data).imp[0];
143178
}
144179

145180
it('should extract native params when single mediaType', () => {

0 commit comments

Comments
 (0)