Skip to content

Commit

Permalink
Updated data mapping of winning bid and auction logs in pubxai analyt…
Browse files Browse the repository at this point in the history
…ics adapter (prebid#6285)

Co-authored-by: Phaneendra Hegde <phaneendra.hegde@gmail.com>
  • Loading branch information
pnh-pubx and pnhegde authored Feb 10, 2021
1 parent ff0b015 commit a037c54
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 113 deletions.
13 changes: 10 additions & 3 deletions modules/pubxaiAnalyticsAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,13 @@ var pubxaiAnalyticsAdapter = Object.assign(adapter(
if (eventType === CONSTANTS.EVENTS.BID_TIMEOUT) {
args.forEach(item => { mapBidResponse(item, 'timeout'); });
} else if (eventType === CONSTANTS.EVENTS.AUCTION_INIT) {
events.auctionInit = args;
events.floorDetail = {};
if (typeof args.bidderRequests[0].bids[0] !== 'undefined' && typeof args.bidderRequests[0].bids[0].floorData !== 'undefined') {
Object.assign(events.floorDetail, args.bidderRequests[0].bids[0].floorData);
}
auctionTimestamp = args.timestamp;
} else if (eventType === CONSTANTS.EVENTS.BID_REQUESTED) {
events.bids = [];
mapBidRequests(args).forEach(item => { events.bids.push(item) });
} else if (eventType === CONSTANTS.EVENTS.BID_RESPONSE) {
mapBidResponse(args, 'response');
Expand All @@ -56,6 +60,8 @@ function mapBidRequests(params) {
adUnitCode: bid.adUnitCode,
requestId: bid.bidderRequestId,
auctionId: bid.auctionId,
placementId: bid.params.placementId,
floorData: bid.floorData,
transactionId: bid.transactionId,
sizes: utils.parseSizesInput(bid.mediaTypes.banner.sizes).toString(),
renderStatus: 1,
Expand Down Expand Up @@ -134,8 +140,9 @@ pubxaiAnalyticsAdapter.shouldFireEventRequest = function (samplingRate = 1) {
function send(data, status) {
if (pubxaiAnalyticsAdapter.shouldFireEventRequest(initOptions.samplingRate)) {
let location = utils.getWindowLocation();
if (typeof data !== 'undefined' && typeof data.auctionInit !== 'undefined') {
Object.assign(data.auctionInit, { host: location.host, path: location.pathname, search: location.search });
if (typeof data !== 'undefined') {
data.pageDetail = {};
Object.assign(data.pageDetail, { host: location.host, path: location.pathname, search: location.search });
}
data.initOptions = initOptions;

Expand Down
164 changes: 54 additions & 110 deletions test/spec/modules/pubxaiAnalyticsAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ describe('pubxai analytics adapter', function() {
pubxId: '6c415fc0-8b0e-4cf5-be73-01526a4db625'
};

let location = utils.getWindowLocation();

let prebidEvent = {
'auctionInit': {
'auctionId': 'bc3806e4-873e-453c-8ae5-204f35e923b4',
Expand Down Expand Up @@ -219,6 +221,12 @@ describe('pubxai analytics adapter', function() {
'originalCpm': 0.5,
'originalCurrency': 'USD',
'floorData': {
'fetchStatus': 'success',
'floorProvider': 'PubXFloor',
'location': 'fetch',
'modelVersion': 'new model 1.0',
'skipRate': 0,
'skipped': false,
'floorValue': 0.4,
'floorRule': '/19968336/header-bid-tag-1|banner',
'floorCurrency': 'USD',
Expand Down Expand Up @@ -381,6 +389,12 @@ describe('pubxai analytics adapter', function() {
'originalCpm': 0.5,
'originalCurrency': 'USD',
'floorData': {
'fetchStatus': 'success',
'floorProvider': 'PubXFloor',
'location': 'fetch',
'modelVersion': 'new model 1.0',
'skipRate': 0,
'skipped': false,
'floorValue': 0.4,
'floorRule': '/19968336/header-bid-tag-1|banner',
'floorCurrency': 'USD',
Expand Down Expand Up @@ -449,6 +463,12 @@ describe('pubxai analytics adapter', function() {
'originalCpm': 0.5,
'originalCurrency': 'USD',
'floorData': {
'fetchStatus': 'success',
'floorProvider': 'PubXFloor',
'location': 'fetch',
'modelVersion': 'new model 1.0',
'skipRate': 0,
'skipped': false,
'floorValue': 0.4,
'floorRule': '/19968336/header-bid-tag-1|banner',
'floorCurrency': 'USD',
Expand Down Expand Up @@ -488,9 +508,13 @@ describe('pubxai analytics adapter', function() {
'params': [{
'placementId': 13144370
}]
}
},
'pageDetail': {
'host': location.host,
'path': location.pathname,
'search': location.search
},
};
let location = utils.getWindowLocation();

let expectedAfterBid = {
'bids': [{
Expand All @@ -509,6 +533,12 @@ describe('pubxai analytics adapter', function() {
'mediaType': 'banner',
'statusMessage': 'Bid available',
'floorData': {
'fetchStatus': 'success',
'floorProvider': 'PubXFloor',
'location': 'fetch',
'modelVersion': 'new model 1.0',
'skipRate': 0,
'skipped': false,
'floorValue': 0.4,
'floorRule': '/19968336/header-bid-tag-1|banner',
'floorCurrency': 'USD',
Expand All @@ -527,118 +557,21 @@ describe('pubxai analytics adapter', function() {
'timeToRespond': 267,
'responseTimestamp': 1603865707449,
'platform': navigator.platform,
'placementId': 13144370,
'deviceType': getDeviceType()
}],
'auctionInit': {
'pageDetail': {
'host': location.host,
'path': location.pathname,
'search': location.search,
'auctionId': 'bc3806e4-873e-453c-8ae5-204f35e923b4',
'timestamp': 1603865707180,
'auctionStatus': 'inProgress',
'adUnits': [{
'code': '/19968336/header-bid-tag-1',
'mediaTypes': {
'banner': {
'sizes': [
[
300,
250
]
]
}
},
'bids': [{
'bidder': 'appnexus',
'params': {
'placementId': 13144370
},
'auctionId': 'bc3806e4-873e-453c-8ae5-204f35e923b4',
'floorData': {
'skipped': false,
'skipRate': 0,
'modelVersion': 'new model 1.0',
'location': 'fetch',
'floorProvider': 'PubXFloor',
'fetchStatus': 'success'
}
}],
'sizes': [
[
300,
250
]
],
'transactionId': '41ec8eaf-3e7c-4a8b-8344-ab796ff6e294'
}],
'adUnitCodes': [
'/19968336/header-bid-tag-1'
],
'bidderRequests': [{
'bidderCode': 'appnexus',
'auctionId': 'bc3806e4-873e-453c-8ae5-204f35e923b4',
'bidderRequestId': '184cbc05bb90ba',
'bids': [{
'bidder': 'appnexus',
'params': {
'placementId': 13144370
},
'auctionId': 'bc3806e4-873e-453c-8ae5-204f35e923b4',
'floorData': {
'skipped': false,
'skipRate': 0,
'modelVersion': 'new model 1.0',
'location': 'fetch',
'floorProvider': 'PubXFloor',
'fetchStatus': 'success'
},
'mediaTypes': {
'banner': {
'sizes': [
[
300,
250
]
]
}
},
'adUnitCode': '/19968336/header-bid-tag-1',
'transactionId': '41ec8eaf-3e7c-4a8b-8344-ab796ff6e294',
'sizes': [
[
300,
250
]
],
'bidId': '248f9a4489835e',
'bidderRequestId': '184cbc05bb90ba',
'src': 'client',
'bidRequestsCount': 1,
'bidderRequestsCount': 1,
'bidderWinsCount': 0
}],
'auctionStart': 1603865707180,
'timeout': 1000,
'refererInfo': {
'referer': 'http://local-pnh.net:8080/stream/',
'reachedTop': true,
'isAmp': false,
'numIframes': 0,
'stack': [
'http://local-pnh.net:8080/stream/'
],
'canonicalUrl': null
},
'start': 1603865707182
}],
'noBids': [],
'bidsReceived': [],
'winningBids': [],
'timeout': 1000,
'config': {
'samplingRate': '1',
'pubxId': '6c415fc0-8b0e-4cf5-be73-01526a4db625'
}
'search': location.search
},
'floorDetail': {
'fetchStatus': 'success',
'floorProvider': 'PubXFloor',
'location': 'fetch',
'modelVersion': 'new model 1.0',
'skipRate': 0,
'skipped': false
},
'initOptions': initOptions
};
Expand All @@ -660,6 +593,12 @@ describe('pubxai analytics adapter', function() {
'status': 'rendered',
'statusMessage': 'Bid available',
'floorData': {
'fetchStatus': 'success',
'floorProvider': 'PubXFloor',
'location': 'fetch',
'modelVersion': 'new model 1.0',
'skipRate': 0,
'skipped': false,
'floorValue': 0.4,
'floorRule': '/19968336/header-bid-tag-1|banner',
'floorCurrency': 'USD',
Expand All @@ -680,6 +619,11 @@ describe('pubxai analytics adapter', function() {
'platform': navigator.platform,
'deviceType': getDeviceType()
},
'pageDetail': {
'host': location.host,
'path': location.pathname,
'search': location.search
},
'initOptions': initOptions
}

Expand Down

0 comments on commit a037c54

Please sign in to comment.