-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Magnite Analytics Adapter : add seat non bid handling #9696
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
ccab78d
Return all bids
spotxslagle 481847d
Adjust findMatch function
spotxslagle a667e40
Return all buds unit testing
spotxslagle d4a2145
Responds to review comments
spotxslagle c90c7d1
Unit test adjustments
spotxslagle d5e116f
Remove extra line for lint
robertrmartinez 3894aa2
minor changes
robertrmartinez 0d0f275
doh
robertrmartinez File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,7 +28,8 @@ const { | |
BIDDER_DONE, | ||
BID_WON, | ||
BID_TIMEOUT, | ||
BILLABLE_EVENT | ||
BILLABLE_EVENT, | ||
SEAT_NON_BID | ||
} | ||
} = CONSTANTS; | ||
|
||
|
@@ -160,6 +161,16 @@ const MOCK = { | |
'status': 'rendered', | ||
getStatusCode: () => 1, | ||
}, | ||
SEAT_NON_BID: { | ||
auctionId: '99785e47-a7c8-4c8a-ae05-ef1c717a4b4d', | ||
seatnonbid: [{ | ||
seat: 'rubicon', | ||
nonbid: [{ | ||
status: 1, | ||
impid: 'box' | ||
}] | ||
}] | ||
}, | ||
AUCTION_END: { | ||
'auctionId': '99785e47-a7c8-4c8a-ae05-ef1c717a4b4d', | ||
'auctionEnd': 1658868384019, | ||
|
@@ -2039,4 +2050,121 @@ describe('magnite analytics adapter', function () { | |
} | ||
}) | ||
}); | ||
|
||
describe('BID_RESPONSE events', () => { | ||
beforeEach(() => { | ||
magniteAdapter.enableAnalytics({ | ||
options: { | ||
endpoint: '//localhost:9999/event', | ||
accountId: 1001 | ||
} | ||
}); | ||
config.setConfig({ rubicon: { updatePageView: true } }); | ||
}); | ||
|
||
it('should add a no-bid bid to the add unit if it recieves one from the server', () => { | ||
const bidResponse = utils.deepClone(MOCK.BID_RESPONSE); | ||
const auctionInit = utils.deepClone(MOCK.AUCTION_INIT); | ||
|
||
bidResponse.requestId = 'fakeId'; | ||
bidResponse.seatBidId = 'fakeId'; | ||
|
||
bidResponse.requestId = 'fakeId'; | ||
events.emit(AUCTION_INIT, auctionInit); | ||
events.emit(BID_REQUESTED, MOCK.BID_REQUESTED); | ||
events.emit(BID_RESPONSE, bidResponse) | ||
events.emit(BIDDER_DONE, MOCK.BIDDER_DONE); | ||
events.emit(AUCTION_END, MOCK.AUCTION_END); | ||
clock.tick(rubiConf.analyticsBatchTimeout + 1000); | ||
|
||
let message = JSON.parse(server.requests[0].requestBody); | ||
expect(utils.generateUUID.called).to.equal(true); | ||
|
||
expect(message.auctions[0].adUnits[0].bids[1]).to.deep.equal( | ||
{ | ||
bidder: 'rubicon', | ||
source: 'server', | ||
status: 'success', | ||
bidResponse: { | ||
'bidPriceUSD': 3.4, | ||
'dimensions': { | ||
'height': 250, | ||
'width': 300 | ||
}, | ||
'mediaType': 'banner' | ||
}, | ||
oldBidId: 'fakeId', | ||
unknownBid: true, | ||
bidId: 'fakeId', | ||
clientLatencyMillis: 271 | ||
} | ||
); | ||
}); | ||
}); | ||
|
||
describe('SEAT_NON_BID events', () => { | ||
let seatnonbid; | ||
|
||
const runNonBidAuction = () => { | ||
events.emit(AUCTION_INIT, MOCK.AUCTION_INIT); | ||
events.emit(BID_REQUESTED, MOCK.BID_REQUESTED); | ||
events.emit(SEAT_NON_BID, seatnonbid) | ||
events.emit(BIDDER_DONE, MOCK.BIDDER_DONE); | ||
events.emit(AUCTION_END, MOCK.AUCTION_END); | ||
clock.tick(rubiConf.analyticsBatchTimeout + 1000); | ||
}; | ||
const checkStatusAgainstCode = (status, code, error, index) => { | ||
seatnonbid.seatnonbid[0].nonbid[0].status = code; | ||
runNonBidAuction(); | ||
let message = JSON.parse(server.requests[index].requestBody); | ||
let bid = message.auctions[0].adUnits[0].bids[1]; | ||
|
||
if (error) { | ||
expect(bid.error).to.deep.equal(error); | ||
} else { | ||
expect(bid.error).to.equal(undefined); | ||
} | ||
expect(bid.source).to.equal('server'); | ||
expect(bid.status).to.equal(status); | ||
expect(bid.isSeatNonBid).to.equal(true); | ||
}; | ||
beforeEach(() => { | ||
magniteAdapter.enableAnalytics({ | ||
options: { | ||
endpoint: '//localhost:9999/event', | ||
accountId: 1001 | ||
} | ||
}); | ||
seatnonbid = utils.deepClone(MOCK.SEAT_NON_BID); | ||
}); | ||
|
||
it('adds seatnonbid info to bids array', () => { | ||
runNonBidAuction(); | ||
let message = JSON.parse(server.requests[0].requestBody); | ||
|
||
expect(message.auctions[0].adUnits[0].bids[1]).to.deep.equal( | ||
{ | ||
bidder: 'rubicon', | ||
source: 'server', | ||
status: 'no-bid', | ||
isSeatNonBid: true, | ||
clientLatencyMillis: -139101369960 | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So this one tests if the status is not in the status map, and then below test is all of the other ones cool. |
||
); | ||
}); | ||
|
||
it('adjusts the status according to the status map', () => { | ||
const statuses = [ | ||
{code: 0, status: 'no-bid'}, | ||
{code: 100, status: 'error', error: {code: 'request-error', description: 'general error'}}, | ||
{code: 101, status: 'error', error: {code: 'timeout-error', description: 'prebid server timeout'}}, | ||
{code: 200, status: 'rejected'}, | ||
{code: 202, status: 'rejected'}, | ||
{code: 301, status: 'rejected-ipf'} | ||
]; | ||
statuses.forEach((info, index) => { | ||
checkStatusAgainstCode(info.status, info.code, info.error, index); | ||
}); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 nice! |
||
}); | ||
}); | ||
}); |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
WE should probably safe check in case the auction was not found for some reason: