Skip to content

Commit 469065b

Browse files
PWyrembaksa1omon
authored andcommitted
TrustX Bid Adapter updating to use referrerInfo (prebid#3972)
* Add trustx adapter and tests for it * update integration example * Update trustx adapter * Post-review fixes of Trustx adapter * Code improvement for trustx adapter: changed default price type from gross to net * Update TrustX adapter to support the 1.0 version * Make requested changes for TrustX adapter * Updated markdown file for TrustX adapter * Fix TrustX adapter and spec file * Update TrustX adapter: r parameter was added to ad request as cache buster * Add support of gdpr to Trustx Bid Adapter * Add wtimeout to ad request params for TrustX Bid Adapter * TrustX Bid Adapter: remove last ampersand in the ad request * Update TrustX Bid Adapter to support identical uids in parameters * Update TrustX Bid Adapter to ignore bids that sizes do not match the size of the request * Update TrustX Bid Adapter to support instream and outstream video * Added wrapperType and wrapperVersion parameters in ad request for TrustX Bid Adapter * Update TrustX Bid Adapter to use refererInfo instead depricated function utils.getTopWindowUrl
1 parent 98dc4e7 commit 469065b

File tree

2 files changed

+25
-12
lines changed

2 files changed

+25
-12
lines changed

modules/trustxBidAdapter.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,6 @@ export const spec = {
8484
});
8585

8686
const payload = {
87-
u: utils.getTopWindowUrl(),
8887
pt: priceType,
8988
auids: auids.join(','),
9089
sizes: utils.getKeys(sizeMap).join(','),
@@ -94,6 +93,9 @@ export const spec = {
9493
};
9594

9695
if (bidderRequest) {
96+
if (bidderRequest.refererInfo && bidderRequest.refererInfo.referer) {
97+
payload.u = encodeURIComponent(bidderRequest.refererInfo.referer);
98+
}
9799
if (bidderRequest.timeout) {
98100
payload.wtimeout = bidderRequest.timeout;
99101
}

test/spec/modules/trustxBidAdapter_spec.js

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,14 @@ describe('TrustXAdapter', function () {
4747
});
4848
return res;
4949
}
50+
51+
const bidderRequest = {
52+
refererInfo: {
53+
referer: 'http://example.com'
54+
}
55+
};
56+
const encodedReferer = encodeURIComponent(bidderRequest.refererInfo.referer);
57+
5058
let bidRequests = [
5159
{
5260
'bidder': 'trustx',
@@ -84,10 +92,10 @@ describe('TrustXAdapter', function () {
8492
];
8593

8694
it('should attach valid params to the tag', function () {
87-
const request = spec.buildRequests([bidRequests[0]]);
95+
const request = spec.buildRequests([bidRequests[0]], bidderRequest);
8896
expect(request.data).to.be.an('string');
8997
const payload = parseRequest(request.data);
90-
expect(payload).to.have.property('u').that.is.a('string');
98+
expect(payload).to.have.property('u', encodedReferer);
9199
expect(payload).to.have.property('pt', 'net');
92100
expect(payload).to.have.property('auids', '43');
93101
expect(payload).to.have.property('sizes', '300x250,300x600');
@@ -97,10 +105,10 @@ describe('TrustXAdapter', function () {
97105
});
98106

99107
it('sizes must not be duplicated', function () {
100-
const request = spec.buildRequests(bidRequests);
108+
const request = spec.buildRequests(bidRequests, bidderRequest);
101109
expect(request.data).to.be.an('string');
102110
const payload = parseRequest(request.data);
103-
expect(payload).to.have.property('u').that.is.a('string');
111+
expect(payload).to.have.property('u', encodedReferer);
104112
expect(payload).to.have.property('pt', 'net');
105113
expect(payload).to.have.property('auids', '43,43,45');
106114
expect(payload).to.have.property('sizes', '300x250,300x600,728x90');
@@ -109,10 +117,10 @@ describe('TrustXAdapter', function () {
109117

110118
it('pt parameter must be "gross" if params.priceType === "gross"', function () {
111119
bidRequests[1].params.priceType = 'gross';
112-
const request = spec.buildRequests(bidRequests);
120+
const request = spec.buildRequests(bidRequests, bidderRequest);
113121
expect(request.data).to.be.an('string');
114122
const payload = parseRequest(request.data);
115-
expect(payload).to.have.property('u').that.is.a('string');
123+
expect(payload).to.have.property('u', encodedReferer);
116124
expect(payload).to.have.property('pt', 'gross');
117125
expect(payload).to.have.property('auids', '43,43,45');
118126
expect(payload).to.have.property('sizes', '300x250,300x600,728x90');
@@ -122,10 +130,10 @@ describe('TrustXAdapter', function () {
122130

123131
it('pt parameter must be "net" or "gross"', function () {
124132
bidRequests[1].params.priceType = 'some';
125-
const request = spec.buildRequests(bidRequests);
133+
const request = spec.buildRequests(bidRequests, bidderRequest);
126134
expect(request.data).to.be.an('string');
127135
const payload = parseRequest(request.data);
128-
expect(payload).to.have.property('u').that.is.a('string');
136+
expect(payload).to.have.property('u', encodedReferer);
129137
expect(payload).to.have.property('pt', 'net');
130138
expect(payload).to.have.property('auids', '43,43,45');
131139
expect(payload).to.have.property('sizes', '300x250,300x600,728x90');
@@ -134,23 +142,26 @@ describe('TrustXAdapter', function () {
134142
});
135143

136144
it('if gdprConsent is present payload must have gdpr params', function () {
137-
const request = spec.buildRequests(bidRequests, {gdprConsent: {consentString: 'AAA', gdprApplies: true}});
145+
const bidderRequestWithGDPR = Object.assign({gdprConsent: {consentString: 'AAA', gdprApplies: true}}, bidderRequest);
146+
const request = spec.buildRequests(bidRequests, bidderRequestWithGDPR);
138147
expect(request.data).to.be.an('string');
139148
const payload = parseRequest(request.data);
140149
expect(payload).to.have.property('gdpr_consent', 'AAA');
141150
expect(payload).to.have.property('gdpr_applies', '1');
142151
});
143152

144153
it('if gdprApplies is false gdpr_applies must be 0', function () {
145-
const request = spec.buildRequests(bidRequests, {gdprConsent: {consentString: 'AAA', gdprApplies: false}});
154+
const bidderRequestWithGDPR = Object.assign({gdprConsent: {consentString: 'AAA', gdprApplies: false}}, bidderRequest);
155+
const request = spec.buildRequests(bidRequests, bidderRequestWithGDPR);
146156
expect(request.data).to.be.an('string');
147157
const payload = parseRequest(request.data);
148158
expect(payload).to.have.property('gdpr_consent', 'AAA');
149159
expect(payload).to.have.property('gdpr_applies', '0');
150160
});
151161

152162
it('if gdprApplies is undefined gdpr_applies must be 1', function () {
153-
const request = spec.buildRequests(bidRequests, {gdprConsent: {consentString: 'AAA'}});
163+
const bidderRequestWithGDPR = Object.assign({gdprConsent: {consentString: 'AAA'}}, bidderRequest);
164+
const request = spec.buildRequests(bidRequests, bidderRequestWithGDPR);
154165
expect(request.data).to.be.an('string');
155166
const payload = parseRequest(request.data);
156167
expect(payload).to.have.property('gdpr_consent', 'AAA');

0 commit comments

Comments
 (0)