Skip to content

Commit

Permalink
Merge tag '0.31.0' of https://github.com/prebid/Prebid.js into prebuilt
Browse files Browse the repository at this point in the history
* tag '0.31.0' of https://github.com/prebid/Prebid.js: (54 commits)
  Fix for prebid#1628 (allowing standard bidCpmAdjustment) (prebid#1645)
  Prebid 0.31.0 Release
  Support native click tracking (prebid#1691)
  Initial commit for video support for pbs (prebid#1706)
  Fixes: Immediate adapter response may end auction (prebid#1690)
  Rubicon feature/s2s test module (prebid#1678)
  Renaming of "huddledmasses" adapter into colossusssp (prebid#1701)
  Don't set non-object configurations (prebid#1704)
  Update JSDoc for `pbjs.enableAnalytics` (prebid#1565)
  Add ad units event (prebid#1702)
  AppnexusAst adapter: logging error message from endpoint (prebid#1697)
  AppnexusAst bidadapter markdown file (prebid#1696)
  Change Default Content-Type for POST Requests to 'application/json' (prebid#1681)
  Code improvement for trustx adapter (prebid#1673)
  PulsePoint Lite adapter - Enabling Sync pixel (prebid#1686)
  Update spotx video adapter to set the spotx_ad_key used in DFP (prebid#1614)
  Fix broken AOL mobile endpoint secure bid requests (prebid#1684)
  Fix adapter tests that hardcoded pbjs. (prebid#1666)
  no longer attaching gpt slots to adUnits, which breaks utils.cloneJson(adUnit) (prebid#1676)
  remove bidmanager from rubicon tests (prebid#1671)
  ...
  • Loading branch information
Mat Brown committed Oct 18, 2017
2 parents b064822 + e74ea2a commit 67b5f38
Show file tree
Hide file tree
Showing 71 changed files with 3,493 additions and 1,810 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
15 changes: 9 additions & 6 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,14 +88,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 @@ -142,11 +150,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
8 changes: 5 additions & 3 deletions integrationExamples/gpt/pbjs_example_gpt.html
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@
}
},
{
bidder: 'huddledmasses',
bidder: 'colossusssp',
params: {
placement_id: 0
}
Expand Down Expand Up @@ -340,7 +340,9 @@
},
{
bidder: 'yieldmo',
params: {}
params: {
placementId: 'ym_12341234' // Optional Yieldmo Placement ID
}
},
{
bidder: 'adequant',
Expand Down Expand Up @@ -382,7 +384,7 @@
}
},
{
bidder: 'huddledmasses',
bidder: 'colossusssp',
params: {
placement_id: 0
}
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;
Loading

0 comments on commit 67b5f38

Please sign in to comment.