Skip to content

Commit d403664

Browse files
patrickloughreynllerandi3lift
authored andcommitted
Triplelift Bid Adapter: copying ad unit impression data (prebid#9865)
* TL-35335: Cast playbackmethod as array * TL-36204: Copy tid to imp extension obj * Added support for entire ortb2Imp obj * Only setting what exists in ortb2Imp.ext * Added additional test to check copy of entire ext obj * Revert "TL-36204: Copy tid to imp extension object" * TL-36204: Copying ortb2Imp.ext to impression ext obj * Added edge case logic and additional test * recos for tid change * Added spread operator to replace deepClone --------- Co-authored-by: nllerandi3lift <[email protected]> Co-authored-by: Nick Llerandi <[email protected]>
1 parent 395e159 commit d403664

File tree

2 files changed

+60
-8
lines changed

2 files changed

+60
-8
lines changed

modules/tripleliftBidAdapter.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,15 @@ function _buildPostBody(bidRequests, bidderRequest) {
130130
}
131131

132132
if (!isEmpty(bidRequest.ortb2Imp)) {
133+
// legacy method for extracting ortb2Imp.ext
133134
imp.fpd = _getAdUnitFpd(bidRequest.ortb2Imp);
135+
136+
// preferred method for extracting ortb2Imp.ext
137+
if (!isEmpty(bidRequest.ortb2Imp.ext)) {
138+
imp.ext = { ...bidRequest.ortb2Imp.ext };
139+
}
134140
}
141+
135142
return imp;
136143
});
137144

test/spec/modules/tripleliftBidAdapter_spec.js

Lines changed: 53 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -139,15 +139,13 @@ describe('triplelift adapter', function () {
139139
sizes: [[300, 250], [300, 600], [1, 1, 1], ['flex']],
140140
bidId: '30b31c1838de1e',
141141
bidderRequestId: '22edbae2733bf6',
142+
transactionId: '173f49a8-7549-4218-a23c-e7ba59b47229',
142143
auctionId: '1d1a030790a475',
143144
userId: {},
144145
schain,
145146
ortb2Imp: {
146147
ext: {
147-
data: {
148-
pbAdSlot: 'homepage-top-rect',
149-
adUnitSpecificAttribute: 123
150-
}
148+
tid: '173f49a8-7549-4218-a23c-e7ba59b47229'
151149
}
152150
}
153151
},
@@ -178,6 +176,15 @@ describe('triplelift adapter', function () {
178176
auctionId: '1d1a030790a475',
179177
userId: {},
180178
schain,
179+
ortb2Imp: {
180+
ext: {
181+
data: {
182+
pbAdSlot: 'homepage-top-rect',
183+
adUnitSpecificAttribute: 123
184+
},
185+
tid: '173f49a8-7549-4218-a23c-e7ba59b47229'
186+
}
187+
}
181188
},
182189
// banner and outstream video
183190
{
@@ -245,6 +252,11 @@ describe('triplelift adapter', function () {
245252
auctionId: '1d1a030790a475',
246253
userId: {},
247254
schain,
255+
ortb2Imp: {
256+
misc: {
257+
test: 1
258+
}
259+
}
248260
},
249261
// incomplete banner and incomplete video
250262
{
@@ -689,6 +701,39 @@ describe('triplelift adapter', function () {
689701
expect(payload.imp[13].video.placement).to.equal(3);
690702
});
691703

704+
it('should add tid to imp.ext if transactionId exists', function() {
705+
const request = tripleliftAdapterSpec.buildRequests(bidRequests, bidderRequest);
706+
expect(request.data.imp[0].ext.tid).to.exist.and.be.a('string');
707+
expect(request.data.imp[0].ext.tid).to.equal('173f49a8-7549-4218-a23c-e7ba59b47229');
708+
});
709+
710+
it('should not add impression ext object if ortb2Imp does not exist', function() {
711+
const request = tripleliftAdapterSpec.buildRequests(bidRequests, bidderRequest);
712+
expect(request.data.imp[2].ext).to.not.exist;
713+
});
714+
715+
it('should not add impression ext object if ortb2Imp.ext does not exist', function() {
716+
const request = tripleliftAdapterSpec.buildRequests(bidRequests, bidderRequest);
717+
expect(request.data.imp[3].ext).to.not.exist;
718+
});
719+
720+
it('should copy entire impression ext object', function() {
721+
const request = tripleliftAdapterSpec.buildRequests(bidRequests, bidderRequest);
722+
expect(request.data.imp[1].ext).to.haveOwnProperty('tid');
723+
expect(request.data.imp[1].ext).to.haveOwnProperty('data');
724+
expect(request.data.imp[1].ext.data).to.haveOwnProperty('adUnitSpecificAttribute');
725+
expect(request.data.imp[1].ext.data).to.haveOwnProperty('pbAdSlot');
726+
expect(request.data.imp[1].ext).to.deep.equal(
727+
{
728+
data: {
729+
pbAdSlot: 'homepage-top-rect',
730+
adUnitSpecificAttribute: 123
731+
},
732+
tid: '173f49a8-7549-4218-a23c-e7ba59b47229'
733+
}
734+
);
735+
});
736+
692737
it('should add tdid to the payload if included', function () {
693738
const id = '6bca7f6b-a98a-46c0-be05-6020f7604598';
694739
bidRequests[0].userId.tdid = id;
@@ -1103,10 +1148,10 @@ describe('triplelift adapter', function () {
11031148
});
11041149
it('should send ad unit fpd if kvps are available', function() {
11051150
const request = tripleliftAdapterSpec.buildRequests(bidRequests, bidderRequest);
1106-
expect(request.data.imp[0].fpd.context).to.haveOwnProperty('data');
1107-
expect(request.data.imp[0].fpd.context.data).to.haveOwnProperty('pbAdSlot');
1108-
expect(request.data.imp[0].fpd.context.data).to.haveOwnProperty('adUnitSpecificAttribute');
1109-
expect(request.data.imp[1].fpd).to.not.exist;
1151+
expect(request.data.imp[1].fpd.context).to.haveOwnProperty('data');
1152+
expect(request.data.imp[1].fpd.context.data).to.haveOwnProperty('pbAdSlot');
1153+
expect(request.data.imp[1].fpd.context.data).to.haveOwnProperty('adUnitSpecificAttribute');
1154+
expect(request.data.imp[2].fpd).to.not.exist;
11101155
});
11111156
it('should send 1PlusX data as fpd if localStorage is available and no other fpd is defined', function() {
11121157
sandbox.stub(storage, 'getDataFromLocalStorage').callsFake(() => '{"kid":1,"s":"ySRdArquXuBolr/cVv0UNqrJhTO4QZsbNH/t+2kR3gXjbA==","t":"/yVtBrquXuBolr/cVv0UNtx1mssdLYeKFhWFI3Dq1dJnug=="}');

0 commit comments

Comments
 (0)