Skip to content

Commit

Permalink
Support for downloading Analytics Adapters via http://prebid.org/down…
Browse files Browse the repository at this point in the history
…load.html (prebid#1021)

* ET-1691: Pulsepoint Analytics adapter for Prebid. (#1)

* ET-1691: Adding pulsepoint analytics and tests for pulsepoint adapter

* ET-1691: Adding pulsepoint analytics and tests for pulsepoint adapter

* ET-1691: cleanup

* ET-1691: minor

* ET-1691: revert package.json change

* Adding bidRequest to bidFactory.createBid method as per prebid#509

* ET-1765: Adding support for additional params in PulsePoint adapter (#2)

* ET-1850: Fixing prebid#866

* Minor fix

* Ability to specify Analytics adapters for build

* minor

* fixing broken tests

* Removing all analytics adapters in the default file
  • Loading branch information
anand-venkatraman authored and Matt Kendall committed Mar 30, 2017
1 parent 2262123 commit 4b880ec
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 12 deletions.
1 change: 1 addition & 0 deletions analytics.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[]
2 changes: 1 addition & 1 deletion loaders/adapterLoader.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const fs = require('fs');
const blockLoader = require('block-loader');
const getAdapters = require('./getAdapters');

const adapters = getAdapters();
const adapters = getAdapters('adapters.json', 'adapters');
const files = fs.readdirSync('src/adapters').map((file) => file.replace(/\.[^/.]+$/, ''));
const adapterNames = adapters.filter(getStandardAdapters).filter(getUniques);
//adapters loaded from `srcPath`
Expand Down
3 changes: 2 additions & 1 deletion loaders/analyticsLoader.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

const fs = require('fs');
const blockLoader = require('block-loader');
let analyticsAdapters = require('../package.json').analytics;
const getAdapters = require('./getAdapters');
let analyticsAdapters = getAdapters('analytics.json', 'analyticsAdapters');

var options = {
start: '/** INSERT ANALYTICS - DO NOT EDIT OR REMOVE */',
Expand Down
8 changes: 3 additions & 5 deletions loaders/getAdapters.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ const fs = require('fs');
const path = require('path');
const argv = require('yargs').argv;

const defaultAdapters = 'adapters.json';

function load(file) {
try {
const buffer = fs.readFileSync(file);
Expand All @@ -15,8 +13,8 @@ function load(file) {
}
}

module.exports = function getAdapters() {
let customAdapters = argv.adapters;
module.exports = function getAdapters(defaultAdapters, argName) {
let customAdapters = argv[argName];

if (!customAdapters) {
return load(defaultAdapters);
Expand All @@ -29,7 +27,7 @@ module.exports = function getAdapters() {
return load(customAdapters);
} catch (e) {
console.log(`Prebid Warning: custom adapters config cannot be loaded from ${customAdapters}, ` +
'using default adapters.json');
`using default ${defaultAdapters}`);
return load(defaultAdapters);
}
};
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
"prebid"
],
"globalVarName": "pbjs",
"analytics": [],
"author": "the prebid.js contributors",
"license": "Apache-2.0",
"devDependencies": {
Expand Down
10 changes: 6 additions & 4 deletions test/spec/loaders/getAdapters_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ describe('loaders/getAdapters', () => {

let defaultAdapters;
let customAdapters;
const defaultAdaptersFile = 'adapters.json';
const adaptersArg = 'adapters';

beforeEach(() => {
defaultAdapters = [ 'adapter 1', 'adapter 2', 'adapter 3' ];
Expand All @@ -32,7 +34,7 @@ describe('loaders/getAdapters', () => {
const getAdapters = proxyquire('../../../loaders/getAdapters', {
yargs: { argv: { adapters: 'custom-adapters.json' } }
});
expect(getAdapters()).to.deep.equal(customAdapters);
expect(getAdapters(defaultAdaptersFile, adaptersArg)).to.deep.equal(customAdapters);
});

});
Expand All @@ -51,7 +53,7 @@ describe('loaders/getAdapters', () => {
const getAdapters = proxyquire('../../../loaders/getAdapters', {
yargs: { argv: { adapters: 'non-existent-adapters.json' } }
});
expect(getAdapters()).to.deep.equal(defaultAdapters);
expect(getAdapters(defaultAdaptersFile, adaptersArg)).to.deep.equal(defaultAdapters);
expect(log).to.match(/non-existent-adapters.json/);
console.log = consoleLog;
});
Expand All @@ -69,7 +71,7 @@ describe('loaders/getAdapters', () => {
const getAdapters = proxyquire('../../../loaders/getAdapters', {
yargs: { argv: {} }
});
expect(getAdapters()).to.deep.equal(defaultAdapters);
expect(getAdapters(defaultAdaptersFile, adaptersArg)).to.deep.equal(defaultAdapters);
});

});
Expand All @@ -83,7 +85,7 @@ describe('loaders/getAdapters', () => {
const getAdapters = proxyquire('../../../loaders/getAdapters', {
yargs: { argv: {} }
});
expect(getAdapters()).to.deep.equal([]);
expect(getAdapters(defaultAdaptersFile, adaptersArg)).to.deep.equal([]);
});

});
Expand Down

0 comments on commit 4b880ec

Please sign in to comment.