Skip to content

added onBidWon event #5679

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

Merged
merged 8 commits into from
Sep 16, 2020
Merged
Show file tree
Hide file tree
Changes from 4 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
15 changes: 15 additions & 0 deletions modules/luponmediaBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import * as utils from '../src/utils.js';
import {registerBidder} from '../src/adapters/bidderFactory.js';
import {config} from '../src/config.js';
import {BANNER} from '../src/mediaTypes.js';
import { ajax } from '../src/ajax.js';

const BIDDER_CODE = 'luponmedia';
const ENDPOINT_URL = 'https://rtb.adxpremium.services/openrtb2/auction';
Expand Down Expand Up @@ -113,6 +114,10 @@ export const spec = {
hasSynced = true;
return allUserSyncs;
},
onBidWon: bid => {
const bidString = JSON.stringify(bid);
sendWinningsToServer(bidString);
},
};

function newOrtbBidRequest(bidRequest, bidderRequest, currentImps) {
Expand Down Expand Up @@ -349,6 +354,16 @@ function _getPageUrl(bidRequest, bidderRequest) {
return bidRequest.params.secure ? pageUrl.replace(/^http:/i, 'https:') : pageUrl;
}

function sendWinningsToServer(data) {
let mutation = `mutation {createWin(input: {win: {eventData: "${window.btoa(data)}"}}) {win {createTime } } }`;
let dataToSend = JSON.stringify({ query: mutation });

ajax('https://analytics.adxpremium.services/graphql', null, dataToSend, {
contentType: 'application/json',
method: 'POST'
});
}

function appendSiteAppDevice(data, bidRequest, bidderRequest) {
if (!data) return;

Expand Down
30 changes: 30 additions & 0 deletions test/spec/modules/luponmediaBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -364,4 +364,34 @@ describe('luponmediaBidAdapter', function () {
expect(checkSchain).to.equal(false);
});
});

describe('On winning bid', function () {
const bids = {
'bidderCode': 'luponmedia',
'width': 300,
'height': 250,
'statusMessage': 'Bid available',
'adId': '105bbf8c54453ff',
'requestId': '934b8752185955',
'mediaType': 'banner',
'source': 'client',
'cpm': 0.364,
'creativeId': '443801010',
'currency': 'USD',
'netRevenue': false,
'ttl': 300,
'referrer': '',
'ad': '',
'auctionId': '926a8ea3-3dd4-4bf2-95ab-c85c2ce7e99b',
'responseTimestamp': 1598527728026,
'requestTimestamp': 1598527727629,
'bidder': 'luponmedia',
'adUnitCode': 'div-gpt-ad-1533155193780-5',
'timeToRespond': 397,
'size': '300x250',
'status': 'rendered'
};

spec.onBidWon(bids);
Copy link
Collaborator

Choose a reason for hiding this comment

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

This does not actually test anything.

See this https://github.com/prebid/Prebid.js/blob/master/test/spec/modules/adpartnerBidAdapter_spec.js#L199 example.

From Line 199 and on.

You can see they trigger the spec.onBidWon but are validating the return, as well as stubbing the request and making sure it has the right data they expect.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi @robertrmartinez we just made the change that you suggested.

});
});