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

TL-36204: Copying ortb2Imp.ext to impression ext obj #77

Merged
merged 5 commits into from
Apr 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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