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: outstream support #8709

Merged
merged 39 commits into from
Jul 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
d4958f5
alt outstream support
nllerandi3lift Jan 3, 2022
dc9915e
removes consoleLog
nllerandi3lift Jan 3, 2022
834f1c3
rename video ttl
nllerandi3lift Jan 3, 2022
acd0a39
multi-imp
nllerandi3lift Jan 5, 2022
6581557
simplify video if statement in buildPostBody
nllerandi3lift Jan 5, 2022
4fc8912
Merge pull request #42 from prebid/master
Jan 6, 2022
192cf7d
distinguish banner from video bid; temp solution for testing
nllerandi3lift Jan 6, 2022
84e82ce
adds tests for mediatype
nllerandi3lift Jan 6, 2022
76d16e0
remove console log
nllerandi3lift Jan 6, 2022
3d72c33
individual instream/outstream tests
nllerandi3lift Jan 11, 2022
8dd055b
simplify some functions
nllerandi3lift Jan 11, 2022
735a137
nitpick
nllerandi3lift Jan 11, 2022
d7e59af
Merge branch 'prebid:master' into master
nllerandi3lift Jan 14, 2022
1101d6c
Merge branch 'prebid:master' into master
nllerandi3lift Jan 31, 2022
343ae51
adds media_type check
nllerandi3lift Feb 4, 2022
6fff6f3
Merge branch 'prebid:master' into master
nllerandi3lift Feb 18, 2022
06a815e
Merge branch 'prebid:master' into master
nllerandi3lift Mar 7, 2022
a41b5d4
Merge branch 'prebid:master' into master
nllerandi3lift Mar 14, 2022
dfba5d8
adds placement options to outstream
nllerandi3lift Mar 15, 2022
e18efc1
checks instream placement values
nllerandi3lift Mar 16, 2022
66ab3c8
Merge branch 'prebid:master' into master
nllerandi3lift Mar 23, 2022
33c780c
TL-19850 Finished log error logic around floors functionality
Apr 5, 2022
7fc0801
Merge branch 'prebid:master' into master
nllerandi3lift Apr 5, 2022
905e884
deprecates getlegacyFpd
nllerandi3lift Apr 7, 2022
c2650c2
remove console log
nllerandi3lift Apr 7, 2022
9bb44c6
Merge branch 'prebid:master' into master
nllerandi3lift Apr 8, 2022
450cfb6
Merge pull request #48 from triplelift-internal/TL-26965-deprecateLeg…
nllerandi3lift Apr 8, 2022
0ebf51c
TL-19850 Changed functionlity of tests
patrickloughrey Apr 20, 2022
9072383
Merge branch 'prebid:master' into master
nllerandi3lift Apr 21, 2022
da47d96
Merge pull request #47 from triplelift-internal/TL-19850-floors-modul…
nllerandi3lift Apr 21, 2022
edcf99b
Merge branch 'prebid:master' into master
nllerandi3lift Apr 29, 2022
3b34724
restore logErrorSpy aftereach
nllerandi3lift Apr 29, 2022
103814f
Merge branch 'prebid:master' into master
nllerandi3lift Apr 29, 2022
5b93e6d
Merge branch 'prebid:master' into master
nllerandi3lift May 3, 2022
bc6de82
Merge branch 'prebid:master' into master
nllerandi3lift May 9, 2022
68c867c
merge master
nllerandi3lift May 9, 2022
c8bd184
Merge branch 'master' into TL-24341-outstreamSupport-B
nllerandi3lift Jun 29, 2022
d1b617e
removing pub name from test
nllerandi3lift Jul 19, 2022
224967a
Merge pull request #41 from triplelift-internal/TL-24341-outstreamSup…
nllerandi3lift Jul 19, 2022
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
64 changes: 45 additions & 19 deletions modules/tripleliftBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const GVLID = 28;
const BIDDER_CODE = 'triplelift';
const STR_ENDPOINT = 'https://tlx.3lift.com/header/auction?';
const BANNER_TIME_TO_LIVE = 300;
const INSTREAM_TIME_TO_LIVE = 3600;
const VIDEO_TIME_TO_LIVE = 3600;
let gdprApplies = true;
let consentString = null;
export const storage = getStorageManager({gvlid: GVLID, bidderCode: BIDDER_CODE});
Expand Down Expand Up @@ -120,12 +120,15 @@ function _buildPostBody(bidRequests, bidderRequest) {
tagid: bidRequest.params.inventoryCode,
floor: _getFloor(bidRequest)
};
// remove the else to support multi-imp
if (_isInstreamBidRequest(bidRequest)) {
// Check for video bidrequest
if (_isVideoBidRequest(bidRequest)) {
imp.video = _getORTBVideo(bidRequest);
} else if (bidRequest.mediaTypes.banner) {
}
// append banner if applicable and request is not for instream
if (bidRequest.mediaTypes.banner && !_isInstream(bidRequest)) {
imp.banner = { format: _sizes(bidRequest.sizes) };
};
}

if (!isEmpty(bidRequest.ortb2Imp)) {
imp.fpd = _getAdUnitFpd(bidRequest.ortb2Imp);
}
Expand Down Expand Up @@ -153,22 +156,41 @@ function _buildPostBody(bidRequests, bidderRequest) {
return data;
}

function _isInstreamBidRequest(bidRequest) {
if (!bidRequest.mediaTypes.video) return false;
if (!bidRequest.mediaTypes.video.context) return false;
if (bidRequest.mediaTypes.video.context.toLowerCase() === 'instream') {
return true;
} else {
return false;
}
function _isVideoBidRequest(bidRequest) {
return _isValidVideoObject(bidRequest) && (_isInstream(bidRequest) || _isOutstream(bidRequest));
}

function _isOutstream(bidRequest) {
return _isValidVideoObject(bidRequest) && bidRequest.mediaTypes.video.context.toLowerCase() === 'outstream';
}

function _isInstream(bidRequest) {
return _isValidVideoObject(bidRequest) && bidRequest.mediaTypes.video.context.toLowerCase() === 'instream';
}

function _isValidVideoObject(bidRequest) {
return bidRequest.mediaTypes.video && bidRequest.mediaTypes.video.context;
}

function _getORTBVideo(bidRequest) {
// give precedent to mediaTypes.video
let video = { ...bidRequest.params.video, ...bidRequest.mediaTypes.video };
if (!video.w) video.w = video.playerSize[0][0];
if (!video.h) video.h = video.playerSize[0][1];
try {
if (!video.w) video.w = video.playerSize[0][0];
if (!video.h) video.h = video.playerSize[0][1];
} catch (err) {
logWarn('Video size not defined', err);
}
if (video.context === 'instream') video.placement = 1;
if (video.context === 'outstream') {
if (!video.placement) {
video.placement = 3
} else if ([3, 4, 5].indexOf(video.placement) === -1) {
logMessage(`video.placement value of ${video.placement} is invalid for outstream context. Setting placement to 3`)
video.placement = 3
}
}

// clean up oRTB object
delete video.playerSize;
return video;
Expand All @@ -180,7 +202,7 @@ function _getFloor (bid) {
try {
const floorInfo = bid.getFloor({
currency: 'USD',
mediaType: _isInstreamBidRequest(bid) ? 'video' : 'banner',
mediaType: _isVideoBidRequest(bid) ? 'video' : 'banner',
size: '*'
});
if (typeof floorInfo === 'object' &&
Expand Down Expand Up @@ -366,10 +388,10 @@ function _buildResponseObject(bidderRequest, bid) {
meta: {}
};

if (_isInstreamBidRequest(breq)) {
if (_isVideoBidRequest(breq) && bid.media_type === 'video') {
bidResponse.vastXml = bid.ad;
bidResponse.mediaType = 'video';
bidResponse.ttl = INSTREAM_TIME_TO_LIVE;
bidResponse.ttl = VIDEO_TIME_TO_LIVE;
};

if (bid.advertiser_name) {
Expand All @@ -381,7 +403,11 @@ function _buildResponseObject(bidderRequest, bid) {
}

if (bid.tl_source && bid.tl_source == 'hdx') {
bidResponse.meta.mediaType = 'banner';
if (_isVideoBidRequest(breq) && bid.media_type === 'video') {
bidResponse.meta.mediaType = 'video'
} else {
bidResponse.meta.mediaType = 'banner'
}
}

if (bid.tl_source && bid.tl_source == 'tlx') {
Expand Down
Loading