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

Triplelift Bid Adapter: copying ad unit impression data #9865

Merged
merged 20 commits into from
May 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
25664ce
TL-35335: Cast playbackmethod as array
patrickloughrey Mar 1, 2023
7307d1a
Merge pull request #72 from triplelift-internal/TL-35335-cast-playbac…
patrickloughrey Mar 1, 2023
ee90d99
Merge branch 'prebid:master' into master
nllerandi3lift Apr 14, 2023
3ee1e9b
Merge branch 'prebid:master' into master
patrickloughrey Apr 17, 2023
0ff06ab
Merge branch 'prebid:master' into master
patrickloughrey Apr 21, 2023
40dbe99
TL-36204: Copy tid to imp extension obj
patrickloughrey Apr 21, 2023
4291c1e
Added support for entire ortb2Imp obj
patrickloughrey Apr 24, 2023
feecf24
Only setting what exists in ortb2Imp.ext
patrickloughrey Apr 24, 2023
a709f3f
Added additional test to check copy of entire ext obj
patrickloughrey Apr 24, 2023
49ba6a9
Merge pull request #74 from triplelift-internal/TL-36204-Copy-TID
patrickloughrey Apr 25, 2023
cd65aba
Merge branch 'prebid:master' into master
patrickloughrey Apr 25, 2023
b362e3a
Revert "TL-36204: Copy tid to imp extension object"
patrickloughrey Apr 25, 2023
5574ef5
Merge pull request #75 from triplelift-internal/revert-74-TL-36204-Co…
patrickloughrey Apr 25, 2023
cfba68c
TL-36204: Copying ortb2Imp.ext to impression ext obj
patrickloughrey Apr 25, 2023
13cab1f
Added edge case logic and additional test
patrickloughrey Apr 26, 2023
f074dc0
recos for tid change
nllerandi3lift Apr 27, 2023
0b4d931
merge conflict
nllerandi3lift Apr 27, 2023
e8c6bd1
Added spread operator to replace deepClone
patrickloughrey Apr 27, 2023
f4a6c93
Merge pull request #77 from triplelift-internal/TL-36204-Copy-Imp-Ext
patrickloughrey Apr 27, 2023
4262b7f
Merge branch 'prebid:master' into master
patrickloughrey Apr 27, 2023
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
7 changes: 7 additions & 0 deletions modules/tripleliftBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,15 @@ function _buildPostBody(bidRequests, bidderRequest) {
}

if (!isEmpty(bidRequest.ortb2Imp)) {
// legacy method for extracting ortb2Imp.ext
imp.fpd = _getAdUnitFpd(bidRequest.ortb2Imp);

// preferred method for extracting ortb2Imp.ext
if (!isEmpty(bidRequest.ortb2Imp.ext)) {
imp.ext = { ...bidRequest.ortb2Imp.ext };
}
}

return imp;
});

Expand Down
61 changes: 53 additions & 8 deletions test/spec/modules/tripleliftBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,15 +139,13 @@ describe('triplelift adapter', function () {
sizes: [[300, 250], [300, 600], [1, 1, 1], ['flex']],
bidId: '30b31c1838de1e',
bidderRequestId: '22edbae2733bf6',
transactionId: '173f49a8-7549-4218-a23c-e7ba59b47229',
auctionId: '1d1a030790a475',
userId: {},
schain,
ortb2Imp: {
ext: {
data: {
pbAdSlot: 'homepage-top-rect',
adUnitSpecificAttribute: 123
}
tid: '173f49a8-7549-4218-a23c-e7ba59b47229'
}
}
},
Expand Down Expand Up @@ -178,6 +176,15 @@ describe('triplelift adapter', function () {
auctionId: '1d1a030790a475',
userId: {},
schain,
ortb2Imp: {
ext: {
data: {
pbAdSlot: 'homepage-top-rect',
adUnitSpecificAttribute: 123
},
tid: '173f49a8-7549-4218-a23c-e7ba59b47229'
}
}
},
// banner and outstream video
{
Expand Down Expand Up @@ -245,6 +252,11 @@ describe('triplelift adapter', function () {
auctionId: '1d1a030790a475',
userId: {},
schain,
ortb2Imp: {
misc: {
test: 1
}
}
},
// incomplete banner and incomplete video
{
Expand Down Expand Up @@ -689,6 +701,39 @@ describe('triplelift adapter', function () {
expect(payload.imp[13].video.placement).to.equal(3);
});

it('should add tid to imp.ext if transactionId exists', function() {
const request = tripleliftAdapterSpec.buildRequests(bidRequests, bidderRequest);
expect(request.data.imp[0].ext.tid).to.exist.and.be.a('string');
expect(request.data.imp[0].ext.tid).to.equal('173f49a8-7549-4218-a23c-e7ba59b47229');
});

it('should not add impression ext object if ortb2Imp does not exist', function() {
const request = tripleliftAdapterSpec.buildRequests(bidRequests, bidderRequest);
expect(request.data.imp[2].ext).to.not.exist;
});

it('should not add impression ext object if ortb2Imp.ext does not exist', function() {
const request = tripleliftAdapterSpec.buildRequests(bidRequests, bidderRequest);
expect(request.data.imp[3].ext).to.not.exist;
});

it('should copy entire impression ext object', function() {
const request = tripleliftAdapterSpec.buildRequests(bidRequests, bidderRequest);
expect(request.data.imp[1].ext).to.haveOwnProperty('tid');
expect(request.data.imp[1].ext).to.haveOwnProperty('data');
expect(request.data.imp[1].ext.data).to.haveOwnProperty('adUnitSpecificAttribute');
expect(request.data.imp[1].ext.data).to.haveOwnProperty('pbAdSlot');
expect(request.data.imp[1].ext).to.deep.equal(
{
data: {
pbAdSlot: 'homepage-top-rect',
adUnitSpecificAttribute: 123
},
tid: '173f49a8-7549-4218-a23c-e7ba59b47229'
}
);
});

it('should add tdid to the payload if included', function () {
const id = '6bca7f6b-a98a-46c0-be05-6020f7604598';
bidRequests[0].userId.tdid = id;
Expand Down Expand Up @@ -1103,10 +1148,10 @@ describe('triplelift adapter', function () {
});
it('should send ad unit fpd if kvps are available', function() {
const request = tripleliftAdapterSpec.buildRequests(bidRequests, bidderRequest);
expect(request.data.imp[0].fpd.context).to.haveOwnProperty('data');
expect(request.data.imp[0].fpd.context.data).to.haveOwnProperty('pbAdSlot');
expect(request.data.imp[0].fpd.context.data).to.haveOwnProperty('adUnitSpecificAttribute');
expect(request.data.imp[1].fpd).to.not.exist;
expect(request.data.imp[1].fpd.context).to.haveOwnProperty('data');
expect(request.data.imp[1].fpd.context.data).to.haveOwnProperty('pbAdSlot');
expect(request.data.imp[1].fpd.context.data).to.haveOwnProperty('adUnitSpecificAttribute');
expect(request.data.imp[2].fpd).to.not.exist;
});
it('should send 1PlusX data as fpd if localStorage is available and no other fpd is defined', function() {
sandbox.stub(storage, 'getDataFromLocalStorage').callsFake(() => '{"kid":1,"s":"ySRdArquXuBolr/cVv0UNqrJhTO4QZsbNH/t+2kR3gXjbA==","t":"/yVtBrquXuBolr/cVv0UNtx1mssdLYeKFhWFI3Dq1dJnug=="}');
Expand Down