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#128 in AOLP_ADS_JS/prebid.js from release/1…
Browse files Browse the repository at this point in the history
….30.0 to aolgithub-master

* commit '5a8d2bf93ee15071a78e24ac976103cacf3c6021': (35 commits)
  Added changelog entry.
  Prebid 0.30.1 Release
  Remove undefined variable usage (prebid#1662)
  fixes bug for IE when invalid value passed to parse (prebid#1657)
  Aliasbidder fix (prebid#1652)
  prebidAdapter secure support (prebid#1655)
  Increment pre version
  Prebid 0.30.0 Release
  Add native param support to mediaTypes (prebid#1625)
  PulsePoint Lite adpater changes (prebid#1630)
  Appnexus ast unittest updates (prebid#1654)
  Support aspect ratio specification for native images (prebid#1634)
  Revert changes for switch between client side and server side. (prebid#1653)
  rubicon converted to bidderFactory (prebid#1624)
  Add JSDoc for `pbjs.getAllWinningBids` (prebid#1566)
  Add ignore-loader to handle .md files (prebid#1646)
  fixed PBS cookie syncs (prebid#1637)
  Add placementId request param to Yieldmo bid adapter (prebid#1632)
  Adxcg analytics adapter (prebid#1599)
  Add publisher sub-id support to the Criteo adapter (prebid#1629)
  ...
  • Loading branch information
vzhukovsky committed Oct 24, 2017
2 parents 71d8747 + 5a8d2bf commit ae0895f
Show file tree
Hide file tree
Showing 54 changed files with 2,157 additions and 1,327 deletions.
8 changes: 6 additions & 2 deletions .github/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,12 @@

## Steps to reproduce
<!--
If this is a bug, please provide a list of steps to reproduce the issue and
if possible a link to a test page or minimal demo of the problem via
If this is a bug, please provide a list of steps to reproduce the issue
-->

## Test page
<!--
Include a link to a test page or minimal demo of the problem via
https://jsfiddle.net, http://jsbin.com or similar.
-->

Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
AOL Prebid 1.30.0
----------------
Updated to Prebid 0.30.1


AOL Prebid 1.29.0
----------------
Updated to Prebid 0.29.0
Expand Down
15 changes: 9 additions & 6 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,14 +87,22 @@ function bundle(dev, moduleArr) {

var entries = [helpers.getBuiltPrebidCoreFile(dev)].concat(helpers.getBuiltModules(dev, modules));

var outputFileName = argv.bundleName ? argv.bundleName : 'prebid.js';

// change output filename if argument --tag given
if (argv.tag && argv.tag.length) {
outputFileName = outputFileName.replace(/\.js$/, `.${argv.tag}.js`);
}

gutil.log('Concatenating files:\n', entries);
gutil.log('Appending ' + prebid.globalVarName + '.processQueue();');
gutil.log('Generating bundle:', outputFileName);

return gulp.src(
entries
)
.pipe(gulpif(dev, sourcemaps.init({loadMaps: true})))
.pipe(concat(argv.bundleName ? argv.bundleName : 'prebid.js'))
.pipe(concat(outputFileName))
.pipe(gulpif(!argv.manualEnable, footer('\n<%= global %>.processQueue();', {
global: prebid.globalVarName
}
Expand Down Expand Up @@ -141,11 +149,6 @@ gulp.task('devpack', ['clean'], function () {
gulp.task('webpack', ['clean'], function () {
var cloned = _.cloneDeep(webpackConfig);

// change output filename if argument --tag given
if (argv.tag && argv.tag.length) {
cloned.output.filename = 'prebid.' + argv.tag + '.js';
}

delete cloned.devtool;

var externalModules = helpers.getArgModules();
Expand Down
4 changes: 3 additions & 1 deletion integrationExamples/gpt/pbjs_example_gpt.html
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,9 @@
},
{
bidder: 'yieldmo',
params: {}
params: {
placementId: 'ym_12341234' // Optional Yieldmo Placement ID
}
},
{
bidder: 'adequant',
Expand Down
4 changes: 1 addition & 3 deletions integrationExamples/gpt/pbjs_ucfunnel_gpt.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@
bids: [{
bidder: 'ucfunnel',
params: {
adid: "test-ad-83444226E44368D1E32E49EEBE6D29", //String - required
width: 300,
height: 250
adid: "test-ad-83444226E44368D1E32E49EEBE6D29" //String - required
}
}
]
Expand Down
2 changes: 1 addition & 1 deletion integrationExamples/gpt/pbjs_video_adUnit.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
var videoAdUnit = {
code: 'video1',
sizes: [640,480],
mediaType: 'video',
mediaTypes: { video: {} },
bids: [
{
bidder: 'appnexusAst',
Expand Down
209 changes: 209 additions & 0 deletions modules/adomikAnalyticsAdapter.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,209 @@
import adapter from 'src/AnalyticsAdapter';
import CONSTANTS from 'src/constants.json';
import adaptermanager from 'src/adaptermanager';
// import utils from 'src/utils';

// Events used in adomik analytics adapter
const auctionInit = CONSTANTS.EVENTS.AUCTION_INIT;
const auctionEnd = CONSTANTS.EVENTS.AUCTION_END;
const bidRequested = CONSTANTS.EVENTS.BID_REQUESTED;
const bidResponse = CONSTANTS.EVENTS.BID_RESPONSE;
const bidWon = CONSTANTS.EVENTS.BID_WON;
const bidTimeout = CONSTANTS.EVENTS.BID_TIMEOUT;

let bidwonTimeout = 1000;

let adomikAdapter = Object.assign(adapter({}),
{
// Track every event needed
track({ eventType, args }) {
switch (eventType) {
case auctionInit:
adomikAdapter.currentContext.id = args.requestId
adomikAdapter.currentContext.timeout = args.timeout
if (args.config.bidwonTimeout !== undefined && typeof args.config.bidwonTimeout === 'number') {
bidwonTimeout = args.config.bidwonTimeout;
}
break;

case bidTimeout:
adomikAdapter.currentContext.timeouted = true;
break;

case bidResponse:
adomikAdapter.bucketEvents.push({
type: 'response',
event: adomikAdapter.buildBidResponse(args)
});
break;

case bidWon:
adomikAdapter.bucketEvents.push({
type: 'winner',
event: {
id: args.adId,
placementCode: args.adUnitCode
}
});
break;

case bidRequested:
args.bids.forEach(function(bid) {
adomikAdapter.bucketEvents.push({
type: 'request',
event: {
bidder: bid.bidder.toUpperCase(),
placementCode: bid.placementCode
}
});
});
break;

case auctionEnd:
setTimeout(() => {
if (adomikAdapter.bucketEvents.length > 0) {
adomikAdapter.sendTypedEvent();
}
}, bidwonTimeout);
break;
}
}
}
);

adomikAdapter.sendTypedEvent = function() {
const groupedTypedEvents = adomikAdapter.buildTypedEvents();

const bulkEvents = {
uid: adomikAdapter.currentContext.uid,
ahbaid: adomikAdapter.currentContext.id,
timeout: adomikAdapter.currentContext.timeout,
hostname: window.location.hostname,
eventsByPlacementCode: groupedTypedEvents.map(function(typedEventsByType) {
let sizes = [];
const eventKeys = ['request', 'response', 'winner'];
let events = {};

eventKeys.forEach((eventKey) => {
events[`${eventKey}s`] = [];
if (typedEventsByType[eventKey] !== undefined) {
typedEventsByType[eventKey].forEach((typedEvent) => {
if (typedEvent.event.size !== undefined) {
const size = adomikAdapter.sizeUtils.handleSize(sizes, typedEvent.event.size);
if (size !== null) {
sizes = [...sizes, size];
}
}
events[`${eventKey}s`] = [...events[`${eventKey}s`], typedEvent.event];
});
}
});

return {
placementCode: typedEventsByType.placementCode,
sizes,
events
};
})
};

// Encode object in base64
const encodedBuf = window.btoa(JSON.stringify(bulkEvents));

// Create final url and split it in 1600 characters max (+endpoint length)
const encodedUri = encodeURIComponent(encodedBuf);
const splittedUrl = encodedUri.match(/.{1,1600}/g);

splittedUrl.forEach((split, i) => {
const partUrl = `${split}&id=${adomikAdapter.currentContext.id}&part=${i}&on=${splittedUrl.length - 1}`;
const img = new Image(1, 1);
img.src = 'https://' + adomikAdapter.currentContext.url + '/?q=' + partUrl;
})
};

adomikAdapter.buildBidResponse = function (bid) {
return {
bidder: bid.bidderCode.toUpperCase(),
placementCode: bid.adUnitCode,
id: bid.adId,
status: (bid.statusMessage === 'Bid available') ? 'VALID' : 'EMPTY_OR_ERROR',
cpm: parseFloat(bid.cpm),
size: {
width: Number(bid.width),
height: Number(bid.height)
},
timeToRespond: bid.timeToRespond,
afterTimeout: adomikAdapter.currentContext.timeouted
};
}

adomikAdapter.sizeUtils = {
sizeAlreadyExists: (sizes, typedEventSize) => {
return sizes.find((size) => size.height === typedEventSize.height && size.width === typedEventSize.width);
},
formatSize: (typedEventSize) => {
return {
width: Number(typedEventSize.width),
height: Number(typedEventSize.height)
};
},
handleSize: (sizes, typedEventSize) => {
let formattedSize = null;
if (adomikAdapter.sizeUtils.sizeAlreadyExists(sizes, typedEventSize) === undefined) {
formattedSize = adomikAdapter.sizeUtils.formatSize(typedEventSize);
}
return formattedSize;
}
};

adomikAdapter.buildTypedEvents = function () {
const groupedTypedEvents = [];
adomikAdapter.bucketEvents.forEach(function(typedEvent, i) {
const [placementCode, type] = [typedEvent.event.placementCode, typedEvent.type];
let existTypedEvent = groupedTypedEvents.findIndex((groupedTypedEvent) => groupedTypedEvent.placementCode === placementCode);

if (existTypedEvent === -1) {
groupedTypedEvents.push({
placementCode: placementCode,
[type]: [typedEvent]
});
existTypedEvent = groupedTypedEvents.length - 1;
}

if (groupedTypedEvents[existTypedEvent][type]) {
groupedTypedEvents[existTypedEvent][type] = [...groupedTypedEvents[existTypedEvent][type], typedEvent];
} else {
groupedTypedEvents[existTypedEvent][type] = [typedEvent];
}
});

return groupedTypedEvents;
}

// Initialize adomik object
adomikAdapter.currentContext = {};
adomikAdapter.bucketEvents = [];

adomikAdapter.adapterEnableAnalytics = adomikAdapter.enableAnalytics;

adomikAdapter.enableAnalytics = function (config) {
const initOptions = config.options;
if (initOptions) {
adomikAdapter.currentContext = {
uid: initOptions.id,
url: initOptions.url,
debug: initOptions.debug,
id: '',
timeouted: false,
timeout: 0,
}
adomikAdapter.adapterEnableAnalytics(config);
}
};

adaptermanager.registerAnalyticsAdapter({
adapter: adomikAdapter,
code: 'adomik'
});

export default adomikAdapter;
94 changes: 94 additions & 0 deletions modules/adxcgAnalyticsAdapter.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
import {ajax} from 'src/ajax';
import adapter from 'src/AnalyticsAdapter';
import adaptermanager from 'src/adaptermanager';
import * as url from 'src/url';
import * as utils from 'src/utils';

const emptyUrl = '';
const analyticsType = 'endpoint';
const adxcgAnalyticsVersion = 'v1.04';

let initOptions;
let auctionTimestamp;
let events = {
bidRequests: [],
bidResponses: []
};

var adxcgAnalyticsAdapter = Object.assign(adapter(
{
emptyUrl,
analyticsType
}), {
track({eventType, args}) {
if (typeof args !== 'undefined') {
if (eventType === 'bidTimeout') {
events.bidTimeout = args;
} else if (eventType === 'auctionInit') {
events.auctionInit = args;
auctionTimestamp = args.timestamp;
} else if (eventType === 'bidRequested') {
events.bidRequests.push(args);
} else if (eventType === 'bidResponse') {
events.bidResponses.push(mapBidResponse(args));
} else if (eventType === 'bidWon') {
send({
bidWon: mapBidResponse(args)
});
}
}

if (eventType === 'auctionEnd') {
send(events);
}
}
});

function mapBidResponse(bidResponse) {
return {
adUnitCode: bidResponse.adUnitCode,
statusMessage: bidResponse.statusMessage,
bidderCode: bidResponse.bidderCode,
adId: bidResponse.adId,
mediaType: bidResponse.mediaType,
creative_id: bidResponse.creative_id,
width: bidResponse.width,
height: bidResponse.height,
cpm: bidResponse.cpm,
timeToRespond: bidResponse.timeToRespond
};
}

function send(data) {
data.initOptions = initOptions;
data.auctionTimestamp = auctionTimestamp;

let location = utils.getTopWindowLocation();
let secure = location.protocol == 'https:';

let adxcgAnalyticsRequestUrl = url.format({
protocol: secure ? 'https' : 'http',
hostname: secure ? 'hbarxs.adxcg.net' : 'hbarx.adxcg.net',
pathname: '/pbrx',
search: {
auctionTimestamp: auctionTimestamp,
adxcgAnalyticsVersion: adxcgAnalyticsVersion,
prebidVersion: $$PREBID_GLOBAL$$.version
}
});

ajax(adxcgAnalyticsRequestUrl, undefined, JSON.stringify(data), {method: 'POST'});
}

adxcgAnalyticsAdapter.originEnableAnalytics = adxcgAnalyticsAdapter.enableAnalytics;
adxcgAnalyticsAdapter.enableAnalytics = function (config) {
initOptions = config.options;
adxcgAnalyticsAdapter.originEnableAnalytics(config);
};

adaptermanager.registerAnalyticsAdapter({
adapter: adxcgAnalyticsAdapter,
code: 'adxcg'
});

export default adxcgAnalyticsAdapter;
Loading

0 comments on commit ae0895f

Please sign in to comment.