Skip to content

Commit

Permalink
Tappx Bid Adapter: getting correct site page (#9187)
Browse files Browse the repository at this point in the history
* Fix: creating host correctly when http or https are added from the beginning

* Fix :: Changed double quotes for single quotes

* Fix :: Getting the full page URL

* Fix :: Changed order params

* Fix :: Replaced quotes from double to simple

* Fix :: Adapting format to lint

* Remove TODO comment

* Added more controls

* camelcase fix

* Changed test

* Remove "inIframe" util

Co-authored-by: Jordi Arnau <jarnau@tappx.com>
Co-authored-by: ruben_tappx <rcaparros@tappx.com>
  • Loading branch information
3 people authored Nov 17, 2022
1 parent c86f41b commit a88c296
Showing 1 changed file with 21 additions and 6 deletions.
27 changes: 21 additions & 6 deletions modules/tappxBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const BIDDER_CODE = 'tappx';
const GVLID_CODE = 628;
const TTL = 360;
const CUR = 'USD';
const TAPPX_BIDDER_VERSION = '0.1.1005';
const TAPPX_BIDDER_VERSION = '0.1.2';
const TYPE_CNN = 'prebidjs';
const LOG_PREFIX = '[TAPPX]: ';
const VIDEO_SUPPORT = ['instream', 'outstream'];
Expand Down Expand Up @@ -271,12 +271,28 @@ function buildOneRequest(validBidRequests, bidderRequest) {
api[0] = deepAccess(validBidRequests, 'params.api') ? deepAccess(validBidRequests, 'params.api') : [3, 5];
} else {
let bundle = _extractPageUrl(validBidRequests, bidderRequest);
let site = {};
let site = deepAccess(validBidRequests, 'params.site') || {};
site.name = bundle;
site.page = bidderRequest?.refererInfo?.page || deepAccess(validBidRequests, 'params.site.page') || bidderRequest?.refererInfo?.topmostLocation || window.location.href || bundle;
site.domain = bundle;
site.ref = bidderRequest?.refererInfo?.ref || window.top.document.referrer || '';
site.ext = {};
site.ext.is_amp = bidderRequest?.refererInfo?.isAmp || 0;
site.ext.page_da = deepAccess(validBidRequests, 'params.site.page') || '-';
site.ext.page_rip = bidderRequest?.refererInfo?.page || '-';
site.ext.page_rit = bidderRequest?.refererInfo?.topmostLocation || '-';
site.ext.page_wlh = window.location.href || '-';
publisher.name = bundle;
publisher.domain = bundle;
let sitename = document.getElementsByTagName('meta')['title'];
if (sitename && sitename.content) {
site.name = sitename.content;
}
tagid = `${site.name}_typeAdBanVid_${getOs()}`;
let keywords = document.getElementsByTagName('meta')['keywords'];
if (keywords && keywords.content) {
site.keywords = keywords.content;
}
payload.site = site;
}
// < App/Site object
Expand All @@ -295,9 +311,9 @@ function buildOneRequest(validBidRequests, bidderRequest) {
if (
((bannerMediaType.sizes[0].indexOf(480) >= 0) && (bannerMediaType.sizes[0].indexOf(320) >= 0)) ||
((bannerMediaType.sizes[0].indexOf(768) >= 0) && (bannerMediaType.sizes[0].indexOf(1024) >= 0))) {
banner.pos = 7;
banner.pos = 0;
} else {
banner.pos = 4;
banner.pos = 0;
}

banner.api = api;
Expand Down Expand Up @@ -565,8 +581,7 @@ export function _checkParamDataType(key, value, datatype) {
}

export function _extractPageUrl(validBidRequests, bidderRequest) {
// TODO: does the fallback make sense?
let url = bidderRequest?.refererInfo?.page || bidderRequest.refererInfo?.topmostLocation;
let url = bidderRequest?.refererInfo?.page || bidderRequest?.refererInfo?.topmostLocation;
return parseDomain(url, {noLeadingWww: true});
}

Expand Down

0 comments on commit a88c296

Please sign in to comment.