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

Updated data mapping of auction and winning bid objects in pubxai analytics adapter. #6285

Merged
1 commit merged into from
Feb 10, 2021
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
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') {
Copy link

@ghost ghost Feb 10, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

any reason why you took the data.auctionInit !== undefined check away? Ah i see that you removed it from the test. Just want to make sure this is expected

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have removed auctionInit from the data object completely as we don't need it anymore. That's why this condition isn't required here.

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