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

Read OpenRTB app objects if set in config + bug fix for when ad units are reloaded #5086

Merged
merged 38 commits into from
Apr 8, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
1beaa7c
Livewrapped bid and analytics adapter
bjorn-lw Sep 25, 2018
250fca3
Merge remote-tracking branch 'upstream/master'
bjorn-lw Oct 4, 2018
c47dd60
Fixed some tests for browser compatibility
bjorn-lw Oct 4, 2018
5c0a354
Fixed some tests for browser compatibility
bjorn-lw Oct 4, 2018
f02ada1
Changed analytics adapter code name
bjorn-lw Oct 5, 2018
b2f72e1
Merge remote-tracking branch 'upstream/master'
bjorn-lw Oct 5, 2018
4792245
Fix double quote in debug message
bjorn-lw Oct 9, 2018
02a6e5a
modified how gdpr is being passed
bjorn-lw Nov 2, 2018
a26936a
Merge remote-tracking branch 'upstream/master'
bjorn-lw Nov 2, 2018
e799957
Merge remote-tracking branch 'upstream/master'
bjorn-lw Jan 16, 2019
176ea08
Added support for Publisher Common ID Module
bjorn-lw Jan 17, 2019
e20d9e7
Merge remote-tracking branch 'upstream/master'
bjorn-lw Jan 17, 2019
5f1951a
Corrections for ttr in analytics
bjorn-lw Feb 18, 2019
efe678c
Merge remote-tracking branch 'upstream/master'
bjorn-lw Feb 18, 2019
e959425
ANalytics updates
bjorn-lw Feb 18, 2019
43f2f07
Auction start time stamp changed
bjorn-lw Feb 22, 2019
18bfbbf
Merge remote-tracking branch 'upstream/master'
bjorn-lw Apr 11, 2019
87ebc8b
Detect recovered ad blocked requests
bjorn-lw Apr 15, 2019
f5f1e64
Merge branch 'master' of https://github.com/prebid/Prebid.js
bjorn-lw Aug 16, 2019
332b500
Collect info on ad units receiving any valid bid
bjorn-lw Aug 16, 2019
bda0fff
Merge branch 'master' of https://github.com/prebid/Prebid.js
bjorn-lw Oct 1, 2019
5f09e2a
Support for ID5
bjorn-lw Oct 22, 2019
728be38
Typo in test + eids on wrong level
bjorn-lw Oct 22, 2019
55d4448
Merge remote-tracking branch 'upstream/master'
bjorn-lw Dec 3, 2019
26c35ad
Merge remote-tracking branch 'upstream/master'
bjorn-lw Dec 12, 2019
531365e
Fix for Prebid 3.0
bjorn-lw Dec 12, 2019
6603c59
Fix get referer
bjorn-lw Dec 12, 2019
0ea76e4
http -> https in tests
bjorn-lw Dec 18, 2019
aa1a01d
Native support
bjorn-lw Dec 22, 2019
80b1079
Read sizes from mediatype.banner
bjorn-lw Jan 20, 2020
2114e29
Merge remote-tracking branch 'upstream/master'
bjorn-lw Jan 20, 2020
4c2db42
Revert accidental commit
bjorn-lw Jan 20, 2020
59c9ed2
Merge remote-tracking branch 'upstream/master'
bjorn-lw Jan 27, 2020
52903d5
Support native data collection + minor refactorings
bjorn-lw Jan 31, 2020
7bf4d26
Set analytics endpoint
bjorn-lw Feb 1, 2020
06cba0f
Support for app parameters
bjorn-lw Apr 7, 2020
2cdd237
Merge remote-tracking branch 'upstream/master'
bjorn-lw Apr 7, 2020
a9f204c
Fix issue where adunits with bids were not counted on reload
bjorn-lw Apr 7, 2020
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
36 changes: 21 additions & 15 deletions modules/livewrappedAnalyticsAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ let initOptions;
export const BID_WON_TIMEOUT = 500;

const cache = {
auctions: {},
bidAdUnits: {}
auctions: {}
};

let livewrappedAnalyticsAdapter = Object.assign(adapter({EMPTYURL, ANALYTICSTYPE}), {
Expand All @@ -28,7 +27,7 @@ let livewrappedAnalyticsAdapter = Object.assign(adapter({EMPTYURL, ANALYTICSTYPE
switch (eventType) {
case CONSTANTS.EVENTS.AUCTION_INIT:
utils.logInfo('LIVEWRAPPED_AUCTION_INIT:', args);
cache.auctions[args.auctionId] = {bids: {}};
cache.auctions[args.auctionId] = {bids: {}, bidAdUnits: {}};
break;
case CONSTANTS.EVENTS.BID_REQUESTED:
utils.logInfo('LIVEWRAPPED_BID_REQUESTED:', args);
Expand Down Expand Up @@ -64,8 +63,12 @@ let livewrappedAnalyticsAdapter = Object.assign(adapter({EMPTYURL, ANALYTICSTYPE
if (!bidResponse.ttr) {
bidResponse.ttr = time - bidResponse.start;
}
if (!cache.bidAdUnits[bidResponse.adUnit]) {
cache.bidAdUnits[bidResponse.adUnit] = {sent: 0, timeStamp: cache.auctions[args.auctionId].timeStamp};
if (!cache.auctions[args.auctionId].bidAdUnits[bidResponse.adUnit]) {
cache.auctions[args.auctionId].bidAdUnits[bidResponse.adUnit] =
{
sent: 0,
timeStamp: cache.auctions[args.auctionId].timeStamp
};
}
break;
case CONSTANTS.EVENTS.BIDDER_DONE:
Expand Down Expand Up @@ -240,16 +243,19 @@ function getTimeouts() {
function getbidAdUnits() {
var bidAdUnits = [];

Object.keys(cache.bidAdUnits).forEach(adUnit => {
let bidAdUnit = cache.bidAdUnits[adUnit];
if (!bidAdUnit.sent) {
bidAdUnit.sent = 1;

bidAdUnits.push({
adUnit: adUnit,
timeStamp: bidAdUnit.timeStamp
});
}
Object.keys(cache.auctions).forEach(auctionId => {
let auction = cache.auctions[auctionId];
Object.keys(auction.bidAdUnits).forEach(adUnit => {
let bidAdUnit = auction.bidAdUnits[adUnit];
if (!bidAdUnit.sent) {
bidAdUnit.sent = 1;

bidAdUnits.push({
adUnit: adUnit,
timeStamp: bidAdUnit.timeStamp
});
}
});
});

return bidAdUnits;
Expand Down
51 changes: 48 additions & 3 deletions modules/livewrappedBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export const storage = getStorageManager();

const BIDDER_CODE = 'livewrapped';
export const URL = 'https://lwadm.com/ad';
const VERSION = '1.2';
const VERSION = '1.3';

export const spec = {
code: BIDDER_CODE,
Expand All @@ -29,6 +29,7 @@ export const spec = {
* seats: List of bidders and seats Optional. {"bidder name": ["seat 1", "seat 2"], ...}
* deviceId: Device id if available Optional.
* ifa: Advertising ID Optional.
* bundle: App bundle Optional. Read from config if exists.
* options Dynamic data Optional. Optional data to send into adapter.
*
* @param {BidRequest} bid The bid params to validate.
Expand All @@ -55,9 +56,10 @@ export const spec = {
const seats = find(bidRequests, hasSeatsParam);
const deviceId = find(bidRequests, hasDeviceIdParam);
const ifa = find(bidRequests, hasIfaParam);
const bundle = find(bidRequests, hasBundleParam);
const tid = find(bidRequests, hasTidParam);
bidUrl = bidUrl ? bidUrl.params.bidUrl : URL;
url = url ? url.params.url : getTopWindowLocation(bidderRequest);
url = url ? url.params.url : (getAppDomain() || getTopWindowLocation(bidderRequest));
test = test ? test.params.test : undefined;
var adRequests = bidRequests.map(bidToAdRequest);

Expand All @@ -69,7 +71,10 @@ export const spec = {
test: test,
seats: seats ? seats.params.seats : undefined,
deviceId: deviceId ? deviceId.params.deviceId : undefined,
ifa: ifa ? ifa.params.ifa : undefined,
ifa: ifa ? ifa.params.ifa : getDeviceIfa(),
bundle: bundle ? bundle.params.bundle : getAppBundle(),
width: getDeviceWidth(),
height: getDeviceHeight(),
tid: tid ? tid.params.tid : undefined,
version: VERSION,
gdprApplies: bidderRequest.gdprConsent ? bidderRequest.gdprConsent.gdprApplies : undefined,
Expand Down Expand Up @@ -178,6 +183,10 @@ function hasIfaParam(bid) {
return !!bid.params.ifa;
}

function hasBundleParam(bid) {
return !!bid.params.bundle;
}

function hasTidParam(bid) {
return !!bid.params.tid;
}
Expand Down Expand Up @@ -264,4 +273,40 @@ function getTopWindowLocation(bidderRequest) {
return config.getConfig('pageUrl') || url;
}

function getAppBundle() {
if (typeof config.getConfig('app') === 'object') {
return config.getConfig('app').bundle;
}
}

function getAppDomain() {
if (typeof config.getConfig('app') === 'object') {
return config.getConfig('app').domain;
}
}

function getDeviceIfa() {
if (typeof config.getConfig('device') === 'object') {
return config.getConfig('device').ifa;
}
}

function getDeviceWidth() {
let device = config.getConfig('device');
if (typeof device === 'object' && device.width) {
return device.width;
}

return window.innerWidth;
}

function getDeviceHeight() {
let device = config.getConfig('device');
if (typeof device === 'object' && device.height) {
return device.height;
}

return window.innerHeight;
}

registerBidder(spec);
Loading