Skip to content
This repository has been archived by the owner on Feb 13, 2021. It is now read-only.

Commit

Permalink
Merge pull request prebid#26 in AOLP_ADS_JS/prebid.js from feature/PL…
Browse files Browse the repository at this point in the history
…MP-58-changes-for-Prebid-0.12.0 to release/1.2.0

* commit '6eb1afc22fffc5a53e022b16a6ed4a775e2fa5aa':
  Updated CHANGELOG
  Fixed per-adapter timeouts
  Fixed sorting of per-adapter timeouts
  Fixed unit tests for AOL analytics
  Made changes required due to pull from Prebid official
  • Loading branch information
marian-r committed Sep 19, 2016
2 parents fa4dae9 + 6eb1afc commit 7b830f3
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 20 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
AOL Prebid 1.2.0
----------------
Updated to Prebid 0.12.0.
Fixed sorting of per-adapter timeouts.


AOL Prebid 1.1.0
----------------
AOL adapter is optimized and heavily reduced in size.
Expand Down
14 changes: 7 additions & 7 deletions src/adapters/analytics/aol.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import BIDDERS_IDS_MAP from './aolPartnersIds.json';
const events = require('src/events');
const utils = require('../../utils');

const AUCTION_COMPLETED = CONSTANTS.EVENTS.AUCTION_COMPLETED;
const AUCTION_END = CONSTANTS.EVENTS.AUCTION_END;
const BID_WON = CONSTANTS.EVENTS.BID_WON;
const BID_TIMEOUT = CONSTANTS.EVENTS.BID_TIMEOUT;
const AOL_BIDDER_CODE = 'aol';
Expand Down Expand Up @@ -65,7 +65,7 @@ export default utils.extend(adapter({
}
});

events.on(AUCTION_COMPLETED, args => this.enqueue({ eventType: AUCTION_COMPLETED, args }));
events.on(AUCTION_END, args => this.enqueue({ eventType: AUCTION_END, args }));
events.on(BID_WON, args => this.enqueue({ eventType: BID_WON, args }));

this.enableAnalytics = function _enable() {
Expand All @@ -76,11 +76,11 @@ export default utils.extend(adapter({
//override AnalyticsAdapter functions by supplying custom methods
track({ eventType, args }) {
switch (eventType) {
case AUCTION_COMPLETED:
let adUnitsConf = args.adUnits;
let bidsReceived = args.bidsReceived;
case AUCTION_END:
let adUnitsConf = $$PREBID_GLOBAL$$.adUnits;
let bidsReceived = $$PREBID_GLOBAL$$._bidsReceived;
let bidsReceivedIds = bidsReceived.map(receivedBid => receivedBid.adId);
let timedOutBids = args.bidsRequested
let timedOutBids = $$PREBID_GLOBAL$$._bidsRequested
.map(bidderRequest => bidderRequest.bids
.filter(bid => bidsReceivedIds.indexOf(bid.bidId) < 0)
.map(bid => {
Expand Down Expand Up @@ -137,7 +137,7 @@ export default utils.extend(adapter({
},

reportEvent(url) {
ajax(url, null, null, null, {isTrackingRequest: true});
ajax(url, null, null, { withCredentials: true });
},

getBaseSchema(eventId, adUnit) {
Expand Down
2 changes: 1 addition & 1 deletion src/adapters/aol.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ var AolAdapter = function AolAdapter() {

_addBidResponse(bid, response);

}, null, null, { isTrackingRequest: true });
}, null, { withCredentials: true });
});
}

Expand Down
4 changes: 2 additions & 2 deletions src/bidmanager.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ exports.addBidResponse = function (adUnitCode, bid) {

bid.timeToRespond = bid.responseTimestamp - bid.requestTimestamp;

if (bid.timeToRespond > $$PREBID_GLOBAL$$.bidderTimeout) {
if (_currentTimeoutIndex >= _timeouts.length && bid.timeToRespond > $$PREBID_GLOBAL$$.bidderTimeout) {
const timedOut = true;

this.executeCallback(timedOut);
Expand Down Expand Up @@ -252,7 +252,7 @@ function setNextTimeout() {
var nextTimeout = _timeouts[_currentTimeoutIndex];
var previousTimeout = _timeouts[_currentTimeoutIndex - 1] || 0;
var timeoutDifference = nextTimeout - previousTimeout;
setTimeout(exports.executeCallback, timeoutDifference);
setTimeout(() => exports.executeCallback(true), timeoutDifference);
}

function hasBidsWithPendingTimeouts() {
Expand Down
3 changes: 1 addition & 2 deletions src/constants.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@
"BID_TIMEOUT": "bidTimeout",
"BID_REQUESTED": "bidRequested",
"BID_RESPONSE": "bidResponse",
"BID_WON": "bidWon",
"AUCTION_COMPLETED": "auctionCompleted"
"BID_WON": "bidWon"
},
"EVENT_ID_PATHS": {
"bidWon": "adUnitCode"
Expand Down
2 changes: 1 addition & 1 deletion src/prebid.js
Original file line number Diff line number Diff line change
Expand Up @@ -549,7 +549,7 @@ $$PREBID_GLOBAL$$.requestBids = function ({ bidsBackHandler, timeout, adUnits, a
}
}
}
timeouts.sort();
timeouts.sort((a, b) => a - b);
}

//set timeout(s) for all bids
Expand Down
17 changes: 10 additions & 7 deletions test/spec/unit/adapters/analytics/aol_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import CONSTANTS from '../../../../../src/constants.json';
import { getBidResponses, getRequestedBids, getAdUnits } from '../../../../fixtures/fixturesAnalytics';

const aolAnalytics = require('../../../../../src/adapters/analytics/aol').default;
const AUCTION_COMPLETED = CONSTANTS.EVENTS.AUCTION_COMPLETED;
const AUCTION_END = CONSTANTS.EVENTS.AUCTION_END;
const BID_WON = CONSTANTS.EVENTS.BID_WON;

describe(`
Expand All @@ -24,17 +24,17 @@ describe(`
let spyTrack = sinon.spy(aolAnalytics, 'track');
let spyReportEvent = sinon.spy(aolAnalytics, 'reportEvent');
let spyBuildEndpoint = sinon.spy(aolAnalytics, 'buildEndpoint');
let bidsReceived = getBidResponses();
let bidsRequested = getRequestedBids();
let adUnits = getAdUnits();
$$PREBID_GLOBAL$$._bidsReceived = getBidResponses();
$$PREBID_GLOBAL$$._bidsRequested = getRequestedBids();
$$PREBID_GLOBAL$$.adUnits = getAdUnits();
let url = 'foobar';

events.emit(AUCTION_COMPLETED, { bidsReceived, bidsRequested, adUnits });
events.emit(AUCTION_END);

it(`THEN: AOL Analytics track is called for the auction complete event`, () => {
assert.ok(spyTrack.calledWith({
eventType: AUCTION_COMPLETED,
args: { bidsReceived, bidsRequested, adUnits }
eventType: AUCTION_END,
args: undefined
}));
});

Expand All @@ -49,6 +49,9 @@ describe(`
//assert.equal(spyReportEvent.args[0][0], url);
});

$$PREBID_GLOBAL$$._bidsReceived = [];
$$PREBID_GLOBAL$$._bidsRequested = [];
$$PREBID_GLOBAL$$.adUnits = [];
aolAnalytics.track.restore();
aolAnalytics.reportEvent.restore();
aolAnalytics.buildEndpoint.restore();
Expand Down

0 comments on commit 7b830f3

Please sign in to comment.