diff --git a/.circleci/config.yml b/.circleci/config.yml index 16bdd5b317e..ca6713bb587 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -7,7 +7,7 @@ jobs: build: docker: # specify the version you desire here - - image: circleci/node:7.10 + - image: circleci/node:8.9.0 # Specify service dependencies here if necessary # CircleCI maintains a library of pre-built images diff --git a/.eslintrc.js b/.eslintrc.js index 02ff81614c7..56e4808f985 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -1,3 +1,6 @@ + +const allowedModules = require("./allowedModules"); + module.exports = { "env": { "browser": true, @@ -11,6 +14,9 @@ module.exports = { } }, "extends": "standard", + "plugins": [ + "prebid" + ], "globals": { "$$PREBID_GLOBAL$$": false }, @@ -31,5 +37,11 @@ module.exports = { "no-throw-literal": "off", "no-undef": "off", "no-useless-escape": "off", - } + }, + "overrides": Object.keys(allowedModules).map((key) => ({ + "files": key + "/**/*.js", + "rules": { + "prebid/validate-imports": ["error", allowedModules[key]] + } + })) }; diff --git a/.gitignore b/.gitignore index 88e849a35ad..c0452b7b3d0 100644 --- a/.gitignore +++ b/.gitignore @@ -28,6 +28,9 @@ build/coverage/ .idea/ # if you remove the above rule, at least ignore the following: +# VS Code +.vscode/ + # User-specific stuff: # .idea/workspace.xml # .idea/tasks.xml diff --git a/.nvmrc b/.nvmrc index 4fedf1d20e1..fa97ecedc28 100644 --- a/.nvmrc +++ b/.nvmrc @@ -1 +1 @@ -7.0 +8.9 diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index b82b249fa36..9c00a2bf51a 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -4,7 +4,7 @@ commit your changes, and [open a pull request](https://help.github.com/articles/ master branch. Pull requests must have 80% code coverage before beign considered for merge. -Additional details about the process can be found [here](./pr_review.md). +Additional details about the process can be found [here](./PR_REVIEW.md). ## Issues [prebid.org](http://prebid.org/) contains documentation that may help answer questions you have about using Prebid.js. diff --git a/PR_REVIEW.md b/PR_REVIEW.md index d5799472377..4ad8b8ec372 100644 --- a/PR_REVIEW.md +++ b/PR_REVIEW.md @@ -14,6 +14,11 @@ For modules and core platform updates, the initial reviewer should request an ad - Review for obvious errors or bad coding practice / use best judgement here. - If the change is a new feature / change to core prebid.js - review the change with a Tech Lead on the project and make sure they agree with the nature of change. - If the change results in needing updates to docs (such as public API change, module interface etc), add a label for "needs docs" and inform the submitter they must submit a docs PR to update the appropriate area of Prebid.org **before the PR can merge**. Help them with finding where the docs are located on prebid.org if needed. + - Below are some examples of bidder specific updates that should require docs update (in their dev-docs/bidders/bidder.md file): + - Add support for GDPR consentManagement module > add `gdpr_supported: true` + - Add support for userId module > add `userId: pubCommon, digitrust, newProviderHere` + - Add support for video and/or native mediaTypes > add `media_types: video, native` + - Add support for COPPA > add `coppa_supported: true` - If all above is good, add a `LGTM` comment and request 1 additional core member to review. - Once there is 2 `LGTM` on the PR, merge to master - Ask the submitter to add a PR for documentation if applicable. diff --git a/README.md b/README.md index 62c835f8eb3..be07a27ddc1 100644 --- a/README.md +++ b/README.md @@ -66,7 +66,7 @@ module.exports = { } ``` -Or for Babel 6 and/or Node v8.6.0 and less: +Or for Babel 6: ```javascript // you must manually install and specify the presets and plugins yourself options: { @@ -112,11 +112,11 @@ prebid.requestBids({ $ cd Prebid.js $ npm install -*Note:* You need to have `NodeJS` 6.x or greater installed. +*Note:* You need to have `NodeJS` 8.9.x or greater installed. -*Note:* In the 1.24.0 release of Prebid.js we have transitioned to using gulp 4.0 from using gulp 3.9.1. To compily with gulp's recommended setup for 4.0, you'll need to have `gulp-cli` installed globally prior to running the general `npm install`. This shouldn't impact any other projects you may work on that use an earlier version of gulp in it's setup. +*Note:* In the 1.24.0 release of Prebid.js we have transitioned to using gulp 4.0 from using gulp 3.9.1. To comply with gulp's recommended setup for 4.0, you'll need to have `gulp-cli` installed globally prior to running the general `npm install`. This shouldn't impact any other projects you may work on that use an earlier version of gulp in its setup. -If you have a previous version of `gulp` installed globally, you'll need to remove it before installing `gulp-cli`. You can check if this is installed by running `gulp -v` and seeing the version that's listed in the `CLI` field of the output. If you have the `gulp` package installd globally, it's likely the same version that you'll see in the `Local` field. If you already have `gulp-cli` installed, it should be a lower major version (it's at version `2.0.1` at the time of the transition). +If you have a previous version of `gulp` installed globally, you'll need to remove it before installing `gulp-cli`. You can check if this is installed by running `gulp -v` and seeing the version that's listed in the `CLI` field of the output. If you have the `gulp` package installed globally, it's likely the same version that you'll see in the `Local` field. If you already have `gulp-cli` installed, it should be a lower major version (it's at version `2.0.1` at the time of the transition). To remove the old package, you can use the command: `npm rm gulp -g` @@ -207,10 +207,20 @@ gulp test-coverage gulp view-coverage ``` -For end-to-end testing, edit the example file `./integrationExamples/gpt/pbjs_example_gpt.html`: +For Prebid.org members with access to BrowserStack, additional end-to-end testing can be done with: -1. Change `{id}` values appropriately to set up ad units and bidders -2. Set the path to Prebid.js in your example file as shown below (see `pbs.src`). +```bash +gulp e2e-test --host=test.localhost +``` + +To run these tests, the following items are required: +- setup an alias of localhost in your `hosts` file (eg `127.0.0.1 test.localhost`); note - you can use any alias. Use this alias in the command-line argument above. +- access to [BrowserStack](https://www.browserstack.com/) account. Assign the following variables in your bash_profile: +```bash +export BROWSERSTACK_USERNAME='YourUserNameHere' +export BROWSERSTACK_ACCESS_KEY='YourAccessKeyHere' +``` +You can get these BrowserStack values from your profile page. For development: diff --git a/allowedModules.js b/allowedModules.js new file mode 100644 index 00000000000..e66b8e24098 --- /dev/null +++ b/allowedModules.js @@ -0,0 +1,24 @@ + +const sharedWhiteList = [ + "core-js/library/fn/array/find", // no ie11 + "core-js/library/fn/array/includes", // no ie11 + "core-js/library/fn/set", // ie11 supports Set but not Set#values + "core-js/library/fn/string/includes", // no ie11 + "core-js/library/fn/number/is-integer", // no ie11, + "core-js/library/fn/array/from" // no ie11 +]; + +module.exports = { + 'modules': [ + ...sharedWhiteList, + 'jsencrypt', + 'crypto-js' + ], + 'src': [ + ...sharedWhiteList, + 'fun-hooks/no-eval', + 'just-clone', + 'dlv', + 'dset' + ] +}; diff --git a/browsers.json b/browsers.json index 703bf44d41d..9042d7d0627 100644 --- a/browsers.json +++ b/browsers.json @@ -1,9 +1,17 @@ { - "bs_ie_14_windows_10": { + "bs_edge_17_windows_10": { "base": "BrowserStack", "os_version": "10", "browser": "edge", - "browser_version": "14.0", + "browser_version": "17.0", + "device": null, + "os": "Windows" + }, + "bs_edge_16_windows_10": { + "base": "BrowserStack", + "os_version": "10", + "browser": "edge", + "browser_version": "16.0", "device": null, "os": "Windows" }, @@ -15,52 +23,52 @@ "device": null, "os": "Windows" }, - "bs_chrome_62_windows_10": { + "bs_chrome_74_windows_10": { "base": "BrowserStack", "os_version": "10", "browser": "chrome", - "browser_version": "62.0", + "browser_version": "74.0", "device": null, "os": "Windows" }, - "bs_chrome_61_windows_10": { + "bs_chrome_75_windows_10": { "base": "BrowserStack", "os_version": "10", "browser": "chrome", - "browser_version": "61.0", + "browser_version": "75.0", "device": null, "os": "Windows" }, - "bs_firefox_58_windows_10": { + "bs_firefox_66_windows_10": { "base": "BrowserStack", "os_version": "10", "browser": "firefox", - "browser_version": "58.0", + "browser_version": "66.0", "device": null, "os": "Windows" }, - "bs_firefox_57_windows_10": { + "bs_firefox_67_windows_10": { "base": "BrowserStack", "os_version": "10", "browser": "firefox", - "browser_version": "57.0", + "browser_version": "67.0", "device": null, "os": "Windows" }, - "bs_safari_9.1_mac_elcapitan": { + "bs_safari_11_mac_high_sierra": { "base": "BrowserStack", - "os_version": "El Capitan", + "os_version": "High Sierra", "browser": "safari", - "browser_version": "9.1", + "browser_version": "11.1", "device": null, "os": "OS X" }, - "bs_safari_8_mac_yosemite": { + "bs_safari_12_mac_mojave": { "base": "BrowserStack", - "os_version": "Yosemite", + "os_version": "Mojave", "browser": "safari", - "browser_version": "8.0", + "browser_version": "12.0", "device": null, "os": "OS X" } -} \ No newline at end of file +} diff --git a/gulpHelpers.js b/gulpHelpers.js index 33169da3773..84f01b4e966 100644 --- a/gulpHelpers.js +++ b/gulpHelpers.js @@ -3,17 +3,16 @@ const fs = require('fs.extra'); const path = require('path'); const argv = require('yargs').argv; const MANIFEST = 'package.json'; -const exec = require('child_process').exec; const through = require('through2'); const _ = require('lodash'); const gutil = require('gulp-util'); +const submodules = require('./modules/.submodules.json'); const MODULE_PATH = './modules'; const BUILD_PATH = './build/dist'; const DEV_PATH = './build/dev'; const ANALYTICS_PATH = '../analytics'; - // get only subdirectories that contain package.json with 'main' property function isModuleDirectory(filePath) { try { @@ -22,8 +21,7 @@ function isModuleDirectory(filePath) { const module = require(manifestPath); return module && module.main; } - } - catch (error) {} + } catch (error) {} } module.exports = { @@ -38,11 +36,13 @@ module.exports = { jsonifyHTML: function (str) { console.log(arguments); return str.replace(/\n/g, '') - .replace(/<\//g, '<\\/') - .replace(/\/>/g, '\\/>'); + .replace(/<\//g, '<\\/') + .replace(/\/>/g, '\\/>'); }, getArgModules() { - var modules = (argv.modules || '').split(',').filter(module => !!module); + var modules = (argv.modules || '') + .split(',') + .filter(module => !!module); try { if (modules.length === 1 && path.extname(modules[0]).toLowerCase() === '.json') { @@ -52,13 +52,22 @@ module.exports = { fs.readFileSync(moduleFile, 'utf8') ); } - } catch(e) { + } catch (e) { throw new gutil.PluginError({ plugin: 'modules', message: 'failed reading: ' + argv.modules }); } + Object.keys(submodules).forEach(parentModule => { + if ( + !modules.includes(parentModule) && + modules.some(module => submodules[parentModule].includes(module)) + ) { + modules.unshift(parentModule); + } + }); + return modules; }, getModules: _.memoize(function(externalModules) { @@ -72,19 +81,22 @@ module.exports = { var moduleName = file.split(new RegExp('[.\\' + path.sep + ']'))[0]; var modulePath = path.join(absoluteModulePath, file); if (fs.lstatSync(modulePath).isDirectory()) { - modulePath = path.join(modulePath, "index.js") + modulePath = path.join(modulePath, 'index.js') } memo[modulePath] = moduleName; return memo; }, {}); - } catch(err) { + } catch (err) { internalModules = {}; } return Object.assign(externalModules.reduce((memo, module) => { try { - var modulePath = require.resolve(module); + // prefer internal project modules before looking at project dependencies + var modulePath = require.resolve(module, {paths: ['./modules']}); + if (modulePath === '') modulePath = require.resolve(module); + memo[modulePath] = module; - } catch(err) { + } catch (err) { // do something } return memo; @@ -93,7 +105,7 @@ module.exports = { getBuiltModules: function(dev, externalModules) { var modules = this.getModuleNames(externalModules); - if(Array.isArray(externalModules)) { + if (Array.isArray(externalModules)) { modules = _.intersection(modules, externalModules); } return modules.map(name => path.join(__dirname, dev ? DEV_PATH : BUILD_PATH, name + '.js')); @@ -128,7 +140,7 @@ module.exports = { * Returns an array of source files for inclusion in build process */ getAnalyticsSources: function() { - if (!argv.analytics) {return [];} // empty arrays won't affect a standard build + if (!argv.analytics) { return []; } // empty arrays won't affect a standard build const directoryContents = fs.readdirSync(ANALYTICS_PATH); return directoryContents @@ -155,62 +167,5 @@ module.exports = { } return options; - }, - - createEnd2EndTestReport : function(targetDestinationDir) { - var browsers = require('./browsers.json'); - var env = []; - var input = 'bs'; - for(var key in browsers) { - if(key.substring(0, input.length) === input && browsers[key].browser !== 'iphone') { - env.push(key); - } - } - - //create new directory structure - fs.rmrfSync(targetDestinationDir); - env.forEach(item => { - fs.mkdirpSync(targetDestinationDir + '/' + item); - }); - - //move xml files to newly created directory - var walker = fs.walk('./build/coverage/e2e/reports'); - walker.on("file", function (root, stat, next) { - env.forEach(item => { - if(stat.name.search(item) !== -1) { - var src = root + '/' + stat.name; - var dest = targetDestinationDir + '/' + item + '/' + stat.name; - fs.copy(src, dest, {replace: true}, function(err) { - if(err) { - throw err; - } - }); - } - }); - next(); - }); - - //run junit-viewer to read xml and create html - env.forEach(item => { - //junit-viewer --results="./custom-reports/chrome51" --save="./chrome.html" - var cmd = 'junit-viewer --results="' + targetDestinationDir + '/' + item + '" --save="' + targetDestinationDir + '/' + item +'.html"'; - exec(cmd); - }); - - //create e2e-results.html - var html = 'End to End Testing Result
Note: Refresh in 2-3 seconds if it says "Cannot get ....."
'; - var li = ''; - var tabs = ''; - env.forEach(function(item,i) { - i++; - li = li + '
  • '+item+'
  • '; - tabs = tabs + '
    '; - }); - html = html + '' + tabs; - html = html + '
    '; - - var filepath = targetDestinationDir + '/results.html'; - fs.openSync(filepath, 'w+'); - fs.writeFileSync(filepath, html); } }; diff --git a/gulpfile.js b/gulpfile.js index d3b29aa66a7..24c628ef228 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -19,13 +19,14 @@ var header = require('gulp-header'); var footer = require('gulp-footer'); var replace = require('gulp-replace'); var shell = require('gulp-shell'); -var optimizejs = require('gulp-optimize-js'); var eslint = require('gulp-eslint'); var gulpif = require('gulp-if'); var sourcemaps = require('gulp-sourcemaps'); var through = require('through2'); var fs = require('fs'); var jsEscape = require('gulp-js-escape'); +const path = require('path'); +const execa = require('execa'); var prebid = require('./package.json'); var dateString = 'Updated : ' + (new Date()).toISOString().substring(0, 10); @@ -51,22 +52,6 @@ function clean() { .pipe(gulpClean()); } -function e2etestReport() { - var reportPort = 9010; - var targetDestinationDir = './e2etest-report'; - helpers.createEnd2EndTestReport(targetDestinationDir); - connect.server({ - port: reportPort, - root: './', - livereload: true - }); - - setTimeout(function() { - opens('http://localhost:' + reportPort + '/' + targetDestinationDir.slice(2) + '/results.html'); - }, 5000); -}; -e2etestReport.displayName = 'e2etest-report'; - // Dependant task for building postbid. It escapes postbid-config file. function escapePostbidConfig() { gulp.src('./integrationExamples/postbid/oas/postbid-config.js') @@ -92,13 +77,14 @@ function lint(done) { // View the code coverage report in the browser. function viewCoverage(done) { var coveragePort = 1999; + var mylocalhost = (argv.host) ? argv.host : 'localhost'; connect.server({ port: coveragePort, root: 'build/coverage/karma_html', livereload: false }); - opens('http://localhost:' + coveragePort); + opens('http://' + mylocalhost + ':' + coveragePort); done(); }; @@ -158,7 +144,6 @@ function makeWebpackPkg() { .pipe(webpackStream(cloned, webpack)) .pipe(uglify()) .pipe(gulpif(file => file.basename === 'prebid-core.js', header(banner, { prebid: prebid }))) - .pipe(optimizejs()) .pipe(gulp.dest('build/dist')); } @@ -220,18 +205,6 @@ function bundle(dev, moduleArr) { .pipe(gulpif(dev, sourcemaps.write('.'))); } -// Workaround for incompatibility between Karma & gulp callbacks. -// See https://github.com/karma-runner/gulp-karma/issues/18 for some related discussion. -function newKarmaCallback(done) { - return function (exitCode) { - if (exitCode) { - done(new Error('Karma tests failed with exit code ' + exitCode)); - } else { - done(); - } - } -} - // Run the unit tests. // // By default, this runs in headless chrome. @@ -244,6 +217,13 @@ function newKarmaCallback(done) { function test(done) { if (argv.notest) { done(); + } else if (argv.e2e) { + let wdioCmd = path.join(__dirname, 'node_modules/.bin/wdio'); + let wdioConf = path.join(__dirname, 'wdio.conf.js'); + let wdioOpts = [ + wdioConf + ]; + return execa(wdioCmd, wdioOpts, { stdio: 'inherit' }); } else { var karmaConf = karmaConfMaker(false, argv.browserstack, argv.watch, argv.file); @@ -256,6 +236,22 @@ function test(done) { } } +function newKarmaCallback(done) { + return function(exitCode) { + if (exitCode) { + done(new Error('Karma tests failed with exit code ' + exitCode)); + if (argv.browserstack) { + process.exit(exitCode); + } + } else { + done(); + if (argv.browserstack) { + process.exit(exitCode); + } + } + } +} + // If --file "" is given, the task will only run tests in the specified file. function testCoverage(done) { new KarmaServer(karmaConfMaker(true, false, false, argv.file), newKarmaCallback(done)).start(); @@ -268,35 +264,6 @@ function coveralls() { // 2nd arg is a dependency: 'test' must be finished .pipe(shell('cat build/coverage/lcov.info | node_modules/coveralls/bin/coveralls.js')); } -function e2eTest() { - var cmdQueue = []; - if (argv.browserstack) { - var browsers = require('./browsers.json'); - delete browsers['bs_ie_9_windows_7']; - - var cmdStr = ' --config nightwatch.conf.js'; - if (argv.group) { - cmdStr = cmdStr + ' --group ' + argv.group; - } - cmdStr = cmdStr + ' --reporter ./test/spec/e2e/custom-reporter/pbjs-html-reporter.js'; - - var startWith = 'bs'; - - Object.keys(browsers).filter(function(v) { - return v.substring(0, startWith.length) === startWith && browsers[v].browser !== 'iphone'; - }).map(function(v, i, arr) { - var newArr = (i % 2 === 0) ? arr.slice(i, i + 2) : null; - if (newArr) { - var cmd = 'nightwatch --env ' + newArr.join(',') + cmdStr; - cmdQueue.push(cmd); - } - }); - } - - return gulp.src('') - .pipe(shell(cmdQueue.join(';'))); -} - // This task creates postbid.js. Postbid setup is different from prebid.js // More info can be found here http://prebid.org/overview/what-is-post-bid.html @@ -308,6 +275,21 @@ function buildPostbid() { .pipe(gulp.dest('build/postbid/')); } +function setupE2e(done) { + if (!argv.host) { + throw new gutil.PluginError({ + plugin: 'E2E test', + message: gutil.colors.red('Host should be defined e.g. ap.localhost, anlocalhost. localhost cannot be used as safari browserstack is not able to connect to localhost') + }); + } + process.env.TEST_SERVER_HOST = argv.host; + if (argv.https) { + process.env.TEST_SERVER_PROTOCOL = argv.https; + } + argv.e2e = true; + done(); +} + // support tasks gulp.task(lint); gulp.task(watch); @@ -333,12 +315,9 @@ gulp.task('build-postbid', gulp.series(escapePostbidConfig, buildPostbid)); gulp.task('serve', gulp.series(clean, lint, gulp.parallel('build-bundle-dev', watch, test))); gulp.task('default', gulp.series(clean, makeWebpackPkg)); -gulp.task(e2etestReport); -gulp.task('e2etest', gulp.series(clean, gulp.parallel(makeDevpackPkg, makeWebpackPkg), e2eTest)); - +gulp.task('e2e-test', gulp.series(clean, setupE2e, gulp.parallel('build-bundle-dev', watch), test)) // other tasks gulp.task(bundleToStdout); gulp.task('bundle', gulpBundle.bind(null, false)); // used for just concatenating pre-built files with no build step -gulp.task('serve-nw', gulp.parallel(lint, watch, 'e2etest')); module.exports = nodeBundle; diff --git a/integrationExamples/gpt/digitrust_Full.html b/integrationExamples/gpt/digitrust_Full.html new file mode 100644 index 00000000000..7ec268a619a --- /dev/null +++ b/integrationExamples/gpt/digitrust_Full.html @@ -0,0 +1,222 @@ + + + Full DigiTrust Prebid Sample + + + + + + + + + + + + + +

    DigiTrust Prebid Full Sample

    + + +

    + This sample shows the simplest integration path for using DigiTrust ID with Prebid. + You can use DigiTrust ID without integrating the entire DigiTrust suite. +

    + +
    + +
    + +
    + + + + diff --git a/integrationExamples/gpt/digitrust_Simple.html b/integrationExamples/gpt/digitrust_Simple.html new file mode 100644 index 00000000000..c9a8c1d2ad6 --- /dev/null +++ b/integrationExamples/gpt/digitrust_Simple.html @@ -0,0 +1,220 @@ + + + Simple DigiTrust Prebid - No Framework + + + + + + + + + + + + + + +

    DigiTrust Prebid Sample - No Framework

    + +

    + This sample shows the simplest integration path for using DigiTrust ID with Prebid. + You can use DigiTrust ID without integrating the entire DigiTrust suite. +

    +
    + +
    + +
    + + diff --git a/integrationExamples/gpt/gdpr_hello_world.html b/integrationExamples/gpt/gdpr_hello_world.html index 084310b57d2..de0630178f1 100644 --- a/integrationExamples/gpt/gdpr_hello_world.html +++ b/integrationExamples/gpt/gdpr_hello_world.html @@ -1,5 +1,7 @@ + + - - - + setTimeout(function() { + sendAdserverRequest(); + console.log('timeout in main pbjs fired'); + }, FAILSAFE_TIMEOUT); + - \ No newline at end of file + diff --git a/integrationExamples/gpt/gpt_aliasingBidder.html b/integrationExamples/gpt/gpt_aliasingBidder.html deleted file mode 100644 index 693be76e82e..00000000000 --- a/integrationExamples/gpt/gpt_aliasingBidder.html +++ /dev/null @@ -1,191 +0,0 @@ - - - - - - - - - - - - - -

    Prebid.js Test

    - -
    - -
    - - -
    - -
    - - - - - - - diff --git a/integrationExamples/gpt/hello_world.html b/integrationExamples/gpt/hello_world.html index e1cdaa0dc29..337c762adc5 100644 --- a/integrationExamples/gpt/hello_world.html +++ b/integrationExamples/gpt/hello_world.html @@ -9,8 +9,11 @@ + + - - - - \ No newline at end of file + diff --git a/integrationExamples/gpt/hello_world_emoteev.html b/integrationExamples/gpt/hello_world_emoteev.html deleted file mode 100644 index 5e4d0716d2b..00000000000 --- a/integrationExamples/gpt/hello_world_emoteev.html +++ /dev/null @@ -1,91 +0,0 @@ - - - - - - - - - - - -

    Basic Prebid.js Example

    -
    Div-1
    -
    - -
    - - - diff --git a/integrationExamples/gpt/inskin_example.html b/integrationExamples/gpt/inskin_example.html new file mode 100644 index 00000000000..197a5b1ffe1 --- /dev/null +++ b/integrationExamples/gpt/inskin_example.html @@ -0,0 +1,102 @@ + + + + + + + + + + + + + + + +

    Prebid.js Test

    +
    Div-1
    +
    + +
    + + diff --git a/integrationExamples/gpt/load_pbjs_before_dfp_example.html b/integrationExamples/gpt/load_pbjs_before_dfp_example.html deleted file mode 100644 index cb17b8c3348..00000000000 --- a/integrationExamples/gpt/load_pbjs_before_dfp_example.html +++ /dev/null @@ -1,265 +0,0 @@ - - - - - - -

    Prebid.js Test

    -
    - -
    -
    - -
    - - diff --git a/integrationExamples/gpt/load_pbjs_dfp_concurrently.html b/integrationExamples/gpt/load_pbjs_dfp_concurrently.html deleted file mode 100644 index 0d6270ba7a5..00000000000 --- a/integrationExamples/gpt/load_pbjs_dfp_concurrently.html +++ /dev/null @@ -1,282 +0,0 @@ - - - - - - -

    Prebid.js Test

    -
    - -
    -
    - -
    - - diff --git a/integrationExamples/gpt/pbjs_example_gpt.html b/integrationExamples/gpt/pbjs_example_gpt.html deleted file mode 100644 index 3a32eb5dbd6..00000000000 --- a/integrationExamples/gpt/pbjs_example_gpt.html +++ /dev/null @@ -1,633 +0,0 @@ - - - -Prebid.js integration example - - - - -

    Prebid.js Test

    - -
    - -
    - - -
    - -
    - - - - - - - diff --git a/integrationExamples/gpt/pbjs_innity_gpt.html b/integrationExamples/gpt/pbjs_innity_gpt.html deleted file mode 100644 index 7882d44791d..00000000000 --- a/integrationExamples/gpt/pbjs_innity_gpt.html +++ /dev/null @@ -1,94 +0,0 @@ - - - - - - - - - - - - - - - - - - - - -

    Prebid.js Test

    -
    Div-1
    -
    - -
    - - \ No newline at end of file diff --git a/integrationExamples/gpt/pbjs_partial_refresh_gpt.html b/integrationExamples/gpt/pbjs_partial_refresh_gpt.html deleted file mode 100644 index 09009a24d76..00000000000 --- a/integrationExamples/gpt/pbjs_partial_refresh_gpt.html +++ /dev/null @@ -1,296 +0,0 @@ - - - - - - - - - - - - - -

    Prebid.js Test

    - -
    Div-1, 300x250 or 300x600
    - - - -
    - -
    - - -
    Div-2, 728x90 or 970x90
    - - - - -
    - -
    - - - - - diff --git a/integrationExamples/gpt/pbjs_yieldbot_gpt.html b/integrationExamples/gpt/pbjs_yieldbot_gpt.html deleted file mode 100644 index 986eed8fc5e..00000000000 --- a/integrationExamples/gpt/pbjs_yieldbot_gpt.html +++ /dev/null @@ -1,201 +0,0 @@ - - - - - - - - -

    Prebid.js Yieldbot Adapter Basic Example

    - Use the links below to enable and disable Yieldbot test bids.
    -
    - Note: -
    - The "Enable - Yieldbot Test Bids" link below will set a cookie to force Yieldbot bid requests to return static test creative: the cookie expires in 24 hrs. -
    - -
      -
    1. Enable - Yieldbot Test Bids
    2. -
    3. Disable - Yieldbot Test Bids
    4. -
    -
    Div-0, 728x90
    - -
    - -
    -
    Div-1, 300x250 or 300x600
    - -
    - -
    -
    Div-2, 300x250 or 300x600
    - The bid for the 300x250 | 300x600 slot is shown under Div-1 above. - - -
    - -
    - - diff --git a/integrationExamples/gpt/pollux_example.html b/integrationExamples/gpt/pollux_example.html deleted file mode 100644 index 56eedbf2a9c..00000000000 --- a/integrationExamples/gpt/pollux_example.html +++ /dev/null @@ -1,132 +0,0 @@ - - - - - - - - - - - - - - - - - - - test - - - -
    - -
    - -
    -
    - -
    - -
    - - \ No newline at end of file diff --git a/integrationExamples/gpt/prebidServer_example.html b/integrationExamples/gpt/prebidServer_example.html index f13c93963c6..db61a6a46d6 100644 --- a/integrationExamples/gpt/prebidServer_example.html +++ b/integrationExamples/gpt/prebidServer_example.html @@ -41,7 +41,7 @@ { bidder: 'appnexus', params: { - placementId: '13144370' + placementId: 13144370 } } ] diff --git a/integrationExamples/gpt/prebidServer_native_example.html b/integrationExamples/gpt/prebidServer_native_example.html new file mode 100644 index 00000000000..16c7d38a427 --- /dev/null +++ b/integrationExamples/gpt/prebidServer_native_example.html @@ -0,0 +1,174 @@ + + + + + + + + + + + + + + + + +

    Prebid Native

    +
    +

    No response

    + +
    + +
    +
    + +
    +

    No response

    + +
    + + + + diff --git a/integrationExamples/gpt/unruly_example.html b/integrationExamples/gpt/unruly_example.html deleted file mode 100644 index 038951b9eb8..00000000000 --- a/integrationExamples/gpt/unruly_example.html +++ /dev/null @@ -1,124 +0,0 @@ - - - - - - - - - - - - - - - - - - test - - - -
    - -
    - - - diff --git a/integrationExamples/gpt/userId_example.html b/integrationExamples/gpt/userId_example.html index d64e22e44c7..9e1cd01f8fa 100644 --- a/integrationExamples/gpt/userId_example.html +++ b/integrationExamples/gpt/userId_example.html @@ -140,7 +140,18 @@ name: "unifiedid", expires: 30 }, - + }, { + name: "id5Id", + params: { + partner: 173 //Set your real ID5 partner ID here for production, please ask for one at http://id5.io/prebid + }, + storage: { + type: "cookie", + name: "id5id", + expires: 90, + refreshInSeconds: 8*3600 // Refresh frequency of cookies, defaulting to 'expires' + }, + }, { name: "pubCommonId", storage: { @@ -152,6 +163,16 @@ // foo: '9879878907987', // bar:'93939' // } + }, { + name: 'identityLink', + params: { + pid: '14' // Set your real identityLink placement ID here + }, + storage: { + type: 'cookie', + name: 'idl_env', + expires: 60 + } }], syncDelay: 5000 } diff --git a/integrationExamples/gpt/x-domain/creative.html b/integrationExamples/gpt/x-domain/creative.html index 3b0058f2ee8..a6981706227 100644 --- a/integrationExamples/gpt/x-domain/creative.html +++ b/integrationExamples/gpt/x-domain/creative.html @@ -2,10 +2,11 @@ // this script can be returned by an ad server delivering a cross domain iframe, into which the // creative will be rendered, e.g. DFP delivering a SafeFrame +let windowLocation = window.location; var urlParser = document.createElement('a'); urlParser.href = '%%PATTERN:url%%'; var publisherDomain = urlParser.protocol + '//' + urlParser.hostname; -var adServerDomain = urlParser.protocol + '//tpc.googlesyndication.com'; +var adServerDomain = windowLocation.protocol + '//tpc.googlesyndication.com'; function renderAd(ev) { var key = ev.message ? 'message' : 'data'; diff --git a/integrationExamples/longform/basic_w_custom_adserver_translation.html b/integrationExamples/longform/basic_w_custom_adserver_translation.html new file mode 100644 index 00000000000..995ea822da4 --- /dev/null +++ b/integrationExamples/longform/basic_w_custom_adserver_translation.html @@ -0,0 +1,132 @@ + + + + + Prebid Freewheel Integration Demo + + + + + + + + + + + + + + + + + + +

    Prebid Freewheel Integration Demo

    +

    custom adserver translation file

    +
    +
    + +
    +
    +
    +
    +

    + +

    +
    +
    +
    + // bids +
    +
    +
    +
    +
    +

    + +

    +
    +
    +
    + // bids +
    +
    +
    +
    +
    +
    +
    + + + + \ No newline at end of file diff --git a/integrationExamples/longform/basic_w_requireExactDuration.html b/integrationExamples/longform/basic_w_requireExactDuration.html new file mode 100644 index 00000000000..016b51d09c4 --- /dev/null +++ b/integrationExamples/longform/basic_w_requireExactDuration.html @@ -0,0 +1,130 @@ + + + + + Prebid Freewheel Integration Demo + + + + + + + + + + + + + + + + + + +

    Prebid Freewheel Test Page

    +

    requireExactDuration = true

    +
    +
    + +
    +
    +
    +
    +

    + +

    +
    +
    +
    + // bids +
    +
    +
    +
    +
    +

    + +

    +
    +
    +
    + // bids +
    +
    +
    +
    +
    +
    +
    + + + + \ No newline at end of file diff --git a/integrationExamples/longform/basic_wo_brandCategoryExclusion.html b/integrationExamples/longform/basic_wo_brandCategoryExclusion.html new file mode 100644 index 00000000000..c8af5801406 --- /dev/null +++ b/integrationExamples/longform/basic_wo_brandCategoryExclusion.html @@ -0,0 +1,130 @@ + + + + + Prebid Freewheel Integration Demo + + + + + + + + + + + + + + + + + + +

    Prebid Freewheel Test Page

    +

    brandCategoryExclusion = false

    +
    +
    + +
    +
    +
    +
    +

    + +

    +
    +
    +
    + // bids +
    +
    +
    +
    +
    +

    + +

    +
    +
    +
    + // bids +
    +
    +
    +
    +
    +
    +
    + + + + \ No newline at end of file diff --git a/integrationExamples/longform/basic_wo_requireExactDuration.html b/integrationExamples/longform/basic_wo_requireExactDuration.html new file mode 100644 index 00000000000..215138479cc --- /dev/null +++ b/integrationExamples/longform/basic_wo_requireExactDuration.html @@ -0,0 +1,131 @@ + + + + + Prebid Freewheel Integration Demo + + + + + + + + + + + + + + + + + + +

    Prebid Freewheel Test Page

    +

    requireExactDuration = false

    +
    +
    + +
    +
    +
    +
    +

    + +

    +
    +
    +
    + // bids +
    +
    +
    +
    +
    +

    + +

    +
    +
    +
    + // bids +
    +
    +
    +
    +
    +
    +
    + + + + \ No newline at end of file diff --git a/integrationExamples/longform/custom_adserver_translation.json b/integrationExamples/longform/custom_adserver_translation.json new file mode 100644 index 00000000000..377fe9cdeda --- /dev/null +++ b/integrationExamples/longform/custom_adserver_translation.json @@ -0,0 +1,1180 @@ +{ + "mapping":{ + "IAB1-1":{ + "id":404, + "name":"Publishing" + }, + "IAB1-2":{ + "id":392, + "name":"Entertainment" + }, + "IAB1-5":{ + "id":419, + "name":"Filmed Entertainment" + }, + "IAB1-6":{ + "id":392, + "name":"Entertainment" + }, + "IAB1-7":{ + "id":392, + "name":"Entertainment" + }, + "IAB2-1":{ + "id":399, + "name":"Automotive" + }, + "IAB2-2":{ + "id":399, + "name":"Automotive" + }, + "IAB2-3":{ + "id":399, + "name":"Automotive" + }, + "IAB2-4":{ + "id":399, + "name":"Automotive" + }, + "IAB2-5":{ + "id":399, + "name":"Automotive" + }, + "IAB2-6":{ + "id":399, + "name":"Automotive" + }, + "IAB2-7":{ + "id":399, + "name":"Automotive" + }, + "IAB2-8":{ + "id":399, + "name":"Automotive" + }, + "IAB2-9":{ + "id":399, + "name":"Automotive" + }, + "IAB2-10":{ + "id":399, + "name":"Automotive" + }, + "IAB2-11":{ + "id":399, + "name":"Automotive" + }, + "IAB2-12":{ + "id":399, + "name":"Automotive" + }, + "IAB2-13":{ + "id":399, + "name":"Automotive" + }, + "IAB2-14":{ + "id":399, + "name":"Automotive" + }, + "IAB2-15":{ + "id":399, + "name":"Automotive" + }, + "IAB2-16":{ + "id":399, + "name":"Automotive" + }, + "IAB2-17":{ + "id":399, + "name":"Automotive" + }, + "IAB2-18":{ + "id":399, + "name":"Automotive" + }, + "IAB2-19":{ + "id":399, + "name":"Automotive" + }, + "IAB2-20":{ + "id":399, + "name":"Automotive" + }, + "IAB2-21":{ + "id":399, + "name":"Automotive" + }, + "IAB2-22":{ + "id":399, + "name":"Automotive" + }, + "IAB2-23":{ + "id":399, + "name":"Automotive" + }, + "IAB3-1":{ + "id":393, + "name":"Business Services" + }, + "IAB3-2":{ + "id":393, + "name":"Business Services" + }, + "IAB3-3":{ + "id":393, + "name":"Business Services" + }, + "IAB3-4":{ + "id":409, + "name":"Computing Product" + }, + "IAB3-5":{ + "id":393, + "name":"Business Services" + }, + "IAB3-6":{ + "id":393, + "name":"Business Services" + }, + "IAB3-7":{ + "id":398, + "name":"Government/Municipal" + }, + "IAB3-8":{ + "id":393, + "name":"Business Services" + }, + "IAB3-9":{ + "id":393, + "name":"Business Services" + }, + "IAB3-10":{ + "id":393, + "name":"Business Services" + }, + "IAB3-11":{ + "id":393, + "name":"Business Services" + }, + "IAB3-12":{ + "id":393, + "name":"Business Services" + }, + "IAB4-1":{ + "id":393, + "name":"Business Services" + }, + "IAB4-2":{ + "id":405, + "name":"Educational Services" + }, + "IAB4-3":{ + "id":405, + "name":"Educational Services" + }, + "IAB4-4":{ + "id":393, + "name":"Business Services" + }, + "IAB4-5":{ + "id":393, + "name":"Business Services" + }, + "IAB4-6":{ + "id":393, + "name":"Business Services" + }, + "IAB4-7":{ + "id":406, + "name":"Health Care Services" + }, + "IAB4-8":{ + "id":405, + "name":"Educational Services" + }, + "IAB4-9":{ + "id":417, + "name":"Telecommunications" + }, + "IAB4-10":{ + "id":429, + "name":"Military" + }, + "IAB4-11":{ + "id":393, + "name":"Business Services" + }, + "IAB5-1":{ + "id":405, + "name":"Educational Services" + }, + "IAB5-2":{ + "id":405, + "name":"Educational Services" + }, + "IAB5-3":{ + "id":405, + "name":"Educational Services" + }, + "IAB5-4":{ + "id":405, + "name":"Educational Services" + }, + "IAB5-5":{ + "id":405, + "name":"Educational Services" + }, + "IAB5-6":{ + "id":405, + "name":"Educational Services" + }, + "IAB5-7":{ + "id":405, + "name":"Educational Services" + }, + "IAB5-8":{ + "id":405, + "name":"Educational Services" + }, + "IAB5-9":{ + "id":405, + "name":"Educational Services" + }, + "IAB5-10":{ + "id":405, + "name":"Educational Services" + }, + "IAB5-11":{ + "id":405, + "name":"Educational Services" + }, + "IAB5-12":{ + "id":405, + "name":"Educational Services" + }, + "IAB5-13":{ + "id":405, + "name":"Educational Services" + }, + "IAB5-14":{ + "id":405, + "name":"Educational Services" + }, + "IAB5-15":{ + "id":405, + "name":"Educational Services" + }, + "IAB7-1":{ + "id":406, + "name":"Health Care Services" + }, + "IAB7-2":{ + "id":406, + "name":"Health Care Services" + }, + "IAB7-3":{ + "id":406, + "name":"Health Care Services" + }, + "IAB7-4":{ + "id":406, + "name":"Health Care Services" + }, + "IAB7-5":{ + "id":406, + "name":"Health Care Services" + }, + "IAB7-6":{ + "id":406, + "name":"Health Care Services" + }, + "IAB7-7":{ + "id":406, + "name":"Health Care Services" + }, + "IAB7-8":{ + "id":406, + "name":"Health Care Services" + }, + "IAB7-9":{ + "id":406, + "name":"Health Care Services" + }, + "IAB7-10":{ + "id":406, + "name":"Health Care Services" + }, + "IAB7-11":{ + "id":406, + "name":"Health Care Services" + }, + "IAB7-12":{ + "id":406, + "name":"Health Care Services" + }, + "IAB7-13":{ + "id":406, + "name":"Health Care Services" + }, + "IAB7-14":{ + "id":406, + "name":"Health Care Services" + }, + "IAB7-15":{ + "id":406, + "name":"Health Care Services" + }, + "IAB7-16":{ + "id":406, + "name":"Health Care Services" + }, + "IAB7-17":{ + "id":406, + "name":"Health Care Services" + }, + "IAB7-18":{ + "id":406, + "name":"Health Care Services" + }, + "IAB7-19":{ + "id":406, + "name":"Health Care Services" + }, + "IAB7-20":{ + "id":406, + "name":"Health Care Services" + }, + "IAB7-21":{ + "id":406, + "name":"Health Care Services" + }, + "IAB7-22":{ + "id":406, + "name":"Health Care Services" + }, + "IAB7-23":{ + "id":406, + "name":"Health Care Services" + }, + "IAB7-24":{ + "id":406, + "name":"Health Care Services" + }, + "IAB7-25":{ + "id":406, + "name":"Health Care Services" + }, + "IAB7-26":{ + "id":406, + "name":"Health Care Services" + }, + "IAB7-27":{ + "id":406, + "name":"Health Care Services" + }, + "IAB7-28":{ + "id":406, + "name":"Health Care Services" + }, + "IAB7-29":{ + "id":406, + "name":"Health Care Services" + }, + "IAB7-30":{ + "id":406, + "name":"Health Care Services" + }, + "IAB7-31":{ + "id":406, + "name":"Health Care Services" + }, + "IAB7-32":{ + "id":406, + "name":"Health Care Services" + }, + "IAB7-33":{ + "id":406, + "name":"Health Care Services" + }, + "IAB7-34":{ + "id":406, + "name":"Health Care Services" + }, + "IAB7-35":{ + "id":406, + "name":"Health Care Services" + }, + "IAB7-36":{ + "id":406, + "name":"Health Care Services" + }, + "IAB7-37":{ + "id":406, + "name":"Health Care Services" + }, + "IAB7-38":{ + "id":406, + "name":"Health Care Services" + }, + "IAB7-39":{ + "id":406, + "name":"Health Care Services" + }, + "IAB7-40":{ + "id":406, + "name":"Health Care Services" + }, + "IAB7-41":{ + "id":406, + "name":"Health Care Services" + }, + "IAB7-42":{ + "id":406, + "name":"Health Care Services" + }, + "IAB7-43":{ + "id":406, + "name":"Health Care Services" + }, + "IAB7-44":{ + "id":406, + "name":"Health Care Services" + }, + "IAB7-45":{ + "id":406, + "name":"Health Care Services" + }, + "IAB8-1":{ + "id":394, + "name":"Food" + }, + "IAB8-2":{ + "id":394, + "name":"Food" + }, + "IAB8-3":{ + "id":394, + "name":"Food" + }, + "IAB8-4":{ + "id":394, + "name":"Food" + }, + "IAB8-5":{ + "id":400, + "name":"Beer/Wine/Liquor" + }, + "IAB8-6":{ + "id":401, + "name":"Beverages" + }, + "IAB8-7":{ + "id":394, + "name":"Food" + }, + "IAB8-8":{ + "id":394, + "name":"Food" + }, + "IAB8-9":{ + "id":407, + "name":"Restaurant/Fast Food" + }, + "IAB8-10":{ + "id":394, + "name":"Food" + }, + "IAB8-11":{ + "id":394, + "name":"Food" + }, + "IAB8-12":{ + "id":394, + "name":"Food" + }, + "IAB8-13":{ + "id":394, + "name":"Food" + }, + "IAB8-14":{ + "id":394, + "name":"Food" + }, + "IAB8-15":{ + "id":394, + "name":"Food" + }, + "IAB8-16":{ + "id":394, + "name":"Food" + }, + "IAB8-17":{ + "id":394, + "name":"Food" + }, + "IAB8-18":{ + "id":400, + "name":"Beer/Wine/Liquor" + }, + "IAB9-1":{ + "id":392, + "name":"Entertainment" + }, + "IAB9-3":{ + "id":418, + "name":"Jewelry" + }, + "IAB9-5":{ + "id":413, + "name":"Gaming" + }, + "IAB9-6":{ + "id":412, + "name":"Household Products" + }, + "IAB9-9":{ + "id":426, + "name":"Tobacco" + }, + "IAB9-11":{ + "id":404, + "name":"Publishing" + }, + "IAB9-15":{ + "id":404, + "name":"Publishing" + }, + "IAB9-16":{ + "id":392, + "name":"Entertainment" + }, + "IAB9-18":{ + "id":393, + "name":"Business Services" + }, + "IAB9-19":{ + "id":418, + "name":"Jewelry" + }, + "IAB9-23":{ + "id":424, + "name":"Photographic Equipment" + }, + "IAB9-24":{ + "id":392, + "name":"Entertainment" + }, + "IAB9-25":{ + "id":392, + "name":"Entertainment" + }, + "IAB9-30":{ + "id":392, + "name":"Entertainment" + }, + "IAB10-1":{ + "id":415, + "name":"Appliances" + }, + "IAB10-5":{ + "id":434, + "name":"Home Furnishings" + }, + "IAB10-6":{ + "id":434, + "name":"Home Furnishings" + }, + "IAB10-7":{ + "id":434, + "name":"Home Furnishings" + }, + "IAB10-8":{ + "id":393, + "name":"Business Services" + }, + "IAB10-9":{ + "id":434, + "name":"Home Furnishings" + }, + "IAB11-1":{ + "id":398, + "name":"Government/Municipal" + }, + "IAB11-2":{ + "id":398, + "name":"Government/Municipal" + }, + "IAB11-3":{ + "id":398, + "name":"Government/Municipal" + }, + "IAB11-4":{ + "id":398, + "name":"Government/Municipal" + }, + "IAB11-5":{ + "id":398, + "name":"Government/Municipal" + }, + "IAB12-1":{ + "id":438, + "name":"News" + }, + "IAB12-2":{ + "id":438, + "name":"News" + }, + "IAB12-3":{ + "id":438, + "name":"News" + }, + "IAB13-1":{ + "id":393, + "name":"Business Services" + }, + "IAB13-2":{ + "id":393, + "name":"Business Services" + }, + "IAB13-3":{ + "id":438, + "name":"News" + }, + "IAB13-4":{ + "id":391, + "name":"Financial Services" + }, + "IAB13-5":{ + "id":393, + "name":"Business Services" + }, + "IAB13-6":{ + "id":436, + "name":"Insurance" + }, + "IAB13-7":{ + "id":393, + "name":"Business Services" + }, + "IAB13-8":{ + "id":393, + "name":"Business Services" + }, + "IAB13-9":{ + "id":393, + "name":"Business Services" + }, + "IAB13-10":{ + "id":393, + "name":"Business Services" + }, + "IAB13-11":{ + "id":393, + "name":"Business Services" + }, + "IAB13-12":{ + "id":393, + "name":"Business Services" + }, + "IAB16-1":{ + "id":423, + "name":"Pet Food/Supplies" + }, + "IAB16-2":{ + "id":423, + "name":"Pet Food/Supplies" + }, + "IAB16-3":{ + "id":423, + "name":"Pet Food/Supplies" + }, + "IAB16-4":{ + "id":423, + "name":"Pet Food/Supplies" + }, + "IAB16-5":{ + "id":423, + "name":"Pet Food/Supplies" + }, + "IAB16-6":{ + "id":423, + "name":"Pet Food/Supplies" + }, + "IAB16-7":{ + "id":423, + "name":"Pet Food/Supplies" + }, + "IAB17-1":{ + "id":425, + "name":"Professional Sports" + }, + "IAB17-2":{ + "id":425, + "name":"Professional Sports" + }, + "IAB17-3":{ + "id":425, + "name":"Professional Sports" + }, + "IAB17-4":{ + "id":425, + "name":"Professional Sports" + }, + "IAB17-5":{ + "id":425, + "name":"Professional Sports" + }, + "IAB17-6":{ + "id":425, + "name":"Professional Sports" + }, + "IAB17-7":{ + "id":425, + "name":"Professional Sports" + }, + "IAB17-8":{ + "id":425, + "name":"Professional Sports" + }, + "IAB17-9":{ + "id":425, + "name":"Professional Sports" + }, + "IAB17-10":{ + "id":425, + "name":"Professional Sports" + }, + "IAB17-11":{ + "id":425, + "name":"Professional Sports" + }, + "IAB17-12":{ + "id":425, + "name":"Professional Sports" + }, + "IAB17-13":{ + "id":425, + "name":"Professional Sports" + }, + "IAB17-14":{ + "id":425, + "name":"Professional Sports" + }, + "IAB17-15":{ + "id":425, + "name":"Professional Sports" + }, + "IAB17-16":{ + "id":425, + "name":"Professional Sports" + }, + "IAB17-17":{ + "id":425, + "name":"Professional Sports" + }, + "IAB17-18":{ + "id":425, + "name":"Professional Sports" + }, + "IAB17-19":{ + "id":425, + "name":"Professional Sports" + }, + "IAB17-20":{ + "id":425, + "name":"Professional Sports" + }, + "IAB17-21":{ + "id":425, + "name":"Professional Sports" + }, + "IAB17-22":{ + "id":425, + "name":"Professional Sports" + }, + "IAB17-23":{ + "id":425, + "name":"Professional Sports" + }, + "IAB17-24":{ + "id":425, + "name":"Professional Sports" + }, + "IAB17-25":{ + "id":425, + "name":"Professional Sports" + }, + "IAB17-26":{ + "id":425, + "name":"Professional Sports" + }, + "IAB17-27":{ + "id":425, + "name":"Professional Sports" + }, + "IAB17-28":{ + "id":425, + "name":"Professional Sports" + }, + "IAB17-29":{ + "id":425, + "name":"Professional Sports" + }, + "IAB17-30":{ + "id":425, + "name":"Professional Sports" + }, + "IAB17-31":{ + "id":425, + "name":"Professional Sports" + }, + "IAB17-32":{ + "id":425, + "name":"Professional Sports" + }, + "IAB17-33":{ + "id":425, + "name":"Professional Sports" + }, + "IAB17-34":{ + "id":425, + "name":"Professional Sports" + }, + "IAB17-35":{ + "id":425, + "name":"Professional Sports" + }, + "IAB17-36":{ + "id":425, + "name":"Professional Sports" + }, + "IAB17-37":{ + "id":425, + "name":"Professional Sports" + }, + "IAB17-38":{ + "id":425, + "name":"Professional Sports" + }, + "IAB17-39":{ + "id":425, + "name":"Professional Sports" + }, + "IAB17-40":{ + "id":425, + "name":"Professional Sports" + }, + "IAB17-41":{ + "id":425, + "name":"Professional Sports" + }, + "IAB17-42":{ + "id":425, + "name":"Professional Sports" + }, + "IAB17-43":{ + "id":425, + "name":"Professional Sports" + }, + "IAB17-44":{ + "id":425, + "name":"Professional Sports" + }, + "IAB18-1":{ + "id":411, + "name":"Cosmetics/Toiletries" + }, + "IAB18-2":{ + "id":397, + "name":"Apparel" + }, + "IAB18-3":{ + "id":397, + "name":"Apparel" + }, + "IAB18-4":{ + "id":418, + "name":"Jewelry" + }, + "IAB18-5":{ + "id":397, + "name":"Apparel" + }, + "IAB18-6":{ + "id":397, + "name":"Apparel" + }, + "IAB19-2":{ + "id":409, + "name":"Computing Product" + }, + "IAB19-3":{ + "id":409, + "name":"Computing Product" + }, + "IAB19-4":{ + "id":409, + "name":"Computing Product" + }, + "IAB19-5":{ + "id":424, + "name":"Photographic Equipment" + }, + "IAB19-6":{ + "id":417, + "name":"Telecommunications" + }, + "IAB19-7":{ + "id":409, + "name":"Computing Product" + }, + "IAB19-8":{ + "id":409, + "name":"Computing Product" + }, + "IAB19-9":{ + "id":409, + "name":"Computing Product" + }, + "IAB19-10":{ + "id":409, + "name":"Computing Product" + }, + "IAB19-11":{ + "id":409, + "name":"Computing Product" + }, + "IAB19-12":{ + "id":409, + "name":"Computing Product" + }, + "IAB19-13":{ + "id":404, + "name":"Publishing" + }, + "IAB19-14":{ + "id":409, + "name":"Computing Product" + }, + "IAB19-15":{ + "id":409, + "name":"Computing Product" + }, + "IAB19-16":{ + "id":409, + "name":"Computing Product" + }, + "IAB19-17":{ + "id":419, + "name":"Filmed Entertainment" + }, + "IAB19-18":{ + "id":409, + "name":"Computing Product" + }, + "IAB19-19":{ + "id":409, + "name":"Computing Product" + }, + "IAB19-20":{ + "id":409, + "name":"Computing Product" + }, + "IAB19-21":{ + "id":409, + "name":"Computing Product" + }, + "IAB19-22":{ + "id":409, + "name":"Computing Product" + }, + "IAB19-23":{ + "id":409, + "name":"Computing Product" + }, + "IAB19-24":{ + "id":409, + "name":"Computing Product" + }, + "IAB19-25":{ + "id":409, + "name":"Computing Product" + }, + "IAB19-26":{ + "id":409, + "name":"Computing Product" + }, + "IAB19-27":{ + "id":409, + "name":"Computing Product" + }, + "IAB19-28":{ + "id":409, + "name":"Computing Product" + }, + "IAB19-29":{ + "id":392, + "name":"Entertainment" + }, + "IAB19-30":{ + "id":409, + "name":"Computing Product" + }, + "IAB19-31":{ + "id":409, + "name":"Computing Product" + }, + "IAB19-32":{ + "id":409, + "name":"Computing Product" + }, + "IAB19-33":{ + "id":409, + "name":"Computing Product" + }, + "IAB19-34":{ + "id":409, + "name":"Computing Product" + }, + "IAB19-35":{ + "id":409, + "name":"Computing Product" + }, + "IAB19-36":{ + "id":409, + "name":"Computing Product" + }, + "IAB20-1":{ + "id":395, + "name":"Travel/Hotels/Airlines" + }, + "IAB20-2":{ + "id":395, + "name":"Travel/Hotels/Airlines" + }, + "IAB20-3":{ + "id":395, + "name":"Travel/Hotels/Airlines" + }, + "IAB20-4":{ + "id":395, + "name":"Travel/Hotels/Airlines" + }, + "IAB20-5":{ + "id":395, + "name":"Travel/Hotels/Airlines" + }, + "IAB20-6":{ + "id":395, + "name":"Travel/Hotels/Airlines" + }, + "IAB20-7":{ + "id":395, + "name":"Travel/Hotels/Airlines" + }, + "IAB20-8":{ + "id":395, + "name":"Travel/Hotels/Airlines" + }, + "IAB20-9":{ + "id":395, + "name":"Travel/Hotels/Airlines" + }, + "IAB20-10":{ + "id":395, + "name":"Travel/Hotels/Airlines" + }, + "IAB20-11":{ + "id":395, + "name":"Travel/Hotels/Airlines" + }, + "IAB20-12":{ + "id":395, + "name":"Travel/Hotels/Airlines" + }, + "IAB20-13":{ + "id":395, + "name":"Travel/Hotels/Airlines" + }, + "IAB20-14":{ + "id":395, + "name":"Travel/Hotels/Airlines" + }, + "IAB20-15":{ + "id":395, + "name":"Travel/Hotels/Airlines" + }, + "IAB20-16":{ + "id":395, + "name":"Travel/Hotels/Airlines" + }, + "IAB20-17":{ + "id":395, + "name":"Travel/Hotels/Airlines" + }, + "IAB20-18":{ + "id":395, + "name":"Travel/Hotels/Airlines" + }, + "IAB20-19":{ + "id":395, + "name":"Travel/Hotels/Airlines" + }, + "IAB20-20":{ + "id":395, + "name":"Travel/Hotels/Airlines" + }, + "IAB20-21":{ + "id":395, + "name":"Travel/Hotels/Airlines" + }, + "IAB20-22":{ + "id":395, + "name":"Travel/Hotels/Airlines" + }, + "IAB20-23":{ + "id":395, + "name":"Travel/Hotels/Airlines" + }, + "IAB20-24":{ + "id":395, + "name":"Travel/Hotels/Airlines" + }, + "IAB20-25":{ + "id":395, + "name":"Travel/Hotels/Airlines" + }, + "IAB20-26":{ + "id":395, + "name":"Travel/Hotels/Airlines" + }, + "IAB20-27":{ + "id":395, + "name":"Travel/Hotels/Airlines" + }, + "IAB21-1":{ + "id":416, + "name":"Real Estate" + }, + "IAB21-2":{ + "id":416, + "name":"Real Estate" + }, + "IAB21-3":{ + "id":416, + "name":"Real Estate" + }, + "IAB22-1":{ + "id":403, + "name":"Retail Stores/Chains" + }, + "IAB22-2":{ + "id":403, + "name":"Retail Stores/Chains" + }, + "IAB22-3":{ + "id":403, + "name":"Retail Stores/Chains" + } + } +} \ No newline at end of file diff --git a/integrationExamples/longform/longformTestUtils.js b/integrationExamples/longform/longformTestUtils.js new file mode 100644 index 00000000000..096be91bb77 --- /dev/null +++ b/integrationExamples/longform/longformTestUtils.js @@ -0,0 +1,66 @@ +var prebidTestUtils = prebidTestUtils || {}; + +function getIndustry(id) { + var mapping = window.localStorage.getItem('iabToFwMappingkey'); + if (mapping) { + try { + mapping = JSON.parse(mapping); + } catch (error) { + // + } + var industry; + mapping = mapping['mapping']; + for (var v in mapping) { + if (mapping[v]['id'] == id) { + industry = mapping[v]['name']; + break; + } + } + return industry; + } +} + +prebidTestUtils.loadKv = function (targetingArr) { + var div = document.getElementById('collapseThree').children[0]; + var html = ''; + Object.keys(targetingArr).forEach(function(adUnitCode) { + targetingArr[adUnitCode].forEach(function (targeting) { + Object.keys(targeting).forEach(function (key) { + html += '' + }); + }); + }); + html += '
    ' + key + '' + targeting[key] + '
    '; + div.innerHTML = html; +} + +prebidTestUtils.loadBids = function (targetingArr, brandCatExclusion) { + var div = document.getElementById('collapseTwo').children[0]; + var html = ''; + var index = 1; + Object.keys(targetingArr).forEach(function(adUnitCode) { + targetingArr[adUnitCode].forEach(function (targeting) { + Object.keys(targeting).forEach(function (key) { + if (key !== 'hb_cache_id') { + var result = targeting[key].split('_'); + html += ''; + html += ''; + html += ''; + if (brandCatExclusion) { + html += ''; + html += ''; + } else { + html += ''; + html += ''; + } + html += ''; + html += ''; + html += ''; + index++; + } + }); + }); + }); + html += '
    #CPMIndustryDurationStatusComm Break #
    ' + index + '' + result[0] + '' + getIndustry(result[1]) + '' + result[2] + '' + result[1] + '
    '; + div.innerHTML = html; +} diff --git a/integrationExamples/longform/longform_testpages_style.css b/integrationExamples/longform/longform_testpages_style.css new file mode 100644 index 00000000000..fe8105edcfa --- /dev/null +++ b/integrationExamples/longform/longform_testpages_style.css @@ -0,0 +1,34 @@ +#videoPlayer { + height: 480px; + width: 100%; + background-color: #000; +} + +.outer { + position: relative; +} + +#skip { + position: absolute; + right: 20px; + bottom: 20px; + display: none; + color: white; + background-color: black; + border: 1px solid gray; +} + +#adCount { + color: white; + position: absolute; + left: 20px; + bottom: 20px; + display: none; +} + +#showad { + color: white; + position: absolute; + left: 20px; + top: 20px; +} \ No newline at end of file diff --git a/karma.conf.maker.js b/karma.conf.maker.js index 649a13a16fc..9aa416375b5 100644 --- a/karma.conf.maker.js +++ b/karma.conf.maker.js @@ -85,7 +85,8 @@ function setBrowsers(karmaConf, browserstack) { if (browserstack) { karmaConf.browserStack = { username: process.env.BROWSERSTACK_USERNAME, - accessKey: process.env.BROWSERSTACK_ACCESS_KEY + accessKey: process.env.BROWSERSTACK_ACCESS_KEY, + build: 'Prebidjs Unit Tests ' + new Date().toLocaleString() } if (process.env.TRAVIS) { karmaConf.browserStack.startTunnel = false; diff --git a/modules/.submodules.json b/modules/.submodules.json new file mode 100644 index 00000000000..c0e30037660 --- /dev/null +++ b/modules/.submodules.json @@ -0,0 +1,11 @@ +{ + "userId": [ + "digiTrustIdSystem", + "id5IdSystem", + "criteortusIdSystem" + ], + "adpod": [ + "freeWheelAdserverVideo", + "dfpAdServerVideo" + ] +} diff --git a/modules/33acrossBidAdapter.js b/modules/33acrossBidAdapter.js index 1cf885ed6e4..f53bf8b9d17 100644 --- a/modules/33acrossBidAdapter.js +++ b/modules/33acrossBidAdapter.js @@ -1,8 +1,7 @@ +import { registerBidder } from '../src/adapters/bidderFactory'; +import { config } from '../src/config'; import * as utils from '../src/utils'; -const { registerBidder } = require('../src/adapters/bidderFactory'); -const { config } = require('../src/config'); - const BIDDER_CODE = '33across'; const END_POINT = 'https://ssc.33across.com/api/v1/hb'; const SYNC_ENDPOINT = 'https://de.tynt.com/deb/v2?m=xch&rt=html'; @@ -32,17 +31,43 @@ function _isViewabilityMeasurable(element) { } function _getViewability(element, topWin, { w, h } = {}) { - return utils.getWindowTop().document.visibilityState === 'visible' + return topWin.document.visibilityState === 'visible' ? _getPercentInView(element, topWin, { w, h }) : 0; } +function _mapAdUnitPathToElementId(adUnitCode) { + if (utils.isGptPubadsDefined()) { + const adSlots = googletag.pubads().getSlots(); + const isMatchingAdSlot = utils.isSlotMatchingAdUnitCode(adUnitCode); + + for (let i = 0; i < adSlots.length; i++) { + if (isMatchingAdSlot(adSlots[i])) { + const id = adSlots[i].getSlotElementId(); + + utils.logInfo(`[33Across Adapter] Map ad unit path to HTML element id: '${adUnitCode}' -> ${id}`); + + return id; + } + } + } + + utils.logWarn(`[33Across Adapter] Unable to locate element for ad unit code: '${adUnitCode}'`); + + return null; +} + +function _getAdSlotHTMLElement(adUnitCode) { + return document.getElementById(adUnitCode) || + document.getElementById(_mapAdUnitPathToElementId(adUnitCode)); +} + // Infer the necessary data from valid bid for a minimal ttxRequest and create HTTP request // NOTE: At this point, TTX only accepts request for a single impression -function _createServerRequest(bidRequest, gdprConsent) { +function _createServerRequest(bidRequest, gdprConsent = {}) { const ttxRequest = {}; const params = bidRequest.params; - const element = document.getElementById(bidRequest.adUnitCode); + const element = _getAdSlotHTMLElement(bidRequest.adUnitCode); const sizes = _transformSizes(bidRequest.sizes); const minSize = _getMinSize(sizes); @@ -52,10 +77,6 @@ function _createServerRequest(bidRequest, gdprConsent) { const contributeViewability = ViewabilityContributor(viewabilityAmount); - if (element === null) { - utils.logWarn(`Unable to locate element with id: '${bidRequest.adUnitCode}'`); - } - /* * Infer data for the request payload */ @@ -122,14 +143,22 @@ function _createServerRequest(bidRequest, gdprConsent) { } // Sync object will always be of type iframe for TTX -function _createSync(siteId) { +function _createSync({siteId, gdprConsent = {}}) { const ttxSettings = config.getConfig('ttxSettings'); const syncUrl = (ttxSettings && ttxSettings.syncUrl) || SYNC_ENDPOINT; - return { + const {consentString, gdprApplies} = gdprConsent; + + const sync = { type: 'iframe', - url: `${syncUrl}&id=${siteId}` + url: `${syncUrl}&id=${siteId}&gdpr_consent=${encodeURIComponent(consentString)}` + }; + + if (typeof gdprApplies === 'boolean') { + sync.url += `&gdpr=${Number(gdprApplies)}`; } + + return sync; } function _getSize(size) { @@ -261,16 +290,15 @@ function isBidRequestValid(bid) { // NOTE: With regards to gdrp consent data, // - the server independently infers gdpr applicability therefore, setting the default value to false -// - the server, at this point, also doesn't need the consent string to handle gdpr compliance. So passing -// value whether set or not, for the sake of future dev. function buildRequests(bidRequests, bidderRequest) { - const gdprConsent = Object.assign({ consentString: undefined, gdprApplies: false }, bidderRequest && bidderRequest.gdprConsent); + const gdprConsent = Object.assign({ + consentString: undefined, + gdprApplies: false + }, bidderRequest && bidderRequest.gdprConsent); adapterState.uniqueSiteIds = bidRequests.map(req => req.params.siteId).filter(utils.uniques); - return bidRequests.map((req) => { - return _createServerRequest(req, gdprConsent); - }); + return bidRequests.map(req => _createServerRequest(req, gdprConsent)); } // NOTE: At this point, the response from 33exchange will only ever contain one bid i.e. the highest bid @@ -285,14 +313,12 @@ function interpretResponse(serverResponse, bidRequest) { return bidResponses; } -// Register one sync per unique guid -// NOTE: If gdpr applies do not sync +// Register one sync per unique guid so long as iframe is enable +// Else no syncs +// For logic on how we handle gdpr data see _createSyncs and module's unit tests +// '33acrossBidAdapter#getUserSyncs' function getUserSyncs(syncOptions, responses, gdprConsent) { - if (gdprConsent && gdprConsent.gdprApplies === true) { - return [] - } else { - return (syncOptions.iframeEnabled) ? adapterState.uniqueSiteIds.map(_createSync) : ([]); - } + return (syncOptions.iframeEnabled) ? adapterState.uniqueSiteIds.map((siteId) => _createSync({gdprConsent, siteId})) : ([]); } export const spec = { diff --git a/modules/33acrossBidAdapter.md b/modules/33acrossBidAdapter.md index bdb2b944861..c313f3b6e0b 100644 --- a/modules/33acrossBidAdapter.md +++ b/modules/33acrossBidAdapter.md @@ -16,7 +16,7 @@ Connects to 33Across's exchange for bids. ``` var adUnits = [ { - code: '33across-hb-ad-123456-1', + code: '33across-hb-ad-123456-1', // ad slot HTML element ID sizes: [ [300, 250], [728, 90] @@ -24,7 +24,7 @@ var adUnits = [ bids: [{ bidder: '33across', params: { - siteId: 'examplePub1234', + siteId: 'cxBE0qjUir6iopaKkGJozW', productId: 'siab' } }] diff --git a/modules/aardvarkBidAdapter.js b/modules/aardvarkBidAdapter.js index 49095b1cfc1..9caaaaa747c 100644 --- a/modules/aardvarkBidAdapter.js +++ b/modules/aardvarkBidAdapter.js @@ -15,6 +15,7 @@ export function resetUserSync() { export const spec = { code: BIDDER_CODE, + aliases: ['adsparc', 'safereach'], isBidRequestValid: function(bid) { return ((typeof bid.params.ai === 'string') && !!bid.params.ai.length && @@ -25,16 +26,26 @@ export const spec = { var auctionCodes = []; var requests = []; var requestsMap = {}; - var referer = utils.getTopWindowUrl(); + var referer = bidderRequest.refererInfo.referer; var pageCategories = []; + var tdId = ''; + var width = window.innerWidth; + var height = window.innerHeight; // This reference to window.top can cause issues when loaded in an iframe if not protected with a try/catch. try { - if (window.top.rtkcategories && Array.isArray(window.top.rtkcategories)) { - pageCategories = window.top.rtkcategories; + var topWin = utils.getWindowTop(); + if (topWin.rtkcategories && Array.isArray(topWin.rtkcategories)) { + pageCategories = topWin.rtkcategories; } + width = topWin.innerWidth; + height = topWin.innerHeight; } catch (e) {} + if (utils.isStr(utils.deepAccess(validBidRequests, '0.userId.tdid'))) { + tdId = validBidRequests[0].userId.tdid; + } + utils._each(validBidRequests, function(b) { var rMap = requestsMap[b.params.ai]; if (!rMap) { @@ -43,11 +54,17 @@ export const spec = { payload: { version: 1, jsonp: false, - rtkreferer: referer + rtkreferer: referer, + w: width, + h: height }, endpoint: DEFAULT_ENDPOINT }; + if (tdId) { + rMap.payload.tdid = tdId; + } + if (pageCategories && pageCategories.length) { rMap.payload.categories = pageCategories.slice(0); } @@ -124,6 +141,10 @@ export const spec = { bidResponse.dealId = rawBid.dealId } + if (rawBid.hasOwnProperty('ex')) { + bidResponse.ex = rawBid.ex; + } + switch (rawBid.media) { case 'banner': bidResponse.ad = rawBid.adm + utils.createTrackPixelHtml(decodeURIComponent(rawBid.nurl)); diff --git a/modules/adformBidAdapter.js b/modules/adformBidAdapter.js index caf9ce71a69..a3aef10e41e 100644 --- a/modules/adformBidAdapter.js +++ b/modules/adformBidAdapter.js @@ -1,6 +1,7 @@ 'use strict'; import {registerBidder} from '../src/adapters/bidderFactory'; +import { config } from '../src/config'; import { BANNER, VIDEO } from '../src/mediaTypes'; const BIDDER_CODE = 'adform'; @@ -12,6 +13,8 @@ export const spec = { }, buildRequests: function (validBidRequests, bidderRequest) { var i, l, j, k, bid, _key, _value, reqParams, netRevenue, gdprObject; + const currency = config.getConfig('currency.adServerCurrency'); + var request = []; var globalParams = [ [ 'adxDomain', 'adx.adform.net' ], [ 'fd', 1 ], [ 'url', null ], [ 'tid', null ] ]; var bids = JSON.parse(JSON.stringify(validBidRequests)); @@ -31,6 +34,7 @@ export const spec = { } reqParams = bid.params; reqParams.transactionId = bid.transactionId; + reqParams.rcur = reqParams.rcur || currency; request.push(formRequestUrl(reqParams)); } diff --git a/modules/adformOpenRTBBidAdapter.js b/modules/adformOpenRTBBidAdapter.js index 94433d907c4..98e6de8036a 100644 --- a/modules/adformOpenRTBBidAdapter.js +++ b/modules/adformOpenRTBBidAdapter.js @@ -8,6 +8,7 @@ import { NATIVE } from '../src/mediaTypes'; import * as utils from '../src/utils'; +import { config } from '../src/config'; const BIDDER_CODE = 'adformOpenRTB'; const NATIVE_ASSET_IDS = { 0: 'title', 2: 'icon', 3: 'image', 5: 'sponsoredBy', 4: 'body', 1: 'cta' }; @@ -56,6 +57,8 @@ export const spec = { const test = setOnAny(validBidRequests, 'params.test'); const publisher = setOnAny(validBidRequests, 'params.publisher'); const siteId = setOnAny(validBidRequests, 'params.siteId'); + const currency = config.getConfig('currency.adServerCurrency'); + const cur = currency && [ currency ]; const imp = validBidRequests.map((bid, id) => { bid.netRevenue = pt; @@ -66,11 +69,28 @@ export const spec = { }; if (props) { asset.id = props.id; + let wmin, hmin, w, h; + let aRatios = bidParams.aspect_ratios; + + if (aRatios && aRatios[0]) { + aRatios = aRatios[0]; + wmin = aRatios.min_width || 0; + hmin = aRatios.ratio_height * wmin / aRatios.ratio_width | 0; + } + + if (bidParams.sizes) { + const sizes = flatten(bidParams.sizes); + w = sizes[0]; + h = sizes[1]; + } + asset[props.name] = { len: bidParams.len, - wmin: bidParams.sizes && bidParams.sizes[0], - hmin: bidParams.sizes && bidParams.sizes[1], - type: props.type + type: props.type, + wmin, + hmin, + w, + h }; return asset; @@ -94,6 +114,7 @@ export const spec = { device: { ua }, source: { tid, fd: 1 }, ext: { pt }, + cur, imp }; @@ -122,9 +143,13 @@ export const spec = { } const { seatbid, cur } = serverResponse.body; + const bidResponses = flatten(seatbid.map(seat => seat.bid)).reduce((result, bid) => { + result[bid.impid - 1] = bid; + return result; + }, []); + return bids.map((bid, id) => { - const _cbid = seatbid && seatbid[id] && seatbid[id].bid; - const bidResponse = _cbid && _cbid[0]; + const bidResponse = bidResponses[id]; if (bidResponse) { return { requestId: bid.bidId, @@ -171,3 +196,7 @@ function setOnAny(collection, key) { } } } + +function flatten(arr) { + return [].concat(...arr); +} diff --git a/modules/adformOpenRTBBidAdapter.md b/modules/adformOpenRTBBidAdapter.md index f59f039f3ec..0dd98ad07b8 100644 --- a/modules/adformOpenRTBBidAdapter.md +++ b/modules/adformOpenRTBBidAdapter.md @@ -45,7 +45,7 @@ Only native format is supported. Using OpenRTB standard. bidder: 'adformOpenRTB', params: { mid: 606169, // required - adxDomain: 'axd.adform.net', // optional + adxDomain: 'adx.adform.net', // optional siteId: '23455', // optional priceType: 'gross' // optional, default is 'net' publisher: { // optional block diff --git a/modules/adheseBidAdapter.js b/modules/adheseBidAdapter.js index daea17a2a5b..6ca8c8a6aa6 100644 --- a/modules/adheseBidAdapter.js +++ b/modules/adheseBidAdapter.js @@ -18,13 +18,15 @@ export const spec = { if (validBidRequests.length === 0) { return null; } + const { gdprConsent, refererInfo } = bidderRequest; const account = getAccount(validBidRequests); const targets = validBidRequests.map(bid => bid.params.data).reduce(mergeTargets, {}); - const gdprParams = (bidderRequest.gdprConsent && bidderRequest.gdprConsent.consentString) ? [ 'xt' + bidderRequest.gdprConsent.consentString ] : []; + const gdprParams = (gdprConsent && gdprConsent.consentString) ? [`xt${gdprConsent.consentString}`] : []; + const refererParams = (refererInfo && refererInfo.referer) ? [`xf${base64urlEncode(refererInfo.referer)}`] : []; const targetsParams = Object.keys(targets).map(targetCode => targetCode + targets[targetCode].join(';')); const slotsParams = validBidRequests.map(bid => 'sl' + bidToSlotName(bid)); - const params = [...slotsParams, ...targetsParams, ...gdprParams].map(s => '/' + s).join(''); + const params = [...slotsParams, ...targetsParams, ...gdprParams, ...refererParams].map(s => `/${s}`).join(''); const cacheBuster = '?t=' + new Date().getTime(); const uri = 'https://ads-' + account + '.adhese.com/json' + params + cacheBuster; @@ -166,4 +168,8 @@ function getAdDetails(ad) { return { creativeId: creativeId, dealId: dealId }; } +function base64urlEncode(s) { + return btoa(s).replace(/\+/g, '-').replace(/\//g, '_').replace(/=+$/, ''); +} + registerBidder(spec); diff --git a/modules/adkernelAdnBidAdapter.js b/modules/adkernelAdnBidAdapter.js index 63321fb82ee..08842db37e3 100644 --- a/modules/adkernelAdnBidAdapter.js +++ b/modules/adkernelAdnBidAdapter.js @@ -1,11 +1,9 @@ import * as utils from '../src/utils'; import {registerBidder} from '../src/adapters/bidderFactory'; import {BANNER, VIDEO} from '../src/mediaTypes'; -import includes from 'core-js/library/fn/array/includes'; import {parse as parseUrl} from '../src/url'; const DEFAULT_ADKERNEL_DSP_DOMAIN = 'tag.adkernel.com'; -const VIDEO_TARGETING = ['mimes', 'protocols', 'api']; const DEFAULT_MIMES = ['video/mp4', 'video/webm', 'application/x-shockwave-flash', 'application/javascript']; const DEFAULT_PROTOCOLS = [2, 3, 5, 6]; const DEFAULT_APIS = [1, 2]; @@ -19,25 +17,22 @@ function buildImp(bidRequest) { id: bidRequest.bidId, tagid: bidRequest.adUnitCode }; - if (utils.deepAccess(bidRequest, `mediaTypes.banner`)) { - let sizes = canonicalizeSizesArray(bidRequest.mediaTypes.banner.sizes); + let bannerReq = utils.deepAccess(bidRequest, `mediaTypes.banner`); + let videoReq = utils.deepAccess(bidRequest, `mediaTypes.video`); + if (bannerReq) { + let sizes = canonicalizeSizesArray(bannerReq.sizes); imp.banner = { format: utils.parseSizesInput(sizes) } - } else if (utils.deepAccess(bidRequest, `mediaTypes.video`)) { - let size = canonicalizeSizesArray(bidRequest.mediaTypes.video.playerSize)[0]; + } else if (videoReq) { + let size = canonicalizeSizesArray(videoReq.playerSize)[0]; imp.video = { w: size[0], h: size[1], - mimes: DEFAULT_MIMES, - protocols: DEFAULT_PROTOCOLS, - api: DEFAULT_APIS + mimes: videoReq.mimes || DEFAULT_MIMES, + protocols: videoReq.protocols || DEFAULT_PROTOCOLS, + api: videoReq.api || DEFAULT_APIS }; - if (bidRequest.params.video) { - Object.keys(bidRequest.params.video) - .filter(param => includes(VIDEO_TARGETING, param)) - .forEach(param => imp.video[param] = bidRequest.params.video[param]); - } } return imp; } @@ -118,8 +113,11 @@ export const spec = { aliases: ['engagesimply'], isBidRequestValid: function(bidRequest) { - return 'params' in bidRequest && (typeof bidRequest.params.host === 'undefined' || typeof bidRequest.params.host === 'string') && - typeof bidRequest.params.pubId === 'number' && 'mediaTypes' in bidRequest && ('banner' in bidRequest.mediaTypes || 'video' in bidRequest.mediaTypes); + return 'params' in bidRequest && + (typeof bidRequest.params.host === 'undefined' || typeof bidRequest.params.host === 'string') && + typeof bidRequest.params.pubId === 'number' && + 'mediaTypes' in bidRequest && + ('banner' in bidRequest.mediaTypes || 'video' in bidRequest.mediaTypes); }, buildRequests: function(bidRequests, bidderRequest) { @@ -133,10 +131,8 @@ export const spec = { acc[host][pubId].push(curr); return acc; }, {}); - let auctionId = bidderRequest.auctionId; - let gdprConsent = bidderRequest.gdprConsent; - let transactionId = bidderRequest.transactionId; - let refererInfo = bidderRequest.refererInfo; + + let {auctionId, gdprConsent, transactionId, refererInfo} = bidderRequest; let requests = []; Object.keys(dispatch).forEach(host => { Object.keys(dispatch[host]).forEach(pubId => { diff --git a/modules/adkernelAdnBidAdapter.md b/modules/adkernelAdnBidAdapter.md index d69bf3b8998..c536ee1438c 100644 --- a/modules/adkernelAdnBidAdapter.md +++ b/modules/adkernelAdnBidAdapter.md @@ -3,7 +3,7 @@ ``` Module Name: AdKernel ADN Bidder Adapter Module Type: Bidder Adapter -Maintainer: denis@adkernel.com +Maintainer: prebid-dev@adkernel.com ``` # Description @@ -14,32 +14,37 @@ Banner and video formats are supported. # Test Parameters ``` - var adUnits = [ - { - code: 'banner-ad-div', - sizes: [[300, 250], [300, 200]], - bids: [ - { - bidder: 'adkernelAdn', - params: { - pubId: 50357, - host: 'dsp-staging.adkernel.com' - } - } - ] - }, { - code: 'video-ad-player', - sizes: [640, 480], - bids: [ - { - bidder: 'adkernelAdn', - mediaType : 'video', - params: { - pubId: 50357, - host: 'dsp-staging.adkernel.com' - } - } - ] - } - ]; +var adUnits = [{ + code: 'banner-ad-div', + mediaTypes: { + banner: { + sizes: [ + [300, 250], + [300, 200] // banner sizes + ], + } + }, + bids: [{ + bidder: 'adkernelAdn', + params: { + pubId: 50357, + host: 'dsp-staging.adkernel.com' + } + }] +}, { + code: 'video-ad-player', + mediaTypes: { + video: { + context: 'instream', // or 'outstream' + playerSize: [640, 480] // video player size + } + }, + bids: [{ + bidder: 'adkernelAdn', + params: { + pubId: 50357, + host: 'dsp-staging.adkernel.com' + } + }] +}]; ``` diff --git a/modules/adkernelBidAdapter.js b/modules/adkernelBidAdapter.js index 254887dad81..7c48458f474 100644 --- a/modules/adkernelBidAdapter.js +++ b/modules/adkernelBidAdapter.js @@ -5,6 +5,13 @@ import find from 'core-js/library/fn/array/find'; import includes from 'core-js/library/fn/array/includes'; import {parse as parseUrl} from '../src/url'; +/* + * In case you're AdKernel whitelable platform's client who needs branded adapter to + * work with Adkernel platform - DO NOT COPY THIS ADAPTER UNDER NEW NAME + * + * Please contact prebid@adkernel.com and we'll add your adapter as an alias. + */ + const VIDEO_TARGETING = ['mimes', 'minduration', 'maxduration', 'protocols', 'startdelay', 'linearity', 'boxingallowed', 'playbackmethod', 'delivery', 'pos', 'api', 'ext']; @@ -16,24 +23,27 @@ const VERSION = '1.3'; export const spec = { code: 'adkernel', - aliases: ['headbidding'], + aliases: ['headbidding', 'adsolut', 'oftmediahb'], supportedMediaTypes: [BANNER, VIDEO], isBidRequestValid: function(bidRequest) { - return 'params' in bidRequest && typeof bidRequest.params.host !== 'undefined' && - 'zoneId' in bidRequest.params && !isNaN(Number(bidRequest.params.zoneId)) && - bidRequest.mediaTypes && (bidRequest.mediaTypes.banner || bidRequest.mediaTypes.video); + return 'params' in bidRequest && + typeof bidRequest.params.host !== 'undefined' && + 'zoneId' in bidRequest.params && + !isNaN(Number(bidRequest.params.zoneId)) && + bidRequest.params.zoneId > 0 && + bidRequest.mediaTypes && + (bidRequest.mediaTypes.banner || bidRequest.mediaTypes.video); }, buildRequests: function(bidRequests, bidderRequest) { let impDispatch = dispatchImps(bidRequests, bidderRequest.refererInfo); - const gdprConsent = bidderRequest.gdprConsent; - const auctionId = bidderRequest.auctionId; + const {gdprConsent, auctionId} = bidderRequest; const requests = []; Object.keys(impDispatch).forEach(host => { Object.keys(impDispatch[host]).forEach(zoneId => { const request = buildRtbRequest(impDispatch[host][zoneId], auctionId, gdprConsent, bidderRequest.refererInfo); requests.push({ method: 'POST', - url: `${window.location.protocol}//${host}/hb?zone=${Number(zoneId)}&v=${VERSION}`, + url: `${window.location.protocol}//${host}/hb?zone=${zoneId}&v=${VERSION}`, data: JSON.stringify(request) }); }); @@ -47,13 +57,12 @@ export const spec = { } let rtbRequest = JSON.parse(request.data); - let rtbImps = rtbRequest.imp; let rtbBids = response.seatbid .map(seatbid => seatbid.bid) .reduce((a, b) => a.concat(b), []); return rtbBids.map(rtbBid => { - let imp = find(rtbImps, imp => imp.id === rtbBid.impid); + let imp = find(rtbRequest.imp, imp => imp.id === rtbBid.impid); let prBid = { requestId: rtbBid.impid, cpm: rtbBid.price, @@ -119,19 +128,16 @@ function buildImp(bidRequest, secure) { if (utils.deepAccess(bidRequest, `mediaTypes.banner`)) { let sizes = canonicalizeSizesArray(bidRequest.mediaTypes.banner.sizes); imp.banner = { - format: sizes.map(s => ({'w': s[0], 'h': s[1]})), + format: sizes.map(wh => utils.parseGPTSingleSizeArrayToRtbSize(wh)), topframe: 0 }; } else if (utils.deepAccess(bidRequest, 'mediaTypes.video')) { let size = canonicalizeSizesArray(bidRequest.mediaTypes.video.playerSize)[0]; - imp.video = { - w: size[0], - h: size[1] - }; + imp.video = utils.parseGPTSingleSizeArrayToRtbSize(size); if (bidRequest.params.video) { Object.keys(bidRequest.params.video) - .filter(param => includes(VIDEO_TARGETING, param)) - .forEach(param => imp.video[param] = bidRequest.params.video[param]); + .filter(key => includes(VIDEO_TARGETING, key)) + .forEach(key => imp.video[key] = bidRequest.params.video[key]); } } if (secure) { @@ -198,18 +204,18 @@ function getLanguage() { */ function createSite(refInfo) { let url = parseUrl(refInfo.referer); - let result = { + let site = { 'domain': url.hostname, 'page': url.protocol + '://' + url.hostname + url.pathname }; if (self === top && document.referrer) { - result.ref = document.referrer; + site.ref = document.referrer; } let keywords = document.getElementsByTagName('meta')['keywords']; if (keywords && keywords.content) { - result.keywords = keywords.content; + site.keywords = keywords.content; } - return result; + return site; } /** diff --git a/modules/adkernelBidAdapter.md b/modules/adkernelBidAdapter.md index 902be481473..f89fa5a26df 100644 --- a/modules/adkernelBidAdapter.md +++ b/modules/adkernelBidAdapter.md @@ -3,7 +3,7 @@ ``` Module Name: AdKernel Bidder Adapter Module Type: Bidder Adapter -Maintainer: denis@adkernel.com +Maintainer: prebid-dev@adkernel.com ``` # Description @@ -14,32 +14,38 @@ Banner and video formats are supported. # Test Parameters ``` - var adUnits = [ - { - code: 'banner-ad-div', - sizes: [[300, 250]], // banner size - bids: [ - { - bidder: 'adkernel', - params: { - zoneId: '30164', //required parameter - host: 'cpm.metaadserving.com' //required parameter - } - } - ] - }, { - code: 'video-ad-player', - sizes: [640, 480], // video player size - bids: [ - { - bidder: 'adkernel', - mediaType : 'video', - params: { - zoneId: '30164', //required parameter - host: 'cpm.metaadserving.com' //required parameter - } - } - ] - } - ]; + var adUnits = [{ + code: 'banner-ad-div', + mediaTypes: { + banner: { + sizes: [[300, 250]], // banner size + } + }, + bids: [ + { + bidder: 'adkernel', + params: { + zoneId: '30164', //required parameter + host: 'cpm.metaadserving.com' //required parameter + } + } + ] + }, { + code: 'video-ad-player', + mediaTypes: { + video: { + context: 'instream', // or 'outstream' + playerSize: [640, 480] // video player size + } + }, + bids: [ + { + bidder: 'adkernel', + params: { + zoneId: '30164', //required parameter + host: 'cpm.metaadserving.com' //required parameter + } + } + ] + }]; ``` diff --git a/modules/admanBidAdapter.js b/modules/admanBidAdapter.js index 2fd8c2e96f0..4720d06d094 100644 --- a/modules/admanBidAdapter.js +++ b/modules/admanBidAdapter.js @@ -17,7 +17,7 @@ export const spec = { const ENDPOINT_URL = '//bidtor.admanmedia.com/prebid'; const bids = validBidRequests.map(buildRequestObject); const payload = { - referrer: utils.getTopWindowUrl(), + referer: utils.getTopWindowUrl(), bids, deviceWidth: screen.width }; diff --git a/modules/admixerBidAdapter.js b/modules/admixerBidAdapter.js index c5a26d47f89..c6d6dd34a11 100644 --- a/modules/admixerBidAdapter.js +++ b/modules/admixerBidAdapter.js @@ -2,10 +2,11 @@ import * as utils from '../src/utils'; import {registerBidder} from '../src/adapters/bidderFactory'; const BIDDER_CODE = 'admixer'; +const ALIASES = ['go2net']; const ENDPOINT_URL = '//inv-nets.admixer.net/prebid.1.0.aspx'; export const spec = { code: BIDDER_CODE, - aliases: [], + aliases: ALIASES, supportedMediaTypes: ['banner', 'video'], /** * Determines whether or not the given bid request is valid. @@ -28,9 +29,7 @@ export const spec = { referrer: encodeURIComponent(utils.getTopWindowUrl()), }; bidderRequest.forEach((bid) => { - if (bid.bidder === BIDDER_CODE) { - payload.imps.push(bid); - } + payload.imps.push(bid); }); const payloadString = JSON.stringify(payload); return { diff --git a/modules/adpod.js b/modules/adpod.js index fe49c10e193..875809b8df5 100644 --- a/modules/adpod.js +++ b/modules/adpod.js @@ -13,19 +13,22 @@ */ import * as utils from '../src/utils'; -import { addBidToAuction, doCallbacksIfTimedout, AUCTION_IN_PROGRESS, callPrebidCache } from '../src/auction'; +import { addBidToAuction, doCallbacksIfTimedout, AUCTION_IN_PROGRESS, callPrebidCache, getPriceByGranularity, getPriceGranularity } from '../src/auction'; import { checkAdUnitSetup } from '../src/prebid'; import { checkVideoBidSetup } from '../src/video'; -import { setupBeforeHookFnOnce } from '../src/hook'; +import { setupBeforeHookFnOnce, module } from '../src/hook'; import { store } from '../src/videoCache'; import { config } from '../src/config'; import { ADPOD } from '../src/mediaTypes'; import Set from 'core-js/library/fn/set'; import find from 'core-js/library/fn/array/find'; +import { auctionManager } from '../src/auctionManager'; +import CONSTANTS from '../src/constants.json'; + const from = require('core-js/library/fn/array/from'); -export const TARGETING_KEY_PB_CAT_DUR = 'hb_pb_cat_dur'; -export const TARGETING_KEY_CACHE_ID = 'hb_cache_id' +const TARGETING_KEY_PB_CAT_DUR = 'hb_pb_cat_dur'; +const TARGETING_KEY_CACHE_ID = 'hb_cache_id'; let queueTimeDelay = 50; let queueSizeLimit = 5; @@ -117,7 +120,9 @@ function createDispatcher(timeoutDuration) { function attachPriceIndustryDurationKeyToBid(bid, brandCategoryExclusion) { let initialCacheKey = bidCacheRegistry.getInitialCacheKey(bid); let duration = utils.deepAccess(bid, 'video.durationBucket'); - let cpmFixed = bid.cpm.toFixed(2); + const granularity = getPriceGranularity(bid.mediaType); + let cpmFixed = getPriceByGranularity(granularity)(bid); + let pcd; if (brandCategoryExclusion) { @@ -214,21 +219,21 @@ export function callPrebidCacheHook(fn, auctionInstance, bidResponse, afterBidAd if (!adServerCatId && brandCategoryExclusion) { utils.logWarn('Detected a bid without meta.adServerCatId while setConfig({adpod.brandCategoryExclusion}) was enabled. This bid has been rejected:', bidResponse) afterBidAdded(); - } - - if (config.getConfig('adpod.deferCaching') === false) { - bidCacheRegistry.addBid(bidResponse); - attachPriceIndustryDurationKeyToBid(bidResponse, brandCategoryExclusion); - - updateBidQueue(auctionInstance, bidResponse, afterBidAdded); } else { - // generate targeting keys for bid - bidCacheRegistry.setupInitialCacheKey(bidResponse); - attachPriceIndustryDurationKeyToBid(bidResponse, brandCategoryExclusion); + if (config.getConfig('adpod.deferCaching') === false) { + bidCacheRegistry.addBid(bidResponse); + attachPriceIndustryDurationKeyToBid(bidResponse, brandCategoryExclusion); - // add bid to auction - addBidToAuction(auctionInstance, bidResponse); - afterBidAdded(); + updateBidQueue(auctionInstance, bidResponse, afterBidAdded); + } else { + // generate targeting keys for bid + bidCacheRegistry.setupInitialCacheKey(bidResponse); + attachPriceIndustryDurationKeyToBid(bidResponse, brandCategoryExclusion); + + // add bid to auction + addBidToAuction(auctionInstance, bidResponse); + afterBidAdded(); + } } } else { fn.call(this, auctionInstance, bidResponse, afterBidAdded, bidderRequest); @@ -256,8 +261,8 @@ export function checkAdUnitSetupHook(fn, adUnits) { let errMsg = `Detected missing or incorrectly setup fields for an adpod adUnit. Please review the following fields of adUnitCode: ${adUnit.code}. This adUnit will be removed from the auction.`; let playerSize = !!(videoConfig.playerSize && utils.isArrayOfNums(videoConfig.playerSize)); - let adPodDurationSec = !!(videoConfig.adPodDurationSec && utils.isNumber(videoConfig.adPodDurationSec)); - let durationRangeSec = !!(videoConfig.durationRangeSec && utils.isArrayOfNums(videoConfig.durationRangeSec)); + let adPodDurationSec = !!(videoConfig.adPodDurationSec && utils.isNumber(videoConfig.adPodDurationSec) && videoConfig.adPodDurationSec > 0); + let durationRangeSec = !!(videoConfig.durationRangeSec && utils.isArrayOfNums(videoConfig.durationRangeSec) && videoConfig.durationRangeSec.every(range => range > 0)); if (!playerSize || !adPodDurationSec || !durationRangeSec) { errMsg += (!playerSize) ? '\nmediaTypes.video.playerSize' : ''; @@ -385,12 +390,14 @@ config.getConfig('adpod', config => adpodSetConfig(config.adpod)); /** * This function initializes the adpod module's hooks. This is called by the corresponding adserver video module. */ -export function initAdpodHooks() { +function initAdpodHooks() { setupBeforeHookFnOnce(callPrebidCache, callPrebidCacheHook); setupBeforeHookFnOnce(checkAdUnitSetup, checkAdUnitSetupHook); setupBeforeHookFnOnce(checkVideoBidSetup, checkVideoBidSetupHook); } +initAdpodHooks() + /** * * @param {Array[Object]} bids list of 'winning' bids that need to be cached @@ -420,11 +427,163 @@ export function callPrebidCacheAfterAuction(bids, callback) { * @param {Object} bid */ export function sortByPricePerSecond(a, b) { - if (a.cpm / a.video.durationBucket < b.cpm / b.video.durationBucket) { + if (a.adserverTargeting[CONSTANTS.TARGETING_KEYS.PRICE_BUCKET] / a.video.durationBucket < b.adserverTargeting[CONSTANTS.TARGETING_KEYS.PRICE_BUCKET] / b.video.durationBucket) { return 1; } - if (a.cpm / a.video.durationBucket > b.cpm / b.video.durationBucket) { + if (a.adserverTargeting[CONSTANTS.TARGETING_KEYS.PRICE_BUCKET] / a.video.durationBucket > b.adserverTargeting[CONSTANTS.TARGETING_KEYS.PRICE_BUCKET] / b.video.durationBucket) { return -1; } return 0; } + +/** + * This function returns targeting keyvalue pairs for long-form adserver modules. Freewheel and GAM are currently supporting Prebid long-form + * @param {Object} options + * @param {Array[string]} codes + * @param {function} callback + * @returns targeting kvs for adUnitCodes + */ +export function getTargeting({codes, callback} = {}) { + if (!callback) { + utils.logError('No callback function was defined in the getTargeting call. Aborting getTargeting().'); + return; + } + codes = codes || []; + const adPodAdUnits = getAdPodAdUnits(codes); + const bidsReceived = auctionManager.getBidsReceived(); + const competiveExclusionEnabled = config.getConfig('adpod.brandCategoryExclusion'); + const deferCachingSetting = config.getConfig('adpod.deferCaching'); + const deferCachingEnabled = (typeof deferCachingSetting === 'boolean') ? deferCachingSetting : true; + + let bids = getBidsForAdpod(bidsReceived, adPodAdUnits); + bids = (competiveExclusionEnabled || deferCachingEnabled) ? getExclusiveBids(bids) : bids; + bids.sort(sortByPricePerSecond); + + let targeting = {}; + if (deferCachingEnabled === false) { + adPodAdUnits.forEach((adUnit) => { + let adPodTargeting = []; + let adPodDurationSeconds = utils.deepAccess(adUnit, 'mediaTypes.video.adPodDurationSec'); + + bids + .filter((bid) => bid.adUnitCode === adUnit.code) + .forEach((bid, index, arr) => { + if (bid.video.durationBucket <= adPodDurationSeconds) { + adPodTargeting.push({ + [TARGETING_KEY_PB_CAT_DUR]: bid.adserverTargeting[TARGETING_KEY_PB_CAT_DUR] + }); + adPodDurationSeconds -= bid.video.durationBucket; + } + if (index === arr.length - 1 && adPodTargeting.length > 0) { + adPodTargeting.push({ + [TARGETING_KEY_CACHE_ID]: bid.adserverTargeting[TARGETING_KEY_CACHE_ID] + }); + } + }); + targeting[adUnit.code] = adPodTargeting; + }); + + callback(null, targeting); + } else { + let bidsToCache = []; + adPodAdUnits.forEach((adUnit) => { + let adPodDurationSeconds = utils.deepAccess(adUnit, 'mediaTypes.video.adPodDurationSec'); + + bids + .filter((bid) => bid.adUnitCode === adUnit.code) + .forEach((bid) => { + if (bid.video.durationBucket <= adPodDurationSeconds) { + bidsToCache.push(bid); + adPodDurationSeconds -= bid.video.durationBucket; + } + }); + }); + + callPrebidCacheAfterAuction(bidsToCache, function(error, bidsSuccessfullyCached) { + if (error) { + callback(error, null); + } else { + let groupedBids = utils.groupBy(bidsSuccessfullyCached, 'adUnitCode'); + Object.keys(groupedBids).forEach((adUnitCode) => { + let adPodTargeting = []; + + groupedBids[adUnitCode].forEach((bid, index, arr) => { + adPodTargeting.push({ + [TARGETING_KEY_PB_CAT_DUR]: bid.adserverTargeting[TARGETING_KEY_PB_CAT_DUR] + }); + + if (index === arr.length - 1 && adPodTargeting.length > 0) { + adPodTargeting.push({ + [TARGETING_KEY_CACHE_ID]: bid.adserverTargeting[TARGETING_KEY_CACHE_ID] + }); + } + }); + targeting[adUnitCode] = adPodTargeting; + }); + + callback(null, targeting); + } + }); + } + return targeting; +} + +/** + * This function returns the adunit of mediaType adpod + * @param {Array} codes adUnitCodes + * @returns {Array[Object]} adunits of mediaType adpod + */ +function getAdPodAdUnits(codes) { + return auctionManager.getAdUnits() + .filter((adUnit) => utils.deepAccess(adUnit, 'mediaTypes.video.context') === ADPOD) + .filter((adUnit) => (codes.length > 0) ? codes.indexOf(adUnit.code) != -1 : true); +} + +/** + * This function removes bids of same category. It will be used when competitive exclusion is enabled. + * @param {Array[Object]} bidsReceived + * @returns {Array[Object]} unique category bids + */ +function getExclusiveBids(bidsReceived) { + let bids = bidsReceived + .map((bid) => Object.assign({}, bid, {[TARGETING_KEY_PB_CAT_DUR]: bid.adserverTargeting[TARGETING_KEY_PB_CAT_DUR]})); + bids = utils.groupBy(bids, TARGETING_KEY_PB_CAT_DUR); + let filteredBids = []; + Object.keys(bids).forEach((targetingKey) => { + bids[targetingKey].sort(utils.compareOn('responseTimestamp')); + filteredBids.push(bids[targetingKey][0]); + }); + return filteredBids; +} + +/** + * This function returns bids for adpod adunits + * @param {Array[Object]} bidsReceived + * @param {Array[Object]} adPodAdUnits + * @returns {Array[Object]} bids of mediaType adpod + */ +function getBidsForAdpod(bidsReceived, adPodAdUnits) { + let adUnitCodes = adPodAdUnits.map((adUnit) => adUnit.code); + return bidsReceived + .filter((bid) => adUnitCodes.indexOf(bid.adUnitCode) != -1 && (bid.video && bid.video.context === ADPOD)) +} + +const sharedMethods = { + TARGETING_KEY_PB_CAT_DUR: TARGETING_KEY_PB_CAT_DUR, + TARGETING_KEY_CACHE_ID: TARGETING_KEY_CACHE_ID, + 'getTargeting': getTargeting +} +Object.freeze(sharedMethods); + +module('adpod', function shareAdpodUtilities(...args) { + if (!utils.isPlainObject(args[0])) { + utils.logError('Adpod module needs plain object to share methods with submodule'); + return; + } + function addMethods(object, func) { + for (let name in func) { + object[name] = func[name]; + } + } + addMethods(args[0], sharedMethods); +}); diff --git a/modules/adponeBidAdapter.js b/modules/adponeBidAdapter.js index cd30f663b16..2d27c9c4240 100644 --- a/modules/adponeBidAdapter.js +++ b/modules/adponeBidAdapter.js @@ -59,6 +59,13 @@ export const spec = { }); return answer; + }, + + onBidWon: bid => { + const bidString = JSON.stringify(bid); + const encodedBuf = window.btoa(bidString); + const img = new Image(1, 1); + img.src = `https://rtb.adpone.com/prebid/analytics?q=${encodedBuf}`; } }; diff --git a/modules/advangelistsBidAdapter.js b/modules/advangelistsBidAdapter.js old mode 100755 new mode 100644 diff --git a/modules/advangelistsBidAdapter.md b/modules/advangelistsBidAdapter.md old mode 100755 new mode 100644 diff --git a/modules/advenueBidAdapter.js b/modules/advenueBidAdapter.js index 3e7711cca0d..6dc5856eacb 100644 --- a/modules/advenueBidAdapter.js +++ b/modules/advenueBidAdapter.js @@ -1,6 +1,6 @@ -import { registerBidder } from 'src/adapters/bidderFactory'; -import { BANNER, NATIVE, VIDEO } from 'src/mediaTypes'; -import * as utils from 'src/utils'; +import { registerBidder } from '../src/adapters/bidderFactory'; +import { BANNER, NATIVE, VIDEO } from '../src/mediaTypes'; +import * as utils from '../src/utils'; const BIDDER_CODE = 'advenue'; const URL_MULTI = '//ssp.advenuemedia.co.uk/?c=o&m=multi'; diff --git a/modules/adxcgBidAdapter.js b/modules/adxcgBidAdapter.js index 23808fa3be7..34b5ea25fb0 100644 --- a/modules/adxcgBidAdapter.js +++ b/modules/adxcgBidAdapter.js @@ -11,6 +11,7 @@ import includes from 'core-js/library/fn/array/includes' * updated for gdpr compliance on 2018.05.22 -requires gdpr compliance module * updated to pass aditional auction and impression level parameters. added pass for video targeting parameters * updated to fix native support for image width/height and icon 2019.03.17 + * updated support for userid - pubcid,ttid 2019.05.28 */ const BIDDER_CODE = 'adxcg' @@ -159,6 +160,14 @@ export const spec = { beaconParams.prebidBidIds = prebidBidIds.join(',') beaconParams.bidfloors = bidfloors.join(',') + if (utils.isStr(utils.deepAccess(validBidRequests, '0.userId.pubcid'))) { + beaconParams.pubcid = validBidRequests[0].userId.pubcid; + } + + if (utils.isStr(utils.deepAccess(validBidRequests, '0.userId.tdid'))) { + beaconParams.tdid = validBidRequests[0].userId.tdid; + } + let adxcgRequestUrl = url.format({ protocol: secure ? 'https' : 'http', hostname: secure ? 'hbps.adxcg.net' : 'hbp.adxcg.net', diff --git a/modules/adxpremiumAnalyticsAdapter.js b/modules/adxpremiumAnalyticsAdapter.js new file mode 100644 index 00000000000..2224759dc6a --- /dev/null +++ b/modules/adxpremiumAnalyticsAdapter.js @@ -0,0 +1,160 @@ +import { ajax } from '../src/ajax'; +import adapter from '../src/AnalyticsAdapter'; +import adapterManager from '../src/adapterManager'; +import CONSTANTS from '../src/constants.json'; +import * as utils from '../src/utils'; + +const analyticsType = 'endpoint'; +const url = 'https://adxpremium.services/graphql'; + +// Events needed +const { + EVENTS: { + AUCTION_INIT, + BID_REQUESTED, + BID_TIMEOUT, + BID_RESPONSE, + BID_WON, + AUCTION_END + } +} = CONSTANTS; + +// Memory objects +let completeObject = { + publisher_id: null, + auction_id: null, + referer: null, + screen_resolution: window.screen.width + 'x' + window.screen.height, + device_type: null, + geo: null, + events: [] +}; + +let adxpremiumAnalyticsAdapter = Object.assign(adapter({ url, analyticsType }), { + track({ eventType, args }) { + switch (eventType) { + case AUCTION_INIT: + auctionInit(args); + break; + case BID_REQUESTED: + bidRequested(args); + break; + case BID_RESPONSE: + bidResponse(args); + break; + case BID_WON: + bidWon(args); + break; + case BID_TIMEOUT: + bidTimeout(args); + break; + case AUCTION_END: + setTimeout(function () { sendEvent(completeObject) }, 3100); + break; + default: + break; + } + } +}); + +// DFP support +let googletag = window.googletag || {}; +googletag.cmd = googletag.cmd || []; +googletag.cmd.push(function() { + googletag.pubads().addEventListener('slotRenderEnded', args => { + console.log(Date.now() + ' GOOGLE SLOT: ' + JSON.stringify(args)); + }); +}); + +// Event handlers +let bidResponsesMapper = {}; + +function auctionInit(args) { + completeObject.auction_id = args.auctionId; + completeObject.publisher_id = adxpremiumAnalyticsAdapter.initOptions.pubId; + try { completeObject.referer = args.bidderRequests[0].refererInfo.referer.split('?')[0]; } catch (e) { console.log(e.message); } + completeObject.device_type = deviceType(); +} +function bidRequested(args) { + let tmpObject = { + type: 'REQUEST', + bidder_code: args.bidderCode, + event_timestamp: args.start, + bid_gpt_codes: {} + }; + + args.bids.forEach(bid => { + tmpObject.bid_gpt_codes[bid.adUnitCode] = bid.sizes; + }); + + completeObject.events.push(tmpObject); +} + +function bidResponse(args) { + let tmpObject = { + type: 'RESPONSE', + bidder_code: args.bidderCode, + event_timestamp: args.responseTimestamp, + size: args.size, + gpt_code: args.adUnitCode, + currency: args.currency, + creative_id: args.creativeId, + time_to_respond: args.timeToRespond, + cpm: args.cpm, + is_winning: false + }; + + bidResponsesMapper[args.requestId] = completeObject.events.push(tmpObject) - 1; +} + +function bidWon(args) { + let eventIndex = bidResponsesMapper[args.requestId]; + completeObject.events[eventIndex].is_winning = true; +} + +function bidTimeout(args) { /* TODO: implement timeout */ } + +// Methods +function deviceType() { + if ((/ipad|android 3.0|xoom|sch-i800|playbook|tablet|kindle/i.test(navigator.userAgent.toLowerCase()))) { + return 'tablet'; + } + if ((/iphone|ipod|android|blackberry|opera|mini|windows\sce|palm|smartphone|iemobile/i.test(navigator.userAgent.toLowerCase()))) { + return 'mobile'; + } + return 'desktop'; +} + +function sendEvent(completeObject) { + try { + let responseEvents = btoa(JSON.stringify(completeObject)); + let mutation = `mutation {createEvent(input: {event: {eventData: "${responseEvents}"}}) {event {createTime } } }`; + let dataToSend = JSON.stringify({ query: mutation }); + ajax(url, function () { console.log(Date.now() + ' Sending event to adxpremium server.') }, dataToSend, { + contentType: 'application/json', + method: 'POST' + }); + } catch (err) { console.log(err) } +} + +// save the base class function +adxpremiumAnalyticsAdapter.originEnableAnalytics = adxpremiumAnalyticsAdapter.enableAnalytics; + +// override enableAnalytics so we can get access to the config passed in from the page +adxpremiumAnalyticsAdapter.enableAnalytics = function (config) { + adxpremiumAnalyticsAdapter.initOptions = config.options; + + if (!config.options.pubId) { + utils.logError('Publisher ID (pubId) option is not defined. Analytics won\'t work'); + return; + } + + adxpremiumAnalyticsAdapter.originEnableAnalytics(config); // call the base class function +} + +adapterManager.registerAnalyticsAdapter({ + adapter: adxpremiumAnalyticsAdapter, + code: 'adxpremium' +}); + +export default adxpremiumAnalyticsAdapter; diff --git a/modules/adxpremiumAnalyticsAdapter.md b/modules/adxpremiumAnalyticsAdapter.md new file mode 100644 index 00000000000..b2a5efd653f --- /dev/null +++ b/modules/adxpremiumAnalyticsAdapter.md @@ -0,0 +1,41 @@ +# Overview + +Module Name: AdxPremium Analytics Adapter + +Module Type: Analytics Adapter + +Maintainer: info@luponmedia.com + +--- + +# Description + +Analytics adapter for luponmedia.com prebid platform. Contact [info@luponmedia.com]() if you have any questions about integration. + +--- + +# Integration + +AdxPremium Anaytics Adapter can be used as: + +- Part of the whole AdxPremium Header Bidding Ecosystem *(free)* + +- External Analytics tool for your Prebid script *(Paid)* + +##### AdxPremium Header Bidding Ecosystem + +Integration is as easy as adding the following lines of code: + +```javascript +pbjs.que.push(function () { + pbjs.enableAnalytics([{ + provider: 'adxpremium', + options: { + pubID: 12345678 + } + }); + }]); +}); +``` + +*Note*: To use AdxPremium Prebid Analytics Adapter, you have to be AdxPremium publisher and get the publisher ID as well as include the adapter in your **Prebid Core** script. diff --git a/modules/adyoulikeBidAdapter.js b/modules/adyoulikeBidAdapter.js index 4bca9b58fe5..a3e07b25c35 100644 --- a/modules/adyoulikeBidAdapter.js +++ b/modules/adyoulikeBidAdapter.js @@ -18,7 +18,7 @@ export const spec = { * @return boolean True if this is a valid bid, and false otherwise. */ isBidRequestValid: function (bid) { - const sizes = getSize(bid.sizes); + const sizes = getSize(getSizeArray(bid)); if (!bid.params || !bid.params.placement || !sizes.width || !sizes.height) { return false; } @@ -34,12 +34,14 @@ export const spec = { const payload = { Version: VERSION, Bids: bidRequests.reduce((accumulator, bid) => { - let size = getSize(bid.sizes); + let sizesArray = getSizeArray(bid); + let size = getSize(sizesArray); accumulator[bid.bidId] = {}; accumulator[bid.bidId].PlacementID = bid.params.placement; accumulator[bid.bidId].TransactionID = bid.transactionId; accumulator[bid.bidId].Width = size.width; accumulator[bid.bidId].Height = size.height; + accumulator[bid.bidId].AvailableSizes = sizesArray.join(','); return accumulator; }, {}), PageRefreshed: getPageRefreshed() @@ -132,7 +134,7 @@ function getPageRefreshed() { function createEndpoint(bidRequests, bidderRequest) { let host = getHostname(bidRequests); return format({ - protocol: (document.location.protocol === 'https:') ? 'https' : 'http', + protocol: 'https', host: `${DEFAULT_DC}${host}.omnitagjs.com`, pathname: '/hb-api/prebid/v1', search: createEndpointQS(bidderRequest) @@ -156,10 +158,20 @@ function createEndpointQS(bidderRequest) { return qs; } +function getSizeArray(bid) { + let inputSize = bid.sizes; + if (bid.mediaTypes && bid.mediaTypes.banner) { + inputSize = bid.mediaTypes.banner.sizes; + } + + return utils.parseSizesInput(inputSize); +} + /* Get parsed size from request size */ -function getSize(requestSizes) { +function getSize(sizesArray) { const parsed = {}; - const size = utils.parseSizesInput(requestSizes)[0]; + // the main requested size is the first one + const size = sizesArray[0]; if (typeof size !== 'string') { return parsed; @@ -187,7 +199,6 @@ function createBid(response) { return { requestId: response.BidID, - bidderCode: spec.code, width: response.Width, height: response.Height, ad: response.Ad, diff --git a/modules/ajaBidAdapter.js b/modules/ajaBidAdapter.js index 58008fe864a..be7e1238f64 100644 --- a/modules/ajaBidAdapter.js +++ b/modules/ajaBidAdapter.js @@ -31,6 +31,10 @@ export const spec = { queryString = utils.tryAppendQueryString(queryString, 'prebid_id', bid.bidId); queryString = utils.tryAppendQueryString(queryString, 'prebid_ver', '$prebid.version$'); + if (bidderRequest && bidderRequest.refererInfo) { + queryString = utils.tryAppendQueryString(queryString, 'page_url', bidderRequest.refererInfo.referer); + } + bidRequests.push({ method: 'GET', url: URL, diff --git a/modules/aolBidAdapter.js b/modules/aolBidAdapter.js index 5b8a76db4fc..c065828c10d 100644 --- a/modules/aolBidAdapter.js +++ b/modules/aolBidAdapter.js @@ -29,17 +29,18 @@ const SYNC_TYPES = { } }; -const pubapiTemplate = template`//${'host'}/pubapi/3.0/${'network'}/${'placement'}/${'pageid'}/${'sizeid'}/ADTECH;v=2;cmd=bid;cors=yes;alias=${'alias'};misc=${'misc'};${'dynamicParams'}`; -const nexageBaseApiTemplate = template`//${'host'}/bidRequest?`; +const pubapiTemplate = template`${'host'}/pubapi/3.0/${'network'}/${'placement'}/${'pageid'}/${'sizeid'}/ADTECH;v=2;cmd=bid;cors=yes;alias=${'alias'};misc=${'misc'};${'dynamicParams'}`; +const nexageBaseApiTemplate = template`${'host'}/bidRequest?`; const nexageGetApiTemplate = template`dcn=${'dcn'}&pos=${'pos'}&cmd=bid${'dynamicParams'}`; const MP_SERVER_MAP = { us: 'adserver-us.adtech.advertising.com', eu: 'adserver-eu.adtech.advertising.com', as: 'adserver-as.adtech.advertising.com' }; -const NEXAGE_SERVER = 'hb.nexage.com'; +const NEXAGE_SERVER = 'c2shb.ssp.yahoo.com'; const ONE_DISPLAY_TTL = 60; const ONE_MOBILE_TTL = 3600; +const DEFAULT_PROTO = 'https'; const NUMERIC_VALUES = { TRUE: 1, @@ -198,7 +199,7 @@ export const spec = { // Set region param, used by AOL analytics. params.region = regionParam; - return pubapiTemplate({ + return this.applyProtocol(pubapiTemplate({ host: server, network: params.network, placement: parseInt(params.placement), @@ -207,7 +208,7 @@ export const spec = { alias: params.alias || utils.getUniqueIdentifierStr(), misc: new Date().getTime(), // cache busting dynamicParams: this.formatMarketplaceDynamicParams(params, consentData) - }); + })); }, buildOneMobileGetUrl(bid, consentData) { let {dcn, pos, ext} = bid.params; @@ -219,9 +220,15 @@ export const spec = { return nexageApi; }, buildOneMobileBaseUrl(bid) { - return nexageBaseApiTemplate({ + return this.applyProtocol(nexageBaseApiTemplate({ host: bid.params.host || NEXAGE_SERVER - }); + })); + }, + applyProtocol(url) { + if (/^https?:\/\//i.test(url)) { + return url; + } + return (url.indexOf('//') === 0) ? `${DEFAULT_PROTO}:${url}` : `${DEFAULT_PROTO}://${url}`; }, formatMarketplaceDynamicParams(params = {}, consentData) { let queryParams = {}; diff --git a/modules/appierAnalyticsAdapter.js b/modules/appierAnalyticsAdapter.js new file mode 100644 index 00000000000..76811b598e0 --- /dev/null +++ b/modules/appierAnalyticsAdapter.js @@ -0,0 +1,244 @@ +import {ajax} from '../src/ajax'; +import adapter from '../src/AnalyticsAdapter'; +import CONSTANTS from '../src/constants.json'; +import adapterManager from '../src/adapterManager'; +import {logError, logInfo, deepClone} from '../src/utils'; + +const analyticsType = 'endpoint'; + +export const ANALYTICS_VERSION = '1.0.0'; + +const DEFAULT_SERVER = 'https://prebid-analytics.c.appier.net/v1'; + +const { + EVENTS: { + AUCTION_END, + BID_WON, + BID_TIMEOUT + } +} = CONSTANTS; + +export const BIDDER_STATUS = { + BID: 'bid', + NO_BID: 'noBid', + BID_WON: 'bidWon', + TIMEOUT: 'timeout' +}; + +export const getCpmInUsd = function (bid) { + if (bid.currency === 'USD') { + return bid.cpm; + } else { + return bid.getCpmInNewCurrency('USD'); + } +}; + +const analyticsOptions = {}; + +export const parseBidderCode = function (bid) { + let bidderCode = bid.bidderCode || bid.bidder; + return bidderCode.toLowerCase(); +}; + +export const parseAdUnitCode = function (bidResponse) { + return bidResponse.adUnitCode.toLowerCase(); +}; + +export const appierAnalyticsAdapter = Object.assign(adapter({DEFAULT_SERVER, analyticsType}), { + + cachedAuctions: {}, + + initConfig(config) { + /** + * Required option: affiliateId + * Required option: configId + * + * Optional option: server + * Optional option: sampling + * Optional option: adSampling + * Optional option: autoPick + * Optional option: predictionId + * @type {boolean} + */ + analyticsOptions.options = deepClone(config.options); + if (typeof config.options.affiliateId !== 'string' || config.options.affiliateId.length < 1) { + logError('"options.affiliateId" is required.'); + return false; + } + if (typeof config.options.configId !== 'string' || config.options.configId.length < 1) { + logError('"options.configId" is required.'); + return false; + } + + analyticsOptions.affiliateId = config.options.affiliateId; + analyticsOptions.configId = config.options.configId; + analyticsOptions.server = config.options.server || DEFAULT_SERVER; + + analyticsOptions.sampled = true; + if (typeof config.options.sampling === 'number') { + analyticsOptions.sampled = Math.random() < parseFloat(config.options.sampling); + } + analyticsOptions.adSampled = false; + if (typeof config.options.adSampling === 'number') { + analyticsOptions.adSampled = Math.random() < parseFloat(config.options.adSampling); + } + analyticsOptions.autoPick = config.options.autoPick || null; + analyticsOptions.predictionId = config.options.predictionId || null; + + return true; + }, + sendEventMessage(endPoint, data) { + logInfo(`AJAX: ${endPoint}: ` + JSON.stringify(data)); + + ajax(`${analyticsOptions.server}/${endPoint}`, null, JSON.stringify(data), { + contentType: 'application/json', + withCredentials: true + }); + }, + createCommonMessage(auctionId) { + return { + version: ANALYTICS_VERSION, + auctionId: auctionId, + affiliateId: analyticsOptions.affiliateId, + configId: analyticsOptions.configId, + referrer: window.location.href, + sampling: analyticsOptions.options.sampling, + adSampling: analyticsOptions.options.adSampling, + prebid: '$prebid.version$', + autoPick: analyticsOptions.autoPick, + predictionId: analyticsOptions.predictionId, + adUnits: {}, + }; + }, + serializeBidResponse(bid, status) { + const result = { + prebidWon: (status === BIDDER_STATUS.BID_WON), + isTimeout: (status === BIDDER_STATUS.TIMEOUT), + status: status, + }; + if (status === BIDDER_STATUS.BID || status === BIDDER_STATUS.BID_WON) { + Object.assign(result, { + time: bid.timeToRespond, + cpm: bid.cpm, + currency: bid.currency, + originalCpm: bid.originalCpm || bid.cpm, + cpmUsd: getCpmInUsd(bid), + originalCurrency: bid.originalCurrency || bid.currency, + }); + } + return result; + }, + addBidResponseToMessage(message, bid, status) { + const adUnitCode = parseAdUnitCode(bid); + message.adUnits[adUnitCode] = message.adUnits[adUnitCode] || {}; + const bidder = parseBidderCode(bid); + const bidResponse = this.serializeBidResponse(bid, status); + message.adUnits[adUnitCode][bidder] = bidResponse; + }, + createBidMessage(auctionEndArgs, winningBids, timeoutBids) { + const {auctionId, timestamp, timeout, auctionEnd, adUnitCodes, bidsReceived, noBids} = auctionEndArgs; + const message = this.createCommonMessage(auctionId); + + message.auctionElapsed = (auctionEnd - timestamp); + message.timeout = timeout; + + adUnitCodes.forEach((adUnitCode) => { + message.adUnits[adUnitCode] = {}; + }); + + // We handled noBids first because when currency conversion is enabled, a bid with a foreign currency + // will be set to NO_BID initially, and then set to BID after the currency rate json file is fully loaded. + // In this situation, the bid exists in both noBids and bids arrays. + noBids.forEach(bid => this.addBidResponseToMessage(message, bid, BIDDER_STATUS.NO_BID)); + + // This array may contain some timeout bids (responses come back after auction timeout) + bidsReceived.forEach(bid => this.addBidResponseToMessage(message, bid, BIDDER_STATUS.BID)); + + // We handle timeout after bids since it's possible that a bid has a response, but the response comes back + // after auction end. In this case, the bid exists in both bidsReceived and timeoutBids arrays. + timeoutBids.forEach(bid => this.addBidResponseToMessage(message, bid, BIDDER_STATUS.TIMEOUT)); + + // mark the winning bids with prebidWon = true + winningBids.forEach(bid => { + const adUnitCode = parseAdUnitCode(bid); + const bidder = parseBidderCode(bid); + message.adUnits[adUnitCode][bidder].prebidWon = true; + }); + return message; + }, + createImpressionMessage(bid) { + const message = this.createCommonMessage(bid.auctionId); + this.addBidResponseToMessage(message, bid, BIDDER_STATUS.BID_WON); + return message; + }, + createCreativeMessage(auctionId, bids) { + const message = this.createCommonMessage(auctionId); + bids.forEach((bid) => { + const adUnitCode = parseAdUnitCode(bid); + const bidder = parseBidderCode(bid); + message.adUnits[adUnitCode] = message.adUnits[adUnitCode] || {}; + message.adUnits[adUnitCode][bidder] = {ad: bid.ad}; + }); + return message; + }, + getCachedAuction(auctionId) { + this.cachedAuctions[auctionId] = this.cachedAuctions[auctionId] || { + timeoutBids: [], + }; + return this.cachedAuctions[auctionId]; + }, + handleAuctionEnd(auctionEndArgs) { + const cachedAuction = this.getCachedAuction(auctionEndArgs.auctionId); + const highestCpmBids = pbjs.getHighestCpmBids(); + this.sendEventMessage('bid', + this.createBidMessage(auctionEndArgs, highestCpmBids, cachedAuction.timeoutBids) + ); + if (analyticsOptions.adSampled) { + this.sendEventMessage('cr', + this.createCreativeMessage(auctionEndArgs.auctionId, auctionEndArgs.bidsReceived) + ); + } + }, + handleBidTimeout(timeoutBids) { + timeoutBids.forEach((bid) => { + const cachedAuction = this.getCachedAuction(bid.auctionId); + cachedAuction.timeoutBids.push(bid); + }); + }, + handleBidWon(bidWonArgs) { + this.sendEventMessage('imp', this.createImpressionMessage(bidWonArgs)); + }, + track({eventType, args}) { + if (analyticsOptions.sampled) { + switch (eventType) { + case BID_WON: + this.handleBidWon(args); + break; + case BID_TIMEOUT: + this.handleBidTimeout(args); + break; + case AUCTION_END: + this.handleAuctionEnd(args); + break; + } + } + }, + getAnalyticsOptions() { + return analyticsOptions; + }, +}); + +// save the base class function +appierAnalyticsAdapter.originEnableAnalytics = appierAnalyticsAdapter.enableAnalytics; + +// override enableAnalytics so we can get access to the config passed in from the page +appierAnalyticsAdapter.enableAnalytics = function (config) { + if (this.initConfig(config)) { + appierAnalyticsAdapter.originEnableAnalytics(config); // call the base class function + } +}; + +adapterManager.registerAnalyticsAdapter({ + adapter: appierAnalyticsAdapter, + code: 'appierAnalytics' +}); diff --git a/modules/appierAnalyticsAdapter.md b/modules/appierAnalyticsAdapter.md new file mode 100644 index 00000000000..09f0676d054 --- /dev/null +++ b/modules/appierAnalyticsAdapter.md @@ -0,0 +1,23 @@ +# Overview + +Module Name: Appier Analytics Adapter +Module Type: Analytics Adapter +Maintainer: apn-dev@appier.com + +# Description + +Analytics adapter for Appier + +# Test Parameters + +``` +{ + provider: 'appierAnalytics', + options: { + 'configId': 'YOUR_CONFIG_ID', + 'affiliateId': 'YOUR_AFFILIATE_ID', + } +} +``` + +PS. [Prebid currency module](http://prebid.org/dev-docs/modules/currency.html) is required, please make sure your prebid code contains currency module code. diff --git a/modules/appnexusBidAdapter.js b/modules/appnexusBidAdapter.js index 0f295dadef1..5b682f747e2 100644 --- a/modules/appnexusBidAdapter.js +++ b/modules/appnexusBidAdapter.js @@ -3,14 +3,16 @@ import * as utils from '../src/utils'; import { config } from '../src/config'; import { registerBidder, getIabSubCategory } from '../src/adapters/bidderFactory'; import { BANNER, NATIVE, VIDEO, ADPOD } from '../src/mediaTypes'; +import { auctionManager } from '../src/auctionManager'; import find from 'core-js/library/fn/array/find'; import includes from 'core-js/library/fn/array/includes'; +import { OUTSTREAM, INSTREAM } from '../src/video'; const BIDDER_CODE = 'appnexus'; const URL = '//ib.adnxs.com/ut/v3/prebid'; const VIDEO_TARGETING = ['id', 'mimes', 'minduration', 'maxduration', 'startdelay', 'skippable', 'playback_method', 'frameworks']; -const USER_PARAMS = ['age', 'external_uid', 'segments', 'gender', 'dnt', 'language']; +const USER_PARAMS = ['age', 'externalUid', 'segments', 'gender', 'dnt', 'language']; const APP_DEVICE_PARAMS = ['geo', 'device_id']; // appid is collected separately const DEBUG_PARAMS = ['enabled', 'dongle', 'member_id', 'debug_timeout']; const NATIVE_MAPPING = { @@ -19,13 +21,11 @@ const NATIVE_MAPPING = { cta: 'ctatext', image: { serverName: 'main_image', - requiredParams: { required: true }, - minimumParams: { sizes: [{}] }, + requiredParams: { required: true } }, icon: { serverName: 'icon', - requiredParams: { required: true }, - minimumParams: { sizes: [{}] }, + requiredParams: { required: true } }, sponsoredBy: 'sponsored_by', privacyLink: 'privacy_link', @@ -35,6 +35,9 @@ const NATIVE_MAPPING = { const SOURCE = 'pbjs'; const MAX_IMPS_PER_REQUEST = 15; const mappingFileUrl = '//acdn.adnxs.com/prebid/appnexus-mapping/mappings.json'; +const SCRIPT_TAG_START = '= 1; + + let regexMatchFileName = str.match(VIEWABILITY_FILE_NAME); + let fileNameInStr = regexMatchFileName != null && regexMatchFileName.length >= 1; + + return str.startsWith(SCRIPT_TAG_START) && fileNameInStr && viewUrlStartInStr; +} + +function getAppnexusViewabilityScriptFromJsTrackers(jsTrackerArray) { + let viewJsPayload; + if (utils.isStr(jsTrackerArray) && strIsAppnexusViewabilityScript(jsTrackerArray)) { + viewJsPayload = jsTrackerArray; + } else if (utils.isArray(jsTrackerArray)) { + for (let i = 0; i < jsTrackerArray.length; i++) { + let currentJsTracker = jsTrackerArray[i]; + if (strIsAppnexusViewabilityScript(currentJsTracker)) { + viewJsPayload = currentJsTracker; + } + } + } + return viewJsPayload; +} + +function getViewabilityScriptUrlFromPayload(viewJsPayload) { + // extracting the content of the src attribute + // -> substring between src=" and " + let indexOfFirstQuote = viewJsPayload.indexOf('src="') + 5; // offset of 5: the length of 'src=' + 1 + let indexOfSecondQuote = viewJsPayload.indexOf('"', indexOfFirstQuote); + let jsTrackerSrc = viewJsPayload.substring(indexOfFirstQuote, indexOfSecondQuote); + return jsTrackerSrc; +} + function formatRequest(payload, bidderRequest) { let request = []; @@ -368,44 +476,64 @@ function newBid(serverBid, rtbBid, bidderRequest) { } }; + if (rtbBid.advertiser_id) { + bid.meta = Object.assign({}, bid.meta, { advertiserId: rtbBid.advertiser_id }); + } + if (rtbBid.rtb.video) { + // shared video properties used for all 3 contexts Object.assign(bid, { width: rtbBid.rtb.video.player_width, height: rtbBid.rtb.video.player_height, - vastUrl: rtbBid.rtb.video.asset_url, vastImpUrl: rtbBid.notify_url, ttl: 3600 }); const videoContext = utils.deepAccess(bidRequest, 'mediaTypes.video.context'); - if (videoContext === ADPOD) { - const iabSubCatId = getIabSubCategory(bidRequest.bidder, rtbBid.brand_category_id); - bid.meta = { - iabSubCatId - }; - - bid.video = { - context: ADPOD, - durationSeconds: Math.floor(rtbBid.rtb.video.duration_ms / 1000), - }; + switch (videoContext) { + case ADPOD: + const iabSubCatId = getIabSubCategory(bidRequest.bidder, rtbBid.brand_category_id); + bid.meta = Object.assign({}, bid.meta, { iabSubCatId }); + bid.video = { + context: ADPOD, + durationSeconds: Math.floor(rtbBid.rtb.video.duration_ms / 1000), + }; + bid.vastUrl = rtbBid.rtb.video.asset_url; + break; + case OUTSTREAM: + bid.adResponse = serverBid; + bid.adResponse.ad = bid.adResponse.ads[0]; + bid.adResponse.ad.video = bid.adResponse.ad.rtb.video; + bid.vastXml = rtbBid.rtb.video.content; + + if (rtbBid.renderer_url) { + const videoBid = find(bidderRequest.bids, bid => bid.bidId === serverBid.uuid); + const rendererOptions = utils.deepAccess(videoBid, 'renderer.options'); + bid.renderer = newRenderer(bid.adUnitCode, rtbBid, rendererOptions); + } + break; + case INSTREAM: + bid.vastUrl = rtbBid.rtb.video.asset_url; + break; } + } else if (rtbBid.rtb[NATIVE]) { + const nativeAd = rtbBid.rtb[NATIVE]; - // This supports Outstream Video - if (rtbBid.renderer_url) { - const rendererOptions = utils.deepAccess( - bidderRequest.bids[0], - 'renderer.options' - ); + // setting up the jsTracker: + // we put it as a data-src attribute so that the tracker isn't called + // until we have the adId (see onBidWon) + let jsTrackerDisarmed = rtbBid.viewability.config.replace('src=', 'data-src='); - Object.assign(bid, { - adResponse: serverBid, - renderer: newRenderer(bid.adUnitCode, rtbBid, rendererOptions) - }); - bid.adResponse.ad = bid.adResponse.ads[0]; - bid.adResponse.ad.video = bid.adResponse.ad.rtb.video; + let jsTrackers = nativeAd.javascript_trackers; + + if (jsTrackers == undefined) { + jsTrackers = jsTrackerDisarmed; + } else if (utils.isStr(jsTrackers)) { + jsTrackers = [jsTrackers, jsTrackerDisarmed]; + } else { + jsTrackers.push(jsTrackerDisarmed); } - } else if (rtbBid.rtb[NATIVE]) { - const nativeAd = rtbBid.rtb[NATIVE]; + bid[NATIVE] = { title: nativeAd.title, body: nativeAd.desc, @@ -424,7 +552,7 @@ function newBid(serverBid, rtbBid, bidderRequest) { displayUrl: nativeAd.displayurl, clickTrackers: nativeAd.link.click_trackers, impressionTrackers: nativeAd.impression_trackers, - javascriptTrackers: nativeAd.javascript_trackers + javascriptTrackers: jsTrackers }; if (nativeAd.main_img) { bid['native'].image = { @@ -538,13 +666,19 @@ function bidToTag(bid) { .forEach(param => tag.video[param] = bid.params.video[param]); } - if ( - (utils.isEmpty(bid.mediaType) && utils.isEmpty(bid.mediaTypes)) || - (bid.mediaType === BANNER || (bid.mediaTypes && bid.mediaTypes[BANNER])) - ) { + if (bid.renderer) { + tag.video = Object.assign({}, tag.video, {custom_renderer_present: true}); + } + + let adUnit = find(auctionManager.getAdUnits(), au => bid.transactionId === au.transactionId); + if (adUnit && adUnit.mediaTypes && adUnit.mediaTypes.banner) { tag.ad_types.push(BANNER); } + if (tag.ad_types.length === 0) { + delete tag.ad_types; + } + return tag; } @@ -675,20 +809,18 @@ function buildNativeRequest(params) { const requiredParams = NATIVE_MAPPING[key] && NATIVE_MAPPING[key].requiredParams; request[requestKey] = Object.assign({}, requiredParams, params[key]); - // minimum params are passed if no non-required params given on adunit - const minimumParams = NATIVE_MAPPING[key] && NATIVE_MAPPING[key].minimumParams; - - if (requiredParams && minimumParams) { - // subtract required keys from adunit keys - const adunitKeys = Object.keys(params[key]); - const requiredKeys = Object.keys(requiredParams); - const remaining = adunitKeys.filter(key => !includes(requiredKeys, key)); - - // if none are left over, the minimum params needs to be sent - if (remaining.length === 0) { - request[requestKey] = Object.assign({}, request[requestKey], minimumParams); + // convert the sizes of image/icon assets to proper format (if needed) + const isImageAsset = !!(requestKey === NATIVE_MAPPING.image.serverName || requestKey === NATIVE_MAPPING.icon.serverName); + if (isImageAsset && request[requestKey].sizes) { + let sizes = request[requestKey].sizes; + if (utils.isArrayOfNums(sizes) || (utils.isArray(sizes) && sizes.length > 0 && sizes.every(sz => utils.isArrayOfNums(sz)))) { + request[requestKey].sizes = transformSizes(request[requestKey].sizes); } } + + if (requestKey === NATIVE_MAPPING.privacyLink) { + request.privacy_supported = true; + } }); return request; diff --git a/modules/arteebeeBidAdapter.js b/modules/arteebeeBidAdapter.js index ddf728a143e..74d5d5d3d52 100644 --- a/modules/arteebeeBidAdapter.js +++ b/modules/arteebeeBidAdapter.js @@ -96,7 +96,7 @@ function makeRtbRequest(req, bidderRequest) { 'tmax': config.getConfig('bidderTimeout') }; - if (req.params.coppa) { + if (config.getConfig('coppa') === true || req.params.coppa) { rtbReq.regs = {coppa: 1}; } diff --git a/modules/beachfrontBidAdapter.js b/modules/beachfrontBidAdapter.js index 552413f4878..0143f01835d 100644 --- a/modules/beachfrontBidAdapter.js +++ b/modules/beachfrontBidAdapter.js @@ -7,15 +7,15 @@ import { VIDEO, BANNER } from '../src/mediaTypes'; import find from 'core-js/library/fn/array/find'; import includes from 'core-js/library/fn/array/includes'; -const ADAPTER_VERSION = '1.4'; +const ADAPTER_VERSION = '1.7'; const ADAPTER_NAME = 'BFIO_PREBID'; const OUTSTREAM = 'outstream'; -export const VIDEO_ENDPOINT = '//reachms.bfmio.com/bid.json?exchange_id='; -export const BANNER_ENDPOINT = '//display.bfmio.com/prebid_display'; +export const VIDEO_ENDPOINT = 'https://reachms.bfmio.com/bid.json?exchange_id='; +export const BANNER_ENDPOINT = 'https://display.bfmio.com/prebid_display'; export const OUTSTREAM_SRC = '//player-cdn.beachfrontmedia.com/playerapi/loader/outstream.js'; -export const VIDEO_TARGETING = ['mimes', 'playbackmethod', 'maxduration']; +export const VIDEO_TARGETING = ['mimes', 'playbackmethod', 'maxduration', 'placement']; export const DEFAULT_MIMES = ['video/mp4', 'application/javascript']; let appId = ''; @@ -123,12 +123,12 @@ export const spec = { } else if (syncOptions.iframeEnabled) { syncs.push({ type: 'iframe', - url: `//sync.bfmio.com/sync_iframe?ifg=1&id=${appId}&gdpr=${gdprApplies ? 1 : 0}&gc=${consentString || ''}&gce=1` + url: `https://sync.bfmio.com/sync_iframe?ifg=1&id=${appId}&gdpr=${gdprApplies ? 1 : 0}&gc=${consentString || ''}&gce=1` }); } else if (syncOptions.pixelEnabled) { syncs.push({ type: 'image', - url: `//sync.bfmio.com/syncb?pid=144&id=${appId}&gdpr=${gdprApplies ? 1 : 0}&gc=${consentString || ''}&gce=1` + url: `https://sync.bfmio.com/syncb?pid=144&id=${appId}&gdpr=${gdprApplies ? 1 : 0}&gc=${consentString || ''}&gce=1` }); } @@ -143,21 +143,20 @@ function createRenderer(bidRequest) { loaded: false }); - renderer.setRender(outstreamRender); - - return renderer; -} - -function outstreamRender(bid) { - bid.renderer.push(() => { - window.Beachfront.Player(bid.adUnitCode, { - ad_tag_url: bid.vastUrl, - width: bid.width, - height: bid.height, - expand_in_view: false, - collapse_on_complete: true + renderer.setRender(bid => { + bid.renderer.push(() => { + window.Beachfront.Player(bid.adUnitCode, { + adTagUrl: bid.vastUrl, + width: bid.width, + height: bid.height, + expandInView: getPlayerBidParam(bidRequest, 'expandInView', false), + collapseOnComplete: getPlayerBidParam(bidRequest, 'collapseOnComplete', true), + progressColor: getPlayerBidParam(bidRequest, 'progressColor') + }); }); }); + + return renderer; } function getFirstSize(sizes) { @@ -231,6 +230,11 @@ function getBannerBidParam(bid, key) { return utils.deepAccess(bid, 'params.banner.' + key) || utils.deepAccess(bid, 'params.' + key); } +function getPlayerBidParam(bid, key, defaultValue) { + let param = utils.deepAccess(bid, 'params.player.' + key); + return param === undefined ? defaultValue : param; +} + function isVideoBidValid(bid) { return isVideoBid(bid) && getVideoBidParam(bid, 'appId') && getVideoBidParam(bid, 'bidfloor'); } diff --git a/modules/beachfrontBidAdapter.md b/modules/beachfrontBidAdapter.md index fb14db59710..3f827fe9241 100644 --- a/modules/beachfrontBidAdapter.md +++ b/modules/beachfrontBidAdapter.md @@ -86,3 +86,35 @@ Module that connects to Beachfront's demand sources } ]; ``` + +# Outstream Player Params Example +```javascript + var adUnits = [ + { + code: 'test-video-outstream', + mediaTypes: { + video: { + context: 'outstream', + playerSize: [ 640, 360 ] + } + }, + bids: [ + { + bidder: 'beachfront', + params: { + video: { + bidfloor: 0.01, + appId: '11bc5dd5-7421-4dd8-c926-40fa653bec76', + mimes: [ 'video/mp4', 'application/javascript' ] + }, + player: { + progressColor: '#50A8FA', + expandInView: false, + collapseOnComplete: true + } + } + } + ] + } + ]; +``` diff --git a/modules/betweenBidAdapter.js b/modules/betweenBidAdapter.js index d93c4433980..9da6b4dbe29 100644 --- a/modules/betweenBidAdapter.js +++ b/modules/betweenBidAdapter.js @@ -112,7 +112,7 @@ export const spec = { // }); syncs.push({ type: 'iframe', - url: 'http://ads.betweendigital.com/sspmatch-iframe' + url: '//ads.betweendigital.com/sspmatch-iframe' }); return syncs; } diff --git a/modules/bidglassBidAdapter.js b/modules/bidglassBidAdapter.js new file mode 100644 index 00000000000..f5991f7f3a5 --- /dev/null +++ b/modules/bidglassBidAdapter.js @@ -0,0 +1,134 @@ +import * as utils from '../src/utils'; +// import {config} from 'src/config'; +import {registerBidder} from '../src/adapters/bidderFactory'; + +const BIDDER_CODE = 'bidglass'; + +export const spec = { + code: BIDDER_CODE, + aliases: ['bg'], // short code + /** + * Determines whether or not the given bid request is valid. + * + * @param {BidRequest} bid The bid params to validate. + * @return boolean True if this is a valid bid, and false otherwise. + */ + isBidRequestValid: function(bid) { + return !!(bid.params.adUnitId && !isNaN(parseFloat(bid.params.adUnitId)) && isFinite(bid.params.adUnitId)); + }, + /** + * Make a server request from the list of BidRequests. + * + * @param {validBidRequests[]} - an array of bids + * @return ServerRequest Info describing the request to the server. + */ + buildRequests: function(validBidRequests, bidderRequest) { + /* + Sample array entry for validBidRequests[]: + [{ + "bidder": "bidglass", + "bidId": "51ef8751f9aead", + "params": { + "adUnitId": 11, + ... + }, + "adUnitCode": "div-gpt-ad-1460505748561-0", + "transactionId": "d7b773de-ceaa-484d-89ca-d9f51b8d61ec", + "sizes": [[320,50],[300,250],[300,600]], + "bidderRequestId": "418b37f85e772c", + "auctionId": "18fd8b8b0bd757", + "bidRequestsCount": 1 + }] + */ + + let imps = []; + let getReferer = function() { + return window === window.top ? window.location.href : window.parent === window.top ? document.referrer : null; + }; + let getOrigins = function() { + var ori = [window.location.protocol + '//' + window.location.hostname]; + + if (window.location.ancestorOrigins) { + for (var i = 0; i < window.location.ancestorOrigins.length; i++) { + ori.push(window.location.ancestorOrigins[i]); + } + } else if (window !== window.top) { + // Derive the parent origin + var parts = document.referrer.split('/'); + + ori.push(parts[0] + '//' + parts[2]); + + if (window.parent !== window.top) { + // Additional unknown origins exist + ori.push('null'); + } + } + + return ori; + }; + + utils._each(validBidRequests, function(bid) { + bid.sizes = ((utils.isArray(bid.sizes) && utils.isArray(bid.sizes[0])) ? bid.sizes : [bid.sizes]); + bid.sizes = bid.sizes.filter(size => utils.isArray(size)); + + // Stuff to send: [bid id, sizes, adUnitId] + imps.push({ + bidId: bid.bidId, + sizes: bid.sizes, + adUnitId: utils.getBidIdParameter('adUnitId', bid.params) + }); + }); + + // Stuff to send: page URL + const bidReq = { + reqId: utils.getUniqueIdentifierStr(), + imps: imps, + ref: getReferer(), + ori: getOrigins() + }; + + let url = 'https://bid.glass/ad/hb.php?' + + `src=$$REPO_AND_VERSION$$`; + + return { + method: 'POST', + url: url, + data: JSON.stringify(bidReq), + options: { + contentType: 'text/plain', + withCredentials: false + } + } + }, + + /** + * Unpack the response from the server into a list of bids. + * + * @param {ServerResponse} serverResponse A successful response from the server. + * @return {Bid[]} An array of bids which were nested inside the server. + */ + interpretResponse: function(serverResponse) { + const bidResponses = []; + + utils._each(serverResponse.body.bidResponses, function(bid) { + bidResponses.push({ + requestId: bid.requestId, + cpm: parseFloat(bid.cpm), + width: parseInt(bid.width, 10), + height: parseInt(bid.height, 10), + creativeId: bid.creativeId, + dealId: bid.dealId || null, + currency: bid.currency || 'USD', + mediaType: bid.mediaType || 'banner', + netRevenue: true, + ttl: bid.ttl || 10, + ad: bid.ad + }); + }); + + return bidResponses; + } + +} + +registerBidder(spec); diff --git a/modules/bidglassBidAdapter.md b/modules/bidglassBidAdapter.md new file mode 100644 index 00000000000..5384a095314 --- /dev/null +++ b/modules/bidglassBidAdapter.md @@ -0,0 +1,34 @@ +# Overview + +``` +Module Name: Bid Glass Bid Adapter +Module Type: Bidder Adapter +Maintainer: dliebner@gmail.com +``` + +# Description + +Connects to Bid Glass and allows bids on ad units to compete within prebid. + +# Sample Ad Unit: For Publishers +``` +var adUnits = [{ + code: 'bg-test-rectangle', + sizes: [[300, 250]], + bids: [{ + bidder: 'bidglass', + params: { + adUnitId: '-1' + } + }] +},{ + code: 'bg-test-leaderboard', + sizes: [[728, 90]], + bids: [{ + bidder: 'bidglass', + params: { + adUnitId: '-1' + } + }] +}] +``` \ No newline at end of file diff --git a/modules/bidphysicsBidAdapter.js b/modules/bidphysicsBidAdapter.js index 260a473c631..cbd76c8bc10 100644 --- a/modules/bidphysicsBidAdapter.js +++ b/modules/bidphysicsBidAdapter.js @@ -1,4 +1,4 @@ -import {registerBidder} from 'src/adapters/bidderFactory'; +import {registerBidder} from '../src/adapters/bidderFactory'; import * as utils from '../src/utils'; import {BANNER} from '../src/mediaTypes'; @@ -10,7 +10,7 @@ const DEFAULT_NET_REVENUE = true; export const spec = { code: 'bidphysics', - aliases: ['yieldlift', 'padsquad'], + aliases: ['yieldlift'], supportedMediaTypes: [BANNER], isBidRequestValid: function (bid) { diff --git a/modules/bucksenseBidAdapter.js b/modules/bucksenseBidAdapter.js new file mode 100644 index 00000000000..12a9e287f38 --- /dev/null +++ b/modules/bucksenseBidAdapter.js @@ -0,0 +1,124 @@ +import { registerBidder } from '../src/adapters/bidderFactory'; +import { BANNER } from '../src/mediaTypes'; +import * as utils from '../src/utils'; + +const WHO = 'BKSHBID-005'; +const BIDDER_CODE = 'bucksense'; +const URL = 'https://prebid.bksn.se:445/prebidjs/'; + +export const spec = { + code: BIDDER_CODE, + supportedMediaTypes: [BANNER], + + /** + * Determines whether or not the given bid request is valid. + * + * @param {object} bid The bid to validate. + * @return boolean True if this is a valid bid, and false otherwise. + */ + isBidRequestValid: function (bid) { + utils.logInfo(WHO + ' isBidRequestValid() - INPUT bid:', bid); + if (bid.bidder !== BIDDER_CODE || typeof bid.params === 'undefined') { + return false; + } + if (typeof bid.params.placementId === 'undefined') { + return false; + } + return true; + }, + + /** + * Make a server request from the list of BidRequests. + * + * @param {BidRequest[]} validBidRequests A non-empty list of valid bid requests that should be sent to the Server. + * @return ServerRequest Info describing the request to the server. + */ + buildRequests: function (validBidRequests, bidderRequest) { + utils.logInfo(WHO + ' buildRequests() - INPUT validBidRequests:', validBidRequests, 'INPUT bidderRequest:', bidderRequest); + let requests = []; + const len = validBidRequests.length; + for (let i = 0; i < len; i++) { + var bid = validBidRequests[i]; + var params = {}; + for (var key in bid.params) { + if (bid.params.hasOwnProperty(key)) { + params[key] = encodeURI(bid.params[key]); + } + } + delete bid.params; + var sizes = bid.sizes; + delete bid.sizes; + var sendData = { + 'pub_id': location.host, + 'pl_id': '' + params.placementId, + 'secure': (location.protocol === 'https:') ? 1 : 0, + 'href': encodeURI(location.href), + 'bid_id': bid.bidId, + 'params': params, + 'sizes': sizes, + '_bid': bidderRequest + }; + requests.push({ + method: 'POST', + url: URL, + data: sendData + }); + } + utils.logInfo(WHO + ' buildRequests() - requests:', requests); + return requests; + }, + + /** + * Unpack the response from the server into a list of bids. + * + * @param {*} serverResponse A successful response from the server. + * @return {Bid[]} An array of bids which were nested inside the server. + */ + interpretResponse: function (serverResponse, request) { + utils.logInfo(WHO + ' interpretResponse() - INPUT serverResponse:', serverResponse, 'INPUT request:', request); + + const bidResponses = []; + if (serverResponse.body) { + var oResponse = serverResponse.body; + + var sRequestID = oResponse.requestId || ''; + var nCPM = oResponse.cpm || 0; + var nWidth = oResponse.width || 0; + var nHeight = oResponse.height || 0; + var nTTL = oResponse.ttl || 0; + var sCreativeID = oResponse.creativeId || 0; + var sCurrency = oResponse.currency || 'USD'; + var bNetRevenue = oResponse.netRevenue || true; + var sAd = oResponse.ad || ''; + + if (request && sRequestID.length == 0) { + utils.logInfo(WHO + ' interpretResponse() - use RequestID from Placments'); + sRequestID = request.data.bid_id || ''; + } + + if (request && request.data.params.hasOwnProperty('testcpm')) { + utils.logInfo(WHO + ' interpretResponse() - use Test CPM '); + nCPM = request.data.params.testcpm; + } + + let bidResponse = { + requestId: sRequestID, + cpm: nCPM, + width: nWidth, + height: nHeight, + ttl: nTTL, + creativeId: sCreativeID, + currency: sCurrency, + netRevenue: bNetRevenue, + ad: sAd + }; + bidResponses.push(bidResponse); + } else { + utils.logInfo(WHO + ' interpretResponse() - serverResponse not valid'); + } + utils.logInfo(WHO + ' interpretResponse() - return', bidResponses); + return bidResponses; + }, + +}; +registerBidder(spec); diff --git a/modules/bucksenseBidAdapter.md b/modules/bucksenseBidAdapter.md new file mode 100644 index 00000000000..a240a2c31d8 --- /dev/null +++ b/modules/bucksenseBidAdapter.md @@ -0,0 +1,38 @@ +# Overview + +``` +Module Name: Bucksense Bidder Adapter +Module Type: Bidder Adapter +Maintainer: stefano.dechicchis@bucksense.com +``` + +# Description + +Use `bucksense` as bidder. + +`placementId` is required, use the Placement ID received by Bucksense. + + +Module that connects to Example's demand sources + +## AdUnits configuration example +``` + var adUnits = [ + { + code: 'test-div', + mediaTypes: { + banner: { + sizes: [[300, 250]], + } + }, + bids: [ + { + bidder: "bucksense", + params: { + placementId : 1000 + } + } + ] + } + ]; +``` \ No newline at end of file diff --git a/modules/buzzoolaBidAdapter.js b/modules/buzzoolaBidAdapter.js new file mode 100644 index 00000000000..da2a3b30c2e --- /dev/null +++ b/modules/buzzoolaBidAdapter.js @@ -0,0 +1,108 @@ +import * as utils from '../src/utils'; +import {registerBidder} from '../src/adapters/bidderFactory'; +import {BANNER, VIDEO} from '../src/mediaTypes'; +import {Renderer} from '../src/Renderer'; +import {OUTSTREAM} from '../src/video'; + +const BIDDER_CODE = 'buzzoola'; +const ENDPOINT = 'https://exchange.buzzoola.com/ssp/prebidjs'; +const RENDERER_SRC = 'https://tube.buzzoola.com/new/build/buzzlibrary.js'; + +export const spec = { + code: BIDDER_CODE, + aliases: ['buzzoolaAdapter'], + supportedMediaTypes: [BANNER, VIDEO], + + /** + * Determines whether or not the given bid request is valid. + * + * @param {BidRequest} bid The bid params to validate. + * @return {boolean} True if this is a valid bid, and false otherwise. + */ + isBidRequestValid: function (bid) { + let types = bid.mediaTypes; + return !!(bid && bid.mediaTypes && (types.banner || types.video) && bid.params && bid.params.placementId); + }, + + /** + * Make a server request from the list of BidRequests. + * + * @param {BidRequest[]} validBidRequests an array of bids + * @param bidderRequest + * @return ServerRequest Info describing the request to the server. + */ + buildRequests: function (validBidRequests, bidderRequest) { + return { + url: ENDPOINT, + method: 'POST', + data: bidderRequest, + } + }, + + /** + * Unpack the response from the server into a list of bids. + * + * @param {ServerResponse} serverResponse A successful response from the server. + * @param bidderRequest + * @return {Bid[]} An array of bids which were nested inside the server. + */ + interpretResponse: function ({body}, {data}) { + let requestBids = {}; + let response; + + try { + response = JSON.parse(body); + } catch (ex) { + response = body; + } + + if (!Array.isArray(response)) response = []; + + data.bids.forEach(bid => requestBids[bid.bidId] = bid); + + return response.map(bid => { + let requestBid = requestBids[bid.requestId]; + let context = utils.deepAccess(requestBid, 'mediaTypes.video.context'); + let validBid = utils.deepClone(bid); + + if (validBid.mediaType === VIDEO && context === OUTSTREAM) { + let renderer = Renderer.install({ + id: validBid.requestId, + url: RENDERER_SRC, + loaded: false + }); + + renderer.setRender(setOutstreamRenderer); + validBid.renderer = renderer + } + + return validBid; + }); + } +}; + +/** + * Initialize Buzzoola Outstream player + * + * @param bid + */ +function setOutstreamRenderer(bid) { + let adData = JSON.parse(bid.ad); + let unitSettings = utils.deepAccess(adData, 'placement.unit_settings'); + let extendedSettings = { + width: '' + bid.width, + height: '' + bid.height, + container_height: '' + bid.height + }; + + adData.placement = Object.assign({}, adData.placement); + adData.placement.unit_settings = Object.assign({}, unitSettings, extendedSettings); + + bid.renderer.push(() => { + window.Buzzoola.Core.install(document.querySelector(`#${bid.adUnitCode}`), { + data: adData + }); + }); +} + +registerBidder(spec); diff --git a/modules/buzzoolaBidAdapter.md b/modules/buzzoolaBidAdapter.md new file mode 100644 index 00000000000..aec3eda6c58 --- /dev/null +++ b/modules/buzzoolaBidAdapter.md @@ -0,0 +1,72 @@ +# Overview + +``` +Module Name: Buzzoola Bid Adapter +Module Type: Bidder Adapter +Maintainer: devteam@buzzoola.com +``` + +# Description + +Connects to Buzzoola exchange for bids. + +Buzzoola bid adapter supports Banner and Video (instream and outstream). + +# Test Parameters +``` +var adUnits = [ + // Banner adUnit + { + code: 'banner-div', + mediaTypes: { + banner: { + sizes: [[240, 400], [300, 600]], + } + }, + bids: [{ + bidder: 'buzzoola', + params: { + placementId: 417846 + } + }] + }, + // Video instream adUnit + { + code: 'video-instream', + mediaTypes: { + video: { + context: 'instream', + playerSize: [640, 380], + mimes: ['video/mp4'], + minduration: 1, + maxduration: 2, + } + }, + bids: [{ + bidder: 'buzzoola', + params: { + placementId: 417845 + } + }] + }, + // Video outstream adUnit + { + code: 'video-outstream', + mediaTypes: { + video: { + context: 'outstream', + playerSize: [640, 380], + mimes: ['video/mp4'], + minduration: 1, + maxduration: 2, + } + }, + bids: [{ + bidder: 'buzzoola', + params: { + placementId: 417845 + } + }] + } +]; +``` diff --git a/modules/categoryTranslation.js b/modules/categoryTranslation.js index f4d0a281f57..091b16c8211 100644 --- a/modules/categoryTranslation.js +++ b/modules/categoryTranslation.js @@ -26,8 +26,8 @@ export const registerAdserver = hook('async', function(adServer) { let url; if (adServer === 'freewheel') { url = DEFAULT_TRANSLATION_FILE_URL; + initTranslation(url, DEFAULT_IAB_TO_FW_MAPPING_KEY); } - initTranslation(url, DEFAULT_IAB_TO_FW_MAPPING_KEY); }, 'registerAdserver'); registerAdserver(); diff --git a/modules/cedatoBidAdapter.js b/modules/cedatoBidAdapter.js index 8c049410b3a..d81ae858869 100644 --- a/modules/cedatoBidAdapter.js +++ b/modules/cedatoBidAdapter.js @@ -1,6 +1,6 @@ -import * as utils from 'src/utils'; -import { registerBidder } from 'src/adapters/bidderFactory'; -import { BANNER } from 'src/mediaTypes'; +import * as utils from '../src/utils'; +import { registerBidder } from '../src/adapters/bidderFactory'; +import { BANNER, VIDEO } from '../src/mediaTypes'; const BIDDER_CODE = 'cedato'; const BID_URL = '//h.cedatoplayer.com/hb'; @@ -14,7 +14,7 @@ const NET_REVENUE = true; export const spec = { code: BIDDER_CODE, - supportedMediaTypes: [BANNER], + supportedMediaTypes: [BANNER, VIDEO], isBidRequestValid: function(bid) { return !!( @@ -31,19 +31,23 @@ export const spec = { const params = req.params; const at = FIRST_PRICE; const site = { id: params.player_id, domain: document.domain }; - const device = { ua: navigator.userAgent, ip: '' }; + const device = { ua: navigator.userAgent }; const user = { id: getUserID() } const currency = CURRENCY; const tmax = bidderRequest.timeout; const imp = bidRequests.map(req => { - const banner = { 'format': getFormats(utils.deepAccess(req, 'mediaTypes.banner.sizes')) }; + const banner = getMediaType(req, 'banner'); + const video = getMediaType(req, 'video'); const bidfloor = params.bidfloor; const bidId = req.bidId; + const adUnitCode = req.adUnitCode; return { bidId, banner, + video, + adUnitCode, bidfloor, }; }); @@ -68,38 +72,24 @@ export const spec = { return { method: 'POST', - url: BID_URL, + url: params.bid_url || BID_URL, data: JSON.stringify(payload), + bidderRequest }; }, - interpretResponse: function(resp) { - if (resp.body === '') return []; - - const bids = resp.body.seatbid[0].bid.map(bid => { - const cpm = bid.price; - const requestId = bid.uuid; - const width = bid.w; - const height = bid.h; - const creativeId = bid.crid; - const dealId = bid.dealid; - const currency = resp.body.cur; - const netRevenue = NET_REVENUE; - const ttl = TTL; - const ad = bid.adm; + interpretResponse: function(resp, {bidderRequest}) { + resp = resp.body; + const bids = []; - return { - cpm, - requestId, - width, - height, - creativeId, - dealId, - currency, - netRevenue, - ttl, - ad, - }; + if (!resp) { + return bids; + } + + resp.seatbid[0].bid.map(serverBid => { + const bid = newBid(serverBid, bidderRequest); + bid.currency = resp.cur; + bids.push(bid); }); return bids; @@ -107,28 +97,99 @@ export const spec = { getUserSyncs: function(syncOptions, resps, gdprConsent) { const syncs = []; - if (syncOptions.pixelEnabled) { - resps.forEach(() => { - const uuid = getUserID(); - const syncUrl = SYNC_URL; - let params = ''; - if (gdprConsent && typeof gdprConsent.consentString === 'string') { - if (typeof gdprConsent.gdprApplies === 'boolean') { - params += `?gdpr=${Number(gdprConsent.gdprApplies)}&gdpr_consent=${gdprConsent.consentString}`; - } else { - params += `?gdpr_consent=${gdprConsent.consentString}`; - } - } - syncs.push({ - type: 'image', - url: syncUrl.replace('{UUID}', uuid) + params, - }); - }); + if (syncOptions.iframeEnabled) { + syncs.push(getSync('iframe', gdprConsent)); + } else if (syncOptions.pixelEnabled) { + syncs.push(getSync('image', gdprConsent)); } return syncs; } } +function getMediaType(req, type) { + const { mediaTypes } = req; + + if (!mediaTypes) { + return; + } + + switch (type) { + case 'banner': + if (mediaTypes.banner) { + const { sizes } = mediaTypes.banner; + return { + format: getFormats(sizes) + }; + } + break; + + case 'video': + if (mediaTypes.video) { + const { playerSize, context } = mediaTypes.video; + return { + context: context, + format: getFormats(playerSize) + }; + } + } +} + +function newBid(serverBid, bidderRequest) { + const bidRequest = utils.getBidRequest(serverBid.uuid, [bidderRequest]); + + const cpm = serverBid.price; + const requestId = serverBid.uuid; + const width = serverBid.w; + const height = serverBid.h; + const creativeId = serverBid.crid; + const dealId = serverBid.dealid; + const mediaType = serverBid.media_type; + const netRevenue = NET_REVENUE; + const ttl = TTL; + + const bid = { + cpm, + requestId, + width, + height, + mediaType, + creativeId, + dealId, + netRevenue, + ttl, + }; + + if (mediaType == 'video') { + const videoContext = utils.deepAccess(bidRequest, 'mediaTypes.video.context'); + + if (videoContext == 'instream') { + bid.vastUrl = serverBid.vast_url; + bid.vastImpUrl = serverBid.notify_url; + } + } else { + bid.ad = serverBid.adm; + } + + return bid; +} + +const getSync = (type, gdprConsent) => { + const uuid = getUserID(); + const syncUrl = SYNC_URL; + let params = '&type=' + type; + if (gdprConsent && typeof gdprConsent.consentString === 'string') { + if (typeof gdprConsent.gdprApplies === 'boolean') { + params += `&gdpr=${Number(gdprConsent.gdprApplies)}&gdpr_consent=${gdprConsent.consentString}`; + } else { + params += `&gdpr_consent=${gdprConsent.consentString}`; + } + } + return { + type: type, + url: syncUrl.replace('{UUID}', uuid) + params, + }; +} + const getUserID = () => { const cookieName = COOKIE_NAME; const uuidLen = UUID_LEN; diff --git a/modules/cleanmedianetBidAdapter.js b/modules/cleanmedianetBidAdapter.js index 325b17ec543..15871e1a6ae 100644 --- a/modules/cleanmedianetBidAdapter.js +++ b/modules/cleanmedianetBidAdapter.js @@ -1,15 +1,15 @@ import * as utils from '../src/utils'; -import { parse } from '../src/url'; -import { registerBidder } from '../src/adapters/bidderFactory'; -import { config } from '../src/config'; -import { Renderer } from '../src/Renderer'; -import { BANNER, VIDEO } from '../src/mediaTypes'; +import {parse} from '../src/url'; +import {registerBidder} from '../src/adapters/bidderFactory'; +import {config} from '../src/config'; +import {Renderer} from '../src/Renderer'; +import {BANNER, VIDEO} from '../src/mediaTypes'; export const helper = { - startsWith: function(str, search) { + startsWith: function (str, search) { return str.substr(0, search.length) === search; }, - getMediaType: function(bid) { + getMediaType: function (bid) { if (bid.ext) { if (bid.ext.media_type) { return bid.ext.media_type.toLowerCase(); @@ -28,7 +28,7 @@ export const spec = { aliases: [], supportedMediaTypes: [BANNER, VIDEO], - isBidRequestValid: function(bid) { + isBidRequestValid: function (bid) { return ( !!bid.params.supplyPartnerId && typeof bid.params.supplyPartnerId === 'string' && @@ -44,7 +44,7 @@ export const spec = { ); }, - buildRequests: function(validBidRequests, bidderRequest) { + buildRequests: function (validBidRequests, bidderRequest) { return validBidRequests.map(bidRequest => { const { adUnitCode, @@ -122,17 +122,27 @@ export const spec = { if (mediaTypes && mediaTypes.video) { if (!hasFavoredMediaType || params.favoredMediaType === VIDEO) { - const videoImp = Object.assign({}, imp, { + let videoImp = { video: { - w: sizes.length ? sizes[0][0] : 300, - h: sizes.length ? sizes[0][1] : 250, protocols: params.protocols || [1, 2, 3, 4, 5, 6], pos: params.pos || 0, - ext: { - context: mediaTypes.video.context - } + ext: {context: mediaTypes.video.context} } - }); + }; + + let playerSize = mediaTypes.video.playerSize || sizes; + if (utils.isArray(playerSize[0])) { + videoImp.video.w = playerSize[0][0]; + videoImp.video.h = playerSize[0][1]; + } else if (utils.isNumber(playerSize[0])) { + videoImp.video.w = playerSize[0]; + videoImp.video.h = playerSize[1]; + } else { + videoImp.video.w = 300; + videoImp.video.h = 250; + } + + videoImp = Object.assign({}, imp, videoImp); rtbBidRequest.imp.push(videoImp); } } @@ -150,7 +160,7 @@ export const spec = { }); }, - interpretResponse: function(serverResponse, bidRequest) { + interpretResponse: function (serverResponse, bidRequest) { const response = serverResponse && serverResponse.body; if (!response) { utils.logError('empty response'); @@ -165,16 +175,14 @@ export const spec = { bids.forEach(bid => { const outBid = { - adId: bidRequest.bidRequest.adUnitCode, requestId: bidRequest.bidRequest.bidId, cpm: bid.price, width: bid.w, height: bid.h, ttl: 60 * 10, - creativeId: bid.crid, + creativeId: bid.crid || bid.adid, netRevenue: true, currency: bid.cur || response.cur, - adUnitCode: bidRequest.bidRequest.adUnitCode, mediaType: helper.getMediaType(bid) }; @@ -185,7 +193,7 @@ export const spec = { ) ) { if (outBid.mediaType === BANNER) { - outBids.push(Object.assign({}, outBid, { ad: bid.adm })); + outBids.push(Object.assign({}, outBid, {ad: bid.adm})); } else if (outBid.mediaType === VIDEO) { const context = utils.deepAccess( bidRequest.bidRequest, @@ -207,7 +215,7 @@ export const spec = { return outBids; }, - getUserSyncs: function(syncOptions, serverResponses, gdprConsent) { + getUserSyncs: function (syncOptions, serverResponses, gdprConsent) { const syncs = []; const gdprApplies = gdprConsent && typeof gdprConsent.gdprApplies === 'boolean' @@ -224,7 +232,7 @@ export const spec = { const url = pixel.url + (pixel.url.indexOf('?') > 0 ? '&' + suffix : '?' + suffix); - return syncs.push({ type: pixel.type, url }); + return syncs.push({type: pixel.type, url}); }); } if (Array.isArray(bidResponse.seatbid)) { @@ -238,7 +246,7 @@ export const spec = { (pixel.url.indexOf('?') > 0 ? '&' + suffix : '?' + suffix); - return syncs.push({ type: pixel.type, url }); + return syncs.push({type: pixel.type, url}); }); } }); diff --git a/modules/consentManagement.js b/modules/consentManagement.js index 94a3b13e383..1e2a6648145 100644 --- a/modules/consentManagement.js +++ b/modules/consentManagement.js @@ -342,7 +342,7 @@ export function resetConsentData() { * A configuration function that initializes some module variables, as well as add a hook into the requestBids function * @param {object} config required; consentManagement module config settings; cmp (string), timeout (int), allowAuctionWithoutConsent (boolean) */ -export function setConfig(config) { +export function setConsentConfig(config) { if (utils.isStr(config.cmpApi)) { userCMP = config.cmpApi; } else { @@ -379,4 +379,4 @@ export function setConfig(config) { } addedConsentHook = true; } -config.getConfig('consentManagement', config => setConfig(config.consentManagement)); +config.getConfig('consentManagement', config => setConsentConfig(config.consentManagement)); diff --git a/modules/conversantBidAdapter.js b/modules/conversantBidAdapter.js index cb0661c4417..90865493d8d 100644 --- a/modules/conversantBidAdapter.js +++ b/modules/conversantBidAdapter.js @@ -99,7 +99,9 @@ export const spec = { imp.banner = banner; } - if (bid.crumbs && bid.crumbs.pubcid) { + if (bid.userId && bid.userId.pubcid) { + pubcid = bid.userId.pubcid; + } else if (bid.crumbs && bid.crumbs.pubcid) { pubcid = bid.crumbs.pubcid; } diff --git a/modules/cosmosBidAdapter.js b/modules/cosmosBidAdapter.js new file mode 100644 index 00000000000..84131bfa131 --- /dev/null +++ b/modules/cosmosBidAdapter.js @@ -0,0 +1,392 @@ +import { registerBidder } from '../src/adapters/bidderFactory'; +import { BANNER, VIDEO } from '../src/mediaTypes'; +import * as utils from '../src/utils'; + +const BIDDER_CODE = 'cosmos'; +const BID_ENDPOINT = '//bid.cosmoshq.com/openrtb2/bids'; +const USER_SYNC_ENDPOINT = '//sync.cosmoshq.com/js/v1/usersync.html'; +const HTTP_POST = 'POST'; +const LOG_PREFIX = 'COSMOS: '; +const DEFAULT_CURRENCY = 'USD'; +const HTTPS = 'https:'; +const MEDIA_TYPES = 'mediaTypes'; +const MIMES = 'mimes'; +const DEFAULT_NET_REVENUE = false; + +export const spec = { + code: BIDDER_CODE, + supportedMediaTypes: [BANNER, VIDEO], + + /** + * generate UUID + **/ + _createUUID: function () { + return ('' + new Date().getTime()); + }, + + /** + * copy object if not null + **/ + _copyObject: function (src, dst) { + if (src) { + // copy complete object + Object.keys(src).forEach(param => dst[param] = src[param]); + } + }, + + /** + * parse object + **/ + _parse: function (rawPayload) { + try { + if (rawPayload) { + return JSON.parse(rawPayload); + } + } catch (ex) { + utils.logError(LOG_PREFIX, 'Exception: ', ex); + } + return null; + }, + + /** + * Determines whether or not the given bid request is valid. + * + * @param {BidRequest} bid The bid params to validate. + * @return boolean True if this is a valid bid, and false otherwise. + **/ + isBidRequestValid: function (bid) { + if (!bid || !bid.params) { + utils.logError(LOG_PREFIX, 'nil/empty bid object'); + return false; + } + + if (!utils.isEmpty(bid.params.publisherId) || + !utils.isNumber(bid.params.publisherId)) { + utils.logError(LOG_PREFIX, 'publisherId is mandatory and must be numeric. Ad Unit: ', JSON.stringify(bid)); + return false; + } + // video bid request validation + if (bid.hasOwnProperty(MEDIA_TYPES) && bid.mediaTypes.hasOwnProperty(VIDEO)) { + if (!bid.mediaTypes.video.hasOwnProperty(MIMES) || + !utils.isArray(bid.mediaTypes.video.mimes) || + bid.mediaTypes.video.mimes.length === 0) { + utils.logError(LOG_PREFIX, 'mimes are mandatory for video bid request. Ad Unit: ', JSON.stringify(bid)); + return false; + } + } + + return true; + }, + + /** + * Make a server request from the list of BidRequests. + * + * @param {validBidRequests[]} - an array of bids + * @return ServerRequest Info describing the request to the server. + **/ + buildRequests: function (validBidRequests, bidderRequest) { + if (validBidRequests.length === 0) { + return []; + } + + var refererInfo; + if (bidderRequest && bidderRequest.refererInfo) { + refererInfo = bidderRequest.refererInfo; + } + + let clonedBidRequests = utils.deepClone(validBidRequests); + return clonedBidRequests.map(bidRequest => { + const oRequest = spec._createRequest(bidRequest, refererInfo); + if (oRequest) { + spec._setGDPRParams(bidderRequest, oRequest); + return { + method: HTTP_POST, + url: BID_ENDPOINT, + data: JSON.stringify(oRequest) + }; + } + }); + }, + + /** + * Unpack the response from the server into a list of bids. + * + * @param {ServerResponse} serverResponse A successful response from the server. + * @return {Bid[]} An array of bids which were nested inside the server. + **/ + interpretResponse: function (serverResponse, request) { + let response = serverResponse.body; + var bidResponses = []; + try { + if (response.seatbid) { + var currency = response.cur ? response.cur : DEFAULT_CURRENCY; + response.seatbid.forEach(seatbid => { + var bids = seatbid.bid ? seatbid.bid : []; + bids.forEach(bid => { + var bidResponse = { + requestId: bid.impid, + cpm: (parseFloat(bid.price) || 0).toFixed(2), + width: bid.w, + height: bid.h, + creativeId: bid.crid, + currency: currency, + netRevenue: DEFAULT_NET_REVENUE, + ttl: 300 + }; + if (bid.dealid) { + bidResponse.dealId = bid.dealid; + } + + var req = spec._parse(request.data); + if (req.imp && req.imp.length > 0) { + req.imp.forEach(impr => { + if (impr.id === bid.impid) { + if (impr.banner) { + bidResponse.ad = bid.adm; + bidResponse.mediaType = BANNER; + } else { + bidResponse.width = bid.hasOwnProperty('w') ? bid.w : impr.video.w; + bidResponse.height = bid.hasOwnProperty('h') ? bid.h : impr.video.h; + bidResponse.vastXml = bid.adm; + bidResponse.mediaType = VIDEO; + } + } + }); + } + bidResponses.push(bidResponse); + }); + }); + } + } catch (ex) { + utils.logError(LOG_PREFIX, 'Exception: ', ex); + } + return bidResponses; + }, + + /** + * Register the user sync pixels which should be dropped after the auction. + * @param {SyncOptions} syncOptions Which user syncs are allowed? + * @param {ServerResponse[]} serverResponses List of server's responses. + * @return {UserSync[]} The user syncs which should be dropped. + **/ + getUserSyncs: function (syncOptions, serverResponses) { + if (syncOptions.iframeEnabled) { + return [{ + type: 'iframe', + url: USER_SYNC_ENDPOINT + }]; + } else { + utils.logWarn(LOG_PREFIX + 'Please enable iframe based user sync.'); + } + }, + + /** + * create IAB standard OpenRTB bid request + **/ + _createRequest: function (bidRequests, refererInfo) { + var oRequest = {}; + try { + oRequest = { + id: spec._createUUID(), + imp: spec._createImpressions(bidRequests), + user: {}, + ext: {} + }; + var site = spec._createSite(bidRequests, refererInfo); + var app = spec._createApp(bidRequests); + var device = spec._createDevice(bidRequests); + if (app) { + oRequest.app = app; + } + if (site) { + oRequest.site = site; + } + if (device) { + oRequest.device = device; + } + } catch (ex) { + utils.logError(LOG_PREFIX, 'Exception: ', ex); + oRequest = null; + } + return oRequest; + }, + + /** + * create impression array objects + **/ + _createImpressions: function (request) { + var impressions = []; + var impression = spec._creatImpression(request); + if (impression) { + impressions.push(impression); + } + return impressions; + }, + + /** + * create impression (single) object + **/ + _creatImpression: function (request) { + if (!request.hasOwnProperty(MEDIA_TYPES)) { + return undefined; + } + + var params = request && request.params ? request.params : null; + var impression = { + id: request.bidId ? request.bidId : spec._createUUID(), + secure: window.location.protocol === HTTPS ? 1 : 0, + bidfloorcur: request.params.currency ? request.params.currency : DEFAULT_CURRENCY + }; + if (params.bidFloor) { + impression.bidfloor = params.bidFloor; + } + + if (params.tagId) { + impression.tagid = params.tagId.toString(); + } + + var banner; + var video; + var mediaType; + for (mediaType in request.mediaTypes) { + switch (mediaType) { + case BANNER: + banner = spec._createBanner(request); + if (banner) { + impression.banner = banner; + } + break; + case VIDEO: + video = spec._createVideo(request); + if (video) { + impression.video = video; + } + break; + } + } + + return impression.hasOwnProperty(BANNER) || + impression.hasOwnProperty(VIDEO) ? impression : undefined; + }, + + /** + * create the banner object + **/ + _createBanner: function (request) { + if (utils.deepAccess(request, 'mediaTypes.banner')) { + var banner = {}; + var sizes = request.mediaTypes.banner.sizes; + if (sizes && utils.isArray(sizes) && sizes.length > 0) { + var format = []; + banner.w = sizes[0][0]; + banner.h = sizes[0][1]; + sizes.forEach(size => { + format.push({ + w: size[0], + h: size[1] + }); + }); + banner.format = format; + } + + spec._copyObject(request.mediaTypes.banner, banner); + spec._copyObject(request.params.banner, banner); + return banner; + } + return undefined; + }, + + /** + * create video object + **/ + _createVideo: function (request) { + if (utils.deepAccess(request, 'mediaTypes.video')) { + var video = {}; + var sizes = request.mediaTypes.video.playerSize; + if (sizes && utils.isArray(sizes) && sizes.length > 1) { + video.w = sizes[0]; + video.h = sizes[1]; + } + spec._copyObject(request.mediaTypes.video, video); + spec._copyObject(request.params.video, video); + return video; + } + return undefined; + }, + + /** + * create site object + **/ + _createSite: function (request, refererInfo) { + var rSite = request.params.site; + if (rSite || !request.params.app) { + var site = {}; + spec._copyObject(rSite, site); + + if (refererInfo) { + if (refererInfo.referer) { + site.ref = encodeURIComponent(refererInfo.referer); + } + if (utils.isArray(refererInfo.stack) && refererInfo.stack.length > 0) { + site.page = encodeURIComponent(refererInfo.stack[0]); + let anchrTag = document.createElement('a'); + anchrTag.href = site.page; + site.domain = anchrTag.hostname; + } + } + + // override publisher object + site.publisher = { + id: request.params.publisherId.toString() + }; + return site; + } + return undefined; + }, + + /** + * create app object + **/ + _createApp: function (request) { + var rApp = request.params.app; + if (rApp) { + var app = {}; + spec._copyObject(rApp, app); + // override publisher object + app.publisher = { + id: request.params.publisherId.toString() + }; + return app; + } + return undefined; + }, + + /** + * create device obejct + **/ + _createDevice: function (request) { + var device = {}; + var rDevice = request.params.device; + spec._copyObject(rDevice, device); + device.dnt = utils.getDNT() ? 1 : 0; + device.ua = navigator.userAgent; + device.language = (navigator.language || navigator.browserLanguage || navigator.userLanguage || navigator.systemLanguage); + device.w = (window.screen.width || window.innerWidth); + device.h = (window.screen.height || window.innerHeigh); + return device; + }, + + /** + * set GDPR parameters + **/ + _setGDPRParams: function (bidderRequest, oRequest) { + if (!bidderRequest || !bidderRequest.gdprConsent) { + return; + } + + oRequest.regs = { ext: { gdpr: bidderRequest.gdprConsent.gdprApplies ? 1 : 0 } }; + oRequest.user = { ext: { consent: bidderRequest.gdprConsent.consentString } }; + }, + +} +registerBidder(spec); diff --git a/modules/cosmosBidAdapter.md b/modules/cosmosBidAdapter.md new file mode 100644 index 00000000000..187a19ba17a --- /dev/null +++ b/modules/cosmosBidAdapter.md @@ -0,0 +1,80 @@ +# Overview + +``` +Module Name: Cosmos Bid Adapter +Module Type: Bidder Adapter +Maintainer: dev@cosmoshq.com +``` + +# Description + +Module that connects to Cosmos server for bids. +Supported Ad Fortmats: +* Banner +* Video + +# Configuration +## Following configuration required for enabling user sync. +```javascript +pbjs.setConfig({ + userSync: { + iframeEnabled: true, + enabledBidders: ['cosmos'], + syncDelay: 6000 + }}); +``` +## For Video ads, enable prebid cache +```javascript +pbjs.setConfig({ + cache: { + url: 'https://prebid.adnxs.com/pbc/v1/cache' + } +}); +``` + +# Test Parameters +``` + var adUnits = [ + // Banner adUnit + { + code: 'banner-div', + mediaTypes: { + banner: { //supported as per the openRTB spec + sizes: [[300, 250]] // required + } + }, + bids: [ + { + bidder: "cosmos", + params: { + publisherId: 1001, // required + tagId: 1 // optional + } + } + ] + }, + // Video adUnit + { + code: 'video-div', + mediaTypes: { + video: { // supported as per the openRTB spec + sizes: [[300, 50]], // required + mimes : ['video/mp4', 'application/javascript'], // required + context: 'instream' // optional + } + }, + bids: [ + { + bidder: "cosmos", + params: { + publisherId: 1001, // required + tagId: 1, // optional + video: { // supported as per the openRTB spec + + } + } + } + ] + } + ]; +``` diff --git a/modules/cpmstarBidAdapter.js b/modules/cpmstarBidAdapter.js new file mode 100644 index 00000000000..84b76cbbc35 --- /dev/null +++ b/modules/cpmstarBidAdapter.js @@ -0,0 +1,118 @@ + +import * as utils from '../src/utils'; +import { registerBidder } from '../src/adapters/bidderFactory'; +import {VIDEO, BANNER} from '../src/mediaTypes'; + +const BIDDER_CODE = 'cpmstar'; + +const ENDPOINT_DEV = '//dev.server.cpmstar.com/view.aspx'; +const ENDPOINT_STAGING = '//staging.server.cpmstar.com/view.aspx'; +const ENDPOINT_PRODUCTION = '//server.cpmstar.com/view.aspx'; + +const DEFAULT_TTL = 300; +const DEFAULT_CURRENCY = 'USD'; + +export const spec = { + code: BIDDER_CODE, + supportedMediaTypes: [BANNER, VIDEO], + pageID: Math.floor(Math.random() * 10e6), + + getMediaType: function(bidRequest) { + if (bidRequest == null) return BANNER; + return !utils.deepAccess(bidRequest, 'mediaTypes.video') ? BANNER : VIDEO; + }, + + getPlayerSize: function(bidRequest) { + var playerSize = utils.deepAccess(bidRequest, 'mediaTypes.video.playerSize'); + if (playerSize == null) return [640, 440]; + if (playerSize[0] != null) playerSize = playerSize[0]; + if (playerSize == null || playerSize[0] == null || playerSize[1] == null) return [640, 440]; + return playerSize; + }, + + isBidRequestValid: function (bid) { + return ((typeof bid.params.placementId === 'string') && !!bid.params.placementId.length) || (typeof bid.params.placementId === 'number'); + }, + + buildRequests: function (validBidRequests, bidderRequest) { + var requests = []; + // This reference to window.top can cause issues when loaded in an iframe if not protected with a try/catch. + + for (var i = 0; i < validBidRequests.length; i++) { + var bidRequest = validBidRequests[i]; + var referer = encodeURIComponent(bidderRequest.refererInfo.referer); + var e = utils.getBidIdParameter('endpoint', bidRequest.params); + var ENDPOINT = e == 'dev' ? ENDPOINT_DEV : e == 'staging' ? ENDPOINT_STAGING : ENDPOINT_PRODUCTION; + var mediaType = spec.getMediaType(bidRequest); + var playerSize = spec.getPlayerSize(bidRequest); + var videoArgs = '&fv=0' + (playerSize ? ('&w=' + playerSize[0] + '&h=' + playerSize[1]) : ''); + requests.push({ + method: 'GET', + url: ENDPOINT + '?media=' + mediaType + (mediaType == VIDEO ? videoArgs : '') + '&json=c_b&mv=1&poolid=' + utils.getBidIdParameter('placementId', bidRequest.params) + '&reachedTop=' + encodeURIComponent(bidderRequest.refererInfo.reachedTop) + '&requestid=' + bidRequest.bidId + '&referer=' + referer, + bidRequest: bidRequest, + }); + } + + return requests; + }, + + interpretResponse: function (serverResponse, request) { + var bidRequest = request.bidRequest; + var mediaType = spec.getMediaType(bidRequest); + + var bidResponses = []; + + if (!Array.isArray(serverResponse.body)) { + serverResponse.body = [serverResponse.body]; + } + + for (var i = 0; i < serverResponse.body.length; i++) { + var raw = serverResponse.body[i]; + var rawBid = raw.creatives[0]; + if (!rawBid) { + utils.logWarn('cpmstarBidAdapter: server response failed check'); + return; + } + var cpm = (parseFloat(rawBid.cpm) || 0); + + if (!cpm) { + utils.logWarn('cpmstarBidAdapter: server response failed check. Missing cpm') + return; + } + + var bidResponse = { + requestId: rawBid.requestid, + cpm: cpm, + width: rawBid.width || 0, + height: rawBid.height || 0, + currency: rawBid.currency ? rawBid.currency : DEFAULT_CURRENCY, + netRevenue: rawBid.netRevenue ? rawBid.netRevenue : true, + ttl: rawBid.ttl ? rawBid.ttl : DEFAULT_TTL, + creativeId: rawBid.creativeid || 0, + }; + + if (rawBid.hasOwnProperty('dealId')) { + bidResponse.dealId = rawBid.dealId + } + + if (mediaType == BANNER && rawBid.code) { + bidResponse.ad = rawBid.code + (rawBid.px_cr ? "\n" : ''); + } else if (mediaType == VIDEO && rawBid.creativemacros && rawBid.creativemacros.HTML5VID_VASTSTRING) { + var playerSize = spec.getPlayerSize(bidRequest); + if (playerSize != null) { + bidResponse.width = playerSize[0]; + bidResponse.height = playerSize[1]; + } + bidResponse.mediaType = VIDEO; + bidResponse.vastXml = rawBid.creativemacros.HTML5VID_VASTSTRING; + } else { + return utils.logError('bad response', rawBid); + } + + bidResponses.push(bidResponse); + } + + return bidResponses; + } +}; +registerBidder(spec); diff --git a/modules/cpmstarBidAdapter.md b/modules/cpmstarBidAdapter.md new file mode 100644 index 00000000000..7dab435b0f0 --- /dev/null +++ b/modules/cpmstarBidAdapter.md @@ -0,0 +1,50 @@ +# Overview + +``` +Module Name: Cpmstar Bidder Adapter +Module Type: Bidder Adapter +Maintainer: josh@cpmstar.com +``` + +# Description + +Module that connects to Cpmstar's demand sources + +# Test Parameters +``` +var adUnits = [ + { + code: 'banner-ad-div', + mediaTypes: { + banner: { + sizes: [[300, 250]], + } + }, + bids: [ + { + bidder: 'cpmstar', + params: { + placementId: 81006 + } + }, + ] + }, + { + code: 'video-ad-div', + mediaTypes: { + video: { + context: 'instream', + sizes: [[640, 480]] + } + }, + bids:[ + { + bidder: 'cpmstar', + params: { + placementId: 81007 + } + } + ] + } +]; +``` \ No newline at end of file diff --git a/modules/criteoBidAdapter.js b/modules/criteoBidAdapter.js old mode 100755 new mode 100644 index ff612aff905..559c02cd4a9 --- a/modules/criteoBidAdapter.js +++ b/modules/criteoBidAdapter.js @@ -1,20 +1,19 @@ import { loadExternalScript } from '../src/adloader'; import { registerBidder } from '../src/adapters/bidderFactory'; +import { config } from '../src/config'; +import { BANNER, VIDEO } from '../src/mediaTypes'; import { parse } from '../src/url'; import * as utils from '../src/utils'; import find from 'core-js/library/fn/array/find'; import JSEncrypt from 'jsencrypt/bin/jsencrypt'; import sha256 from 'crypto-js/sha256'; -const ADAPTER_VERSION = 16; +export const ADAPTER_VERSION = 20; const BIDDER_CODE = 'criteo'; const CDB_ENDPOINT = '//bidder.criteo.com/cdb'; const CRITEO_VENDOR_ID = 91; -const INTEGRATION_MODES = { - 'amp': 1, -}; const PROFILE_ID_INLINE = 207; -const PROFILE_ID_PUBLISHERTAG = 185; +export const PROFILE_ID_PUBLISHERTAG = 185; // Unminified source code can be found in: https://github.com/Prebid-org/prebid-js-external-js-criteo/blob/master/dist/prod.js const PUBLISHER_TAG_URL = '//static.criteo.net/js/ld/publishertag.prebid.js'; @@ -29,14 +28,27 @@ OmOSj0/qnYTAYCu0cR5LiyWG79KlIgUyMbp92ulGg24gAyGrVn4+v/4c53WlOEUp /** @type {BidderSpec} */ export const spec = { code: BIDDER_CODE, + supportedMediaTypes: [ BANNER, VIDEO ], /** * @param {object} bid * @return {boolean} */ - isBidRequestValid: bid => ( - !!(bid && bid.params && (bid.params.zoneId || bid.params.networkId)) - ), + isBidRequestValid: (bid) => { + // either one of zoneId or networkId should be set + if (!(bid && bid.params && (bid.params.zoneId || bid.params.networkId))) { + return false; + } + + // video media types requires some mandatory params + if (hasVideoMediaType(bid)) { + if (!hasValidVideoMediaType(bid)) { + return false; + } + } + + return true; + }, /** * @param {BidRequest[]} bidRequests @@ -47,6 +59,8 @@ export const spec = { let url; let data; + Object.assign(bidderRequest, { ceh: config.getConfig('criteo.ceh') }); + // If publisher tag not already loaded try to get it from fast bid if (!publisherTagAvailable()) { window.Criteo = window.Criteo || {}; @@ -106,9 +120,13 @@ export const spec = { creativeId: bidId, width: slot.width, height: slot.height, + dealId: slot.dealCode, } if (slot.native) { bid.ad = createNativeAd(bidId, slot.native, bidRequest.params.nativeCallback); + } else if (slot.video) { + bid.vastUrl = slot.displayurl; + bid.mediaType = VIDEO; } else { bid.ad = slot.creative; } @@ -169,12 +187,12 @@ function buildContext(bidRequests) { url: url, debug: queryString['pbt_debug'] === '1', noLog: queryString['pbt_nolog'] === '1', - integrationMode: undefined, + amp: false, }; bidRequests.forEach(bidRequest => { - if (bidRequest.params.integrationMode) { - context.integrationMode = bidRequest.params.integrationMode; + if (bidRequest.params.integrationMode === 'amp') { + context.amp = true; } }) @@ -192,8 +210,8 @@ function buildCdbUrl(context) { url += '&wv=' + encodeURIComponent('$prebid.version$'); url += '&cb=' + String(Math.floor(Math.random() * 99999999999)); - if (context.integrationMode in INTEGRATION_MODES) { - url += '&im=' + INTEGRATION_MODES[context.integrationMode]; + if (context.amp) { + url += '&im=1'; } if (context.debug) { url += '&debug=1'; @@ -222,7 +240,7 @@ function buildCdbRequest(context, bidRequests, bidderRequest) { impid: bidRequest.adUnitCode, transactionid: bidRequest.transactionId, auctionId: bidRequest.auctionId, - sizes: bidRequest.sizes.map(size => size[0] + 'x' + size[1]), + sizes: getBannerSizes(bidRequest), }; if (bidRequest.params.zoneId) { slot.zoneid = bidRequest.params.zoneId; @@ -233,12 +251,33 @@ function buildCdbRequest(context, bidRequests, bidderRequest) { if (bidRequest.params.nativeCallback) { slot.native = true; } + if (hasVideoMediaType(bidRequest)) { + const video = { + playersizes: getVideoSizes(bidRequest), + mimes: bidRequest.mediaTypes.video.mimes, + protocols: bidRequest.mediaTypes.video.protocols, + maxduration: bidRequest.mediaTypes.video.maxduration, + api: bidRequest.mediaTypes.video.api + } + + video.skip = bidRequest.params.video.skip; + video.placement = bidRequest.params.video.placement; + video.minduration = bidRequest.params.video.minduration; + video.playbackmethod = bidRequest.params.video.playbackmethod; + video.startdelay = bidRequest.params.video.startdelay; + + slot.video = video; + } return slot; }), }; if (networkId) { request.publisher.networkid = networkId; } + request.user = {}; + if (bidderRequest && bidderRequest.ceh) { + request.user.ceh = bidderRequest.ceh; + } if (bidderRequest && bidderRequest.gdprConsent) { request.gdprConsent = {}; if (typeof bidderRequest.gdprConsent.gdprApplies !== 'undefined') { @@ -255,6 +294,66 @@ function buildCdbRequest(context, bidRequests, bidderRequest) { return request; } +function getVideoSizes(bidRequest) { + return parseSizes(utils.deepAccess(bidRequest, 'mediaTypes.video.playerSize')); +} + +function getBannerSizes(bidRequest) { + return parseSizes(utils.deepAccess(bidRequest, 'mediaTypes.banner.sizes') || bidRequest.sizes); +} + +function parseSize(size) { + return size[0] + 'x' + size[1]; +} + +function parseSizes(sizes) { + if (Array.isArray(sizes[0])) { // is there several sizes ? (ie. [[728,90],[200,300]]) + return sizes.map(size => parseSize(size)); + } + + return [parseSize(sizes)]; // or a single one ? (ie. [728,90]) +} + +function hasVideoMediaType(bidRequest) { + if (utils.deepAccess(bidRequest, 'params.video') === undefined) { + return false; + } + return utils.deepAccess(bidRequest, 'mediaTypes.video') !== undefined; +} + +function hasValidVideoMediaType(bidRequest) { + let isValid = true; + + var requiredMediaTypesParams = ['mimes', 'playerSize', 'maxduration', 'protocols', 'api']; + + requiredMediaTypesParams.forEach(function(param) { + if (utils.deepAccess(bidRequest, 'mediaTypes.video.' + param) === undefined) { + isValid = false; + utils.logError('Criteo Bid Adapter: mediaTypes.video.' + param + ' is required'); + } + }); + + var requiredParams = ['skip', 'placement', 'playbackmethod']; + + requiredParams.forEach(function(param) { + if (utils.deepAccess(bidRequest, 'params.video.' + param) === undefined) { + isValid = false; + utils.logError('Criteo Bid Adapter: params.video.' + param + ' is required'); + } + }); + + if (isValid) { + // We do not support long form for now, also we have to check that context & placement are consistent + if (bidRequest.mediaTypes.video.context == 'instream' && bidRequest.params.video.placement === 1) { + return true; + } else if (bidRequest.mediaTypes.video.context == 'outstream' && bidRequest.params.video.placement !== 1) { + return true; + } + } + + return false; +} + /** * @param {string} id * @param {*} payload @@ -281,47 +380,37 @@ function createNativeAd(id, payload, callback) { `; } -export function cryptoVerify(key, hash, code) { - var jse = new JSEncrypt(); - jse.setPublicKey(key); - return jse.verify(code, hash, sha256); -} - -function validateFastBid(fastBid) { - // The value stored must contain the file's encrypted hash as first line - const firstLineEnd = fastBid.indexOf('\n'); - const firstLine = fastBid.substr(0, firstLineEnd).trim(); - if (firstLine.substr(0, 9) !== '// Hash: ') { - utils.logWarn('No hash found in FastBid'); - return false; - } - - // Remove the hash part from the locally stored value - const fileEncryptedHash = firstLine.substr(9); - const publisherTag = fastBid.substr(firstLineEnd + 1); - - // Verify the hash using cryptography - try { - return cryptoVerify(FAST_BID_PUBKEY, fileEncryptedHash, publisherTag); - } catch (e) { - utils.logWarn('Failed to verify Criteo FastBid'); - return undefined; - } -} - /** * @return {boolean} */ -function tryGetCriteoFastBid() { +export function tryGetCriteoFastBid() { try { - const fastBid = localStorage.getItem('criteo_fast_bid'); - if (fastBid !== null) { - if (validateFastBid(fastBid) === false) { - utils.logWarn('Invalid Criteo FastBid found'); - localStorage.removeItem('criteo_fast_bid'); + const fastBidStorageKey = 'criteo_fast_bid'; + const hashPrefix = '// Hash: '; + const fastBidFromStorage = localStorage.getItem(fastBidStorageKey); + + if (fastBidFromStorage !== null) { + // The value stored must contain the file's encrypted hash as first line + const firstLineEndPosition = fastBidFromStorage.indexOf('\n'); + const firstLine = fastBidFromStorage.substr(0, firstLineEndPosition).trim(); + + if (firstLine.substr(0, hashPrefix.length) !== hashPrefix) { + utils.logWarn('No hash found in FastBid'); + localStorage.removeItem(fastBidStorageKey); } else { - utils.logInfo('Using Criteo FastBid'); - eval(fastBid); // eslint-disable-line no-eval + // Remove the hash part from the locally stored value + const publisherTagHash = firstLine.substr(hashPrefix.length); + const publisherTag = fastBidFromStorage.substr(firstLineEndPosition + 1); + + var jsEncrypt = new JSEncrypt(); + jsEncrypt.setPublicKey(FAST_BID_PUBKEY); + if (jsEncrypt.verify(publisherTag, publisherTagHash, sha256)) { + utils.logInfo('Using Criteo FastBid'); + eval(publisherTag); // eslint-disable-line no-eval + } else { + utils.logWarn('Invalid Criteo FastBid found'); + localStorage.removeItem(fastBidStorageKey); + } } } } catch (e) { diff --git a/modules/criteoBidAdapter.md b/modules/criteoBidAdapter.md old mode 100755 new mode 100644 index 796c70a980f..e4c441c758d --- a/modules/criteoBidAdapter.md +++ b/modules/criteoBidAdapter.md @@ -25,3 +25,13 @@ Module that connects to Criteo's demand sources. } ]; ``` + +# Additional Config (Optional) +Set the "ceh" property to provides the user's hashed email if available +``` + pbjs.setConfig({ + criteo: { + ceh: 'hashed mail' + } + }); +``` \ No newline at end of file diff --git a/modules/criteortusIdSystem.js b/modules/criteortusIdSystem.js new file mode 100644 index 00000000000..02edf0ef06e --- /dev/null +++ b/modules/criteortusIdSystem.js @@ -0,0 +1,105 @@ +/** + * This module adds Criteo Real Time User Sync to the User ID module + * The {@link module:modules/userId} module is required + * @module modules/criteortusIdSystem + * @requires module:modules/userId + */ + +import * as utils from '../src/utils' +import { ajax } from '../src/ajax'; +import { submodule } from '../src/hook'; + +const key = '__pbjs_criteo_rtus'; + +/** @type {Submodule} */ +export const criteortusIdSubmodule = { + /** + * used to link submodule with config + * @type {string} + */ + name: 'criteortus', + /** + * decode the stored id value for passing to bid requests + * @function + * @returns {{criteortus:Object}} + */ + decode() { + let uid = utils.getCookie(key); + try { + uid = JSON.parse(uid); + return { 'criteortus': uid }; + } catch (error) { + utils.logError('Error in parsing criteo rtus data', error); + } + }, + /** + * performs action to obtain id and return a value in the callback's response argument + * @function + * @param {SubmoduleParams} [configParams] + * @returns {function(callback:function)} + */ + getId(configParams) { + if (!configParams || !utils.isPlainObject(configParams.clientIdentifier)) { + utils.logError('User ID - Criteo rtus requires client identifier to be defined'); + return; + } + + let uid = utils.getCookie(key); + if (uid) { + return uid; + } else { + let userIds = {}; + return function(callback) { + let bidders = Object.keys(configParams.clientIdentifier); + + function afterAllResponses() { + // criteo rtus user id expires in 1 hour + const expiresStr = (new Date(Date.now() + (60 * 60 * 1000))).toUTCString(); + utils.setCookie(key, JSON.stringify(userIds), expiresStr); + callback(userIds); + } + + const onResponse = utils.delayExecution(afterAllResponses, bidders.length); + + bidders.forEach((bidder) => { + let url = `https://gum.criteo.com/sync?c=${configParams.clientIdentifier[bidder]}&r=3`; + const getSuccessHandler = (bidder) => { + return function onSuccess(response) { + if (response) { + try { + response = JSON.parse(response); + userIds[bidder] = response; + onResponse(); + } catch (error) { + utils.logError(error); + } + } + } + } + + const getFailureHandler = (bidder) => { + return function onFailure(error) { + utils.logError(`Criteo RTUS server call failed for ${bidder}`, error); + onResponse(); + } + } + + ajax( + url, + { + success: getSuccessHandler(bidder), + error: getFailureHandler(bidder) + }, + undefined, + Object.assign({ + method: 'GET', + withCredentials: true + }) + ); + }) + } + } + } +}; + +submodule('userId', criteortusIdSubmodule); diff --git a/modules/currency.js b/modules/currency.js index 17c38b17a98..ae2f9ac1f1b 100644 --- a/modules/currency.js +++ b/modules/currency.js @@ -180,14 +180,14 @@ export function addBidResponseHook(fn, adUnitCode, bid) { bid.currency = 'USD'; } - let fromCurrency = bid.currency; - let cpm = bid.cpm; - // used for analytics bid.getCpmInNewCurrency = function(toCurrency) { - return (parseFloat(cpm) * getCurrencyConversion(fromCurrency, toCurrency)).toFixed(3); + return (parseFloat(this.cpm) * getCurrencyConversion(this.currency, toCurrency)).toFixed(3); }; + bid.originalCpm = bid.cpm; + bid.originalCurrency = bid.currency; + // execute immediately if the bid is already in the desired currency if (bid.currency === adServerCurrency) { return fn.call(this, adUnitCode, bid); @@ -212,8 +212,6 @@ function wrapFunction(fn, context, params) { let fromCurrency = bid.currency; try { let conversion = getCurrencyConversion(fromCurrency); - bid.originalCpm = bid.cpm; - bid.originalCurrency = bid.currency; if (conversion !== 1) { bid.cpm = (parseFloat(bid.cpm) * conversion).toFixed(4); bid.currency = adServerCurrency; diff --git a/modules/danmarketBidAdapter.md b/modules/danmarketBidAdapter.md old mode 100755 new mode 100644 diff --git a/modules/datablocksAnalyticsAdapter.js b/modules/datablocksAnalyticsAdapter.js new file mode 100644 index 00000000000..76dd490180b --- /dev/null +++ b/modules/datablocksAnalyticsAdapter.js @@ -0,0 +1,19 @@ +/** + * Analytics Adapter for Datablocks + */ + +import adapter from '../src/AnalyticsAdapter'; +import adapterManager from '../src/adapterManager'; + +var datablocksAdapter = adapter({ + global: 'datablocksAnalytics', + handler: 'on', + analyticsType: 'bundle' +}); + +adapterManager.registerAnalyticsAdapter({ + adapter: datablocksAdapter, + code: 'datablocks' +}); + +export default datablocksAdapter; diff --git a/modules/datablocksAnalyticsAdapter.md b/modules/datablocksAnalyticsAdapter.md new file mode 100644 index 00000000000..07f65da6e2c --- /dev/null +++ b/modules/datablocksAnalyticsAdapter.md @@ -0,0 +1,23 @@ +# Overview + +Module Name: Datablocks Analytics Adapter +Module Type: Datablocks Adapter +Maintainer: support@datablocks.net + +# Description + +Analytics adapter for Datablocks.net. Contact support@datablocks.net for information. + +# Test Parameters + +``` +{ + provider: 'datablocks', + options: { + publisherId: 12345, + sourceId: 12356, + host: 'prebid.datablocks.net' + + } +} +``` \ No newline at end of file diff --git a/modules/datablocksBidAdapter.js b/modules/datablocksBidAdapter.js new file mode 100644 index 00000000000..aa427c6eae1 --- /dev/null +++ b/modules/datablocksBidAdapter.js @@ -0,0 +1,285 @@ +import * as utils from '../src/utils'; +import { registerBidder } from '../src/adapters/bidderFactory'; +import { BANNER, NATIVE } from '../src/mediaTypes'; +import { parse as parseUrl } from '../src/url'; +const NATIVE_MAP = { + 'body': 2, + 'body2': 10, + 'price': 6, + 'displayUrl': 11, + 'cta': 12 +}; +const NATIVE_IMAGE = [{ + id: 1, + required: 1, + title: { + len: 140 + } +}, { + id: 2, + required: 1, + img: { type: 3 } +}, { + id: 3, + required: 1, + data: { + type: 11 + } +}, { + id: 4, + required: 0, + data: { + type: 2 + } +}, { + id: 5, + required: 0, + img: { type: 1 } +}, { + id: 6, + required: 0, + data: { + type: 12 + } +}]; + +export const spec = { + supportedMediaTypes: [BANNER, NATIVE], + code: 'datablocks', + isBidRequestValid: function(bid) { + return !!(bid.params.host && bid.params.sourceId && + bid.mediaTypes && (bid.mediaTypes.banner || bid.mediaTypes.native)); + }, + buildRequests: function(validBidRequests, bidderRequest) { + if (!validBidRequests.length) { return []; } + + let imps = {}; + let site = {}; + let device = {}; + let refurl = parseUrl(bidderRequest.referrer); + let requests = []; + + validBidRequests.forEach(bidRequest => { + let imp = { + id: bidRequest.bidId, + tagid: bidRequest.adUnitCode, + secure: window.location.protocol == 'https:' + } + + if (utils.deepAccess(bidRequest, `mediaTypes.banner`)) { + let sizes = bidRequest.mediaTypes.banner.sizes; + if (sizes.length == 1) { + imp.banner = { + w: sizes[0][0], + h: sizes[0][1] + } + } else if (sizes.length > 1) { + imp.banner = { + format: sizes.map(size => ({ w: size[0], h: size[1] })) + }; + } else { + return; + } + } else if (utils.deepAccess(bidRequest, 'mediaTypes.native')) { + let nativeImp = bidRequest.mediaTypes.native; + + if (nativeImp.type) { + let nativeAssets = []; + switch (nativeImp.type) { + case 'image': + nativeAssets = NATIVE_IMAGE; + break; + default: + return; + } + imp.native = JSON.stringify({ assets: nativeAssets }); + } else { + let nativeAssets = []; + let nativeKeys = Object.keys(nativeImp); + nativeKeys.forEach((nativeKey, index) => { + let required = !!nativeImp[nativeKey].required; + let assetId = index + 1; + switch (nativeKey) { + case 'title': + nativeAssets.push({ + id: assetId, + required: required, + title: { + len: nativeImp[nativeKey].len || 140 + } + }); + break; + case 'body': // desc + case 'body2': // desc2 + case 'price': + case 'display_url': + let data = { + id: assetId, + required: required, + data: { + type: NATIVE_MAP[nativeKey] + } + } + if (nativeImp[nativeKey].data && nativeImp[nativeKey].data.len) { data.data.len = nativeImp[nativeKey].data.len; } + + nativeAssets.push(data); + break; + case 'image': + if (nativeImp[nativeKey].sizes && nativeImp[nativeKey].sizes.length) { + nativeAssets.push({ + id: assetId, + required: required, + image: { + type: 3, + w: nativeImp[nativeKey].sizes[0], + h: nativeImp[nativeKey].sizes[1] + } + }) + } + } + }); + imp.native = { + request: JSON.stringify({native: {assets: nativeAssets}}) + }; + } + } + let host = bidRequest.params.host; + let sourceId = bidRequest.params.sourceId; + imps[host] = imps[host] || {}; + let hostImp = imps[host][sourceId] = imps[host][sourceId] || { imps: [] }; + hostImp.imps.push(imp); + hostImp.subid = hostImp.imps.subid || bidRequest.params.subid || 'blank'; + hostImp.path = 'search'; + hostImp.idParam = 'sid'; + hostImp.protocol = '//'; + }); + + // Generate Site obj + site.domain = refurl.hostname; + site.page = refurl.protocol + '://' + refurl.hostname + refurl.pathname; + if (self === top && document.referrer) { + site.ref = document.referrer; + } + let keywords = document.getElementsByTagName('meta')['keywords']; + if (keywords && keywords.content) { + site.keywords = keywords.content; + } + + // Generate Device obj. + device.ip = 'peer'; + device.ua = window.navigator.userAgent; + device.js = 1; + device.language = ((navigator.language || navigator.userLanguage || '').split('-'))[0] || 'en'; + + RtbRequest(device, site, imps).forEach(formatted => { + requests.push({ + method: 'POST', + url: formatted.url, + data: formatted.body, + options: { + withCredentials: false + } + }) + }); + + return requests; + + function RtbRequest(device, site, imps) { + let collection = []; + Object.keys(imps).forEach(host => { + let sourceIds = imps[host]; + Object.keys(sourceIds).forEach(sourceId => { + let impObj = sourceIds[sourceId]; + collection.push({ + url: `${impObj.protocol}${host}/${impObj.path}/?${impObj.idParam}=${sourceId}`, + body: { + id: bidderRequest.auctionId, + imp: impObj.imps, + site: Object.assign({ id: impObj.subid || 'blank' }, site), + device: Object.assign({}, device) + } + }) + }) + }) + + return collection; + } + }, + interpretResponse: function(serverResponse, bidRequest) { + if (!serverResponse || !serverResponse.body || !serverResponse.body.seatbid) { + return []; + } + let body = serverResponse.body; + + let bids = body.seatbid + .map(seatbid => seatbid.bid) + .reduce((memo, bid) => memo.concat(bid), []); + let req = bidRequest.data; + let reqImps = req.imp; + + return bids.map(rtbBid => { + let imp; + for (let i in reqImps) { + let testImp = reqImps[i] + if (testImp.id == rtbBid.impid) { + imp = testImp; + break; + } + } + let br = { + requestId: rtbBid.impid, + cpm: rtbBid.price, + creativeId: rtbBid.crid, + currency: rtbBid.currency || 'USD', + netRevenue: true, + ttl: 360 + }; + if (!imp) { + return br; + } else if (imp.banner) { + br.mediaType = BANNER; + br.width = rtbBid.w; + br.height = rtbBid.h; + br.ad = rtbBid.adm; + } else if (imp.native) { + br.mediaType = NATIVE; + + let reverseNativeMap = {}; + let nativeKeys = Object.keys(NATIVE_MAP); + nativeKeys.forEach(k => { + reverseNativeMap[NATIVE_MAP[k]] = k; + }); + + let idMap = {}; + let nativeReq = JSON.parse(imp.native.request); + if (nativeReq.native && nativeReq.native.assets) { + nativeReq.native.assets.forEach(asset => { + if (asset.data) { idMap[asset.id] = reverseNativeMap[asset.data.type]; } + }) + } + + const nativeResponse = JSON.parse(rtbBid.adm); + const { assets, link, imptrackers, jstrackers } = nativeResponse.native; + const result = { + clickUrl: link.url, + clickTrackers: link.clicktrackers || undefined, + impressionTrackers: imptrackers || undefined, + javascriptTrackers: jstrackers ? [jstrackers] : undefined + }; + assets.forEach(asset => { + if (asset.title) { + result.title = asset.title.text; + } else if (asset.img) { + result.image = asset.img.url; + } else if (idMap[asset.id]) { + result[idMap[asset.id]] = asset.data.value; + } + }) + br.native = result; + } + return br; + }); + } + +}; +registerBidder(spec); diff --git a/modules/datablocksBidAdapter.md b/modules/datablocksBidAdapter.md new file mode 100644 index 00000000000..7562eee5704 --- /dev/null +++ b/modules/datablocksBidAdapter.md @@ -0,0 +1,54 @@ +# Overview + +``` +Module Name: Datablocks Bidder Adapter +Module Type: Bidder Adapter +Maintainer: support@datablocks.net +``` + +# Description + +Connects to Datablocks Version 5 Platform +Banner Native and + + +# Test Parameters +``` + var adUnits = [ + { + code: 'banner-div', + sizes: [[300, 250]], + mediaTypes:{ + banner: { + sizes: [300,250] + } + }, + bids: [ + { + bidder: 'datablocks', + params: { + sourceId: 12345, + host: 'prebid.datablocks.net' + } + } + ] + }, { + code: 'native-div', + mediaTypes : { + native: { + title:{required:true}, + body:{required:true} + } + }, + bids: [ + { + bidder: 'datablocks', + params: { + sourceId: 12345, + host: 'prebid.datablocks.net' + } + } + ] + } + ]; +``` \ No newline at end of file diff --git a/modules/dfpAdServerVideo.js b/modules/dfpAdServerVideo.js index d8cd6e099ee..6f3c23f1f3d 100644 --- a/modules/dfpAdServerVideo.js +++ b/modules/dfpAdServerVideo.js @@ -7,6 +7,8 @@ import { targeting } from '../src/targeting'; import { formatQS, format as buildUrl, parse } from '../src/url'; import { deepAccess, isEmpty, logError, parseSizesInput } from '../src/utils'; import { config } from '../src/config'; +import { getHook, submodule } from '../src/hook'; +import { auctionManager } from '../src/auctionManager'; /** * @typedef {Object} DfpVideoParams @@ -45,6 +47,8 @@ const defaultParamConstants = { unviewed_position_start: 1, }; +export const adpodUtils = {}; + /** * Merge all the bid data and publisher-supplied options into a single URL, and then return it. * @@ -56,9 +60,9 @@ const defaultParamConstants = { * (or the auction's winning bid for this adUnit, if undefined) compete alongside the rest of the * demand in DFP. */ -export default function buildDfpVideoUrl(options) { +export function buildDfpVideoUrl(options) { if (!options.params && !options.url) { - logError(`A params object or a url is required to use pbjs.adServers.dfp.buildVideoUrl`); + logError(`A params object or a url is required to use $$PREBID_GLOBAL$$.adServers.dfp.buildVideoUrl`); return; } @@ -103,6 +107,92 @@ export default function buildDfpVideoUrl(options) { }); } +export function notifyTranslationModule(fn) { + fn.call(this, 'dfp'); +} + +getHook('registerAdserver').before(notifyTranslationModule); + +/** + * @typedef {Object} DfpAdpodOptions + * + * @param {string} code Ad Unit code + * @param {Object} params Query params which should be set on the DFP request. + * These will override this module's defaults whenever they conflict. + * @param {function} callback Callback function to execute when master tag is ready + */ + +/** + * Creates master tag url for long-form + * @param {DfpAdpodOptions} options + * @returns {string} A URL which calls DFP with custom adpod targeting key values to compete with rest of the demand in DFP + */ +export function buildAdpodVideoUrl({code, params, callback} = {}) { + if (!params || !callback) { + logError(`A params object and a callback is required to use pbjs.adServers.dfp.buildAdpodVideoUrl`); + return; + } + + const derivedParams = { + correlator: Date.now(), + sz: getSizeForAdUnit(code), + url: encodeURIComponent(location.href), + }; + + function getSizeForAdUnit(code) { + let adUnit = auctionManager.getAdUnits() + .filter((adUnit) => adUnit.code === code) + let sizes = deepAccess(adUnit[0], 'mediaTypes.video.playerSize'); + return parseSizesInput(sizes).join('|'); + } + + adpodUtils.getTargeting({ + 'codes': [code], + 'callback': createMasterTag + }); + + function createMasterTag(err, targeting) { + if (err) { + callback(err, null); + return; + } + + let initialValue = { + [adpodUtils.TARGETING_KEY_PB_CAT_DUR]: undefined, + [adpodUtils.TARGETING_KEY_CACHE_ID]: undefined + } + let customParams = {}; + if (targeting[code]) { + customParams = targeting[code].reduce((acc, curValue) => { + if (Object.keys(curValue)[0] === adpodUtils.TARGETING_KEY_PB_CAT_DUR) { + acc[adpodUtils.TARGETING_KEY_PB_CAT_DUR] = (typeof acc[adpodUtils.TARGETING_KEY_PB_CAT_DUR] !== 'undefined') ? acc[adpodUtils.TARGETING_KEY_PB_CAT_DUR] + ',' + curValue[adpodUtils.TARGETING_KEY_PB_CAT_DUR] : curValue[adpodUtils.TARGETING_KEY_PB_CAT_DUR]; + } else if (Object.keys(curValue)[0] === adpodUtils.TARGETING_KEY_CACHE_ID) { + acc[adpodUtils.TARGETING_KEY_CACHE_ID] = curValue[adpodUtils.TARGETING_KEY_CACHE_ID] + } + return acc; + }, initialValue); + } + + let encodedCustomParams = encodeURIComponent(formatQS(customParams)); + + const queryParams = Object.assign({}, + defaultParamConstants, + derivedParams, + params, + { cust_params: encodedCustomParams } + ); + + const masterTag = buildUrl({ + protocol: 'https', + host: 'pubads.g.doubleclick.net', + pathname: '/gampad/ads', + search: queryParams + }); + + callback(null, masterTag); + } +} + /** * Builds a video url from a base dfp video url and a winning bid, appending * Prebid-specific key-values. @@ -170,5 +260,9 @@ function getCustParams(bid, options) { } registerVideoSupport('dfp', { - buildVideoUrl: buildDfpVideoUrl + buildVideoUrl: buildDfpVideoUrl, + buildAdpodVideoUrl: buildAdpodVideoUrl, + getAdpodTargeting: (args) => adpodUtils.getTargeting(args) }); + +submodule('adpod', adpodUtils); diff --git a/modules/digiTrustIdSystem.js b/modules/digiTrustIdSystem.js new file mode 100644 index 00000000000..17f6fd9f737 --- /dev/null +++ b/modules/digiTrustIdSystem.js @@ -0,0 +1,363 @@ +/** + * This module adds DigiTrust ID support to the User ID module + * The {@link module:modules/userId} module is required + * If the full DigiTrust Id library is included the standard functions + * will be invoked to obtain the user's DigiTrust Id. + * When the full library is not included this will fall back to the + * DigiTrust Identity API and generate a mock DigiTrust object. + * @module modules/digiTrustIdSystem + * @requires module:modules/userId + */ + +import * as utils from '../src/utils' +import { ajax } from '../src/ajax'; +import { submodule } from '../src/hook'; + +var fallbackTimeout = 1550; // timeout value that allows userId system to execute first +var fallbackTimer = 0; // timer Id for fallback init so we don't double call + +/** + * Checks to see if the DigiTrust framework is initialized. + * @function + */ +function isInitialized() { + if (window.DigiTrust == null) { + return false; + } + return DigiTrust.isClient; // this is set to true after init +} + +/** + * Tests for presence of the DigiTrust object + * */ +function isPresent() { + return (window.DigiTrust != null); +} + +var noop = function () { +}; + +const MAX_RETRIES = 2; +const DT_ID_SVC = 'https://prebid.digitru.st/id/v1'; + +var isFunc = function (fn) { + return typeof (fn) === 'function'; +} + +function callApi(options) { + ajax( + DT_ID_SVC, + { + success: options.success, + error: options.fail + }, + null, + { + method: 'GET' + } + ); +} + +/** + * Encode the Id per DigiTrust lib + * @param {any} id + */ +function encId(id) { + try { + if (typeof (id) !== 'string') { + id = JSON.stringify(id); + } + return encodeURIComponent(btoa(id)); + } catch (ex) { + return id; + } +} + +/** + * Writes the Identity into the expected DigiTrust cookie + * @param {any} id + */ +function writeDigiId(id) { + var key = 'DigiTrust.v1.identity'; + var date = new Date(); + date.setTime(date.getTime() + 604800000); + var exp = 'expires=' + date.toUTCString(); + document.cookie = key + '=' + encId(id) + '; ' + exp + '; path=/;SameSite=none;'; +} + +/** + * Set up a DigiTrust facade object to mimic the API + * + */ +function initDigitrustFacade(config) { + var _savedId = null; // closure variable for storing Id to avoid additional requests + + clearTimeout(fallbackTimer); + fallbackTimer = 0; + + var facade = { + isClient: true, + isMock: true, + _internals: { + callCount: 0, + initCallback: null + }, + getUser: function (obj, callback) { + var isAsync = !!isFunc(callback); + var cb = isAsync ? callback : noop; + var errResp = { success: false }; + var inter = facade._internals; + inter.callCount++; + + // wrap the initializer callback, if present + var checkCallInitializeCb = function (idResponse) { + if (inter.callCount <= 1 && isFunc(inter.initCallback)) { + try { + inter.initCallback(idResponse); + } catch (ex) { + utils.logError('Exception in passed DigiTrust init callback'); + } + } + } + + if (!isMemberIdValid) { + if (!isAsync) { + return errResp + } else { + cb(errResp); + return; + } + } + + if (_savedId != null) { + checkCallInitializeCb(_savedId); + if (isAsync) { + cb(_savedId); + return; + } else { + return _savedId; + } + } + + var opts = { + success: function (respText, result) { + var idResult = { + success: true + } + try { + writeDigiId(respText); + idResult.identity = JSON.parse(respText); + _savedId = idResult; + } catch (ex) { + idResult.success = false; + } + checkCallInitializeCb(idResult); + cb(idResult); + }, + fail: function (statusErr, result) { + utils.logError('DigiTrustId API error: ' + statusErr); + } + } + + callApi(opts); + + if (!isAsync) { + return errResp; // even if it will be successful later, without a callback we report a "failure in this moment" + } + } + } + + if (config && isFunc(config.callback)) { + facade._internals.initCallback = config.callback; + } + + if (window && window.DigiTrust == null) { + window.DigiTrust = facade; + } +} + +/** + * Tests to see if a member ID is valid within facade + * @param {any} memberId + */ +var isMemberIdValid = function (memberId) { + if (memberId && memberId.length > 0) { + return true; + } else { + utils.logError('[DigiTrust Prebid Client Error] Missing member ID, add the member ID to the function call options'); + return false; + } +}; + +/** + * Encapsulation of needed info for the callback return. + * + * @param {any} opts + */ +var ResultWrapper = function (opts) { + var me = this; + this.idObj = null; + + var idSystemFn = null; + + /** + * Callback method that is passed back to the userId module. + * + * @param {function} callback + */ + this.userIdCallback = function (callback) { + idSystemFn = callback; + if (me.idObj != null && isFunc(callback)) { + callback(wrapIdResult()); + } + } + + /** + * Return a wrapped result formatted for userId system + */ + function wrapIdResult() { + if (me.idObj == null) { + return null; + } + + var cp = me.configParams; + var exp = (cp && cp.storage && cp.storage.expires) || 60; + + var rslt = { + data: null, + expires: exp + }; + if (me.idObj && me.idObj.success && me.idObj.identity) { + rslt.data = me.idObj.identity; + } else { + rslt.err = 'Failure getting id'; + } + + return rslt; + } + + this.retries = 0; + this.retryId = 0; + + this.executeIdRequest = function (configParams) { + DigiTrust.getUser({ member: 'prebid' }, function (idResult) { + me.idObj = idResult; + var cb = function () { + if (isFunc(idSystemFn)) { + idSystemFn(wrapIdResult()); + } + } + + cb(); + if (configParams && configParams.callback && isFunc(configParams.callback)) { + try { + configParams.callback(idResult); + } catch (ex) { + utils.logError('Failure in DigiTrust executeIdRequest', ex); + } + } + }); + } +} + +// An instance of the result wrapper object. +var resultHandler = new ResultWrapper(); + +/* + * Internal implementation to get the Id and trigger callback + */ +function getDigiTrustId(configParams) { + if (resultHandler.configParams == null) { + resultHandler.configParams = configParams; + } + + // First see if we should initialize DigiTrust framework + if (isPresent() && !isInitialized()) { + initializeDigiTrust(configParams); + resultHandler.retryId = setTimeout(function () { + getDigiTrustId(configParams); + }, 100 * (1 + resultHandler.retries++)); + return resultHandler.userIdCallback; + } else if (!isInitialized()) { // Second see if we should build a facade object + if (resultHandler.retries >= MAX_RETRIES) { + initDigitrustFacade(configParams); // initialize a facade object that relies on the AJAX call + resultHandler.executeIdRequest(configParams); + } else { + // use expanding envelope + if (resultHandler.retryId != 0) { + clearTimeout(resultHandler.retryId); + } + resultHandler.retryId = setTimeout(function () { + getDigiTrustId(configParams); + }, 100 * (1 + resultHandler.retries++)); + } + return resultHandler.userIdCallback; + } else { // Third get the ID + resultHandler.executeIdRequest(configParams); + return resultHandler.userIdCallback; + } +} + +function initializeDigiTrust(config) { + utils.logInfo('Digitrust Init'); + var dt = window.DigiTrust; + if (dt && !dt.isClient && config != null) { + dt.initialize(config.init, config.callback); + } else if (dt == null) { + // Assume we are already on a delay and DigiTrust is not on page + initDigitrustFacade(config); + } +} + +var testHook = {}; + +/** + * Exposes the test hook object by attaching to the digitrustIdModule. + * This method is called in the unit tests to surface internals. + */ +export function surfaceTestHook() { + digiTrustIdSubmodule['_testHook'] = testHook; + return testHook; +} + +testHook.initDigitrustFacade = initDigitrustFacade; // expose for unit tests + +/** @type {Submodule} */ +export const digiTrustIdSubmodule = { + /** + * used to link submodule with config + * @type {string} + */ + name: 'digitrust', + /** + * decode the stored id value for passing to bid requests + * @function + * @param {string} value + * @returns {{pubcid:string}} + */ + decode: function (idData) { + try { + return { 'digitrustid': idData }; + } catch (e) { + utils.logError('DigiTrust ID submodule decode error'); + } + }, + getId: getDigiTrustId, + _testInit: surfaceTestHook +}; + +// check for fallback init of DigiTrust +function fallbackInit() { + if (resultHandler.retryId == 0 && !isInitialized()) { + // this triggers an init + var conf = { + member: 'fallback', + callback: noop + }; + getDigiTrustId(conf); + } +} + +fallbackTimer = setTimeout(fallbackInit, fallbackTimeout); + +submodule('userId', digiTrustIdSubmodule); diff --git a/modules/digiTrustIdSystem.md b/modules/digiTrustIdSystem.md new file mode 100644 index 00000000000..c0b274d3292 --- /dev/null +++ b/modules/digiTrustIdSystem.md @@ -0,0 +1,156 @@ +## DigiTrust Universal Id Integration + +Setup +----- +The DigiTrust Id integration for Prebid may be used with or without the full +DigiTrust library. This is an optional module that must be used in conjunction +with the userId module. + +See the [Prebid Integration Guide for DigiTrust](https://github.com/digi-trust/dt-cdn/wiki/Prebid-Integration-for-DigiTrust-Id) +and the [DigiTrust wiki](https://github.com/digi-trust/dt-cdn/wiki) +for further instructions. + + +## Example Prebid Configuration for Digitrust Id +``` + pbjs.que.push(function() { + pbjs.setConfig({ + usersync: { + userIds: [{ + name: "digitrust", + params: { + init: { + member: 'example_member_id', + site: 'example_site_id' + }, + callback: function (digiTrustResult) { + // This callback method is optional and used for error handling + // in many if not most cases. + /* + if (digiTrustResult.success) { + // Success in Digitrust init; + // 'DigiTrust Id (encrypted): ' + digiTrustResult.identity.id; + } + else { + // Digitrust init failed + } + */ + } + }, + storage: { + type: "html5", + name: "pbjsdigitrust", + expires: 60 + } + }] + } + }); + pbjs.addAdUnits(adUnits); + pbjs.requestBids({ + bidsBackHandler: sendAdserverRequest + }); + }); + +``` + + +## Building Prebid with DigiTrust Support +Your Prebid build must include the modules for both **userId** and **digitrustIdLoader**. Follow the build instructions for Prebid as +explained in the top level README.md file of the Prebid source tree. + +ex: $ gulp build --modules=userId,digitrustIdLoader + +### Step by step Prebid build instructions for DigiTrust + +1. Download the Prebid source from [Prebid Git Repo](https://github.com/prebid/Prebid.js) +2. Set up your environment as outlined in the [Readme File](https://github.com/prebid/Prebid.js/blob/master/README.md#Build) +3. Execute the build command either with all modules or with the `userId` and `digitrustIdLoader` modules. + ``` + $ gulp build --modules=userId,digitrustIdLoader + ``` +4. (Optional) Concatenate the DigiTrust source code to the end of your `prebid.js` file for a single source distribution. +5. Upload the resulting source file to your CDN. + + +## Deploying Prebid with DigiTrust ID support +**Precondition:** You must be a DigiTrust member and have registered through the [DigiTrust Signup Process](http://www.digitru.st/signup/). +Your assigned publisher ID will be required in the configuration settings for all deployment scenarios. + +There are three supported approaches to deploying the Prebid-integrated DigiTrust package: + +* "Bare bones" deployment using only the integrated DigiTrust module code. +* Full DigiTrust with CDN referenced DigiTrust.js library. +* Full DigiTrust packaged with Prebid or site js. + +### Bare Bones Deployment + +This deployment results in the smallest Javascript package and is the simplest deployment. +It is appropriate for testing or deployments where simplicity is key. This approach +utilizes the REST API for ID generation. While there is less Javascript in use, +the user may experience more network requests than the scenarios that include the full +DigiTrust library. + +1. Build your Prebid package as above, skipping step 4. +2. Add the DigiTrust initializer section to your Prebid initialization object as below, + using your Member ID and Site ID. +3. Add a reference to your Prebid package and the initialization code on all pages you wish + to utilize Prebid with integrated DigiTrust ID. + + + + +### Full DigiTrust with CDN referenced DigiTrust library + +Both "Full DigiTrust" deployments will result in a larger initial Javascript payload. +The end user may experience fewer overall network requests as the encrypted and anonymous +DigiTrust ID can often be generated fully in client-side code. Utilizing the CDN reference +to the official DigiTrust distribution insures you will be running the latest version of the library. + +The Full DigiTrust deployment is designed to work with both new DigiTrust with Prebid deployments, and with +Prebid deployments by existing DigiTrust members. This allows you to migrate your code more slowly +without losing DigiTrust support in the process. + +1. Deploy your built copy of `prebid.js` to your CDN. +2. On each page reference both your `prebid.js` and a copy of the **DigiTrust** library. + This may either be a copy downloaded from the [DigiTrust CDN](https://cdn.digitru.st/prod/1/digitrust.min.js) to your CDN, + or directly referenced from the URL https://cdn.digitru.st/prod/1/digitrust.min.js. These may be added to the page in any order. +3. Add a configuration section for Prebid that includes the `usersync` settings and the `digitrust` settings. + +### Full DigiTrust packaged with Prebid + + +1. Deploy your built copy of `prebid.js` to your CDN. Be sure to perform *Step 4* of the build to concatenate or + integrate the full DigiTrust library code with your Prebid package. +2. On each page reference your `prebid.js` +3. Add a configuration section for Prebid that includes the `usersync` settings and the `digitrust` settings. + This code may also be appended to your Prebid package or placed in other initialization methods. + + + +## Parameter Descriptions for the `usersync` Configuration Section +The below parameters apply only to the DigiTrust ID integration. + +| Param under usersync.userIds[] | Scope | Type | Description | Example | +| --- | --- | --- | --- | --- | +| name | Required | String | ID value for the DigiTrust module - `"digitrust"` | `"digitrust"` | +| params | Required | Object | Details for DigiTrust initialization. | | +| params.init | Required | Object | Initialization parameters, including the DigiTrust Publisher ID and Site ID. | | +| params.init.member | Required | String | DigiTrust Publisher Id | "A897dTzB" | +| params.init.site | Required | String | DigiTrust Site Id | "MM2123" | +| params.callback | Optional | Function | Callback method to fire after initialization of the DigiTrust framework. The argument indicates failure and success and the identity object upon success. | | +| storage | Required | Object | The publisher must specify the local storage in which to store the results of the call to get the user ID. This can be either cookie or HTML5 storage. | | +| storage.type | Required | String | This is where the results of the user ID will be stored. The recommended method is `localStorage` by specifying `html5`. | `"html5"` | +| storage.name | Required | String | The name of the cookie or html5 local storage where the user ID will be stored. | `"pbjsdigitrust"` | +| storage.expires | Optional | Integer | How long (in days) the user ID information will be stored. Default is 30 for UnifiedId and 1825 for PubCommonID | `365` | +| value | Optional | Object | Used only if the page has a separate mechanism for storing the Unified ID. The value is an object containing the values to be sent to the adapters. In this scenario, no URL is called and nothing is added to local storage | `{"tdid": "D6885E90-2A7A-4E0F-87CB-7734ED1B99A3"}` | + + + +## Further Reading + ++ [DigiTrust Home Page](http://digitru.st) + ++ [DigiTrust integration guide](https://github.com/digi-trust/dt-cdn/wiki/Integration-Guide) + ++ [DigiTrust ID Encryption](https://github.com/digi-trust/dt-cdn/wiki/ID-encryption) + diff --git a/modules/emoteevBidAdapter.js b/modules/emoteevBidAdapter.js index 9b03b357818..db84b6ea36d 100644 --- a/modules/emoteevBidAdapter.js +++ b/modules/emoteevBidAdapter.js @@ -1,76 +1,362 @@ +/** + * This file contains Emoteev bid adpater. + * + * It is organised as follows: + * - Constants values; + * - Spec API functions, which should be pristine pure; + * - Ancillary functions, which should be as pure as possible; + * - Adapter API, where unpure side-effects happen. + * + * The code style is « functional core, imperative shell ». + * + * @link https://www.emoteev.io + * @file This files defines the spec of EmoteevBidAdapter. + * @author Emoteev Engineering . + */ + import {registerBidder} from '../src/adapters/bidderFactory'; import {BANNER} from '../src/mediaTypes'; -import * as utils from '../src/utils'; +import { + triggerPixel, + getUniqueIdentifierStr, + contains, + deepAccess, + isArray, + isInteger, + getParameterByName, + getCookie +} from '../src/utils'; import {config} from '../src/config'; +import * as url from '../src/url'; export const BIDDER_CODE = 'emoteev'; -export const AK_PBJS_VERSION = '1.35.0'; -export const EMOTEEV_BASE_URL = 'https://prebid.emoteev.io'; -export const EMOTEEV_BASE_URL_STAGING = 'https://prebid-staging.emoteev.io'; -export const EMOTEEV_BASE_URL_DEVELOPMENT = 'http://localhost:3000'; +/** + * Version number of the adapter API. + */ +export const ADAPTER_VERSION = '1.35.0'; + +export const DOMAIN = 'prebid.emoteev.io'; +export const DOMAIN_STAGING = 'prebid-staging.emoteev.io'; +export const DOMAIN_DEVELOPMENT = 'localhost:3000'; -export const ENDPOINT_PATH = '/api/prebid/bid'; -export const USER_SYNC_IFRAME_URL_PATH = '/api/prebid/sync-iframe'; -export const USER_SYNC_IMAGE_URL_PATH = '/api/prebid/sync-image'; +/** + * Path of Emoteev endpoint for events. + */ +export const EVENTS_PATH = '/api/ad_event.json'; + +/** + * Path of Emoteev bidder. + */ +export const BIDDER_PATH = '/api/prebid/bid'; +export const USER_SYNC_IFRAME_PATH = '/api/prebid/sync-iframe'; +export const USER_SYNC_IMAGE_PATH = '/api/prebid/sync-image'; export const PRODUCTION = 'production'; export const STAGING = 'staging'; export const DEVELOPMENT = 'development'; export const DEFAULT_ENV = PRODUCTION; -export const conformBidRequest = bidRequest => { +export const ON_ADAPTER_CALLED = 'on_adapter_called'; +export const ON_BID_WON = 'on_bid_won'; +export const ON_BIDDER_TIMEOUT = 'on_bidder_timeout'; + +export const IN_CONTENT = 'content'; +export const FOOTER = 'footer'; +export const OVERLAY = 'overlay'; +export const WALLPAPER = 'wallpaper'; + +/** + * Vendor ID assigned to Emoteev from the Global Vendor & CMP List. + * + * See https://vendorlist.consensu.org/vendorinfo.json for more information. + * @type {number} + */ +export const VENDOR_ID = 15; + +/** + * Pure function. See http://prebid.org/dev-docs/bidder-adaptor.html#valid-build-requests-array for detailed semantic. + * + * @param {AdUnit.bidRequest} bidRequest + * @returns {boolean} Is this bidRequest valid? + */ +export const isBidRequestValid = (bidRequest) => { + return !!( + bidRequest && + bidRequest.params && + deepAccess(bidRequest, 'params.adSpaceId') && + validateContext(deepAccess(bidRequest, 'params.context')) && + validateExternalId(deepAccess(bidRequest, 'params.externalId')) && + bidRequest.bidder === BIDDER_CODE && + validateSizes(deepAccess(bidRequest, 'mediaTypes.banner.sizes'))); +}; + +/** + * Pure function. See http://prebid.org/dev-docs/bidder-adaptor.html#serverrequest-objects for detailed semantic. + * + * @param {string} env Emoteev environment parameter + * @param {boolean} debug Pbjs debug parameter. + * @param {string} currency See http://prebid.org/dev-docs/modules/currency.html for detailed semantic. + * @param {Array} validBidRequests Takes an array of bid requests, which are guaranteed to have passed the isBidRequestValid() test. + * @param bidderRequest General context for a bidder request being constructed + * @returns {ServerRequest} + */ +export const buildRequests = (env, debug, currency, validBidRequests, bidderRequest) => { return { - params: bidRequest.params, - crumbs: bidRequest.crumbs, - sizes: bidRequest.sizes, - bidId: bidRequest.bidId, - bidderRequestId: bidRequest.bidderRequestId, + method: 'POST', + url: bidderUrl(env), + data: JSON.stringify(requestsPayload(debug, currency, validBidRequests, bidderRequest)) // Keys with undefined values will be filtered out. }; }; -export const emoteevDebug = (parameterDebug, configDebug) => { - if (parameterDebug && parameterDebug.length && parameterDebug.length > 0) return JSON.parse(parameterDebug); - else if (configDebug) return configDebug; - else return false; -}; +/** + * Pure function. See http://prebid.org/dev-docs/bidder-adaptor.html#interpreting-the-response for detailed semantic. + * + * @param {Array} serverResponse.body The body of the server response is an array of bid objects. + * @returns {Array} + */ +export const interpretResponse = (serverResponse) => serverResponse.body; -export const emoteevEnv = (parameteremoteevEnv, configemoteevEnv) => { - if (utils.contains([PRODUCTION, STAGING, DEVELOPMENT], parameteremoteevEnv)) return parameteremoteevEnv; - else if (utils.contains([PRODUCTION, STAGING, DEVELOPMENT], configemoteevEnv)) return configemoteevEnv; - else return DEFAULT_ENV; +/** + * Pure function. See http://prebid.org/dev-docs/bidder-adaptor.html#registering-on-set-targeting for detailed semantic. + * + * @param {string} env Emoteev environment parameter. + * @param {BidRequest} bidRequest + * @returns {UrlObject} + */ +export function onAdapterCalled(env, bidRequest) { + return { + protocol: 'https', + hostname: domain(env), + pathname: EVENTS_PATH, + search: { + eventName: ON_ADAPTER_CALLED, + pubcId: deepAccess(bidRequest, 'crumbs.pubcid'), + bidId: bidRequest.bidId, + adSpaceId: deepAccess(bidRequest, 'params.adSpaceId'), + cache_buster: getUniqueIdentifierStr() + } + }; +} + +/** + * Pure function. See http://prebid.org/dev-docs/bidder-adaptor.html#registering-on-bid-won for detailed semantic. + * + * @param {string} env Emoteev environment parameter. + * @param {string} pubcId Publisher common id. See http://prebid.org/dev-docs/modules/pubCommonId.html for detailed semantic. + * @param bidObject + * @returns {UrlObject} + */ +export const onBidWon = (env, pubcId, bidObject) => { + const bidId = bidObject.requestId; + return { + protocol: 'https', + hostname: domain(env), + pathname: EVENTS_PATH, + search: { + eventName: ON_BID_WON, + pubcId, + bidId, + cache_buster: getUniqueIdentifierStr() + } + }; }; -export const emoteevOverrides = (parameteremoteevOverrides, configemoteevOverrides) => { - if (parameteremoteevOverrides && parameteremoteevOverrides.length !== 0) { - let parsedParams = null; - try { - parsedParams = JSON.parse(parameteremoteevOverrides); - } catch (error) { - parsedParams = null; +/** + * Pure function. See http://prebid.org/dev-docs/bidder-adaptor.html#registering-on-timeout for detailed semantic. + * + * @param {string} env Emoteev environment parameter. + * @param {BidRequest} bidRequest + * @returns {UrlObject} + */ +export const onTimeout = (env, bidRequest) => { + return { + protocol: 'https', + hostname: domain(env), + pathname: EVENTS_PATH, + search: { + eventName: ON_BIDDER_TIMEOUT, + pubcId: deepAccess(bidRequest, 'crumbs.pubcid'), + bidId: bidRequest.bidId, + adSpaceId: deepAccess(bidRequest, 'params.adSpaceId'), + timeout: bidRequest.timeout, + cache_buster: getUniqueIdentifierStr() } - if (parsedParams) return parsedParams; } - if (configemoteevOverrides && Object.keys(configemoteevOverrides).length !== 0) return configemoteevOverrides; - else return {}; }; -export const akUrl = (environment) => { - switch (environment) { +/** + * Pure function. See http://prebid.org/dev-docs/bidder-adaptor.html#registering-user-syncs for detailed semantic. + * + * @param {string} env Emoteev environment parameter + * @param {SyncOptions} syncOptions + * @returns userSyncs + */ +export const getUserSyncs = (env, syncOptions) => { + let syncs = []; + if (syncOptions.pixelEnabled) { + syncs.push({ + type: 'image', + url: userSyncImageUrl(env), + }); + } + if (syncOptions.iframeEnabled) { + syncs.push({ + type: 'iframe', + url: userSyncIframeUrl(env), + }); + } + return syncs; +}; + +/** + * Pure function. + * + * @param {string} env Emoteev environment parameter + * @returns {string} The domain for network calls to Emoteev. + */ +export const domain = (env) => { + switch (env) { case DEVELOPMENT: - return EMOTEEV_BASE_URL_DEVELOPMENT; + return DOMAIN_DEVELOPMENT; case STAGING: - return EMOTEEV_BASE_URL_STAGING; + return DOMAIN_STAGING; default: - return EMOTEEV_BASE_URL; + return DOMAIN; } }; -export const endpointUrl = (parameteremoteevEnv, configemoteevEnv) => akUrl(emoteevEnv(parameteremoteevEnv, configemoteevEnv)).concat(ENDPOINT_PATH); -export const userSyncIframeUrl = (parameteremoteevEnv, configemoteevEnv) => akUrl(emoteevEnv(parameteremoteevEnv, configemoteevEnv)).concat(USER_SYNC_IFRAME_URL_PATH); -export const userSyncImageUrl = (parameteremoteevEnv, configemoteevEnv) => akUrl(emoteevEnv(parameteremoteevEnv, configemoteevEnv)).concat(USER_SYNC_IMAGE_URL_PATH); +/** + * Pure function. + * + * @param {string} env Emoteev environment parameter + * @returns {string} The full URL which events is sent to. + */ +export const eventsUrl = env => url.format({ + protocol: (env === DEVELOPMENT) ? 'http' : 'https', + hostname: domain(env), + pathname: EVENTS_PATH +}); + +/** + * Pure function. + * + * @param {string} env Emoteev environment parameter + * @returns {string} The full URL which bidderRequest is sent to. + */ +export const bidderUrl = env => url.format({ + protocol: (env === DEVELOPMENT) ? 'http' : 'https', + hostname: domain(env), + pathname: BIDDER_PATH +}); -export const getViewDimensions = () => { +/** + * Pure function. + * + * @param {string} env Emoteev environment parameter + * @returns {string} The full URL called for iframe-based user sync + */ +export const userSyncIframeUrl = env => url.format({ + protocol: (env === DEVELOPMENT) ? 'http' : 'https', + hostname: domain(env), + pathname: USER_SYNC_IFRAME_PATH +}); + +/** + * Pure function. + * + * @param {string} env Emoteev environment parameter + * @returns {string} The full URL called for image-based user sync + */ +export const userSyncImageUrl = env => url.format({ + protocol: (env === DEVELOPMENT) ? 'http' : 'https', + hostname: domain(env), + pathname: USER_SYNC_IMAGE_PATH +}); + +/** + * Pure function. + * + * @param {Array>} sizes + * @returns {boolean} are sizes valid? + */ +export const validateSizes = sizes => isArray(sizes) && sizes.length > 0 && sizes.every(size => isArray(size) && size.length === 2); + +/** + * Pure function. + * + * @param {string} context + * @returns {boolean} is param `context` valid? + */ +export const validateContext = context => contains([IN_CONTENT, FOOTER, OVERLAY, WALLPAPER], context); + +/** + * Pure function. + * + * @param {(number|null|undefined)} externalId + * @returns {boolean} is param `externalId` valid? + */ +export const validateExternalId = externalId => externalId === undefined || externalId === null || (isInteger(externalId) && externalId > 0); + +/** + * Pure function. + * + * @param {BidRequest} bidRequest + * @returns {object} An object which represents a BidRequest for Emoteev server side. + */ +export const conformBidRequest = bidRequest => { + return { + params: bidRequest.params, + crumbs: bidRequest.crumbs, + sizes: bidRequest.sizes, + bidId: bidRequest.bidId, + bidderRequestId: bidRequest.bidderRequestId, + }; +}; + +/** + * Pure function. + * + * @param {object} bidderRequest + * @returns {(boolean|undefined)} raw consent data. + */ +export const gdprConsent = (bidderRequest) => (deepAccess(bidderRequest, 'gdprConsent.vendorData.vendorConsents') || {})[VENDOR_ID]; + +/** + * Pure function. + * + * @param {boolean} debug Pbjs debug parameter + * @param {string} currency See http://prebid.org/dev-docs/modules/currency.html for detailed information + * @param {BidRequest} validBidRequests + * @param {object} bidderRequest + * @returns + */ +export const requestsPayload = (debug, currency, validBidRequests, bidderRequest) => { + return { + akPbjsVersion: ADAPTER_VERSION, + bidRequests: validBidRequests.map(conformBidRequest), + currency: currency, + debug: debug, + language: navigator.language, + refererInfo: bidderRequest.refererInfo, + deviceInfo: getDeviceInfo( + getDeviceDimensions(window), + getViewDimensions(window, document), + getDocumentDimensions(document), + isWebGLEnabled(document)), + userAgent: navigator.userAgent, + gdprApplies: deepAccess(bidderRequest, 'gdprConsent.gdprApplies'), + gdprConsent: gdprConsent(bidderRequest), + }; +}; + +/** + * Pure function + * @param {Window} window + * @param {Document} document + * @returns {{width: number, height: number}} View dimensions + */ +export const getViewDimensions = (window, document) => { let w = window; let prefix = 'inner'; @@ -85,14 +371,24 @@ export const getViewDimensions = () => { }; }; -export const getDeviceDimensions = () => { +/** + * Pure function + * @param {Window} window + * @returns {{width: number, height: number}} Device dimensions + */ +export const getDeviceDimensions = (window) => { return { width: window.screen ? window.screen.width : '', height: window.screen ? window.screen.height : '', }; }; -export const getDocumentDimensions = () => { +/** + * Pure function + * @param {Document} document + * @returns {{width: number, height: number}} Document dimensions + */ +export const getDocumentDimensions = (document) => { const de = document.documentElement; const be = document.body; @@ -112,7 +408,12 @@ export const getDocumentDimensions = () => { }; }; -export const isWebGLEnabled = () => { +/** + * Unpure function + * @param {Document} document + * @returns {boolean} Is WebGL enabled? + */ +export const isWebGLEnabled = (document) => { // Create test canvas let canvas = document.createElement('canvas'); @@ -141,6 +442,14 @@ export const isWebGLEnabled = () => { return !!gl; }; +/** + * Pure function + * @param {{width: number, height: number}} deviceDimensions + * @param {{width: number, height: number}} viewDimensions + * @param {{width: number, height: number}} documentDimensions + * @param {boolean} webGL + * @returns {object} Device information + */ export const getDeviceInfo = (deviceDimensions, viewDimensions, documentDimensions, webGL) => { return { browserWidth: viewDimensions.width, @@ -153,62 +462,62 @@ export const getDeviceInfo = (deviceDimensions, viewDimensions, documentDimensio }; }; -const validateSizes = sizes => utils.isArray(sizes) && sizes.some(size => utils.isArray(size) && size.length === 2); +/** + * Pure function + * @param {object} config pbjs config value + * @param {string} parameter Environment override from URL query param. + * @returns {string} One of [PRODUCTION, STAGING, DEVELOPMENT]. + */ +export const resolveEnv = (config, parameter) => { + const configEnv = deepAccess(config, 'emoteev.env'); + + if (contains([PRODUCTION, STAGING, DEVELOPMENT], parameter)) return parameter; + else if (contains([PRODUCTION, STAGING, DEVELOPMENT], configEnv)) return configEnv; + else return DEFAULT_ENV; +}; +/** + * Pure function + * @param {object} config pbjs config value + * @param {string} parameter Debug override from URL query param. + * @returns {boolean} + */ +export const resolveDebug = (config, parameter) => { + if (parameter && parameter.length && parameter.length > 0) return JSON.parse(parameter); + else if (config.debug) return config.debug; + else return false; +}; + +/** + * EmoteevBidAdapter spec + * @access public + * @type {BidderSpec} + */ export const spec = { code: BIDDER_CODE, supportedMediaTypes: [BANNER], - - isBidRequestValid: (bid) => { - return !!( - bid && - bid.params && - bid.params.adSpaceId && - bid.bidder === BIDDER_CODE && - validateSizes(bid.mediaTypes.banner.sizes) - ); - }, - - buildRequests: (validBidRequests, bidderRequest) => { - const payload = Object.assign({}, - { - akPbjsVersion: AK_PBJS_VERSION, - bidRequests: validBidRequests.map(conformBidRequest), - currency: config.getConfig('currency'), - debug: emoteevDebug(utils.getParameterByName('emoteevDebug'), config.getConfig('emoteev.debug')), - language: navigator.language, - refererInfo: bidderRequest.refererInfo, - deviceInfo: getDeviceInfo(getDeviceDimensions(), getViewDimensions(), getDocumentDimensions(), isWebGLEnabled()), - userAgent: navigator.userAgent, - }, - emoteevOverrides(utils.getParameterByName('emoteevOverrides'), config.getConfig('emoteev.overrides'))); - - return { - method: 'POST', - url: endpointUrl(utils.getParameterByName('emoteevEnv'), config.getConfig('emoteev.env')), - data: JSON.stringify(payload), - }; - }, - - interpretResponse: (serverResponse) => serverResponse.body, - - getUserSyncs: (syncOptions, serverResponses) => { - const parameteremoteevEnv = utils.getParameterByName('emoteev.env'); - const configemoteevEnv = config.getConfig('emoteev.env'); - const syncs = []; - if (syncOptions.iframeEnabled) { - syncs.push({ - type: 'iframe', - url: userSyncIframeUrl(parameteremoteevEnv, configemoteevEnv), - }); - } - if (syncOptions.pixelEnabled && serverResponses.length > 0) { - syncs.push({ - type: 'image', - url: userSyncImageUrl(parameteremoteevEnv, configemoteevEnv), - }); - } - return syncs; - }, + isBidRequestValid: isBidRequestValid, + buildRequests: (validBidRequests, bidderRequest) => + buildRequests( + resolveEnv(config.getConfig(), getParameterByName('emoteevEnv')), + resolveDebug(config.getConfig(), getParameterByName('debug')), + config.getConfig('currency'), + validBidRequests, + bidderRequest), + interpretResponse: interpretResponse, + onBidWon: (bidObject) => + triggerPixel(url.format(onBidWon( + resolveEnv(config.getConfig(), getParameterByName('emoteevEnv')), + getCookie('_pubcid'), + bidObject))), + onTimeout: (bidRequest) => + triggerPixel(url.format(onTimeout( + resolveEnv(config.getConfig(), getParameterByName('emoteevEnv')), + bidRequest))), + getUserSyncs: (syncOptions) => + getUserSyncs( + resolveEnv(config.getConfig(), getParameterByName('emoteevEnv')), + syncOptions), }; + registerBidder(spec); diff --git a/modules/emokteevBidAdapter.md b/modules/emoteevBidAdapter.md similarity index 76% rename from modules/emokteevBidAdapter.md rename to modules/emoteevBidAdapter.md index 88b0b21a96f..226a8374369 100644 --- a/modules/emokteevBidAdapter.md +++ b/modules/emoteevBidAdapter.md @@ -18,14 +18,16 @@ Module that connects to Emoteev's demand sources code: 'test-div', mediaTypes: { banner: { - sizes: [[300, 250]], + sizes: [[720, 90]], } }, bids: [ { bidder: 'emoteev', params: { - adSpaceId: 5084 + adSpaceId: 5084, + context: 'footer', + externalId: 42, } } ] diff --git a/modules/emx_digitalBidAdapter.js b/modules/emx_digitalBidAdapter.js index c42f98d4751..12f3482184b 100644 --- a/modules/emx_digitalBidAdapter.js +++ b/modules/emx_digitalBidAdapter.js @@ -1,82 +1,134 @@ import * as utils from '../src/utils'; -import { - registerBidder -} from '../src/adapters/bidderFactory'; -import { - BANNER -} from '../src/mediaTypes'; -import { - config -} from '../src/config'; +import { registerBidder } from '../src/adapters/bidderFactory'; +import { BANNER, VIDEO } from '../src/mediaTypes'; +import { Renderer } from '../src/Renderer'; +import includes from 'core-js/library/fn/array/includes'; const BIDDER_CODE = 'emx_digital'; const ENDPOINT = 'hb.emxdgt.com'; +const RENDERER_URL = '//js.brealtime.com/outstream/1.30.0/bundle.js'; +const ADAPTER_VERSION = '1.41.0'; +const DEFAULT_CUR = 'USD'; -let emxAdapter = {}; - -emxAdapter.validateSizes = function(sizes) { - if (!utils.isArray(sizes) || typeof sizes[0] === 'undefined') { - return false; - } - return sizes.every(size => utils.isArray(size) && size.length === 2); -} - -export const spec = { - code: BIDDER_CODE, - supportedMediaTypes: [BANNER], - isBidRequestValid: function (bid) { - return !!bid.params.tagid && - typeof bid.params.tagid === 'string' && - (typeof bid.params.bidfloor === 'undefined' || typeof bid.params.bidfloor === 'string') && - bid.bidder === BIDDER_CODE && - (emxAdapter.validateSizes(bid.mediaTypes.banner.sizes) || emxAdapter.validateSizes(bid.sizes)); - }, - buildRequests: function (validBidRequests, bidRequests) { - const {host, href, protocol} = utils.getTopWindowLocation(); - let emxData = {}; - let emxImps = []; - const auctionId = bidRequests.auctionId; - const timeout = config.getConfig('bidderTimeout'); - const timestamp = Date.now(); - const url = location.protocol + '//' + ENDPOINT + ('?t=' + timeout + '&ts=' + timestamp); - const networkProtocol = protocol.indexOf('https') > -1 ? 1 : 0; - - utils._each(validBidRequests, function (bid) { - let tagId = utils.getBidIdParameter('tagid', bid.params); - let bidFloor = parseFloat(utils.getBidIdParameter('bidfloor', bid.params)) || 0; - let sizes = bid.mediaTypes.banner.sizes; - if (!emxAdapter.validateSizes(sizes)) { - sizes = bid.sizes - } - let emxBid = { - id: bid.bidId, - tid: bid.transactionId, - tagid: tagId, - secure: networkProtocol, - banner: { - format: sizes.map(function (size) { - return { - w: size[0], - h: size[1] - }; - }), - w: sizes[0][0], - h: sizes[0][1] - } - } - if (bidFloor > 0) { - emxBid.bidfloor = bidFloor +export const emxAdapter = { + validateSizes: (sizes) => { + if (!utils.isArray(sizes) || typeof sizes[0] === 'undefined') { + utils.logWarn(BIDDER_CODE + ': Sizes should be an array'); + return false; + } + return sizes.every(size => utils.isArray(size) && size.length === 2); + }, + checkVideoContext: (bid) => { + return ((bid && bid.mediaTypes && bid.mediaTypes.video && bid.mediaTypes.video.context) && ((bid.mediaTypes.video.context === 'instream') || (bid.mediaTypes.video.context === 'outstream'))); + }, + buildBanner: (bid) => { + let sizes = []; + bid.mediaTypes && bid.mediaTypes.banner && bid.mediaTypes.banner.sizes ? sizes = bid.mediaTypes.banner.sizes : sizes = bid.sizes; + if (!emxAdapter.validateSizes(sizes)) { + utils.logWarn(BIDDER_CODE + ': could not detect mediaType banner sizes. Assigning to bid sizes instead'); + sizes = bid.sizes + } + return { + format: sizes.map((size) => { + return { + w: size[0], + h: size[1] + }; + }), + w: sizes[0][0], + h: sizes[0][1] + }; + }, + formatVideoResponse: (bidResponse, emxBid, bidRequest) => { + bidResponse.vastXml = emxBid.adm; + if (bidRequest.bidRequest && bidRequest.bidRequest.mediaTypes && bidRequest.bidRequest.mediaTypes.video && bidRequest.bidRequest.mediaTypes.video.context === 'outstream') { + bidResponse.renderer = emxAdapter.createRenderer(bidResponse, { + id: emxBid.id, + url: RENDERER_URL + }); + } + return bidResponse; + }, + isMobile: () => { + return (/(ios|ipod|ipad|iphone|android)/i).test(navigator.userAgent); + }, + isConnectedTV: () => { + return (/(smart[-]?tv|hbbtv|appletv|googletv|hdmi|netcast\.tv|viera|nettv|roku|\bdtv\b|sonydtv|inettvbrowser|\btv\b)/i).test(navigator.userAgent); + }, + getDevice: () => { + return { + ua: navigator.userAgent, + js: 1, + dnt: (navigator.doNotTrack === 'yes' || navigator.doNotTrack === '1' || navigator.msDoNotTrack === '1') ? 1 : 0, + h: screen.height, + w: screen.width, + devicetype: emxAdapter.isMobile() ? 1 : emxAdapter.isConnectedTV() ? 3 : 2, + language: (navigator.language || navigator.browserLanguage || navigator.userLanguage || navigator.systemLanguage), + }; + }, + cleanProtocols: (video) => { + if (video.protocols && includes(video.protocols, 7)) { + // not supporting VAST protocol 7 (VAST 4.0); + utils.logWarn(BIDDER_CODE + ': VAST 4.0 is currently not supported. This protocol has been filtered out of the request.'); + video.protocols = video.protocols.filter(protocol => protocol !== 7); + } + return video; + }, + outstreamRender: (bid) => { + bid.renderer.push(function () { + let params = (bid && bid.params && bid.params[0] && bid.params[0].video) ? bid.params[0].video : {}; + window.emxVideoQueue = window.emxVideoQueue || []; + window.queueEmxVideo({ + id: bid.adUnitCode, + adsResponses: bid.vastXml, + options: params + }); + if (window.emxVideoReady && window.videojs) { + window.emxVideoReady(); } - emxImps.push(emxBid); }); - emxData = { - id: auctionId, - imp: emxImps, - site: { - domain: host, - page: href - } - }; + }, + createRenderer: (bid, rendererParams) => { + const renderer = Renderer.install({ + id: rendererParams.id, + url: RENDERER_URL, + loaded: false + }); + try { + renderer.setRender(emxAdapter.outstreamRender); + } catch (err) { + utils.logWarn('Prebid Error calling setRender on renderer', err); + } + + return renderer; + }, + buildVideo: (bid) => { + let videoObj = Object.assign(bid.mediaTypes.video, bid.params.video); + + if (utils.isArray(bid.mediaTypes.video.playerSize[0])) { + videoObj['w'] = bid.mediaTypes.video.playerSize[0][0]; + videoObj['h'] = bid.mediaTypes.video.playerSize[0][1]; + } else { + videoObj['w'] = bid.mediaTypes.video.playerSize[0]; + videoObj['h'] = bid.mediaTypes.video.playerSize[1]; + } + return emxAdapter.cleanProtocols(videoObj); + }, + parseResponse: (bidResponseAdm) => { + try { + return decodeURIComponent(bidResponseAdm); + } catch (err) { + utils.logError('emx_digitalBidAdapter', 'error', err); + } + }, + getReferrer: () => { + try { + return window.top.document.referrer; + } catch (err) { + return document.referrer; + } + }, + getGdpr: (bidRequests, emxData) => { if (bidRequests.gdprConsent) { emxData.regs = { ext: { @@ -91,22 +143,112 @@ export const spec = { } }; } + + return emxData; + } +}; + +export const spec = { + code: BIDDER_CODE, + supportedMediaTypes: [BANNER, VIDEO], + isBidRequestValid: function (bid) { + if (!bid || !bid.params) { + utils.logWarn(BIDDER_CODE + ': Missing bid or bid params.'); + return false; + } + + if (bid.bidder !== BIDDER_CODE) { + utils.logWarn(BIDDER_CODE + ': Must use "emx_digital" as bidder code.'); + return false; + } + + if (!bid.params.tagid || !utils.isStr(bid.params.tagid)) { + utils.logWarn(BIDDER_CODE + ': Missing tagid param or tagid present and not type String.'); + return false; + } + + if (bid.mediaTypes && bid.mediaTypes.banner) { + let sizes; + bid.mediaTypes.banner.sizes ? sizes = bid.mediaTypes.banner.sizes : sizes = bid.sizes; + if (!emxAdapter.validateSizes(sizes)) { + utils.logWarn(BIDDER_CODE + ': Missing sizes in bid'); + return false; + } + } else if (bid.mediaTypes && bid.mediaTypes.video) { + if (!emxAdapter.checkVideoContext(bid)) { + utils.logWarn(BIDDER_CODE + ': Missing video context: instream or outstream'); + return false; + } + + if (!bid.mediaTypes.video.playerSize) { + utils.logWarn(BIDDER_CODE + ': Missing video playerSize'); + return false; + } + } + + return true; + }, + buildRequests: function (validBidRequests, bidRequest) { + const emxImps = []; + const timeout = bidRequest.timeout || ''; + const timestamp = Date.now(); + const url = location.protocol + '//' + ENDPOINT + ('?t=' + timeout + '&ts=' + timestamp + '&src=pbjs'); + const secure = location.protocol.indexOf('https') > -1 ? 1 : 0; + const domain = utils.getTopWindowLocation().hostname; + const page = bidRequest.refererInfo.referer; + const device = emxAdapter.getDevice(); + const ref = emxAdapter.getReferrer(); + + utils._each(validBidRequests, function (bid) { + let tagid = utils.getBidIdParameter('tagid', bid.params); + let bidfloor = parseFloat(utils.getBidIdParameter('bidfloor', bid.params)) || 0; + let isVideo = !!bid.mediaTypes.video; + let data = { + id: bid.bidId, + tid: bid.transactionId, + tagid, + secure + }; + let typeSpecifics = isVideo ? { video: emxAdapter.buildVideo(bid) } : { banner: emxAdapter.buildBanner(bid) }; + let bidfloorObj = bidfloor > 0 ? { bidfloor, bidfloorcur: DEFAULT_CUR } : {}; + let emxBid = Object.assign(data, typeSpecifics, bidfloorObj); + + emxImps.push(emxBid); + }); + + let emxData = { + id: bidRequest.auctionId, + imp: emxImps, + device, + site: { + domain, + page, + ref + }, + cur: DEFAULT_CUR, + version: ADAPTER_VERSION + }; + + emxData = emxAdapter.getGdpr(bidRequest, Object.assign({}, emxData)); return { method: 'POST', url: url, data: JSON.stringify(emxData), options: { withCredentials: true - } + }, + bidRequest }; }, - interpretResponse: function (serverResponse) { + interpretResponse: function (serverResponse, bidRequest) { let emxBidResponses = []; let response = serverResponse.body || {}; if (response.seatbid && response.seatbid.length > 0 && response.seatbid[0].bid) { response.seatbid.forEach(function (emxBid) { emxBid = emxBid.bid[0]; - emxBidResponses.push({ + let isVideo = false; + let adm = emxAdapter.parseResponse(emxBid.adm) || ''; + let bidResponse = { requestId: emxBid.id, cpm: emxBid.price, width: emxBid.w, @@ -115,10 +257,15 @@ export const spec = { dealId: emxBid.dealid || null, currency: 'USD', netRevenue: true, - mediaType: BANNER, - ad: decodeURIComponent(emxBid.adm), - ttl: emxBid.ttl - }); + ttl: emxBid.ttl, + ad: adm + }; + if (emxBid.adm && emxBid.adm.indexOf(' -1) { + isVideo = true; + bidResponse = emxAdapter.formatVideoResponse(bidResponse, Object.assign({}, emxBid), bidRequest); + } + bidResponse.mediaType = (isVideo ? VIDEO : BANNER); + emxBidResponses.push(bidResponse); }); } return emxBidResponses; @@ -131,12 +278,6 @@ export const spec = { url: '//biddr.brealtime.com/check.html' }); } - if (syncOptions.pixelEnabled) { - syncs.push({ - type: 'image', - url: '//edba.brealtime.com/' - }); - } return syncs; } }; diff --git a/modules/emx_digitalBidAdapter.md b/modules/emx_digitalBidAdapter.md index c9435e2f1d1..03ba554c5ad 100644 --- a/modules/emx_digitalBidAdapter.md +++ b/modules/emx_digitalBidAdapter.md @@ -8,7 +8,7 @@ Maintainer: git@emxdigital.com # Description -The EMX Digital adapter provides publishers with access to the EMX Marketplace. The adapter is GDPR compliant. Please note that the adapter supports Banner media type only. +The EMX Digital adapter provides publishers with access to the EMX Marketplace. The adapter is GDPR compliant. Please note that the adapter supports Banner and Video (Instream & Outstream) media types. Note: The EMX Digital adapter requires approval and implementation guidelines from the EMX team, including existing publishers that work with EMX Digital. Please reach out to your account manager or prebid@emxdigital.com for more information. @@ -23,7 +23,7 @@ var adUnits = [{ code: 'banner-div', mediaTypes: { banner: { - sizes: [ + sizes: [ [300, 250], [300, 600] } }, @@ -36,3 +36,27 @@ var adUnits = [{ }] }]; ``` + +# Video Example +``` +var adUnits = [{ + code: 'video-div', + mediaTypes: { + video: { + context: 'instream', // also applicable for 'outstream' + playerSize: [640, 480] + } + }, + bids: [ + { + bidder: 'emx_digital', + params: { + tagid: '25251', + video: { + skippable: true, + playback_methods: ['auto_play_sound_off'] + } + } + }] +}]; +``` diff --git a/modules/eywamediaBidAdapter.js b/modules/eywamediaBidAdapter.js new file mode 100644 index 00000000000..543775dc3aa --- /dev/null +++ b/modules/eywamediaBidAdapter.js @@ -0,0 +1,181 @@ +import * as utils from '../src/utils'; +import { registerBidder } from '../src/adapters/bidderFactory'; + +const BIDDER_CODE = 'eywamedia'; +const CURRENCY = 'USD'; +const VERSION = '1.0.0'; +const TIME_TO_LIVE = 360; +const NET_REVENUE = true; +const COOKIE_NAME = 'emaduuid'; +const UUID_LEN = 36; +const SERVER_ENDPOINT = 'https://adtarbostg.eywamedia.com/auctions/prebidjs/3000'; +const localWindow = getTopWindow(); + +export const spec = { + code: BIDDER_CODE, + supportedMediaTypes: ['banner'], + /** + * Determines whether or not the given bid request is valid. + * @param {object} bid, bid to validate + * @return boolean, true if valid, otherwise false + */ + isBidRequestValid: function(bid) { + return !!(bid.params.publisherId); + }, + /** + * Make a server request from the list of BidRequests. + * + * @param {BidRequest[]} bidRequests A non-empty list of bid requests which should be sent to the Server. + * @return requestPayload Info describing the request to the server. + */ + buildRequests: function(bidRequests, bidRequest) { + const device = getDeviceInfo(); + const site = getSiteInfo(); + const user = getUserInfo(); + + let requestPayload = { + id: utils.generateUUID(), + publisherId: bidRequests[0].params.publisherId, + device: device, + site: site, + user: user, + bidPayload: bidRequests, + cacheBust: new Date().getTime().toString(), + adapterVersion: VERSION, + tmax: bidRequest.timeout + }; + + return { + method: 'POST', + url: SERVER_ENDPOINT, + options: { + contentType: 'application/json' + }, + data: requestPayload + } + }, + + /** + * Makes Eywamedia Ad Server response compatible to Prebid specs + * @param serverResponse successful response from Ad Server + * @param bidderRequest original bidRequest + * @return {Bid[]} an array of bids + */ + interpretResponse: function (serverResponse, bidRequest) { + var bidObject, response; + var bidRespones = []; + var responses = serverResponse.body; + for (var i = 0; i < responses.length; i++) { + response = responses[i]; + bidObject = { + requestId: response.bidId, + cpm: response.cpm, + width: parseInt(response.width), + height: parseInt(response.height), + creativeId: response.bidId, + currency: CURRENCY, + netRevenue: NET_REVENUE, + ttl: TIME_TO_LIVE, + ad: response.ad, + bidderCode: BIDDER_CODE, + transactionId: response.transactionId, + mediaType: response.respType, + }; + bidRespones.push(bidObject); + } + return bidRespones; + } +} +registerBidder(spec); + +/*************************************** + * Helper Functions + ***************************************/ + +/** + * get device type + */ +function getDeviceType() { + let ua = navigator.userAgent; + // Tablets must be checked before phones. + if ((/(tablet|ipad|playbook|silk)|(android(?!.*mobi))/i).test(ua)) { + return 5; // "Tablet" + } + if ((/Mobile|iP(hone|od|ad)|Android|BlackBerry|IEMobile|Kindle|NetFront|Silk-Accelerated|(hpw|web)OS|Fennec|Minimo|Opera M(obi|ini)|Blazer|Dolfin|Dolphin|Skyfire|Zune/).test(ua)) { + return 4; // "Phone" + } + return 2; // Personal Computers +}; + +/** + * get device info + */ +function getDeviceInfo() { + const language = navigator.language; + return { + ua: navigator.userAgent, + language: navigator[language], + devicetype: getDeviceType(), + dnt: utils.getDNT(), + geo: {}, + js: 1 + }; +}; + +/** + * get site info + */ +function getSiteInfo() { + const topLocation = utils.getTopWindowLocation(); + return { + domain: topLocation.hostname, + page: topLocation.href, + referrer: utils.getTopWindowReferrer(), + desc: getPageDescription(), + title: localWindow.document.title, + }; +}; + +/** + * get user info + */ +function getUserInfo() { + return { + id: getUserID(), + }; +}; + +/** + * get user Id + */ +const getUserID = () => { + const i = document.cookie.indexOf(COOKIE_NAME); + + if (i === -1) { + const uuid = utils.generateUUID(); + document.cookie = `${COOKIE_NAME}=${uuid}; path=/`; + return uuid; + } + + const j = i + COOKIE_NAME.length + 1; + return document.cookie.substring(j, j + UUID_LEN); +}; + +/** + * get page description + */ +function getPageDescription() { + if (document.querySelector('meta[name="description"]')) { + return document.querySelector('meta[name="description"]').getAttribute('content'); // Value of the description metadata from the publisher's page. + } else { + return ''; + } +}; + +function getTopWindow() { + try { + return window.top; + } catch (e) { + return window; + } +}; diff --git a/modules/eywamediaBidAdapter.md b/modules/eywamediaBidAdapter.md new file mode 100644 index 00000000000..76b9b032c1b --- /dev/null +++ b/modules/eywamediaBidAdapter.md @@ -0,0 +1,37 @@ +# Overview + +``` +Module Name: Eywamedia Bid Adapter +Module Type: Bidder Adapter +Maintainer: sharath@eywamedia.com +Note: Our ads will only render in mobile and desktop +``` + +# Description + +Connects to Eywamedia Ad Server for bids. + +Eywamedia bid adapter supports Banners. + +# Test Parameters +``` +var adUnits = [ + // Banner adUnit + { + code: 'div-gpt-ad-1460505748561-0', + sizes: [[300, 250], [300,600]], + bids: [{ + bidder: 'eywamedia', + params: { + publisherId: 'f63a2362-5aa4-4829-bbd2-2678ced8b63e', //Required - GUID (may include numbers and characters) + bidFloor: 0.50, // optional + cats: ["iab1-1","iab23-2"], // optional + keywords: ["sports", "cricket"], // optional + lat: 12.33333, // optional + lon: 77.32322, // optional + locn: "country$region$city$zip" // optional + } + }] + } +]; +``` diff --git a/modules/fairtradeBidAdapter.md b/modules/fairtradeBidAdapter.md old mode 100755 new mode 100644 diff --git a/modules/feedadBidAdapter.js b/modules/feedadBidAdapter.js new file mode 100644 index 00000000000..1e995ee8914 --- /dev/null +++ b/modules/feedadBidAdapter.js @@ -0,0 +1,290 @@ +import * as utils from '../src/utils'; +import {registerBidder} from '../src/adapters/bidderFactory'; +import {BANNER, VIDEO} from '../src/mediaTypes'; +import {ajax} from '../src/ajax'; + +/** + * Version of the FeedAd bid adapter + * @type {string} + */ +const VERSION = '1.0.0'; + +/** + * @typedef {object} FeedAdApiBidRequest + * @inner + * + * @property {number} ad_type + * @property {string} client_token + * @property {string} placement_id + * @property {string} sdk_version + * @property {boolean} app_hybrid + * + * @property {string} [app_bundle_id] + * @property {string} [app_name] + * @property {object} [custom_params] + * @property {number} [connectivity] + * @property {string} [device_adid] + * @property {string} [device_platform] + */ + +/** + * @typedef {object} FeedAdApiBidResponse + * @inner + * + * @property {string} ad - Ad HTML payload + * @property {number} cpm - number / float + * @property {string} creativeId - ID of creative for tracking + * @property {string} currency - 3-letter ISO 4217 currency-code + * @property {number} height - Height of creative returned in [].ad + * @property {boolean} netRevenue - Is the CPM net (true) or gross (false)? + * @property {string} requestId - bids[].bidId + * @property {number} ttl - Time to live for this ad + * @property {number} width - Width of creative returned in [].ad + */ + +/** + * @typedef {object} FeedAdApiTrackingParams + * @inner + * + * @property app_hybrid {boolean} + * @property client_token {string} + * @property klass {'prebid_bidWon'|'prebid_bidTimeout'} + * @property placement_id {string} + * @property prebid_auction_id {string} + * @property prebid_bid_id {string} + * @property prebid_transaction_id {string} + * @property referer {string} + * @property sdk_version {string} + * @property [app_bundle_id] {string} + * @property [app_name] {string} + * @property [device_adid] {string} + * @property [device_platform] {1|2|3} 1 - Android | 2 - iOS | 3 - Windows + */ + +/** + * Bidder network identity code + * @type {string} + */ +const BIDDER_CODE = 'feedad'; + +/** + * The media types supported by FeedAd + * @type {MediaType[]} + */ +const MEDIA_TYPES = [VIDEO, BANNER]; + +/** + * Tag for logging + * @type {string} + */ +const TAG = '[FeedAd]'; + +/** + * Pattern for valid placement IDs + * @type {RegExp} + */ +const PLACEMENT_ID_PATTERN = /^[a-z0-9][a-z0-9_-]+[a-z0-9]$/; + +const API_ENDPOINT = 'https://api.feedad.com'; +const API_PATH_BID_REQUEST = '/1/prebid/web/bids'; +const API_PATH_TRACK_REQUEST = '/1/prebid/web/events'; + +/** + * Stores temporary auction metadata + * @type {Object.} + */ +const BID_METADATA = {}; + +/** + * Checks if the bid is compatible with FeedAd. + * + * @param {BidRequest} bid - the bid to check + * @return {boolean} true if the bid is valid + */ +function isBidRequestValid(bid) { + const clientToken = utils.deepAccess(bid, 'params.clientToken'); + if (!clientToken || !isValidClientToken(clientToken)) { + utils.logWarn(TAG, "missing or invalid parameter 'clientToken'. found value:", clientToken); + return false; + } + + const placementId = utils.deepAccess(bid, 'params.placementId'); + if (!placementId || !isValidPlacementId(placementId)) { + utils.logWarn(TAG, "missing or invalid parameter 'placementId'. found value:", placementId); + return false; + } + + return true; +} + +/** + * Checks if a client token is valid + * @param {string} clientToken - the client token + * @return {boolean} true if the token is valid + */ +function isValidClientToken(clientToken) { + return typeof clientToken === 'string' && clientToken.length > 0; +} + +/** + * Checks if the given placement id is of a correct format. + * Valid IDs are words of lowercase letters from a to z and numbers from 0 to 9. + * The words can be separated by hyphens or underscores. + * Multiple separators must not follow each other. + * The whole placement ID must not be larger than 256 characters. + * + * @param placementId - the placement id to verify + * @returns if the placement ID is valid. + */ +function isValidPlacementId(placementId) { + return typeof placementId === 'string' && + placementId.length > 0 && + placementId.length <= 256 && + PLACEMENT_ID_PATTERN.test(placementId); +} + +/** + * Checks if the given media types contain unsupported settings + * @param {MediaTypes} mediaTypes - the media types to check + * @return {MediaTypes} the unsupported settings, empty when all types are supported + */ +function filterSupportedMediaTypes(mediaTypes) { + return { + banner: mediaTypes.banner, + video: mediaTypes.video && mediaTypes.video.context === 'outstream' ? mediaTypes.video : undefined, + native: undefined + }; +} + +/** + * Checks if the given media types are empty + * @param {MediaTypes} mediaTypes - the types to check + * @return {boolean} true if the types are empty + */ +function isMediaTypesEmpty(mediaTypes) { + return Object.keys(mediaTypes).every(type => mediaTypes[type] === undefined); +} + +/** + * Creates the bid request params the api expects from the prebid bid request + * @param {BidRequest} request - the validated prebid bid request + * @return {FeedAdApiBidRequest} + */ +function createApiBidRParams(request) { + return { + ad_type: 0, + client_token: request.params.clientToken, + placement_id: request.params.placementId, + sdk_version: `prebid_${VERSION}`, + app_hybrid: false, + }; +} + +/** + * Builds the bid request to the FeedAd Server + * @param {BidRequest[]} validBidRequests - all validated bid requests + * @param {object} bidderRequest - meta information + * @return {ServerRequest|ServerRequest[]} + */ +function buildRequests(validBidRequests, bidderRequest) { + if (!bidderRequest) { + return []; + } + let acceptableRequests = validBidRequests.filter(request => !isMediaTypesEmpty(filterSupportedMediaTypes(request.mediaTypes))); + if (acceptableRequests.length === 0) { + return []; + } + let data = Object.assign({}, bidderRequest, { + bids: acceptableRequests.map(req => { + req.params = createApiBidRParams(req); + return req; + }) + }); + data.bids.forEach(bid => BID_METADATA[bid.bidId] = { + referer: data.refererInfo.referer, + transactionId: bid.transactionId + }); + return { + method: 'POST', + url: `${API_ENDPOINT}${API_PATH_BID_REQUEST}`, + data, + options: { + contentType: 'application/json' + } + }; +} + +/** + * Adapts the FeedAd server response to Prebid format + * @param {ServerResponse} serverResponse - the FeedAd server response + * @param {BidRequest} request - the initial bid request + * @returns {Bid[]} the FeedAd bids + */ +function interpretResponse(serverResponse, request) { + /** + * @type FeedAdApiBidResponse[] + */ + return typeof serverResponse.body === 'string' ? JSON.parse(serverResponse.body) : serverResponse.body; +} + +/** + * Creates the parameters for the FeedAd tracking call + * @param {object} data - prebid data + * @param {'prebid_bidWon'|'prebid_bidTimeout'} klass - type of tracking call + * @return {FeedAdApiTrackingParams|null} + */ +function createTrackingParams(data, klass) { + const bidId = data.bidId || data.requestId; + if (!BID_METADATA.hasOwnProperty(bidId)) { + return null; + } + const {referer, transactionId} = BID_METADATA[bidId]; + delete BID_METADATA[bidId]; + return { + app_hybrid: false, + client_token: data.params[0].clientToken, + placement_id: data.params[0].placementId, + klass, + prebid_auction_id: data.auctionId, + prebid_bid_id: bidId, + prebid_transaction_id: transactionId, + referer, + sdk_version: VERSION + }; +} + +/** + * Creates a tracking handler for the given event type + * @param klass - the event type + * @return {Function} the tracking handler function + */ +function trackingHandlerFactory(klass) { + return (data) => { + if (!data) { + return; + } + let params = createTrackingParams(data, klass); + if (params) { + ajax(`${API_ENDPOINT}${API_PATH_TRACK_REQUEST}`, null, JSON.stringify(params), { + withCredentials: true, + method: 'POST', + contentType: 'application/json' + }); + } + } +} + +/** + * @type {BidderSpec} + */ +export const spec = { + code: BIDDER_CODE, + supportedMediaTypes: MEDIA_TYPES, + isBidRequestValid, + buildRequests, + interpretResponse, + onTimeout: trackingHandlerFactory('prebid_bidTimeout'), + onBidWon: trackingHandlerFactory('prebid_bidWon') +}; + +registerBidder(spec); diff --git a/modules/feedadBidAdapter.md b/modules/feedadBidAdapter.md new file mode 100644 index 00000000000..fd57025c29e --- /dev/null +++ b/modules/feedadBidAdapter.md @@ -0,0 +1,44 @@ +# Overview + +``` +Module Name: FeedAd Adapter +Module Type: Bidder Adapter +Maintainer: mail@feedad.com +``` + +# Description + +Prebid.JS adapter that connects to the FeedAd demand sources. + +# Test Parameters +``` + var adUnits = [ + { + code: 'test-div', + mediaTypes: { + banner: { // supports all banner sizes + sizes: [[300, 250]], + }, + video: { // supports only outstream video + context: 'outstream' + } + }, + bids: [ + { + bidder: "feedad", + params: { + clientToken: 'your-client-token' // see below for more info + placementId: 'your-placement-id' // see below for more info + } + } + ] + } + ]; +``` + +# Required Parameters + +| Parameter | Description | +| --------- | ----------- | +| `clientToken` | Your FeedAd web client token. You can view your client token inside the FeedAd admin panel. | +| `placementId` | You can choose placement IDs yourself. A placement ID should be named after the ad position inside your product. For example, if you want to display an ad inside a list of news articles, you could name it "ad-news-overview".
    A placement ID may consist of lowercase `a-z`, `0-9`, `-` and `_`. You do not have to manually create the placement IDs before using them. Just specify them within the code, and they will appear in the FeedAd admin panel after the first request.
    [Learn more](/concept/feed_ad/index.html) about Placement IDs and how they are grouped to play the same Creative. | diff --git a/modules/freeWheelAdserverVideo.js b/modules/freeWheelAdserverVideo.js index c81f3356d71..03217b1165d 100644 --- a/modules/freeWheelAdserverVideo.js +++ b/modules/freeWheelAdserverVideo.js @@ -3,152 +3,17 @@ */ import { registerVideoSupport } from '../src/adServerManager'; -import { auctionManager } from '../src/auctionManager'; -import { groupBy, deepAccess, logError, compareOn } from '../src/utils'; -import { config } from '../src/config'; -import { ADPOD } from '../src/mediaTypes'; -import { initAdpodHooks, TARGETING_KEY_PB_CAT_DUR, TARGETING_KEY_CACHE_ID, callPrebidCacheAfterAuction, sortByPricePerSecond } from './adpod'; -import { getHook } from '../src/hook'; +import { getHook, submodule } from '../src/hook'; +export const adpodUtils = {}; export function notifyTranslationModule(fn) { fn.call(this, 'freewheel'); } getHook('registerAdserver').before(notifyTranslationModule); -/** - * This function returns targeting keyvalue pairs for freewheel adserver module - * @param {Object} options - * @param {Array[string]} codes - * @param {function} callback - * @returns targeting kvs for adUnitCodes - */ -export function getTargeting({codes, callback} = {}) { - if (!callback) { - logError('No callback function was defined in the getTargeting call. Aborting getTargeting().'); - return; - } - codes = codes || []; - const adPodAdUnits = getAdPodAdUnits(codes); - const bidsReceived = auctionManager.getBidsReceived(); - const competiveExclusionEnabled = config.getConfig('adpod.brandCategoryExclusion'); - const deferCachingSetting = config.getConfig('adpod.deferCaching'); - const deferCachingEnabled = (typeof deferCachingSetting === 'boolean') ? deferCachingSetting : true; - - let bids = getBidsForAdpod(bidsReceived, adPodAdUnits); - bids = (competiveExclusionEnabled || deferCachingEnabled) ? getExclusiveBids(bids) : bids; - bids.sort(sortByPricePerSecond); - - let targeting = {}; - if (deferCachingEnabled === false) { - adPodAdUnits.forEach((adUnit) => { - let adPodTargeting = []; - let adPodDurationSeconds = deepAccess(adUnit, 'mediaTypes.video.adPodDurationSec'); - - bids - .filter((bid) => bid.adUnitCode === adUnit.code) - .forEach((bid, index, arr) => { - if (bid.video.durationBucket <= adPodDurationSeconds) { - adPodTargeting.push({ - [TARGETING_KEY_PB_CAT_DUR]: bid.adserverTargeting[TARGETING_KEY_PB_CAT_DUR] - }); - adPodDurationSeconds -= bid.video.durationBucket; - } - if (index === arr.length - 1 && adPodTargeting.length > 0) { - adPodTargeting.push({ - [TARGETING_KEY_CACHE_ID]: bid.adserverTargeting[TARGETING_KEY_CACHE_ID] - }); - } - }); - targeting[adUnit.code] = adPodTargeting; - }); - - callback(null, targeting); - } else { - let bidsToCache = []; - adPodAdUnits.forEach((adUnit) => { - let adPodDurationSeconds = deepAccess(adUnit, 'mediaTypes.video.adPodDurationSec'); - - bids - .filter((bid) => bid.adUnitCode === adUnit.code) - .forEach((bid) => { - if (bid.video.durationBucket <= adPodDurationSeconds) { - bidsToCache.push(bid); - adPodDurationSeconds -= bid.video.durationBucket; - } - }); - }); - - callPrebidCacheAfterAuction(bidsToCache, function(error, bidsSuccessfullyCached) { - if (error) { - callback(error, null); - } else { - let groupedBids = groupBy(bidsSuccessfullyCached, 'adUnitCode'); - Object.keys(groupedBids).forEach((adUnitCode) => { - let adPodTargeting = []; - - groupedBids[adUnitCode].forEach((bid, index, arr) => { - adPodTargeting.push({ - [TARGETING_KEY_PB_CAT_DUR]: bid.adserverTargeting[TARGETING_KEY_PB_CAT_DUR] - }); - - if (index === arr.length - 1 && adPodTargeting.length > 0) { - adPodTargeting.push({ - [TARGETING_KEY_CACHE_ID]: bid.adserverTargeting[TARGETING_KEY_CACHE_ID] - }); - } - }); - targeting[adUnitCode] = adPodTargeting; - }); - - callback(null, targeting); - } - }); - } - return targeting; -} - -/** - * This function returns the adunit of mediaType adpod - * @param {Array} codes adUnitCodes - * @returns {Array[Object]} adunits of mediaType adpod - */ -function getAdPodAdUnits(codes) { - return auctionManager.getAdUnits() - .filter((adUnit) => deepAccess(adUnit, 'mediaTypes.video.context') === ADPOD) - .filter((adUnit) => (codes.length > 0) ? codes.indexOf(adUnit.code) != -1 : true); -} - -/** - * This function removes bids of same freewheel category. It will be used when competitive exclusion is enabled. - * @param {Array[Object]} bidsReceived - * @returns {Array[Object]} unique freewheel category bids - */ -function getExclusiveBids(bidsReceived) { - let bids = bidsReceived - .map((bid) => Object.assign({}, bid, {[TARGETING_KEY_PB_CAT_DUR]: bid.adserverTargeting[TARGETING_KEY_PB_CAT_DUR]})); - bids = groupBy(bids, TARGETING_KEY_PB_CAT_DUR); - let filteredBids = []; - Object.keys(bids).forEach((targetingKey) => { - bids[targetingKey].sort(compareOn('responseTimestamp')); - filteredBids.push(bids[targetingKey][0]); - }); - return filteredBids; -} - -/** - * This function returns bids for adpod adunits - * @param {Array[Object]} bidsReceived - * @param {Array[Object]} adPodAdUnits - * @returns {Array[Object]} bids of mediaType adpod - */ -function getBidsForAdpod(bidsReceived, adPodAdUnits) { - let adUnitCodes = adPodAdUnits.map((adUnit) => adUnit.code); - return bidsReceived - .filter((bid) => adUnitCodes.indexOf(bid.adUnitCode) != -1 && (bid.video && bid.video.context === ADPOD)) -} - -initAdpodHooks(); registerVideoSupport('freewheel', { - getTargeting: getTargeting + getTargeting: (args) => adpodUtils.getTargeting(args) }); + +submodule('adpod', adpodUtils); diff --git a/modules/gamoshiBidAdapter.js b/modules/gamoshiBidAdapter.js index 307f2d8bc91..6d243f155bf 100644 --- a/modules/gamoshiBidAdapter.js +++ b/modules/gamoshiBidAdapter.js @@ -5,12 +5,11 @@ import {Renderer} from '../src/Renderer'; import {BANNER, VIDEO} from '../src/mediaTypes'; const ENDPOINTS = { - 'viewdeos': 'https://rtb.viewdeos.com', - 'cleanmedia': 'https://bidder.cleanmediaads.com', - 'gamoshi': 'https://rtb.gamoshi.io', - 'gambid': 'https://rtb.gamoshi.io', + 'gamoshi': 'https://rtb.gamoshi.io' }; +const DEFAULT_TTL = 360; + export const helper = { getTopFrame: function () { try { @@ -43,7 +42,7 @@ export const helper = { export const spec = { code: 'gamoshi', - aliases: ['gambid', 'cleanmedia', 'viewdeos'], + aliases: ['gambid', 'cleanmedia', 'viewdeos', 'adastaMedia', '9MediaOnline'], supportedMediaTypes: ['banner', 'video'], isBidRequestValid: function (bid) { @@ -59,7 +58,7 @@ export const spec = { buildRequests: function (validBidRequests, bidderRequest) { return validBidRequests.map(bidRequest => { const {adUnitCode, auctionId, mediaTypes, params, sizes, transactionId} = bidRequest; - const baseEndpoint = params['rtbEndpoint'] || ENDPOINTS[bidRequest.bidder] || ENDPOINTS['gamoshi']; + const baseEndpoint = params['rtbEndpoint'] || ENDPOINTS['gamoshi']; const rtbEndpoint = `${baseEndpoint}/r/${params.supplyPartnerId}/bidr?rformat=open_rtb&reqformat=rtb_json&bidder=prebid` + (params.query ? '&' + params.query : ''); let url = config.getConfig('pageUrl') || bidderRequest.refererInfo.referer; @@ -114,10 +113,11 @@ export const spec = { if (mediaTypes && mediaTypes.video) { if (!hasFavoredMediaType || params.favoredMediaType === VIDEO) { + const playerSize = mediaTypes.video.playerSize || sizes; const videoImp = Object.assign({}, imp, { video: { - w: sizes.length ? sizes[0][0] : 300, - h: sizes.length ? sizes[0][1] : 250, + w: playerSize ? playerSize[0][0] : 300, + h: playerSize ? playerSize[0][1] : 250, protocols: params.protocols || [1, 2, 3, 4, 5, 6], pos: params.pos || 0, ext: { @@ -149,18 +149,15 @@ export const spec = { bids.forEach(bid => { const outBid = { - adId: bidRequest.bidRequest.adUnitCode, requestId: bidRequest.bidRequest.bidId, cpm: bid.price, width: bid.w, height: bid.h, - ttl: 60 * 10, - creativeId: bid.crid, + ttl: DEFAULT_TTL, + creativeId: bid.crid || bid.adid, netRevenue: true, currency: bid.cur || response.cur, - adUnitCode: bidRequest.bidRequest.adUnitCode, mediaType: helper.getMediaType(bid) - }; if (utils.deepAccess(bidRequest.bidRequest, 'mediaTypes.' + outBid.mediaType)) { diff --git a/modules/go2net.md b/modules/go2net.md new file mode 100644 index 00000000000..acea57b1c55 --- /dev/null +++ b/modules/go2net.md @@ -0,0 +1,29 @@ +# Overview + +Module Name: Go2Net Bidder Adapter +Module Type: Bidder Adapter +Maintainer: vprytuzhalova@go2net.com.ua + +# Description + +Connects to Go2Net demand source to fetch bids. +Banner and Video formats are supported. +Please use ```go2net``` as the bidder code. + +# Ad Unit Example +``` + var adUnits = [ + { + code: 'desktop-banner-ad-div', + sizes: [[300, 250]], // a display size + bids: [ + { + bidder: "go2net", + params: { + zone: 'fb3d34d0-7a88-4a4a-a5c9-8088cd7845f4' + } + } + ] + } + ]; +``` diff --git a/modules/gridBidAdapter.js b/modules/gridBidAdapter.js index fd1a382d995..edbf5ed08bd 100644 --- a/modules/gridBidAdapter.js +++ b/modules/gridBidAdapter.js @@ -6,7 +6,7 @@ import { VIDEO, BANNER } from '../src/mediaTypes'; const BIDDER_CODE = 'grid'; const ENDPOINT_URL = '//grid.bidswitch.net/hb'; const TIME_TO_LIVE = 360; -const RENDERER_URL = '//cdn.adnxs.com/renderer/video/ANOutstreamVideo.js'; +const RENDERER_URL = '//acdn.adnxs.com/video/outstream/ANOutstreamVideo.js'; const LOG_ERROR_MESS = { noAuid: 'Bid from response has no auid parameter - ', @@ -41,26 +41,53 @@ export const spec = { buildRequests: function(validBidRequests, bidderRequest) { const auids = []; const bidsMap = {}; + const slotsMapByUid = {}; + const sizeMap = {}; const bids = validBidRequests || []; let reqId; bids.forEach(bid => { reqId = bid.bidderRequestId; - if (!bidsMap[bid.params.uid]) { - bidsMap[bid.params.uid] = [bid]; - auids.push(bid.params.uid); + const {params: {uid}, adUnitCode} = bid; + auids.push(uid); + const sizesId = utils.parseSizesInput(bid.sizes); + + if (!slotsMapByUid[uid]) { + slotsMapByUid[uid] = {}; + } + const slotsMap = slotsMapByUid[uid]; + if (!slotsMap[adUnitCode]) { + slotsMap[adUnitCode] = {adUnitCode, bids: [bid], parents: []}; } else { - bidsMap[bid.params.uid].push(bid); + slotsMap[adUnitCode].bids.push(bid); } + const slot = slotsMap[adUnitCode]; + + sizesId.forEach((sizeId) => { + sizeMap[sizeId] = true; + if (!bidsMap[uid]) { + bidsMap[uid] = {}; + } + + if (!bidsMap[uid][sizeId]) { + bidsMap[uid][sizeId] = [slot]; + } else { + bidsMap[uid][sizeId].push(slot); + } + slot.parents.push({parent: bidsMap[uid], key: sizeId, uid}); + }); }); const payload = { - u: utils.getTopWindowUrl(), auids: auids.join(','), + sizes: utils.getKeys(sizeMap).join(','), r: reqId }; if (bidderRequest) { + if (bidderRequest.refererInfo && bidderRequest.refererInfo.referer) { + payload.u = bidderRequest.refererInfo.referer; + } if (bidderRequest.timeout) { payload.wtimeout = bidderRequest.timeout; } @@ -108,7 +135,7 @@ export const spec = { if (errorMessage) utils.logError(errorMessage); return bidResponses; } -} +}; function _getBidFromResponse(respItem) { if (!respItem) { @@ -129,24 +156,25 @@ function _addBidResponse(serverBid, bidsMap, bidResponses) { else { const awaitingBids = bidsMap[serverBid.auid]; if (awaitingBids) { - awaitingBids.forEach(bid => { - const size = bid.sizes[0]; - if (serverBid.w && serverBid.h) { - size[0] = serverBid.w; - size[1] = serverBid.h; - } + const sizeId = `${serverBid.w}x${serverBid.h}`; + if (awaitingBids[sizeId]) { + const slot = awaitingBids[sizeId][0]; + + const bid = slot.bids.shift(); + const bidResponse = { requestId: bid.bidId, // bid.bidderRequestId, bidderCode: spec.code, cpm: serverBid.price, - width: size[0], - height: size[1], + width: serverBid.w, + height: serverBid.h, creativeId: serverBid.auid, // bid.bidId, currency: 'USD', netRevenue: false, ttl: TIME_TO_LIVE, dealId: serverBid.dealid }; + if (serverBid.content_type === 'video') { bidResponse.vastXml = serverBid.adm; bidResponse.mediaType = VIDEO; @@ -164,7 +192,22 @@ function _addBidResponse(serverBid, bidsMap, bidResponses) { bidResponse.mediaType = BANNER; } bidResponses.push(bidResponse); - }); + + if (!slot.bids.length) { + slot.parents.forEach(({parent, key, uid}) => { + const index = parent[key].indexOf(slot); + if (index > -1) { + parent[key].splice(index, 1); + } + if (!parent[key].length) { + delete parent[key]; + if (!utils.getKeys(parent).length) { + delete bidsMap[uid]; + } + } + }); + } + } } else { errorMessage = LOG_ERROR_MESS.noPlacementCode + serverBid.auid; } diff --git a/modules/gridBidAdapter.md b/modules/gridBidAdapter.md old mode 100755 new mode 100644 diff --git a/modules/gumgumBidAdapter.js b/modules/gumgumBidAdapter.js index 98bf6b17552..898cd4a59bd 100644 --- a/modules/gumgumBidAdapter.js +++ b/modules/gumgumBidAdapter.js @@ -14,7 +14,7 @@ let browserParams = {}; let pageViewId = null // TODO: potential 0 values for browserParams sent to ad server -function _getBrowserParams() { +function _getBrowserParams(topWindowUrl) { let topWindow let topScreen let topUrl @@ -41,7 +41,7 @@ function _getBrowserParams() { try { topWindow = global.top; topScreen = topWindow.screen; - topUrl = utils.getTopWindowUrl() + topUrl = topWindowUrl || utils.getTopWindowUrl(); } catch (error) { utils.logError(error); return browserParams @@ -56,7 +56,7 @@ function _getBrowserParams() { ce: utils.cookiesAreEnabled(), dpr: topWindow.devicePixelRatio || 1, jcsi: JSON.stringify({ t: 0, rq: 8 }), - og_url: getOgURL() + ogu: getOgURL() } ns = getNetworkSpeed() @@ -75,14 +75,20 @@ function getWrapperCode(wrapper, data) { return wrapper.replace('AD_JSON', window.btoa(JSON.stringify(data))) } -// TODO: use getConfig() -function _getDigiTrustQueryParams() { - function getDigiTrustId () { - var digiTrustUser = (window.DigiTrust && window.DigiTrust.getUser) ? window.DigiTrust.getUser(DT_CREDENTIALS) : {}; - return (digiTrustUser && digiTrustUser.success && digiTrustUser.identity) || ''; - }; +function _getTradeDeskIDParam(userId) { + const unifiedIdObj = {}; + if (userId.tdid) { + unifiedIdObj.tdid = userId.tdid; + } + return unifiedIdObj; +} - let digiTrustId = getDigiTrustId(); +function _getDigiTrustQueryParams(userId) { + let digiTrustId = userId.digitrustid && userId.digitrustid.data; + if (!digiTrustId) { + const digiTrustUser = (window.DigiTrust && window.DigiTrust.getUser) ? window.DigiTrust.getUser(DT_CREDENTIALS) : {}; + digiTrustId = (digiTrustUser && digiTrustUser.success && digiTrustUser.identity) || ''; + } // Verify there is an ID and this user has not opted out if (!digiTrustId || (digiTrustId.privacy && digiTrustId.privacy.optout)) { return {}; @@ -129,15 +135,17 @@ function isBidRequestValid (bid) { */ function buildRequests (validBidRequests, bidderRequest) { const bids = []; - const gdprConsent = Object.assign({ consentString: null, gdprApplies: true }, bidderRequest && bidderRequest.gdprConsent) + const gdprConsent = bidderRequest && bidderRequest.gdprConsent; utils._each(validBidRequests, bidRequest => { const timeout = config.getConfig('bidderTimeout'); const { bidId, params = {}, - transactionId + transactionId, + userId = {} } = bidRequest; - const data = {} + const data = {}; + const topWindowUrl = bidderRequest && bidderRequest.refererInfo && bidderRequest.refererInfo.referer; if (pageViewId) { data.pv = pageViewId } @@ -156,8 +164,10 @@ function buildRequests (validBidRequests, bidderRequest) { data.ni = parseInt(params.ICV, 10); data.pi = 5; } - data.gdprApplies = gdprConsent.gdprApplies; - if (gdprConsent.gdprApplies) { + if (gdprConsent) { + data.gdprApplies = gdprConsent.gdprApplies ? 1 : 0; + } + if (data.gdprApplies) { data.gdprConsent = gdprConsent.consentString; } @@ -167,10 +177,10 @@ function buildRequests (validBidRequests, bidderRequest) { tId: transactionId, pi: data.pi, selector: params.selector, - sizes: bidRequest.sizes, + sizes: bidRequest.sizes || bidRequest.mediatype[banner].sizes, url: BID_ENDPOINT, method: 'GET', - data: Object.assign(data, _getBrowserParams(), _getDigiTrustQueryParams()) + data: Object.assign(data, _getBrowserParams(topWindowUrl), _getDigiTrustQueryParams(userId), _getTradeDeskIDParam(userId)) }) }); return bids; @@ -213,7 +223,7 @@ function interpretResponse (serverResponse, bidRequest) { let [width, height] = sizes[0].split('x') // return 1x1 when breakout expected - if ((product === 2 || product === 5) && includes(sizes, '1x1')) { + if (product === 5 && includes(sizes, '1x1')) { width = '1' height = '1' } diff --git a/modules/gumgumBidAdapter.md b/modules/gumgumBidAdapter.md index 57616a90ac2..3abc8a246c9 100644 --- a/modules/gumgumBidAdapter.md +++ b/modules/gumgumBidAdapter.md @@ -21,7 +21,7 @@ var adUnits = [ bidder: 'gumgum', params: { inSlot: '15901', // GumGum Slot ID given to the client, - bidFloor: 0.03 // CPM bid floor + bidfloor: 0.03 // CPM bid floor } } ] @@ -33,7 +33,7 @@ var adUnits = [ bidder: 'gumgum', params: { inScreen: 'dc9d6be1', // GumGum Zone ID given to the client - bidFloor: 0.03 // CPM bid floor + bidfloor: 0.03 // CPM bid floor } } ] diff --git a/modules/gxoneBidAdapter.md b/modules/gxoneBidAdapter.md old mode 100755 new mode 100644 diff --git a/modules/hpmdnetworkBidAdapter.js b/modules/hpmdnetworkBidAdapter.js new file mode 100644 index 00000000000..b23d17a7bf3 --- /dev/null +++ b/modules/hpmdnetworkBidAdapter.js @@ -0,0 +1,96 @@ +import { registerBidder } from '../src/adapters/bidderFactory'; +import { BANNER } from '../src/mediaTypes'; + +const BIDDER_CODE = 'hpmdnetwork'; +const BIDDER_CODE_ALIAS = 'hpmd'; +const HPMDNETWORK_HOST = '//banner.hpmdnetwork.ru/bidder/request'; +const DEFAULT_TTL = 300; +const DEFAULT_CURRENCY = 'RUB'; + +export const spec = { + code: BIDDER_CODE, + aliases: [ BIDDER_CODE_ALIAS ], + supportedMediaTypes: [ BANNER ], + isBidRequestValid: isBidRequestValid, + buildRequests: buildRequests, + interpretResponse: interpretResponse, +}; + +function isBidRequestValid(bid) { + const { placementId } = bid.params; + return !!placementId; +} + +function buildRequests(validBidRequests, bidderRequest) { + const payload = {}; + payload.places = []; + + validBidRequests.forEach((bidRequest) => { + const place = { + id: bidRequest.bidId, + placementId: bidRequest.params.placementId + '', + }; + payload.places.push(place); + }); + + payload.url = bidderRequest.refererInfo.referer; + payload.settings = { currency: DEFAULT_CURRENCY }; + + return { + method: 'POST', + url: HPMDNETWORK_HOST, + data: payload, + }; +} + +function interpretResponse(serverResponse) { + const { body } = serverResponse; + const bidResponses = []; + + if (body.bids) { + body.bids.forEach((bid) => { + const size = getCreativeSize(bid); + const bidResponse = { + requestId: bid.id, + cpm: bid.cpm, + ad: wrapDisplayUrl(bid.displayUrl), + width: size.width, + height: size.height, + creativeId: bid.creativeId || generateRandomInt(), + currency: bid.currency || DEFAULT_CURRENCY, + netRevenue: true, + ttl: bid.ttl || DEFAULT_TTL, + }; + + bidResponses.push(bidResponse); + }); + } + + return bidResponses; +} + +function wrapDisplayUrl(displayUrl) { + return ``; +} + +function getCreativeSize(creativeSize) { + const size = { + width: 1, + height: 1, + }; + + if (!!creativeSize.width && creativeSize.width !== -1) { + size.width = creativeSize.width; + } + if (!!creativeSize.height && creativeSize.height !== -1) { + size.height = creativeSize.height; + } + + return size; +} + +function generateRandomInt() { + return Math.random().toString(16).substring(2); +} + +registerBidder(spec); diff --git a/modules/hpmdnetworkBidAdapter.md b/modules/hpmdnetworkBidAdapter.md new file mode 100644 index 00000000000..b7ac51a9311 --- /dev/null +++ b/modules/hpmdnetworkBidAdapter.md @@ -0,0 +1,32 @@ +# Overview + +Module Name: HPMD Network Bidder Adapter + +Module Type: Bidder Adapter + +Maintainer: a.fominov@hpmdnetwork.ru + +# Description + +You can use this adapter to get a bid from HPMD Network. + +About us : https://www.hpmdnetwork.ru/ + + +# Test Parameters +```javascript + var adUnits = [ + { + code: 'test-div', + bids: [ + { + bidder: "hpmdnetwork", + params: { + placementId: "123" + } + } + ] + } + ]; +``` + diff --git a/modules/iasBidAdapter.js b/modules/iasBidAdapter.js index bda5af1f4ec..5530cbefb82 100644 --- a/modules/iasBidAdapter.js +++ b/modules/iasBidAdapter.js @@ -59,6 +59,7 @@ function buildRequests(bidRequests) { queries.push(['wr', stringifyWindowSize()]); queries.push(['sr', stringifyScreenSize()]); + queries.push(['url', encodeURIComponent(window.location.href)]); const queryString = encodeURI(queries.map(qs => qs.join('=')).join('&')); @@ -80,6 +81,7 @@ function getPageLevelKeywords(response) { let result = {}; shallowMerge(result, response.brandSafety); result.fr = response.fr; + result.custom = response.custom; return result; } diff --git a/modules/id5IdSystem.js b/modules/id5IdSystem.js new file mode 100644 index 00000000000..6fb5014c962 --- /dev/null +++ b/modules/id5IdSystem.js @@ -0,0 +1,62 @@ +/** + * This module adds ID5 to the User ID module + * The {@link module:modules/userId} module is required + * @module modules/unifiedIdSystem + * @requires module:modules/userId + */ + +import * as utils from '../src/utils' +import {ajax} from '../src/ajax'; +import {submodule} from '../src/hook'; + +/** @type {Submodule} */ +export const id5IdSubmodule = { + /** + * used to link submodule with config + * @type {string} + */ + name: 'id5Id', + /** + * decode the stored id value for passing to bid requests + * @function decode + * @param {(Object|string)} value + * @returns {(Object|undefined)} + */ + decode(value) { + return (value && typeof value['ID5ID'] === 'string') ? { 'id5id': value['ID5ID'] } : undefined; + }, + /** + * performs action to obtain id and return a value in the callback's response argument + * @function + * @param {SubmoduleParams} [configParams] + * @param {ConsentData} [consentData] + * @param {(Object|undefined)} cacheIdObj + * @returns {(Object|function(callback:function))} + */ + getId(configParams, consentData, cacheIdObj) { + if (!configParams || typeof configParams.partner !== 'number') { + utils.logError(`User ID - ID5 submodule requires partner to be defined as a number`); + return undefined; + } + const hasGdpr = (consentData && typeof consentData.gdprApplies === 'boolean' && consentData.gdprApplies) ? 1 : 0; + const gdprConsentString = hasGdpr ? consentData.consentString : ''; + const storedUserId = this.decode(cacheIdObj); + const url = `https://id5-sync.com/g/v1/${configParams.partner}.json?1puid=${storedUserId ? storedUserId.id5id : ''}&gdpr=${hasGdpr}&gdpr_consent=${gdprConsentString}`; + + return function (callback) { + ajax(url, response => { + let responseObj; + if (response) { + try { + responseObj = JSON.parse(response); + } catch (error) { + utils.logError(error); + } + } + callback(responseObj); + }, undefined, { method: 'GET', withCredentials: true }); + } + } +}; + +submodule('userId', id5IdSubmodule); diff --git a/modules/identityLinkIdSystem.js b/modules/identityLinkIdSystem.js new file mode 100644 index 00000000000..9aca5f85adf --- /dev/null +++ b/modules/identityLinkIdSystem.js @@ -0,0 +1,74 @@ +/** + * This module adds IdentityLink to the User ID module + * The {@link module:modules/userId} module is required + * @module modules/identityLinkSubmodule + * @requires module:modules/userId + */ + +import * as utils from '../src/utils.js' +import {ajax} from '../src/ajax.js'; +import {submodule} from '../src/hook'; + +/** @type {Submodule} */ +export const identityLinkSubmodule = { + /** + * used to link submodule with config + * @type {string} + */ + name: 'identityLink', + /** + * decode the stored id value for passing to bid requests + * @function + * @param {string} value + * @returns {{idl_env:string}} + */ + decode(value) { + return { 'idl_env': value } + }, + /** + * performs action to obtain id and return a value in the callback's response argument + * @function + * @param {SubmoduleParams} [configParams] + * @returns {function(callback:function)} + */ + getId(configParams) { + if (!configParams || typeof configParams.pid !== 'string') { + utils.logError('identityLink submodule requires partner id to be defined'); + return; + } + // use protocol relative urls for http or https + const url = `https://api.rlcdn.com/api/identity/envelope?pid=${configParams.pid}`; + // if ats library is initialised, use it to retrieve envelope. If not use standard third party endpoint + if (window.ats) { + return function(callback) { + window.ats.retrieveEnvelope(function (envelope) { + if (envelope) { + callback(JSON.parse(envelope).envelope); + } else { + getEnvelope(url, callback); + } + }); + } + } else { + return function (callback) { + getEnvelope(url, callback); + } + } + } +} +// return envelope from third party endpoint +function getEnvelope(url, callback) { + ajax(url, response => { + let responseObj; + if (response) { + try { + responseObj = JSON.parse(response); + } catch (error) { + utils.logError(error); + } + } + callback(responseObj.envelope); + }, undefined, {method: 'GET', withCredentials: true}); +} + +submodule('userId', identityLinkSubmodule); diff --git a/modules/imonomyBidAdapter.js b/modules/imonomyBidAdapter.js new file mode 100644 index 00000000000..9a0d29a1374 --- /dev/null +++ b/modules/imonomyBidAdapter.js @@ -0,0 +1,130 @@ +import * as utils from '../src/utils'; +import { registerBidder } from '../src/adapters/bidderFactory'; + +const BIDDER_CODE = 'imonomy'; +const ENDPOINT = '//b.imonomy.com/openrtb/hb/00000'; +const USYNCURL = '//b.imonomy.com/UserMatching/b/'; + +export const spec = { + code: BIDDER_CODE, + + /** + * Determines whether or not the given bid request is valid. Valid bid request must have placementId and hbid + * + * @param {BidRequest} bid The bid params to validate. + * @return {boolean} True if this is a valid bid, and false otherwise. + */ + isBidRequestValid: bid => { + return !!(bid && bid.params && bid.params.placementId && bid.params.hbid); + }, + /** + * Make a server request from the list of BidRequests. + * + * @param {BidRequest[]} validBidRequests an array of bids + * @return ServerRequest Info describing the request to the server. + */ + buildRequests: validBidRequests => { + const tags = validBidRequests.map(bid => { + // map each bid id to bid object to retrieve adUnit code in callback + let tag = { + uuid: bid.bidId, + sizes: bid.sizes, + trid: bid.transactionId, + hbid: bid.params.hbid, + placementid: bid.params.placementId + }; + + // add floor price if specified (not mandatory) + if (bid.params.floorPrice) { + tag.floorprice = bid.params.floorPrice; + } + + return tag; + }); + + // Imonomy server config + const time = new Date().getTime(); + const kbConf = { + ts_as: time, + hb_placements: [], + hb_placement_bidids: {}, + hb_floors: {}, + cb: _generateCb(time), + tz: new Date().getTimezoneOffset(), + }; + + validBidRequests.forEach(bid => { + kbConf.hdbdid = kbConf.hdbdid || bid.params.hbid; + kbConf.encode_bid = kbConf.encode_bid || bid.params.encode_bid; + kbConf.hb_placement_bidids[bid.params.placementId] = bid.bidId; + if (bid.params.floorPrice) { + kbConf.hb_floors[bid.params.placementId] = bid.params.floorPrice; + } + kbConf.hb_placements.push(bid.params.placementId); + }); + + let payload = {}; + if (!utils.isEmpty(tags)) { + payload = { bids: [...tags], kbConf }; + } + + let endpointToUse = ENDPOINT; + if (kbConf.hdbdid) { + endpointToUse = endpointToUse.replace('00000', kbConf.hdbdid); + } + + return { + method: 'POST', + url: endpointToUse, + data: JSON.stringify(payload) + }; + }, + /** + * Unpack the response from the server into a list of bids. + * + * @param {*} response A successful response from the server. + * @return {Bid[]} An array of bids which were nested inside the server. + */ + interpretResponse: (response) => { + const bidResponses = []; + if (response && response.body && response.body.bids) { + response.body.bids.forEach(bid => { + // The bid ID. Used to tie this bid back to the request. + if (bid.uuid) { + bid.requestId = bid.uuid; + } else { + utils.logError('No uuid for bid'); + } + // The creative payload of the returned bid. + if (bid.creative) { + bid.ad = bid.creative; + } else { + utils.logError('No creative for bid'); + } + bidResponses.push(bid); + }); + } + return bidResponses; + }, + /** + * Register User Sync. + */ + getUserSyncs: syncOptions => { + if (syncOptions.iframeEnabled) { + return [{ + type: 'iframe', + url: USYNCURL + }]; + } + } +}; + +/** +* Generated cache baster value to be sent to bid server +* @param {*} time current time to use for creating cb. +*/ +function _generateCb(time) { + return Math.floor((time % 65536) + (Math.floor(Math.random() * 65536) * 65536)); +} + +registerBidder(spec); diff --git a/modules/imonomyBidAdapter.md b/modules/imonomyBidAdapter.md new file mode 100644 index 00000000000..451eb0994d8 --- /dev/null +++ b/modules/imonomyBidAdapter.md @@ -0,0 +1,29 @@ +# Overview + +**Module Name**: Imonomy Bidder Adapter +**Module Type**: Bidder Adapter +**Maintainer**: support@imonomy.com + +# Description + +Connects to Imonomy demand source to fetch bids. + +# Test Parameters +``` + var adUnits = [{ + code: 'banner-ad-div', + sizes: [[300, 250]], + + // Replace this object to test a new Adapter! + bids: [{ + bidder: 'imonomy', + params: { + placementId: 'e69148e0ba6c4c07977dc2daae5e1577', + hbid: '14567718624', + floorPrice: 0.5 + } + }] + }]; +``` + + diff --git a/modules/improvedigitalBidAdapter.js b/modules/improvedigitalBidAdapter.js index fdfe5970572..22569f04cc3 100644 --- a/modules/improvedigitalBidAdapter.js +++ b/modules/improvedigitalBidAdapter.js @@ -6,7 +6,7 @@ import { BANNER, NATIVE } from '../src/mediaTypes'; const BIDDER_CODE = 'improvedigital'; export const spec = { - version: '5.1.0', + version: '5.2.0', code: BIDDER_CODE, aliases: ['id'], supportedMediaTypes: [BANNER, NATIVE], @@ -43,6 +43,10 @@ export const spec = { requestParameters.gdpr = bidderRequest.gdprConsent.consentString; } + if (bidderRequest && bidderRequest.refererInfo && bidderRequest.refererInfo.referer) { + requestParameters.referrer = bidderRequest.refererInfo.referer; + } + let requestObj = idClient.createRequest( normalizedBids, // requestObject requestParameters @@ -75,6 +79,8 @@ export const spec = { if (bidObject.native) { // Native bid.native = getNormalizedNativeAd(bidObject.native); + // Expose raw oRTB response to the client to allow parsing assets not directly supported by Prebid + bid.ortbNative = bidObject.native; if (bidObject.nurl) { bid.native.impressionTrackers.unshift(bidObject.nurl); } @@ -169,11 +175,13 @@ function getNormalizedBidRequest(bid) { publisherId = utils.getBidIdParameter('publisherId', bid.params) || null; placementKey = utils.getBidIdParameter('placementKey', bid.params) || null; } - let keyValues = utils.getBidIdParameter('keyValues', bid.params) || null; - let singleSizeFilter = utils.getBidIdParameter('size', bid.params) || null; - let bidId = utils.getBidIdParameter('bidId', bid); - let transactionId = utils.getBidIdParameter('transactionId', bid); + const keyValues = utils.getBidIdParameter('keyValues', bid.params) || null; + const singleSizeFilter = utils.getBidIdParameter('size', bid.params) || null; + const bidId = utils.getBidIdParameter('bidId', bid); + const transactionId = utils.getBidIdParameter('transactionId', bid); const currency = config.getConfig('currency.adServerCurrency'); + const bidFloor = utils.getBidIdParameter('bidFloor', bid.params); + const bidFloorCur = utils.getBidIdParameter('bidFloorCur', bid.params); let normalizedBidRequest = {}; if (placementId) { @@ -211,6 +219,10 @@ function getNormalizedBidRequest(bid) { if (currency) { normalizedBidRequest.currency = currency; } + if (bidFloor) { + normalizedBidRequest.bidFloor = bidFloor; + normalizedBidRequest.bidFloorCur = bidFloorCur ? bidFloorCur.toUpperCase() : 'USD'; + } return normalizedBidRequest; } @@ -231,6 +243,33 @@ function getNormalizedNativeAd(rawNative) { case 2: native.body = asset.data.value; break; + case 3: + native.rating = asset.data.value; + break; + case 4: + native.likes = asset.data.value; + break; + case 5: + native.downloads = asset.data.value; + break; + case 6: + native.price = asset.data.value; + break; + case 7: + native.salePrice = asset.data.value; + break; + case 8: + native.phone = asset.data.value; + break; + case 9: + native.address = asset.data.value; + break; + case 10: + native.body2 = asset.data.value; + break; + case 11: + native.displayUrl = asset.data.value; + break; case 12: native.cta = asset.data.value; break; @@ -255,26 +294,42 @@ function getNormalizedNativeAd(rawNative) { } }); // Trackers - native.impressionTrackers = rawNative.imptrackers || []; - native.javascriptTrackers = rawNative.jstracker; + if (rawNative.eventtrackers) { + native.impressionTrackers = []; + rawNative.eventtrackers.forEach(tracker => { + // Only handle impression event. Viewability events are not supported yet. + if (tracker.event !== 1) return; + switch (tracker.method) { + case 1: // img + native.impressionTrackers.push(tracker.url); + break; + case 2: // js + // javascriptTrackers is a string. If there's more than one JS tracker in bid response, the last script will be used. + native.javascriptTrackers = ``; + break; + } + }); + } else { + native.impressionTrackers = rawNative.imptrackers || []; + native.javascriptTrackers = rawNative.jstracker; + } if (rawNative.link) { native.clickUrl = rawNative.link.url; native.clickTrackers = rawNative.link.clicktrackers; } + if (rawNative.privacy) { + native.privacyLink = rawNative.privacy; + } return native; } registerBidder(spec); export function ImproveDigitalAdServerJSClient(endPoint) { this.CONSTANTS = { - HTTP_SECURITY: { - STANDARD: 0, - SECURE: 1 - }, - AD_SERVER_BASE_URL: 'ad.360yield.com', + AD_SERVER_BASE_URL: 'ice.360yield.com', END_POINT: endPoint || 'hb', AD_SERVER_URL_PARAM: 'jsonp=', - CLIENT_VERSION: 'JS-5.3.0', + CLIENT_VERSION: 'JS-6.2.0', MAX_URL_LENGTH: 2083, ERROR_CODES: { MISSING_PLACEMENT_PARAMS: 2, @@ -300,6 +355,7 @@ export function ImproveDigitalAdServerJSClient(endPoint) { } requestParameters.returnObjType = requestParameters.returnObjType || this.CONSTANTS.RETURN_OBJ_TYPE.DEFAULT; + requestParameters.adServerBaseUrl = 'https://' + (requestParameters.adServerBaseUrl || this.CONSTANTS.AD_SERVER_BASE_URL); let impressionObjects = []; let impressionObject; @@ -325,7 +381,7 @@ export function ImproveDigitalAdServerJSClient(endPoint) { } let errors = null; - let baseUrl = `${(requestParameters.secure === 1 ? 'https' : 'http')}://${this.CONSTANTS.AD_SERVER_BASE_URL}/${this.CONSTANTS.END_POINT}?${this.CONSTANTS.AD_SERVER_URL_PARAM}`; + let baseUrl = `${requestParameters.adServerBaseUrl}/${this.CONSTANTS.END_POINT}?${this.CONSTANTS.AD_SERVER_URL_PARAM}`; let bidRequestObject = { bid_request: this.createBasicBidRequestObject(requestParameters, extraRequestParameters) @@ -386,12 +442,11 @@ export function ImproveDigitalAdServerJSClient(endPoint) { case this.CONSTANTS.RETURN_OBJ_TYPE.URL_PARAMS_SPLIT: return { method: 'GET', - url: `//${this.CONSTANTS.AD_SERVER_BASE_URL}/${this.CONSTANTS.END_POINT}`, + url: `${requestParameters.adServerBaseUrl}/${this.CONSTANTS.END_POINT}`, data: `${this.CONSTANTS.AD_SERVER_URL_PARAM}${encodeURIComponent(JSON.stringify(bidRequestObject))}` }; default: - const baseUrl = `${(requestParameters.secure === 1 ? 'https' : 'http')}://` + - `${this.CONSTANTS.AD_SERVER_BASE_URL}/` + + const baseUrl = `${requestParameters.adServerBaseUrl}/` + `${this.CONSTANTS.END_POINT}?${this.CONSTANTS.AD_SERVER_URL_PARAM}`; return { url: baseUrl + encodeURIComponent(JSON.stringify(bidRequestObject)) @@ -401,6 +456,7 @@ export function ImproveDigitalAdServerJSClient(endPoint) { this.createBasicBidRequestObject = function(requestParameters, extraRequestParameters) { let impressionBidRequestObject = {}; + impressionBidRequestObject.secure = 1; if (requestParameters.requestId) { impressionBidRequestObject.id = requestParameters.requestId; } else { @@ -418,9 +474,6 @@ export function ImproveDigitalAdServerJSClient(endPoint) { if (requestParameters.callback) { impressionBidRequestObject.callback = requestParameters.callback; } - if ('secure' in requestParameters) { - impressionBidRequestObject.secure = requestParameters.secure; - } if (requestParameters.libVersion) { impressionBidRequestObject.version = requestParameters.libVersion + '-' + this.CONSTANTS.CLIENT_VERSION; } @@ -455,6 +508,12 @@ export function ImproveDigitalAdServerJSClient(endPoint) { if (placementObject.currency) { impressionObject.currency = placementObject.currency.toUpperCase(); } + if (placementObject.bidFloor) { + impressionObject.bidfloor = placementObject.bidFloor; + } + if (placementObject.bidFloorCur) { + impressionObject.bidfloorcur = placementObject.bidFloorCur.toUpperCase(); + } if (placementObject.placementId) { impressionObject.pid = placementObject.placementId; } diff --git a/modules/improvedigitalBidAdapter.md b/modules/improvedigitalBidAdapter.md index d70b624171f..15602d11038 100644 --- a/modules/improvedigitalBidAdapter.md +++ b/modules/improvedigitalBidAdapter.md @@ -2,7 +2,7 @@ **Module Name**: Improve Digital Bidder Adapter **Module Type**: Bidder Adapter -**Maintainer**: hb@improvedigital.com +**Maintainer**: hb@azerion.com # Description diff --git a/modules/inskinBidAdapter.js b/modules/inskinBidAdapter.js index fbd87083b58..ae8eebcb7ae 100644 --- a/modules/inskinBidAdapter.js +++ b/modules/inskinBidAdapter.js @@ -116,9 +116,15 @@ export const spec = { if (serverResponse) { const decision = serverResponse.decisions && serverResponse.decisions[bidId]; - const price = decision && decision.pricing && decision.pricing.clearPrice; + const data = decision && decision.contents && decision.contents[0] && decision.contents[0].data; + const pubCPM = data && data.customData && data.customData.pubCPM; + const clearPrice = decision && decision.pricing && decision.pricing.clearPrice; + const price = pubCPM || clearPrice; if (decision && price) { + decision.impressionUrl += ('&property:pubcpm=' + price); + bidObj.price = price; + bid.requestId = bidId; bid.cpm = price; bid.width = decision.width; @@ -149,6 +155,7 @@ export const spec = { const id = 'ism_tag_' + Math.floor((Math.random() * 10e16)); window[id] = { bidId: e.data.bidId, + bidPrice: bidsMap[e.data.bidId].price, serverResponse }; const script = document.createElement('script'); diff --git a/modules/ixBidAdapter.js b/modules/ixBidAdapter.js index b1cc459d972..8d76d862655 100644 --- a/modules/ixBidAdapter.js +++ b/modules/ixBidAdapter.js @@ -1,7 +1,6 @@ import * as utils from '../src/utils'; import { BANNER } from '../src/mediaTypes'; import { config } from '../src/config'; -import isArray from 'core-js/library/fn/array/is-array'; import isInteger from 'core-js/library/fn/number/is-integer'; import { registerBidder } from '../src/adapters/bidderFactory'; @@ -92,7 +91,7 @@ function parseBid(rawBid, currency) { * @return {boolean} True if this is a valid size format, and false otherwise. */ function isValidSize(size) { - return isArray(size) && size.length === 2 && isInteger(size[0]) && isInteger(size[1]); + return Array.isArray(size) && size.length === 2 && isInteger(size[0]) && isInteger(size[1]); } /** @@ -185,8 +184,10 @@ export const spec = { */ buildRequests: function (validBidRequests, options) { const bannerImps = []; + const userEids = []; let validBidRequest = null; let bannerImp = null; + // Always start by assuming the protocol is HTTPS. This way, it will work // whether the page protocol is HTTP or HTTPS. Then check if the page is // actually HTTP.If we can guarantee it is, then, and only then, set protocol to @@ -201,6 +202,21 @@ export const spec = { bannerImps.push(bannerImp); } + // RTI ids will be included in the bid request if the function getIdentityInfo() is loaded + // and if the data for the partner exist + if (window.headertag && typeof window.headertag.getIdentityInfo === 'function') { + let identityInfo = window.headertag.getIdentityInfo(); + if (identityInfo && typeof identityInfo === 'object') { + for (const partnerName in identityInfo) { + if (identityInfo.hasOwnProperty(partnerName)) { + let response = identityInfo[partnerName]; + if (!response.responsePending && response.data && typeof response.data === 'object' && Object.keys(response.data).length) { + userEids.push(response.data); + } + } + } + } + } const r = {}; // Since bidderRequestId are the same for different bid request, just use the first one. @@ -210,6 +226,10 @@ export const spec = { r.site = {}; r.ext = {}; r.ext.source = 'prebid'; + if (userEids.length > 0) { + r.user = {}; + r.user.eids = userEids; + } if (document.referrer && document.referrer !== '') { r.site.ref = document.referrer; @@ -229,10 +249,9 @@ export const spec = { } if (gdprConsent.hasOwnProperty('consentString')) { - r.user = { - ext: { - consent: gdprConsent.consentString || '' - } + r.user = r.user || {}; + r.user.ext = { + consent: gdprConsent.consentString || '' }; } } diff --git a/modules/justpremiumBidAdapter.js b/modules/justpremiumBidAdapter.js index b5a2a5ac120..68b73c333ca 100644 --- a/modules/justpremiumBidAdapter.js +++ b/modules/justpremiumBidAdapter.js @@ -1,9 +1,9 @@ import { registerBidder } from '../src/adapters/bidderFactory' -import { getTopWindowLocation } from '../src/utils' +import { deepAccess } from '../src/utils'; const BIDDER_CODE = 'justpremium' const ENDPOINT_URL = '//pre.ads.justpremium.com/v/2.0/t/xhr' -const JP_ADAPTER_VERSION = '1.3' +const JP_ADAPTER_VERSION = '1.4' const pixels = [] const TRACK_START_TIME = Date.now() let LAST_PAYLOAD = {} @@ -31,8 +31,7 @@ export const spec = { }).filter((value, index, self) => { return self.indexOf(value) === index }), - hostname: getTopWindowLocation().hostname, - protocol: getTopWindowLocation().protocol.replace(':', ''), + referer: bidderRequest.refererInfo.referer, sw: dim.screenWidth, sh: dim.screenHeight, ww: dim.innerWidth, @@ -48,6 +47,14 @@ export const spec = { sizes[zone].push.apply(sizes[zone], b.sizes) }) + if (deepAccess(validBidRequests[0], 'userId.pubcid')) { + payload.pubcid = deepAccess(validBidRequests[0], 'userId.pubcid') + } else if (deepAccess(validBidRequests[0], 'crumbs.pubcid')) { + payload.pubcid = deepAccess(validBidRequests[0], 'crumbs.pubcid') + } + + payload.uids = validBidRequests[0].userId + if (bidderRequest && bidderRequest.gdprConsent) { payload.gdpr_consent = { consent_string: bidderRequest.gdprConsent.consentString, @@ -99,9 +106,9 @@ export const spec = { }, getUserSyncs: function getUserSyncs(syncOptions, responses, gdprConsent) { - let url = '//pre.ads.justpremium.com/v/1.0/t/sync' + let url = '//pre.ads.justpremium.com/v/1.0/t/sync' + '?_c=' + 'a' + Math.random().toString(36).substring(7) + Date.now(); if (gdprConsent && (typeof gdprConsent.gdprApplies === 'boolean')) { - url = url + '?consentString=' + encodeURIComponent(gdprConsent.consentString) + url = url + '&consentString=' + encodeURIComponent(gdprConsent.consentString) } if (syncOptions.iframeEnabled) { pixels.push({ diff --git a/modules/kargoBidAdapter.js b/modules/kargoBidAdapter.js index ecd26f49509..7932822e90c 100644 --- a/modules/kargoBidAdapter.js +++ b/modules/kargoBidAdapter.js @@ -5,6 +5,11 @@ const BIDDER_CODE = 'kargo'; const HOST = 'https://krk.kargo.com'; const SYNC = 'https://crb.kargo.com/api/v1/initsyncrnd/{UUID}?seed={SEED}&idx={INDEX}'; const SYNC_COUNT = 5; + +let sessionId, + lastPageUrl, + requestCounter; + export const spec = { code: BIDDER_CODE, isBidRequestValid: function(bid) { @@ -17,8 +22,18 @@ export const spec = { const currencyObj = config.getConfig('currency'); const currency = (currencyObj && currencyObj.adServerCurrency) || 'USD'; const bidIds = {}; - utils._each(validBidRequests, bid => bidIds[bid.bidId] = bid.params.placementId); + const bidSizes = {}; + utils._each(validBidRequests, bid => { + bidIds[bid.bidId] = bid.params.placementId; + bidSizes[bid.bidId] = bid.sizes; + }); + let tdid; + if (validBidRequests.length > 0 && validBidRequests[0].userId && validBidRequests[0].userId.tdid) { + tdid = validBidRequests[0].userId.tdid; + } const transformedParams = Object.assign({}, { + sessionId: spec._getSessionId(), + requestCount: spec._getRequestCount(), timeout: bidderRequest.timeout, currency: currency, cpmGranularity: 1, @@ -27,8 +42,10 @@ export const spec = { floor: 0, ceil: 20 }, - bidIDs: bidIds - }, spec._getAllMetadata()); + bidIDs: bidIds, + bidSizes: bidSizes, + prebidRawBidRequests: validBidRequests + }, spec._getAllMetadata(tdid)); const encodedParams = encodeURIComponent(JSON.stringify(transformedParams)); return Object.assign({}, bidderRequest, { method: 'GET', @@ -152,14 +169,18 @@ export const spec = { } }, - _getUserIds() { + _getUserIds(tdid) { const crb = spec._getCrb(); - return { + const userIds = { kargoID: crb.userId, clientID: crb.clientId, crbIDs: crb.syncIds || {}, optOut: crb.optOut }; + if (tdid) { + userIds.tdID = tdid; + } + return userIds; }, _getClientId() { @@ -167,9 +188,9 @@ export const spec = { return crb.clientId; }, - _getAllMetadata() { + _getAllMetadata(tdid) { return { - userIDs: spec._getUserIds(), + userIDs: spec._getUserIds(tdid), krux: spec._getKrux(), pageURL: window.location.href, rawCRB: spec._readCookie('krg_crb'), @@ -177,6 +198,21 @@ export const spec = { }; }, + _getSessionId() { + if (!sessionId) { + sessionId = spec._generateRandomUuid(); + } + return sessionId; + }, + + _getRequestCount() { + if (lastPageUrl === window.location.pathname) { + return ++requestCounter; + } + lastPageUrl = window.location.pathname; + return requestCounter = 0; + }, + _generateRandomUuid() { try { // crypto.getRandomValues is supported everywhere but Opera Mini for years diff --git a/modules/livewrappedAnalyticsAdapter.js b/modules/livewrappedAnalyticsAdapter.js index 272ccadfbcf..72c46de744d 100644 --- a/modules/livewrappedAnalyticsAdapter.js +++ b/modules/livewrappedAnalyticsAdapter.js @@ -17,10 +17,12 @@ export const BID_WON_TIMEOUT = 500; const cache = { auctions: {}, + bidAdUnits: {} }; let livewrappedAnalyticsAdapter = Object.assign(adapter({EMPTYURL, ANALYTICSTYPE}), { track({eventType, args}) { + const time = utils.timestamp(); utils.logInfo('LIVEWRAPPED_EVENT:', [eventType, args]); switch (eventType) { @@ -30,16 +32,18 @@ let livewrappedAnalyticsAdapter = Object.assign(adapter({EMPTYURL, ANALYTICSTYPE break; case CONSTANTS.EVENTS.BID_REQUESTED: utils.logInfo('LIVEWRAPPED_BID_REQUESTED:', args); + cache.auctions[args.auctionId].timeStamp = args.start; args.bids.forEach(function(bidRequest) { - cache.auctions[args.auctionId].timeStamp = args.start; cache.auctions[args.auctionId].bids[bidRequest.bidId] = { bidder: bidRequest.bidder, adUnit: bidRequest.adUnitCode, isBid: false, won: false, timeout: false, - sendStatus: 0 + sendStatus: 0, + readyToSend: 0, + start: args.start } utils.logInfo(bidRequest); @@ -49,25 +53,33 @@ let livewrappedAnalyticsAdapter = Object.assign(adapter({EMPTYURL, ANALYTICSTYPE case CONSTANTS.EVENTS.BID_RESPONSE: utils.logInfo('LIVEWRAPPED_BID_RESPONSE:', args); - let bidResponse = cache.auctions[args.auctionId].bids[args.adId]; + let bidResponse = cache.auctions[args.auctionId].bids[args.requestId]; bidResponse.isBid = args.getStatusCode() === CONSTANTS.STATUS.GOOD; bidResponse.width = args.width; bidResponse.height = args.height; bidResponse.cpm = args.cpm; bidResponse.ttr = args.timeToRespond; + bidResponse.readyToSend = 1; + if (!bidResponse.ttr) { + bidResponse.ttr = time - bidResponse.start; + } + if (!cache.bidAdUnits[bidResponse.adUnit]) { + cache.bidAdUnits[bidResponse.adUnit] = {sent: 0, timeStamp: cache.auctions[args.auctionId].timeStamp}; + } break; case CONSTANTS.EVENTS.BIDDER_DONE: utils.logInfo('LIVEWRAPPED_BIDDER_DONE:', args); args.bids.forEach(doneBid => { - let bid = cache.auctions[doneBid.auctionId].bids[doneBid.bidId]; + let bid = cache.auctions[doneBid.auctionId].bids[doneBid.bidId || doneBid.requestId]; if (!bid.ttr) { - bid.ttr = Date.now() - args.auctionStart; + bid.ttr = time - bid.start; } + bid.readyToSend = 1; }); break; case CONSTANTS.EVENTS.BID_WON: utils.logInfo('LIVEWRAPPED_BID_WON:', args); - let wonBid = cache.auctions[args.auctionId].bids[args.adId]; + let wonBid = cache.auctions[args.auctionId].bids[args.requestId]; wonBid.won = true; if (wonBid.sendStatus != 0) { livewrappedAnalyticsAdapter.sendEvents(); @@ -105,7 +117,9 @@ livewrappedAnalyticsAdapter.sendEvents = function() { requests: getSentRequests(), responses: getResponses(), wins: getWins(), - timeouts: getTimeouts() + timeouts: getTimeouts(), + bidAdUnits: getbidAdUnits(), + rcv: getAdblockerRecovered() }; if (events.requests.length == 0 && @@ -118,6 +132,12 @@ livewrappedAnalyticsAdapter.sendEvents = function() { ajax(URL, undefined, JSON.stringify(events), {method: 'POST'}); } +function getAdblockerRecovered() { + try { + return utils.getWindowTop().I12C && utils.getWindowTop().I12C.Morph === 1; + } catch (e) {} +} + function getSentRequests() { var sentRequests = []; @@ -147,7 +167,7 @@ function getResponses() { Object.keys(cache.auctions[auctionId].bids).forEach(bidId => { let auction = cache.auctions[auctionId]; let bid = auction.bids[bidId]; - if (!(bid.sendStatus & RESPONSESENT) && !bid.timeout) { + if (bid.readyToSend && !(bid.sendStatus & RESPONSESENT) && !bid.timeout) { bid.sendStatus |= RESPONSESENT; responses.push({ @@ -214,6 +234,24 @@ function getTimeouts() { return timeouts; } +function getbidAdUnits() { + var bidAdUnits = []; + + Object.keys(cache.bidAdUnits).forEach(adUnit => { + let bidAdUnit = cache.bidAdUnits[adUnit]; + if (!bidAdUnit.sent) { + bidAdUnit.sent = 1; + + bidAdUnits.push({ + adUnit: adUnit, + timeStamp: bidAdUnit.timeStamp + }); + } + }); + + return bidAdUnits; +} + adapterManager.registerAnalyticsAdapter({ adapter: livewrappedAnalyticsAdapter, code: 'livewrapped' diff --git a/modules/livewrappedBidAdapter.js b/modules/livewrappedBidAdapter.js index 69a89421a32..1ad18cb15eb 100644 --- a/modules/livewrappedBidAdapter.js +++ b/modules/livewrappedBidAdapter.js @@ -24,6 +24,7 @@ export const spec = { * seats: List of bidders and seats Optional. {"bidder name": ["seat 1", "seat 2"], ...} * deviceId: Device id if available Optional. * ifa: Advertising ID Optional. + * options Dynamic data Optional. Optional data to send into adapter. * * @param {BidRequest} bid The bid params to validate. * @return boolean True if this is a valid bid, and false otherwise. @@ -69,6 +70,7 @@ export const spec = { gdprApplies: bidderRequest.gdprConsent ? bidderRequest.gdprConsent.gdprApplies : undefined, gdprConsent: bidderRequest.gdprConsent ? bidderRequest.gdprConsent.consentString : undefined, cookieSupport: !utils.isSafariBrowser() && utils.cookiesAreEnabled(), + rcv: getAdblockerRecovered(), adRequests: [...adRequests] }; const payloadString = JSON.stringify(payload); @@ -178,7 +180,8 @@ function bidToAdRequest(bid) { callerAdUnitId: bid.params.adUnitName || bid.adUnitCode || bid.placementCode, bidId: bid.bidId, transactionId: bid.transactionId, - formats: bid.sizes.map(sizeToFormat) + formats: bid.sizes.map(sizeToFormat), + options: bid.params.options }; } @@ -189,4 +192,10 @@ function sizeToFormat(size) { } } +function getAdblockerRecovered() { + try { + return utils.getWindowTop().I12C && utils.getWindowTop().I12C.Morph === 1; + } catch (e) {} +} + registerBidder(spec); diff --git a/modules/lkqdBidAdapter.js b/modules/lkqdBidAdapter.js index a97939c15b1..a39abb320b2 100644 --- a/modules/lkqdBidAdapter.js +++ b/modules/lkqdBidAdapter.js @@ -30,7 +30,7 @@ function isBidRequestValid(bidRequest) { return false; } -function buildRequests(validBidRequests) { +function buildRequests(validBidRequests, bidderRequest) { let bidRequests = []; for (let i = 0; i < validBidRequests.length; i++) { @@ -138,6 +138,8 @@ function buildRequests(validBidRequests) { } if (bidRequest.params.hasOwnProperty('pageurl') && bidRequest.params.pageurl != null) { sspData.pageurl = bidRequest.params.pageurl; + } else if (bidderRequest && bidderRequest.refererInfo) { + sspData.pageurl = encodeURIComponent(bidderRequest.refererInfo.referer); } if (bidRequest.params.hasOwnProperty('contentId') && bidRequest.params.contentId != null) { sspData.contentid = bidRequest.params.contentId; diff --git a/modules/lockerdomeBidAdapter.md b/modules/lockerdomeBidAdapter.md index 2e2e69a7557..2dbec86ffba 100644 --- a/modules/lockerdomeBidAdapter.md +++ b/modules/lockerdomeBidAdapter.md @@ -22,7 +22,7 @@ var adUnits = [{ bids: [{ bidder: 'lockerdome', params: { - adUnitId: 10809467961050726 + adUnitId: 'LD10809467961050726' } }] }]; diff --git a/modules/logicadBidAdapter.js b/modules/logicadBidAdapter.js new file mode 100644 index 00000000000..65d765c30a3 --- /dev/null +++ b/modules/logicadBidAdapter.js @@ -0,0 +1,68 @@ +import {registerBidder} from '../src/adapters/bidderFactory'; +import {BANNER} from '../src/mediaTypes'; + +const BIDDER_CODE = 'logicad'; +const ENDPOINT_URL = 'https://pb.ladsp.com/adrequest/prebid'; + +export const spec = { + code: BIDDER_CODE, + supportedMediaTypes: [BANNER], + isBidRequestValid: function (bid) { + return !!(bid.params && bid.params.tid); + }, + buildRequests: function (bidRequests, bidderRequest) { + const requests = []; + for (let i = 0, len = bidRequests.length; i < len; i++) { + const request = { + method: 'POST', + url: ENDPOINT_URL, + data: JSON.stringify(newBidRequest(bidRequests[i], bidderRequest)), + options: {}, + bidderRequest + }; + requests.push(request); + } + return requests; + }, + interpretResponse: function (serverResponse, bidderRequest) { + serverResponse = serverResponse.body; + const bids = []; + if (!serverResponse || serverResponse.error) { + return bids; + } + serverResponse.seatbid.forEach(function (seatbid) { + bids.push(seatbid.bid); + }) + return bids; + }, + getUserSyncs: function (syncOptions, serverResponses) { + if (serverResponses.length > 0 && serverResponses[0].body.userSync && + syncOptions.pixelEnabled && serverResponses[0].body.userSync.type == 'image') { + return [{ + type: 'image', + url: serverResponses[0].body.userSync.url + }]; + } + return []; + }, +}; + +function newBidRequest(bid, bidderRequest) { + return { + auctionId: bid.auctionId, + bidderRequestId: bid.bidderRequestId, + bids: [{ + adUnitCode: bid.adUnitCode, + bidId: bid.bidId, + transactionId: bid.transactionId, + sizes: bid.sizes, + params: bid.params, + mediaTypes: bid.mediaTypes + }], + prebidJsVersion: '$prebid.version$', + referrer: bidderRequest.refererInfo.referer, + auctionStartTime: bidderRequest.auctionStart, + }; +} + +registerBidder(spec); diff --git a/modules/logicadBidAdapter.md b/modules/logicadBidAdapter.md new file mode 100644 index 00000000000..32d40a7d3cd --- /dev/null +++ b/modules/logicadBidAdapter.md @@ -0,0 +1,25 @@ +# Overview +``` +Module Name: Logicad for Publishers +Module Type: Bidder Adapter +Maintainer: prebid@so-netmedia.jp +``` + +# Description +Module that connects to Logicad's demand sources. +Currently module supports only banner mediaType. + +# Test Parameters +``` + var adUnits = [{ + code: 'test-code', + sizes: [[300, 250],[300, 600]], + bids: [{ + bidder: 'logicad', + params: { + tid: 'test', + page: 'url', + } + }] + }]; +``` diff --git a/modules/loopmeBidAdapter.js b/modules/loopmeBidAdapter.js index fb2f891d3b0..dd0c7e38553 100644 --- a/modules/loopmeBidAdapter.js +++ b/modules/loopmeBidAdapter.js @@ -1,6 +1,7 @@ -import * as utils from 'src/utils'; -import { registerBidder } from 'src/adapters/bidderFactory'; -import { BANNER } from 'src/mediaTypes'; +import * as utils from '../src/utils'; +import { registerBidder } from '../src/adapters/bidderFactory'; +import { BANNER, VIDEO } from '../src/mediaTypes'; +import { Renderer } from '../src/Renderer'; const LOOPME_ENDPOINT = 'https://loopme.me/api/hb'; @@ -16,7 +17,7 @@ const entries = (obj) => { export const spec = { code: 'loopme', - supportedMediaTypes: [BANNER], + supportedMediaTypes: [BANNER, VIDEO], /** * @param {object} bid * @return boolean @@ -46,14 +47,17 @@ export const spec = { .map(item => `${item[0]}=${encodeURI(item[1])}`) .join('&'); + const adUnitSizes = bidRequest.mediaTypes[BANNER] + ? utils.getAdUnitSizes(bidRequest) + : utils.deepAccess(bidRequest.mediaTypes, 'video.playerSize'); + const sizes = '&sizes=' + - utils - .getAdUnitSizes(bidRequest) + adUnitSizes .map(size => `${size[0]}x${size[1]}`) .join('&sizes='); - queryString = `${queryString}${sizes}`; + queryString = `${queryString}${sizes}${bidRequest.mediaTypes[VIDEO] ? '&media_type=video' : ''}`; return { method: 'GET', @@ -71,14 +75,58 @@ export const spec = { */ interpretResponse: function(response = {}, bidRequest) { const responseObj = response.body; + if ( + responseObj === null || + typeof responseObj !== 'object' + ) { + return []; + } if ( - responseObj == null || - typeof responseObj !== 'object' || - !responseObj.hasOwnProperty('ad') + !responseObj.hasOwnProperty('ad') && + !responseObj.hasOwnProperty('vastUrl') ) { return []; } + // responseObj.vastUrl = 'https://rawgit.com/InteractiveAdvertisingBureau/VAST_Samples/master/VAST%201-2.0%20Samples/Inline_NonLinear_Verification_VAST2.0.xml'; + if (responseObj.vastUrl) { + const renderer = Renderer.install({ + id: bidRequest.bidId, + url: 'https://i.loopme.me/html/vast/loopme_flex.js', + loaded: false + }); + renderer.setRender((bid) => { + renderer.push(function () { + var adverts = [{ + 'type': 'VAST', + 'url': bid.vastUrl, + 'autoClose': -1 + }]; + var config = { + containerId: bid.adUnitCode, + vastTimeout: 250, + ads: adverts, + user_consent: '%%USER_CONSENT%%', + }; + window.L.flex.loader.load(config); + }) + }); + return [ + { + requestId: bidRequest.bidId, + cpm: responseObj.cpm, + width: responseObj.width, + height: responseObj.height, + ttl: responseObj.ttl, + currency: responseObj.currency, + creativeId: responseObj.creativeId, + dealId: responseObj.dealId, + netRevenue: responseObj.netRevenue, + vastUrl: responseObj.vastUrl, + renderer + } + ]; + } return [ { diff --git a/modules/loopmeBidAdapter.md b/modules/loopmeBidAdapter.md index be8c20cfade..1b195a118f2 100644 --- a/modules/loopmeBidAdapter.md +++ b/modules/loopmeBidAdapter.md @@ -10,7 +10,7 @@ Maintainer: support@loopme.com Connect to LoopMe's exchange for bids. -# Test Parameters +# Test Parameters (Banner) ``` var adUnits = [{ code: 'test-div', @@ -27,3 +27,22 @@ var adUnits = [{ }] }]; ``` + +# Test Parameters (Video) +``` +var adUnits = [{ + code: 'video1', + mediaTypes: { + video: { + playerSize: [640, 480], + context: 'outstream' + } + }, + bids: [{ + bidder: 'loopme', + params: { + ak: '223051e07f' + } + }] +}]; +``` diff --git a/modules/marsmediaBidAdapter.js b/modules/marsmediaBidAdapter.js new file mode 100644 index 00000000000..09eb4ac6c75 --- /dev/null +++ b/modules/marsmediaBidAdapter.js @@ -0,0 +1,130 @@ +import * as utils from '../src/utils'; +import {registerBidder} from '../src/adapters/bidderFactory'; +const BIDDER_CODE = 'marsmedia'; + +function getDomain() { + if (!utils.inIframe()) { + return window.location.hostname + } + let origins = window.document.location.ancestorOrigins + if (origins && origins.length > 0) { + return origins[origins.length - 1] + } +} + +export const spec = { + code: BIDDER_CODE, + aliases: ['mars'], + isBidRequestValid: function(bid) { + return (bid.params.publisherID !== null); + }, + buildRequests: function(validBidRequests, bidderRequest) { + try { + let protocol = (window.location.protocol === 'https:'); + const parse = getSize(validBidRequests[0].sizes); + const publisherId = validBidRequests[0].params.publisherID; + const payload = { + id: validBidRequests[0].bidId, + cur: ['USD'], + + language: window.navigator.userLanguage || window.navigator.language, + site: { + id: publisherId, + domain: getDomain(), + page: document.URL, + ref: document.referrer, + publisher: { + id: publisherId, + domain: getDomain() + } + }, + imp: [{ + id: utils.getUniqueIdentifierStr(), + banner: { + w: parse.width, + h: parse.height, + secure: protocol + }, + bidfloor: parseFloat(validBidRequests[0].params.floor) > 0 ? validBidRequests[0].params.floor : 0 + }], + device: { + ua: navigator.userAgent + }, + user: { + id: publisherId + }, + publisher: { + id: publisherId, + domain: getDomain() + } + }; + + if (bidderRequest && bidderRequest.gdprConsent) { + payload.gdpr = { + applies: bidderRequest.gdprConsent.gdprApplies, + consent: bidderRequest.gdprConsent.consentString + }; + } + + return { + method: 'POST', + url: '//bid306.rtbsrv.com/bidder/?bid=3mhdom', + data: JSON.stringify(payload) + }; + } catch (e) { + utils.logError(e, {validBidRequests, bidderRequest}); + } + }, + interpretResponse: function(serverResponse, bidRequest) { + const bidResponses = []; + let res = serverResponse.body; + if (!res) { + return [] + } + + for (let x = 0; x < res.seatbid.length; x++) { + var bidAd = res.seatbid[x].bid[0]; + + bidResponses.push({ + requestId: res.id, + cpm: Number(bidAd.price), + width: bidAd.w, + height: bidAd.h, + ad: bidAd.adm, + ttl: 60, + creativeId: bidAd.cid, + netRevenue: true, + currency: 'USD' + }) + } + + return bidResponses; + }, + getUserSyncs: function(syncOptions, serverResponses) { + return []; + } +}; + +function getSize(requestSizes) { + const parsed = {}; + const size = utils.parseSizesInput(requestSizes)[0]; + + if (typeof size !== 'string') { + return parsed; + } + + const parsedSize = size.toUpperCase().split('X'); + const width = parseInt(parsedSize[0], 10); + if (width) { + parsed.width = width; + } + + const height = parseInt(parsedSize[1], 10); + if (height) { + parsed.height = height; + } + + return parsed; +} + +registerBidder(spec); diff --git a/modules/marsmediaBidAdapter.md b/modules/marsmediaBidAdapter.md new file mode 100644 index 00000000000..fee962f9173 --- /dev/null +++ b/modules/marsmediaBidAdapter.md @@ -0,0 +1,32 @@ +# Overview + +``` +Module Name: Mars Media Group (mars.media) Bidder Adapter +Module Type: Bidder Adapter +Maintainer: vladi@mars.media +``` + +# Description + +Prebid adapter for Mars Media Group RTB. Requires approval and account setup. + +# Test Parameters + +## Web +``` + var adUnits = [ + { + code: 'test-div', + sizes: [[300, 250]], + bids: [ + { + bidder: "marsmedia", + params: { + publisherID: 9999, + floor: 0.11 + } + } + ] + } + ]; +``` \ No newline at end of file diff --git a/modules/meazyBidAdapter.js b/modules/meazyBidAdapter.js new file mode 100644 index 00000000000..8604ef770da --- /dev/null +++ b/modules/meazyBidAdapter.js @@ -0,0 +1,149 @@ +import * as utils from '../src/utils'; +import { registerBidder } from '../src/adapters/bidderFactory'; +import { BANNER } from '../src/mediaTypes'; + +const BIDDER_CODE = 'meazy'; +const PREBID_ENDPOINT = 'rtb-filter.meazy.co'; +const SYNC_ENDPOINT = '//sync.meazy.co/sync/iframe'; +const ENDPOINT_CONFIG = { + defaultCurrency: ['USD'], + availableSize: ['300x250', '320x480', '160x600'] +}; + +const buildURI = (pid) => { + return `//${PREBID_ENDPOINT}/pbjs?host=${utils.getOrigin()}&api_key=${pid}`; +} + +const validateSize = (size) => { + return ENDPOINT_CONFIG.availableSize.indexOf(size.join('x')) !== -1; +} + +const buildImpression = (bidRequest) => { + const impression = { + id: utils.getUniqueIdentifierStr(), + tagid: bidRequest.adUnitCode, + banner: { + format: bidRequest.sizes.map(size => ({ w: size[0], h: size[1] })) + } + }; + + return impression; +} + +export const spec = { + code: BIDDER_CODE, + supportedMediaTypes: [BANNER], + + /** + * Determines whether or not the given bid request is valid. + * + * @param {object} bid The bid to validate. + * @return boolean True if this is a valid bid, and false otherwise. + */ + isBidRequestValid: function(bid) { + return !!bid.params.pid && bid.sizes.some(validateSize); + }, + + /** + * Make a server request from the list of BidRequests. + * + * @param {BidRequest[]} bidRequests A non-empty list of bid requests which should be sent to the Server. + * @return ServerRequest Info describing the request to the server. + */ + buildRequests: function(bidRequests, bidderRequest) { + const payload = { + id: bidRequests[0].bidId, + site: { + domain: utils.getOrigin() + }, + device: { + w: window.screen.width, + h: window.screen.height, + language: navigator.language + }, + cur: ENDPOINT_CONFIG.defaultCurrency, + imp: bidRequests.map(buildImpression), + user: {} + }; + + if (bidderRequest.refererInfo) { + if (bidderRequest.refererInfo.referer) { + payload.site.ref = bidderRequest.refererInfo.referer; + } + + if (utils.isArray(bidderRequest.refererInfo) && bidderRequest.refererInfo.stack.length > 0) { + payload.site.page = bidderRequest.refererInfo.stack[0]; + } + } + + if (utils.deepAccess(bidderRequest, 'gdprConsent.gdprApplies')) { + payload.user.ext = { + consent: bidderRequest.gdprConsent.consentString, + gdpr: bidderRequest.gdprConsent.gdprApplies & 1 + } + } + + const payloadString = JSON.stringify(payload); + + return { + method: 'POST', + url: buildURI(bidRequests[0].params.pid), + data: payloadString + }; + }, + + /** + * Unpack the response from the server into a list of bids. + * + * @param {*} serverResponse A successful response from the server. + * @return {Bid[]} An array of bids which were nested inside the server. + */ + interpretResponse: function(serverResponse) { + const bids = []; + + if (!utils.isArray(serverResponse.body.seatbid) || !serverResponse.body.seatbid[0]) { + return bids; + } + + serverResponse.body.seatbid[0].bid.forEach(bidResponse => { + const bid = { + requestId: serverResponse.body.id, + cpm: bidResponse.price, + width: bidResponse.w, + height: bidResponse.h, + creativeId: bidResponse.crid, + netRevenue: bidResponse.netRevenue !== undefined ? bidResponse.netRevenue : true, + dealId: bidResponse.dealid, + currency: ENDPOINT_CONFIG.defaultCurrency[0], + ttl: bidResponse.exp || 900, + ad: bidResponse.adm + } + + bids.push(bid); + }); + + return bids; + }, + + getUserSyncs: function(syncOptions, serverResponses) { + const syncs = []; + + if (syncOptions.pixelEnabled && serverResponses[0] && utils.deepAccess(serverResponses[0], 'body.ext.syncUrl')) { + syncs.push({ + type: 'image', + url: serverResponses[0].body.ext.syncUrl + }); + } + + if (syncOptions.iframeEnabled) { + syncs.push({ + type: 'iframe', + url: SYNC_ENDPOINT + }); + } + + return syncs; + } +} + +registerBidder(spec); diff --git a/modules/meazyBidAdapter.md b/modules/meazyBidAdapter.md new file mode 100644 index 00000000000..354673bf590 --- /dev/null +++ b/modules/meazyBidAdapter.md @@ -0,0 +1,23 @@ +# Overview + +Module Name: Meazy Bidder Adapter +Module Type: Bidder Adapter +Maintainer: dima@meazy.co + +# Description + +Module that connects to Meazy demand sources + +# Test Parameters +``` +var adUnits = [{ + code: 'test-div', + sizes: [[300, 250]], + bids: [{ + bidder: "meazy", + params: { + pid: '6910b7344ae566a1' + } + }] +}]; +``` \ No newline at end of file diff --git a/modules/mgidBidAdapter.js b/modules/mgidBidAdapter.js index 5a91cccde9e..154c00f6a06 100644 --- a/modules/mgidBidAdapter.js +++ b/modules/mgidBidAdapter.js @@ -1,16 +1,71 @@ -import {registerBidder} from 'src/adapters/bidderFactory'; +import {registerBidder} from '../src/adapters/bidderFactory'; import * as utils from '../src/utils'; import * as urlUtils from '../src/url'; -import { BANNER } from 'src/mediaTypes'; +import {BANNER, NATIVE} from '../src/mediaTypes'; +import {config} from '../src/config'; +const DEFAULT_CUR = 'USD'; const BIDDER_CODE = 'mgid'; -const ENDPOINT_URL = '//dsp.mgid.com/prebid/'; +const ENDPOINT_URL = 'https://prebid.mgid.com/prebid/'; +const LOG_WARN_PREFIX = '[MGID warn]: '; +const LOG_INFO_PREFIX = '[MGID info]: '; +const NATIVE_ASSETS = { + 'TITLE': { ID: 1, KEY: 'title', TYPE: 0 }, + 'IMAGE': { ID: 2, KEY: 'image', TYPE: 0 }, + 'ICON': { ID: 3, KEY: 'icon', TYPE: 0 }, + 'SPONSOREDBY': { ID: 4, KEY: 'sponsoredBy', TYPE: 1 }, // please note that type of SPONSORED is also 1 + 'DESC': { ID: 5, KEY: 'data', TYPE: 2 }, // please note that type of BODY is also set to 2 + 'PRICE': { ID: 6, KEY: 'price', TYPE: 6 }, + 'SALEPRICE': { ID: 7, KEY: 'saleprice', TYPE: 7 }, + 'DISPLAYURL': { ID: 8, KEY: 'displayurl', TYPE: 11 }, + 'CTA': { ID: 9, KEY: 'cta', TYPE: 12 }, + 'BODY': { ID: 10, KEY: 'body', TYPE: 2 }, // please note that type of DESC is also set to 2 + 'SPONSORED': { ID: 11, KEY: 'sponsored', TYPE: 1 }, // please note that type of SPONSOREDBY is also set to 1 +}; +const NATIVE_ASSET_IMAGE_TYPE = { + 'ICON': 1, + 'IMAGE': 3 +}; +const DEFAULT_IMAGE_WIDTH = 492; +const DEFAULT_IMAGE_HEIGHT = 328; +const DEFAULT_ICON_WIDTH = 50; +const DEFAULT_ICON_HEIGHT = 50; +const DEFAULT_TITLE_LENGTH = 80; + +let isInvalidNativeRequest = false; + +// check if title, image can be added with mandatory field default values +const NATIVE_MINIMUM_REQUIRED_IMAGE_ASSETS = [ + { + id: NATIVE_ASSETS.SPONSOREDBY.ID, + required: true, + data: { + type: 1 + } + }, + { + id: NATIVE_ASSETS.TITLE.ID, + required: true, + }, + { + id: NATIVE_ASSETS.IMAGE.ID, + required: true, + } +]; +let _NATIVE_ASSET_ID_TO_KEY_MAP = {}; +let _NATIVE_ASSET_KEY_TO_ASSET_MAP = {}; + +// loading _NATIVE_ASSET_ID_TO_KEY_MAP +utils._each(NATIVE_ASSETS, anAsset => { _NATIVE_ASSET_ID_TO_KEY_MAP[anAsset.ID] = anAsset.KEY }); +// loading _NATIVE_ASSET_KEY_TO_ASSET_MAP +utils._each(NATIVE_ASSETS, anAsset => { _NATIVE_ASSET_KEY_TO_ASSET_MAP[anAsset.KEY] = anAsset }); export const spec = { - VERSION: '1.0', + VERSION: '1.4', code: BIDDER_CODE, - aliases: ['mgid'], // short code - supportedMediaTypes: [BANNER], - reId: /^[0-9]+$/, + supportedMediaTypes: [BANNER, NATIVE], + reId: /^[1-9][0-9]*$/, + NATIVE_ASSET_ID_TO_KEY_MAP: _NATIVE_ASSET_ID_TO_KEY_MAP, + NATIVE_ASSET_KEY_TO_ASSET_MAP: _NATIVE_ASSET_KEY_TO_ASSET_MAP, /** * Determines whether or not the given bid request is valid. * @@ -19,16 +74,38 @@ export const spec = { */ isBidRequestValid: (bid) => { const banner = utils.deepAccess(bid, 'mediaTypes.banner'); - const sizes = utils.deepAccess(banner, 'sizes'); - let sizesOk = typeof (sizes) == 'object' && sizes.length > 0; - for (let f = 0; sizesOk && f < sizes.length; f++) { - sizesOk = sizes[f].length == 2; - } - return typeof (bid.params) == 'object' && !!bid.params.accountId && !!bid.params.placementId && - typeof (bid.params.accountId) == 'string' && typeof (bid.params.placementId) == 'string' && - bid.params.accountId.length > 0 && bid.params.placementId.length > 0 && - bid.params.accountId.toString().match(spec.reId) > 0 && bid.params.placementId.toString().match(spec.reId) && - typeof (banner) == 'object' && sizesOk; + const native = utils.deepAccess(bid, 'mediaTypes.native'); + let nativeOk = utils.isPlainObject(native); + if (nativeOk) { + const nativeParams = utils.deepAccess(bid, 'nativeParams'); + let assetsCount = 0; + if (utils.isPlainObject(nativeParams)) { + for (let k in nativeParams) { + let v = nativeParams[k]; + const supportProp = spec.NATIVE_ASSET_KEY_TO_ASSET_MAP.hasOwnProperty(k); + if (supportProp) { + assetsCount++ + } + if (!utils.isPlainObject(v) || (!supportProp && utils.deepAccess(v, 'required'))) { + nativeOk = false; + break; + } + } + } + nativeOk = nativeOk && (assetsCount > 0); + } + let bannerOk = utils.isPlainObject(banner); + if (bannerOk) { + const sizes = utils.deepAccess(banner, 'sizes'); + bannerOk = utils.isArray(sizes) && sizes.length > 0; + for (let f = 0; bannerOk && f < sizes.length; f++) { + bannerOk = sizes[f].length === 2; + } + } + let acc = Number(bid.params.accountId); + let plcmt = Number(bid.params.placementId); + return (bannerOk || nativeOk) && utils.isPlainObject(bid.params) && !!bid.adUnitCode && utils.isStr(bid.adUnitCode) && (plcmt > 0 ? bid.params.placementId.toString().search(spec.reId) === 0 : true) && + !!acc && acc > 0 && bid.params.accountId.toString().search(spec.reId) === 0; }, /** * Make a server request from the list of BidRequests. @@ -37,75 +114,82 @@ export const spec = { * @return ServerRequest Info describing the request to the server. */ buildRequests: (validBidRequests, bidderRequest) => { - utils.logInfo(`MGID DEBUG: buildRequests`); - if (validBidRequests.length == 0) { - return null; + utils.logInfo(LOG_INFO_PREFIX + `buildRequests`); + if (validBidRequests.length === 0) { + return; } - const referer = utils.deepAccess(bidderRequest, 'refererInfo.referer'); - const hostname = urlUtils.parse(referer).hostname; + const info = pageInfo(); + const page = info.location || utils.deepAccess(bidderRequest, 'refererInfo.referer') || utils.deepAccess(bidderRequest, 'refererInfo.canonicalUrl'); + const hostname = urlUtils.parse(page).hostname; let domain = extractDomainFromHost(hostname) || hostname; const accountId = setOnAny(validBidRequests, 'params.accountId'); const muid = getLocalStorageSafely('mgMuidn'); let url = (setOnAny(validBidRequests, 'params.bidUrl') || ENDPOINT_URL) + accountId; - if (muid != null && typeof (muid) == 'string' && muid.length > 0) { + if (utils.isStr(muid) && muid.length > 0) { url += '?muid=' + muid; } - const page = utils.deepAccess(bidderRequest, 'refererInfo.canonicalUrl') || referer; + const cur = [setOnAny(validBidRequests, 'params.currency') || setOnAny(validBidRequests, 'params.cur') || config.getConfig('currency.adServerCurrency') || DEFAULT_CUR]; const secure = window.location.protocol === 'https:' ? 1 : 0; - const imp = validBidRequests.map((bid, id) => { - const placeId = utils.deepAccess(bid, 'params.placementId'); - const sizes = utils.deepAccess(bid, 'mediaTypes.banner.sizes'); - let format = []; - if (sizes.length > 1) { - for (let f = 0; f < sizes.length; f++) { - if (sizes[f].length == 2) { - format.push({w: sizes[f][0], h: sizes[f][1]}); - } - } - } - return { + let imp = []; + validBidRequests.forEach(bid => { + let tagid = utils.deepAccess(bid, 'params.placementId') || 0; + tagid = !tagid ? bid.adUnitCode : tagid + '/' + bid.adUnitCode; + let impObj = { id: bid.bidId, - tagid: placeId, - banner: { - w: sizes && sizes[0][0], - h: sizes && sizes[0][1], - format, - }, + tagid, secure, }; + const bidFloor = utils.deepAccess(bid, 'params.bidFloor') || utils.deepAccess(bid, 'params.bidfloor') || 0; + if (bidFloor && utils.isNumber(bidFloor)) { + impObj.bidfloor = bidFloor; + } + for (let mediaTypes in bid.mediaTypes) { + switch (mediaTypes) { + case BANNER: + impObj.banner = createBannerRequest(bid); + imp.push(impObj); + break; + case NATIVE: + const native = createNativeRequest(bid.nativeParams); + if (!isInvalidNativeRequest) { + impObj.native = { + 'request': native + }; + imp.push(impObj); + } + break; + } + } }); - let ext = {mgid_ver: spec.VERSION, prebid_ver: $$PREBID_GLOBAL$$.version}; - let user = {}; - let regs = {}; - if (bidderRequest && bidderRequest.gdprConsent) { - user.ext = { - consent: bidderRequest.gdprConsent.consentString - }; - - regs.ext = { - gdpr: (bidderRequest.gdprConsent.gdprApplies ? 1 : 0) - }; + if (imp.length === 0) { + return; } - const request = { + let request = { id: utils.deepAccess(bidderRequest, 'bidderRequestId'), - site: { domain, page }, - cur: ['USD'], + site: {domain, page}, + cur: cur, + geo: {utcoffset: info.timeOffset}, device: { ua: navigator.userAgent, js: 1, - dnt: (navigator.doNotTrack == 'yes' || navigator.doNotTrack == '1' || navigator.msDoNotTrack == '1') ? 1 : 0, + dnt: (navigator.doNotTrack === 'yes' || navigator.doNotTrack === '1' || navigator.msDoNotTrack === '1') ? 1 : 0, h: screen.height, w: screen.width, language: getLanguage() }, - user, - regs, - ext, + ext: {mgid_ver: spec.VERSION, prebid_ver: $$PREBID_GLOBAL$$.version}, imp }; - utils.logInfo(`MGID DEBUG: buildRequests\n${request}`); + if (bidderRequest && bidderRequest.gdprConsent) { + request.user = {ext: {consent: bidderRequest.gdprConsent.consentString}}; + request.regs = {ext: {gdpr: (bidderRequest.gdprConsent.gdprApplies ? 1 : 0)}} + } + if (info.referrer) { + request.site.ref = info.referrer + } + utils.logInfo(LOG_INFO_PREFIX + `buildRequest:`, request); return { method: 'POST', url: url, @@ -119,41 +203,55 @@ export const spec = { * @return {Bid[]} An array of bids which were nested inside the server. */ interpretResponse: (serverResponse, bidRequests) => { - if (serverResponse == null || serverResponse.body == null || serverResponse.body == '' || !serverResponse.body.seatbid || !serverResponse.body.seatbid[0]) { - return []; + utils.logInfo(LOG_INFO_PREFIX + `interpretResponse`, serverResponse); + if (serverResponse == null || serverResponse.body == null || serverResponse.body === '' || !utils.isArray(serverResponse.body.seatbid) || !serverResponse.body.seatbid.length) { + return; } - utils.logInfo(`MGID DEBUG: interpretResponse`); const returnedBids = []; const muidn = utils.deepAccess(serverResponse.body, 'ext.muidn') - if (muidn != null && typeof (muidn) == 'string' && muidn.length > 0) { + if (utils.isStr(muidn) && muidn.length > 0) { setLocalStorageSafely('mgMuidn', muidn) } - serverResponse.body.seatbid[0].bid.forEach((value, index) => { - returnedBids.push(prebidBid(value, serverResponse.body.cur)); + serverResponse.body.seatbid.forEach((bids) => { + bids.bid.forEach((bid) => { + const pbid = prebidBid(bid, serverResponse.body.cur); + if (pbid.mediaType === NATIVE && utils.isEmpty(pbid.native)) { + return; + } + returnedBids.push(pbid); + }) }); - utils.logInfo(`MGID DEBUG:\n${returnedBids}`); + utils.logInfo(LOG_INFO_PREFIX + `interpretedResponse`, returnedBids); return returnedBids; }, onBidWon: (bid) => { - const cpm = bid.pbMg; - if (bid.nurl != '') { + const cpm = utils.deepAccess(bid, 'adserverTargeting.hb_pb') || ''; + if (utils.isStr(bid.nurl) && bid.nurl !== '') { bid.nurl = bid.nurl.replace( - /\$\{AUCTION_PRICE\}/, + /\${AUCTION_PRICE}/, cpm ); pixel(bid.nurl); - }; + } if (bid.isBurl) { - bid.ad = bid.ad.replace( - /\$\{AUCTION_PRICE\}/, - cpm - ); + if (bid.mediaType === BANNER) { + bid.ad = bid.ad.replace( + /\${AUCTION_PRICE}/, + cpm + ) + } else { + bid.burl = bid.burl.replace( + /\${AUCTION_PRICE}/, + cpm + ); + pixel(bid.burl); + } } - utils.logInfo(`MGID DEBUG: onBidWon`); + utils.logInfo(LOG_INFO_PREFIX + `onBidWon`); }, getUserSyncs: (syncOptions, serverResponses) => { - utils.logInfo(`MGID DEBUG: getUserSyncs`); + utils.logInfo(LOG_INFO_PREFIX + `getUserSyncs`); } }; @@ -174,8 +272,8 @@ function setOnAny(collection, key) { * @return Bid */ function prebidBid(serverBid, cur) { - if (cur == null || cur == '') { - cur = 'USD'; + if (!utils.isStr(cur) || cur === '') { + cur = DEFAULT_CUR; } const bid = { requestId: serverBid.impid, @@ -190,12 +288,28 @@ function prebidBid(serverBid, cur) { netRevenue: true, ttl: serverBid.ttl || 300, nurl: serverBid.nurl || '', - isBurl: typeof (serverBid.burl) == 'string' && serverBid.burl.length > 0, + burl: serverBid.burl || '', + isBurl: utils.isStr(serverBid.burl) && serverBid.burl.length > 0, }; - + setMediaType(serverBid, bid); + switch (bid.mediaType) { + case BANNER: + break; + case NATIVE: + parseNativeResponse(serverBid, bid); + break; + } return bid; } +function setMediaType(bid, newBid) { + if (utils.deepAccess(bid, 'ext.crtype') === 'native') { + newBid.mediaType = NATIVE; + } else { + newBid.mediaType = BANNER; + } +} + function extractDomainFromHost(pageHost) { if (pageHost == 'localhost') { return 'localhost' @@ -224,7 +338,7 @@ function pixel(url) { function getLanguage() { const language = navigator.language ? 'language' : 'userLanguage'; const lang2 = navigator[language].split('-')[0]; - if (lang2.length == 2 || lang2.length == 3) { + if (lang2.length === 2 || lang2.length === 3) { return lang2; } return ''; @@ -245,3 +359,220 @@ function setLocalStorageSafely(key, val) { return null; } } + +function createBannerRequest(bid) { + const sizes = utils.deepAccess(bid, 'mediaTypes.banner.sizes'); + let format = []; + if (sizes.length > 1) { + for (let f = 0; f < sizes.length; f++) { + if (sizes[f].length === 2) { + format.push({w: sizes[f][0], h: sizes[f][1]}); + } + } + } + let r = { + w: sizes && sizes[0][0], + h: sizes && sizes[0][1], + }; + if (format.length) { + r.format = format + } + return r +} + +function createNativeRequest(params) { + let nativeRequestObject = { + plcmtcnt: 1, + assets: [] + }; + for (let key in params) { + let assetObj = {}; + if (params.hasOwnProperty(key)) { + if (!(nativeRequestObject.assets && nativeRequestObject.assets.length > 0 && nativeRequestObject.assets.hasOwnProperty(key))) { + switch (key) { + case NATIVE_ASSETS.TITLE.KEY: + assetObj = { + id: NATIVE_ASSETS.TITLE.ID, + required: params[key].required ? 1 : 0, + title: { + len: params[key].len || params[key].length || DEFAULT_TITLE_LENGTH + } + }; + break; + case NATIVE_ASSETS.IMAGE.KEY: + const wmin = params[key].wmin || params[key].minimumWidth || (utils.isArray(params[key].minsizes) && params[key].minsizes.length > 0 ? params[key].minsizes[0] : 0); + const hmin = params[key].hmin || params[key].minimumHeight || (utils.isArray(params[key].minsizes) && params[key].minsizes.length > 1 ? params[key].minsizes[1] : 0); + assetObj = { + id: NATIVE_ASSETS.IMAGE.ID, + required: params[key].required ? 1 : 0, + img: { + type: NATIVE_ASSET_IMAGE_TYPE.IMAGE, + w: params[key].w || params[key].width || (utils.isArray(params[key].sizes) && params[key].sizes.length > 0 ? params[key].sizes[0] : 0), + h: params[key].h || params[key].height || (utils.isArray(params[key].sizes) && params[key].sizes.length > 1 ? params[key].sizes[1] : 0), + mimes: params[key].mimes, + ext: params[key].ext, + } + }; + if (wmin > 0) { + assetObj.img.wmin = wmin; + } + if (hmin > 0) { + assetObj.img.hmin = hmin; + } + if (!assetObj.img.w) { + assetObj.img.w = DEFAULT_IMAGE_WIDTH; + } + if (!assetObj.img.h) { + assetObj.img.h = DEFAULT_IMAGE_HEIGHT; + } + break; + case NATIVE_ASSETS.ICON.KEY: + assetObj = { + id: NATIVE_ASSETS.ICON.ID, + required: params[key].required ? 1 : 0, + img: { + type: NATIVE_ASSET_IMAGE_TYPE.ICON, + w: params[key].w || params[key].width || (utils.isArray(params[key].sizes) && params[key].sizes.length > 0 ? params[key].sizes[0] : 0), + h: params[key].h || params[key].height || (utils.isArray(params[key].sizes) && params[key].sizes.length > 0 ? params[key].sizes[1] : 0), + } + }; + if (!assetObj.img.w) { + assetObj.img.w = DEFAULT_ICON_WIDTH; + } + if (!assetObj.img.h) { + assetObj.img.h = DEFAULT_ICON_HEIGHT; + } + break; + case NATIVE_ASSETS.SPONSORED.KEY: + case NATIVE_ASSETS.SPONSOREDBY.KEY: + case NATIVE_ASSETS.PRICE.KEY: + case NATIVE_ASSETS.SALEPRICE.KEY: + case NATIVE_ASSETS.DESC.KEY: + case NATIVE_ASSETS.BODY.KEY: + case NATIVE_ASSETS.DISPLAYURL.KEY: + case NATIVE_ASSETS.CTA.KEY: + assetObj = commonNativeRequestObject(spec.NATIVE_ASSET_KEY_TO_ASSET_MAP[key], params); + break; + default: + if (params[key].required) { + isInvalidNativeRequest = true; + return; + } + } + } + } + if (assetObj.id) { + nativeRequestObject.assets[nativeRequestObject.assets.length] = assetObj; + } + } + + // for native image adtype prebid has to have few required assests i.e. title,sponsoredBy, image + // if any of these are missing from the request then request will not be sent + let requiredAssetCount = NATIVE_MINIMUM_REQUIRED_IMAGE_ASSETS.length; + let presentrequiredAssetCount = 0; + NATIVE_MINIMUM_REQUIRED_IMAGE_ASSETS.forEach(ele => { + let lengthOfExistingAssets = nativeRequestObject.assets.length; + for (let i = 0; i < lengthOfExistingAssets; i++) { + if (ele.id === nativeRequestObject.assets[i].id) { + presentrequiredAssetCount++; + break; + } else { + if (ele.id === 4 && nativeRequestObject.assets[i].id === 11) { + if (utils.deepAccess(nativeRequestObject.assets[i], 'data.type') === ele.data.type) { + presentrequiredAssetCount++; + break; + } + } + } + } + }); + isInvalidNativeRequest = requiredAssetCount !== presentrequiredAssetCount; + return nativeRequestObject; +} + +function commonNativeRequestObject(nativeAsset, params) { + const key = nativeAsset.KEY; + return { + id: nativeAsset.ID, + required: params[key].required ? 1 : 0, + data: { + type: nativeAsset.TYPE, + len: params[key].len, + ext: params[key].ext + } + }; +} + +function parseNativeResponse(bid, newBid) { + newBid.native = {}; + if (bid.hasOwnProperty('adm')) { + let adm = ''; + try { + adm = JSON.parse(bid.adm); + } catch (ex) { + utils.logWarn(LOG_WARN_PREFIX + 'Error: Cannot parse native response for ad response: ' + newBid.adm); + return; + } + if (adm && adm.native && adm.native.assets && adm.native.assets.length > 0) { + newBid.mediaType = NATIVE; + for (let i = 0, len = adm.native.assets.length; i < len; i++) { + switch (adm.native.assets[i].id) { + case NATIVE_ASSETS.TITLE.ID: + newBid.native.title = adm.native.assets[i].title && adm.native.assets[i].title.text; + break; + case NATIVE_ASSETS.IMAGE.ID: + newBid.native.image = { + url: adm.native.assets[i].img && adm.native.assets[i].img.url, + height: adm.native.assets[i].img && adm.native.assets[i].img.h, + width: adm.native.assets[i].img && adm.native.assets[i].img.w, + }; + break; + case NATIVE_ASSETS.ICON.ID: + newBid.native.icon = { + url: adm.native.assets[i].img && adm.native.assets[i].img.url, + height: adm.native.assets[i].img && adm.native.assets[i].img.h, + width: adm.native.assets[i].img && adm.native.assets[i].img.w, + }; + break; + case NATIVE_ASSETS.SPONSOREDBY.ID: + case NATIVE_ASSETS.SPONSORED.ID: + case NATIVE_ASSETS.PRICE: + case NATIVE_ASSETS.SALEPRICE.ID: + case NATIVE_ASSETS.DESC.ID: + case NATIVE_ASSETS.BODY.ID: + case NATIVE_ASSETS.DISPLAYURL.ID: + case NATIVE_ASSETS.CTA.ID: + newBid.native[spec.NATIVE_ASSET_ID_TO_KEY_MAP[adm.native.assets[i].id]] = adm.native.assets[i].data && adm.native.assets[i].data.value; + break; + } + } + newBid.native.clickUrl = adm.native.link && adm.native.link.url; + newBid.native.clickTrackers = (adm.native.link && adm.native.link.clicktrackers) || []; + newBid.native.impressionTrackers = adm.native.imptrackers || []; + newBid.native.jstracker = adm.native.jstracker || []; + newBid.width = 0; + newBid.height = 0; + } + } +} + +function pageInfo() { + var w, d, l, r, m, p, t; + for (w = window, d = w.document, l = d.location.href, r = d.referrer, m = 0, t = new Date(); w !== w.parent;) { + try { + p = w.parent; l = p.location.href; r = p.document.referrer; w = p; + } catch (e) { + m = top !== w.parent ? 2 : 1; + break + } + } + return { + location: l, + referrer: r || '', + masked: m, + wWidth: w.innerWidth, + wHeight: w.innerHeight, + date: t.toUTCString(), + timeOffset: t.getTimezoneOffset() + }; +} diff --git a/modules/microadBidAdapter.js b/modules/microadBidAdapter.js index d42e4053fda..391be2c465b 100644 --- a/modules/microadBidAdapter.js +++ b/modules/microadBidAdapter.js @@ -1,5 +1,5 @@ -import { registerBidder } from 'src/adapters/bidderFactory'; -import { BANNER } from 'src/mediaTypes'; +import { registerBidder } from '../src/adapters/bidderFactory'; +import { BANNER } from '../src/mediaTypes'; const BIDDER_CODE = 'microad'; diff --git a/modules/my6senseBidAdapter.js b/modules/my6senseBidAdapter.js index 38aa1da8573..1f6080d82b9 100644 --- a/modules/my6senseBidAdapter.js +++ b/modules/my6senseBidAdapter.js @@ -2,7 +2,7 @@ import { BANNER, NATIVE } from '../src/mediaTypes'; const {registerBidder} = require('../src/adapters/bidderFactory'); const BIDDER_CODE = 'my6sense'; -const END_POINT = '//papi.mynativeplatform.com/pub2/web/v1.15.0/hbwidget.json'; +const END_POINT = '//hb.mynativeplatform.com/pub2/web/v1.15.0/hbwidget.json'; const END_POINT_METHOD = 'POST'; // called first diff --git a/modules/mytargetBidAdapter.js b/modules/mytargetBidAdapter.js index e5b6cc735ef..5b727f7043f 100644 --- a/modules/mytargetBidAdapter.js +++ b/modules/mytargetBidAdapter.js @@ -35,6 +35,12 @@ function getSiteName(referrer) { return sitename; } +function getCurrency() { + let currency = config.getConfig('currency.adServerCurrency'); + + return (currency === 'USD') ? currency : DEFAULT_CURRENCY; +} + function generateRandomId() { return Math.random().toString(16).substring(2); } @@ -60,7 +66,7 @@ export const spec = { page: referrer }, settings: { - currency: DEFAULT_CURRENCY, + currency: getCurrency(), windowSize: { width: window.screen.width, height: window.screen.height diff --git a/modules/nafdigitalBidAdapter.js b/modules/nafdigitalBidAdapter.js new file mode 100644 index 00000000000..7bbfd8b38dd --- /dev/null +++ b/modules/nafdigitalBidAdapter.js @@ -0,0 +1,246 @@ +import * as utils from '../src/utils'; +import * as url from '../src/url'; +import { registerBidder } from '../src/adapters/bidderFactory'; +import { BANNER } from '../src/mediaTypes'; +import { config } from '../src/config'; + +const BIDDER_CODE = 'nafdigital'; +const URL = 'https://nafdigitalbidder.com/hb'; + +export const spec = { + code: BIDDER_CODE, + supportedMediaTypes: [BANNER], + isBidRequestValid, + buildRequests, + interpretResponse, + getUserSyncs +}; + +function buildRequests(bidReqs, bidderRequest) { + try { + let referrer = ''; + if (bidderRequest && bidderRequest.refererInfo) { + referrer = bidderRequest.refererInfo.referer; + } + const nafdigitalImps = []; + const publisherId = utils.getBidIdParameter('publisherId', bidReqs[0].params); + utils._each(bidReqs, function (bid) { + bid.sizes = ((utils.isArray(bid.sizes) && utils.isArray(bid.sizes[0])) ? bid.sizes : [bid.sizes]); + bid.sizes = bid.sizes.filter(size => utils.isArray(size)); + const processedSizes = bid.sizes.map(size => ({w: parseInt(size[0], 10), h: parseInt(size[1], 10)})); + + const element = document.getElementById(bid.adUnitCode); + const minSize = _getMinSize(processedSizes); + const viewabilityAmount = _isViewabilityMeasurable(element) + ? _getViewability(element, utils.getWindowTop(), minSize) + : 'na'; + const viewabilityAmountRounded = isNaN(viewabilityAmount) ? viewabilityAmount : Math.round(viewabilityAmount); + + const imp = { + id: bid.bidId, + banner: { + format: processedSizes, + ext: { + viewability: viewabilityAmountRounded + } + }, + tagid: String(bid.adUnitCode) + }; + const bidFloor = utils.getBidIdParameter('bidFloor', bid.params); + if (bidFloor) { + imp.bidfloor = bidFloor; + } + nafdigitalImps.push(imp); + }); + const nafdigitalBidReq = { + id: utils.getUniqueIdentifierStr(), + imp: nafdigitalImps, + site: { + domain: url.parse(referrer).host, + page: referrer, + publisher: { + id: publisherId + } + }, + device: { + devicetype: _getDeviceType(), + w: screen.width, + h: screen.height + }, + tmax: config.getConfig('bidderTimeout') + }; + + return { + method: 'POST', + url: URL, + data: JSON.stringify(nafdigitalBidReq), + options: {contentType: 'text/plain', withCredentials: false} + }; + } catch (e) { + utils.logError(e, {bidReqs, bidderRequest}); + } +} + +function isBidRequestValid(bid) { + if (bid.bidder !== BIDDER_CODE || typeof bid.params === 'undefined') { + return false; + } + + if (typeof bid.params.publisherId === 'undefined') { + return false; + } + + return true; +} + +function interpretResponse(serverResponse) { + if (!serverResponse.body || typeof serverResponse.body != 'object') { + utils.logWarn('NAF digital server returned empty/non-json response: ' + JSON.stringify(serverResponse.body)); + return []; + } + const { body: {id, seatbid} } = serverResponse; + try { + const nafdigitalBidResponses = []; + if (id && + seatbid && + seatbid.length > 0 && + seatbid[0].bid && + seatbid[0].bid.length > 0) { + seatbid[0].bid.map(nafdigitalBid => { + nafdigitalBidResponses.push({ + requestId: nafdigitalBid.impid, + cpm: parseFloat(nafdigitalBid.price), + width: parseInt(nafdigitalBid.w), + height: parseInt(nafdigitalBid.h), + creativeId: nafdigitalBid.crid || nafdigitalBid.id, + currency: 'USD', + netRevenue: true, + mediaType: BANNER, + ad: _getAdMarkup(nafdigitalBid), + ttl: 60 + }); + }); + } + return nafdigitalBidResponses; + } catch (e) { + utils.logError(e, {id, seatbid}); + } +} + +// Don't do user sync for now +function getUserSyncs(syncOptions, responses, gdprConsent) { + return []; +} + +function _isMobile() { + return (/(ios|ipod|ipad|iphone|android)/i).test(navigator.userAgent); +} + +function _isConnectedTV() { + return (/(smart[-]?tv|hbbtv|appletv|googletv|hdmi|netcast\.tv|viera|nettv|roku|\bdtv\b|sonydtv|inettvbrowser|\btv\b)/i).test(navigator.userAgent); +} + +function _getDeviceType() { + return _isMobile() ? 1 : _isConnectedTV() ? 3 : 2; +} + +function _getAdMarkup(bid) { + let adm = bid.adm; + if ('nurl' in bid) { + adm += utils.createTrackPixelHtml(bid.nurl); + } + return adm; +} + +function _isViewabilityMeasurable(element) { + return !_isIframe() && element !== null; +} + +function _getViewability(element, topWin, { w, h } = {}) { + return utils.getWindowTop().document.visibilityState === 'visible' + ? _getPercentInView(element, topWin, { w, h }) + : 0; +} + +function _isIframe() { + try { + return utils.getWindowSelf() !== utils.getWindowTop(); + } catch (e) { + return true; + } +} + +function _getMinSize(sizes) { + return sizes.reduce((min, size) => size.h * size.w < min.h * min.w ? size : min); +} + +function _getBoundingBox(element, { w, h } = {}) { + let { width, height, left, top, right, bottom } = element.getBoundingClientRect(); + + if ((width === 0 || height === 0) && w && h) { + width = w; + height = h; + right = left + w; + bottom = top + h; + } + + return { width, height, left, top, right, bottom }; +} + +function _getIntersectionOfRects(rects) { + const bbox = { + left: rects[0].left, + right: rects[0].right, + top: rects[0].top, + bottom: rects[0].bottom + }; + + for (let i = 1; i < rects.length; ++i) { + bbox.left = Math.max(bbox.left, rects[i].left); + bbox.right = Math.min(bbox.right, rects[i].right); + + if (bbox.left >= bbox.right) { + return null; + } + + bbox.top = Math.max(bbox.top, rects[i].top); + bbox.bottom = Math.min(bbox.bottom, rects[i].bottom); + + if (bbox.top >= bbox.bottom) { + return null; + } + } + + bbox.width = bbox.right - bbox.left; + bbox.height = bbox.bottom - bbox.top; + + return bbox; +} + +function _getPercentInView(element, topWin, { w, h } = {}) { + const elementBoundingBox = _getBoundingBox(element, { w, h }); + + // Obtain the intersection of the element and the viewport + const elementInViewBoundingBox = _getIntersectionOfRects([ { + left: 0, + top: 0, + right: topWin.innerWidth, + bottom: topWin.innerHeight + }, elementBoundingBox ]); + + let elementInViewArea, elementTotalArea; + + if (elementInViewBoundingBox !== null) { + // Some or all of the element is in view + elementInViewArea = elementInViewBoundingBox.width * elementInViewBoundingBox.height; + elementTotalArea = elementBoundingBox.width * elementBoundingBox.height; + + return ((elementInViewArea / elementTotalArea) * 100); + } + + // No overlap between element and the viewport; therefore, the element + // lies completely out of view + return 0; +} + +registerBidder(spec); diff --git a/modules/nafdigitalBidAdapter.md b/modules/nafdigitalBidAdapter.md new file mode 100644 index 00000000000..b17b1f13e1e --- /dev/null +++ b/modules/nafdigitalBidAdapter.md @@ -0,0 +1,38 @@ +# Overview + +``` +Module Name: NAF Digital Bid Adapter +Module Type: Bidder Adapter +Maintainer: vyatsun@gmail.com +``` + +# Description + +NAF Digital adapter integration to the Prebid library. + +# Test Parameters + +``` +var adUnits = [ + { + code: 'test-leaderboard', + sizes: [[728, 90]], + bids: [{ + bidder: 'nafdigital', + params: { + publisherId: 2141020, + bidFloor: 0.01 + } + }] + }, { + code: 'test-banner', + sizes: [[300, 250]], + bids: [{ + bidder: 'nafdigital', + params: { + publisherId: 2141020 + } + }] + } +] +``` diff --git a/modules/nanointeractiveBidAdapter.js b/modules/nanointeractiveBidAdapter.js index cfef32b4c80..a76cc90ac10 100644 --- a/modules/nanointeractiveBidAdapter.js +++ b/modules/nanointeractiveBidAdapter.js @@ -1,11 +1,11 @@ import * as utils from '../src/utils'; -import { registerBidder } from '../src/adapters/bidderFactory'; -import { BANNER } from '../src/mediaTypes'; +import {config} from '../src/config'; +import {registerBidder} from '../src/adapters/bidderFactory'; export const BIDDER_CODE = 'nanointeractive'; -export const ENGINE_BASE_URL = 'https://www.audiencemanager.de/hb'; +export const END_POINT_URL = 'https://ad.audiencemanager.de'; -export const DATA_PARTNER_PIXEL_ID = 'pid'; +export const SSP_PLACEMENT_ID = 'pid'; export const NQ = 'nq'; export const NQ_NAME = 'name'; export const CATEGORY = 'category'; @@ -17,22 +17,27 @@ export const LOCATION = 'loc'; export const spec = { code: BIDDER_CODE, - supportedMediaTypes: [BANNER], + aliases: ['ni'], - isBidRequestValid (bid) { - const pid = bid.params[DATA_PARTNER_PIXEL_ID]; + isBidRequestValid(bid) { + const pid = bid.params[SSP_PLACEMENT_ID]; return !!(pid); }, - buildRequests (bidRequests) { + + buildRequests(validBidRequests, bidderRequest) { let payload = []; - bidRequests.forEach(bid => payload.push(createSingleBidRequest(bid))); + validBidRequests.forEach( + bid => payload.push(createSingleBidRequest(bid, bidderRequest)) + ); + const url = getEndpointUrl('main') + '/hb'; + return { method: 'POST', - url: ENGINE_BASE_URL, + url: url, data: JSON.stringify(payload) }; }, - interpretResponse (serverResponse) { + interpretResponse(serverResponse) { const bids = []; serverResponse.body.forEach(serverBid => { if (isEngineResponseValid(serverBid)) { @@ -41,23 +46,37 @@ export const spec = { }); return bids; } + }; -function createSingleBidRequest (bid) { - return { - [DATA_PARTNER_PIXEL_ID]: bid.params[DATA_PARTNER_PIXEL_ID], +function createSingleBidRequest(bid, bidderRequest) { + const location = utils.deepAccess(bidderRequest, 'refererInfo.referer'); + const origin = utils.getOrigin(); + const data = { + [SSP_PLACEMENT_ID]: bid.params[SSP_PLACEMENT_ID], [NQ]: [createNqParam(bid)], [CATEGORY]: [createCategoryParam(bid)], [SUB_ID]: createSubIdParam(bid), - [REF]: createRefParam(bid), + [REF]: createRefParam(), sizes: bid.sizes.map(value => value[0] + 'x' + value[1]), bidId: bid.bidId, - cors: utils.getOrigin(), - [LOCATION]: createLocationParam(), + cors: origin, + [LOCATION]: location, + lsUserId: getLsUserId() }; + + if (bidderRequest && bidderRequest.gdprConsent) { + data['gdprConsent'] = bidderRequest.gdprConsent.consentString; + data['gdprApplies'] = (bidderRequest.gdprConsent.gdprApplies) ? '1' : '0'; + } + + return data; } -function createSingleBidResponse (serverBid) { +function createSingleBidResponse(serverBid) { + if (serverBid.userId) { + localStorage.setItem('lsUserId', serverBid.userId); + } return { requestId: serverBid.id, cpm: serverBid.cpm, @@ -67,32 +86,50 @@ function createSingleBidResponse (serverBid) { ttl: serverBid.ttl, creativeId: serverBid.creativeId, netRevenue: serverBid.netRevenue || true, - currency: serverBid.currency, + currency: serverBid.currency }; } -function createNqParam (bid) { +function createNqParam(bid) { return bid.params[NQ_NAME] ? utils.getParameterByName(bid.params[NQ_NAME]) : bid.params[NQ] || null; } -function createCategoryParam (bid) { +function createCategoryParam(bid) { return bid.params[CATEGORY_NAME] ? utils.getParameterByName(bid.params[CATEGORY_NAME]) : bid.params[CATEGORY] || null; } -function createSubIdParam (bid) { +function createSubIdParam(bid) { return bid.params[SUB_ID] || null; } -function createRefParam (bid) { - return bid.params[REF] ? null : utils.getTopWindowReferrer() || null; +function createRefParam() { + try { + return window.top.document.referrer; + } catch (ex) { + return document.referrer; + } } -function createLocationParam () { - return utils.getTopWindowLocation().href; +function isEngineResponseValid(response) { + return !!response.cpm && !!response.ad; } -function isEngineResponseValid (response) { - return !!response.cpm && !!response.ad; +/** + * Used mainly for debugging + * + * @param type + * @returns string + */ +function getEndpointUrl(type) { + const nanoConfig = config.getConfig('nano'); + return (nanoConfig && nanoConfig['endpointUrl']) || END_POINT_URL; +} + +function getLsUserId() { + if (localStorage.getItem('lsUserId') != null) { + return localStorage.getItem('lsUserId'); + } + return null; } registerBidder(spec); diff --git a/modules/nextMilleniumBidAdapter.js b/modules/nextMillenniumBidAdapter.js similarity index 98% rename from modules/nextMilleniumBidAdapter.js rename to modules/nextMillenniumBidAdapter.js index 46f5a42b3c0..8093f6e8f7c 100644 --- a/modules/nextMilleniumBidAdapter.js +++ b/modules/nextMillenniumBidAdapter.js @@ -2,7 +2,7 @@ import * as utils from '../src/utils'; import { registerBidder } from '../src/adapters/bidderFactory'; import { BANNER } from '../src/mediaTypes'; -const BIDDER_CODE = 'nextMillenium'; +const BIDDER_CODE = 'nextMillennium'; const HOST = 'https://brainlyads.com'; const CURRENCY = 'USD'; const TIME_TO_LIVE = 360; diff --git a/modules/nextMilleniumBidAdapter.md b/modules/nextMillenniumBidAdapter.md similarity index 76% rename from modules/nextMilleniumBidAdapter.md rename to modules/nextMillenniumBidAdapter.md index a89e7e30822..c583969b4af 100644 --- a/modules/nextMilleniumBidAdapter.md +++ b/modules/nextMillenniumBidAdapter.md @@ -1,12 +1,12 @@ # Overview ``` -Module Name: NextMillenium Bid Adapter +Module Name: NextMillennium Bid Adapter Module Type: Bidder Adapter Maintainer: mikhail.ivanchenko@iageengineering.net ``` # Description -Module that connects to NextMillenium's server for bids. +Module that connects to NextMillennium's server for bids. Currently module supports only banner mediaType. # Test Parameters @@ -19,7 +19,7 @@ Currently module supports only banner mediaType. } }, bids: [{ - bidder: 'nextMillenium', + bidder: 'nextMillennium', params: { placement_id: -1 } diff --git a/modules/nobidBidAdapter.js b/modules/nobidBidAdapter.js new file mode 100644 index 00000000000..ce4c25d75fa --- /dev/null +++ b/modules/nobidBidAdapter.js @@ -0,0 +1,305 @@ +import * as utils from '../src/utils'; +import { registerBidder } from '../src/adapters/bidderFactory'; +import { BANNER } from '../src/mediaTypes'; +const BIDDER_CODE = 'nobid'; +window.nobidVersion = '1.1.0'; +function log(msg, obj) { + utils.logInfo('-NoBid- ' + msg, obj) +} +function nobidBuildRequests(bids, bidderRequest) { + var serializeState = function(divIds, siteId, adunits) { + var filterAdUnitsByIds = function(divIds, adUnits) { + var filtered = []; + if (!divIds || !divIds.length) { + filtered = adUnits; + } else if (adUnits) { + var a = []; + if (!(divIds instanceof Array)) a.push(divIds); + else a = divIds; + for (var i = 0, l = adUnits.length; i < l; i++) { + var adUnit = adUnits[i]; + if (adUnit && adUnit.d && (a.indexOf(adUnit.d) > -1)) { + filtered.push(adUnit); + } + } + } + return filtered; + } + var gdprConsent = function(bidderRequest) { + var gdprConsent = {}; + if (bidderRequest && bidderRequest.gdprConsent) { + gdprConsent = { + consentString: bidderRequest.gdprConsent.consentString, + // will check if the gdprApplies field was populated with a boolean value (ie from page config). If it's undefined, then default to true + consentRequired: (typeof bidderRequest.gdprConsent.gdprApplies === 'boolean') ? bidderRequest.gdprConsent.gdprApplies : false + } + } + return gdprConsent; + } + var topLocation = function(bidderRequest) { + var ret = ''; + if (bidderRequest && bidderRequest.refererInfo && bidderRequest.refererInfo.referer) { + ret = bidderRequest.refererInfo.referer; + } else { + ret = (window.context && window.context.location && window.context.location.href) ? window.context.location.href : document.location.href; + } + return encodeURIComponent(ret.replace(/\%/g, '')); + } + var timestamp = function() { + var date = new Date(); + var zp = function (val) { return (val <= 9 ? '0' + val : '' + val); } + var d = date.getDate(); + var y = date.getFullYear(); + var m = date.getMonth() + 1; + var h = date.getHours(); + var min = date.getMinutes(); + var s = date.getSeconds(); + return '' + y + '-' + zp(m) + '-' + zp(d) + ' ' + zp(h) + ':' + zp(min) + ':' + zp(s); + }; + var clientDim = function() { + try { + return `${screen.width}x${screen.height}`; + } catch (e) { + console.error(e); + } + } + var state = {}; + state['sid'] = siteId; + state['l'] = topLocation(bidderRequest); + state['tt'] = encodeURIComponent(document.title); + state['tt'] = state['tt'].replace(/'|;|quot;|39;|&|&|#|\r\n|\r|\n|\t|\f|\%0A|\"|\%22|\%5C|\%23|\%26|\%26|\%09/gm, ''); + state['a'] = filterAdUnitsByIds(divIds, adunits || []); + state['t'] = timestamp(); + state['tz'] = Math.round(new Date().getTimezoneOffset()); + state['r'] = clientDim(); + state['lang'] = (navigator.languages && navigator.languages[0]) || navigator.language || navigator.userLanguage; + state['ref'] = document.referrer; + state['gdpr'] = gdprConsent(bidderRequest); + return state; + } + function newAdunit(adunitObject, adunits) { + var getAdUnit = function(divid, adunits) { + for (var i = 0; i < adunits.length; i++) { + if (adunits[i].d === divid) { + return adunits[i]; + } + } + return false; + } + var removeByAttrValue = function(array, attribute, value) { + for (var i = array.length - 1; i >= 0; i--) { + var entry = array[i]; + if (entry[attribute] && entry[attribute] === value) { + array.splice(i, 1); + } + } + } + var a = getAdUnit(adunitObject.div, adunits) || {}; + if (adunitObject.account) { + a.s = adunitObject.account; + } + if (adunitObject.sizes) { + a.z = adunitObject.sizes; + } + if (adunitObject.div) { + a.d = adunitObject.div; + } + if (adunitObject.targeting) { + a.g = adunitObject.targeting; + } else { + a.g = {}; + } + if (adunitObject.companion) { + a.c = adunitObject.companion; + } + if (adunitObject.div) { + removeByAttrValue(adunits, 'd', adunitObject.div); + } + if (adunitObject.sizeMapping) { + a.sm = adunitObject.sizeMapping; + } + if (adunitObject.siteId) { + a.sid = adunitObject.siteId; + } + /* {"BIDDER_ID":{"WxH":"TAG_ID", "WxH":"TAG_ID"}} */ + if (adunitObject.rtb) { + a.rtb = adunitObject.rtb; + } + adunits.push(a); + return adunits; + } + /* DISCOVER SLOTS */ + var divids = []; + var siteId = 0; + var adunits = []; + for (var i = 0; i < bids.length; i++) { + var bid = bids[i]; + var divid = bid.adUnitCode; + divids.push(divid); + var sizes = bid.sizes; + siteId = (typeof bid.params['siteId'] != 'undefined' && bid.params['siteId']) ? bid.params['siteId'] : siteId; + if (siteId && bid.params && bid.params.tags) { + newAdunit({div: divid, sizes: sizes, rtb: bid.params.tags, siteId: siteId}, adunits); + } else if (siteId) { + newAdunit({div: divid, sizes: sizes, siteId: siteId}, adunits); + } + } + if (siteId) { + return serializeState(divids, siteId, adunits); + } else { + return false; + } +} +function nobidInterpretResponse(response, bidRequest) { + var findBid = function(divid, bids) { + for (var i = 0; i < bids.length; i++) { + if (bids[i].adUnitCode === divid) { + return bids[i]; + } + } + return false; + } + var bidResponses = []; + for (var i = 0; response.bids && i < response.bids.length; i++) { + var bid = response.bids[i]; + if (bid.bdrid < 100 || !bidRequest || !bidRequest.bidderRequest || !bidRequest.bidderRequest.bids) continue; + nobid.bidResponses['' + bid.id] = bid; + var reqBid = findBid(bid.divid, bidRequest.bidderRequest.bids); + if (!reqBid) continue; + const bidResponse = { + requestId: reqBid.bidId, + cpm: 1 * ((bid.price) ? bid.price : (bid.bucket) ? bid.bucket : 0), + width: bid.size.w, + height: bid.size.h, + creativeId: (bid.creativeid) || '', + dealId: (bid.dealid) || '', + currency: 'USD', + netRevenue: true, + ttl: 300, + ad: bid.adm, + mediaType: BANNER + }; + bidResponses.push(bidResponse); + } + return bidResponses; +}; +window.nobid = window.nobid || {}; +nobid.bidResponses = nobid.bidResponses || {}; +nobid.timeoutTotal = 0; +nobid.bidWonTotal = 0; +nobid.renderTag = function(doc, id, win) { + log('nobid.renderTag()', id); + var bid = nobid.bidResponses['' + id]; + if (bid && bid.adm2) { + log('nobid.renderTag() found tag', id); + var markup = bid.adm2; + doc.write(markup); + doc.close(); + return; + } + log('nobid.renderTag() tag NOT FOUND *ERROR*', id); +} +export const spec = { + code: BIDDER_CODE, + supportedMediaTypes: [BANNER], + /** + * Determines whether or not the given bid request is valid. + * + * @param {BidRequest} bid The bid params to validate. + * @return boolean True if this is a valid bid, and false otherwise. + */ + isBidRequestValid: function(bid) { + log('isBidRequestValid', bid); + return !!bid.params.siteId; + }, + /** + * Make a server request from the list of BidRequests. + * + * @param {validBidRequests[]} - an array of bids + * @return ServerRequest Info describing the request to the server. + */ + buildRequests: function(validBidRequests, bidderRequest) { + function resolveEndpoint() { + var ret = 'https://ads.servenobid.com/'; + var env = (typeof utils.getParameterByName === 'function') && (utils.getParameterByName('nobid-env')); + if (!env) ret = 'https://ads.servenobid.com/'; + else if (env == 'beta') ret = 'https://beta.servenobid.com/'; + else if (env == 'dev') ret = '//localhost:8282/'; + else if (env == 'qa') ret = 'https://qa-ads.nobid.com/'; + return ret; + } + var buildEndpoint = function() { + return resolveEndpoint() + 'adreq?cb=' + Math.floor(Math.random() * 11000); + } + log('buildRequests', validBidRequests); + if (!validBidRequests || validBidRequests.length <= 0) { + log('Empty validBidRequests'); + return; + } + const payload = nobidBuildRequests(validBidRequests, bidderRequest); + if (!payload) return; + const payloadString = JSON.stringify(payload).replace(/'|&|#/g, '') + const endpoint = buildEndpoint(); + return { + method: 'POST', + url: endpoint, + data: payloadString, + bidderRequest + }; + }, + /** + * Unpack the response from the server into a list of bids. + * + * @param {ServerResponse} serverResponse A successful response from the server. + * @return {Bid[]} An array of bids which were nested inside the server. + */ + interpretResponse: function(serverResponse, bidRequest) { + log('interpretResponse', serverResponse); + log('interpretResponse', bidRequest); + return nobidInterpretResponse(serverResponse.body, bidRequest); + }, + + /** + * Register the user sync pixels which should be dropped after the auction. + * + * @param {SyncOptions} syncOptions Which user syncs are allowed? + * @param {ServerResponse[]} serverResponses List of server's responses. + * @return {UserSync[]} The user syncs which should be dropped. + */ + getUserSyncs: function(syncOptions, serverResponses, gdprConsent) { + if (syncOptions.iframeEnabled) { + let params = ''; + if (gdprConsent && typeof gdprConsent.consentString === 'string') { + // add 'gdpr' only if 'gdprApplies' is defined + if (typeof gdprConsent.gdprApplies === 'boolean') { + params += `?gdpr=${Number(gdprConsent.gdprApplies)}&gdpr_consent=${gdprConsent.consentString}`; + } else { + params += `?gdpr_consent=${gdprConsent.consentString}`; + } + } + return [{ + type: 'iframe', + url: 'https://s3.amazonaws.com/nobid-public/sync.html' + params + }]; + } else { + utils.logWarn('-NoBid- Please enable iframe based user sync.', syncOptions); + return []; + } + }, + + /** + * Register bidder specific code, which will execute if bidder timed out after an auction + * @param {data} Containing timeout specific data + */ + onTimeout: function(data) { + nobid.timeoutTotal++; + log('Timeout total: ' + nobid.timeoutTotal, data); + return nobid.timeoutTotal; + }, + onBidWon: function(data) { + nobid.bidWonTotal++; + log('BidWon total: ' + nobid.bidWonTotal, data); + return nobid.bidWonTotal; + } +} +registerBidder(spec); diff --git a/modules/nobidBidAdapter.md b/modules/nobidBidAdapter.md new file mode 100644 index 00000000000..b80a7f6c4b6 --- /dev/null +++ b/modules/nobidBidAdapter.md @@ -0,0 +1,53 @@ +--- +layout: bidder +title: Nobid +description: Prebid Nobid Bidder Adaptor +biddercode: nobid +hide: true +media_types: banner +gdpr_supported: true +--- + +### Bid Params + +{: .table .table-bordered .table-striped } +| Name | Scope | Description | Example | Type | +|---------------|----------|-------------|---------|----------| +| `siteId` | required | siteId is provided by your Nobid account manager | | `integer` | + +# Test Parameters +``` + var adUnits = [ + { + code: 'test-div', + mediaTypes: { + banner: { + sizes: [[300, 250]], // a display size + } + }, + bids: [ + { + bidder: "nobid", + params: { + siteId: 2 + } + } + ] + },{ + code: 'test-div', + mediaTypes: { + banner: { + sizes: [[320, 50]], // a mobile size + } + }, + bids: [ + { + bidder: "nobid", + params: { + siteId: 2 + } + } + ] + } + ]; +``` \ No newline at end of file diff --git a/modules/oneVideoBidAdapter.js b/modules/oneVideoBidAdapter.js index 818c31a84af..16883aedc86 100644 --- a/modules/oneVideoBidAdapter.js +++ b/modules/oneVideoBidAdapter.js @@ -76,19 +76,22 @@ export const spec = { requestId: bidRequest.bidId, bidderCode: spec.code, cpm: bid.price, - creativeId: bid.id, + adId: bid.adid, + creativeId: bid.crid, width: size.width, height: size.height, mediaType: 'video', currency: response.cur, ttl: 100, - netRevenue: true + netRevenue: true, + adUnitCode: bidRequest.adUnitCode }; if (bid.nurl) { bidResponse.vastUrl = bid.nurl; } else if (bid.adm) { bidResponse.vastXml = bid.adm; } + bidResponse.renderer = (bidRequest.mediaTypes.video.context === 'outstream') ? newRenderer(bidRequest, bidResponse) : undefined; return bidResponse; }, /** @@ -190,9 +193,25 @@ function getRequestData(bid, consentData) { if (bid.params.video.placement) { bidData.imp[0].ext.placement = bid.params.video.placement } + if (bid.params.video.rewarded) { + bidData.imp[0].ext.rewarded = bid.params.video.rewarded + } if (bid.params.site && bid.params.site.id) { bidData.site.id = bid.params.site.id } + if (bid.params.video.sid) { + bidData.source = { + ext: { + schain: { + complete: 1, + nodes: [{ + sid: bid.params.video.sid, + rid: bidData.id, + }] + } + } + } + } if (isConsentRequired(consentData)) { bidData.regs = { @@ -216,5 +235,20 @@ function getRequestData(bid, consentData) { function isSecure() { return document.location.protocol === 'https:'; } +/** + * Create oneVideo renderer + * @returns {*} + */ +function newRenderer(bidRequest, bid) { + if (!bidRequest.renderer) { + bidRequest.renderer = {}; + bidRequest.renderer.url = 'https://cdn.vidible.tv/prod/hb-outstream-renderer/renderer.js'; + bidRequest.renderer.render = function(bid) { + setTimeout(function () { + o2PlayerRender(bid); + }, 700) + }; + } +} registerBidder(spec); diff --git a/modules/oneVideoBidAdapter.md b/modules/oneVideoBidAdapter.md old mode 100755 new mode 100644 index 6e34d245c3e..c7f6af399e7 --- a/modules/oneVideoBidAdapter.md +++ b/modules/oneVideoBidAdapter.md @@ -33,8 +33,11 @@ Connects to One Video demand source to fetch bids. position: 1, delivery: [2], playbackmethod: [1,5], - placement: 123 + placement: 123, + sid: , + rewarded: 1 }, + }, site: { id: 1, page: 'http://abhi12345.com', diff --git a/modules/onetagBidAdapter.js b/modules/onetagBidAdapter.js index 72a88039fed..ce671772dad 100644 --- a/modules/onetagBidAdapter.js +++ b/modules/onetagBidAdapter.js @@ -24,7 +24,7 @@ function isBidRequestValid(bid) { return false; } - if (typeof bid.params.pubId !== 'string' || bid.sizes === 'undefined' || bid.sizes.length === 0) { + if (typeof bid.params.pubId !== 'string' || typeof bid.sizes === 'undefined' || bid.sizes.length === 0) { return false; } @@ -90,7 +90,7 @@ function interpretResponse(serverResponse, request) { netRevenue: false, mediaType: bids.type ? bids.type : BANNER, ad: bid.ad, - ttl: bid.ttl || 6000 + ttl: bid.ttl || 300 }); }); } diff --git a/modules/open8BidAdapter.js b/modules/open8BidAdapter.js index be616d0ec30..bac95f4499e 100644 --- a/modules/open8BidAdapter.js +++ b/modules/open8BidAdapter.js @@ -1,8 +1,8 @@ -import { Renderer } from 'src/Renderer'; +import { Renderer } from '../src/Renderer'; import {ajax} from '../src/ajax'; -import * as utils from 'src/utils'; -import { registerBidder } from 'src/adapters/bidderFactory'; -import { VIDEO, BANNER } from 'src/mediaTypes'; +import * as utils from '../src/utils'; +import { registerBidder } from '../src/adapters/bidderFactory'; +import { VIDEO, BANNER } from '../src/mediaTypes'; const BIDDER_CODE = 'open8'; const URL = '//as.vt.open8.com/v1/control/prebid'; diff --git a/modules/openxBidAdapter.js b/modules/openxBidAdapter.js index 52a97a98952..a79343ab2ff 100644 --- a/modules/openxBidAdapter.js +++ b/modules/openxBidAdapter.js @@ -8,7 +8,7 @@ import {parse} from '../src/url'; const SUPPORTED_AD_TYPES = [BANNER, VIDEO]; const BIDDER_CODE = 'openx'; const BIDDER_CONFIG = 'hb_pb'; -const BIDDER_VERSION = '2.1.6'; +const BIDDER_VERSION = '2.1.9'; let shouldSendBoPixel = true; @@ -75,7 +75,7 @@ export const spec = { }; function isVideoRequest(bidRequest) { - return utils.deepAccess(bidRequest, 'mediaTypes.video') || bidRequest.mediaType === VIDEO; + return (utils.deepAccess(bidRequest, 'mediaTypes.video') && !utils.deepAccess(bidRequest, 'mediaTypes.banner')) || bidRequest.mediaType === VIDEO; } function createBannerBidResponses(oxResponseObj, {bids, startTime}) { @@ -121,6 +121,10 @@ function createBannerBidResponses(oxResponseObj, {bids, startTime}) { bidResponse.meta.brandId = adUnit.brand_id; } + if (adUnit.adv_id) { + bidResponse.meta.dspid = adUnit.adv_id; + } + bidResponses.push(bidResponse); registerBeacon(BANNER, adUnit, startTime); @@ -233,13 +237,32 @@ function buildCommonQueryParamsFromBids(bids, bidderRequest) { } } - if (bids[0].crumbs && bids[0].crumbs.pubcid) { + if ((bids[0].userId && bids[0].userId.pubcid)) { + defaultParams.pubcid = bids[0].userId.pubcid; + } else if (bids[0].crumbs && bids[0].crumbs.pubcid) { defaultParams.pubcid = bids[0].crumbs.pubcid; } + if (bids[0].schain) { + defaultParams.schain = serializeSupplyChain(bids[0].schain); + } + return defaultParams; } +function serializeSupplyChain(supplyChain) { + return `${supplyChain.ver},${supplyChain.complete}!${serializeSupplyChainNodes(supplyChain.nodes)}`; +} + +function serializeSupplyChainNodes(supplyChainNodes) { + const supplyChainNodePropertyOrder = ['asi', 'sid', 'hp', 'rid', 'name', 'domain']; + + return supplyChainNodes.map(supplyChainNode => { + return supplyChainNodePropertyOrder.map(property => supplyChainNode[property] || '') + .join(','); + }).join('!'); +} + function buildOXBannerRequest(bids, bidderRequest) { let customParamsForAllBids = []; let hasCustomParam = false; @@ -256,7 +279,7 @@ function buildOXBannerRequest(bids, bidderRequest) { queryParams.ns = 1; } - if (bids.some(bid => bid.params.coppa)) { + if (config.getConfig('coppa') === true || bids.some(bid => bid.params.coppa)) { queryParams.tfcd = 1; } diff --git a/modules/openxBidAdapter.md b/modules/openxBidAdapter.md index 042399cf023..965b8ee1948 100644 --- a/modules/openxBidAdapter.md +++ b/modules/openxBidAdapter.md @@ -75,12 +75,8 @@ var adUnits = [ params: { unit: '1611023124', delDomain: 'PUBLISHER-d.openx.net', - openrtb: { - imp: [{ - video: { - mimes: ['video/x-ms-wmv, video/mp4'] - } - }] + video: { + mimes: ['video/x-ms-wmv, video/mp4'] } } }] diff --git a/modules/openxoutstreamBidAdapter.js b/modules/openxoutstreamBidAdapter.js index 42c7a3fff32..9011a949e7b 100644 --- a/modules/openxoutstreamBidAdapter.js +++ b/modules/openxoutstreamBidAdapter.js @@ -114,7 +114,7 @@ function buildOXBannerRequest(bid, bidderRequest) { queryParams.ns = 1; } - if (bid.params.coppa) { + if (config.getConfig('coppa') === true || bid.params.coppa) { queryParams.tfcd = 1; } diff --git a/modules/optimeraBidAdapter.js b/modules/optimeraBidAdapter.js index ab4c75c1c1f..bc4407ababa 100644 --- a/modules/optimeraBidAdapter.js +++ b/modules/optimeraBidAdapter.js @@ -1,4 +1,5 @@ -import { registerBidder } from 'src/adapters/bidderFactory'; +import { registerBidder } from '../src/adapters/bidderFactory'; +import { deepAccess } from '../src/utils'; const BIDDER_CODE = 'optimera'; const SCORES_BASE_URL = 'https://dyv1bugovvq1g.cloudfront.net/'; @@ -11,12 +12,11 @@ export const spec = { * @param {bidRequest} bid The bid params to validate. * @return boolean True if this is a valid bid, and false otherwise. */ - isBidRequestValid: function (bidRequest) { + isBidRequestValid (bidRequest) { if (typeof bidRequest.params !== 'undefined' && typeof bidRequest.params.clientID !== 'undefined') { return true; - } else { - return false; } + return false; }, /** * Make a server request from the list of BidRequests. @@ -27,18 +27,19 @@ export const spec = { * @param {validBidRequests[]} - an array of bids * @return ServerRequest Info describing the request to the server. */ - buildRequests: function (validBidRequests) { - let optimeraHost = window.location.host; - let optimeraPathName = window.location.pathname; + buildRequests (validBidRequests) { + const optimeraHost = window.location.host; + const optimeraPathName = window.location.pathname; if (typeof validBidRequests[0].params.clientID !== 'undefined') { - let clientID = validBidRequests[0].params.clientID; - let scoresURL = SCORES_BASE_URL + clientID + '/' + optimeraHost + optimeraPathName + '.js'; + const { clientID } = validBidRequests[0].params; + const scoresURL = `${SCORES_BASE_URL + clientID}/${optimeraHost}${optimeraPathName}.js`; return { method: 'GET', url: scoresURL, payload: validBidRequests, }; } + return {}; }, /** * Unpack the response from the server into a list of bids. @@ -49,24 +50,25 @@ export const spec = { * @param {*} serverResponse A successful response from the server. * @return {Bid[]} An array of bids which were nested inside the server. */ - interpretResponse: function (serverResponse, bidRequest) { - let validBids = bidRequest.payload; - let bidResponses = []; + interpretResponse (serverResponse, bidRequest) { + const validBids = bidRequest.payload; + const bidResponses = []; let dealId = ''; if (typeof serverResponse.body !== 'undefined') { - let scores = serverResponse.body; - for (let i = 0; i < validBids.length; i++) { + const scores = serverResponse.body; + for (let i = 0; i < validBids.length; i += 1) { if (typeof validBids[i].params.clientID !== 'undefined') { if (validBids[i].adUnitCode in scores) { - dealId = scores[validBids[i].adUnitCode]; + const deviceDealId = deepAccess(scores, `device.${validBids[i].params.device}.${validBids[i].adUnitCode}`); + dealId = deviceDealId || scores[validBids[i].adUnitCode]; } - let bidResponse = { + const bidResponse = { requestId: validBids[i].bidId, ad: '
    ', cpm: 0.01, width: 0, height: 0, - dealId: dealId, + dealId, ttl: 300, creativeId: '1', netRevenue: '0', diff --git a/modules/optimeraBidAdapter.md b/modules/optimeraBidAdapter.md index 909c0a46cd6..25da9b6236f 100644 --- a/modules/optimeraBidAdapter.md +++ b/modules/optimeraBidAdapter.md @@ -19,7 +19,8 @@ Module that adds ad placement visibility scores for DFP. { bidder: 'optimera', params: { - clientID: '9999' + clientID: '9999', + device: 'mo' } }] },{ @@ -29,7 +30,8 @@ Module that adds ad placement visibility scores for DFP. { bidder: 'optimera', params: { - clientID: '9999' + clientID: '9999', + device: 'mo' } }] }]; diff --git a/modules/orbidderBidAdapter.js b/modules/orbidderBidAdapter.js index e316f3ef212..954ad82261f 100644 --- a/modules/orbidderBidAdapter.js +++ b/modules/orbidderBidAdapter.js @@ -19,7 +19,8 @@ export const spec = { (bid.params.accountId && (typeof bid.params.accountId === 'string')) && (bid.params.placementId && (typeof bid.params.placementId === 'string')) && ((typeof bid.params.bidfloor === 'undefined') || (typeof bid.params.bidfloor === 'number')) && - ((typeof bid.params.keyValues === 'undefined') || (typeof bid.params.keyValues === 'object'))); + ((typeof bid.params.keyValues === 'undefined') || (typeof bid.params.keyValues === 'object')) && + ((typeof bid.params.profile === 'undefined') || (typeof bid.params.profile === 'object'))); }, buildRequests(validBidRequests, bidderRequest) { @@ -42,12 +43,10 @@ export const spec = { } }; spec.bidParams[bidRequest.bidId] = bidRequest.params; - if (bidRequest && bidRequest.gdprConsent) { + if (bidderRequest && bidderRequest.gdprConsent) { ret.data.gdprConsent = { - consentString: bidRequest.gdprConsent.consentString, - consentRequired: (typeof bidRequest.gdprConsent.gdprApplies === 'boolean') - ? bidRequest.gdprConsent.gdprApplies - : true + consentString: bidderRequest.gdprConsent.consentString, + consentRequired: (typeof bidderRequest.gdprConsent.gdprApplies === 'boolean') && bidderRequest.gdprConsent.gdprApplies }; } return ret; @@ -72,15 +71,18 @@ export const spec = { return bidResponses; }, - onBidWon(winObj) { + onBidWon(bid) { + this.onHandler(bid, '/win'); + }, + + onHandler (bid, route) { const getRefererInfo = detectReferer(window); - winObj.pageUrl = getRefererInfo().referer; - if (spec.bidParams[winObj.adId]) { - winObj.params = spec.bidParams[winObj.adId]; + bid.pageUrl = getRefererInfo().referer; + if (spec.bidParams[bid.requestId] && (typeof bid.params === 'undefined')) { + bid.params = [spec.bidParams[bid.requestId]]; } - - spec.ajaxCall(`${spec.orbidderHost}/win`, JSON.stringify(winObj)); + spec.ajaxCall(`${spec.orbidderHost}${route}`, JSON.stringify(bid)); }, ajaxCall(endpoint, data) { diff --git a/modules/otmBidAdapter.js b/modules/otmBidAdapter.js index 57ac414c7b6..ddb4d356f5c 100644 --- a/modules/otmBidAdapter.js +++ b/modules/otmBidAdapter.js @@ -1,5 +1,5 @@ -import {BANNER} from 'src/mediaTypes'; -import {registerBidder} from 'src/adapters/bidderFactory'; +import {BANNER} from '../src/mediaTypes'; +import {registerBidder} from '../src/adapters/bidderFactory'; export const spec = { code: 'otm', diff --git a/modules/ozoneBidAdapter.js b/modules/ozoneBidAdapter.js index 406bffdf4df..9bd4f21ff96 100644 --- a/modules/ozoneBidAdapter.js +++ b/modules/ozoneBidAdapter.js @@ -2,14 +2,20 @@ import * as utils from '../src/utils'; import { registerBidder } from '../src/adapters/bidderFactory'; import { BANNER, NATIVE, VIDEO } from '../src/mediaTypes'; import {config} from '../src/config'; +import {getPriceBucketString} from '../src/cpmBucketManager'; +import { Renderer } from '../src/Renderer' const BIDDER_CODE = 'ozone'; const OZONEURI = 'https://elb.the-ozone-project.com/openrtb2/auction'; const OZONECOOKIESYNC = 'https://elb.the-ozone-project.com/static/load-cookie.html'; -const OZONEVERSION = '1.4.7'; +const OZONE_RENDERER_URL = 'https://prebid.the-ozone-project.com/ozone-renderer.js'; + +const OZONEVERSION = '2.1.2'; + export const spec = { code: BIDDER_CODE, + supportedMediaTypes: [VIDEO, BANNER], /** * Basic check to see whether required parameters are in the request. @@ -51,49 +57,66 @@ export const spec = { utils.logInfo('OZONE: OZONE BID ADAPTER VALIDATION FAILED : customParams should be renamed to customData'); return false; } - if (bid.params.hasOwnProperty('ozoneData')) { - if (typeof bid.params.ozoneData !== 'object') { - utils.logInfo('OZONE: OZONE BID ADAPTER VALIDATION FAILED : ozoneData is not an object'); - return false; - } - } if (bid.params.hasOwnProperty('lotameData')) { if (typeof bid.params.lotameData !== 'object') { utils.logInfo('OZONE: OZONE BID ADAPTER VALIDATION FAILED : lotameData is not an object'); return false; } } + if (bid.hasOwnProperty('mediaTypes') && bid.mediaTypes.hasOwnProperty(VIDEO)) { + if (!bid.mediaTypes.video.hasOwnProperty('context')) { + utils.logInfo('OZONE: [WARNING] No context key/value in bid. Rejecting bid: ', bid); + return false; + } + if (bid.mediaTypes.video.context !== 'outstream') { + utils.logInfo('OZONE: [WARNING] Only outstream video is supported. Rejecting bid: ', bid); + return false; + } + } return true; }, + buildRequests(validBidRequests, bidderRequest) { utils.logInfo('OZONE: ozone v' + OZONEVERSION + ' validBidRequests', validBidRequests, 'bidderRequest', bidderRequest); - utils.logInfo('OZONE: buildRequests setting auctionId', bidderRequest.auctionId); let singleRequest = config.getConfig('ozone.singleRequest'); - singleRequest = singleRequest !== false; // undefined & true will be true utils.logInfo('OZONE: config ozone.singleRequest : ', singleRequest); let htmlParams = validBidRequests[0].params; // the html page config params will be included in each element let ozoneRequest = {}; // we only want to set specific properties on this, not validBidRequests[0].params - // ozoneRequest['id'] = utils.generateUUID(); - delete ozoneRequest.test; // don't allow test to be set in the config - ONLY use $_GET['pbjs_debug'] - if (bidderRequest.gdprConsent) { + + if (bidderRequest && bidderRequest.gdprConsent) { utils.logInfo('OZONE: ADDING GDPR info'); ozoneRequest.regs = {}; ozoneRequest.regs.ext = {}; - ozoneRequest.regs.ext.gdpr = bidderRequest.gdprConsent.gdprApplies === true ? 1 : 0; + ozoneRequest.regs.ext.gdpr = bidderRequest.gdprConsent.gdprApplies ? 1 : 0; if (ozoneRequest.regs.ext.gdpr) { - ozoneRequest.user = {}; - ozoneRequest.user.ext = {'consent': bidderRequest.gdprConsent.consentString}; + ozoneRequest.user = ozoneRequest.user || {}; + if ( + bidderRequest.gdprConsent.vendorData && + bidderRequest.gdprConsent.vendorData.vendorConsents && + typeof bidderRequest.gdprConsent.consentString !== 'undefined' + ) { + utils.logInfo('OZONE: found all info we need for GDPR - will add info to request object'); + ozoneRequest.user.ext = {'consent': bidderRequest.gdprConsent.consentString}; + // are we able to make this request? + let vendorConsents = bidderRequest.gdprConsent.vendorData.vendorConsents; + let boolGdprConsentForOzone = vendorConsents[524]; + let arrGdprConsents = toFlatArray(bidderRequest.gdprConsent.vendorData.purposeConsents); + ozoneRequest.regs.ext.oz_con = boolGdprConsentForOzone ? 1 : 0; + ozoneRequest.regs.ext.gap = arrGdprConsents; + } + } else { + utils.logInfo('OZONE: **** Failed to find required info for GDPR for request object, even though bidderRequest.gdprConsent is TRUE ****'); } } else { - utils.logInfo('OZONE: WILL NOT ADD GDPR info'); + utils.logInfo('OZONE: WILL NOT ADD GDPR info; no bidderRequest.gdprConsent object was present.'); } + ozoneRequest.device = {'w': window.innerWidth, 'h': window.innerHeight}; let tosendtags = validBidRequests.map(ozoneBidRequest => { var obj = {}; - obj.id = ozoneBidRequest.bidId; // this causes a failure if we change it to something else - // obj.id = ozoneBidRequest.adUnitCode; // (eg. 'mpu' or 'leaderboard') A unique identifier for this impression within the context of the bid request (typically, starts with 1 and increments. + obj.id = ozoneBidRequest.bidId; // this causes an error if we change it to something else, even if you update the bidRequest object: "WARNING: Bidder ozone made bid for unknown request ID: mb7953.859498327448. Ignoring." obj.tagid = (ozoneBidRequest.params.placementId).toString(); obj.secure = window.location.protocol === 'https:' ? 1 : 0; // is there a banner (or nothing declared, so banner is the default)? @@ -111,10 +134,24 @@ export const spec = { arrBannerSizes = ozoneBidRequest.mediaTypes[BANNER].sizes; /* Note - if there is a sizes element in the config root it will be pushed into here */ utils.logInfo('OZONE: setting banner size from the mediaTypes.banner element for bidId ' + obj.id + ': ', arrBannerSizes); } - // Video integration is not complete yet if (ozoneBidRequest.mediaTypes.hasOwnProperty(VIDEO)) { obj.video = ozoneBidRequest.mediaTypes[VIDEO]; - utils.logInfo('OZONE: setting video object from the mediaTypes.video element: ' + obj.id + ':', obj.video); + // we need to duplicate some of the video values + let wh = getWidthAndHeightFromVideoObject(obj.video); + utils.logInfo('OZONE: setting video object from the mediaTypes.video element: ' + obj.id + ':', obj.video, 'wh=', wh); + if (wh && typeof wh === 'object') { + obj.video.w = wh['w']; + obj.video.h = wh['h']; + if (playerSizeIsNestedArray(obj.video)) { // this should never happen; it was in the original spec for this change though. + utils.logInfo('OZONE: setting obj.video.format to be an array of objects'); + obj.video.format = [wh]; + } else { + utils.logInfo('OZONE: setting obj.video.format to be an object'); + obj.video.format = wh; + } + } else { + utils.logInfo('OZONE: cannot set w, h & format values for video; the config is not right'); + } } // Native integration is not complete yet if (ozoneBidRequest.mediaTypes.hasOwnProperty(NATIVE)) { @@ -141,25 +178,21 @@ export const spec = { obj.ext = {'prebid': {'storedrequest': {'id': (ozoneBidRequest.params.placementId).toString()}}, 'ozone': {}}; obj.ext.ozone.adUnitCode = ozoneBidRequest.adUnitCode; // eg. 'mpu' obj.ext.ozone.transactionId = ozoneBidRequest.transactionId; // this is the transactionId PER adUnit, common across bidders for this unit + obj.ext.ozone.oz_pb_v = OZONEVERSION; if (ozoneBidRequest.params.hasOwnProperty('customData')) { obj.ext.ozone.customData = ozoneBidRequest.params.customData; } - if (ozoneBidRequest.params.hasOwnProperty('ozoneData')) { - obj.ext.ozone.ozoneData = ozoneBidRequest.params.ozoneData; - } if (ozoneBidRequest.params.hasOwnProperty('lotameData')) { obj.ext.ozone.lotameData = ozoneBidRequest.params.lotameData; } - if (ozoneBidRequest.hasOwnProperty('crumbs') && ozoneBidRequest.crumbs.hasOwnProperty('pubcid')) { + if (utils.deepAccess(ozoneBidRequest, 'crumbs.pubcid')) { obj.ext.ozone.pubcid = ozoneBidRequest.crumbs.pubcid; } return obj; }); - utils.logInfo('tosendtags = ', tosendtags); ozoneRequest.site = {'publisher': {'id': htmlParams.publisherId}, 'page': document.location.href}; ozoneRequest.test = parseInt(getTestQuerystringValue()); // will be 1 or 0 - // utils.logInfo('_ozoneInternal is', _ozoneInternal); // return the single request object OR the array: if (singleRequest) { utils.logInfo('OZONE: buildRequests starting to generate response for a single request'); @@ -177,7 +210,6 @@ export const spec = { utils.logInfo('OZONE: buildRequests going to return for single: ', ret); return ret; } - // not single request - pull apart the tosendtags array & return an array of objects each containing one element in the imp array. let arrRet = tosendtags.map(imp => { utils.logInfo('OZONE: buildRequests starting to generate non-single response, working on imp : ', imp); @@ -201,67 +233,65 @@ export const spec = { /** * Interpret the response if the array contains BIDDER elements, in the format: [ [bidder1 bid 1, bidder1 bid 2], [bidder2 bid 1, bidder2 bid 2] ] * NOte that in singleRequest mode this will be called once, else it will be called for each adSlot's response + * + * Updated April 2019 to return all bids, not just the one we decide is the 'winner' + * * @param serverResponse * @param request * @returns {*} */ interpretResponse(serverResponse, request) { - utils.logInfo('OZONE: version' + OZONEVERSION + ' interpretResponse', serverResponse, request); serverResponse = serverResponse.body || {}; - if (serverResponse.seatbid) { - if (utils.isArray(serverResponse.seatbid)) { - // serverResponse seems good, let's get the list of bids from the request object: - let arrRequestBids = request.bidderRequest.bids; - // build up a list of winners, one for each bidId in arrBidIds - let arrWinners = []; - for (let i = 0; i < arrRequestBids.length; i++) { - let thisBid = arrRequestBids[i]; - let ozoneInternalKey = thisBid.bidId; - let {seat: winningSeat, bid: winningBid} = ozoneGetWinnerForRequestBid(thisBid, serverResponse.seatbid); - - if (winningBid == null) { - utils.logInfo('OZONE: FAILED to get winning bid for bid : ', thisBid, 'will skip. Possibly a non-single request, which will be missing some bid IDs'); - continue; - } - - const {defaultWidth, defaultHeight} = defaultSize(arrRequestBids[i]); - winningBid = ozoneAddStandardProperties(winningBid, defaultWidth, defaultHeight); - - utils.logInfo('OZONE: Going to add the adserverTargeting custom parameters for key: ', ozoneInternalKey); - let adserverTargeting = {}; - let allBidsForThisBidid = ozoneGetAllBidsForBidId(ozoneInternalKey, serverResponse.seatbid); - // add all the winning & non-winning bids for this bidId: - Object.keys(allBidsForThisBidid).forEach(function(bidderName, index, ar2) { - utils.logInfo('OZONE: inside allBidsForThisBidid:foreach', bidderName, index, ar2, allBidsForThisBidid); - adserverTargeting['oz_' + bidderName] = bidderName; - adserverTargeting['oz_' + bidderName + '_pb'] = String(allBidsForThisBidid[bidderName].price); - adserverTargeting['oz_' + bidderName + '_crid'] = String(allBidsForThisBidid[bidderName].crid); - adserverTargeting['oz_' + bidderName + '_adv'] = String(allBidsForThisBidid[bidderName].adomain); - adserverTargeting['oz_' + bidderName + '_imp_id'] = String(allBidsForThisBidid[bidderName].impid); - }); - // now add the winner data: - adserverTargeting['oz_auc_id'] = String(request.bidderRequest.auctionId); - adserverTargeting['oz_winner'] = String(winningSeat); - adserverTargeting['oz_winner_auc_id'] = String(winningBid.id); - adserverTargeting['oz_winner_imp_id'] = String(winningBid.impid); - adserverTargeting['oz_response_id'] = String(serverResponse.id); + if (!serverResponse.hasOwnProperty('seatbid')) { return []; } + if (typeof serverResponse.seatbid !== 'object') { return []; } + let arrAllBids = []; + serverResponse.seatbid = injectAdIdsIntoAllBidResponses(serverResponse.seatbid); // we now make sure that each bid in the bidresponse has a unique (within page) adId attribute. + for (let i = 0; i < serverResponse.seatbid.length; i++) { + let sb = serverResponse.seatbid[i]; + for (let j = 0; j < sb.bid.length; j++) { + const {defaultWidth, defaultHeight} = defaultSize(request.bidderRequest.bids[j]); // there should be the same number of bids as requests, so index [j] should always exist. + let thisBid = ozoneAddStandardProperties(sb.bid[j], defaultWidth, defaultHeight); - winningBid.adserverTargeting = adserverTargeting; - utils.logInfo('OZONE: winner is', winningBid); - arrWinners.push(winningBid); - utils.logInfo('OZONE: arrWinners is', arrWinners); + // from https://github.com/prebid/Prebid.js/pull/1082 + if (utils.deepAccess(thisBid, 'ext.prebid.type') === VIDEO) { + utils.logInfo('OZONE: going to attach a renderer to:', j); + let renderConf = createObjectForInternalVideoRender(thisBid); + thisBid.renderer = Renderer.install(renderConf); + } else { + utils.logInfo('OZONE: bid is not a video, will not attach a renderer: ', j); } - let winnersClean = arrWinners.filter(w => { - return (w.bidId); // will be cast to boolean + + let ozoneInternalKey = thisBid.bidId; + let adserverTargeting = {}; + // all keys for all bidders for this bid have to be added to all objects returned, else some keys will not be sent to ads? + let allBidsForThisBidid = ozoneGetAllBidsForBidId(ozoneInternalKey, serverResponse.seatbid); + // add all the winning & non-winning bids for this bidId: + utils.logInfo('OZONE: Going to iterate allBidsForThisBidId', allBidsForThisBidid); + Object.keys(allBidsForThisBidid).forEach(function(bidderName, index, ar2) { + adserverTargeting['oz_' + bidderName] = bidderName; + adserverTargeting['oz_' + bidderName + '_pb'] = String(allBidsForThisBidid[bidderName].price); + adserverTargeting['oz_' + bidderName + '_crid'] = String(allBidsForThisBidid[bidderName].crid); + adserverTargeting['oz_' + bidderName + '_adv'] = String(allBidsForThisBidid[bidderName].adomain); + adserverTargeting['oz_' + bidderName + '_imp_id'] = String(allBidsForThisBidid[bidderName].impid); + adserverTargeting['oz_' + bidderName + '_adId'] = String(allBidsForThisBidid[bidderName].adId); + adserverTargeting['oz_' + bidderName + '_pb_r'] = getRoundedBid(allBidsForThisBidid[bidderName].price, allBidsForThisBidid[bidderName].ext.prebid.type); + if (allBidsForThisBidid[bidderName].hasOwnProperty('dealid')) { + adserverTargeting['oz_' + bidderName + '_dealid'] = String(allBidsForThisBidid[bidderName].dealid); + } }); - utils.logInfo('OZONE: going to return winnersClean:', winnersClean); - return winnersClean; - } else { - return []; + // also add in the winning bid, to be sent to dfp + let {seat: winningSeat, bid: winningBid} = ozoneGetWinnerForRequestBid(ozoneInternalKey, serverResponse.seatbid); + adserverTargeting['oz_auc_id'] = String(request.bidderRequest.auctionId); + adserverTargeting['oz_winner'] = String(winningSeat); + adserverTargeting['oz_winner_auc_id'] = String(winningBid.id); + adserverTargeting['oz_winner_imp_id'] = String(winningBid.impid); + adserverTargeting['oz_response_id'] = String(serverResponse.id); + adserverTargeting['oz_pb_v'] = OZONEVERSION; + thisBid.adserverTargeting = adserverTargeting; + arrAllBids.push(thisBid); } - } else { - return []; } + return arrAllBids; }, getUserSyncs(optionsType, serverResponse) { if (!serverResponse || serverResponse.length === 0) { @@ -275,6 +305,21 @@ export const spec = { } } } +/** + * add a page-level-unique adId element to all server response bids. + * NOTE that this is distructive - it mutates the serverResponse object sent in as a parameter + * @param seatbid object (serverResponse.seatbid) + * @returns seatbid object + */ +export function injectAdIdsIntoAllBidResponses(seatbid) { + for (let i = 0; i < seatbid.length; i++) { + let sb = seatbid[i]; + for (let j = 0; j < sb.bid.length; j++) { + sb.bid[j]['adId'] = sb.bid[j]['impid'] + '-' + i; // modify the bidId per-bid, so each bid has a unique adId within this response, and dfp can select one. + } + } + return seatbid; +} export function checkDeepArray(Arr) { if (Array.isArray(Arr)) { if (Array.isArray(Arr[0])) { @@ -287,6 +332,13 @@ export function checkDeepArray(Arr) { } } export function defaultSize(thebidObj) { + if (!thebidObj) { + utils.logInfo('OZONE: defaultSize received empty bid obj! going to return fixed default size'); + return { + 'defaultHeight': 250, + 'defaultWidth': 300 + }; + } const {sizes} = thebidObj; const returnObject = {}; returnObject.defaultWidth = checkDeepArray(sizes)[0]; @@ -300,15 +352,14 @@ export function defaultSize(thebidObj) { * @param serverResponseSeatBid * @returns {*} bid object */ -export function ozoneGetWinnerForRequestBid(requestBid, serverResponseSeatBid) { +export function ozoneGetWinnerForRequestBid(requestBidId, serverResponseSeatBid) { let thisBidWinner = null; let winningSeat = null; for (let j = 0; j < serverResponseSeatBid.length; j++) { let theseBids = serverResponseSeatBid[j].bid; let thisSeat = serverResponseSeatBid[j].seat; for (let k = 0; k < theseBids.length; k++) { - if (theseBids[k].impid === requestBid.bidId) { // we've found a matching server response bid for this request bid - // if (theseBids[k].impid === requestBid.adUnitCode) { // we've found a matching server response bid for this request bid + if (theseBids[k].impid === requestBidId) { // we've found a matching server response bid for this request bid if ((thisBidWinner == null) || (thisBidWinner.price < theseBids[k].price)) { thisBidWinner = theseBids[k]; winningSeat = thisSeat; @@ -327,22 +378,88 @@ export function ozoneGetWinnerForRequestBid(requestBid, serverResponseSeatBid) { * @returns {} = {ozone:{obj}, appnexus:{obj}, ... } */ export function ozoneGetAllBidsForBidId(matchBidId, serverResponseSeatBid) { - utils.logInfo('OZONE: ozoneGetAllBidsForBidId - starting, with: ', matchBidId, serverResponseSeatBid); let objBids = {}; for (let j = 0; j < serverResponseSeatBid.length; j++) { let theseBids = serverResponseSeatBid[j].bid; let thisSeat = serverResponseSeatBid[j].seat; for (let k = 0; k < theseBids.length; k++) { if (theseBids[k].impid === matchBidId) { // we've found a matching server response bid for the request bid we're looking for - utils.logInfo('ozoneGetAllBidsForBidId - found matching bid: ', matchBidId, theseBids[k]); objBids[thisSeat] = theseBids[k]; } } } - utils.logInfo('OZONE: ozoneGetAllBidsForBidId - going to return: ', objBids); return objBids; } +/** + * Round the bid price down according to the granularity + * @param price + * @param mediaType = video, banner or native + */ +export function getRoundedBid(price, mediaType) { + const mediaTypeGranularity = config.getConfig(`mediaTypePriceGranularity.${mediaType}`); // might be string or object or nothing; if set then this takes precedence over 'priceGranularity' + let objBuckets = config.getConfig('customPriceBucket'); // this is always an object - {} if strBuckets is not 'custom' + let strBuckets = config.getConfig('priceGranularity'); // priceGranularity value, always a string ** if priceGranularity is set to an object then it's always 'custom' + let theConfigObject = getGranularityObject(mediaType, mediaTypeGranularity, strBuckets, objBuckets); + let theConfigKey = getGranularityKeyName(mediaType, mediaTypeGranularity, strBuckets); + + utils.logInfo('OZONE: getRoundedBid. price:', price, 'mediaType:', mediaType, 'configkey:', theConfigKey, 'configObject:', theConfigObject, 'mediaTypeGranularity:', mediaTypeGranularity, 'strBuckets:', strBuckets); + + let priceStringsObj = getPriceBucketString( + price, + theConfigObject, + config.getConfig('currency.granularityMultiplier') + ); + utils.logInfo('OZONE: priceStringsObj', priceStringsObj); + // by default, without any custom granularity set, you get granularity name : 'medium' + let granularityNamePriceStringsKeyMapping = { + 'medium': 'med', + 'custom': 'custom', + 'high': 'high', + 'low': 'low', + 'dense': 'dense' + }; + if (granularityNamePriceStringsKeyMapping.hasOwnProperty(theConfigKey)) { + let priceStringsKey = granularityNamePriceStringsKeyMapping[theConfigKey]; + utils.logInfo('OZONE: looking for priceStringsKey:', priceStringsKey); + return priceStringsObj[priceStringsKey]; + } + return priceStringsObj['auto']; +} + +/** + * return the key to use to get the value out of the priceStrings object, taking into account anything at + * config.priceGranularity level or config.mediaType.xxx level + * I've noticed that the key specified by prebid core : config.getConfig('priceGranularity') does not properly + * take into account the 2-levels of config + */ +export function getGranularityKeyName(mediaType, mediaTypeGranularity, strBuckets) { + if (typeof mediaTypeGranularity === 'string') { + return mediaTypeGranularity; + } + if (typeof mediaTypeGranularity === 'object') { + return 'custom'; + } + if (typeof strBuckets === 'string') { + return strBuckets; + } + return 'auto'; // fall back to a default key - should literally never be needed though. +} + +/** + * return the object to use to create the custom value of the priceStrings object, taking into account anything at + * config.priceGranularity level or config.mediaType.xxx level + */ +export function getGranularityObject(mediaType, mediaTypeGranularity, strBuckets, objBuckets) { + if (typeof mediaTypeGranularity === 'object') { + return mediaTypeGranularity; + } + if (strBuckets === 'custom') { + return objBuckets; + } + return ''; +} + /** * We expect to be able to find a standard set of properties on winning bid objects; add them here. * @param seatBid @@ -379,5 +496,112 @@ export function getTestQuerystringValue() { return 0; } +/** + * Generate a random number per ad; I'll use the current ms timestamp, then append 8 random alpha/numeric characters + * Randomness : 1 in 208 billion random combinations per-millisecond, non-repeating sequence. + * + * @returns {*} + */ +export function pgGuid() { + return new Date().getTime() + 'xxxxxxxx'.replace(/x/g, function(c) { + return Math.round((Math.random() * 36)).toString(36); + }); +} + +function createObjectForInternalVideoRender(bid) { + let obj = { + url: OZONE_RENDERER_URL, + callback: () => onOutstreamRendererLoaded(bid) + } + return obj; +} + +function onOutstreamRendererLoaded(bid) { + try { + bid.renderer.setRender(outstreamRender); + } catch (err) { + utils.logWarn('Prebid Error calling setRender on renderer', err) + } +} + +function outstreamRender(bid) { + window.ozoneVideo.outstreamRender(bid); +} + +/** + * convert {1: true, + 2: true, + 3: true, + 4: true, + 5: true} + to : [1,2,3,4,5] + * @param obj + */ +function toFlatArray(obj) { + let ret = []; + Object.keys(obj).forEach(function(key) { if (obj[key]) { ret.push(parseInt(key)); } }); + utils.logInfo('OZONE: toFlatArray:', obj, 'returning', ret); + return ret; +} + +/** + * + * @param objVideo will be like {"playerSize":[640,480],"mimes":["video/mp4"],"context":"outstream"} or POSSIBLY {"playerSize":[[640,480]],"mimes":["video/mp4"],"context":"outstream"} + * @return object {w,h} or null + */ +export function getWidthAndHeightFromVideoObject(objVideo) { + let playerSize = getPlayerSizeFromObject(objVideo); + if (!playerSize) { + return null; + } + if (playerSize[0] && typeof playerSize[0] === 'object') { + utils.logInfo('OZONE: getWidthAndHeightFromVideoObject found nested array inside playerSize.', playerSize[0]); + playerSize = playerSize[0]; + if (typeof playerSize[0] !== 'number' && typeof playerSize[0] !== 'string') { + utils.logInfo('OZONE: getWidthAndHeightFromVideoObject found non-number/string type inside the INNER array in playerSize. This is totally wrong - cannot continue.', playerSize[0]); + return null; + } + } + if (playerSize.length !== 2) { + utils.logInfo('OZONE: getWidthAndHeightFromVideoObject found playerSize with length of ' + playerSize.length + '. This is totally wrong - cannot continue.'); + return null; + } + return ({'w': playerSize[0], 'h': playerSize[1]}); +} + +/** + * @param objVideo will be like {"playerSize":[640,480],"mimes":["video/mp4"],"context":"outstream"} or POSSIBLY {"playerSize":[[640,480]],"mimes":["video/mp4"],"context":"outstream"} + * @return object {w,h} or null + */ +export function playerSizeIsNestedArray(objVideo) { + let playerSize = getPlayerSizeFromObject(objVideo); + if (!playerSize) { + return null; + } + if (playerSize.length < 1) { + return null; + } + return (playerSize[0] && typeof playerSize[0] === 'object'); +} + +/** + * Common functionality when looking at a video object, to get the playerSize + * @param objVideo + * @returns {*} + */ +function getPlayerSizeFromObject(objVideo) { + utils.logInfo('OZONE: getPlayerSizeFromObject received object', objVideo); + if (!objVideo.hasOwnProperty('playerSize')) { + utils.logError('OZONE: getPlayerSizeFromObject FAILED: no playerSize in video object', objVideo); + return null; + } + let playerSize = objVideo.playerSize; + if (typeof playerSize !== 'object') { + utils.logError('OZONE: getPlayerSizeFromObject FAILED: playerSize is not an object/array', objVideo); + return null; + } + return playerSize; +} + registerBidder(spec); utils.logInfo('OZONE: ozoneBidAdapter ended'); diff --git a/modules/ozoneBidAdapter.md b/modules/ozoneBidAdapter.md index c013a4d558c..1fe5e681e25 100644 --- a/modules/ozoneBidAdapter.md +++ b/modules/ozoneBidAdapter.md @@ -1,4 +1,4 @@ - + # Overview ``` @@ -12,7 +12,7 @@ Maintainer: engineering@ozoneproject.com Module that connects to the Ozone Project's demand source(s). -The Ozone Project bid adapter supports Banner mediaTypes ONLY. +The Ozone Project bid adapter supports Banner and Outstream Video mediaTypes ONLY. # Test Parameters @@ -36,9 +36,41 @@ adUnits = [{ publisherId: 'OZONENUK0001', /* an ID to identify the publisher account - required */ siteId: '4204204201', /* An ID used to identify a site within a publisher account - required */ placementId: '0420420421', /* an ID used to identify the piece of inventory - required - for appnexus test use 13144370. */ - customData: {"key1": "value1", "key2": "value2}, /* optional JSON placeholder for passing publisher key-values for targeting. */ - ozoneData: {"key1": "value1", "key2": "value2"}, /* optional JSON placeholder for for passing ozone project key-values for targeting. */ - lotameData: {"key1": "value1", "key2": "value2} /* optional JSON placeholder for passing Lotame DMP data */ + customData: [{"settings": {}, "targeting": {"key": "value", "key2": ["value1", "value2"]}}],/* optional array with 'targeting' placeholder for passing publisher specific key-values for targeting. */ + lotameData: {"key1": "value1", "key2": "value2"} /* optional JSON placeholder for passing Lotame DMP data */ + } + }] + }]; +``` + + +``` + +//Outstream Video adUnit + +adUnits = [{ + code: 'id-of-your-video-div', + mediaTypes: { + video: { + playerSize: [640, 480], + mimes: ['video/mp4'], + context: 'outstream', + } + }, + bids: [{ + bidder: 'ozone', + params: { + publisherId: 'OZONENUK0001', /* an ID to identify the publisher account - required */ + siteId: '4204204201', /* An ID used to identify a site within a publisher account - required */ + customData: [{"settings": {}, "targeting": { "key": "value", "key2": ["value1", "value2"]}}] + placementId: '0440440442', /* an ID used to identify the piece of inventory - required - for unruly test use 0440440442. */ + customData: [{"settings": {}, "targeting": {"key": "value", "key2": ["value1", "value2"]}}],/* optional array with 'targeting' placeholder for passing publisher specific key-values for targeting. */ + lotameData: {"key1": "value1", "key2": "value2"}, /* optional JSON placeholder for passing Lotame DMP data */ + video: { + skippable: true, /* optional */ + playback_method: ['auto_play_sound_off'], /* optional */ + targetDiv: 'some-different-div-id-to-my-adunitcode' /* optional */ + } } }] }]; diff --git a/modules/padsquadBidAdapter.js b/modules/padsquadBidAdapter.js new file mode 100644 index 00000000000..f5800bed7c9 --- /dev/null +++ b/modules/padsquadBidAdapter.js @@ -0,0 +1,132 @@ +import {registerBidder} from '../src/adapters/bidderFactory'; +import * as utils from '../src/utils'; +import {BANNER} from '../src/mediaTypes'; + +const ENDPOINT_URL = '//x.padsquad.com/auction'; + +const DEFAULT_BID_TTL = 30; +const DEFAULT_CURRENCY = 'USD'; +const DEFAULT_NET_REVENUE = true; + +export const spec = { + code: 'padsquad', + supportedMediaTypes: [BANNER], + + isBidRequestValid: function (bid) { + return (!!bid.params.unitId && typeof bid.params.unitId === 'string') || + (!!bid.params.networkId && typeof bid.params.networkId === 'string') || + (!!bid.params.publisherId && typeof bid.params.publisherId === 'string'); + }, + + buildRequests: function (validBidRequests, bidderRequest) { + if (!validBidRequests || !bidderRequest) { + return; + } + const publisherId = validBidRequests[0].params.publisherId; + const networkId = validBidRequests[0].params.networkId; + const impressions = validBidRequests.map(bidRequest => ({ + id: bidRequest.bidId, + banner: { + format: bidRequest.sizes.map(sizeArr => ({ + w: sizeArr[0], + h: sizeArr[1] + })) + }, + ext: { + exchange: { + unitId: bidRequest.params.unitId + } + } + })); + + const openrtbRequest = { + id: bidderRequest.auctionId, + imp: impressions, + site: { + domain: window.location.hostname, + page: window.location.href, + ref: bidderRequest.refererInfo ? bidderRequest.refererInfo.referer || null : null + }, + ext: { + exchange: { + publisherId: publisherId, + networkId: networkId, + } + } + }; + + // apply gdpr + if (bidderRequest.gdprConsent) { + openrtbRequest.regs = {ext: {gdpr: bidderRequest.gdprConsent.gdprApplies ? 1 : 0}}; + openrtbRequest.user = {ext: {consent: bidderRequest.gdprConsent.consentString}}; + } + + const payloadString = JSON.stringify(openrtbRequest); + return { + method: 'POST', + url: ENDPOINT_URL, + data: payloadString, + }; + }, + + interpretResponse: function (serverResponse, request) { + const bidResponses = []; + const response = (serverResponse || {}).body; + // response is always one seat with (optional) bids for each impression + if (response && response.seatbid && response.seatbid.length === 1 && response.seatbid[0].bid && response.seatbid[0].bid.length) { + response.seatbid[0].bid.forEach(bid => { + bidResponses.push({ + requestId: bid.impid, + cpm: bid.price, + width: bid.w, + height: bid.h, + ad: bid.adm, + ttl: DEFAULT_BID_TTL, + creativeId: bid.crid, + netRevenue: DEFAULT_NET_REVENUE, + currency: DEFAULT_CURRENCY, + }) + }) + } else { + utils.logInfo('padsquad.interpretResponse :: no valid responses to interpret'); + } + return bidResponses; + }, + getUserSyncs: function (syncOptions, serverResponses) { + utils.logInfo('padsquad.getUserSyncs', 'syncOptions', syncOptions, 'serverResponses', serverResponses); + let syncs = []; + + if (!syncOptions.iframeEnabled && !syncOptions.pixelEnabled) { + return syncs; + } + + serverResponses.forEach(resp => { + const userSync = utils.deepAccess(resp, 'body.ext.usersync'); + if (userSync) { + let syncDetails = []; + Object.keys(userSync).forEach(key => { + const value = userSync[key]; + if (value.syncs && value.syncs.length) { + syncDetails = syncDetails.concat(value.syncs); + } + }); + syncDetails.forEach(syncDetails => { + syncs.push({ + type: syncDetails.type === 'iframe' ? 'iframe' : 'image', + url: syncDetails.url + }); + }); + + if (!syncOptions.iframeEnabled) { + syncs = syncs.filter(s => s.type !== 'iframe') + } + if (!syncOptions.pixelEnabled) { + syncs = syncs.filter(s => s.type !== 'image') + } + } + }); + return syncs; + }, + +}; +registerBidder(spec); diff --git a/modules/padsquadBidAdapter.md b/modules/padsquadBidAdapter.md new file mode 100644 index 00000000000..0a69db42ce3 --- /dev/null +++ b/modules/padsquadBidAdapter.md @@ -0,0 +1,33 @@ +# Overview + +``` +Module Name: Padsquad Bid Adapter +Module Type: Bidder Adapter +Maintainer: yeeldpadsquad@gmail.com +``` + +# Description + +Connects to Padsquad exchange for bids. + +Padsquad bid adapter supports Banner ads. + +# Test Parameters +``` +var adUnits = [ + { + code: 'banner-ad-div', + mediaTypes: { + banner: { + sizes: [[300, 250], [300,600]] + } + }, + bids: [{ + bidder: 'padsquad', + params: { + unitId: 'test' + } + }] + } +]; +``` diff --git a/modules/piximediaBidAdapter.js b/modules/piximediaBidAdapter.js index b97c91e5b5b..7fca4e32996 100644 --- a/modules/piximediaBidAdapter.js +++ b/modules/piximediaBidAdapter.js @@ -20,6 +20,7 @@ export const spec = { timestamp: utils.timestamp(), pver: '1.0', pbparams: JSON.stringify(bidRequest.params), + pbsizes: JSON.stringify(parseSized), pbwidth: arrSize[0], pbheight: arrSize[1], pbbidid: bidRequest.bidId, diff --git a/modules/playgroundxyzBidAdapter.js b/modules/playgroundxyzBidAdapter.js index 91f6b701b72..26483f1277a 100644 --- a/modules/playgroundxyzBidAdapter.js +++ b/modules/playgroundxyzBidAdapter.js @@ -102,18 +102,10 @@ export const spec = { }, getUserSyncs: function (syncOptions) { - if (syncOptions.iframeEnabled) { - return [{ - type: 'iframe', - url: '//acdn.adnxs.com/ib/static/usersync/v3/async_usersync.html' - }]; - } - if (syncOptions.pixelEnabled) { - return [{ - type: 'image', - url: '//ib.adnxs.com/getuidnb?https://ads.playground.xyz/usersync?partner=appnexus&uid=$UID' - }]; - } + return [{ + type: 'image', + url: '//ib.adnxs.com/getuidnb?https://ads.playground.xyz/usersync?partner=appnexus&uid=$UID' + }]; } } diff --git a/modules/prebidServerBidAdapter/index.js b/modules/prebidServerBidAdapter/index.js index 586d78ed2ca..7ffaf9988dd 100644 --- a/modules/prebidServerBidAdapter/index.js +++ b/modules/prebidServerBidAdapter/index.js @@ -5,7 +5,8 @@ import { ajax } from '../../src/ajax'; import { STATUS, S2S, EVENTS } from '../../src/constants'; import adapterManager from '../../src/adapterManager'; import { config } from '../../src/config'; -import { VIDEO } from '../../src/mediaTypes'; +import { VIDEO, NATIVE } from '../../src/mediaTypes'; +import { processNativeAdUnitParams } from '../../src/native'; import { isValid } from '../../src/adapters/bidderFactory'; import events from '../../src/events'; import includes from 'core-js/library/fn/array/includes'; @@ -232,20 +233,24 @@ function doClientSideSyncs(bidders) { }); } -function _getDigiTrustQueryParams() { - function getDigiTrustId() { - let digiTrustUser = window.DigiTrust && (config.getConfig('digiTrustId') || window.DigiTrust.getUser({member: 'T9QSFKPDN9'})); +function _getDigiTrustQueryParams(bidRequest = {}) { + function getDigiTrustId(bidRequest) { + const bidRequestDigitrust = utils.deepAccess(bidRequest, 'bids.0.userId.digitrustid.data'); + if (bidRequestDigitrust) { + return bidRequestDigitrust; + } + + const digiTrustUser = config.getConfig('digiTrustId'); return (digiTrustUser && digiTrustUser.success && digiTrustUser.identity) || null; } - let digiTrustId = getDigiTrustId(); + let digiTrustId = getDigiTrustId(bidRequest); // Verify there is an ID and this user has not opted out if (!digiTrustId || (digiTrustId.privacy && digiTrustId.privacy.optout)) { return null; } return { id: digiTrustId.id, - keyv: digiTrustId.keyv, - pref: 0 + keyv: digiTrustId.keyv }; } @@ -334,7 +339,7 @@ const LEGACY_PROTOCOL = { _appendSiteAppDevice(request); - let digiTrust = _getDigiTrustQueryParams(); + let digiTrust = _getDigiTrustQueryParams(bidRequests && bidRequests[0]); if (digiTrust) { request.digiTrust = digiTrust; } @@ -342,7 +347,7 @@ const LEGACY_PROTOCOL = { return request; }, - interpretResponse(result, bidderRequests, requestedBidders) { + interpretResponse(result, bidderRequests) { const bids = []; if (result.status === 'OK' || result.status === 'no_cookie') { if (result.bidder_status) { @@ -427,11 +432,57 @@ const LEGACY_PROTOCOL = { } }; +// https://iabtechlab.com/wp-content/uploads/2016/07/OpenRTB-Native-Ads-Specification-Final-1.2.pdf#page=40 +let nativeDataIdMap = { + sponsoredBy: 1, // sponsored + body: 2, // desc + rating: 3, + likes: 4, + downloads: 5, + price: 6, + salePrice: 7, + phone: 8, + address: 9, + body2: 10, // desc2 + cta: 12 // ctatext +}; +let nativeDataNames = Object.keys(nativeDataIdMap); + +let nativeImgIdMap = { + icon: 1, + image: 3 +}; + +let nativeEventTrackerEventMap = { + impression: 1, + 'viewable-mrc50': 2, + 'viewable-mrc100': 3, + 'viewable-video50': 4, +}; + +let nativeEventTrackerMethodMap = { + img: 1, + js: 2 +}; + +// enable reverse lookup +[ + nativeDataIdMap, + nativeImgIdMap, + nativeEventTrackerEventMap, + nativeEventTrackerMethodMap +].forEach(map => { + Object.keys(map).forEach(key => { + map[map[key]] = key; + }); +}); + /* * Protocol spec for OpenRTB endpoint * e.g., https:///v1/openrtb2/auction */ let bidIdMap = {}; +let nativeAssetCache = {}; // store processed native params to preserve const OPEN_RTB_PROTOCOL = { buildRequest(s2sBidRequest, bidRequests, adUnits) { let imps = []; @@ -439,6 +490,74 @@ const OPEN_RTB_PROTOCOL = { // transform ad unit into array of OpenRTB impression objects adUnits.forEach(adUnit => { + const nativeParams = processNativeAdUnitParams(utils.deepAccess(adUnit, 'mediaTypes.native')); + let nativeAssets; + if (nativeParams) { + try { + nativeAssets = nativeAssetCache[adUnit.code] = Object.keys(nativeParams).reduce((assets, type) => { + let params = nativeParams[type]; + + function newAsset(obj) { + return Object.assign({ + required: params.required ? 1 : 0 + }, obj ? utils.cleanObj(obj) : {}); + } + + switch (type) { + case 'image': + case 'icon': + let imgTypeId = nativeImgIdMap[type]; + let asset = utils.cleanObj({ + type: imgTypeId, + w: utils.deepAccess(params, 'sizes.0'), + h: utils.deepAccess(params, 'sizes.1'), + wmin: utils.deepAccess(params, 'aspect_ratios.0.min_width') + }); + if (!(asset.w || asset.wmin)) { + throw 'invalid img sizes (must provided sizes or aspect_ratios)'; + } + if (Array.isArray(params.aspect_ratios)) { + // pass aspect_ratios as ext data I guess? + asset.ext = { + aspectratios: params.aspect_ratios.map( + ratio => `${ratio.ratio_width}:${ratio.ratio_height}` + ) + } + } + assets.push(newAsset({ + img: asset + })); + break; + case 'title': + if (!params.len) { + throw 'invalid title.len'; + } + assets.push(newAsset({ + title: { + len: params.len + } + })); + break; + default: + let dataAssetTypeId = nativeDataIdMap[type]; + if (dataAssetTypeId) { + assets.push(newAsset({ + data: { + type: dataAssetTypeId, + len: params.len + } + })) + } + } + return assets; + }, []); + } catch (e) { + utils.logError('error creating native request: ' + String(e)) + } + } + const videoParams = utils.deepAccess(adUnit, 'mediaTypes.video'); + const bannerParams = utils.deepAccess(adUnit, 'mediaTypes.banner'); + adUnit.bids.forEach(bid => { // OpenRTB response contains the adunit code and bidder name. These are // combined to create a unique key for each bid since an id isn't returned @@ -450,14 +569,13 @@ const OPEN_RTB_PROTOCOL = { } }); - let banner; + let mediaTypes = {}; // default to banner if mediaTypes isn't defined - if (utils.isEmpty(adUnit.mediaTypes)) { + if (!(nativeParams || videoParams || bannerParams)) { const sizeObjects = adUnit.sizes.map(size => ({ w: size[0], h: size[1] })); - banner = {format: sizeObjects}; + mediaTypes['banner'] = {format: sizeObjects}; } - const bannerParams = utils.deepAccess(adUnit, 'mediaTypes.banner'); if (bannerParams && bannerParams.sizes) { const sizes = utils.parseSizesInput(bannerParams.sizes); @@ -469,13 +587,37 @@ const OPEN_RTB_PROTOCOL = { return { w, h }; }); - banner = {format}; + mediaTypes['banner'] = {format}; } - let video; - const videoParams = utils.deepAccess(adUnit, 'mediaTypes.video'); if (!utils.isEmpty(videoParams)) { - video = videoParams; + if (videoParams.context === 'outstream' && !adUnit.renderer) { + // Don't push oustream w/o renderer to request object. + utils.logError('Outstream bid without renderer cannot be sent to Prebid Server.'); + } else { + mediaTypes['video'] = videoParams; + } + } + + if (nativeAssets) { + try { + mediaTypes['native'] = { + request: JSON.stringify({ + // TODO: determine best way to pass these and if we allow defaults + context: 1, + plcmttype: 1, + eventtrackers: [ + {event: 1, methods: [1]} + ], + // TODO: figure out how to support privacy field + // privacy: int + assets: nativeAssets + }), + ver: '1.2' + } + } catch (e) { + utils.logError('error creating native request: ' + String(e)) + } } // get bidder params in form { : {...params} } @@ -490,12 +632,17 @@ const OPEN_RTB_PROTOCOL = { const imp = { id: adUnit.code, ext, secure: _s2sConfig.secure }; - if (banner) { imp.banner = banner; } - if (video) { imp.video = video; } + Object.assign(imp, mediaTypes); - imps.push(imp); + if (imp.banner || imp.video || imp.native) { + imps.push(imp); + } }); + if (!imps.length) { + utils.logError('Request to Prebid Server rejected due to invalid media type(s) in adUnit.') + return; + } const request = { id: s2sBidRequest.tid, source: {tid: s2sBidRequest.tid}, @@ -519,28 +666,61 @@ const OPEN_RTB_PROTOCOL = { request.ext.prebid = Object.assign(request.ext.prebid, _s2sConfig.extPrebid); } + /** + * @type {(string[]|string|undefined)} - OpenRTB property 'cur', currencies available for bids + */ + const adServerCur = config.getConfig('currency.adServerCurrency'); + if (adServerCur && typeof adServerCur === 'string') { + // if the value is a string, wrap it with an array + request.cur = [adServerCur]; + } else if (Array.isArray(adServerCur) && adServerCur.length) { + // if it's an array, get the first element + request.cur = [adServerCur[0]]; + } + _appendSiteAppDevice(request); - const digiTrust = _getDigiTrustQueryParams(); + const digiTrust = _getDigiTrustQueryParams(bidRequests && bidRequests[0]); if (digiTrust) { - request.user = { ext: { digitrust: digiTrust } }; + utils.deepSetValue(request, 'user.ext.digitrust', digiTrust); + } + + // pass schain object if it is present + const schain = utils.deepAccess(bidRequests, '0.bids.0.schain'); + if (schain) { + request.source.ext = { + schain: schain + }; } if (!utils.isEmpty(aliases)) { request.ext.prebid.aliases = aliases; } - if (bidRequests && bidRequests[0].userId && typeof bidRequests[0].userId === 'object') { - if (!request.user) { - request.user = {}; - } - if (!request.user.ext) { - request.user.ext = {} + const bidUserId = utils.deepAccess(bidRequests, '0.bids.0.userId'); + if (bidUserId && typeof bidUserId === 'object' && (bidUserId.tdid || bidUserId.pubcid)) { + utils.deepSetValue(request, 'user.ext.eids', []); + + if (bidUserId.tdid) { + request.user.ext.eids.push({ + source: 'adserver.org', + uids: [{ + id: bidUserId.tdid, + ext: { + rtiPartner: 'TDID' + } + }] + }); } - if (!request.user.ext.tpid) { - request.user.ext.tpid = {} + + if (bidUserId.pubcid) { + request.user.ext.eids.push({ + source: 'pubcommon', + uids: [{ + id: bidUserId.pubcid, + }] + }); } - Object.assign(request.user.ext.tpid, bidRequests[0].userId); } if (bidRequests && bidRequests[0].gdprConsent) { @@ -560,22 +740,17 @@ const OPEN_RTB_PROTOCOL = { request.regs = { ext: { gdpr: gdprApplies } }; } - let consentString = bidRequests[0].gdprConsent.consentString; - if (request.user) { - if (request.user.ext) { - request.user.ext.consent = consentString; - } else { - request.user.ext = { consent: consentString }; - } - } else { - request.user = { ext: { consent: consentString } }; - } + utils.deepSetValue(request, 'user.ext.consent', bidRequests[0].gdprConsent.consentString); + } + + if (getConfig('coppa') === true) { + utils.deepSetValue(request, 'regs.coppa', 1); } return request; }, - interpretResponse(response, bidderRequests, requestedBidders) { + interpretResponse(response, bidderRequests) { const bids = []; if (response.seatbid) { @@ -614,6 +789,9 @@ const OPEN_RTB_PROTOCOL = { if (utils.deepAccess(bid, 'ext.prebid.type') === VIDEO) { bidObject.mediaType = VIDEO; + let sizes = bidRequest.sizes && bidRequest.sizes[0]; + bidObject.playerHeight = sizes[0]; + bidObject.playerWidth = sizes[1]; // try to get cache values from 'response.ext.prebid.cache' // else try 'bid.ext.prebid.targeting' as fallback @@ -628,6 +806,60 @@ const OPEN_RTB_PROTOCOL = { if (bid.adm) { bidObject.vastXml = bid.adm; } if (!bidObject.vastUrl && bid.nurl) { bidObject.vastUrl = bid.nurl; } + } else if (utils.deepAccess(bid, 'ext.prebid.type') === NATIVE) { + bidObject.mediaType = NATIVE; + let adm; + if (typeof bid.adm === 'string') { + adm = bidObject.adm = JSON.parse(bid.adm); + } else { + adm = bidObject.adm = bid.adm; + } + + let trackers = { + [nativeEventTrackerMethodMap.img]: adm.imptrackers || [], + [nativeEventTrackerMethodMap.js]: adm.jstracker ? [adm.jstracker] : [] + }; + if (adm.eventtrackers) { + adm.eventtrackers.forEach(tracker => { + switch (tracker.method) { + case nativeEventTrackerMethodMap.img: + trackers[nativeEventTrackerMethodMap.img].push(tracker.url); + break; + case nativeEventTrackerMethodMap.js: + trackers[nativeEventTrackerMethodMap.js].push(tracker.url); + break; + } + }); + } + + if (utils.isPlainObject(adm) && Array.isArray(adm.assets)) { + let origAssets = nativeAssetCache[bidRequest.adUnitCode]; + bidObject.native = utils.cleanObj(adm.assets.reduce((native, asset) => { + let origAsset = origAssets[asset.id]; + if (utils.isPlainObject(asset.img)) { + native[origAsset.img.type ? nativeImgIdMap[origAsset.img.type] : 'image'] = utils.pick( + asset.img, + ['url', 'w as width', 'h as height'] + ); + } else if (utils.isPlainObject(asset.title)) { + native['title'] = asset.title.text + } else if (utils.isPlainObject(asset.data)) { + nativeDataNames.forEach(dataType => { + if (nativeDataIdMap[dataType] === origAsset.data.type) { + native[dataType] = asset.data.value; + } + }); + } + return native; + }, utils.cleanObj({ + clickUrl: adm.link, + clickTrackers: utils.deepAccess(adm, 'link.clicktrackers'), + impressionTrackers: trackers[nativeEventTrackerMethodMap.img], + javascriptTrackers: trackers[nativeEventTrackerMethodMap.js] + }))); + } else { + utils.logError('prebid server native response contained no assets'); + } } else { // banner if (bid.adm && bid.nurl) { bidObject.ad = bid.adm; @@ -695,10 +927,13 @@ export function PrebidServer() { const adUnits = utils.deepClone(s2sBidRequest.ad_units); // at this point ad units should have a size array either directly or mapped so filter for that - const adUnitsWithSizes = adUnits.filter(unit => unit.sizes && unit.sizes.length); + const validAdUnits = adUnits.filter(unit => + (unit.sizes && unit.sizes.length) || + (unit.mediaTypes && unit.mediaTypes.native) + ); // in case config.bidders contains invalid bidders, we only process those we sent requests for - const requestedBidders = adUnitsWithSizes + const requestedBidders = validAdUnits .map(adUnit => adUnit.bids.map(bid => bid.bidder).filter(utils.uniques)) .reduce(utils.flatten) .filter(utils.uniques); @@ -708,18 +943,19 @@ export function PrebidServer() { queueSync(_s2sConfig.bidders, consent); } - const request = protocolAdapter().buildRequest(s2sBidRequest, bidRequests, adUnitsWithSizes); - const requestJson = JSON.stringify(request); - - ajax( - _s2sConfig.endpoint, - { - success: response => handleResponse(response, requestedBidders, bidRequests, addBidResponse, done), - error: done - }, - requestJson, - { contentType: 'text/plain', withCredentials: true } - ); + const request = protocolAdapter().buildRequest(s2sBidRequest, bidRequests, validAdUnits); + const requestJson = request && JSON.stringify(request); + if (request && requestJson) { + ajax( + _s2sConfig.endpoint, + { + success: response => handleResponse(response, requestedBidders, bidRequests, addBidResponse, done), + error: done + }, + requestJson, + { contentType: 'text/plain', withCredentials: true } + ); + } }; /* Notify Prebid of bid responses so bids can get in the auction */ diff --git a/modules/prebidmanagerAnalyticsAdapter.js b/modules/prebidmanagerAnalyticsAdapter.js new file mode 100644 index 00000000000..f3474abe95a --- /dev/null +++ b/modules/prebidmanagerAnalyticsAdapter.js @@ -0,0 +1,191 @@ +import {ajaxBuilder} from '../src/ajax'; +import adapter from '../src/AnalyticsAdapter'; +import adapterManager from '../src/adapterManager'; + +/** + * prebidmanagerAnalyticsAdapter.js - analytics adapter for prebidmanager + */ +const DEFAULT_EVENT_URL = 'https://endpoint.prebidmanager.com/endpoint' +const analyticsType = 'endpoint'; +const analyticsName = 'Prebid Manager Analytics: '; + +var utils = require('../src/utils'); +var CONSTANTS = require('../src/constants.json'); +let ajax = ajaxBuilder(0); + +var _VERSION = 1; +var initOptions = null; +var _pageViewId = utils.generateUUID(); +var _startAuction = 0; +var _bidRequestTimeout = 0; +let flushInterval; +var pmAnalyticsEnabled = false; + +var w = window; +var d = document; +var e = d.documentElement; +var g = d.getElementsByTagName('body')[0]; +var x = w.innerWidth || e.clientWidth || g.clientWidth; +var y = w.innerHeight || e.clientHeight || g.clientHeight; + +var _pageView = { + eventType: 'pageView', + userAgent: window.navigator.userAgent, + timestamp: Date.now(), + timezoneOffset: new Date().getTimezoneOffset(), + language: window.navigator.language, + vendor: window.navigator.vendor, + screenWidth: x, + screenHeight: y +}; + +var _eventQueue = [ + _pageView +]; + +let prebidmanagerAnalytics = Object.assign(adapter({url: DEFAULT_EVENT_URL, analyticsType}), { + track({eventType, args}) { + handleEvent(eventType, args); + } +}); + +prebidmanagerAnalytics.originEnableAnalytics = prebidmanagerAnalytics.enableAnalytics; +prebidmanagerAnalytics.enableAnalytics = function (config) { + initOptions = config.options || {}; + initOptions.url = initOptions.url || DEFAULT_EVENT_URL; + pmAnalyticsEnabled = true; + prebidmanagerAnalytics.originEnableAnalytics(config); + flushInterval = setInterval(flush, 1000); +}; + +prebidmanagerAnalytics.originDisableAnalytics = prebidmanagerAnalytics.disableAnalytics; +prebidmanagerAnalytics.disableAnalytics = function() { + if (!pmAnalyticsEnabled) { + return; + } + flush(); + clearInterval(flushInterval); + prebidmanagerAnalytics.originDisableAnalytics(); +}; + +function flush() { + if (!pmAnalyticsEnabled) { + return; + } + + if (_eventQueue.length > 1) { + var data = { + pageViewId: _pageViewId, + ver: _VERSION, + bundleId: initOptions.bundleId, + events: _eventQueue + }; + + ajax( + initOptions.url, + () => utils.logInfo(`${analyticsName} sent events batch`), + _VERSION + ':' + JSON.stringify(data), + { + contentType: 'text/plain', + method: 'POST', + withCredentials: true + } + ); + _eventQueue = [ + _pageView + ]; + } +} + +function handleEvent(eventType, eventArgs) { + eventArgs = eventArgs ? JSON.parse(JSON.stringify(eventArgs)) : {}; + var pmEvent = {}; + + switch (eventType) { + case CONSTANTS.EVENTS.AUCTION_INIT: { + pmEvent = eventArgs; + _startAuction = pmEvent.timestamp; + _bidRequestTimeout = pmEvent.timeout; + break; + } + case CONSTANTS.EVENTS.AUCTION_END: { + pmEvent = eventArgs; + pmEvent.start = _startAuction; + pmEvent.end = Date.now(); + break; + } + case CONSTANTS.EVENTS.BID_ADJUSTMENT: { + pmEvent.bidders = eventArgs; + break; + } + case CONSTANTS.EVENTS.BID_TIMEOUT: { + pmEvent.bidders = eventArgs; + pmEvent.duration = _bidRequestTimeout; + break; + } + case CONSTANTS.EVENTS.BID_REQUESTED: { + pmEvent = eventArgs; + break; + } + case CONSTANTS.EVENTS.BID_RESPONSE: { + pmEvent = eventArgs; + delete pmEvent.ad; + break; + } + case CONSTANTS.EVENTS.BID_WON: { + pmEvent = eventArgs; + delete pmEvent.ad; + delete pmEvent.adUrl; + break; + } + case CONSTANTS.EVENTS.BIDDER_DONE: { + pmEvent = eventArgs; + break; + } + case CONSTANTS.EVENTS.SET_TARGETING: { + pmEvent.targetings = eventArgs; + break; + } + case CONSTANTS.EVENTS.REQUEST_BIDS: { + pmEvent = eventArgs; + break; + } + case CONSTANTS.EVENTS.ADD_AD_UNITS: { + pmEvent = eventArgs; + break; + } + case CONSTANTS.EVENTS.AD_RENDER_FAILED: { + pmEvent = eventArgs; + break; + } + default: + return; + } + + pmEvent.eventType = eventType; + pmEvent.timestamp = pmEvent.timestamp || Date.now(); + + sendEvent(pmEvent); +} + +function sendEvent(event) { + _eventQueue.push(event); + utils.logInfo(`${analyticsName}Event ${event.eventType}:`, event); + + if (event.eventType === CONSTANTS.EVENTS.AUCTION_END) { + flush(); + } +} + +adapterManager.registerAnalyticsAdapter({ + adapter: prebidmanagerAnalytics, + code: 'prebidmanager' +}); + +prebidmanagerAnalytics.getOptions = function () { + return initOptions; +}; + +prebidmanagerAnalytics.flush = flush; + +export default prebidmanagerAnalytics; diff --git a/modules/prebidmanagerAnalyticsAdapter.md b/modules/prebidmanagerAnalyticsAdapter.md new file mode 100644 index 00000000000..030e79b406f --- /dev/null +++ b/modules/prebidmanagerAnalyticsAdapter.md @@ -0,0 +1,9 @@ +# Overview + +Module Name: Prebid Manager Analytics Adapter +Module Type: Analytics Adapter +Maintainer: admin@prebidmanager.com + +# Description + +Analytics adapter for Prebid Manager. Contact admin@prebidmanager.com for information. diff --git a/modules/projectLimeLightBidAdapter.js b/modules/projectLimeLightBidAdapter.js new file mode 100644 index 00000000000..b0de181315e --- /dev/null +++ b/modules/projectLimeLightBidAdapter.js @@ -0,0 +1,125 @@ +import { registerBidder } from '../src/adapters/bidderFactory'; +import { BANNER, VIDEO } from '../src/mediaTypes'; +import {ajax} from '../src/ajax'; +import * as utils from '../src/utils'; + +const BIDDER_CODE = 'project-limelight'; +const URL = '//ads.project-limelight.com/hb'; + +/** + * Determines whether or not the given bid response is valid. + * + * @param {object} bid The bid to validate. + * @return boolean True if this is a valid bid, and false otherwise. + */ +function isBidResponseValid(bid) { + if (!bid.requestId || !bid.cpm || !bid.creativeId || !bid.ttl || !bid.currency) { + return false; + } + switch (bid.mediaType) { + case BANNER: + return Boolean(bid.width && bid.height && bid.ad); + case VIDEO: + return Boolean(bid.vastXml || bid.vastUrl); + } + return false; +} + +function extractBidSizes(bid) { + const bidSizes = []; + + bid.sizes.forEach(size => { + bidSizes.push({ + width: size[0], + height: size[1] + }); + }); + + return bidSizes; +} + +export const spec = { + code: BIDDER_CODE, + supportedMediaTypes: [BANNER, VIDEO], + + /** + * Determines whether or not the given bid request is valid. + * + * @param {object} bid The bid to validate. + * @return boolean True if this is a valid bid, and false otherwise. + */ + isBidRequestValid: (bid) => { + return Boolean(bid.bidId && bid.params); + }, + + /** + * Make a server request from the list of BidRequests. + * + * @return ServerRequest Info describing the request to the server. + */ + buildRequests: (validBidRequests, bidderRequest) => { + let winTop; + try { + winTop = window.top; + winTop.location.toString(); + } catch (e) { + utils.logMessage(e); + winTop = window; + }; + const placements = []; + const request = { + 'secure': (location.protocol === 'https:'), + 'deviceWidth': winTop.screen.width, + 'deviceHeight': winTop.screen.height, + 'adUnits': placements + }; + for (let i = 0; i < validBidRequests.length; i++) { + const bid = validBidRequests[i]; + const params = bid.params; + placements.push({ + id: params.adUnitId, + bidId: bid.bidId, + transactionId: bid.transactionId, + sizes: extractBidSizes(bid), + type: params.adUnitType.toUpperCase() + }); + } + return { + method: 'POST', + url: URL, + data: request + }; + }, + + onBidWon: (bid) => { + const cpm = bid.pbMg; + if (bid.nurl !== '') { + bid.nurl = bid.nurl.replace( + /\$\{AUCTION_PRICE\}/, + cpm + ); + ajax(bid.nurl, null); + }; + }, + + /** + * Unpack the response from the server into a list of bids. + * + * @param {*} serverResponse A successful response from the server. + * @return {Bid[]} An array of bids which were nested inside the server. + */ + interpretResponse: (bidResponses) => { + const res = []; + const bidResponsesBody = bidResponses.body; + const len = bidResponsesBody.length; + for (let i = 0; i < len; i++) { + const bid = bidResponsesBody[i]; + if (isBidResponseValid(bid)) { + res.push(bid); + } + } + return res; + }, +}; + +registerBidder(spec); diff --git a/modules/projectLimeLightBidAdapter.md b/modules/projectLimeLightBidAdapter.md new file mode 100644 index 00000000000..71621983b89 --- /dev/null +++ b/modules/projectLimeLightBidAdapter.md @@ -0,0 +1,55 @@ +# Overview + +``` +Module Name: Project LimeLight SSP Adapter +Module Type: Bidder Adapter +Maintainer: engineering@project-limelight.com +``` + +# Description + +Module that connects to Project Limelight SSP demand sources + +# Test Parameters for banner +``` + var adUnits = [{ + code: 'placementCode', + sizes: [[300, 250]], + bids: [{ + bidder: 'project-limelight', + params: { + adUnitId: 0, + adUnitType: 'banner' + } + }] + } + ]; +``` + +# Test Parameters for video +``` +var videoAdUnit = [{ + code: 'video1', + sizes: [[300, 250]], + bids: [{ + bidder: 'project-limelight', + params: { + adUnitId: 0, + adUnitType: 'video' + } + }] + }]; +``` + +# Configuration + +The Project Limelight Bid Adapter expects Prebid Cache(for video) to be enabled so that we can store and retrieve a single vastXml. + +``` +pbjs.setConfig({ + usePrebidCache: true, + cache: { + url: 'https://prebid.adnxs.com/pbc/v1/cache' + } +}); +``` diff --git a/modules/pubCommonId.js b/modules/pubCommonId.js index 3175dc22613..5b92592f07a 100644 --- a/modules/pubCommonId.js +++ b/modules/pubCommonId.js @@ -6,15 +6,126 @@ import * as utils from '../src/utils' import { config } from '../src/config'; -const COOKIE_NAME = '_pubcid'; -const DEFAULT_EXPIRES = 2628000; // 5-year worth of minutes +const ID_NAME = '_pubcid'; +const OPTOUT_NAME = '_pubcid_optout'; +const DEFAULT_EXPIRES = 525600; // 1-year worth of minutes const PUB_COMMON = 'PublisherCommonId'; +const EXP_SUFFIX = '_exp'; +const COOKIE = 'cookie'; +const LOCAL_STORAGE = 'html5'; -var pubcidEnabled = true; -var interval = DEFAULT_EXPIRES; +let pubcidConfig = { + enabled: true, + interval: DEFAULT_EXPIRES, + typeEnabled: LOCAL_STORAGE, + readOnly: false +}; -export function isPubcidEnabled() { return pubcidEnabled; } -export function getExpInterval() { return interval; } +/** + * Set an item in the storage with expiry time. + * @param {string} key Key of the item to be stored + * @param {string} val Value of the item to be stored + * @param {number} expires Expiry time in minutes + */ + +export function setStorageItem(key, val, expires) { + try { + if (expires !== undefined && expires != null) { + const expStr = (new Date(Date.now() + (expires * 60 * 1000))).toUTCString(); + localStorage.setItem(key + EXP_SUFFIX, expStr); + } + + localStorage.setItem(key, val); + } catch (e) { + utils.logMessage(e); + } +} + +/** + * Retrieve an item from storage if it exists and hasn't expired. + * @param {string} key Key of the item. + * @returns {string|null} Value of the item. + */ +export function getStorageItem(key) { + let val = null; + + try { + const expVal = localStorage.getItem(key + EXP_SUFFIX); + + if (!expVal) { + // If there is no expiry time, then just return the item + val = localStorage.getItem(key); + } else { + // Only return the item if it hasn't expired yet. + // Otherwise delete the item. + const expDate = new Date(expVal); + const isValid = (expDate.getTime() - Date.now()) > 0; + if (isValid) { + val = localStorage.getItem(key); + } else { + removeStorageItem(key); + } + } + } catch (e) { + utils.logMessage(e); + } + + return val; +} + +/** + * Remove an item from storage + * @param {string} key Key of the item to be removed + */ +export function removeStorageItem(key) { + try { + localStorage.removeItem(key + EXP_SUFFIX); + localStorage.removeItem(key); + } catch (e) { + utils.logMessage(e); + } +} + +/** + * Read a value either from cookie or local storage + * @param {string} name Name of the item + * @returns {string|null} a string if item exists + */ +function readValue(name) { + let value; + if (pubcidConfig.typeEnabled === COOKIE) { + value = getCookie(name); + } else if (pubcidConfig.typeEnabled === LOCAL_STORAGE) { + value = getStorageItem(name); + if (!value) { + value = getCookie(name); + } + } + + if (value === 'undefined' || value === 'null') { return null; } + + return value; +} + +/** + * Write a value to either cookies or local storage + * @param {string} name Name of the item + * @param {string} value Value to be stored + * @param {number} expInterval Expiry time in minutes + */ +function writeValue(name, value, expInterval) { + if (name && value) { + if (pubcidConfig.typeEnabled === COOKIE) { + setCookie(name, value, expInterval); + } else if (pubcidConfig.typeEnabled === LOCAL_STORAGE) { + setStorageItem(name, value, expInterval); + } + } +} + +export function isPubcidEnabled() { return pubcidConfig.enabled; } +export function getExpInterval() { return pubcidConfig.interval; } +export function getPubcidConfig() { return pubcidConfig; } /** * Decorate ad units with pubcid. This hook function is called before the @@ -29,7 +140,7 @@ export function requestBidHook(next, config) { let pubcid = null; // Pass control to the next function if not enabled - if (!pubcidEnabled) { + if (!pubcidConfig.enabled || !pubcidConfig.typeEnabled) { return next.call(this, config); } @@ -38,11 +149,22 @@ export function requestBidHook(next, config) { pubcid = window[PUB_COMMON].getId(); utils.logMessage(PUB_COMMON + ': pubcid = ' + pubcid); } else { - // Otherwise get the existing cookie or create a new id - pubcid = getCookie(COOKIE_NAME) || utils.generateUUID(); + // Otherwise get the existing cookie + pubcid = readValue(ID_NAME); + + if (!pubcidConfig.readOnly) { + if (!pubcid) { + pubcid = utils.generateUUID(); + // Update the cookie/storage with the latest expiration date + writeValue(ID_NAME, pubcid, pubcidConfig.interval); + // Only return pubcid if it is saved successfully + pubcid = readValue(ID_NAME); + } else { + // Update the cookie/storage with the latest expiration date + writeValue(ID_NAME, pubcid, pubcidConfig.interval); + } + } - // Update the cookie with the latest expiration date - setCookie(COOKIE_NAME, pubcid, interval); utils.logMessage('pbjs: pubcid = ' + pubcid); } @@ -68,21 +190,49 @@ export function setCookie(name, value, expires) { // Helper to read a cookie export function getCookie(name) { - let m = window.document.cookie.match('(^|;)\\s*' + name + '\\s*=\\s*([^;]*)\\s*(;|$)'); - return m ? decodeURIComponent(m[2]) : null; + if (name && window.document.cookie) { + let m = window.document.cookie.match('(^|;)\\s*' + name + '\\s*=\\s*([^;]*)\\s*(;|$)'); + return m ? decodeURIComponent(m[2]) : null; + } + return null; } /** * Configuration function * @param {boolean} enable Enable or disable pubcid. By default the module is enabled. * @param {number} expInterval Expiration interval of the cookie in minutes. + * @param {string} type Type of storage to use + * @param {boolean} readOnly Read but not update id */ -export function setConfig({ enable = true, expInterval = DEFAULT_EXPIRES } = {}) { - pubcidEnabled = enable; - interval = parseInt(expInterval, 10); - if (isNaN(interval)) { - interval = DEFAULT_EXPIRES; +export function setConfig({ enable = true, expInterval = DEFAULT_EXPIRES, type = 'html5,cookie', readOnly = false } = {}) { + pubcidConfig.enabled = enable; + pubcidConfig.interval = parseInt(expInterval, 10); + if (isNaN(pubcidConfig.interval)) { + pubcidConfig.interval = DEFAULT_EXPIRES; + } + + pubcidConfig.readOnly = readOnly; + + // Default is to use local storage. Fall back to + // cookie only if local storage is not supported. + + pubcidConfig.typeEnabled = null; + + const typeArray = type.split(','); + for (let i = 0; i < typeArray.length; ++i) { + const name = typeArray[i].trim(); + if (name === COOKIE) { + if (utils.cookiesAreEnabled()) { + pubcidConfig.typeEnabled = COOKIE; + break; + } + } else if (name === LOCAL_STORAGE) { + if (utils.hasLocalStorage()) { + pubcidConfig.typeEnabled = LOCAL_STORAGE; + break; + } + } } } @@ -92,10 +242,8 @@ export function setConfig({ enable = true, expInterval = DEFAULT_EXPIRES } = {}) export function initPubcid() { config.getConfig('pubcid', config => setConfig(config.pubcid)); - if (utils.cookiesAreEnabled()) { - if (!getCookie('_pubcid_optout')) { - $$PREBID_GLOBAL$$.requestBids.before(requestBidHook); - } + if (!readValue(OPTOUT_NAME)) { + $$PREBID_GLOBAL$$.requestBids.before(requestBidHook); } } diff --git a/modules/pubCommonId.md b/modules/pubCommonId.md new file mode 100644 index 00000000000..79531bfe87c --- /dev/null +++ b/modules/pubCommonId.md @@ -0,0 +1,37 @@ +## Publisher Common ID Example Configuration + +When the module is included, it's automatically enabled and saves an id to both cookie and local storage with an expiration time of 1 year. + +Example of disabling publisher common id. + +``` +pbjs.setConfig( + pubcid: { + enable: false + } +); +``` + +Example of setting expiration interval to 30 days. The interval is expressed in minutes. + +``` +pbjs.setConfig( + pubcid: { + expInterval: 43200 + } +); +``` + +Example of using local storage only and setting expiration interval to 30 days. + +``` +pbjs.setConfig( + pubcid: { + expInterval: 43200, + type: 'html5' + } +); +``` + + + diff --git a/modules/pubmaticBidAdapter.js b/modules/pubmaticBidAdapter.js index 6891285fcc2..facecdaa578 100644 --- a/modules/pubmaticBidAdapter.js +++ b/modules/pubmaticBidAdapter.js @@ -5,8 +5,8 @@ import {config} from '../src/config'; const BIDDER_CODE = 'pubmatic'; const LOG_WARN_PREFIX = 'PubMatic: '; -const ENDPOINT = '//hbopenbid.pubmatic.com/translator?source=prebid-client'; -const USYNCURL = '//ads.pubmatic.com/AdServer/js/showad.js#PIX&kdntuid=1&p='; +const ENDPOINT = 'https://hbopenbid.pubmatic.com/translator?source=prebid-client'; +const USYNCURL = 'https://ads.pubmatic.com/AdServer/js/showad.js#PIX&kdntuid=1&p='; const DEFAULT_CURRENCY = 'USD'; const AUCTION_TYPE = 1; const PUBMATIC_DIGITRUST_KEY = 'nFIn8aLzbd'; @@ -511,9 +511,9 @@ function _createImpressionObject(bid, conf) { impObj = { id: bid.bidId, - tagid: bid.params.adUnit, + tagid: bid.params.adUnit || undefined, bidfloor: _parseSlotParam('kadfloor', bid.params.kadfloor), - secure: window.location.protocol === 'https:' ? 1 : 0, + secure: 1, ext: { pmZoneId: _parseSlotParam('pmzoneid', bid.params.pmzoneid) }, @@ -601,13 +601,20 @@ function _handleDigitrustId(eids) { } } -function _handleTTDId(eids) { +function _handleTTDId(eids, validBidRequests) { + let ttdId = null; let adsrvrOrgId = config.getConfig('adsrvrOrgId'); - if (adsrvrOrgId && utils.isStr(adsrvrOrgId.TDID)) { + if (utils.isStr(utils.deepAccess(validBidRequests, '0.userId.tdid'))) { + ttdId = validBidRequests[0].userId.tdid; + } else if (adsrvrOrgId && utils.isStr(adsrvrOrgId.TDID)) { + ttdId = adsrvrOrgId.TDID; + } + + if (ttdId !== null) { eids.push({ 'source': 'adserver.org', 'uids': [{ - 'id': adsrvrOrgId.TDID, + 'id': ttdId, 'atype': 1, 'ext': { 'rtiPartner': 'TDID' @@ -617,10 +624,10 @@ function _handleTTDId(eids) { } } -function _handleEids(payload) { +function _handleEids(payload, validBidRequests) { let eids = []; _handleDigitrustId(eids); - _handleTTDId(eids); + _handleTTDId(eids, validBidRequests); if (eids.length > 0) { payload.user.eids = eids; } @@ -731,6 +738,38 @@ function _blockedIabCategoriesValidation(payload, blockedIabCategories) { } } +function _handleDealCustomTargetings(payload, dctrArr, validBidRequests) { + var dctr = ''; + var dctrLen; + // set dctr value in site.ext, if present in validBidRequests[0], else ignore + if (dctrArr.length > 0) { + if (validBidRequests[0].params.hasOwnProperty('dctr')) { + dctr = validBidRequests[0].params.dctr; + if (utils.isStr(dctr) && dctr.length > 0) { + var arr = dctr.split('|'); + dctr = ''; + arr.forEach(val => { + dctr += (val.length > 0) ? (val.trim() + '|') : ''; + }); + dctrLen = dctr.length; + if (dctr.substring(dctrLen, dctrLen - 1) === '|') { + dctr = dctr.substring(0, dctrLen - 1); + } + payload.site.ext = { + key_val: dctr.trim() + } + } else { + utils.logWarn(LOG_WARN_PREFIX + 'Ignoring param : dctr with value : ' + dctr + ', expects string-value, found empty or non-string value'); + } + if (dctrArr.length > 1) { + utils.logWarn(LOG_WARN_PREFIX + 'dctr value found in more than 1 adunits. Value from 1st adunit will be picked. Ignoring values from subsequent adunits'); + } + } else { + utils.logWarn(LOG_WARN_PREFIX + 'dctr value not found in 1st adunit, ignoring values from subsequent adunits'); + } + } +} + export const spec = { code: BIDDER_CODE, supportedMediaTypes: [BANNER, VIDEO, NATIVE], @@ -746,10 +785,6 @@ export const spec = { utils.logWarn(LOG_WARN_PREFIX + 'Error: publisherId is mandatory and cannot be numeric. Call to OpenBid will not be sent for ad unit: ' + JSON.stringify(bid)); return false; } - if (!utils.isStr(bid.params.adSlot)) { - utils.logWarn(LOG_WARN_PREFIX + 'Error: adSlotId is mandatory and cannot be numeric. Call to OpenBid will not be sent for ad unit: ' + JSON.stringify(bid)); - return false; - } // video ad validation if (bid.params.hasOwnProperty('video')) { if (!bid.params.video.hasOwnProperty('mimes') || !utils.isArray(bid.params.video.mimes) || bid.params.video.mimes.length === 0) { @@ -776,24 +811,17 @@ export const spec = { var conf = _initConf(refererInfo); var payload = _createOrtbTemplate(conf); var bidCurrency = ''; - var dctr = ''; - var dctrLen; var dctrArr = []; var bid; var blockedIabCategories = []; + validBidRequests.forEach(originalBid => { bid = utils.deepClone(originalBid); + bid.params.adSlot = bid.params.adSlot || ''; _parseAdSlot(bid); if (bid.params.hasOwnProperty('video')) { - if (!(bid.params.adSlot && bid.params.adUnit && bid.params.adUnitIndex)) { - utils.logWarn(LOG_WARN_PREFIX + 'Skipping the non-standard adslot: ', bid.params.adSlot, JSON.stringify(bid)); - return; - } + // Nothing to do } else { - if (!(bid.params.adSlot && bid.params.adUnit && bid.params.adUnitIndex)) { - utils.logWarn(LOG_WARN_PREFIX + 'Skipping the non-standard adslot: ', bid.params.adSlot, JSON.stringify(bid)); - return; - } // If we have a native mediaType configured alongside banner, its ok if the banner size is not set in width and height // The corresponding banner imp object will not be generated, but we still want the native object to be sent, hence the following check if (!(bid.hasOwnProperty('mediaTypes') && bid.mediaTypes.hasOwnProperty(NATIVE)) && bid.params.width === 0 && bid.params.height === 0) { @@ -838,6 +866,21 @@ export const spec = { payload.ext.wrapper.wp = 'pbjs'; payload.user.gender = (conf.gender ? conf.gender.trim() : UNDEFINED); payload.user.geo = {}; + payload.user.geo.lat = _parseSlotParam('lat', conf.lat); + payload.user.geo.lon = _parseSlotParam('lon', conf.lon); + payload.user.yob = _parseSlotParam('yob', conf.yob); + payload.device.geo = payload.user.geo; + payload.site.page = conf.kadpageurl.trim() || payload.site.page.trim(); + payload.site.domain = _getDomainFromURL(payload.site.page); + + // adding schain object + if (validBidRequests[0].schain) { + payload.source = { + ext: { + schain: validBidRequests[0].schain + } + }; + } // Attaching GDPR Consent Params if (bidderRequest && bidderRequest.gdprConsent) { @@ -852,43 +895,10 @@ export const spec = { }; } - payload.user.geo.lat = _parseSlotParam('lat', conf.lat); - payload.user.geo.lon = _parseSlotParam('lon', conf.lon); - payload.user.yob = _parseSlotParam('yob', conf.yob); - payload.device.geo = payload.user.geo; - payload.site.page = conf.kadpageurl.trim() || payload.site.page.trim(); - payload.site.domain = _getDomainFromURL(payload.site.page); - - // set dctr value in site.ext, if present in validBidRequests[0], else ignore - if (dctrArr.length > 0) { - if (validBidRequests[0].params.hasOwnProperty('dctr')) { - dctr = validBidRequests[0].params.dctr; - if (utils.isStr(dctr) && dctr.length > 0) { - var arr = dctr.split('|'); - dctr = ''; - arr.forEach(val => { - dctr += (val.length > 0) ? (val.trim() + '|') : ''; - }); - dctrLen = dctr.length; - if (dctr.substring(dctrLen, dctrLen - 1) === '|') { - dctr = dctr.substring(0, dctrLen - 1); - } - payload.site.ext = { - key_val: dctr.trim() - } - } else { - utils.logWarn(LOG_WARN_PREFIX + 'Ignoring param : dctr with value : ' + dctr + ', expects string-value, found empty or non-string value'); - } - if (dctrArr.length > 1) { - utils.logWarn(LOG_WARN_PREFIX + 'dctr value found in more than 1 adunits. Value from 1st adunit will be picked. Ignoring values from subsequent adunits'); - } - } else { - utils.logWarn(LOG_WARN_PREFIX + 'dctr value not found in 1st adunit, ignoring values from subsequent adunits'); - } - } - - _handleEids(payload); + _handleDealCustomTargetings(payload, dctrArr, validBidRequests); + _handleEids(payload, validBidRequests); _blockedIabCategoriesValidation(payload, blockedIabCategories); + return { method: 'POST', url: ENDPOINT, @@ -905,6 +915,8 @@ export const spec = { interpretResponse: (response, request) => { const bidResponses = []; var respCur = DEFAULT_CURRENCY; + let parsedRequest = JSON.parse(request.data); + let parsedReferrer = parsedRequest.site && parsedRequest.site.ref ? parsedRequest.site.ref : ''; try { if (response.body && response.body.seatbid && utils.isArray(response.body.seatbid)) { // Supporting multiple bid responses for same adSize @@ -913,7 +925,6 @@ export const spec = { seatbidder.bid && utils.isArray(seatbidder.bid) && seatbidder.bid.forEach(bid => { - let parsedRequest = JSON.parse(request.data); let newBid = { requestId: bid.impid, cpm: (parseFloat(bid.price) || 0).toFixed(2), @@ -924,7 +935,7 @@ export const spec = { currency: respCur, netRevenue: NET_REVENUE, ttl: 300, - referrer: parsedRequest.site && parsedRequest.site.ref ? parsedRequest.site.ref : '', + referrer: parsedReferrer, ad: bid.adm }; if (parsedRequest.imp && parsedRequest.imp.length > 0) { diff --git a/modules/pubmaticBidAdapter.md b/modules/pubmaticBidAdapter.md index 0f92e1756a5..1948acba40f 100644 --- a/modules/pubmaticBidAdapter.md +++ b/modules/pubmaticBidAdapter.md @@ -25,7 +25,7 @@ var adUnits = [ bidder: 'pubmatic', params: { publisherId: '156209', // required - adSlot: 'pubmatic_test2@300x250', // required + adSlot: 'pubmatic_test2', // optional pmzoneid: 'zone1, zone11', // optional lat: '40.712775', // optional lon: '-74.005973', // optional @@ -33,7 +33,7 @@ var adUnits = [ kadpageurl: 'www.test.com', // optional gender: 'M', // optional kadfloor: '0.50', // optional - currency: 'AUD' // optional (Value configured only in the 1st adunit will be passed on. < br/> Values if present in subsequent adunits, will be ignored.) + currency: 'AUD', // optional (Value configured only in the 1st adunit will be passed on. < br/> Values if present in subsequent adunits, will be ignored.) dctr: 'key1=123|key2=345', // optional (Value configured only in the 1st adunit will be passed on. < br/> Values if present in subsequent adunits, will be ignored.) bcat: ['IAB1-5', 'IAB1-7'] // Optional: Blocked IAB Categories. (Values from all slots will be combined and only unique values will be passed. An array of strings only. Each category should be a string of a length of more than 3 characters.) } @@ -55,8 +55,8 @@ var adVideoAdUnits = [ bids: [{ bidder: 'pubmatic', params: { - publisherId: '351', // required - adSlot: '1363568@300x250', // required + publisherId: '156209', // required + adSlot: 'pubmatic_video1', // optional video: { mimes: ['video/mp4','video/x-flv'], // required skippable: true, // optional @@ -104,7 +104,7 @@ var adUnits = [ bidder: 'pubmatic', params: { publisherId: '156295', // required - adSlot: 'pubmatic_test2@1x1', // required + adSlot: 'pubmatic_test2@1x1', // optional } }] }]; @@ -146,7 +146,7 @@ var adUnits = [ bidder: 'pubmatic', params: { publisherId: '156209', // required - adSlot: 'pubmatic_test2@300x250', // required + adSlot: 'pubmatic_test2@300x250', // optional pmzoneid: 'zone1, zone11', // optional lat: '40.712775', // optional lon: '-74.005973', // optional diff --git a/modules/pulsepointBidAdapter.js b/modules/pulsepointBidAdapter.js index 206eb734495..9c0d67d9612 100644 --- a/modules/pulsepointBidAdapter.js +++ b/modules/pulsepointBidAdapter.js @@ -1,6 +1,7 @@ /* eslint dot-notation:0, quote-props:0 */ import * as utils from '../src/utils'; import { registerBidder } from '../src/adapters/bidderFactory'; +import { Renderer } from '../src/Renderer'; const NATIVE_DEFAULTS = { TITLE_LEN: 100, @@ -13,13 +14,14 @@ const NATIVE_DEFAULTS = { const DEFAULT_BID_TTL = 20; const DEFAULT_CURRENCY = 'USD'; const DEFAULT_NET_REVENUE = true; +const KNOWN_PARAMS = ['cp', 'ct', 'cf', 'video', 'battr', 'bcat', 'badv', 'bidfloor']; /** * PulsePoint Bid Adapter. * Contact: ExchangeTeam@pulsepoint.com * * Aliases - pulseLite and pulsepointLite are supported for backwards compatibility. - * Formats - Display/Native/Outstream formats supported. + * Formats - Display/Native/Video formats supported. * */ export const spec = { @@ -28,7 +30,7 @@ export const spec = { aliases: ['pulseLite', 'pulsepointLite'], - supportedMediaTypes: ['banner', 'native'], + supportedMediaTypes: ['banner', 'native', 'video'], isBidRequestValid: bid => ( !!(bid && bid.params && bid.params.cp && bid.params.ct) @@ -41,12 +43,16 @@ export const spec = { site: site(bidRequests), app: app(bidRequests), device: device(), + bcat: bidRequests[0].params.bcat, + badv: bidRequests[0].params.badv, + user: user(bidRequests[0], bidderRequest), + regs: regs(bidderRequest), }; - applyGdpr(bidderRequest, request); return { method: 'POST', - url: '//bid.contextweb.com/header/ortb', - data: JSON.stringify(request), + url: 'https://bid.contextweb.com/header/ortb?src=prebid', + data: request, + bidderRequest }; }, @@ -58,12 +64,12 @@ export const spec = { if (syncOptions.iframeEnabled) { return [{ type: 'iframe', - url: '//bh.contextweb.com/visitormatch' + url: 'https://bh.contextweb.com/visitormatch' }]; } else if (syncOptions.pixelEnabled) { return [{ type: 'image', - url: '//bh.contextweb.com/visitormatch/prebid' + url: 'https://bh.contextweb.com/visitormatch/prebid' }]; } }, @@ -79,12 +85,13 @@ export const spec = { /** * Callback for bids, after the call to PulsePoint completes. */ -function bidResponseAvailable(bidRequest, bidResponse) { +function bidResponseAvailable(request, response) { const idToImpMap = {}; const idToBidMap = {}; - bidResponse = bidResponse.body + const idToSlotConfig = {}; + const bidResponse = response.body // extract the request bids and the response bids, keyed by impr-id - const ortbRequest = parse(bidRequest.data); + const ortbRequest = request.data; ortbRequest.imp.forEach(imp => { idToImpMap[imp.id] = imp; }); @@ -93,6 +100,11 @@ function bidResponseAvailable(bidRequest, bidResponse) { idToBidMap[bid.impid] = bid; })); } + if (request.bidderRequest) { + request.bidderRequest.bids.forEach(bid => { + idToSlotConfig[bid.bidId] = bid; + }); + } const bids = []; Object.keys(idToImpMap).forEach(id => { if (idToBidMap[id]) { @@ -109,6 +121,15 @@ function bidResponseAvailable(bidRequest, bidResponse) { if (idToImpMap[id]['native']) { bid['native'] = nativeResponse(idToImpMap[id], idToBidMap[id]); bid.mediaType = 'native'; + } else if (idToImpMap[id].video) { + // for outstream, a renderer is specified + if (idToSlotConfig[id] && utils.deepAccess(idToSlotConfig[id], 'mediaTypes.video.context') === 'outstream') { + bid.renderer = outstreamRenderer(utils.deepAccess(idToSlotConfig[id], 'renderer.options'), utils.deepAccess(idToBidMap[id], 'ext.outstream')); + } + bid.vastXml = idToBidMap[id].adm; + bid.mediaType = 'video'; + bid.width = idToBidMap[id].w; + bid.height = idToBidMap[id].h; } else { bid.ad = idToBidMap[id].adm; bid.width = idToImpMap[id].banner.w; @@ -138,6 +159,9 @@ function impression(slot) { banner: banner(slot), 'native': nativeImpression(slot), tagid: slot.params.ct.toString(), + video: video(slot), + bidfloor: slot.params.bidfloor, + ext: ext(slot), }; } @@ -146,12 +170,66 @@ function impression(slot) { */ function banner(slot) { const size = adSize(slot); - return slot.nativeParams ? null : { + return (slot.nativeParams || slot.params.video) ? null : { w: size[0], h: size[1], + battr: slot.params.battr, }; } +/** + * Produces an OpenRTB Video object for the slot given + */ +function video(slot) { + if (slot.params.video) { + return Object.assign({}, slot.params.video, {battr: slot.params.battr}); + } + return null; +} + +/** + * Unknown params are captured and sent on ext + */ +function ext(slot) { + const ext = {}; + const knownParamsMap = {}; + KNOWN_PARAMS.forEach(value => knownParamsMap[value] = 1); + Object.keys(slot.params).forEach(key => { + if (!knownParamsMap[key]) { + ext[key] = slot.params[key]; + } + }); + return Object.keys(ext).length > 0 ? { prebid: ext } : null; +} + +/** + * Sets up the renderer on the bid, for outstream bid responses. + */ +function outstreamRenderer(rendererOptions, outstreamExtOptions) { + const renderer = Renderer.install({ + url: outstreamExtOptions.rendererUrl, + config: { + defaultOptions: outstreamExtOptions.config, + rendererOptions, + type: outstreamExtOptions.type + }, + loaded: false, + }); + renderer.setRender((bid) => { + bid.renderer.push(() => { + const config = bid.renderer.getConfig(); + new window.PulsePointOutstreamRenderer().render({ + adUnitCode: bid.adUnitCode, + vastXml: bid.vastXml, + type: config.type, + defaultOptions: config.defaultOptions, + rendererOptions + }); + }); + }); + return renderer; +} + /** * Produces an OpenRTB Native object for the slot given. */ @@ -166,6 +244,7 @@ function nativeImpression(slot) { return { request: JSON.stringify({ assets }), ver: '1.1', + battr: slot.params.battr, }; } return null; @@ -312,13 +391,50 @@ function adSize(slot) { } /** - * Applies GDPR parameters to request. + * Handles the user level attributes and produces + * an openrtb User object. */ -function applyGdpr(bidderRequest, ortbRequest) { +function user(bidRequest, bidderRequest) { + var ext = {}; + if (bidderRequest) { + if (bidderRequest.gdprConsent) { + ext.consent = bidderRequest.gdprConsent.consentString; + } + } + if (bidRequest) { + if (bidRequest.userId) { + ext.eids = []; + addExternalUserId(ext.eids, bidRequest.userId.pubcid, 'pubcommon'); + addExternalUserId(ext.eids, bidRequest.userId.tdid, 'ttdid'); + addExternalUserId(ext.eids, utils.deepAccess(bidRequest.userId.digitrustid, 'data.id'), 'digitrust'); + addExternalUserId(ext.eids, bidRequest.userId.id5id, 'id5id'); + } + } + return { ext }; +} + +/** + * Produces external userid object in ortb 3.0 model. + */ +function addExternalUserId(eids, value, source) { + if (value) { + eids.push({ + source, + uids: [{ + id: value + }] + }); + } +} + +/** + * Produces the regulations ortb object + */ +function regs(bidderRequest) { if (bidderRequest && bidderRequest.gdprConsent) { - ortbRequest.regs = { ext: { gdpr: bidderRequest.gdprConsent.gdprApplies ? 1 : 0 } }; - ortbRequest.user = { ext: { consent: bidderRequest.gdprConsent.consentString } }; + return { ext: { gdpr: bidderRequest.gdprConsent.gdprApplies ? 1 : 0 } }; } + return null; } /** diff --git a/modules/pulsepointBidAdapter.md b/modules/pulsepointBidAdapter.md index 1b119f0499f..36d4ef6cce5 100644 --- a/modules/pulsepointBidAdapter.md +++ b/modules/pulsepointBidAdapter.md @@ -7,7 +7,7 @@ # Description Connects to PulsePoint demand source to fetch bids. -Banner, Outstream and Native formats are supported. +Banner, Video and Native formats are supported. Please use ```pulsepoint``` as the bidder code. ```pulseLite``` and ```pulsepointLite``` aliases also supported as well. @@ -40,5 +40,57 @@ Please use ```pulsepoint``` as the bidder code. ct: 505642 } }] + },{ + code: 'outstream-div', + mediaTypes: { + video: { + playerSize: [640, 480], + context: 'outstream' + } + }, + bids: [{ + bidder: 'pulsepoint', + params: { + cp: 512379, + ct: 505642, + video: { + h: 300, + w: 400, + minduration: 1, + maxduration: 210, + linearity: 1, + mimes: ["video/mp4", "video/ogg", "video/webm"], + pos: 3 + } + } + }], + renderer: { + options: { + text: "PulsePoint Outstream" + } + } + },{ + code: 'instream', + mediaTypes: { + video: { + playerSize: [640, 480], + context: 'instream' + } + }, + bids: [{ + bidder: 'pulsepoint', + params: { + cp: 512379, + ct: 694973, + video: { + battr: [1,3], + h: 300, + w: 400, + minduration: 1, + maxduration: 210, + protocols: [2,3,5] + } + } + }] }]; ``` diff --git a/modules/quantcastBidAdapter.js b/modules/quantcastBidAdapter.js index 022122b5a2e..739cf75c555 100644 --- a/modules/quantcastBidAdapter.js +++ b/modules/quantcastBidAdapter.js @@ -34,7 +34,24 @@ function extractBidSizes(bid) { } function makeVideoImp(bid) { - const video = bid.params.video; + const video = {}; + if (bid.params.video) { + video['mimes'] = bid.params.video.mimes; + video['minduration'] = bid.params.video.minduration; + video['maxduration'] = bid.params.video.maxduration; + video['protocols'] = bid.params.video.protocols; + video['startdelay'] = bid.params.video.startdelay; + video['linearity'] = bid.params.video.linearity; + video['battr'] = bid.params.video.battr; + video['maxbitrate'] = bid.params.video.maxbitrate; + video['playbackmethod'] = bid.params.video.playbackmethod; + video['delivery'] = bid.params.video.delivery; + video['placement'] = bid.params.video.placement; + video['api'] = bid.params.video.api; + } + if (bid.mediaTypes.video.mimes) { + video['mimes'] = bid.mediaTypes.video.mimes; + } if (utils.isArray(bid.mediaTypes.video.playerSize[0])) { video['w'] = bid.mediaTypes.video.playerSize[0][0]; video['h'] = bid.mediaTypes.video.playerSize[0][1]; @@ -83,17 +100,7 @@ export const spec = { * @return boolean `true` is this is a valid bid, and `false` otherwise */ isBidRequestValid(bid) { - if (!bid) { - return false; - } - - const videoMediaType = utils.deepAccess(bid, 'mediaTypes.video'); - const context = utils.deepAccess(bid, 'mediaTypes.video.context'); - if (videoMediaType && context == 'outstream') { - return false; - } - - return true; + return !!bid.params.publisherId; }, /** @@ -112,12 +119,22 @@ export const spec = { const page = utils.deepAccess(bidderRequest, 'refererInfo.canonicalUrl') || config.getConfig('pageUrl') || utils.deepAccess(window, 'location.href'); const domain = getDomain(page); - const bidRequestsList = bids.map(bid => { + let bidRequestsList = []; + + bids.forEach(bid => { let imp; - const videoContext = utils.deepAccess(bid, 'mediaTypes.video.context'); - if (videoContext === 'instream') { - imp = makeVideoImp(bid); + if (bid.mediaTypes) { + if (bid.mediaTypes.video && bid.mediaTypes.video.context === 'instream') { + imp = makeVideoImp(bid); + } else if (bid.mediaTypes.banner) { + imp = makeBannerImp(bid); + } else { + // Unsupported mediaType + utils.logInfo(`${BIDDER_CODE}: No supported mediaTypes found in ${JSON.stringify(bid.mediaTypes)}`); + return; + } } else { + // Parse as banner by default imp = makeBannerImp(bid); } @@ -143,11 +160,11 @@ export const spec = { : QUANTCAST_DOMAIN; const url = `${QUANTCAST_PROTOCOL}://${qcDomain}:${QUANTCAST_PORT}/qchb`; - return { + bidRequestsList.push({ data, method: 'POST', url - }; + }); }); return bidRequestsList; @@ -182,7 +199,7 @@ export const spec = { } const bidResponsesList = response.bids.map(bid => { - const { ad, cpm, width, height, creativeId, currency, videoUrl } = bid; + const { ad, cpm, width, height, creativeId, currency, videoUrl, dealId } = bid; const result = { requestId: response.requestId, @@ -201,6 +218,10 @@ export const spec = { result['mediaType'] = 'video'; } + if (dealId !== undefined && dealId) { + result['dealId'] = dealId; + } + return result; }); diff --git a/modules/quantcastBidAdapter.md b/modules/quantcastBidAdapter.md index 5d0c2e10fc0..2b55eae9026 100644 --- a/modules/quantcastBidAdapter.md +++ b/modules/quantcastBidAdapter.md @@ -3,7 +3,7 @@ ``` Module Name: Quantcast Bidder Adapter Module Type: Bidder Adapter -Maintainer: igor.soarez@quantcast.com +Maintainer: inventoryteam@quantcast.com ``` # Description diff --git a/modules/rdnBidAdapter.js b/modules/rdnBidAdapter.js index f93145b5377..17071c54be0 100644 --- a/modules/rdnBidAdapter.js +++ b/modules/rdnBidAdapter.js @@ -1,20 +1,21 @@ import { registerBidder } from '../src/adapters/bidderFactory' import * as utils from '../src/utils' import { BANNER } from '../src/mediaTypes' +import { config } from '../src/config' -const BIDDER_CODE = 'rdn' -const ENDPOINT = 'https://s-bid.rmp.rakuten.co.jp/h' +const BIDDER_CODE = 'rdn'; +const ENDPOINT = 'https://s-bid.rmp.rakuten.co.jp/h'; export const spec = { code: BIDDER_CODE, isBidRequestValid: bid => !!bid.params.adSpotId, buildRequests: validBidRequests => { - const bidRequests = [] + const bidRequests = []; validBidRequests.forEach(bid => { - const params = bid.params + const params = bid.params; bidRequests.push({ method: 'GET', - url: ENDPOINT, + url: config.getConfig('rdn.endpoint') || ENDPOINT, data: { bi: bid.bidId, t: params.adSpotId, @@ -28,26 +29,29 @@ export const spec = { pp: encodeURIComponent(utils.getTopWindowReferrer()) } }) - }) + }); return bidRequests }, interpretResponse: (response, request) => { - const sb = response.body - const bidResponses = [] - bidResponses.push({ - requestId: sb.bid_id, - cpm: sb.cpm || 0, - width: sb.width || 0, - height: sb.height || 0, - creativeId: sb.creative_id || 0, - dealId: sb.deal_id || '', - currency: sb.currency || 'JPY', - netRevenue: (sb.net_revenue === undefined) ? true : sb.net_revenue, - mediaType: BANNER, - ttl: sb.ttl, - referrer: utils.getTopWindowUrl(), - ad: sb.ad - }) + const sb = response.body; + const bidResponses = []; + + if (sb.cpm && sb.ad) { + bidResponses.push({ + requestId: sb.bid_id, + cpm: sb.cpm, + width: sb.width || 0, + height: sb.height || 0, + creativeId: sb.creative_id || 0, + dealId: sb.deal_id || '', + currency: sb.currency || 'JPY', + netRevenue: (typeof sb.net_revenue === 'undefined') ? true : !!sb.net_revenue, + mediaType: BANNER, + ttl: sb.ttl, + referrer: utils.getTopWindowUrl(), + ad: sb.ad + }); + } return bidResponses }, @@ -61,7 +65,7 @@ export const spec = { } if (bidResponseObj.sync_urls && bidResponseObj.sync_urls.length > 0) { bidResponseObj.sync_urls.forEach(syncUrl => { - if (syncUrl && syncUrl != 'null' && syncUrl.length > 0) { + if (syncUrl && syncUrl !== 'null' && syncUrl.length > 0) { syncs.push({ type: 'image', url: syncUrl @@ -74,4 +78,4 @@ export const spec = { } } -registerBidder(spec) +registerBidder(spec); diff --git a/modules/realvuAnalyticsAdapter.js b/modules/realvuAnalyticsAdapter.js index 64df6f655b7..51c5a106f1f 100644 --- a/modules/realvuAnalyticsAdapter.js +++ b/modules/realvuAnalyticsAdapter.js @@ -40,7 +40,7 @@ export let lib = { let z = this; let u = navigator.userAgent; z.device = u.match(/iPad|Tablet/gi) ? 'tablet' : u.match(/iPhone|iPod|Android|Opera Mini|IEMobile/gi) ? 'mobile' : 'desktop'; - if (typeof (z.len) == 'undefined') z.len = 0; // check, meybe too much, just make it len:0, + if (typeof (z.len) == 'undefined') z.len = 0; z.ie = navigator.appVersion.match(/MSIE/); z.saf = (u.match(/Safari/) && !u.match(/Chrome/)); z.ff = u.match(/Firefox/i); @@ -54,21 +54,20 @@ export let lib = { } } z.add_evt(window.top1, 'focus', function () { - window.top1.realvu_aa.foc = 1; /* window.top1.realvu_aa.log('focus',-1); */ + window.top1.realvu_aa.foc = 1; + }); + z.add_evt(window.top1, 'scroll', function () { + window.top1.realvu_aa.foc = 1; }); - // z.add_evt(window.top1, "scroll", function(){window.top1.realvu_aa.foc=1;window.top1.realvu_aa.log('scroll focus',-1);}); z.add_evt(window.top1, 'blur', function () { - window.top1.realvu_aa.foc = 0; /* window.top1.realvu_aa.log('blur',-1); */ + window.top1.realvu_aa.foc = 0; }); - // + http://www.w3.org/TR/page-visibility/ z.add_evt(window.top1.document, 'blur', function () { - window.top1.realvu_aa.foc = 0; /* window.top1.realvu_aa.log('blur',-1); */ + window.top1.realvu_aa.foc = 0; }); z.add_evt(window.top1, 'visibilitychange', function () { window.top1.realvu_aa.foc = !window.top1.document.hidden; - /* window.top1.realvu_aa.log('vis-ch '+window.top1.realvu_aa.foc,-1); */ }); - // - z.doLog = (window.top1.location.search.match(/boost_log/) || document.referrer.match(/boost_log/)) ? 1 : 0; if (z.doLog) { window.setTimeout(z.scr(window.top1.location.protocol + '//ac.realvu.net/realvu_aa_viz.js'), 500); @@ -84,11 +83,12 @@ export let lib = { update: function () { let z = this; - let de = window.top1.document.documentElement; - z.x1 = window.top1.pageXOffset ? window.top1.pageXOffset : de.scrollLeft; - z.y1 = window.top1.pageYOffset ? window.top1.pageYOffset : de.scrollTop; - let w1 = window.top1.innerWidth ? window.top1.innerWidth : de.clientWidth; - let h1 = window.top1.innerHeight ? window.top1.innerHeight : de.clientHeight; + let t = window.top1; + let de = t.document.documentElement; + z.x1 = t.pageXOffset ? t.pageXOffset : de.scrollLeft; + z.y1 = t.pageYOffset ? t.pageYOffset : de.scrollTop; + let w1 = t.innerWidth ? t.innerWidth : de.clientWidth; + let h1 = t.innerHeight ? t.innerHeight : de.clientHeight; z.x2 = z.x1 + w1; z.y2 = z.y1 + h1; }, @@ -152,7 +152,7 @@ export let lib = { let bk = z.beacons.shift(); while (typeof bk != 'undefined') { bk.s1 = bk.s1.replace(/_sr=0*_/, '_sr=' + z.sr + '_'); - z.log(' ' + bk.a.riff + ' ' + bk.a.unit_id + /* " "+pin.mode+ */ ' ' + bk.a.w + 'x' + bk.a.h + '@' + bk.a.x + ',' + bk.a.y + + z.log(' ' + bk.a.riff + ' ' + bk.a.unit_id + /* ' '+pin.mode+ */ ' ' + bk.a.w + 'x' + bk.a.h + '@' + bk.a.x + ',' + bk.a.y + ' ' + bk.f + '', bk.a.num); if (bk.a.rnd < Math.pow(10, 1 - (z.sr.charCodeAt(0) & 7))) { z.scr(bk.s1, bk.a); @@ -181,8 +181,8 @@ export let lib = { '_f=' + f + '_r=' + a.riff + '_s=' + a.w + 'x' + a.h; if (a.p) s2 += '_p=' + a.p; - s2 += '_ps=' + this.enc(a.unit_id) + // 08-Jun-15 - _p= is replaced with _ps= - p-number, ps-string - '_dv=' + this.device + + if (f != 'conf') s2 += '_ps=' + this.enc(a.unit_id); + s2 += '_dv=' + this.device + // + '_a=' + this.enc(a.a) '_d=' + pin.mode + '_sr=' + this.sr + @@ -191,7 +191,7 @@ export let lib = { }, enc: function (s1) { - // return escape(s1).replace(/[0-9a-f]{5,}/gi,'RANDOM').replace(/\*/g, "%2A").replace(/_/g, "%5F").replace(/\+/g, + // return escape(s1).replace(/[0-9a-f]{5,}/gi,'RANDOM').replace(/\*/g, '%2A').replace(/_/g, '%5F').replace(/\+/g, return escape(s1).replace(/\*/g, '%2A').replace(/_/g, '%5F').replace(/\+/g, '%2B').replace(/\./g, '%2E').replace(/\x2F/g, '%2F'); }, @@ -467,7 +467,7 @@ export let lib = { return null; }, - doc: function(f) { // return document of f-iframe, keep here "n" as a parameter because of call from setTimeout() + doc: function(f) { // return document of f-iframe let d = null; try { if (f.contentDocument) d = f.contentDocument; // DOM diff --git a/modules/reklamstoreBidAdapter.js b/modules/reklamstoreBidAdapter.js index be484822860..2a659ec0f07 100644 --- a/modules/reklamstoreBidAdapter.js +++ b/modules/reklamstoreBidAdapter.js @@ -1,6 +1,6 @@ -import * as utils from 'src/utils'; -import { registerBidder } from 'src/adapters/bidderFactory'; -import { BANNER } from 'src/mediaTypes'; +import * as utils from '../src/utils'; +import { registerBidder } from '../src/adapters/bidderFactory'; +import { BANNER } from '../src/mediaTypes'; const BIDDER_CODE = 'reklamstore'; const ENDPOINT_URL = '//ads.rekmob.com/m/prebid'; @@ -36,7 +36,6 @@ export const spec = { regionId: bid.params.regionId, dt: getDeviceType(), os: getOS(), - dbg: 1, ref: extractDomain(url), _: (new Date().getTime()), mobile_web: 1 @@ -65,7 +64,7 @@ export const spec = { height: bidResponse.h, creativeId: bidResponse.adId || 1, currency: CURRENCY, - netRevenue: false, + netRevenue: true, ttl: TIME_TO_LIVE, ad: bidResponse.ad }); diff --git a/modules/reloadBidAdapter.js b/modules/reloadBidAdapter.js new file mode 100644 index 00000000000..4ecd4ff3390 --- /dev/null +++ b/modules/reloadBidAdapter.js @@ -0,0 +1,423 @@ +import { + registerBidder +} + from '../src/adapters/bidderFactory'; +import * as utils from '../src/utils'; +const BIDDER_CODE = 'reload'; +const VERSION_ADAPTER = '1.10'; +export const spec = { + code: BIDDER_CODE, + png: {}, + /** + * Determines whether or not the given bid request is valid. + * + * @param {BidRequest} bid The bid params to validate. + * @return boolean True if this is a valid bid, and false otherwise. + */ + isBidRequestValid: function (bid) { + return !!(bid.params && bid.params.plcmID && bid.params.partID && 'opdomID' in bid.params && + 'bsrvID' in bid.params && bid.params.bsrvID >= 0 && bid.params.bsrvID <= 99); + }, + /** + * Make a server request from the list of BidRequests. + * + * @param {validBidRequests[]} - an array of bids + * @return ServerRequest Info describing the request to the server. + */ + buildRequests: function (validBidRequests, bidderRequest) { + let vRequests = []; + let bidReq = { + id: Math.random().toString(10).substring(2), + imp: [] + }; + let vgdprConsent = null; + if (utils.deepAccess(bidderRequest, 'gdprConsent')) { + vgdprConsent = bidderRequest.gdprConsent; + } + let vPrxClientTool = null; + let vSrvUrl = null; + for (let vIdx = 0; vIdx < validBidRequests.length; vIdx++) { + let bidRequest = validBidRequests[vIdx]; + vPrxClientTool = new ReloadClientTool({ + prxVer: VERSION_ADAPTER, + prxType: 'bd', + plcmID: bidRequest.params.plcmID, + partID: bidRequest.params.partID, + opdomID: bidRequest.params.opdomID, + bsrvID: bidRequest.params.bsrvID, + gdprObj: vgdprConsent, + mediaObj: bidRequest.mediaTypes, + wnd: utils.getWindowTop(), + rtop: utils.deepAccess(bidderRequest, 'refererInfo.reachedTop') || false + }); + if (vSrvUrl === null) vSrvUrl = vPrxClientTool.getSrvUrl(); + let vImpression = { + id: bidRequest.bidId, + bidId: bidRequest.bidId, + adUnitCode: bidRequest.adUnitCode, + transactionId: bidRequest.transactionId, + bidderRequestId: bidRequest.bidderRequestId, + auctionId: bidRequest.auctionId, + banner: { + ext: { + type: bidRequest.params.type || 'pcm', + pcmdata: vPrxClientTool.getPCMObj() + } + } + }; + bidReq.imp.push(vImpression); + } + if (bidReq.imp.length > 0) { + const payloadString = JSON.stringify(bidReq); + vRequests.push({ + method: 'POST', + url: vSrvUrl, + data: payloadString + }); + } + return vRequests; + }, + /** + * Unpack the response from the server into a list of bids. + * + * @param {ServerResponse} serverResponse A successful response from the server. + * @return {Bid[]} An array of bids which were nested inside the server. + */ + interpretResponse: function (serverResponse, bidRequest) { + const serverBody = serverResponse.body; + const bidResponses = []; + for (let vIdx = 0; vIdx < serverBody.seatbid.length; vIdx++) { + let vSeatBid = serverBody.seatbid[vIdx]; + for (let vIdxBid = 0; vIdxBid < vSeatBid.bid.length; vIdxBid++) { + let vBid = vSeatBid.bid[vIdxBid]; + let vPrxClientTool = new ReloadClientTool({ + plcmID: vBid.ext.plcmID, + partID: vBid.ext.partID, + opdomID: vBid.ext.opdomID, + bsrvID: vBid.ext.bsrvID + }); + vPrxClientTool.setPCMObj(vBid.ext.pcmdata); + if (vPrxClientTool.getBP() > 0) { + let bidResponse = { + requestId: vBid.impid, + ad: vPrxClientTool.getAM(), + cpm: vPrxClientTool.getBP() / 100, + width: vPrxClientTool.getW(), + height: vPrxClientTool.getH(), + creativeId: vBid.id, + currency: vPrxClientTool.getBC(), + ttl: 300, + netRevenue: true + }; + bidResponses.push(bidResponse); + this.png[vBid.ext.adUnitCode] = vPrxClientTool.getPingUrl('bidwon'); + } + } + } + return bidResponses; + }, + /** + * Register bidder specific code, which will execute if a bid from this bidder won the auction + * @param {Bid} The bid that won the auction + */ + onBidWon: function (bid) { + if (typeof this.png[bid.adUnitCode] !== 'string' || this.png[bid.adUnitCode] === '') return; + (new Image()).src = this.png[bid.adUnitCode]; + } +}; + +function ReloadClientTool(args) { + var that = this; + var _pcmClientVersion = '120'; + var _pcmFilePref = 'prx_root_'; + var _resFilePref = 'prx_pnws_'; + var _pcmInputObjVers = '120'; + var _instObj = null; + var _status = 'NA'; + var _message = ''; + var _log = ''; + var _memFile = _getMemFile(); + + if (_memFile.status !== 'ok') { + _log += 'WARNING: clnt-int mem file initialized\n'; + } + + that.getPCMObj = function () { + return { + thisVer: _pcmInputObjVers, + statStr: _memFile.statStr, + plcmData: _getPlcmData(), + clntData: _getClientData(args.wnd, args.rtop), + resultData: _getRD(), + gdprObj: _getGdpr(), + mediaObj: _getMediaObj(), + proxetString: null, + dboData: null, + plcmSett: null, + }; + }; + + that.setPCMObj = function (obj) { + if (obj.thisVer !== '100') { + _status = 'error'; + _message = 'incomp_output_obj_version'; + _log += ' ERROR incomp_output_obj_version'; + return; + } + + _status = obj.status; + _message = obj.message; + _log += ' ' + obj.log; + + if (obj.status !== 'ok') return; + + _saveMemFile(obj.statStr, obj.srvUrl); + _instObj = obj.instr; + }; + + that.getSrvUrl = function () { + var effSrvUrl = getBidServerUrl(0); + + if (isNaN(parseInt(args.bsrvID)) !== true) effSrvUrl = getBidServerUrl(parseInt(args.bsrvID)); + + if (typeof _memFile.srvUrl === 'string' && _memFile.srvUrl !== '') effSrvUrl = _memFile.srvUrl; + + return _getProtocolString() + effSrvUrl + '/bid'; + + function getBidServerUrl (idx) { + return 'bidsrv' + getTwoDigitString(idx) + '.reload.net'; + + function getTwoDigitString (idx) { + if (idx >= 10) return '' + idx; + else return '0' + idx; + } + } + }; + + that.getMT = function () { + return _checkInstProp('mtype', 'dsp'); + }; + + that.getW = function () { + return _checkInstProp('width', 0); + }; + + that.getH = function () { + return _checkInstProp('height', 0); + }; + + that.getBP = function () { + return _checkInstProp('prc', 0); + }; + + that.getBC = function () { + return _checkInstProp('cur', 'USD'); + }; + + that.getAM = function () { + return _checkInstProp('am', null); + }; + + that.getPingUrl = function (pingName) { + var pingData = _checkInstProp('pingdata', {}); + if (pingData[pingName] !== 'undefined') return pingData[pingName]; + return ''; + }; + + that.setRD = function (data) { + return _setRD(data); + }; + + that.getStat = function () { + return _status; + }; + + that.getMsg = function () { + return _message; + }; + + that.getLog = function () { + return _log; + }; + + function _checkInstProp (key, def) { + if (_instObj === null) return def; + if (typeof _instObj === 'undefined') return def; + if (_instObj.go !== true) return def; + if (typeof _instObj[key] === 'undefined') return def; + return _instObj[key]; + } + + function _getPlcmData () { + return { + prxVer: args.prxVer, + prxType: args.prxType, + plcmID: args.plcmID, + partID: args.partID, + opdomID: args.opdomID, + bsrvID: args.bsrvID, + dmod: args.dmod, + lmod: args.lmod, + lplcmID: args.lplcmID, + }; + } + + function _getClientData (wnd, rtop) { + return { + version: 200, + locTime: Date.now(), + winInfo: _winInf(wnd), + envInfo: getEnvInfo(), + topw: rtop === true, + prot: wnd.document.location.protocol, + host: wnd.document.location.host, + title: wnd.document.title, + }; + + function _winInf (wnd) { + return { + phs: { + w: wnd.screen.width, + h: wnd.screen.height + }, + avl: { + w: wnd.screen.availWidth, + h: wnd.screen.availHeight + }, + inr: { + w: wnd.innerWidth, + h: wnd.innerHeight + }, + bdy: { + w: wnd.document.body.clientWidth, + h: wnd.document.body.clientHeight + } + }; + } + + function getEnvInfo() { + return { + userAgent: navigator.userAgent, + appName: navigator.appName, + appVersion: navigator.appVersion + }; + } + } + + function _getMemFile () { + try { + var memFileObj = _getItem(_getMemFileName()); + + if (memFileObj === null) throw { s: 'init' }; + + if (typeof memFileObj.statStr !== 'string') throw { s: 'error' }; + if (typeof memFileObj.srvUrl !== 'string') throw { s: 'error' }; + + memFileObj.status = 'ok'; + + return memFileObj; + } catch (err) { + var retObj = { + statStr: null, + srvUrl: null + }; + retObj.status = err.s; + + return retObj; + } + } + + function _saveMemFile (statStr, srvUrl) { + try { + var fileData = { + statStr: statStr, + srvUrl: srvUrl, + }; + _setItem(_getMemFileName(), fileData); + return true; + } catch (err) { + return false; + } + } + + function _getMemFileName () { + return _pcmFilePref + args.plcmID + '_' + args.partID; + } + + function _getRD () { + try { + return _getItem(_getResltStatusFileName()); + } catch (err) { + return null; + } + } + + function _setRD (fileData) { + try { + _setItem(_getResltStatusFileName(), fileData); + return true; + } catch (err) { + return false; + } + } + + function _getGdpr() { + return args.gdprObj; + } + + function _getMediaObj() { + return args.mediaObj; + } + + function _getResltStatusFileName () { + if (args.lmod === true) return _resFilePref + args.lplcmID + '_' + args.partID; + else return _resFilePref + args.plcmID + '_' + args.partID; + } + + function _setItem (name, data) { + var stgFileObj = { + ver: _pcmClientVersion, + ts: Date.now(), + }; + + if (typeof data === 'string') { + stgFileObj.objtype = false; + stgFileObj.memdata = data; + } else { + stgFileObj.objtype = true; + stgFileObj.memdata = JSON.stringify(data); + } + + var stgFileStr = JSON.stringify(stgFileObj); + + localStorage.setItem(name, stgFileStr); + + return true; + } + + function _getItem (name) { + try { + var obStgFileStr = localStorage.getItem(name); + if (obStgFileStr === null) return null; + + var stgFileObj = JSON.parse(obStgFileStr); + + if (stgFileObj.ver !== _pcmClientVersion) throw { message: 'version_error' }; + + if (stgFileObj.objtype === true) return JSON.parse(stgFileObj.memdata); + else return '' + stgFileObj.memdata; + } catch (err) { + return null; + } + } + + function _getProtocolString () { + var wnd = null; + try { wnd = top; } catch (err) { wnd = window; } + + if (wnd.location.protocol.toLowerCase().indexOf('http:') >= 0) return 'http://'; + else return 'https://'; + } +}; + +registerBidder(spec); diff --git a/modules/reloadBidAdapter.md b/modules/reloadBidAdapter.md new file mode 100644 index 00000000000..42fe11b40b3 --- /dev/null +++ b/modules/reloadBidAdapter.md @@ -0,0 +1,48 @@ +# Overview + +Module Name: Reload Bid Adapter + +Module Type: Bidder Adapter + +Maintainer: prebid@reload.net + +# Description + +Prebid module for connecting to Reload + +# Parameters +## Banner + +| Name | Scope | Description | Example | +| :------------ | :------- | :---------------------------------------------- | :--------------------------------- | +| `plcmID` | required | Placement ID (provided by Reload) | "4234897234" | +| `partID` | required | Partition ID (provided by Reload) | "part_01" | +| `opdomID` | required | Internal parameter (provided by Reload) | 0 | +| `bsrvID` | required | Internal parameter (provided by Reload) | 12 | +| `type` | optional | Internal parameter (provided by Reload) | "pcm" | + +# Example ad units +# Test Parameters +``` +var adUnits = [ + // Banner adUnit + { + code: 'banner-div', + mediaTypes: { + banner: { + sizes: [ + [300, 250] + ], + } + }, + bids: [{ + bidder: 'reload', + params: { + plcmID: 'prebid_check', + partID: 'part_4', + opdomID: '0', + bsrvID: 0, + type: 'pcm' + } + }] + }]; \ No newline at end of file diff --git a/modules/rhythmoneBidAdapter.js b/modules/rhythmoneBidAdapter.js index 29572c228fe..dc818e89f32 100644 --- a/modules/rhythmoneBidAdapter.js +++ b/modules/rhythmoneBidAdapter.js @@ -15,145 +15,128 @@ function RhythmOneBidAdapter() { let SUPPORTED_VIDEO_API = [1, 2, 5]; let slotsToBids = {}; let that = this; - let version = '1.0.2.1'; - let loadStart = Date.now(); - var win = typeof window !== 'undefined' ? window : {}; + let version = '2.1'; this.isBidRequestValid = function (bid) { - return true; + return !!(bid.params && bid.params.placementId); }; this.getUserSyncs = function (syncOptions, responses, gdprConsent) { - let slots = []; - let placementIds = []; - - for (let k in slotsToBids) { - slots.push(k); - placementIds.push(getFirstParam('placementId', [slotsToBids[k]])); - } - - let data = { - doc_version: 1, - doc_type: 'Prebid Audit', - placement_id: placementIds.join(',').replace(/[,]+/g, ',').replace(/^,|,$/g, '') - }; - let w = typeof (window) !== 'undefined' ? window : {document: {location: {href: ''}}}; - let ao = w.document.location.ancestorOrigins; - let q = []; - let u = '//hbevents.1rx.io/audit?'; - - if (ao && ao.length > 0) { - data.ancestor_origins = ao[ao.length - 1]; - } - - data.popped = w.opener !== null ? 1 : 0; - data.framed = w.top === w ? 0 : 1; - - try { - data.url = w.top.document.location.href.toString(); - } catch (ex) { - data.url = w.document.location.href.toString(); - } - - try { - data.prebid_version = '$prebid.version$'; - data.prebid_timeout = config.getConfig('bidderTimeout'); - } catch (ex) { } - - data.response_ms = Date.now() - loadStart; - data.placement_codes = slots.join(','); - data.bidder_version = version; - if (gdprConsent) { - data.gdpr_consent = gdprConsent.consentString; - data.gdpr = (typeof gdprConsent.gdprApplies === 'boolean') ? gdprConsent.gdprApplies : false; - } - - for (let k in data) { - q.push(encodeURIComponent(k) + '=' + encodeURIComponent((typeof data[k] === 'object' ? JSON.stringify(data[k]) : data[k]))); - } - - q.sort(); - - if (syncOptions.pixelEnabled) { - return [{ - type: 'image', - url: u + q.join('&') - }]; - } + return []; }; - function frameImp(BRs) { - var imp = []; + function frameImp(BRs, bidderRequest) { + var impList = []; + var isSecure = 0; + if (bidderRequest && bidderRequest.refererInfo && bidderRequest.refererInfo.stack.length) { + // clever trick to get the protocol + var el = document.createElement('a'); + el.href = bidderRequest.refererInfo.stack[0]; + isSecure = (el.protocol == 'https:') ? 1 : 0; + } for (var i = 0; i < BRs.length; i++) { - slotsToBids[BRs[i].adUnitCode || BRs[i].placementCode] = BRs[i]; + slotsToBids[BRs[i].adUnitCode] = BRs[i]; var impObj = {}; impObj.id = BRs[i].adUnitCode; impObj.bidfloor = parseFloat(utils.deepAccess(BRs[i], 'params.floor')) || 0; - impObj.secure = win.location.protocol === 'https:' ? 1 : 0; + impObj.secure = isSecure; + if (utils.deepAccess(BRs[i], 'mediaTypes.banner') || utils.deepAccess(BRs[i], 'mediaType') === 'banner') { - impObj.banner = frameBanner(BRs[i]); + let banner = frameBanner(BRs[i]); + if (banner) { + impObj.banner = banner; + } } if (utils.deepAccess(BRs[i], 'mediaTypes.video') || utils.deepAccess(BRs[i], 'mediaType') === 'video') { impObj.video = frameVideo(BRs[i]); } + if (!(impObj.banner || impObj.video)) { + continue; + } impObj.ext = frameExt(BRs[i]); - imp.push(impObj); + impList.push(impObj); } - return imp; + return impList; } function frameSite(bidderRequest) { - return { - domain: attempt(function() { - var d = win.document.location.ancestorOrigins; - if (d && d.length > 0) { - return d[d.length - 1]; - } - return win.top.document.location.hostname; // try/catch is in the attempt function - }, ''), - page: attempt(function() { - var l; - // try/catch is in the attempt function - try { - l = win.top.document.location.href.toString(); - } catch (ex) { - l = win.document.location.href.toString(); - } - return l; - }, ''), - ref: attempt(function() { - if (bidderRequest && bidderRequest.refererInfo) { - return bidderRequest.refererInfo.referer; - } - return ''; - }, '') + var site = { + domain: '', + page: '', + ref: '' } + if (bidderRequest && bidderRequest.refererInfo) { + var ri = bidderRequest.refererInfo; + site.ref = ri.referer; + + if (ri.stack.length) { + site.page = ri.stack[ri.stack.length - 1]; + + // clever trick to get the domain + var el = document.createElement('a'); + el.href = ri.stack[0]; + site.domain = el.hostname; + } + } + return site; } function frameDevice() { return { ua: navigator.userAgent, - devicetype: /(ios|ipod|ipad|iphone|android)/i.test(win.navigator.userAgent) ? 1 : /(smart[-]?tv|hbbtv|appletv|googletv|hdmi|netcast\.tv|viera|nettv|roku|\bdtv\b|sonydtv|inettvbrowser|\btv\b)/i.test(win.navigator.userAgent) ? 3 : 2, ip: '', // Empty Ip string is required, server gets the ip from HTTP header dnt: utils.getDNT() ? 1 : 0, } } - function frameBanner(bid) { - var sizes = utils.parseSizesInput(bid.sizes).map(size => size.split('x')); - return { - w: parseInt(sizes[0][0]), - h: parseInt(sizes[0][1]) + function getValidSizeSet(dimensionList) { + let w = parseInt(dimensionList[0]); + let h = parseInt(dimensionList[1]); + // clever check for NaN + if (! (w !== w || h !== h)) { // eslint-disable-line + return [w, h]; } + return false; + } + + function frameBanner(adUnit) { + // adUnit.sizes is scheduled to be deprecated, continue its support but prefer adUnit.mediaTypes.banner + var sizeList = adUnit.sizes; + if (adUnit.mediaTypes && adUnit.mediaTypes.banner) { + sizeList = adUnit.mediaTypes.banner.sizes; + } + var sizeStringList = utils.parseSizesInput(sizeList); + var format = []; + sizeStringList.forEach(function(size) { + if (size) { + var dimensionList = getValidSizeSet(size.split('x')); + if (dimensionList) { + format.push({ + 'w': dimensionList[0], + 'h': dimensionList[1], + }); + } + } + }); + if (format.length) { + return { + 'format': format + }; + } + + return false; } function frameVideo(bid) { var size = []; if (utils.deepAccess(bid, 'mediaTypes.video.playerSize')) { + var dimensionSet = bid.mediaTypes.video.playerSize; if (utils.isArray(bid.mediaTypes.video.playerSize[0])) { - size = bid.mediaTypes.video.playerSize[0]; - } else if (utils.isNumber(bid.mediaTypes.video.playerSize[0])) { - size = bid.mediaTypes.video.playerSize; + dimensionSet = bid.mediaTypes.video.playerSize[0]; + } + var validSize = getValidSizeSet(dimensionSet) + if (validSize) { + size = validSize; } } return { @@ -172,7 +155,7 @@ function RhythmOneBidAdapter() { function frameExt(bid) { return { bidder: { - placementId: (bid.params && bid.params['placementId']) ? bid.params['placementId'] : '', + placementId: bid.params['placementId'], zone: (bid.params && bid.params['zone']) ? bid.params['zone'] : '1r', path: (bid.params && bid.params['path']) ? bid.params['path'] : 'mvo' } @@ -182,7 +165,7 @@ function RhythmOneBidAdapter() { function frameBid(BRs, bidderRequest) { return { id: BRs[0].bidderRequestId, - imp: frameImp(BRs), + imp: frameImp(BRs, bidderRequest), site: frameSite(bidderRequest), device: frameDevice(), user: { @@ -208,13 +191,6 @@ function RhythmOneBidAdapter() { } } - function attempt(valueFunction, defaultValue) { - try { - return valueFunction(); - } catch (ex) { } - return defaultValue; - } - this.buildRequests = function (BRs, bidderRequest) { let fallbackPlacementId = getFirstParam('placementId', BRs); if (fallbackPlacementId === undefined || BRs.length < 1) { @@ -234,7 +210,9 @@ function RhythmOneBidAdapter() { rmpUrl += '&hbv=' + prebidVersion.replace(fat, '') + ',' + version.replace(fat, ''); var bidRequest = frameBid(BRs, bidderRequest); - loadStart = Date.now(); + if (!bidRequest.imp.length) { + return {}; + } return { method: 'POST', diff --git a/modules/rhythmoneBidAdapter.md b/modules/rhythmoneBidAdapter.md index ec3ee4852e5..df657ed2651 100644 --- a/modules/rhythmoneBidAdapter.md +++ b/modules/rhythmoneBidAdapter.md @@ -14,15 +14,41 @@ This module relays Prebid bids from Rhythm Exchange, RhythmOne's ad exchange. ```js const adUnits = [{ - code: 'uuddlrlrbass', - sizes: [ - [300, 250] - ], + code: 'adSlot-1', + mediaTypes: { + banner: { + sizes: [ + [300, 250], + [300, 600] + ] + } + }, bids: [ { bidder: 'rhythmone', - params: - { + params: + { + placementId: '80184', // REQUIRED + zone: '1r', // OPTIONAL + path: 'mvo', // OPTIONAL + endpoint: "//tag.1rx.io/rmp/80184/0/mvo?z=1r" // OPTIONAL, only required for testing. this api guarantees no 204 responses + } + } + ] +}, +{ + code: 'adSlot-2', + mediaTypes: { + video: { + context: "instream", + playerSize: [640, 480] + } + }, + bids: [ + { + bidder: 'rhythmone', + params: + { placementId: '80184', // REQUIRED zone: '1r', // OPTIONAL path: 'mvo', // OPTIONAL @@ -31,4 +57,4 @@ const adUnits = [{ } ] }]; -``` \ No newline at end of file +``` diff --git a/modules/richAudienceBidAdapter.js b/modules/richaudienceBidAdapter.js similarity index 99% rename from modules/richAudienceBidAdapter.js rename to modules/richaudienceBidAdapter.js index 9701bb4ec48..bd47e481a76 100644 --- a/modules/richAudienceBidAdapter.js +++ b/modules/richaudienceBidAdapter.js @@ -91,6 +91,7 @@ export const spec = { netRevenue: response.netRevenue, currency: response.currency, ttl: response.ttl, + dealId: response.dealId, }; if (response.media_type === 'video') { diff --git a/modules/richAudienceBidAdapter.md b/modules/richaudienceBidAdapter.md similarity index 100% rename from modules/richAudienceBidAdapter.md rename to modules/richaudienceBidAdapter.md diff --git a/modules/rtbhouseBidAdapter.md b/modules/rtbhouseBidAdapter.md index b8410fe8bb6..233ed34053a 100644 --- a/modules/rtbhouseBidAdapter.md +++ b/modules/rtbhouseBidAdapter.md @@ -39,7 +39,8 @@ Please reach out to pmp@rtbhouse.com to receive your own len: 25 }, image: { - required: true + required: true, + sizes: [300, 250] }, body: { required: true, diff --git a/modules/rubiconAnalyticsAdapter.js b/modules/rubiconAnalyticsAdapter.js index 6c4e1b88d8b..560cab91dca 100644 --- a/modules/rubiconAnalyticsAdapter.js +++ b/modules/rubiconAnalyticsAdapter.js @@ -28,7 +28,7 @@ config.getConfig('s2sConfig', ({s2sConfig}) => { }); export const SEND_TIMEOUT = 3000; -const INTEGRATION = 'pbjs'; +const DEFAULT_INTEGRATION = 'pbjs'; const cache = { auctions: {}, @@ -36,33 +36,6 @@ const cache = { timeouts: {}, }; -// basically lodash#pick that also allows transformation functions and property renaming -function _pick(obj, properties) { - return properties.reduce((newObj, prop, i) => { - if (typeof prop === 'function') { - return newObj; - } - - let newProp = prop; - let match = prop.match(/^(.+?)\sas\s(.+?)$/i); - - if (match) { - prop = match[1]; - newProp = match[2]; - } - - let value = obj[prop]; - if (typeof properties[i + 1] === 'function') { - value = properties[i + 1](value, newObj); - } - if (typeof value !== 'undefined') { - newObj[newProp] = value; - } - - return newObj; - }, {}); -} - function stringProperties(obj) { return Object.keys(obj).reduce((newObj, prop) => { let value = obj[prop]; @@ -98,7 +71,7 @@ function formatSource(src) { function sendMessage(auctionId, bidWonId) { function formatBid(bid) { - return _pick(bid, [ + return utils.pick(bid, [ 'bidder', 'bidId', 'status', @@ -113,7 +86,7 @@ function sendMessage(auctionId, bidWonId) { 'clientLatencyMillis', 'serverLatencyMillis', 'params', - 'bidResponse', bidResponse => bidResponse ? _pick(bidResponse, [ + 'bidResponse', bidResponse => bidResponse ? utils.pick(bidResponse, [ 'bidPriceUSD', 'dealId', 'dimensions', @@ -122,7 +95,7 @@ function sendMessage(auctionId, bidWonId) { ]); } function formatBidWon(bid) { - return Object.assign(formatBid(bid), _pick(bid.adUnit, [ + return Object.assign(formatBid(bid), utils.pick(bid.adUnit, [ 'adUnitCode', 'transactionId', 'videoAdFormat', () => bid.videoAdFormat, @@ -139,17 +112,21 @@ function sendMessage(auctionId, bidWonId) { let referrer = config.getConfig('pageUrl') || utils.getTopWindowUrl(); let message = { eventTimeMillis: Date.now(), - integration: INTEGRATION, + integration: config.getConfig('rubicon.int_type') || DEFAULT_INTEGRATION, version: '$prebid.version$', referrerUri: referrer }; + const wrapperName = config.getConfig('rubicon.wrapperName'); + if (wrapperName) { + message.wrapperName = wrapperName; + } let auctionCache = cache.auctions[auctionId]; if (auctionCache && !auctionCache.sent) { let adUnitMap = Object.keys(auctionCache.bids).reduce((adUnits, bidId) => { let bid = auctionCache.bids[bidId]; let adUnit = adUnits[bid.adUnit.adUnitCode]; if (!adUnit) { - adUnit = adUnits[bid.adUnit.adUnitCode] = _pick(bid.adUnit, [ + adUnit = adUnits[bid.adUnit.adUnitCode] = utils.pick(bid.adUnit, [ 'adUnitCode', 'transactionId', 'mediaTypes', @@ -187,7 +164,7 @@ function sendMessage(auctionId, bidWonId) { // This allows the bidWon events to have these params even in the case of a delayed render Object.keys(auctionCache.bids).forEach(function (bidId) { let adCode = auctionCache.bids[bidId].adUnit.adUnitCode; - Object.assign(auctionCache.bids[bidId], _pick(adUnitMap[adCode], ['accountId', 'siteId', 'zoneId'])); + Object.assign(auctionCache.bids[bidId], utils.pick(adUnitMap[adCode], ['accountId', 'siteId', 'zoneId'])); }); let auction = { @@ -232,22 +209,22 @@ function sendMessage(auctionId, bidWonId) { ); } -function parseBidResponse(bid) { - return _pick(bid, [ - 'getCpmInNewCurrency as bidPriceUSD', (fn) => { +export function parseBidResponse(bid) { + return utils.pick(bid, [ + 'bidPriceUSD', () => { if (typeof bid.currency === 'string' && bid.currency.toUpperCase() === 'USD') { return Number(bid.cpm); } // use currency conversion function if present - if (typeof fn === 'function') { - return Number(fn('USD')); + if (typeof bid.getCpmInNewCurrency === 'function') { + return Number(bid.getCpmInNewCurrency('USD')); } - // TODO: throw error or something if not USD and currency module wasn't present? + utils.logWarn('Rubicon Analytics Adapter: Could not determine the bidPriceUSD of the bid ', bid); }, 'dealId', 'status', 'mediaType', - 'dimensions', () => _pick(bid, [ + 'dimensions', () => utils.pick(bid, [ 'width', 'height' ]) @@ -323,7 +300,7 @@ let rubiconAdapter = Object.assign({}, baseAdapter, { case AUCTION_INIT: // set the rubicon aliases setRubiconAliases(adapterManager.aliasRegistry); - let cacheEntry = _pick(args, [ + let cacheEntry = utils.pick(args, [ 'timestamp', 'timeout' ]); @@ -336,7 +313,7 @@ let rubiconAdapter = Object.assign({}, baseAdapter, { // mark adUnits we expect bidWon events for cache.auctions[args.auctionId].bidsWon[bid.adUnitCode] = false; - memo[bid.bidId] = _pick(bid, [ + memo[bid.bidId] = utils.pick(bid, [ 'bidder', bidder => bidder.toLowerCase(), 'bidId', 'status', () => 'no-bid', // default a bid to no-bid until response is recieved or bid is timed out @@ -345,7 +322,7 @@ let rubiconAdapter = Object.assign({}, baseAdapter, { switch (bid.bidder) { // specify bidder params we want here case 'rubicon': - return _pick(params, [ + return utils.pick(params, [ 'accountId', 'siteId', 'zoneId' @@ -376,7 +353,7 @@ let rubiconAdapter = Object.assign({}, baseAdapter, { } } }, - 'adUnit', () => _pick(bid, [ + 'adUnit', () => utils.pick(bid, [ 'adUnitCode', 'transactionId', 'sizes as dimensions', sizes => sizes.map(sizeToDimensions), diff --git a/modules/rubiconBidAdapter.js b/modules/rubiconBidAdapter.js index 034b861f0f7..a1cdfdf8fea 100644 --- a/modules/rubiconBidAdapter.js +++ b/modules/rubiconBidAdapter.js @@ -3,7 +3,7 @@ import {registerBidder} from '../src/adapters/bidderFactory'; import {config} from '../src/config'; import {BANNER, VIDEO} from '../src/mediaTypes'; -const INTEGRATION = 'pbjs_lite_v$prebid.version$'; +const DEFAULT_INTEGRATION = 'pbjs_lite'; function isSecure() { return location.protocol === 'https:'; @@ -14,6 +14,18 @@ export const FASTLANE_ENDPOINT = '//fastlane.rubiconproject.com/a/api/fastlane.j export const VIDEO_ENDPOINT = '//prebid-server.rubiconproject.com/openrtb2/auction'; export const SYNC_ENDPOINT = 'https://eus.rubiconproject.com/usync.html'; +const DIGITRUST_PROP_NAMES = { + FASTLANE: { + id: 'dt.id', + keyv: 'dt.keyv', + pref: 'dt.pref' + }, + PREBID_SERVER: { + id: 'id', + keyv: 'keyv' + } +}; + var sizeMap = { 1: '468x60', 2: '728x90', @@ -25,6 +37,7 @@ var sizeMap = { 14: '250x250', 15: '300x250', 16: '336x280', + 17: '240x400', 19: '300x100', 31: '980x120', 32: '250x360', @@ -70,6 +83,7 @@ var sizeMap = { 126: '200x600', 144: '980x600', 145: '980x150', + 156: '640x320', 159: '320x250', 179: '250x600', 195: '600x300', @@ -79,7 +93,11 @@ var sizeMap = { 214: '980x360', 229: '320x180', 232: '580x400', - 257: '400x600' + 257: '400x600', + 264: '970x1000', + 265: '1920x1080', + 278: '320x500', + 288: '640x380' }; utils._each(sizeMap, (item, key) => sizeMap[item] = key); @@ -98,7 +116,7 @@ export const spec = { for (let i = 0, props = ['accountId', 'siteId', 'zoneId']; i < props.length; i++) { bid.params[props[i]] = parseInt(bid.params[props[i]]) if (isNaN(bid.params[props[i]])) { - utils.logError('Rubicon bid adapter Error: wrong format of accountId or siteId or zoneId.') + utils.logError('Rubicon: wrong format of accountId or siteId or zoneId.') return false } } @@ -151,11 +169,15 @@ export const spec = { includewinners: true, // includebidderkeys always false for openrtb includebidderkeys: false, - priceGranularity: getPriceGranularity(config) + pricegranularity: getPriceGranularity(config) } } } } + const bidFloor = parseFloat(utils.deepAccess(bidRequest, 'params.floor')); + if (!isNaN(bidFloor)) { + data.imp[0].bidfloor = bidFloor; + } // if value is set, will overwrite with same value data.imp[0].ext.rubicon.video.size_id = determineRubiconVideoSizeId(bidRequest) @@ -163,13 +185,9 @@ export const spec = { addVideoParameters(data, bidRequest); - const digiTrust = getDigiTrustQueryParams(); + const digiTrust = _getDigiTrustQueryParams(bidRequest, 'PREBID_SERVER'); if (digiTrust) { - data.user = { - ext: { - digitrust: digiTrust - } - }; + utils.deepSetValue(data, 'user.ext.digitrust', digiTrust); } if (bidderRequest.gdprConsent) { @@ -189,18 +207,39 @@ export const spec = { data.regs = {ext: {gdpr: gdprApplies}}; } - const consentString = bidderRequest.gdprConsent.consentString; - if (data.user) { - if (data.user.ext) { - data.user.ext.consent = consentString; - } else { - data.user.ext = {consent: consentString}; - } - } else { - data.user = {ext: {consent: consentString}}; + utils.deepSetValue(data, 'user.ext.consent', bidderRequest.gdprConsent.consentString); + } + + if (bidRequest.userId && typeof bidRequest.userId === 'object' && + (bidRequest.userId.tdid || bidRequest.userId.pubcid)) { + utils.deepSetValue(data, 'user.ext.eids', []); + + if (bidRequest.userId.tdid) { + data.user.ext.eids.push({ + source: 'adserver.org', + uids: [{ + id: bidRequest.userId.tdid, + ext: { + rtiPartner: 'TDID' + } + }] + }); + } + + if (bidRequest.userId.pubcid) { + data.user.ext.eids.push({ + source: 'pubcommon', + uids: [{ + id: bidRequest.userId.pubcid, + }] + }); } } + if (config.getConfig('coppa') === true) { + utils.deepSetValue(data, 'regs.coppa', 1); + } + return { method: 'POST', url: VIDEO_ENDPOINT, @@ -232,30 +271,30 @@ export const spec = { return groupedBids; }, {}); - requests = videoRequests.concat(Object.keys(groupedBidRequests).map(bidGroupKey => { - let bidsInGroup = groupedBidRequests[bidGroupKey]; - - // fastlane SRA has a limit of 10 slots - if (bidsInGroup.length > 10) { - utils.logWarn(`Rubicon bid adapter Warning: single request mode has a limit of 10 bids: ${bidsInGroup.length - 10} bids were not sent`); - bidsInGroup = bidsInGroup.slice(0, 10); - } - - const combinedSlotParams = spec.combineSlotUrlParams(bidsInGroup.map(bidRequest => { - return spec.createSlotParams(bidRequest, bidderRequest); - })); - - // SRA request returns grouped bidRequest arrays not a plain bidRequest - return { - method: 'GET', - url: FASTLANE_ENDPOINT, - data: spec.getOrderedParams(combinedSlotParams).reduce((paramString, key) => { - const propValue = combinedSlotParams[key]; - return ((utils.isStr(propValue) && propValue !== '') || utils.isNumber(propValue)) ? `${paramString}${key}=${encodeURIComponent(propValue)}&` : paramString; - }, '') + `slots=${bidsInGroup.length}&rand=${Math.random()}`, - bidRequest: bidsInGroup, - }; - })); + // fastlane SRA has a limit of 10 slots + const SRA_BID_LIMIT = 10; + + // multiple requests are used if bids groups have more than 10 bids + requests = videoRequests.concat(Object.keys(groupedBidRequests).reduce((aggregate, bidGroupKey) => { + // for each partioned bidGroup, append a bidRequest to requests list + partitionArray(groupedBidRequests[bidGroupKey], SRA_BID_LIMIT).forEach(bidsInGroup => { + const combinedSlotParams = spec.combineSlotUrlParams(bidsInGroup.map(bidRequest => { + return spec.createSlotParams(bidRequest, bidderRequest); + })); + + // SRA request returns grouped bidRequest arrays not a plain bidRequest + aggregate.push({ + method: 'GET', + url: FASTLANE_ENDPOINT, + data: spec.getOrderedParams(combinedSlotParams).reduce((paramString, key) => { + const propValue = combinedSlotParams[key]; + return ((utils.isStr(propValue) && propValue !== '') || utils.isNumber(propValue)) ? `${paramString}${key}=${encodeURIComponent(propValue)}&` : paramString; + }, '') + `slots=${bidsInGroup.length}&rand=${Math.random()}`, + bidRequest: bidsInGroup + }); + }); + return aggregate; + }, [])); } return requests; }, @@ -348,16 +387,17 @@ export const spec = { const [latitude, longitude] = params.latLong || []; + const configIntType = config.getConfig('rubicon.int_type'); + const data = { 'account_id': params.accountId, 'site_id': params.siteId, 'zone_id': params.zoneId, 'size_id': parsedSizes[0], 'alt_size_ids': parsedSizes.slice(1).join(',') || undefined, - 'p_pos': params.position === 'atf' || params.position === 'btf' ? params.position : 'unknown', 'rp_floor': (params.floor = parseFloat(params.floor)) > 0.01 ? params.floor : 0.01, 'rp_secure': isSecure() ? '1' : '0', - 'tk_flint': INTEGRATION, + 'tk_flint': `${configIntType || DEFAULT_INTEGRATION}_v$prebid.version$`, 'x_source.tid': bidRequest.transactionId, 'p_screen_res': _getScreenResolution(), 'kw': Array.isArray(params.keywords) ? params.keywords.join(',') : '', @@ -368,6 +408,11 @@ export const spec = { 'rf': _getPageUrl(bidRequest, bidderRequest) }; + // add p_pos only if specified and valid + if (params.position === 'atf' || params.position === 'btf') { + data['p_pos'] = params.position; + } + if ((bidRequest.userId || {}).tdid) { data['tpid_tdid'] = bidRequest.userId.tdid; } @@ -399,10 +444,12 @@ export const spec = { } // digitrust properties - const digitrustParams = _getDigiTrustQueryParams(); - Object.keys(digitrustParams).forEach(paramKey => { - data[paramKey] = digitrustParams[paramKey]; - }); + const digitrustParams = _getDigiTrustQueryParams(bidRequest, 'FASTLANE'); + Object.assign(data, digitrustParams); + + if (config.getConfig('coppa') === true) { + data['coppa'] = 1; + } return data; }, @@ -425,9 +472,7 @@ export const spec = { if (responseObj.seatbid) { const responseErrors = utils.deepAccess(responseObj, 'ext.errors.rubicon'); if (Array.isArray(responseErrors) && responseErrors.length > 0) { - responseErrors.forEach(error => { - utils.logError('Got error from PBS Java openRTB: ' + error); - }); + utils.logWarn('Rubicon: Error in video response'); } const bids = []; responseObj.seatbid.forEach(seatbid => { @@ -477,7 +522,7 @@ export const spec = { if (bid.nurl) { bidObject.vastUrl = bid.nurl; } if (!bidObject.vastUrl && bid.nurl) { bidObject.vastUrl = bid.nurl; } } else { - utils.logError('Prebid Server Java openRTB returns response with media type other than video for video request.'); + utils.logWarn('Rubicon: video response received non-video media type'); } bids.push(bidObject); @@ -518,6 +563,9 @@ export const spec = { netRevenue: config.getConfig('rubicon.netRevenue') || false, rubicon: { advertiserId: ad.advertiser, networkId: ad.network + }, + meta: { + advertiserId: ad.advertiser, networkId: ad.network } }; @@ -545,7 +593,7 @@ export const spec = { bids.push(bid); } else { - utils.logError(`Rubicon bid adapter Error: bidRequest undefined at index position:${i}`, bidRequest, responseObj); + utils.logError(`Rubicon: bidRequest undefined at index position:${i}`, bidRequest, responseObj); } return bids; @@ -593,22 +641,36 @@ function _getScreenResolution() { return [window.screen.width, window.screen.height].join('x'); } -function _getDigiTrustQueryParams() { +function _getDigiTrustQueryParams(bidRequest = {}, endpointName) { + if (!endpointName || !DIGITRUST_PROP_NAMES[endpointName]) { + return null; + } + const propNames = DIGITRUST_PROP_NAMES[endpointName]; + function getDigiTrustId() { - let digiTrustUser = window.DigiTrust && (config.getConfig('digiTrustId') || window.DigiTrust.getUser({member: 'T9QSFKPDN9'})); + const bidRequestDigitrust = utils.deepAccess(bidRequest, 'userId.digitrustid.data'); + if (bidRequestDigitrust) { + return bidRequestDigitrust; + } + + let digiTrustUser = (window.DigiTrust && (config.getConfig('digiTrustId') || window.DigiTrust.getUser({member: 'T9QSFKPDN9'}))); return (digiTrustUser && digiTrustUser.success && digiTrustUser.identity) || null; } let digiTrustId = getDigiTrustId(); // Verify there is an ID and this user has not opted out if (!digiTrustId || (digiTrustId.privacy && digiTrustId.privacy.optout)) { - return []; + return null; } - return { - 'dt.id': digiTrustId.id, - 'dt.keyv': digiTrustId.keyv, - 'dt.pref': 0 + + const digiTrustQueryParams = { + [propNames.id]: digiTrustId.id, + [propNames.keyv]: digiTrustId.keyv }; + if (propNames.pref) { + digiTrustQueryParams[propNames.pref] = 0; + } + return digiTrustQueryParams; } /** @@ -664,30 +726,12 @@ function parseSizes(bid, mediaType) { } else if (Array.isArray(bid.sizes) && bid.sizes.length > 0) { sizes = mapSizes(bid.sizes) } else { - utils.logWarn('Warning: no sizes are setup or found'); + utils.logWarn('Rubicon: no sizes are setup or found'); } return masSizeOrdering(sizes); } -function getDigiTrustQueryParams() { - function getDigiTrustId() { - let digiTrustUser = window.DigiTrust && (config.getConfig('digiTrustId') || window.DigiTrust.getUser({member: 'T9QSFKPDN9'})); - return (digiTrustUser && digiTrustUser.success && digiTrustUser.identity) || null; - } - - let digiTrustId = getDigiTrustId(); - // Verify there is an ID and this user has not opted out - if (!digiTrustId || (digiTrustId.privacy && digiTrustId.privacy.optout)) { - return null; - } - return { - id: digiTrustId.id, - keyv: digiTrustId.keyv, - pref: 0 - }; -} - /** * @param {Object} data * @param bidRequest @@ -728,8 +772,14 @@ function addVideoParameters(data, bidRequest) { if (typeof data.imp[0].video === 'object' && data.imp[0].video.skipafter === undefined) { data.imp[0].video.skipafter = bidRequest.params.video.skipdelay; } + // video.pos can already be specified by adunit.mediatypes.video.pos. + // but if not, it might be specified in the params if (typeof data.imp[0].video === 'object' && data.imp[0].video.pos === undefined) { - data.imp[0].video.pos = bidRequest.params.position === 'atf' ? 1 : (bidRequest.params.position === 'btf' ? 3 : 0); + if (bidRequest.params.position === 'atf') { + data.imp[0].video.pos = 1; + } else if (bidRequest.params.position === 'btf') { + data.imp[0].video.pos = 3; + } } const size = parseSizes(bidRequest, 'video') @@ -779,7 +829,7 @@ function bidType(bid, log = false) { // We require either context as instream or outstream if (['outstream', 'instream'].indexOf(utils.deepAccess(bid, `mediaTypes.${VIDEO}.context`)) === -1) { if (log) { - utils.logError('Rubicon bid adapter requires mediaTypes.video.context to be one of outstream or instream'); + utils.logError('Rubicon: mediaTypes.video.context must be outstream or instream'); } return; } @@ -787,13 +837,13 @@ function bidType(bid, log = false) { // we require playerWidth and playerHeight to come from one of params.playerWidth/playerHeight or mediaTypes.video.playerSize or adUnit.sizes if (parseSizes(bid, 'video').length < 2) { if (log) { - utils.logError('Rubicon bid adapter could not determine the playerSize of the video\nplayerWidth and playerHeight are inferred from one of params.playerWidth/playerHeight or mediaTypes.video.playerSize or adUnit.sizes, in that order'); + utils.logError('Rubicon: could not determine the playerSize of the video'); } return; } if (log) { - utils.logMessage('Rubicon bid adapter making video request for adUnit', bid.adUnitCode); + utils.logMessage('Rubicon: making video request for adUnit', bid.adUnitCode); } return 'video'; } else { @@ -801,14 +851,14 @@ function bidType(bid, log = false) { // if we cannot determine them, we reject it! if (parseSizes(bid, 'banner').length === 0) { if (log) { - utils.logError('Rubicon bid adapter could not determine the sizes for a banner request\nThey are inferred from one of params.sizes or mediaTypes.banner.sizes or adUnit.sizes, in that order'); + utils.logError('Rubicon: could not determine the sizes for banner request'); } return; } // everything looks good for banner so lets do it if (log) { - utils.logMessage('Rubicon bid adapter making banner request for adUnit', bid.adUnitCode); + utils.logMessage('Rubicon: making banner request for adUnit', bid.adUnitCode); } return 'banner'; } @@ -891,12 +941,22 @@ export function hasValidVideoParams(bid) { Object.keys(requiredParams).forEach(function(param) { if (Object.prototype.toString.call(utils.deepAccess(bid, 'mediaTypes.video.' + param)) !== requiredParams[param]) { isValid = false; - utils.logError('Rubicon Bid Adapter: mediaTypes.video.' + param + ' is required and must be of type: ' + requiredParams[param]); + utils.logError('Rubicon: mediaTypes.video.' + param + ' is required and must be of type: ' + requiredParams[param]); } }) return isValid; } +/** + * split array into multiple arrays of defined size + * @param {Array} array + * @param {number} size + * @returns {Array} + */ +function partitionArray(array, size) { + return array.map((e, i) => (i % size === 0) ? array.slice(i, i + size) : null).filter((e) => e) +} + var hasSynced = false; export function resetUserSync() { diff --git a/modules/rubiconBidAdapter.md b/modules/rubiconBidAdapter.md index d5beebee31b..540898f792e 100644 --- a/modules/rubiconBidAdapter.md +++ b/modules/rubiconBidAdapter.md @@ -28,14 +28,14 @@ globalsupport@rubiconproject.com for more information. { bidder: "rubicon", params: { - accountId: 1001, - siteId: 113932, - zoneId: 535510 + accountId: 14062, + siteId: 70608, + zoneId: 498816 } } ] },{ - code: 'test-div', + code: 'test-native-size', mediaTypes: { banner: { sizes: [[300, 50]] @@ -45,12 +45,38 @@ globalsupport@rubiconproject.com for more information. { bidder: "rubicon", params: { - accountId: 1001, - siteId: 113932, - zoneId: 535510 + accountId: 14062, + siteId: 70608, + zoneId: 498816 } } ] } ]; + + var videoAdUnit = { + code: 'myVideoAdUnit', + mediaTypes: { + video: { + context: 'instream', + playerSize: [640, 480], + mimes: ['video/mp4', 'video/x-ms-wmv'] + protocols: [2,5], + maxduration:30, + linearity: 1, + api: [2] + } + }, + bids: [{ + bidder: 'rubicon', + params: { + accountId: '7780', + siteId: '87184', + zoneId: '412394', + video: { + language: 'en' + } + } + }] +}; ``` diff --git a/modules/s2sTesting.js b/modules/s2sTesting.js index ae68fc3b9f6..eccc3aa1f8a 100644 --- a/modules/s2sTesting.js +++ b/modules/s2sTesting.js @@ -11,6 +11,7 @@ s2sTesting.CLIENT = CLIENT; var testing = false; // whether testing is turned on var bidSource = {}; // store bidder sources determined from s2sConfing bidderControl +s2sTesting.globalRand = Math.random(); // if 10% of bidderA and 10% of bidderB should be server-side, make it the same 10% // load s2sConfig config.getConfig('s2sConfig', config => { @@ -82,7 +83,7 @@ s2sTesting.getSource = function(sourceWeights = {}, bidSources = [SERVER, CLIENT }); if (!totWeight) return; // bail if no source weights // choose a source randomly based on weights - var rndWeight = Math.random() * totWeight; + var rndWeight = s2sTesting.globalRand * totWeight; for (var i = 0; i < bidSources.length; i++) { let source = bidSources[i]; // choose the first source with an incremental weight > random weight diff --git a/modules/saraBidAdapter.md b/modules/saraBidAdapter.md old mode 100755 new mode 100644 diff --git a/modules/scaleableAnalyticsAdapter.js b/modules/scaleableAnalyticsAdapter.js new file mode 100644 index 00000000000..c875dab7e18 --- /dev/null +++ b/modules/scaleableAnalyticsAdapter.js @@ -0,0 +1,153 @@ +/* COPYRIGHT SCALEABLE LLC 2019 */ + +import { ajax } from '../src/ajax'; +import CONSTANTS from '../src/constants.json'; +import adapter from '../src/AnalyticsAdapter'; +import adapterManager from '../src/adapterManager'; +import * as utils from '../src/utils'; + +const BID_TIMEOUT = CONSTANTS.EVENTS.BID_TIMEOUT; +const AUCTION_INIT = CONSTANTS.EVENTS.AUCTION_INIT; +const BID_RESPONSE = CONSTANTS.EVENTS.BID_RESPONSE; +const BID_WON = CONSTANTS.EVENTS.BID_WON; +const AUCTION_END = CONSTANTS.EVENTS.AUCTION_END; + +const URL = 'https://auction.scaleable.ai/'; +const ANALYTICS_TYPE = 'endpoint'; + +let auctionData = {}; + +let scaleableAnalytics = Object.assign({}, + adapter({ + URL, + ANALYTICS_TYPE + }), + { + // Override AnalyticsAdapter functions by supplying custom methods + track({ eventType, args }) { + switch (eventType) { + case AUCTION_INIT: + onAuctionInit(args); + break; + case AUCTION_END: + onAuctionEnd(args); + break; + case BID_WON: + onBidWon(args); + break; + case BID_RESPONSE: + onBidResponse(args); + break; + case BID_TIMEOUT: + onBidTimeout(args); + break; + default: + break; + } + } + } +); + +scaleableAnalytics.config = {}; +scaleableAnalytics.originEnableAnalytics = scaleableAnalytics.enableAnalytics; +scaleableAnalytics.enableAnalytics = config => { + scaleableAnalytics.config = config; + + scaleableAnalytics.originEnableAnalytics(config); + + scaleableAnalytics.enableAnalytics = function _enable() { + return utils.logMessage(`Analytics adapter for "${global}" already enabled, unnecessary call to \`enableAnalytics\`.`); + }; +} + +scaleableAnalytics.getAuctionData = () => { + return auctionData; +}; + +const sendDataToServer = data => ajax(URL, () => {}, JSON.stringify(data)); + +// Track auction initiated +const onAuctionInit = args => { + const config = scaleableAnalytics.config || {options: {}}; + + for (let idx = args.adUnitCodes.length; idx--;) { + const data = { + event: 'request', + site: config.options.site, + adunit: args.adUnitCodes[idx] + }; + + sendDataToServer(data); + } +} + +// Handle all events besides requests and wins +const onAuctionEnd = args => { + for (let adunit in auctionData) { + sendDataToServer(auctionData[adunit]); + } +} + +// Bid Win Events occur after auction end +const onBidWon = args => { + const config = scaleableAnalytics.config || {options: {}}; + + const data = { + event: 'win', + site: config.options.site, + adunit: args.adUnitCode, + code: args.bidderCode, + cpm: args.cpm, + ttr: args.timeToRespond + }; + + sendDataToServer(data); +} + +const onBidResponse = args => { + const config = scaleableAnalytics.config || {options: {}}; + + if (!auctionData[args.adUnitCode]) { + auctionData[args.adUnitCode] = { + event: 'bids', + bids: [], + adunit: args.adUnitCode, + site: config.options.site + }; + } + + const currBidData = { + code: args.bidderCode, + cpm: args.cpm, + ttr: args.timeToRespond + }; + + auctionData[args.adUnitCode].bids.push(currBidData); +} + +const onBidTimeout = args => { + const config = scaleableAnalytics.config || {options: {}}; + + for (let i = args.length; i--;) { + let currObj = args[i]; + + if (!auctionData[currObj.adUnitCode]) { + auctionData[currObj.adUnitCode] = { + event: 'bids', + bids: [], + timeouts: [], + adunit: currObj.adUnitCode, + site: config.options.site + }; + } + + auctionData[currObj.adUnitCode].timeouts.push(currObj.bidder); + } +} + +adapterManager.registerAnalyticsAdapter({ + adapter: scaleableAnalytics, + code: 'scaleable' +}) + +export default scaleableAnalytics; diff --git a/modules/scaleableAnalyticsAdapter.md b/modules/scaleableAnalyticsAdapter.md new file mode 100644 index 00000000000..0f6fbada55a --- /dev/null +++ b/modules/scaleableAnalyticsAdapter.md @@ -0,0 +1,20 @@ +# Overview + +Module Name: Scaleable Analytics Adapter +Module Type: Analytics Adapter +Maintainer: chris@scaleable.ai + +# Description + +Analytics adapter for scaleable.ai. Contact team@scaleable.ai for more information or to sign up for analytics. + +# Implementation Code + +``` +pbjs.enableAnalytics({ + provider: 'scaleable', + options: { + site: '' // Contact Scaleable to receive your unique site id + } +}); +``` diff --git a/modules/schain.js b/modules/schain.js new file mode 100644 index 00000000000..a5797ba4b39 --- /dev/null +++ b/modules/schain.js @@ -0,0 +1,155 @@ +import {config} from '../src/config'; +import {getGlobal} from '../src/prebidGlobal'; +import { isNumber, isStr, isArray, isPlainObject, hasOwn, logError, isInteger } from '../src/utils'; + +// https://github.com/InteractiveAdvertisingBureau/openrtb/blob/master/supplychainobject.md + +const schainErrorPrefix = 'Invalid schain object found: '; +const shouldBeAString = ' should be a string'; +const shouldBeAnInteger = ' should be an Integer'; +const shouldBeAnObject = ' should be an object'; +const shouldBeAnArray = ' should be an Array'; +const MODE = { + STRICT: 'strict', + RELAXED: 'relaxed', + OFF: 'off' +}; + +// validate the supply chain object +export function isSchainObjectValid(schainObject, returnOnError) { + if (!isPlainObject(schainObject)) { + logError(schainErrorPrefix + `schain` + shouldBeAnObject); + if (returnOnError) return false; + } + + // complete: Integer + if (!isNumber(schainObject.complete) || !isInteger(schainObject.complete)) { + logError(schainErrorPrefix + `schain.complete` + shouldBeAnInteger); + if (returnOnError) return false; + } + + // ver: String + if (!isStr(schainObject.ver)) { + logError(schainErrorPrefix + `schain.ver` + shouldBeAString); + if (returnOnError) return false; + } + + // ext: Object [optional] + if (hasOwn(schainObject, 'ext')) { + if (!isPlainObject(schainObject.ext)) { + logError(schainErrorPrefix + `schain.ext` + shouldBeAnObject); + if (returnOnError) return false; + } + } + + // nodes: Array of objects + let isEachNodeIsValid = true; + if (!isArray(schainObject.nodes)) { + logError(schainErrorPrefix + `schain.nodes` + shouldBeAnArray); + if (returnOnError) return false; + } else { + schainObject.nodes.forEach(node => { + // asi: String + if (!isStr(node.asi)) { + isEachNodeIsValid = isEachNodeIsValid && false; + logError(schainErrorPrefix + `schain.nodes[].asi` + shouldBeAString); + } + + // sid: String + if (!isStr(node.sid)) { + isEachNodeIsValid = isEachNodeIsValid && false; + logError(schainErrorPrefix + `schain.nodes[].sid` + shouldBeAString); + } + + // hp: Integer + if (!isNumber(node.hp) || !isInteger(node.hp)) { + isEachNodeIsValid = isEachNodeIsValid && false; + logError(schainErrorPrefix + `schain.nodes[].hp` + shouldBeAnInteger); + } + + // rid: String [Optional] + if (hasOwn(node, 'rid')) { + if (!isStr(node.rid)) { + isEachNodeIsValid = isEachNodeIsValid && false; + logError(schainErrorPrefix + `schain.nodes[].rid` + shouldBeAString); + } + } + + // name: String [Optional] + if (hasOwn(node, 'name')) { + if (!isStr(node.name)) { + isEachNodeIsValid = isEachNodeIsValid && false; + logError(schainErrorPrefix + `schain.nodes[].name` + shouldBeAString); + } + } + + // domain: String [Optional] + if (hasOwn(node, 'domain')) { + if (!isStr(node.domain)) { + isEachNodeIsValid = isEachNodeIsValid && false; + logError(schainErrorPrefix + `schain.nodes[].domain` + shouldBeAString); + } + } + + // ext: Object [Optional] + if (hasOwn(node, 'ext')) { + if (!isPlainObject(node.ext)) { + isEachNodeIsValid = isEachNodeIsValid && false; + logError(schainErrorPrefix + `schain.nodes[].ext` + shouldBeAnObject); + } + } + }); + } + + if (returnOnError && !isEachNodeIsValid) { + return false; + } + + return true; +} + +export function copySchainObjectInAdunits(adUnits, schainObject) { + // copy schain object in all adUnits as adUnits[].bid.schain + adUnits.forEach(adUnit => { + adUnit.bids.forEach(bid => { + bid.schain = schainObject; + }); + }); +} + +export function isValidSchainConfig(schainObject) { + if (schainObject === undefined) { + return false; + } + if (!isPlainObject(schainObject)) { + logError(schainErrorPrefix + 'schain config will not be passed to bidders as schain is not an object.'); + return false; + } + return true; +} + +export function init(config) { + let mode = MODE.STRICT; + getGlobal().requestBids.before(function(fn, reqBidsConfigObj) { + let schainObject = config.getConfig('schain'); + if (isValidSchainConfig(schainObject)) { + if (isStr(schainObject.validation) && Object.values(MODE).indexOf(schainObject.validation) != -1) { + mode = schainObject.validation; + } + if (mode === MODE.OFF) { + // no need to validate + copySchainObjectInAdunits(reqBidsConfigObj.adUnits || getGlobal().adUnits, schainObject.config); + } else { + if (isSchainObjectValid(schainObject.config, mode === MODE.STRICT)) { + copySchainObjectInAdunits(reqBidsConfigObj.adUnits || getGlobal().adUnits, schainObject.config); + } else { + logError(schainErrorPrefix + 'schain config will not be passed to bidders as it is not valid.'); + } + } + } + // calling fn allows prebid to continue processing + return fn.call(this, reqBidsConfigObj); + }, 40); +} + +init(config) diff --git a/modules/schain.md b/modules/schain.md new file mode 100644 index 00000000000..f43cf0f0d07 --- /dev/null +++ b/modules/schain.md @@ -0,0 +1,51 @@ +# schain module + +Aggregators who manage Prebid wrappers on behalf of multiple publishers and handle payment on behalf of the publishers +need to declare their intermediary status in the Supply Chain Object. As the Supply Chain Object spec prohibits SSPs from adding +upstream intermediaries, Prebid requests in this case need to come with the schain information. In this use case, it's cumbersome +to have every bidder in the wrapper separately configured the same schain information. + +Refer: +- https://iabtechlab.com/sellers-json/ +- https://github.com/InteractiveAdvertisingBureau/openrtb/blob/master/supplychainobject.md + +## Sample code for passing the schain object +``` +pbjs.setConfig( { + "schain": { + "validation": "strict", + "config": { + "ver":"1.0", + "complete": 1, + "nodes": [ + { + "asi":"indirectseller.com", + "sid":"00001", + "hp":1 + }, + + { + "asi":"indirectseller-2.com", + "sid":"00002", + "hp":1 + } + ] + } + } +}); +``` + +## Workflow +The schain module is not enabled by default as it may not be necessary for all publishers. +If required, schain module can be included as following +``` + $ gulp build --modules=schain,pubmaticBidAdapter,openxBidAdapter,rubiconBidAdapter,sovrnBidAdapter +``` +The schain module will validate the schain object passed using pbjs.setConfig API. +If the schain object is valid then it will be passed on to bidders/adapters in ```validBidRequests[].schain``` +You may refer pubmaticBidAdapter implementaion for the same. + +## Validation modes +- ```strict```: It is the default validation mode. In this mode, schain object will not be passed to adapters if it is invalid. Errors are thrown for invalid schain object. +- ```relaxed```: In this mode, errors are thrown for an invalid schain object but the invalid schain object is still passed to adapters. +- ```off```: In this mode, no validations are performed and schain object is passed as is to adapters. diff --git a/modules/seedtagBidAdapter.js b/modules/seedtagBidAdapter.js new file mode 100644 index 00000000000..845d8ffec9d --- /dev/null +++ b/modules/seedtagBidAdapter.js @@ -0,0 +1,205 @@ +import * as utils from '../src/utils' +import { registerBidder } from '../src/adapters/bidderFactory' +import { VIDEO, BANNER } from '../src/mediaTypes' + +const BIDDER_CODE = 'seedtag'; +const SEEDTAG_ALIAS = 'st'; +const SEEDTAG_SSP_ENDPOINT = 'https://s.seedtag.com/c/hb/bid'; +const SEEDTAG_SSP_ONTIMEOUT_ENDPOINT = 'https://s.seedtag.com/se/hb/timeout'; + +const mediaTypesMap = { + [BANNER]: 'display', + [VIDEO]: 'video' +}; + +function mapMediaType(seedtagMediaType) { + if (seedtagMediaType === 'display') return BANNER; + if (seedtagMediaType === 'video') return VIDEO; + else return seedtagMediaType; +} + +function getMediaTypeFromBid(bid) { + return bid.mediaTypes && Object.keys(bid.mediaTypes)[0] +} + +function hasMandatoryParams(params) { + return ( + !!params.publisherId && + !!params.adUnitId && + !!params.placement && + (params.placement === 'inImage' || + params.placement === 'inScreen' || + params.placement === 'banner' || + params.placement === 'video') + ); +} + +function hasVideoMandatoryParams(mediaTypes) { + const isVideoInStream = + !!mediaTypes.video && mediaTypes.video.context === 'instream'; + const isPlayerSize = + !!utils.deepAccess(mediaTypes, 'video.playerSize') && + utils.isArray(utils.deepAccess(mediaTypes, 'video.playerSize')); + return isVideoInStream && isPlayerSize; +} + +function buildBidRequests(validBidRequests) { + return utils._map(validBidRequests, function(validBidRequest) { + const params = validBidRequest.params; + const mediaTypes = utils._map( + Object.keys(validBidRequest.mediaTypes), + function(pbjsType) { + return mediaTypesMap[pbjsType]; + } + ); + const bidRequest = { + id: validBidRequest.bidId, + transactionId: validBidRequest.transactionId, + sizes: validBidRequest.sizes, + supplyTypes: mediaTypes, + adUnitId: params.adUnitId, + placement: params.placement + }; + + if (params.adPosition) { + bidRequest.adPosition = params.adPosition; + } + + if (params.video) { + bidRequest.videoParams = params.video || {}; + bidRequest.videoParams.w = + validBidRequest.mediaTypes.video.playerSize[0][0]; + bidRequest.videoParams.h = + validBidRequest.mediaTypes.video.playerSize[0][1]; + } + + return bidRequest; + }) +} + +function buildBid(seedtagBid) { + const mediaType = mapMediaType(seedtagBid.mediaType); + const bid = { + requestId: seedtagBid.bidId, + cpm: seedtagBid.price, + width: seedtagBid.width, + height: seedtagBid.height, + creativeId: seedtagBid.creativeId, + currency: seedtagBid.currency, + netRevenue: true, + mediaType: mediaType, + ttl: seedtagBid.ttl + }; + if (mediaType === VIDEO) { + bid.vastXml = seedtagBid.content; + } else { + bid.ad = seedtagBid.content; + } + return bid; +} + +export function getTimeoutUrl (data) { + let queryParams = ''; + if ( + utils.isArray(data) && data[0] && + utils.isArray(data[0].params) && data[0].params[0] + ) { + const params = data[0].params[0]; + queryParams = + '?publisherToken=' + params.publisherId + + '&adUnitId=' + params.adUnitId; + } + return SEEDTAG_SSP_ONTIMEOUT_ENDPOINT + queryParams; +} + +export const spec = { + code: BIDDER_CODE, + aliases: [SEEDTAG_ALIAS], + supportedMediaTypes: [BANNER, VIDEO], + + /** + * Determines whether or not the given bid request is valid. + * + * @param {BidRequest} bid The bid params to validate. + * @return boolean True if this is a valid bid, and false otherwise. + */ + isBidRequestValid(bid) { + return getMediaTypeFromBid(bid) === VIDEO + ? hasMandatoryParams(bid.params) && hasVideoMandatoryParams(bid.mediaTypes) + : hasMandatoryParams(bid.params); + }, + + /** + * Make a server request from the list of BidRequests. + * + * @param {validBidRequests[]} - an array of bids + * @return ServerRequest Info describing the request to the server. + */ + buildRequests(validBidRequests, bidderRequest) { + const payload = { + url: bidderRequest.refererInfo.referer, + publisherToken: validBidRequests[0].params.publisherId, + cmp: !!bidderRequest.gdprConsent, + timeout: bidderRequest.timeout, + version: '$prebid.version$', + bidRequests: buildBidRequests(validBidRequests) + }; + + if (payload.cmp) { + const gdprApplies = bidderRequest.gdprConsent.gdprApplies; + if (gdprApplies !== undefined) payload['ga'] = gdprApplies; + payload['cd'] = bidderRequest.gdprConsent.consentString; + } + + const payloadString = JSON.stringify(payload) + return { + method: 'POST', + url: SEEDTAG_SSP_ENDPOINT, + data: payloadString + } + }, + + /** + * Unpack the response from the server into a list of bids. + * + * @param {ServerResponse} serverResponse A successful response from the server. + * @return {Bid[]} An array of bids which were nested inside the server. + */ + interpretResponse: function(serverResponse) { + const serverBody = serverResponse.body; + if (serverBody && serverBody.bids && utils.isArray(serverBody.bids)) { + return utils._map(serverBody.bids, function(bid) { + return buildBid(bid); + }); + } else { + return []; + } + }, + + /** + * Register the user sync pixels which should be dropped after the auction. + * + * @param {SyncOptions} syncOptions Which user syncs are allowed? + * @param {ServerResponse[]} serverResponses List of server's responses. + * @return {UserSync[]} The user syncs which should be dropped. + */ + getUserSyncs(syncOptions, serverResponses) { + const serverResponse = serverResponses[0]; + if (syncOptions.iframeEnabled && serverResponse) { + const cookieSyncUrl = serverResponse.body.cookieSync; + return cookieSyncUrl ? [{ type: 'iframe', url: cookieSyncUrl }] : []; + } else { + return []; + } + }, + + /** + * Register bidder specific code, which will execute if bidder timed out after an auction + * @param {data} Containing timeout specific data + */ + onTimeout(data) { + getTimeoutUrl(data); + utils.triggerPixel(SEEDTAG_SSP_ONTIMEOUT_ENDPOINT); + } +} +registerBidder(spec); diff --git a/modules/seedtagBidAdapter.md b/modules/seedtagBidAdapter.md new file mode 100644 index 00000000000..627ff8333ad --- /dev/null +++ b/modules/seedtagBidAdapter.md @@ -0,0 +1,79 @@ +# Overview + +``` +Module Name: Seedtag Bidder Adapter +Module Type: Bidder Adapter +Maintainer: prebid@seedtag.com +``` + +# Description + +Module that connects to Seedtag demand sources to fetch bids. + +# Test Parameters + +## Sample Banner Ad Unit + +```js +const adUnits = [ + { + code: '/21804003197/prebid_test_300x250', + mediaTypes: { + banner: { + sizes: [[300, 250]] + } + }, + bids: [ + { + bidder: 'seedtag', + params: { + publisherId: '0000-0000-01', // required + adUnitId: '0000', // required + placement: 'banner', // required + adPosition: 0 // optional + } + } + ] + } +] +``` + +## Sample inStream Video Ad Unit + +```js +var adUnits = [{ + code: 'video', + mediaTypes: { + video: { + context: 'instream', // required + playerSize: [600, 300] // required + } + }, + bids: [ + { + bidder: 'seedtag', + params: { + publisherId: '0000-0000-01', // required + adUnitId: '0000', // required + placement: 'video', // required + adPosition: 0, // optional + // Video object as specified in OpenRTB 2.5 + video: { + mimes: ['video/mp4'], // recommended + minduration: 5, // optional + maxduration: 60, // optional + boxingallowed: 1, // optional + skip: 1, // optional + startdelay: 1, // optional + linearity: 1, // optional + battr: [1, 2], // optional + maxbitrate: 10, // optional + playbackmethod: [1], // optional + delivery: [1], // optional + placement: 1, // optional + } + } + } + ] +}]; +``` diff --git a/modules/sekindoUMBidAdapter.md b/modules/sekindoUMBidAdapter.md old mode 100755 new mode 100644 diff --git a/modules/serverbidBidAdapter.js b/modules/serverbidBidAdapter.js index 037721061e2..faeeafdd53f 100644 --- a/modules/serverbidBidAdapter.js +++ b/modules/serverbidBidAdapter.js @@ -16,9 +16,6 @@ const CONFIG = { 'insticator': { 'BASE_URI': 'https://e.serverbid.com/api/v2' }, - 'adsparc': { - 'BASE_URI': 'https://e.serverbid.com/api/v2' - }, 'automatad': { 'BASE_URI': 'https://e.serverbid.com/api/v2' }, @@ -38,7 +35,7 @@ let bidder = 'serverbid'; export const spec = { code: BIDDER_CODE, - aliases: ['connectad', 'onefiftytwo', 'insticator', 'adsparc', 'automatad', 'archon', 'buysellads', 'answermedia'], + aliases: ['connectad', 'onefiftytwo', 'insticator', 'automatad', 'archon', 'buysellads', 'answermedia'], /** * Determines whether or not the given bid request is valid. diff --git a/modules/sharethroughBidAdapter.js b/modules/sharethroughBidAdapter.js index ec97649df6d..7fe41b2b7ae 100644 --- a/modules/sharethroughBidAdapter.js +++ b/modules/sharethroughBidAdapter.js @@ -1,8 +1,16 @@ import { registerBidder } from '../src/adapters/bidderFactory'; -const VERSION = '3.0.1'; +const VERSION = '3.1.0'; const BIDDER_CODE = 'sharethrough'; -const STR_ENDPOINT = document.location.protocol + '//btlr.sharethrough.com/header-bid/v1'; +const STR_ENDPOINT = document.location.protocol + '//btlr.sharethrough.com/WYu2BXv1/v1'; +const DEFAULT_SIZE = [1, 1]; + +// this allows stubbing of utility function that is used internally by the sharethrough adapter +export const sharethroughInternal = { + b64EncodeUnicode, + handleIframe, + isLockedInFrame +}; export const sharethroughAdapterSpec = { code: BIDDER_CODE, @@ -10,10 +18,10 @@ export const sharethroughAdapterSpec = { isBidRequestValid: bid => !!bid.params.pkey && bid.bidder === BIDDER_CODE, buildRequests: (bidRequests, bidderRequest) => { - return bidRequests.map(bid => { + return bidRequests.map(bidRequest => { let query = { - placement_key: bid.params.pkey, - bidId: bid.bidId, + placement_key: bidRequest.params.pkey, + bidId: bidRequest.bidId, consent_required: false, instant_play_capable: canAutoPlayHTML5Video(), hbSource: 'prebid', @@ -29,13 +37,17 @@ export const sharethroughAdapterSpec = { query.consent_required = !!bidderRequest.gdprConsent.gdprApplies; } + if (bidRequest.userId && bidRequest.userId.tdid) { + query.ttduid = bidRequest.userId.tdid; + } + // Data that does not need to go to the server, // but we need as part of interpretResponse() const strData = { - stayInIframe: bid.params.iframe, - iframeSize: bid.params.iframeSize, - sizes: bid.sizes - } + skipIframeBusting: bidRequest.params.iframe, + iframeSize: bidRequest.params.iframeSize, + sizes: bidRequest.sizes + }; return { method: 'GET', @@ -52,9 +64,9 @@ export const sharethroughAdapterSpec = { } const creative = body.creatives[0]; - let size = [0, 0]; - if (req.strData.stayInIframe) { - size = req.strData.iframeSize != undefined + let size = DEFAULT_SIZE; + if (req.strData.iframeSize || req.strData.sizes.length) { + size = req.strData.iframeSize ? req.strData.iframeSize : getLargestSize(req.strData.sizes); } @@ -76,9 +88,9 @@ export const sharethroughAdapterSpec = { getUserSyncs: (syncOptions, serverResponses) => { const syncs = []; const shouldCookieSync = syncOptions.pixelEnabled && - serverResponses.length > 0 && - serverResponses[0].body && - serverResponses[0].body.cookieSyncUrls; + serverResponses.length > 0 && + serverResponses[0].body && + serverResponses[0].body.cookieSyncUrls; if (shouldCookieSync) { serverResponses[0].body.cookieSyncUrls.forEach(url => { @@ -87,8 +99,17 @@ export const sharethroughAdapterSpec = { } return syncs; - } -} + }, + + // Empty implementation for prebid core to be able to find it + onTimeout: (data) => {}, + + // Empty implementation for prebid core to be able to find it + onBidWon: (bid) => {}, + + // Empty implementation for prebid core to be able to find it + onSetTargeting: (bid) => {} +}; function getLargestSize(sizes) { function area(size) { @@ -101,7 +122,7 @@ function getLargestSize(sizes) { } else { return prev } - }, [0, 0]); + }); } function generateAd(body, req) { @@ -111,35 +132,72 @@ function generateAd(body, req) {
    - ` + `; - if (req.strData.stayInIframe) { + if (req.strData.skipIframeBusting) { // Don't break out of iframe - adMarkup = adMarkup + `` + adMarkup = adMarkup + ``; } else { - // Break out of iframe + // Add logic to the markup that detects whether or not in top level document is accessible + // this logic will deploy sfp.js and/or iframe buster script(s) as appropriate adMarkup = adMarkup + ` - ` + (${sharethroughInternal.isLockedInFrame.toString()})() + + `; } return adMarkup; } +function handleIframe () { + // only load iframe buster JS if we can access the top level document + // if we are 'locked in' to this frame then no point trying to bust out: we may as well render in the frame instead + var iframeBusterLoaded = false; + if (!window.lockedInFrame) { + var sfpIframeBusterJs = document.createElement('script'); + sfpIframeBusterJs.src = '//native.sharethrough.com/assets/sfp-set-targeting.js'; + sfpIframeBusterJs.type = 'text/javascript'; + try { + window.document.getElementsByTagName('body')[0].appendChild(sfpIframeBusterJs); + iframeBusterLoaded = true; + } catch (e) { + console.error(e); + } + } + + var clientJsLoaded = (!iframeBusterLoaded) ? !!(window.STR && window.STR.Tag) : !!(window.top.STR && window.top.STR.Tag); + if (!clientJsLoaded) { + var sfpJs = document.createElement('script'); + sfpJs.src = '//native.sharethrough.com/assets/sfp.js'; + sfpJs.type = 'text/javascript'; + + // only add sfp js to window.top if iframe busting successfully loaded; otherwise, add to iframe + try { + if (iframeBusterLoaded) { + window.top.document.getElementsByTagName('body')[0].appendChild(sfpJs); + } else { + window.document.getElementsByTagName('body')[0].appendChild(sfpJs); + } + } catch (e) { + console.error(e); + } + } +} + +// determines if we are capable of busting out of the iframe we are in +// if we catch a DOMException when trying to access top-level document, it means we're stuck in the frame we're in +function isLockedInFrame () { + window.lockedInFrame = false; + try { + window.lockedInFrame = !window.top.document; + } catch (e) { + window.lockedInFrame = (e instanceof DOMException); + } +} + // See https://developer.mozilla.org/en-US/docs/Web/API/WindowBase64/Base64_encoding_and_decoding#The_Unicode_Problem function b64EncodeUnicode(str) { return btoa( diff --git a/modules/sharethroughBidAdapter.md b/modules/sharethroughBidAdapter.md index ab183a41496..2290e370cae 100644 --- a/modules/sharethroughBidAdapter.md +++ b/modules/sharethroughBidAdapter.md @@ -3,7 +3,7 @@ ``` Module Name: Sharethrough Bidder Adapter Module Type: Bidder Adapter -Maintainer: jchau@sharethrough.com && cpan@sharethrough.com +Maintainer: pubgrowth.engineering@sharethrough.com ``` # Description diff --git a/modules/slimcutBidAdapter.js b/modules/slimcutBidAdapter.js new file mode 100644 index 00000000000..1f52e2cbc30 --- /dev/null +++ b/modules/slimcutBidAdapter.js @@ -0,0 +1,128 @@ +import * as utils from '../src/utils'; +import { registerBidder } from '../src/adapters/bidderFactory'; +import { ajax } from '../src/ajax'; + +const BIDDER_CODE = 'slimcut'; +const ENDPOINT_URL = '//sb.freeskreen.com/pbr'; + +export const spec = { + code: BIDDER_CODE, + aliases: ['scm'], + supportedMediaTypes: ['video', 'banner'], + + /** + * Determines whether or not the given bid request is valid. + * + * @param {BidRequest} bid The bid params to validate. + * @return boolean True if this is a valid bid, and false otherwise. + */ + isBidRequestValid: function(bid) { + let isValid = false; + if (typeof bid.params !== 'undefined' && !isNaN(parseInt(utils.getValue(bid.params, 'placementId'))) && parseInt(utils.getValue(bid.params, 'placementId')) > 0) { + isValid = true; + } + return isValid; + }, + + /** + * Make a server request from the list of BidRequests. + * + * @param {validBidRequests[]} an array of bids + * @return ServerRequest Info describing the request to the server. + */ + buildRequests: function(validBidRequests, bidderRequest) { + const bids = validBidRequests.map(buildRequestObject); + const payload = { + referrer: getReferrerInfo(bidderRequest), + data: bids, + deviceWidth: screen.width + }; + + let gdpr = bidderRequest.gdprConsent; + if (bidderRequest && gdpr) { + let isCmp = (typeof gdpr.gdprApplies === 'boolean') + let isConsentString = (typeof gdpr.consentString === 'string') + payload.gdpr_iab = { + consent: isConsentString ? gdpr.consentString : '', + status: isCmp ? gdpr.gdprApplies : -1 + }; + } + + const payloadString = JSON.stringify(payload); + return { + method: 'POST', + url: ENDPOINT_URL, + data: payloadString, + }; + }, + + /** + * Unpack the response from the server into a list of bids. + * + * @param {*} serverResponse A successful response from the server. + * @return {Bid[]} An array of bids which were nested inside the server. + */ + interpretResponse: function(serverResponse, request) { + const bidResponses = []; + serverResponse = serverResponse.body; + + if (serverResponse.responses) { + serverResponse.responses.forEach(function (bid) { + const bidResponse = { + cpm: bid.cpm, + width: bid.width, + height: bid.height, + currency: bid.currency, + netRevenue: bid.netRevenue, + ttl: bid.ttl, + ad: bid.ad, + requestId: bid.requestId, + creativeId: bid.creativeId, + transactionId: bid.tranactionId, + winUrl: bid.winUrl + }; + bidResponses.push(bidResponse); + }); + } + return bidResponses; + }, + + getUserSyncs: function(syncOptions, serverResponses) { + if (syncOptions.iframeEnabled) { + return [{ + type: 'iframe', + url: '//sb.freeskreen.com/async_usersync.html' + }]; + } + return []; + }, + + onBidWon: function(bid) { + ajax(bid.winUrl + bid.cpm, null); + } +} + +function buildRequestObject(bid) { + const reqObj = {}; + let placementId = utils.getValue(bid.params, 'placementId'); + + reqObj.sizes = utils.parseSizesInput(bid.sizes); + reqObj.bidId = utils.getBidIdParameter('bidId', bid); + reqObj.bidderRequestId = utils.getBidIdParameter('bidderRequestId', bid); + reqObj.placementId = parseInt(placementId); + reqObj.adUnitCode = utils.getBidIdParameter('adUnitCode', bid); + reqObj.auctionId = utils.getBidIdParameter('auctionId', bid); + reqObj.transactionId = utils.getBidIdParameter('transactionId', bid); + + return reqObj; +} + +function getReferrerInfo(bidderRequest) { + let ref = window.location.href; + if (bidderRequest && bidderRequest.refererInfo && bidderRequest.refererInfo.referer) { + ref = bidderRequest.refererInfo.referer; + } + return ref; +} + +registerBidder(spec); diff --git a/modules/slimcutBidAdapter.md b/modules/slimcutBidAdapter.md new file mode 100644 index 00000000000..1d83c8cae6f --- /dev/null +++ b/modules/slimcutBidAdapter.md @@ -0,0 +1,45 @@ +# Overview + +**Module Name**: Slimcut Bidder Adapter +**Module Type**: Bidder Adapter +**Maintainer**: support@slimcut.com + +# Description + +Use `slimcut` as bidder. + +`placementId` is required and must be integer. + +The Slimcut adapter requires setup and approval from the Slimcut team. +Please reach out to your account manager for more information. + +# Test Parameters + +``` + var adUnits = [ + { + code: 'test-div', + sizes: [[640, 480]], + bids: [ + { + bidder: "slimcut", + params: { + placementId: 1234 + } + } + ] + } + ]; +``` + +## UserSync example + +``` +pbjs.setConfig({ + userSync: { + iframeEnabled: true, + syncEnabled: true, + syncDelay: 1 + } +}); +``` diff --git a/modules/smartadserverBidAdapter.js b/modules/smartadserverBidAdapter.js index 00d617b3c92..401c72bffaf 100644 --- a/modules/smartadserverBidAdapter.js +++ b/modules/smartadserverBidAdapter.js @@ -16,7 +16,7 @@ export const spec = { * @return boolean True if this is a valid bid, and false otherwise. */ isBidRequestValid: function (bid) { - return !!(bid.params && bid.params.siteId && bid.params.pageId && bid.params.formatId && bid.params.domain); + return !!(bid.params && bid.params.siteId && bid.params.pageId && bid.params.formatId); }, /** * Make a server request from the list of BidRequests. @@ -63,7 +63,7 @@ export const spec = { var payloadString = JSON.stringify(payload); return { method: 'POST', - url: bid.params.domain + '/prebid/v1', + url: (bid.params.domain !== undefined ? bid.params.domain : 'https://prg.smartadserver.com') + '/prebid/v1', data: payloadString, }; }); diff --git a/modules/smartrtbBidAdapter.js b/modules/smartrtbBidAdapter.js index 561ce58e016..1cdef1c474b 100644 --- a/modules/smartrtbBidAdapter.js +++ b/modules/smartrtbBidAdapter.js @@ -1,5 +1,5 @@ -import * as utils from 'src/utils'; -import {registerBidder} from 'src/adapters/bidderFactory'; +import * as utils from '../src/utils'; +import {registerBidder} from '../src/adapters/bidderFactory'; const BIDDER_CODE = 'smartrtb'; function getDomain () { diff --git a/modules/smilewantedBidAdapter.js b/modules/smilewantedBidAdapter.js index bf9a75b6650..ed7e02a51a8 100644 --- a/modules/smilewantedBidAdapter.js +++ b/modules/smilewantedBidAdapter.js @@ -1,11 +1,13 @@ import * as utils from '../src/utils'; +import { Renderer } from '../src/Renderer'; import { config } from '../src/config'; import { registerBidder } from '../src/adapters/bidderFactory'; +import { BANNER, VIDEO } from '../src/mediaTypes'; export const spec = { code: 'smilewanted', aliases: ['smile', 'sw'], - + supportedMediaTypes: [BANNER, VIDEO], /** * Determines whether or not the given bid request is valid. * @@ -65,6 +67,7 @@ export const spec = { interpretResponse: function(serverResponse, bidRequest) { const bidResponses = []; var response = serverResponse.body; + try { if (response) { const bidResponse = { @@ -77,10 +80,19 @@ export const spec = { currency: response.currency, netRevenue: response.isNetCpm, ttl: response.ttl, - adUrl: response.adUrl, - ad: response.ad + ad: response.ad, }; + if (response.formatTypeSw == 'video_instream' || response.formatTypeSw == 'video_outstream') { + bidResponse['mediaType'] = 'video'; + bidResponse['vastUrl'] = response.ad; + bidResponse['ad'] = null; + } + + if (response.formatTypeSw == 'video_outstream') { + bidResponse['renderer'] = newRenderer(JSON.parse(bidRequest.data), response); + } + bidResponses.push(bidResponse); } } catch (error) { @@ -110,4 +122,39 @@ export const spec = { } } +/** + * Create SmileWanted renderer + * @param requestId + * @returns {*} + */ +function newRenderer(bidRequest, bidResponse) { + const renderer = Renderer.install({ + id: bidRequest.bidId, + url: bidResponse.OustreamTemplateUrl, + loaded: false + }); + + try { + renderer.setRender(outstreamRender); + } catch (err) { + utils.logWarn('Prebid Error calling setRender on newRenderer', err); + } + return renderer; +} + +/** + * Initialise SmileWanted outstream + * @param bid + */ +function outstreamRender(bid) { + bid.renderer.push(() => { + window.SmileWantedOutStreamInit({ + width: bid.width, + height: bid.height, + vastUrl: bid.vastUrl, + elId: bid.adUnitCode + }); + }); +} + registerBidder(spec); diff --git a/modules/smilewantedBidAdapter.md b/modules/smilewantedBidAdapter.md index ddc25fe7456..678eda1eeee 100644 --- a/modules/smilewantedBidAdapter.md +++ b/modules/smilewantedBidAdapter.md @@ -13,6 +13,8 @@ To use us as a bidder you must have an account and an active "zoneId" on our Smi # Test Parameters ## Web + +### Display ``` var adUnits = [ { @@ -28,4 +30,42 @@ To use us as a bidder you must have an account and an active "zoneId" on our Smi ] } ]; +``` + +### Video Instream +``` + var videoAdUnit = { + code: 'video1', + mediaTypes: { + video: { + playerSize: [640, 480], + context: 'instream' + } + }, + bids: [{ + bidder: 'smilewanted', + params: { + zoneId: 2, + } + }] + }; +``` + +### Video Outstream +``` + var videoAdUnit = { + code: 'video1', + mediaTypes: { + video: { + playerSize: [640, 480], + context: 'outstream' + } + }, + bids: [{ + bidder: 'smilewanted', + params: { + zoneId: 3, + } + }] + }; ``` \ No newline at end of file diff --git a/modules/somoaudienceBidAdapter.js b/modules/somoBidAdapter.js similarity index 91% rename from modules/somoaudienceBidAdapter.js rename to modules/somoBidAdapter.js index 2afb9265d6c..95e823a5d94 100644 --- a/modules/somoaudienceBidAdapter.js +++ b/modules/somoBidAdapter.js @@ -13,10 +13,10 @@ const APP_TARGETING = ['name', 'bundle', 'domain', 'storeUrl', 'cat', 'ver', 'ke export const spec = { - code: 'somoaudience', + code: 'somo', supportedMediaTypes: [BANNER, VIDEO], - aliases: ['somo'], + aliases: ['somoaudience'], isBidRequestValid: bid => ( !!(bid && bid.params && bid.params.placementId) @@ -25,29 +25,7 @@ export const spec = { buildRequests: function(bidRequests, bidderRequest) { return bidRequests.map(bidRequest => { let da = openRtbRequest(bidRequest, bidderRequest); - if (window.top1 && window.top1.realvu_aa) { - let a = window.top1.realvu_aa.check({ - unit_id: bidRequest.adUnitCode, - size: bidRequest.sizes, - partner_id: 'E321' - }); - a.rq_bids.push({ - bidder: bidRequest.bidder, - adId: bidRequest.bidId, - partner_id: 'E321' - }); - if (a.riff == 'yes') { - da.imp[0].pmp = { - private_auction: 0, - deals: [ - { - id: 'realvu', - bidfloor: 1.5 - } - ] - }; - } - } + return { method: 'POST', url: '//publisher-east.mobileadtrading.com/rtb/bid?s=' + bidRequest.params.placementId.toString(), diff --git a/modules/somoaudienceBidAdapter.md b/modules/somoBidAdapter.md similarity index 89% rename from modules/somoaudienceBidAdapter.md rename to modules/somoBidAdapter.md index 10af6023cb5..de395478061 100644 --- a/modules/somoaudienceBidAdapter.md +++ b/modules/somoBidAdapter.md @@ -5,7 +5,7 @@ **Maintainer**: prebid@somoaudience.com # Description Connects to Somo Audience demand source. -Please use ```somoaudience``` as the bidder code. +Please use ```somo``` as the bidder code. For video integration, somoAudience returns content as vastXML and requires the publisher to define the cache url in config passed to Prebid for it to be valid in the auction # Test Site Parameters @@ -14,7 +14,7 @@ For video integration, somoAudience returns content as vastXML and requires the code: 'banner-ad-div', sizes: [[300, 250]], bids: [{ - bidder: 'somoaudience', + bidder: 'somo', params: { placementId: '22a58cfb0c9b656bff713d1236e930e8' } @@ -27,7 +27,7 @@ var adUnits = [{ code: 'banner-ad-div', sizes: [[300, 250]], bids: [{ - bidder: 'somoaudience', + bidder: 'somo', params: { placementId: '22a58cfb0c9b656bff713d1236e930e8', app: { diff --git a/modules/sonobiBidAdapter.js b/modules/sonobiBidAdapter.js index 0d949fed25a..a0390a981a5 100644 --- a/modules/sonobiBidAdapter.js +++ b/modules/sonobiBidAdapter.js @@ -3,6 +3,7 @@ import { parseSizesInput, logError, generateUUID, isEmpty, deepAccess, logWarn, import { BANNER, VIDEO } from '../src/mediaTypes'; import { config } from '../src/config'; import { Renderer } from '../src/Renderer'; +import { userSync } from '../src/userSync'; const BIDDER_CODE = 'sonobi'; const STR_ENDPOINT = 'https://apex.go.sonobi.com/trinity.json'; @@ -62,6 +63,13 @@ export const spec = { payload.us = config.getConfig('userSync').syncsPerBidder; } + // use userSync's internal function to determine if we can drop an iframe sync pixel + if (_iframeAllowed()) { + payload.ius = 1; + } else { + payload.ius = 0; + } + if (deepAccess(validBidRequests[0], 'params.hfa')) { payload.hfa = deepAccess(validBidRequests[0], 'params.hfa'); } else if (deepAccess(validBidRequests[0], 'userId.pubcid')) { @@ -70,6 +78,10 @@ export const spec = { payload.hfa = `PRE-${validBidRequests[0].crumbs.pubcid}`; } + if (deepAccess(validBidRequests[0], 'userId.tdid')) { + payload.tdid = validBidRequests[0].userId.tdid; + } + if (validBidRequests[0].params.referrer) { payload.ref = validBidRequests[0].params.referrer; } @@ -89,6 +101,13 @@ export const spec = { payload.digkeyv = digitrust.keyv; } + if (validBidRequests[0].schain) { + payload.schain = JSON.stringify(validBidRequests[0].schain) + } + if (deepAccess(validBidRequests[0], 'userId') && Object.keys(validBidRequests[0].userId).length > 0) { + payload.userid = JSON.stringify(validBidRequests[0].userId); + } + // If there is no key_maker data, then don't make the request. if (isEmpty(data)) { return null; @@ -327,4 +346,8 @@ function outstreamRender(bid) { }); } +function _iframeAllowed() { + return userSync.canBidderRegisterSync('iframe', BIDDER_CODE); +} + registerBidder(spec); diff --git a/modules/sortableAnalyticsAdapter.js b/modules/sortableAnalyticsAdapter.js new file mode 100644 index 00000000000..17458065f9a --- /dev/null +++ b/modules/sortableAnalyticsAdapter.js @@ -0,0 +1,534 @@ +import adapter from '../src/AnalyticsAdapter'; +import CONSTANTS from '../src/constants.json'; +import adapterManager from '../src/adapterManager'; +import * as utils from '../src/utils'; +import {ajax} from '../src/ajax'; +import {getGlobal} from '../src/prebidGlobal'; +import { config } from '../src/config'; + +const DEFAULT_PROTOCOL = 'https'; +const DEFAULT_HOST = 'pa.deployads.com'; +const DEFAULT_URL = `${DEFAULT_PROTOCOL}://${DEFAULT_HOST}/pae`; +const ANALYTICS_TYPE = 'endpoint'; +const UTM_STORE_KEY = 'sortable_utm'; + +export const DEFAULT_PBID_TIMEOUT = 1000; +export const TIMEOUT_FOR_REGISTRY = 250; + +const settings = {}; +const { + EVENTS: { + AUCTION_INIT, + AUCTION_END, + BID_REQUESTED, + BID_ADJUSTMENT, + BID_WON, + BID_TIMEOUT, + } +} = CONSTANTS; + +const minsToMillis = mins => mins * 60 * 1000; +const UTM_TTL = minsToMillis(30); + +const SORTABLE_EVENTS = { + BID_WON: 'pbrw', + BID_TIMEOUT: 'pbto', + ERROR: 'pber', + PB_BID: 'pbid' +}; + +const UTM_PARAMS = [ + 'utm_campaign', + 'utm_source', + 'utm_medium', + 'utm_content', + 'utm_term' +]; + +const EVENT_KEYS_SHORT_NAMES = { + 'auctionId': 'ai', + 'adUnitCode': 'ac', + 'adId': 'adi', + 'bidderAlias': 'bs', + 'bidFactor': 'bif', + 'bidId': 'bid', + 'bidRequestCount': 'brc', + 'bidderRequestId': 'brid', + 'bidRequestedSizes': 'rs', + 'bidTopCpm': 'btcp', + 'bidTopCpmCurrency': 'btcc', + 'bidTopIsNetRevenue': 'btin', + 'bidTopFactor': 'btif', + 'bidTopSrc': 'btsrc', + 'cpm': 'c', + 'currency': 'cc', + 'dealId': 'did', + 'isNetRevenue': 'inr', + 'isTop': 'it', + 'isWinner': 'iw', + 'isTimeout': 'ito', + 'mediaType': 'mt', + 'reachedTop': 'rtp', + 'numIframes': 'nif', + 'size': 'siz', + 'start': 'st', + 'tagId': 'tgid', + 'transactionId': 'trid', + 'ttl': 'ttl', + 'ttr': 'ttr', + 'url': 'u', + 'utm_campaign': 'uc', + 'utm_source': 'us', + 'utm_medium': 'um', + 'utm_content': 'un', + 'utm_term': 'ut' +}; + +const auctionCache = {}; + +let bidderFactors = null; + +let timeoutId = null; +let eventsToBeSent = []; + +function getStorage() { + try { + return window['sessionStorage']; + } catch (e) { + return null; + } +} + +function putParams(k, v) { + try { + const storage = getStorage(); + if (!storage) { + return false; + } + if (v === null) { + storage.removeItem(k); + } else { + storage.setItem(k, JSON.stringify(v)); + } + return true; + } catch (e) { + return false; + } +} + +function getParams(k) { + try { + let storage = getStorage(); + if (!storage) { + return null; + } + let value = storage.getItem(k); + return value === null ? null : JSON.parse(value); + } catch (e) { + return null; + } +} + +function storeParams(key, paramsToSave) { + if (!settings.disableSessionTracking) { + for (let property in paramsToSave) { + if (paramsToSave.hasOwnProperty(property)) { + putParams(key, paramsToSave); + break; + } + } + } +} + +function getSiteKey(options) { + const sortableConfig = config.getConfig('sortable') || {}; + const globalSiteId = sortableConfig.siteId; + return globalSiteId || options.siteId; +} + +function generateRandomId() { + let s = (+new Date()).toString(36); + for (let i = 0; i < 6; ++i) { s += (Math.random() * 36 | 0).toString(36); } + return s; +} + +function getSessionParams() { + const stillValid = paramsFromStorage => (paramsFromStorage.created) < (+new Date() + UTM_TTL); + let sessionParams = null; + if (!settings.disableSessionTracking) { + const paramsFromStorage = getParams(UTM_STORE_KEY); + sessionParams = paramsFromStorage && stillValid(paramsFromStorage) ? paramsFromStorage : null; + } + sessionParams = sessionParams || {'created': +new Date(), 'sessionId': generateRandomId()}; + const urlParams = UTM_PARAMS.map(utils.getParameterByName); + if (UTM_PARAMS.every(key => !sessionParams[key])) { + UTM_PARAMS.forEach((v, i) => sessionParams[v] = urlParams[i] || sessionParams[v]); + sessionParams.created = +new Date(); + storeParams(UTM_STORE_KEY, sessionParams); + } + return sessionParams; +} + +function getPrebidVersion() { + return getGlobal().version; +} + +function getFactor(bidder) { + if (bidder && bidder.bidCpmAdjustment) { + return bidder.bidCpmAdjustment(1.0); + } else { + return null; + } +} + +function getBiddersFactors() { + const pb = getGlobal(); + const result = {}; + if (pb && pb.bidderSettings) { + Object.keys(pb.bidderSettings).forEach(bidderKey => { + const bidder = pb.bidderSettings[bidderKey]; + const factor = getFactor(bidder); + if (factor !== null) { + result[bidderKey] = factor; + } + }); + } + return result; +} + +function getBaseEvent(auctionId, adUnitCode, bidderCode) { + const event = {}; + event.s = settings.key; + event.ai = auctionId; + event.ac = adUnitCode; + event.bs = bidderCode; + return event; +} + +function getBidBaseEvent(auctionId, adUnitCode, bidderCode) { + const sessionParams = getSessionParams(); + const prebidVersion = getPrebidVersion(); + const event = getBaseEvent(auctionId, adUnitCode, bidderCode); + event.sid = sessionParams.sessionId; + event.pv = settings.pageviewId; + event.to = auctionCache[auctionId].timeout; + event.pbv = prebidVersion; + UTM_PARAMS.filter(k => sessionParams[k]).forEach(k => event[EVENT_KEYS_SHORT_NAMES[k]] = sessionParams[k]); + return event; +} + +function createPBBidEvent(bid) { + const event = getBidBaseEvent(bid.auctionId, bid.adUnitCode, bid.bidderAlias); + Object.keys(bid).forEach(k => { + const shortName = EVENT_KEYS_SHORT_NAMES[k]; + if (shortName) { + event[shortName] = bid[k]; + } + }); + event._type = SORTABLE_EVENTS.PB_BID; + return event; +} + +function getBidFactor(bidderAlias) { + if (!bidderFactors) { + bidderFactors = getBiddersFactors(); + } + const factor = bidderFactors[bidderAlias]; + return typeof factor !== 'undefined' ? factor : 1.0; +} + +function createPrebidBidWonEvent({auctionId, adUnitCode, bidderAlias, cpm, currency, isNetRevenue}) { + const bidFactor = getBidFactor(bidderAlias); + const event = getBaseEvent(auctionId, adUnitCode, bidderAlias); + event.bif = bidFactor; + bidderFactors = null; + event.c = cpm; + event.cc = currency; + event.inr = isNetRevenue; + event._type = SORTABLE_EVENTS.BID_WON; + return event; +} + +function createPrebidTimeoutEvent({auctionId, adUnitCode, bidderAlias}) { + const event = getBaseEvent(auctionId, adUnitCode, bidderAlias); + event._type = SORTABLE_EVENTS.BID_TIMEOUT; + return event; +} + +function getDistinct(arr) { + return arr.filter((v, i, a) => a.indexOf(v) === i); +} + +function groupBy(list, keyGetterFn) { + const map = {}; + list.forEach(item => { + const key = keyGetterFn(item); + map[key] = map[key] ? map[key].concat(item) : [item]; + }); + return map; +} + +function mergeAndCompressEventsByType(events, type) { + if (!events.length) { + return {}; + } + const allKeys = getDistinct(events.map(ev => Object.keys(ev)).reduce((prev, curr) => prev.concat(curr), [])); + const eventsAsMap = {}; + allKeys.forEach(k => { + events.forEach(ev => eventsAsMap[k] = eventsAsMap[k] ? eventsAsMap[k].concat(ev[k]) : [ev[k]]); + }); + const allSame = arr => arr.every(el => arr[0] === el); + Object.keys(eventsAsMap) + .forEach(k => eventsAsMap[k] = (eventsAsMap[k].length && allSame(eventsAsMap[k])) ? eventsAsMap[k][0] : eventsAsMap[k]); + eventsAsMap._count = events.length; + const result = {}; + result[type] = eventsAsMap; + return result; +} + +function mergeAndCompressEvents(events) { + const types = getDistinct(events.map(e => e._type)); + const groupedEvents = groupBy(events, e => e._type); + const results = types.map(t => groupedEvents[t]) + .map(events => mergeAndCompressEventsByType(events, events[0]._type)); + return results.reduce((prev, eventMap) => { + const key = Object.keys(eventMap)[0]; + prev[key] = eventMap[key]; + return prev; + }, {}); +} + +function registerEvents(events) { + eventsToBeSent = eventsToBeSent.concat(events); + if (!timeoutId) { + timeoutId = setTimeout(() => { + const _eventsToBeSent = eventsToBeSent.slice(); + eventsToBeSent = []; + sendEvents(_eventsToBeSent); + timeoutId = null; + }, TIMEOUT_FOR_REGISTRY); + } +} + +function sendEvents(events) { + const url = settings.url; + const mergedEvents = mergeAndCompressEvents(events); + const options = { + 'contentType': 'text/plain', + 'method': 'POST', + 'withCredentials': true + }; + const onSend = () => utils.logInfo('Sortable Analytics data sent'); + ajax(url, onSend, JSON.stringify(mergedEvents), options); +} + +// converts [[300, 250], [728, 90]] to '300x250,728x90' +function sizesToString(sizes) { + return sizes.map(s => s.join('x')).join(','); +} + +function dimsToSizeString(width, height) { + return `${width}x${height}`; +} + +function handleBidRequested(event) { + const refererInfo = event.refererInfo; + const url = refererInfo.referer; + const reachedTop = refererInfo.reachedTop; + const numIframes = refererInfo.numIframes; + event.bids.forEach(bid => { + const auctionId = bid.auctionId; + const adUnitCode = bid.adUnitCode; + const tagId = bid.bidder === 'sortable' ? bid.params.tagId : ''; + if (!auctionCache[auctionId].adUnits[adUnitCode]) { + auctionCache[auctionId].adUnits[adUnitCode] = {bids: {}}; + } + const adUnit = auctionCache[auctionId].adUnits[adUnitCode]; + const bids = adUnit.bids; + const newBid = { + adUnitCode: bid.adUnitCode, + auctionId: event.auctionId, + bidderAlias: bid.bidder, + bidId: bid.bidId, + bidderRequestId: bid.bidderRequestId, + bidRequestCount: bid.bidRequestsCount, + bidRequestedSizes: sizesToString(bid.sizes), + currency: bid.currency, + cpm: 0.0, + isTimeout: false, + isTop: false, + isWinner: false, + numIframes: numIframes, + start: event.start, + tagId: tagId, + transactionId: bid.transactionId, + reachedTop: reachedTop, + url: encodeURI(url) + }; + bids[newBid.bidderAlias] = newBid; + }); +} + +function handleBidAdjustment(event) { + const auctionId = event.auctionId; + const adUnitCode = event.adUnitCode; + const adUnit = auctionCache[auctionId].adUnits[adUnitCode]; + const bid = adUnit.bids[event.bidderCode]; + const bidFactor = getBidFactor(event.bidderCode); + bid.adId = event.adId; + bid.adUnitCode = event.adUnitCode; + bid.auctionId = event.auctionId; + bid.bidderAlias = event.bidderCode; + bid.bidFactor = bidFactor; + bid.cpm = event.cpm; + bid.currency = event.currency; + bid.dealId = event.dealId; + bid.isNetRevenue = event.netRevenue; + bid.mediaType = event.mediaType; + bid.responseTimestamp = event.responseTimestamp; + bid.size = dimsToSizeString(event.width, event.height); + bid.ttl = event.ttl; + bid.ttr = event.timeToRespond; +} + +function handleBidWon(event) { + const auctionId = event.auctionId; + const auction = auctionCache[auctionId]; + if (auction) { + const adUnitCode = event.adUnitCode; + const adUnit = auction.adUnits[adUnitCode]; + Object.keys(adUnit.bids).forEach(bidderCode => { + const bidFromUnit = adUnit.bids[bidderCode]; + bidFromUnit.isWinner = event.bidderCode === bidderCode; + }); + } else { + const ev = createPrebidBidWonEvent({ + adUnitCode: event.adUnitCode, + auctionId: event.auctionId, + bidderAlias: event.bidderCode, + currency: event.currency, + cpm: event.cpm, + isNetRevenue: event.netRevenue, + }); + registerEvents([ev]); + } +} + +function handleBidTimeout(event) { + event.forEach(timeout => { + const auctionId = timeout.auctionId; + const adUnitCode = timeout.adUnitCode; + const bidderAlias = timeout.bidder; + const auction = auctionCache[auctionId]; + if (auction) { + const adUnit = auction.adUnits[adUnitCode]; + const bid = adUnit.bids[bidderAlias]; + bid.isTimeout = true; + } else { + const prebidTimeoutEvent = createPrebidTimeoutEvent({auctionId, adUnitCode, bidderAlias}); + registerEvents([prebidTimeoutEvent]); + } + }); +} + +function handleAuctionInit(event) { + const auctionId = event.auctionId; + const timeout = event.timeout; + auctionCache[auctionId] = {timeout: timeout, auctionId: auctionId, adUnits: {}}; +} + +function handleAuctionEnd(event) { + const auction = auctionCache[event.auctionId]; + const adUnits = auction.adUnits; + setTimeout(() => { + const events = Object.keys(adUnits).map(adUnitCode => { + const bidderKeys = Object.keys(auction.adUnits[adUnitCode].bids); + const bids = bidderKeys.map(bidderCode => auction.adUnits[adUnitCode].bids[bidderCode]); + const highestBid = bids.length ? bids.reduce(utils.getOldestHighestCpmBid) : null; + return bidderKeys.map(bidderCode => { + const bid = auction.adUnits[adUnitCode].bids[bidderCode]; + if (highestBid && highestBid.cpm) { + bid.isTop = highestBid.bidderAlias === bid.bidderAlias; + bid.bidTopFactor = getBidFactor(highestBid.bidderAlias); + bid.bidTopCpm = highestBid.cpm; + bid.bidTopCpmCurrency = highestBid.currency; + bid.bidTopIsNetRevenue = highestBid.isNetRevenue; + bid.bidTopSrc = highestBid.bidderAlias; + } + return createPBBidEvent(bid); + }); + }).reduce((prev, curr) => prev.concat(curr), []); + bidderFactors = null; + sendEvents(events); + delete auctionCache[event.auctionId]; + }, settings.timeoutForPbid); +} + +function handleError(eventType, event, e) { + const ev = {}; + ev.s = settings.key; + ev.ti = eventType; + ev.args = JSON.stringify(event); + ev.msg = e.message; + ev._type = SORTABLE_EVENTS.ERROR; + registerEvents([ev]); +} + +const sortableAnalyticsAdapter = Object.assign(adapter({url: DEFAULT_URL, ANALYTICS_TYPE}), { + track({eventType, args}) { + try { + switch (eventType) { + case AUCTION_INIT: + handleAuctionInit(args); + break; + case AUCTION_END: + handleAuctionEnd(args); + break; + case BID_REQUESTED: + handleBidRequested(args); + break; + case BID_ADJUSTMENT: + handleBidAdjustment(args); + break; + case BID_WON: + handleBidWon(args); + break; + case BID_TIMEOUT: + handleBidTimeout(args); + break; + } + } catch (e) { + handleError(eventType, args, e); + } + } +}); + +sortableAnalyticsAdapter.originEnableAnalytics = sortableAnalyticsAdapter.enableAnalytics; + +sortableAnalyticsAdapter.enableAnalytics = function (setupConfig) { + if (this.initConfig(setupConfig)) { + utils.logInfo('Sortable Analytics adapter enabled'); + sortableAnalyticsAdapter.originEnableAnalytics(setupConfig); + } +}; + +sortableAnalyticsAdapter.initConfig = function (setupConfig) { + settings.disableSessionTracking = setupConfig.disableSessionTracking === undefined ? false : setupConfig.disableSessionTracking; + settings.key = getSiteKey(setupConfig.options); + settings.protocol = setupConfig.options.protocol || DEFAULT_PROTOCOL; + settings.url = `${settings.protocol}://${setupConfig.options.eventHost || DEFAULT_HOST}/pae/${settings.key}`; + settings.pageviewId = generateRandomId(); + settings.timeoutForPbid = setupConfig.timeoutForPbid ? Math.max(setupConfig.timeoutForPbid, 0) : DEFAULT_PBID_TIMEOUT; + return !!settings.key; +}; + +sortableAnalyticsAdapter.getOptions = function () { + return settings; +}; + +adapterManager.registerAnalyticsAdapter({ + adapter: sortableAnalyticsAdapter, + code: 'sortable' +}); + +export default sortableAnalyticsAdapter; diff --git a/modules/sortableAnalyticsAdapter.md b/modules/sortableAnalyticsAdapter.md new file mode 100644 index 00000000000..a4aa8019031 --- /dev/null +++ b/modules/sortableAnalyticsAdapter.md @@ -0,0 +1,9 @@ +# Overview + +Module Name: Sortable Analytics Adapter +Module Type: Analytics Adapter +Maintainer: prebid@sortable.com + +# Description + +Analytics adapter for Sortable. Contact prebid@sortable.com for information. diff --git a/modules/sovrnAnalyticsAdapter.js b/modules/sovrnAnalyticsAdapter.js new file mode 100644 index 00000000000..bb9051b5a8a --- /dev/null +++ b/modules/sovrnAnalyticsAdapter.js @@ -0,0 +1,280 @@ +import adapter from '../src/AnalyticsAdapter' +import adaptermanager from '../src/adapterManager' +import CONSTANTS from '../src/constants.json' +import {ajaxBuilder} from '../src/ajax' +import * as utils from '../src/utils' +import {config} from '../src/config' +import find from 'core-js/library/fn/array/find' +import includes from 'core-js/library/fn/array/includes' + +const ajax = ajaxBuilder(0) + +const { + EVENTS: { + AUCTION_END, + BID_REQUESTED, + BID_ADJUSTMENT, + BID_RESPONSE, + BID_WON + } +} = CONSTANTS + +let pbaUrl = 'https://pba.aws.lijit.com/analytics' +let currentAuctions = {}; +const analyticsType = 'endpoint' + +let sovrnAnalyticsAdapter = Object.assign(adapter({url: pbaUrl, analyticsType}), { + track({ eventType, args }) { + try { + if (eventType === BID_WON) { + new BidWinner(this.sovrnId, args).send(); + return + } + if (args && args.auctionId && currentAuctions[args.auctionId] && currentAuctions[args.auctionId].status === 'complete') { + throw new Error('Event Received after Auction Close Auction Id ' + args.auctionId) + } + if (args && args.auctionId && currentAuctions[args.auctionId] === undefined) { + currentAuctions[args.auctionId] = new AuctionData(this.sovrnId, args.auctionId) + } + switch (eventType) { + case BID_REQUESTED: + currentAuctions[args.auctionId].bidRequested(args) + break + case BID_ADJUSTMENT: + currentAuctions[args.auctionId].originalBid(args) + break + case BID_RESPONSE: + currentAuctions[args.auctionId].adjustedBid(args) + break + case AUCTION_END: + currentAuctions[args.auctionId].send(); + break + } + } catch (e) { + new LogError(e, this.sovrnId, {eventType, args}).send() + } + }, +}) + +sovrnAnalyticsAdapter.getAuctions = function () { + return currentAuctions; +}; + +sovrnAnalyticsAdapter.originEnableAnalytics = sovrnAnalyticsAdapter.enableAnalytics; + +// override enableAnalytics so we can get access to the config passed in from the page +sovrnAnalyticsAdapter.enableAnalytics = function (config) { + let sovrnId = '' + if (config && config.options && (config.options.sovrnId || config.options.affiliateId)) { + sovrnId = config.options.sovrnId || config.options.affiliateId; + } else { + utils.logError('Need Sovrn Id to log auction results. Please contact a Sovrn representative if you do not know your Sovrn Id.') + return + } + sovrnAnalyticsAdapter.sovrnId = sovrnId; + if (config.options.pbaUrl) { + pbaUrl = config.options.pbaUrl; + } + sovrnAnalyticsAdapter.originEnableAnalytics(config) // call the base class function +}; + +adaptermanager.registerAnalyticsAdapter({ + adapter: sovrnAnalyticsAdapter, + code: 'sovrn' +}); + +/** Class Representing a Winning Bid */ +class BidWinner { + /** + * Creates a new bid winner + * @param {string} sovrnId - the affiliate id from the analytics config + * @param {*} event - the args object from the auction event + */ + constructor(sovrnId, event) { + this.body = {} + this.body.prebidVersion = $$REPO_AND_VERSION$$ + this.body.sovrnId = sovrnId + this.body.winningBid = JSON.parse(JSON.stringify(event)) + this.body.url = utils.getTopWindowLocation().href + this.body.payload = 'winner' + delete this.body.winningBid.ad + } + + /** + * Sends the auction to the the ingest server + */ + send() { + this.body.ts = utils.timestamp() + ajax( + pbaUrl, + null, + JSON.stringify(this.body), + { + contentType: 'application/json', + method: 'POST', + } + ) + } +} + +/** Class representing an Auction */ +class AuctionData { + /** + * Create a new auction data collector + * @param {string} sovrnId - the affiliate id from the analytics config + * @param {string} auctionId - the auction id from the auction event + */ + constructor(sovrnId, auctionId) { + this.auction = {} + this.auction.prebidVersion = $$REPO_AND_VERSION$$ + this.auction.sovrnId = sovrnId + this.auction.auctionId = auctionId + this.auction.payload = 'auction' + this.auction.timeouts = { + buffer: config.getConfig('timeoutBuffer'), + bidder: config.getConfig('bidderTimeout'), + } + this.auction.priceGranularity = config.getConfig('priceGranularity') + this.auction.url = utils.getTopWindowLocation().href + this.auction.requests = [] + this.auction.unsynced = [] + this.dropBidFields = ['auctionId', 'ad', 'requestId', 'bidderCode'] + + setTimeout(function(id) { + delete currentAuctions[id] + }, 300000, this.auction.auctionId) + } + + /** + * Record a bid request event + * @param {*} event - the args object from the auction event + */ + bidRequested(event) { + const eventCopy = JSON.parse(JSON.stringify(event)) + delete eventCopy.doneCbCallCount + delete eventCopy.auctionId + this.auction.requests.push(eventCopy) + } + + /** + * Finds the bid from the auction that the event is associated with + * @param {*} event - the args object from the auction event + * @return {*} - the bid + */ + findBid(event) { + const bidder = find(this.auction.requests, r => (r.bidderCode === event.bidderCode)) + if (!bidder) { + this.auction.unsynced.push(JSON.parse(JSON.stringify(event))) + } + let bid = find(bidder.bids, b => (b.bidId === event.requestId)) + + if (!bid) { + event.unmatched = true + bidder.bids.push(JSON.parse(JSON.stringify(event))) + } + return bid + } + + /** + * Records the original bid before any adjustments have been made + * @param {*} event - the args object from the auction event + * NOTE: the bid adjustment occurs before the bid response + * the bid adjustment seems to be the bid ready to be adjusted + */ + originalBid(event) { + let bid = this.findBid(event) + if (bid) { + Object.assign(bid, JSON.parse(JSON.stringify(event))) + this.dropBidFields.forEach((f) => delete bid[f]) + } + } + + /** + * Replaces original values with adjusted values and records the original values for changed values + * in bid.originalValues + * @param {*} event - the args object from the auction event + */ + adjustedBid(event) { + let bid = this.findBid(event) + if (bid) { + bid.originalValues = Object.keys(event).reduce((o, k) => { + if (JSON.stringify(bid[k]) !== JSON.stringify(event[k]) && !includes(this.dropBidFields, k)) { + o[k] = bid[k] + bid[k] = event[k] + } + return o + }, {}) + } + } + + /** + * Sends the auction to the the ingest server + */ + send() { + let maxBids = {} + this.auction.requests.forEach(request => { + request.bids.forEach(bid => { + maxBids[bid.adUnitCode] = maxBids[bid.adUnitCode] || {cpm: 0} + if (bid.cpm > maxBids[bid.adUnitCode].cpm) { + maxBids[bid.adUnitCode] = bid + } + }) + }) + Object.keys(maxBids).forEach(unit => { + maxBids[unit].isAuctionWinner = true + }) + this.auction.ts = utils.timestamp() + ajax( + pbaUrl, + () => { + currentAuctions[this.auction.auctionId] = {status: 'complete', auctionId: this.auction.auctionId} + }, + JSON.stringify(this.auction), + { + contentType: 'application/json', + method: 'POST', + } + ) + } +} +class LogError { + constructor(e, sovrnId, data) { + this.error = {} + this.error.payload = 'error' + this.error.message = e.message + this.error.stack = e.stack + this.error.data = data + this.error.prebidVersion = $$REPO_AND_VERSION$$ + this.error.sovrnId = sovrnId + this.error.url = utils.getTopWindowLocation().href + this.error.userAgent = navigator.userAgent + } + send() { + if (this.error.data && this.error.data.requests) { + this.error.data.requests.forEach(request => { + if (request.bids) { + request.bids.forEach(bid => { + if (bid.ad) { + delete bid.ad + } + }) + } + }) + } + if (ErrorEvent.data && error.data.ad) { + delete error.data.ad + } + this.error.ts = utils.timestamp() + ajax( + pbaUrl, + null, + JSON.stringify(this.error), + { + contentType: 'application/json', + method: 'POST', + } + ) + } +} + +export default sovrnAnalyticsAdapter; diff --git a/modules/sovrnAnalyticsAdapter.md b/modules/sovrnAnalyticsAdapter.md new file mode 100644 index 00000000000..80bc6d7f6b1 --- /dev/null +++ b/modules/sovrnAnalyticsAdapter.md @@ -0,0 +1,23 @@ +# Overview + +``` +Module Name: Sovrn Analytics Adapter +Module Type: Analytics Adapter +Maintainer: jrosendahl@sovrn.com +``` + +# Description + +Sovrn's analytics adaptor allows you to view detailed auction information in Meridian. + +For more information, visit Sovrn.com. + +# Test Parameters +``` +{ + provider: 'sovrn', + options: { + sovrnId: 'xxxxx', // Sovrn ID (required) you can get this by contacting Sovrn support. + } +} +``` diff --git a/modules/spotxBidAdapter.js b/modules/spotxBidAdapter.js index bc109ccc635..6e374b991d3 100644 --- a/modules/spotxBidAdapter.js +++ b/modules/spotxBidAdapter.js @@ -84,6 +84,10 @@ export const spec = { versionOrtb: ORTB_VERSION }; + if (utils.getBidIdParameter('hide_skin', bid.params) != '') { + ext.hide_skin = +!!utils.getBidIdParameter('hide_skin', bid.params); + } + if (utils.getBidIdParameter('ad_volume', bid.params) != '') { ext.ad_volume = utils.getBidIdParameter('ad_volume', bid.params); } diff --git a/modules/spotxBidAdapter.md b/modules/spotxBidAdapter.md index db5fd448e04..038c698a259 100644 --- a/modules/spotxBidAdapter.md +++ b/modules/spotxBidAdapter.md @@ -54,16 +54,16 @@ This adapter requires setup and approval from the SpotX team. ad_unit: 'outstream', outstream_options: { slot: 'adSlot1', - content_width: 300, - content_height: 250, custom_override: { // This option is not mandatory though used to override default renderer parameters using EASI player options in here: https://developer.spotxchange.com/content/local/docs/sdkDocs/EASI/README.md + content_width: 300, + content_height: 250, collapse: '1', hide_fullscreen: '1', unmute_on_mouse: '1', - click_to_replay: '1', continue_out_of_view: '1', ad_volume: '100', - content_container_id: 'video1' + content_container_id: 'video1', + hide_skin: '1' } } } @@ -121,6 +121,7 @@ function myOutstreamFunction(bid) { script.setAttribute('data-spotx_click_to_replay', '1'); script.setAttribute('data-spotx_continue_out_of_view', '1'); script.setAttribute('data-spotx_ad_volume', '100'); + script.setAttribute('data-spotx_hide_skin', '1'); if (bid.renderer.config.inIframe && window.document.getElementById(bid.renderer.config.inIframe).nodeName == 'IFRAME') { let rawframe = window.document.getElementById(bid.renderer.config.inIframe); let framedoc = rawframe.contentDocument; diff --git a/modules/staqAnalyticsAdapter.js b/modules/staqAnalyticsAdapter.js new file mode 100644 index 00000000000..4d8b81b7be2 --- /dev/null +++ b/modules/staqAnalyticsAdapter.js @@ -0,0 +1,429 @@ +import adapter from '../src/AnalyticsAdapter'; +import CONSTANTS from '../src/constants.json'; +import adapterManager from '../src/adapterManager'; +import {getRefererInfo} from '../src/refererDetection'; +import {parse} from '../src/url'; +import * as utils from '../src/utils'; +import {ajax} from '../src/ajax'; + +const ANALYTICS_VERSION = '1.0.0'; +const DEFAULT_QUEUE_TIMEOUT = 4000; +const DEFAULT_HOST = 'tag.staq.com'; + +let staqAdapterRefWin; + +const STAQ_EVENTS = { + AUCTION_INIT: 'auctionInit', + BID_REQUEST: 'bidRequested', + BID_RESPONSE: 'bidResponse', + BID_WON: 'bidWon', + AUCTION_END: 'auctionEnd', + TIMEOUT: 'adapterTimedOut' +} + +function buildRequestTemplate(connId) { + const url = staqAdapterRefWin.referer; + const ref = staqAdapterRefWin.referer; + const topLocation = staqAdapterRefWin.referer; + + return { + ver: ANALYTICS_VERSION, + domain: topLocation.hostname, + path: topLocation.pathname, + userAgent: navigator.userAgent, + connId: connId, + env: { + screen: { + w: window.screen.width, + h: window.screen.height + }, + lang: navigator.language + }, + src: getUmtSource(url, ref) + } +} + +let analyticsAdapter = Object.assign(adapter({analyticsType: 'endpoint'}), + { + track({ eventType, args }) { + if (!analyticsAdapter.context) { + return; + } + let handler = null; + switch (eventType) { + case CONSTANTS.EVENTS.AUCTION_INIT: + if (analyticsAdapter.context.queue) { + analyticsAdapter.context.queue.init(); + } + handler = trackAuctionInit; + break; + case CONSTANTS.EVENTS.BID_REQUESTED: + handler = trackBidRequest; + break; + case CONSTANTS.EVENTS.BID_RESPONSE: + handler = trackBidResponse; + break; + case CONSTANTS.EVENTS.BID_WON: + handler = trackBidWon; + break; + case CONSTANTS.EVENTS.BID_TIMEOUT: + handler = trackBidTimeout; + break; + case CONSTANTS.EVENTS.AUCTION_END: + handler = trackAuctionEnd; + break; + } + if (handler) { + let events = handler(args); + if (analyticsAdapter.context.queue) { + analyticsAdapter.context.queue.push(events); + if (eventType === CONSTANTS.EVENTS.BID_WON) { + analyticsAdapter.context.queue.updateWithWins(events); + } + } + if (eventType === CONSTANTS.EVENTS.AUCTION_END) { + sendAll(); + } + } + } + }); + +analyticsAdapter.context = {}; + +analyticsAdapter.originEnableAnalytics = analyticsAdapter.enableAnalytics; + +analyticsAdapter.enableAnalytics = (config) => { + utils.logInfo('Enabling STAQ Adapter'); + staqAdapterRefWin = getRefererInfo(window); + if (!config.options.connId) { + utils.logError('ConnId is not defined. STAQ Analytics won\'t work'); + return; + } + if (!config.options.url) { + utils.logError('URL is not defined. STAQ Analytics won\'t work'); + return; + } + analyticsAdapter.context = { + host: config.options.host || DEFAULT_HOST, + url: config.options.url, + connectionId: config.options.connId, + requestTemplate: buildRequestTemplate(config.options.connId), + queue: new ExpiringQueue(sendAll, config.options.queueTimeout || DEFAULT_QUEUE_TIMEOUT) + }; + analyticsAdapter.originEnableAnalytics(config); +}; + +adapterManager.registerAnalyticsAdapter({ + adapter: analyticsAdapter, + code: 'staq' +}); + +export default analyticsAdapter; + +function sendAll() { + let events = analyticsAdapter.context.queue.popAll(); + if (events.length !== 0) { + let req = events.map(event => { + return Object.assign({}, event, analyticsAdapter.context.requestTemplate) + }); + analyticsAdapter.ajaxCall(JSON.stringify(req)); + } +} + +analyticsAdapter.ajaxCall = function ajaxCall(data) { + utils.logInfo('SENDING DATA: ' + data); + ajax(`//${analyticsAdapter.context.url}/prebid/${analyticsAdapter.context.connectionId}`, () => { + }, data, {contentType: 'text/plain'}); +}; + +function trackAuctionInit(args) { + analyticsAdapter.context.auctionTimeStart = Date.now(); + analyticsAdapter.context.auctionId = args.auctionId; + const event = createHbEvent(args.auctionId, undefined, STAQ_EVENTS.AUCTION_INIT); + return [event]; +} + +function trackBidRequest(args) { + return args.bids.map(bid => + createHbEvent(args.auctionId, args.bidderCode, STAQ_EVENTS.BID_REQUEST, bid.adUnitCode)); +} + +function trackBidResponse(args) { + const event = createHbEvent(args.auctionId, args.bidderCode, STAQ_EVENTS.BID_RESPONSE, + args.adUnitCode, args.cpm, args.timeToRespond / 1000, false, args); + return [event]; +} + +function trackBidWon(args) { + const event = createHbEvent(args.auctionId, args.bidderCode, STAQ_EVENTS.BID_WON, args.adUnitCode, args.cpm, undefined, true, args); + return [event]; +} + +function trackAuctionEnd(args) { + const event = createHbEvent(args.auctionId, undefined, STAQ_EVENTS.AUCTION_END, undefined, + undefined, (Date.now() - analyticsAdapter.context.auctionTimeStart) / 1000); + return [event]; +} + +function trackBidTimeout(args) { + return args.map(arg => + createHbEvent(arg.auctionId, arg.bidderCode, STAQ_EVENTS.TIMEOUT) + ); +} + +function createHbEvent(auctionId, adapter, event, adUnitCode = undefined, value = 0, time = 0, bidWon = undefined, eventArgs) { + let ev = { event: event }; + if (adapter) { + ev.adapter = adapter; + ev.bidderName = adapter; + } + if (adUnitCode) { + ev.adUnitCode = adUnitCode; + } + if (value) { + ev.cpm = value; + } + if (time) { + ev.timeToRespond = time; + } + if (typeof bidWon !== 'undefined') { + ev.bidWon = bidWon; + } else if (event === 'bidResponse') { + ev.bidWon = false; + } + ev.auctionId = auctionId; + + if (eventArgs) { + if (STAQ_EVENTS.BID_RESPONSE == event || STAQ_EVENTS.BID_WON == event) { + ev.width = eventArgs.width; + ev.height = eventArgs.height; + + ev.adId = eventArgs.adId; + } + } + + return ev; +} + +const UTM_TAGS = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content', + 'utm_c1', 'utm_c2', 'utm_c3', 'utm_c4', 'utm_c5']; +const STAQ_PREBID_KEY = 'staq_analytics'; +const DIRECT = '(direct)'; +const REFERRAL = '(referral)'; +const ORGANIC = '(organic)'; + +export let storage = { + getItem: (name) => { + return localStorage.getItem(name); + }, + setItem: (name, value) => { + localStorage.setItem(name, value); + } +}; + +export function getUmtSource(pageUrl, referrer) { + let prevUtm = getPreviousTrafficSource(); + let currUtm = getCurrentTrafficSource(pageUrl, referrer); + let [updated, actual] = chooseActualUtm(prevUtm, currUtm); + if (updated) { + storeUtm(actual); + } + return actual; + + function getPreviousTrafficSource() { + let val = storage.getItem(STAQ_PREBID_KEY); + if (!val) { + return getDirect(); + } + return JSON.parse(val); + } + + function getCurrentTrafficSource(pageUrl, referrer) { + var source = getUTM(pageUrl); + if (source) { + return source; + } + if (referrer) { + let se = getSearchEngine(referrer); + if (se) { + return asUtm(se, ORGANIC, ORGANIC); + } + let parsedUrl = parse(pageUrl); + let [refHost, refPath] = getReferrer(referrer); + if (refHost && refHost !== parsedUrl.hostname) { + return asUtm(refHost, REFERRAL, REFERRAL, '', refPath); + } + } + return getDirect(); + } + + function getSearchEngine(pageUrl) { + let engines = { + 'google': /^https?\:\/\/(?:www\.)?(?:google\.(?:com?\.)?(?:com|cat|[a-z]{2})|g.cn)\//i, + 'yandex': /^https?\:\/\/(?:www\.)?ya(?:ndex\.(?:com|net)?\.?(?:asia|mobi|org|[a-z]{2})?|\.ru)\//i, + 'bing': /^https?\:\/\/(?:www\.)?bing\.com\//i, + 'duckduckgo': /^https?\:\/\/(?:www\.)?duckduckgo\.com\//i, + 'ask': /^https?\:\/\/(?:www\.)?ask\.com\//i, + 'yahoo': /^https?\:\/\/(?:[-a-z]+\.)?(?:search\.)?yahoo\.com\//i + }; + + for (let engine in engines) { + if (engines.hasOwnProperty(engine) && engines[engine].test(pageUrl)) { + return engine; + } + } + } + + function getReferrer(referrer) { + let ref = parse(referrer); + return [ref.hostname, ref.pathname]; + } + + function getUTM(pageUrl) { + let urlParameters = parse(pageUrl).search; + if (!urlParameters['utm_campaign'] || !urlParameters['utm_source']) { + return; + } + let utmArgs = []; + utils._each(UTM_TAGS, (utmTagName) => { + let utmValue = urlParameters[utmTagName] || ''; + utmArgs.push(utmValue); + }); + return asUtm.apply(this, utmArgs); + } + + function getDirect() { + return asUtm(DIRECT, DIRECT, DIRECT); + } + + function storeUtm(utm) { + let val = JSON.stringify(utm); + storage.setItem(STAQ_PREBID_KEY, val); + } + + function asUtm(source, medium, campaign, term = '', content = '', c1 = '', c2 = '', c3 = '', c4 = '', c5 = '') { + let result = { + source: source, + medium: medium, + campaign: campaign + }; + if (term) { + result.term = term; + } + if (content) { + result.content = content; + } + if (c1) { + result.c1 = c1; + } + if (c2) { + result.c2 = c2; + } + if (c3) { + result.c3 = c3; + } + if (c4) { + result.c4 = c4; + } + if (c5) { + result.c5 = c5; + } + return result; + } + + function chooseActualUtm(prev, curr) { + if (ord(prev) < ord(curr)) { + return [true, curr]; + } if (ord(prev) > ord(curr)) { + return [false, prev]; + } else { + if (prev.campaign === REFERRAL && prev.content !== curr.content) { + return [true, curr]; + } else if (prev.campaign === ORGANIC && prev.source !== curr.source) { + return [true, curr]; + } else if (isCampaignTraffic(prev) && (prev.campaign !== curr.campaign || prev.source !== curr.source)) { + return [true, curr]; + } + } + return [false, prev]; + } + + function ord(utm) { + switch (utm.campaign) { + case DIRECT: + return 0; + case ORGANIC: + return 1; + case REFERRAL: + return 2; + default: + return 3; + } + } + + function isCampaignTraffic(utm) { + return [DIRECT, REFERRAL, ORGANIC].indexOf(utm.campaign) === -1; + } +} + +/** + * Expiring queue implementation. Fires callback on elapsed timeout since last last update or creation. + * @param callback + * @param ttl + * @constructor + */ +export function ExpiringQueue(callback, ttl) { + let queue = []; + let timeoutId; + + this.push = (event) => { + if (event instanceof Array) { + queue.push.apply(queue, event); + } else { + queue.push(event); + } + reset(); + }; + + this.updateWithWins = (winEvents) => { + winEvents.forEach(winEvent => { + queue.forEach(prevEvent => { + if (prevEvent.event === 'bidResponse' && + prevEvent.auctionId == winEvent.auctionId && + prevEvent.adUnitCode == winEvent.adUnitCode && + prevEvent.adId == winEvent.adId && + prevEvent.adapter == winEvent.adapter) { + prevEvent.bidWon = true; + } + }); + }); + } + + this.popAll = () => { + let result = queue; + queue = []; + reset(); + return result; + }; + + /** + * For test/debug purposes only + * @return {Array} + */ + this.peekAll = () => { + return queue; + }; + + this.init = reset; + + function reset() { + if (timeoutId) { + clearTimeout(timeoutId); + } + timeoutId = setTimeout(() => { + if (queue.length) { + callback(); + } + }, ttl); + } +} diff --git a/modules/staqAnalyticsAdapter.md b/modules/staqAnalyticsAdapter.md new file mode 100644 index 00000000000..c3d2e9ce3a8 --- /dev/null +++ b/modules/staqAnalyticsAdapter.md @@ -0,0 +1,23 @@ +# Overview +Module Name: STAQ Analytics Adapter + +Module Type: Analytics Adapter + +Maintainer: dev@staq.com + +# Description + +Analytics adapter for STAQ. Contact support@staq.com for information. + +# Test Parameters + +``` +{ + provider: 'staq', + options: { + host: , // HOST URL of site. Optional. Only required for whitelisting. + url: 'localhost:3000', // REQUIRED host URL for delivery of information to STAQ + connId: '5678' // REQUIRED STAQ connection ID + } +} +``` diff --git a/modules/stvBidAdapter.js b/modules/stvBidAdapter.js new file mode 100644 index 00000000000..ac655f2013d --- /dev/null +++ b/modules/stvBidAdapter.js @@ -0,0 +1,150 @@ + +import * as utils from '../src/utils'; +import {config} from '../src/config'; +import {registerBidder} from '../src/adapters/bidderFactory'; +import { BANNER, VIDEO } from '../src/mediaTypes'; + +const BIDDER_CODE = 'stv'; +const VADS_ENDPOINT_URL = 'https://ads.smartstream.tv/r/'; +const DEFAULT_VIDEO_SOURCE = 'vads'; +const DEFAULT_BANNER_FORMAT = 'vast2'; + +export const spec = { + code: BIDDER_CODE, + aliases: ['vads'], + supportedMediaTypes: [BANNER, VIDEO], + isBidRequestValid: function(bid) { + return !!(bid.params.placement); + }, + buildRequests: function(validBidRequests, bidderRequest) { + return validBidRequests.map(bidRequest => { + const params = bidRequest.params; + + const videoData = utils.deepAccess(bidRequest, 'mediaTypes.video') || {}; + const sizes = utils.parseSizesInput(videoData.playerSize || bidRequest.sizes)[0]; + const width = sizes.split('x')[0]; + const height = sizes.split('x')[1]; + + const placementId = params.placement; + + const rnd = Math.floor(Math.random() * 99999999999); + const referrer = encodeURIComponent(bidderRequest.refererInfo.referer); + const bidId = bidRequest.bidId; + let endpoint = VADS_ENDPOINT_URL; + + let payload = {}; + if (isVideoRequest(bidRequest)) { + const source = params.source || DEFAULT_VIDEO_SOURCE; + if (source === 'vads') { + payload = { + _f: 'vast2', + alternative: 'prebid_js', + _ps: placementId, + srw: width, + srh: height, + idt: 100, + rnd: rnd, + ref: referrer, + bid_id: bidId, + }; + endpoint = VADS_ENDPOINT_URL; + } + } else { + const outputFormat = params.format || DEFAULT_BANNER_FORMAT; + payload = { + _f: outputFormat, + alternative: 'prebid_js', + inventory_item_id: placementId, + srw: width, + srh: height, + idt: 100, + rnd: rnd, + ref: referrer, + bid_id: bidId, + }; + } + prepareExtraParams(params, payload); + + return { + method: 'GET', + url: endpoint, + data: objectToQueryString(payload), + } + }); + }, + interpretResponse: function(serverResponse, bidRequest) { + const bidResponses = []; + const response = serverResponse.body; + const crid = response.crid || 0; + const cpm = response.cpm / 1000000 || 0; + if (cpm !== 0 && crid !== 0) { + const dealId = response.dealid || ''; + const currency = response.currency || 'EUR'; + const netRevenue = (response.netRevenue === undefined) ? true : response.netRevenue; + const bidResponse = { + requestId: response.bid_id, + cpm: cpm, + width: response.width, + height: response.height, + creativeId: crid, + dealId: dealId, + currency: currency, + netRevenue: netRevenue, + ttl: config.getConfig('_bidderTimeout') + }; + + if (response.vastXml) { + bidResponse.vastXml = response.vastXml; + bidResponse.mediaType = 'video'; + } else { + bidResponse.ad = response.adTag; + } + + bidResponses.push(bidResponse); + } + return bidResponses; + } +} + +function objectToQueryString(obj, prefix) { + let str = []; + let p; + for (p in obj) { + if (obj.hasOwnProperty(p)) { + let k = prefix ? prefix + '[' + p + ']' : p; + let v = obj[p]; + str.push((v !== null && typeof v === 'object') + ? objectToQueryString(v, k) + : encodeURIComponent(k) + '=' + (k == '_ps' ? v : encodeURIComponent(v))); + } + } + return str.join('&'); +} + +/** + * Check if it's a video bid request + * + * @param {BidRequest} bid - Bid request generated from ad slots + * @returns {boolean} True if it's a video bid + */ +function isVideoRequest(bid) { + return bid.mediaType === 'video' || !!utils.deepAccess(bid, 'mediaTypes.video'); +} + +function prepareExtraParams(params, payload) { + if (params.pfilter !== undefined) { + payload.pfilter = params.pfilter; + } + if (params.bcat !== undefined) { + payload.bcat = params.bcat; + } + if (params.noskip !== undefined) { + payload.noskip = params.noskip; + } + + if (params.dvt !== undefined) { + payload.dvt = params.dvt; + } +} + +registerBidder(spec); diff --git a/modules/stvBidAdapter.md b/modules/stvBidAdapter.md new file mode 100644 index 00000000000..79e958c3bba --- /dev/null +++ b/modules/stvBidAdapter.md @@ -0,0 +1,43 @@ +# Overview + +``` +Module Name: STV Video Bidder Adapter +Module Type: Bidder Adapter +Maintainer: prebid@dspx.tv +``` + +# Description + +STV video adapter for Prebid.js 1.x + +# Parameters +``` + var adUnits = [ + { + // video settings + code: 'video-obj', + mediaTypes: { + video: { + context: 'instream', + playerSize: [640, 480] + } + }, + bids: [ + { + bidder: "stv", + params: { + placement: "", // placement ID of inventory with STV + noskip: 1, // 0 or 1 + pfilter: {/* + min_duration: 10, // min duration + max_duration: 30, // max duration + min_bitrate: 300, // min bitrate + max_bitrate: 1600, // max bitrate + */} + } + } + ] + } + ]; +``` + diff --git a/modules/sublimeBidAdapter.js b/modules/sublimeBidAdapter.js new file mode 100644 index 00000000000..fce3df7675b --- /dev/null +++ b/modules/sublimeBidAdapter.js @@ -0,0 +1,135 @@ +import { registerBidder } from '../src/adapters/bidderFactory'; +import { config } from '../src/config'; + +const BIDDER_CODE = 'sublime'; +const DEFAULT_BID_HOST = 'pbjs.sskzlabs.com'; +const DEFAULT_CURRENCY = 'EUR'; +const DEFAULT_PROTOCOL = 'https'; +const DEFAULT_TTL = 600; +const SUBLIME_VERSION = '0.4.0'; + +export const spec = { + code: BIDDER_CODE, + aliases: [], + + /** + * Determines whether or not the given bid request is valid. + * + * @param {BidRequest} bid The bid params to validate. + * @return boolean True if this is a valid bid, and false otherwise. + */ + isBidRequestValid: (bid) => { + return !!bid.params.zoneId; + }, + + /** + * Make a server request from the list of BidRequests. + * + * @param {BidRequest[]} validBidRequests An array of bids + * @param {Object} bidderRequest - Info describing the request to the server. + * @return ServerRequest Info describing the request to the server. + */ + buildRequests: (validBidRequests, bidderRequest) => { + let commonPayload = { + sublimeVersion: SUBLIME_VERSION, + // Current Prebid params + prebidVersion: '$prebid.version$', + currencyCode: config.getConfig('currency.adServerCurrency') || DEFAULT_CURRENCY, + timeout: config.getConfig('bidderTimeout'), + }; + + // RefererInfo + if (bidderRequest && bidderRequest.refererInfo) { + commonPayload.referer = bidderRequest.refererInfo.referer; + commonPayload.numIframes = bidderRequest.refererInfo.numIframes; + } + // GDPR handling + if (bidderRequest && bidderRequest.gdprConsent) { + commonPayload.gdprConsent = bidderRequest.gdprConsent.consentString; + commonPayload.gdpr = bidderRequest.gdprConsent.gdprApplies; // we're handling the undefined case server side + } + + return validBidRequests.map(bid => { + let bidPayload = { + adUnitCode: bid.adUnitCode, + auctionId: bid.auctionId, + bidder: bid.bidder, + bidderRequestId: bid.bidderRequestId, + bidRequestsCount: bid.bidRequestsCount, + requestId: bid.bidId, + sizes: bid.sizes.map(size => ({ + w: size[0], + h: size[1], + })), + transactionId: bid.transactionId, + zoneId: bid.params.zoneId, + }; + + let protocol = bid.params.protocol || DEFAULT_PROTOCOL; + let bidHost = bid.params.bidHost || DEFAULT_BID_HOST; + let payload = Object.assign({}, commonPayload, bidPayload); + + return { + method: 'POST', + url: protocol + '://' + bidHost + '/bid', + data: payload, + options: { + contentType: 'application/json', + withCredentials: true + }, + }; + }); + }, + + /** + * Unpack the response from the server into a list of bids. + * + * @param {*} serverResponse A successful response from the server. + * @param {*} bidRequest An object with bid request informations + * @return {Bid[]} An array of bids which were nested inside the server. + */ + interpretResponse: (serverResponse, bidRequest) => { + const bidResponses = []; + const response = serverResponse.body; + + if (response) { + if (response.timeout || !response.ad || response.ad.match(//gmi)) { + return bidResponses; + } + + // Setting our returned sizes object to default values + let returnedSizes = { + width: 1800, + height: 1000 + }; + + // Verifying Banner sizes + if (bidRequest && bidRequest.data && bidRequest.data.w === 1 && bidRequest.data.h === 1) { + // If banner sizes are 1x1 we set our default size object to 1x1 + returnedSizes = { + width: 1, + height: 1 + }; + } + + const bidResponse = { + requestId: response.requestId || '', + cpm: response.cpm || 0, + width: response.width || returnedSizes.width, + height: response.height || returnedSizes.height, + creativeId: response.creativeId || 1, + dealId: response.dealId || 1, + currency: response.currency || DEFAULT_CURRENCY, + netRevenue: response.netRevenue || true, + ttl: response.ttl || DEFAULT_TTL, + ad: response.ad, + }; + + bidResponses.push(bidResponse); + } + + return bidResponses; + }, +}; + +registerBidder(spec); diff --git a/modules/sublimeBidAdapter.md b/modules/sublimeBidAdapter.md new file mode 100644 index 00000000000..e57f4a1fdb0 --- /dev/null +++ b/modules/sublimeBidAdapter.md @@ -0,0 +1,62 @@ +# Overview + +``` +Module Name: Sublime Bid Adapter +Module Type: Bidder Adapter +Maintainer: pbjs@sublimeskinz.com +``` + +# Description + +Connects to Sublime for bids. +Sublime bid adapter supports Skinz and M-Skinz formats. + +# Nota Bene + +Our prebid adapter is unusable with SafeFrame. + +# Build + +You can build your version of prebid.js, execute: + +```shell +gulp build --modules=sublimeBidAdapter +``` + +Or to build with multiple adapters + +```shell +gulp build --modules=sublimeBidAdapter,secondAdapter,thirdAdapter +``` + +More details in the root [README](../README.md#Build) + +## To build from you own repository + +- copy `/modules/sublimeBidAdapter.js` to your `/modules/` directory +- copy `/modules/sublimeBidAdapter.md` to your `/modules/` directory +- copy `/test/spec/modules/sublimeBidAdapter_spec.js` to your `/test/spec/modules/` directory + +Then build + + +# Invocation Parameters + +```js +var adUnits = [{ + code: 'sublime', + mediaTypes: { + banner: { + sizes: [1800, 1000] + } + }, + bids: [{ + bidder: 'sublime', + params: { + zoneId: + } + }] +}]; +``` + +Where you replace `` by your Sublime Zone id diff --git a/modules/supply2BidAdapter.md b/modules/supply2BidAdapter.md old mode 100755 new mode 100644 diff --git a/modules/synacormediaBidAdapter.js b/modules/synacormediaBidAdapter.js index dcaa2c35f4f..ca533f8cff8 100644 --- a/modules/synacormediaBidAdapter.js +++ b/modules/synacormediaBidAdapter.js @@ -2,24 +2,37 @@ import { getAdUnitSizes, logWarn } from '../src/utils'; import { registerBidder } from '../src/adapters/bidderFactory'; -import { BANNER } from '../src/mediaTypes'; +import { BANNER, VIDEO } from '../src/mediaTypes'; +import includes from 'core-js/library/fn/array/includes'; const BID_HOST = '//prebid.technoratimedia.com'; const USER_SYNC_HOST = '//ad-cdn.technoratimedia.com'; +const VIDEO_PARAMS = [ 'minduration', 'maxduration', 'startdelay', 'placement', 'linearity', 'mimes', 'protocols', 'api' ]; +const BLOCKED_AD_SIZES = [ + '1x1', + '1x2' +]; export const spec = { code: 'synacormedia', - supportedMediaTypes: [ BANNER ], + supportedMediaTypes: [ BANNER, VIDEO ], sizeMap: {}, + isVideoBid: function(bid) { + return bid.mediaTypes !== undefined && + bid.mediaTypes.hasOwnProperty('video'); + }, isBidRequestValid: function(bid) { - return !!(bid && bid.params && bid.params.placementId && bid.params.seatId); + const hasRequiredParams = bid && bid.params && bid.params.hasOwnProperty('placementId') && bid.params.hasOwnProperty('seatId'); + const hasAdSizes = bid && getAdUnitSizes(bid).filter(size => BLOCKED_AD_SIZES.indexOf(size.join('x')) === -1).length > 0 + return !!(hasRequiredParams && hasAdSizes); }, + buildRequests: function(validBidReqs, bidderRequest) { if (!validBidReqs || !validBidReqs.length || !bidderRequest) { return; } - let refererInfo = bidderRequest.refererInfo; - let openRtbBidRequest = { + const refererInfo = bidderRequest.refererInfo; + const openRtbBidRequest = { id: bidderRequest.auctionId, site: { domain: location.hostname, @@ -32,6 +45,7 @@ export const spec = { imp: [] }; let seatId = null; + validBidReqs.forEach((bid, i) => { if (seatId && seatId !== bid.params.seatId) { logWarn(`Synacormedia: there is an inconsistent seatId: ${bid.params.seatId} but only sending bid requests for ${seatId}, you should double check your configuration`); @@ -39,8 +53,8 @@ export const spec = { } else { seatId = bid.params.seatId; } - let placementId = bid.params.placementId; - let bidFloor = bid.params.bidfloor ? parseFloat(bid.params.bidfloor) : null; + const placementId = bid.params.placementId; + const bidFloor = bid.params.bidfloor ? parseFloat(bid.params.bidfloor) : null; if (isNaN(bidFloor)) { logWarn(`Synacormedia: there is an invalid bid floor: ${bid.params.bidfloor}`); } @@ -49,21 +63,39 @@ export const spec = { logWarn(`Synacormedia: there is an invalid POS: ${bid.params.pos}`); pos = 0; } - getAdUnitSizes(bid).forEach((size, i) => { - let request = { - id: bid.bidId + '~' + size[0] + 'x' + size[1], - tagid: placementId, - banner: { - w: size[0], - h: size[1], + const videoOrBannerKey = this.isVideoBid(bid) ? 'video' : 'banner'; + getAdUnitSizes(bid) + .filter(size => BLOCKED_AD_SIZES.indexOf(size.join('x')) === -1) + .forEach((size, i) => { + if (!size || size.length != 2) { + return; + } + const size0 = size[0]; + const size1 = size[1]; + const imp = { + id: `${videoOrBannerKey.substring(0, 1)}${bid.bidId}-${size0}x${size1}`, + tagid: placementId + }; + if (bidFloor !== null && !isNaN(bidFloor)) { + imp.bidfloor = bidFloor; + } + + const videoOrBannerValue = { + w: size0, + h: size1, pos + }; + if (videoOrBannerKey === 'video') { + if (bid.mediaTypes.video) { + this.setValidVideoParams(bid.mediaTypes.video, bid.params.video); + } + if (bid.params.video) { + this.setValidVideoParams(bid.params.video, videoOrBannerValue); + } } - }; - if (bidFloor !== null && !isNaN(bidFloor)) { - request.bidfloor = bidFloor; - } - openRtbBidRequest.imp.push(request); - }); + imp[videoOrBannerKey] = videoOrBannerValue; + openRtbBidRequest.imp.push(imp); + }); }); if (openRtbBidRequest.imp.length && seatId) { @@ -78,42 +110,50 @@ export const spec = { }; } }, + + setValidVideoParams: function (sourceObj, destObj) { + Object.keys(sourceObj) + .filter(param => includes(VIDEO_PARAMS, param) && sourceObj[param] !== null && (!isNaN(parseInt(sourceObj[param], 10)) || !(sourceObj[param].length < 1))) + .forEach(param => destObj[param] = Array.isArray(sourceObj[param]) ? sourceObj[param] : parseInt(sourceObj[param], 10)); + }, interpretResponse: function(serverResponse) { + const updateMacros = (bid, r) => { + return r ? r.replace(/\${AUCTION_PRICE}/g, bid.price) : r; + }; + if (!serverResponse.body || typeof serverResponse.body != 'object') { logWarn('Synacormedia: server returned empty/non-json response: ' + JSON.stringify(serverResponse.body)); return; } + const {id, seatbid: seatbids} = serverResponse.body; let bids = []; if (id && seatbids) { seatbids.forEach(seatbid => { seatbid.bid.forEach(bid => { - let price = parseFloat(bid.price); - let creative = bid.adm.replace(/\${([^}]*)}/g, (match, key) => { - switch (key) { - case 'AUCTION_SEAT_ID': return seatbid.seat; - case 'AUCTION_ID': return id; - case 'AUCTION_BID_ID': return bid.id; - case 'AUCTION_IMP_ID': return bid.impid; - case 'AUCTION_PRICE': return price; - case 'AUCTION_CURRENCY': return 'USD'; - } - return match; - }); - let [, impid, width, height] = bid.impid.match(/^(.*)~(.*)x(.*)$/); - bids.push({ + const creative = updateMacros(bid, bid.adm); + const nurl = updateMacros(bid, bid.nurl); + const [, impType, impid, width, height] = bid.impid.match(/^([vb])(.*)-(.*)x(.*)$/); + const isVideo = impType == 'v'; + const bidObj = { requestId: impid, adId: bid.id.replace(/~/g, '-'), - cpm: price, + cpm: parseFloat(bid.price), width: parseInt(width, 10), height: parseInt(height, 10), - creativeId: seatbid.seat + '~' + bid.crid, + creativeId: `${seatbid.seat}_${bid.crid}`, currency: 'USD', netRevenue: true, - mediaType: BANNER, + mediaType: isVideo ? VIDEO : BANNER, ad: creative, ttl: 60 - }); + }; + if (isVideo) { + const [, uuid] = nurl.match(/ID=([^&]*)&?/); + bidObj.videoCacheKey = encodeURIComponent(uuid); + bidObj.vastUrl = nurl; + } + bids.push(bidObj); }); }); } diff --git a/modules/synacormediaBidAdapter.md b/modules/synacormediaBidAdapter.md index 279cc48bcc1..3a00aa45fed 100644 --- a/modules/synacormediaBidAdapter.md +++ b/modules/synacormediaBidAdapter.md @@ -11,6 +11,13 @@ Maintainer: eng-demand@synacor.com The Synacor Media adapter requires setup and approval from Synacor. Please reach out to your account manager for more information. +### DFP Video Creative +To use video, setup a `VAST redirect` creative within Google AdManager (DFP) with the following VAST tag URL: + +``` +https://track.technoratimedia.com/openrtb/tags?ID=%%PATTERN:hb_cache_id_synacorm%%&AUCTION_PRICE=%%PATTERN:hb_pb_synacormedia%% +``` + # Test Parameters ## Web @@ -24,24 +31,33 @@ Please reach out to your account manager for more information. bidder: "synacormedia", params: { seatId: "prebid", - placementId: "81416", - bidfloor: "0.10", + placementId: "demo1", + bidfloor: 0.10, pos: 1 } }] },{ code: 'test-div2', - sizes: [ - [300, 250] - ], + mediaTypes: { + video: { + context: 'instream', + playerSize: [[300, 250]], + } + }, bids: [{ bidder: "synacormedia", params: { seatId: "prebid", - placementId: "demo2" - bidfloor: "0.10", - pos: 1 + placementId: "demo1", + bidfloor: 0.20, + pos: 1, + video: { + minduration: 15, + maxduration: 30, + startdelay: 1, + linearity: 1 + } } }] - }]; + }]; ``` diff --git a/modules/teadsBidAdapter.js b/modules/teadsBidAdapter.js index 13e6da40d97..121232a6605 100644 --- a/modules/teadsBidAdapter.js +++ b/modules/teadsBidAdapter.js @@ -40,9 +40,10 @@ export const spec = { buildRequests: function(validBidRequests, bidderRequest) { const bids = validBidRequests.map(buildRequestObject); const payload = { - referrer: utils.getTopWindowUrl(), + referrer: getReferrerInfo(bidderRequest), data: bids, - deviceWidth: screen.width + deviceWidth: screen.width, + hb_version: '$prebid.version$' }; let gdpr = bidderRequest.gdprConsent; @@ -84,7 +85,8 @@ export const spec = { ttl: bid.ttl, ad: bid.ad, requestId: bid.bidId, - creativeId: bid.creativeId + creativeId: bid.creativeId, + placementId: bid.placementId }; bidResponses.push(bidResponse); }); @@ -92,16 +94,42 @@ export const spec = { return bidResponses; }, - getUserSyncs: function(syncOptions, responses, gdprApplies) { + getUserSyncs: function(syncOptions, responses, gdprConsent) { + let queryParams = { + hb_provider: 'prebid', + hb_version: '$prebid.version$' + }; + + if (gdprConsent) { + let gdprIab = { + status: findGdprStatus(gdprConsent.gdprApplies, gdprConsent.vendorData), + consent: gdprConsent.consentString + }; + + queryParams.gdprIab = JSON.stringify(gdprIab) + } + + if (utils.deepAccess(responses[0], 'body.responses.0.placementId')) { + queryParams.placementId = responses[0].body.responses[0].placementId + }; + if (syncOptions.iframeEnabled) { return [{ type: 'iframe', - url: '//sync.teads.tv/iframe' + url: '//sync.teads.tv/iframe?' + utils.parseQueryStringParameters(queryParams) }]; } } }; +function getReferrerInfo(bidderRequest) { + let ref = ''; + if (bidderRequest && bidderRequest.refererInfo && bidderRequest.refererInfo.referer) { + ref = bidderRequest.refererInfo.referer; + } + return ref; +} + function findGdprStatus(gdprApplies, gdprData) { let status = gdprStatus.GDPR_APPLIES_PUBLISHER; diff --git a/modules/telariaBidAdapter.js b/modules/telariaBidAdapter.js index 12698f0ce56..fe0277f9fbe 100644 --- a/modules/telariaBidAdapter.js +++ b/modules/telariaBidAdapter.js @@ -5,7 +5,9 @@ import {VIDEO} from '../src/mediaTypes'; import {STATUS} from '../src/constants'; const BIDDER_CODE = 'telaria'; -const ENDPOINT = '.ads.tremorhub.com/ad/tag'; +const DOMAIN = 'tremorhub.com'; +const TAG_ENDPOINT = `ads.${DOMAIN}/ad/tag`; +const EVENTS_ENDPOINT = `events.${DOMAIN}/diag`; export const spec = { code: BIDDER_CODE, @@ -34,7 +36,7 @@ export const spec = { if (url) { requests.push({ method: 'GET', - url: generateUrl(bid, bidderRequest), + url: url, bidId: bid.bidId, vastUrl: url.split('&fmt=json')[0] }); @@ -82,9 +84,9 @@ export const spec = { errorMessage += `: ${bidResult.error}`; } utils.logError(errorMessage); - } else if (bidResult.seatbid && bidResult.seatbid.length > 0) { + } else if (!utils.isEmpty(bidResult.seatbid)) { bidResult.seatbid[0].bid.forEach(tag => { - bids.push(createBid(STATUS.GOOD, bidderRequest, tag, width, height, bidResult.seatbid[0].seat.toLowerCase())); + bids.push(createBid(STATUS.GOOD, bidderRequest, tag, width, height, BIDDER_CODE)); }); } @@ -100,11 +102,89 @@ export const spec = { getUserSyncs: function (syncOptions, serverResponses) { const syncs = []; if (syncOptions.pixelEnabled && serverResponses.length) { - try { - serverResponses[0].body.ext.telaria.userSync.forEach(url => syncs.push({type: 'image', url: url})); - } catch (e) {} + (utils.deepAccess(serverResponses, '0.body.ext.telaria.userSync') || []).forEach(url => syncs.push({type: 'image', url: url})); } return syncs; + }, + + /** + * See http://prebid.org/dev-docs/bidder-adaptor.html#registering-on-timeout for detailed semantic. + * @param timeoutData bidRequest + */ + onTimeout: function (timeoutData) { + let url = getTimeoutUrl(timeoutData); + if (url) { + utils.triggerPixel(url); + } + } +}; + +function getScheme() { + return ((document.location.protocol === 'https:') ? 'https' : 'http') + '://'; +} + +function getSrcPageUrl(params) { + return (params && params['srcPageUrl']) || encodeURIComponent(document.location.href); +} + +function getEncodedValIfNotEmpty(val) { + return !utils.isEmpty(val) ? encodeURIComponent(val) : ''; +} + +/** + * Converts the schain object to a url param value. Please refer to + * https://github.com/InteractiveAdvertisingBureau/openrtb/blob/master/supplychainobject.md + * (schain for non ORTB section) for more information + * @param schainObject + * @returns {string} + */ +function getSupplyChainAsUrlParam(schainObject) { + if (utils.isEmpty(schainObject)) { + return ''; + } + + let scStr = `&schain=${schainObject.ver},${schainObject.complete}`; + + schainObject.nodes.forEach((node) => { + scStr += '!'; + scStr += `${getEncodedValIfNotEmpty(node.asi)},`; + scStr += `${getEncodedValIfNotEmpty(node.sid)},`; + scStr += `${getEncodedValIfNotEmpty(node.hp)},`; + scStr += `${getEncodedValIfNotEmpty(node.rid)},`; + scStr += `${getEncodedValIfNotEmpty(node.name)},`; + scStr += `${getEncodedValIfNotEmpty(node.domain)}`; + }); + + return scStr; +} + +function getUrlParams(params, schainFromBidRequest) { + let urlSuffix = ''; + + if (!utils.isEmpty(params)) { + for (let key in params) { + if (key !== 'schain' && params.hasOwnProperty(key) && !utils.isEmpty(params[key])) { + urlSuffix += `&${key}=${params[key]}`; + } + } + urlSuffix += getSupplyChainAsUrlParam(!utils.isEmpty(schainFromBidRequest) ? schainFromBidRequest : params['schain']); + } + + return urlSuffix; +} + +export const getTimeoutUrl = function(timeoutData) { + let params = utils.deepAccess(timeoutData, '0.params.0'); + + if (!utils.isEmpty(params)) { + let url = `${getScheme()}${EVENTS_ENDPOINT}`; + + url += `?srcPageUrl=${getSrcPageUrl(params)}`; + url += `${getUrlParams(params)}`; + + url += '&hb=1&evt=TO'; + + return url; } }; @@ -116,9 +196,9 @@ export const spec = { * @returns {string} */ function generateUrl(bid, bidderRequest) { - let playerSize = (bid.mediaTypes && bid.mediaTypes.video && bid.mediaTypes.video.playerSize); + let playerSize = utils.deepAccess(bid, 'mediaTypes.video.playerSize'); if (!playerSize) { - utils.logWarn('Although player size isn\'t required it is highly recommended'); + utils.logWarn(`Although player size isn't required it is highly recommended`); } let width, height; @@ -132,45 +212,41 @@ function generateUrl(bid, bidderRequest) { } } - if (bid.params.supplyCode && bid.params.adCode) { - let scheme = ((document.location.protocol === 'https:') ? 'https' : 'http') + '://'; - let url = scheme + bid.params.supplyCode + ENDPOINT + '?adCode=' + bid.params.adCode; + let supplyCode = utils.deepAccess(bid, 'params.supplyCode'); + let adCode = utils.deepAccess(bid, 'params.adCode'); + + if (supplyCode && adCode) { + let url = `${getScheme()}${supplyCode}.${TAG_ENDPOINT}?adCode=${adCode}`; if (width) { - url += ('&playerWidth=' + width); + url += (`&playerWidth=${width}`); } if (height) { - url += ('&playerHeight=' + height); + url += (`&playerHeight=${height}`); } - for (let key in bid.params) { - if (bid.params.hasOwnProperty(key) && bid.params[key]) { - url += ('&' + key + '=' + bid.params[key]); - } - } + url += `${getUrlParams(bid.params, bid.schain)}`; - if (!bid.params['srcPageUrl']) { - url += ('&srcPageUrl=' + encodeURIComponent(document.location.href)); - } + url += `&srcPageUrl=${getSrcPageUrl(bid.params)}`; - url += ('&transactionId=' + bid.transactionId + '&hb=1'); + url += (`&transactionId=${bid.transactionId}`); if (bidderRequest) { if (bidderRequest.gdprConsent) { if (typeof bidderRequest.gdprConsent.gdprApplies === 'boolean') { - url += ('&gdpr=' + (bidderRequest.gdprConsent.gdprApplies ? 1 : 0)); + url += (`&gdpr=${(bidderRequest.gdprConsent.gdprApplies ? 1 : 0)}`); } if (bidderRequest.gdprConsent.consentString) { - url += ('&gdpr_consent=' + bidderRequest.gdprConsent.consentString); + url += (`&gdpr_consent=${bidderRequest.gdprConsent.consentString}`); } } if (bidderRequest.refererInfo && bidderRequest.refererInfo.referer) { - url += ('&referrer=' + encodeURIComponent(bidderRequest.refererInfo.referer)); + url += (`&referrer=${encodeURIComponent(bidderRequest.refererInfo.referer)}`); } } - return (url + '&fmt=json'); + return (url + '&hb=1&fmt=json'); } } diff --git a/modules/telariaBidAdapter.md b/modules/telariaBidAdapter.md index 6a34a14a6b2..6a5e24e9a5e 100644 --- a/modules/telariaBidAdapter.md +++ b/modules/telariaBidAdapter.md @@ -23,7 +23,7 @@ Telaria bid adapter supports insteream Video. } }, bids: [{ - bidder: 'tremor', + bidder: 'telaria', params: { supplyCode: 'ssp-demo-rm6rh', adCode: 'ssp-!demo!-lufip', @@ -33,3 +33,5 @@ Telaria bid adapter supports insteream Video. } ``` +# Example: +https://console.telaria.com/examples/hb/headerbidding.jsp diff --git a/modules/timBidAdapter.js b/modules/timBidAdapter.js index 0539f37deef..449254671f4 100644 --- a/modules/timBidAdapter.js +++ b/modules/timBidAdapter.js @@ -1,7 +1,7 @@ -import * as utils from 'src/utils'; -import {registerBidder} from 'src/adapters/bidderFactory'; +import * as utils from '../src/utils'; +import {registerBidder} from '../src/adapters/bidderFactory'; import * as bidfactory from '../src/bidfactory'; -var CONSTANTS = require('src/constants.json'); +var CONSTANTS = require('../src/constants.json'); const BIDDER_CODE = 'tim'; function parseBidRequest(bidRequest) { diff --git a/modules/topRTBBidAdapter.js b/modules/topRTBBidAdapter.js new file mode 100644 index 00000000000..783d4008b33 --- /dev/null +++ b/modules/topRTBBidAdapter.js @@ -0,0 +1,65 @@ +import * as utils from '../src/utils'; +import {registerBidder} from '../src/adapters/bidderFactory'; +import {BANNER, VIDEO} from '../src/mediaTypes'; + +const BIDDER_CODE = 'topRTB'; +const ENDPOINT_URL = 'https://ssp.toprtb.com/ssp/rest/ReqAd?ref=www.google.com&hbid=0&adUnitId='; +var adName = ''; +export const spec = { + code: BIDDER_CODE, + supportedMediaTypes: [BANNER, VIDEO], + isBidRequestValid: function (bid) { + if (utils.deepAccess(bid, 'mediaTypes.banner')) { + adName = 'banner'; + return bid.params && !!bid.params.adUnitId; + } + if (utils.deepAccess(bid, 'mediaTypes.video')) { + adName = 'video'; + return bid.params && !!bid.params.adUnitId; + } + }, + + buildRequests: function (validBidRequests, bidderRequest) { + let adunitid = []; + utils._each(validBidRequests, function (bid) { + adunitid.push(bid.params.adUnitId + '_' + bid.bidId); + }); + + return { + method: 'GET', + url: ENDPOINT_URL + adunitid.toString() + }; + }, + + interpretResponse: function(serverResponses, request) { + const bidResponses = []; + utils._each(serverResponses.body, function(response) { + if (response.cpm > 0) { + const bidResponse = { + requestId: response.bidId, + cpm: response.cpm, + width: response.width, + height: response.height, + ad: response.mediadata, + ttl: response.ttl, + creativeId: response.id, + netRevenue: true, + currency: response.currency, + tracking: response.tracking, + impression: response.impression + }; + if (adName == 'video') { + bidResponse.vastXml = response.mediadata; + bidResponse.mediaType = 'video'; + } else { + bidResponse.ad = response.mediadata; + bidResponse.mediaType = 'banner'; + } + bidResponses.push(bidResponse); + } + }); + return bidResponses; + } +}; + +registerBidder(spec); diff --git a/modules/topRTBBidAdapter.md b/modules/topRTBBidAdapter.md new file mode 100644 index 00000000000..d1930c928e4 --- /dev/null +++ b/modules/topRTBBidAdapter.md @@ -0,0 +1,30 @@ +# Overview + +``` +Module Name: topRTB Bidder Adapter +Module Type: Bidder Adapter +Maintainer: karthikeyan.d@djaxtech.com +``` + +# Description + +topRTB Bidder Adapter for Prebid.js. +Only Banner & video format is supported. + +# Test Parameters +``` + var adUnits = [ + { + code: 'test-div-0', + sizes: [[728, 90]], // a display size + bids: [ + { + bidder: 'topRTB', + params: { + adUnitId: 'c5c06f77430c4c33814a0577cb4cc978' + } + } + ] + } + ]; +``` diff --git a/modules/tripleliftBidAdapter.js b/modules/tripleliftBidAdapter.js index 748c5087201..2d6b2dce8de 100644 --- a/modules/tripleliftBidAdapter.js +++ b/modules/tripleliftBidAdapter.js @@ -3,7 +3,7 @@ import { registerBidder } from '../src/adapters/bidderFactory'; import * as utils from '../src/utils'; const BIDDER_CODE = 'triplelift'; -const STR_ENDPOINT = document.location.protocol + '//tlx.3lift.com/header/auction?'; +const STR_ENDPOINT = 'https://tlx.3lift.com/header/auction?'; let gdprApplies = true; let consentString = null; @@ -17,7 +17,7 @@ export const tripleliftAdapterSpec = { buildRequests: function(bidRequests, bidderRequest) { let tlCall = STR_ENDPOINT; - let data = _buildPostBody(bidRequests); + let data = _buildPostBody(bidRequests, bidderRequest); tlCall = utils.tryAppendQueryString(tlCall, 'lib', 'prebid'); tlCall = utils.tryAppendQueryString(tlCall, 'v', '$prebid.version$'); @@ -78,7 +78,7 @@ export const tripleliftAdapterSpec = { } } -function _buildPostBody(bidRequests) { +function _buildPostBody(bidRequests, bidderRequest) { let data = {}; data.imp = bidRequests.map(function(bid, index) { return { @@ -88,9 +88,16 @@ function _buildPostBody(bidRequests) { banner: { format: _sizes(bid.sizes) } - } + }; }); + let eids = handleConsortiaUserIds(bidderRequest); + if (eids.length > 0) { + data.user = { + ext: {eids} + }; + } + return data; } @@ -108,6 +115,23 @@ function _isValidSize(size) { return (size.length === 2 && typeof size[0] === 'number' && typeof size[1] === 'number'); } +function handleConsortiaUserIds(bidderRequest) { + let eids = []; + if (bidderRequest.userId && bidderRequest.userId.tdid) { + eids.push({ + source: 'adserver.org', + uids: [{ + id: bidderRequest.userId.tdid, + ext: { + rtiPartner: 'TDID' + } + }] + }); + } + + return eids; +} + function _buildResponseObject(bidderRequest, bid) { let bidResponse = {}; let width = bid.width || 1; diff --git a/modules/tripleliftBidAdapter.md b/modules/tripleliftBidAdapter.md index ad153cdece7..c10ea3675d4 100644 --- a/modules/tripleliftBidAdapter.md +++ b/modules/tripleliftBidAdapter.md @@ -3,7 +3,7 @@ ``` Module Name: Triplelift Bid Adapter Module Type: Bidder Adapter -Maintainer: bzellman@triplelift.com +Maintainer: csmith+s2s@triplelift.com ``` # Description diff --git a/modules/trustxBidAdapter.js b/modules/trustxBidAdapter.js index b0593e5c7d7..00c86dec0d3 100644 --- a/modules/trustxBidAdapter.js +++ b/modules/trustxBidAdapter.js @@ -7,7 +7,7 @@ const BIDDER_CODE = 'trustx'; const ENDPOINT_URL = '//sofia.trustx.org/hb'; const TIME_TO_LIVE = 360; const ADAPTER_SYNC_URL = '//sofia.trustx.org/push_sync'; -const RENDERER_URL = '//cdn.adnxs.com/renderer/video/ANOutstreamVideo.js'; +const RENDERER_URL = '//acdn.adnxs.com/video/outstream/ANOutstreamVideo.js'; const LOG_ERROR_MESS = { noAuid: 'Bid from response has no auid parameter - ', @@ -46,6 +46,7 @@ export const spec = { const sizeMap = {}; const bids = validBidRequests || []; let priceType = 'net'; + let pageKeywords; let reqId; bids.forEach(bid => { @@ -57,6 +58,15 @@ export const spec = { auids.push(uid); const sizesId = utils.parseSizesInput(bid.sizes); + if (!pageKeywords && !utils.isEmpty(bid.params.keywords)) { + const keywords = utils.transformBidderParamKeywords(bid.params.keywords); + + if (keywords.length > 0) { + keywords.forEach(deleteValues); + } + pageKeywords = keywords; + } + if (!slotsMapByUid[uid]) { slotsMapByUid[uid] = {}; } @@ -84,14 +94,22 @@ export const spec = { }); const payload = { - u: utils.getTopWindowUrl(), pt: priceType, auids: auids.join(','), sizes: utils.getKeys(sizeMap).join(','), - r: reqId + r: reqId, + wrapperType: 'Prebid_js', + wrapperVersion: '$prebid.version$' }; + if (pageKeywords) { + payload.keywords = JSON.stringify(pageKeywords); + } + if (bidderRequest) { + if (bidderRequest.refererInfo && bidderRequest.refererInfo.referer) { + payload.u = bidderRequest.refererInfo.referer; + } if (bidderRequest.timeout) { payload.wtimeout = bidderRequest.timeout; } @@ -150,6 +168,16 @@ export const spec = { } } +function isPopulatedArray(arr) { + return !!(utils.isArray(arr) && arr.length > 0); +} + +function deleteValues(keyPairObj) { + if (isPopulatedArray(keyPairObj.value) && keyPairObj.value[0] === '') { + delete keyPairObj.value; + } +} + function _getBidFromResponse(respItem) { if (!respItem) { utils.logError(LOG_ERROR_MESS.emptySeatbid); diff --git a/modules/trustxBidAdapter.md b/modules/trustxBidAdapter.md old mode 100755 new mode 100644 index d6b660c6248..a72f1ba85aa --- a/modules/trustxBidAdapter.md +++ b/modules/trustxBidAdapter.md @@ -32,7 +32,11 @@ TrustX Bid Adapter supports Banner and Video (instream and outstream). bidder: "trustx", params: { uid: 45, - priceType: 'gross' + priceType: 'gross', + keywords: { + brandsafety: ['disaster'], + topic: ['stress', 'fear'] + } } } ] diff --git a/modules/ucfunnelBidAdapter.js b/modules/ucfunnelBidAdapter.js index c1ac951066d..7974f053bbd 100644 --- a/modules/ucfunnelBidAdapter.js +++ b/modules/ucfunnelBidAdapter.js @@ -168,7 +168,7 @@ function getRequestData(bid, bidderRequest) { const dnt = (navigator.doNotTrack == 'yes' || navigator.doNotTrack == '1' || navigator.msDoNotTrack == '1') ? 1 : 0; const videoContext = utils.deepAccess(bid, 'mediaTypes.video.context'); const videoMediaType = utils.deepAccess(bid, 'mediaTypes.video'); - + const userIdTdid = (bid.userId && bid.userId.tdid) ? bid.userId.tdid : ''; // general bid data let bidData = { ver: VER, @@ -181,7 +181,8 @@ function getRequestData(bid, bidderRequest) { ru: ref, adid: utils.getBidIdParameter('adid', bid.params), w: size[0], - h: size[1] + h: size[1], + tdid: userIdTdid }; if (bid.mediaType === 'video' || videoMediaType) { diff --git a/modules/undertoneBidAdapter.js b/modules/undertoneBidAdapter.js index c04616a8385..107f4478102 100644 --- a/modules/undertoneBidAdapter.js +++ b/modules/undertoneBidAdapter.js @@ -41,6 +41,16 @@ function extractDomainFromHost(pageHost) { return domain; } +function getGdprQueryParams(gdprConsent) { + if (!gdprConsent) { + return null; + } + + let gdpr = gdprConsent.gdprApplies ? '1' : '0'; + let gdprstr = gdprConsent.consentString ? gdprConsent.consentString : ''; + return `gdpr=${gdpr}&gdprstr=${gdprstr}`; +} + export const spec = { code: BIDDER_CODE, isBidRequestValid: function(bid) { @@ -51,7 +61,11 @@ export const spec = { }, buildRequests: function(validBidRequests, bidderRequest) { const payload = { - 'x-ut-hb-params': [] + 'x-ut-hb-params': [], + 'commons': { + 'adapterVersion': '$prebid.version$', + 'uids': validBidRequests[0].userId + } }; const referer = bidderRequest.refererInfo.referer; const hostname = urlUtils.parse(referer).hostname; @@ -59,7 +73,12 @@ export const spec = { const pageUrl = getCanonicalUrl() || referer; const pubid = validBidRequests[0].params.publisherId; - const REQ_URL = `${URL}?pid=${pubid}&domain=${domain}`; + let reqUrl = `${URL}?pid=${pubid}&domain=${domain}`; + + let gdprParams = getGdprQueryParams(bidderRequest.gdprConsent); + if (gdprParams) { + reqUrl += `&${gdprParams}`; + } validBidRequests.map(bidReq => { const bid = { @@ -76,7 +95,7 @@ export const spec = { }); return { method: 'POST', - url: REQ_URL, + url: reqUrl, withCredentials: true, data: JSON.stringify(payload) }; @@ -107,23 +126,28 @@ export const spec = { }, getUserSyncs: function(syncOptions, serverResponses, gdprConsent) { const syncs = []; - if (gdprConsent && gdprConsent.gdprApplies === true) { - return syncs; + + let gdprParams = getGdprQueryParams(gdprConsent); + let iframeGdprParams = ''; + let pixelGdprParams = ''; + if (gdprParams) { + iframeGdprParams += `?${gdprParams}`; + pixelGdprParams += `&${gdprParams}`; } if (syncOptions.iframeEnabled) { syncs.push({ type: 'iframe', - url: FRAME_USER_SYNC + url: FRAME_USER_SYNC + iframeGdprParams }); } else if (syncOptions.pixelEnabled) { syncs.push({ type: 'image', - url: PIXEL_USER_SYNC_1 + url: PIXEL_USER_SYNC_1 + pixelGdprParams }, { type: 'image', - url: PIXEL_USER_SYNC_2 + url: PIXEL_USER_SYNC_2 + pixelGdprParams }); } return syncs; diff --git a/modules/unrulyBidAdapter.js b/modules/unrulyBidAdapter.js index 5647d2cd6a3..580357a1978 100644 --- a/modules/unrulyBidAdapter.js +++ b/modules/unrulyBidAdapter.js @@ -4,9 +4,12 @@ import { registerBidder } from '../src/adapters/bidderFactory' import { VIDEO } from '../src/mediaTypes' function configureUniversalTag (exchangeRenderer) { + if (!exchangeRenderer.config) throw new Error('UnrulyBidAdapter: Missing renderer config.') + if (!exchangeRenderer.config.siteId) throw new Error('UnrulyBidAdapter: Missing renderer siteId.') + parent.window.unruly = parent.window.unruly || {}; parent.window.unruly['native'] = parent.window.unruly['native'] || {}; - parent.window.unruly['native'].siteId = parent.window.unruly['native'].siteId || exchangeRenderer.siteId; + parent.window.unruly['native'].siteId = parent.window.unruly['native'].siteId || exchangeRenderer.config.siteId; parent.window.unruly['native'].supplyMode = 'prebid'; } @@ -35,9 +38,18 @@ const serverResponseToBid = (bid, rendererInstance) => ({ const buildPrebidResponseAndInstallRenderer = bids => bids - .filter(serverBid => !!utils.deepAccess(serverBid, 'ext.renderer')) + .filter(serverBid => { + const hasConfig = !!utils.deepAccess(serverBid, 'ext.renderer.config'); + const hasSiteId = !!utils.deepAccess(serverBid, 'ext.renderer.config.siteId'); + + if (!hasConfig) utils.logError(new Error('UnrulyBidAdapter: Missing renderer config.')); + if (!hasSiteId) utils.logError(new Error('UnrulyBidAdapter: Missing renderer siteId.')); + + return hasSiteId + }) .map(serverBid => { const exchangeRenderer = utils.deepAccess(serverBid, 'ext.renderer'); + configureUniversalTag(exchangeRenderer); configureRendererQueue(); diff --git a/modules/userId.js b/modules/userId.js deleted file mode 100644 index bddada7ffbc..00000000000 --- a/modules/userId.js +++ /dev/null @@ -1,429 +0,0 @@ -/** - * This module adds User ID support to prebid.js - */ -import {ajax} from '../src/ajax.js'; -import {config} from '../src/config.js'; -import events from '../src/events.js'; -import * as utils from '../src/utils.js'; -import find from 'core-js/library/fn/array/find'; -import {gdprDataHandler} from '../src/adapterManager.js'; - -const CONSTANTS = require('../src/constants.json'); - -/** - * @typedef {Object} SubmoduleConfig - * @property {string} name - the User ID submodule name - * @property {SubmoduleStorage} storage - browser storage config - * @property {SubmoduleParams} params - params config for use by the submodule.getId function - * @property {Object} value - all object properties will be appended to the User ID bid data - */ - -/** - * @typedef {Object} SubmoduleStorage - * @property {string} type - browser storage type (html5 or cookie) - * @property {string} name - key name to use when saving/reading to local storage or cookies - * @property {number} expires - time to live for browser cookie - */ - -/** - * @typedef {Object} SubmoduleParams - * @property {string} partner - partner url param value - * @property {string} url - webservice request url used to load Id data - */ - -/** - * @typedef {Object} Submodule - * @property {string} name - submodule and config have matching name prop - * @property {decode} decode - decode a stored value for passing to bid requests - * @property {getId} getId - performs action to obtain id and return a value in the callback's response argument - */ - -/** - * @callback getId - * @param {SubmoduleParams} [submoduleConfigParams] - * @param {Object} [consentData] - * @returns {(Function|Object|string)} - */ - -/** - * @callback decode - * @param {Object|string} idData - * @returns {Object} - */ - -/** - * @typedef {Object} SubmoduleContainer - * @property {Submodule} submodule - * @property {SubmoduleConfig} submoduleConfig - * @property {Object} idObj - decoded User ID data that will be appended to bids - * @property {function} callback - */ - -const MODULE_NAME = 'User ID'; -const COOKIE = 'cookie'; -const LOCAL_STORAGE = 'html5'; -const DEFAULT_SYNC_DELAY = 500; - -// @type {number} delay after auction to make webrequests for id data -export let syncDelay; - -// @type {SubmoduleContainer[]} -export let submodules; - -// @type {SubmoduleContainer[]} -let initializedSubmodules; - -// @type {Submodule} -export const unifiedIdSubmodule = { - name: 'unifiedId', - decode(value) { - return (value && typeof value['TDID'] === 'string') ? { 'tdid': value['TDID'] } : undefined; - }, - getId(submoduleConfigParams, consentData) { - if (!submoduleConfigParams || (typeof submoduleConfigParams.partner !== 'string' && typeof submoduleConfigParams.url !== 'string')) { - utils.logError(`${MODULE_NAME} - unifiedId submodule requires either partner or url to be defined`); - return; - } - const url = submoduleConfigParams.url || `http://match.adsrvr.org/track/rid?ttd_pid=${submoduleConfigParams.partner}&fmt=json`; - - return function (callback) { - ajax(url, response => { - let responseObj; - if (response) { - try { - responseObj = JSON.parse(response); - } catch (error) { - utils.logError(error); - } - } - callback(responseObj); - }, undefined, { method: 'GET' }); - } - } -}; - -// @type {Submodule} -export const pubCommonIdSubmodule = { - name: 'pubCommonId', - decode(value) { - return { - 'pubcid': value - } - }, - getId() { - // If the page includes its own pubcid object, then use that instead. - let pubcid; - try { - if (typeof window['PublisherCommonId'] === 'object') { - pubcid = window['PublisherCommonId'].getId(); - } - } catch (e) {} - // check pubcid and return if valid was otherwise create a new id - return (pubcid) || utils.generateUUID(); - } -}; - -/** - * @param {SubmoduleStorage} storage - * @param {string} value - * @param {number|string} expires - */ -export function setStoredValue(storage, value, expires) { - try { - const valueStr = (typeof value === 'object') ? JSON.stringify(value) : value; - const expiresStr = (new Date(Date.now() + (expires * (60 * 60 * 24 * 1000)))).toUTCString(); - - if (storage.type === COOKIE) { - utils.setCookie(storage.name, valueStr, expiresStr); - } else if (storage.type === LOCAL_STORAGE) { - localStorage.setItem(`${storage.name}_exp`, expiresStr); - localStorage.setItem(storage.name, encodeURIComponent(valueStr)); - } - } catch (error) { - utils.logError(error); - } -} - -/** - * @param {SubmoduleStorage} storage - * @returns {string} - */ -export function getStoredValue(storage) { - let storedValue; - try { - if (storage.type === COOKIE) { - storedValue = utils.getCookie(storage.name); - } else if (storage.type === LOCAL_STORAGE) { - const storedValueExp = localStorage.getItem(`${storage.name}_exp`); - // empty string means no expiration set - if (storedValueExp === '') { - storedValue = localStorage.getItem(storage.name); - } else if (storedValueExp) { - if ((new Date(storedValueExp)).getTime() - Date.now() > 0) { - storedValue = decodeURIComponent(localStorage.getItem(storage.name)); - } - } - } - // we support storing either a string or a stringified object, - // so we test if the string contains an stringified object, and if so convert to an object - if (typeof storedValue === 'string' && storedValue.charAt(0) === '{') { - storedValue = JSON.parse(storedValue); - } - } catch (e) { - utils.logError(e); - } - return storedValue; -} - -/** - * test if consent module is present, applies, and is valid for local storage or cookies (purpose 1) - * @param {Object} consentData - * @returns {boolean} - */ -export function hasGDPRConsent(consentData) { - if (consentData && typeof consentData.gdprApplies === 'boolean' && consentData.gdprApplies) { - if (!consentData.consentString) { - return false; - } - if (consentData.vendorData && consentData.vendorData.purposeConsents && consentData.vendorData.purposeConsents['1'] === false) { - return false; - } - } - return true; -} - -/** - * @param {Object[]} submodules - */ -export function processSubmoduleCallbacks(submodules) { - submodules.forEach(function(submodule) { - submodule.callback(function callbackCompleted (idObj) { - // clear callback, this prop is used to test if all submodule callbacks are complete below - submodule.callback = undefined; - - // if valid, id data should be saved to cookie/html storage - if (idObj) { - setStoredValue(submodule.config.storage, idObj, submodule.config.storage.expires); - - // cache decoded value (this is copied to every adUnit bid) - submodule.idObj = submodule.submodule.decode(idObj); - } else { - utils.logError(`${MODULE_NAME}: ${submodule.submodule.name} - request id responded with an empty value`); - } - }); - }); -} - -/** - * @param {Object[]} adUnits - * @param {Object[]} submodules - */ -export function addIdDataToAdUnitBids(adUnits, submodules) { - const submodulesWithIds = submodules.filter(item => typeof item.idObj === 'object' && item.idObj !== null); - if (submodulesWithIds.length) { - if (adUnits) { - adUnits.forEach(adUnit => { - adUnit.bids.forEach(bid => { - // append the User ID property to bid - bid.userId = submodulesWithIds.reduce((carry, item) => { - Object.keys(item.idObj).forEach(key => { - carry[key] = item.idObj[key]; - }); - return carry; - }, {}); - }); - }); - } - } -} - -/** - * Hook is executed before adapters, but after consentManagement. Consent data is requied because - * this module requires GDPR consent with Purpose #1 to save data locally. - * The two main actions handled by the hook are: - * 1. check gdpr consentData and handle submodule initialization. - * 2. append user id data (loaded from cookied/html or from the getId method) to bids to be accessed in adapters. - * @param {object} reqBidsConfigObj required; This is the same param that's used in pbjs.requestBids. - * @param {function} fn required; The next function in the chain, used by hook.js - */ -export function requestBidsHook(fn, reqBidsConfigObj) { - // initialize submodules only when undefined - if (typeof initializedSubmodules === 'undefined') { - initializedSubmodules = initSubmodules(submodules, gdprDataHandler.getConsentData()); - if (initializedSubmodules.length) { - // list of sumodules that have callbacks that need to be executed - const submodulesWithCallbacks = initializedSubmodules.filter(item => typeof item.callback === 'function'); - - if (submodulesWithCallbacks.length) { - // wait for auction complete before processing submodule callbacks - events.on(CONSTANTS.EVENTS.AUCTION_END, function auctionEndHandler() { - events.off(CONSTANTS.EVENTS.AUCTION_END, auctionEndHandler); - - // when syncDelay is zero, process callbacks now, otherwise dealy process with a setTimeout - if (syncDelay > 0) { - setTimeout(function() { - processSubmoduleCallbacks(submodulesWithCallbacks); - }, syncDelay); - } else { - processSubmoduleCallbacks(submodulesWithCallbacks); - } - }); - } - } - } - - // pass available user id data to bid adapters - addIdDataToAdUnitBids(reqBidsConfigObj.adUnits || $$PREBID_GLOBAL$$.adUnits, initializedSubmodules); - - // calling fn allows prebid to continue processing - return fn.call(this, reqBidsConfigObj); -} - -/** - * @param {Object[]} submodules - * @param {Object} consentData - * @returns {string[]} initialized submodules - */ -export function initSubmodules(submodules, consentData) { - // gdpr consent with purpose one is required, otherwise exit immediately - if (!hasGDPRConsent(consentData)) { - utils.logWarn(`${MODULE_NAME} - gdpr permission not valid for local storage or cookies, exit module`); - return []; - } - return submodules.reduce((carry, item) => { - // There are two submodule configuration types to handle: storage or value - // 1. storage: retrieve user id data from cookie/html storage or with the submodule's getId method - // 2. value: pass directly to bids - if (item.config && item.config.storage) { - const storedId = getStoredValue(item.config.storage); - if (storedId) { - // cache decoded value (this is copied to every adUnit bid) - item.idObj = item.submodule.decode(storedId); - } else { - // getId will return user id data or a function that will load the data - const getIdResult = item.submodule.getId(item.config.params, consentData); - - // If the getId result has a type of function, it is asynchronous and cannot be called until later - if (typeof getIdResult === 'function') { - item.callback = getIdResult; - } else { - // A getId result that is not a function is assumed to be valid user id data, which should be saved to users local storage or cookies - setStoredValue(item.config.storage, getIdResult, item.config.storage.expires); - - // cache decoded value (this is copied to every adUnit bid) - item.idObj = item.submodule.decode(getIdResult); - } - } - } else if (item.config.value) { - // cache decoded value (this is copied to every adUnit bid) - item.idObj = item.config.value; - } - - carry.push(item); - return carry; - }, []); -} - -/** - * list of submodule configurations with valid 'storage' or 'value' obj definitions - * * storage config: contains values for storing/retrieving User ID data in browser storage - * * value config: object properties that are copied to bids (without saving to storage) - * @param {SubmoduleConfig[]} submoduleConfigs - * @param {Submodule[]} enabledSubmodules - * @returns {SubmoduleConfig[]} - */ -export function getValidSubmoduleConfigs(submoduleConfigs, enabledSubmodules) { - if (!Array.isArray(submoduleConfigs)) { - return []; - } - - // list of browser enabled storage types - const validStorageTypes = []; - if (utils.localStorageIsEnabled()) { - // check if optout exists in local storage (null if returned if key does not exist) - if (!localStorage.getItem('_pbjs_id_optout') && !localStorage.getItem('_pubcid_optout')) { - validStorageTypes.push(LOCAL_STORAGE); - } else { - utils.logInfo(`${MODULE_NAME} - opt-out localStorage found, exit module`); - } - } - if (utils.cookiesAreEnabled()) { - validStorageTypes.push(COOKIE); - } - - return submoduleConfigs.reduce((carry, submoduleConfig) => { - // every submodule config obj must contain a valid 'name' - if (!submoduleConfig || typeof submoduleConfig.name !== 'string' || !submoduleConfig.name) { - return carry; - } - - // Validate storage config - // contains 'type' and 'name' properties with non-empty string values - // 'type' must be a value currently enabled in the browser - if (submoduleConfig.storage && - typeof submoduleConfig.storage.type === 'string' && submoduleConfig.storage.type && - typeof submoduleConfig.storage.name === 'string' && submoduleConfig.storage.name && - validStorageTypes.indexOf(submoduleConfig.storage.type) !== -1) { - carry.push(submoduleConfig); - } else if (submoduleConfig.value !== null && typeof submoduleConfig.value === 'object') { - // Validate value config - // must be valid object with at least one property - carry.push(submoduleConfig); - } - return carry; - }, []); -} - -/** - * @param config - * @param {Submodule[]} enabledSubmodules - */ -export function init (config, enabledSubmodules) { - submodules = []; - initializedSubmodules = undefined; - - // exit immediately if opt out cookie exists. _pubcid_optout is checked for compatiblility with pubCommonId module opt out - if (utils.getCookie('_pbjs_id_optout')) { - utils.logInfo(`${MODULE_NAME} - opt-out cookie found, exit module`); - return; - } - - // listen for config userSyncs to be set - config.getConfig('usersync', ({usersync}) => { - if (usersync) { - syncDelay = (typeof usersync.syncDelay !== 'undefined') ? usersync.syncDelay : DEFAULT_SYNC_DELAY; - - // filter any invalid configs out - const submoduleConfigs = getValidSubmoduleConfigs(usersync.userIds, enabledSubmodules); - if (submoduleConfigs.length === 0) { - // exit module, if no valid configurations exist - return; - } - - // get list of submodules with valid configurations - submodules = enabledSubmodules.reduce((carry, enabledSubmodule) => { - // try to find submodule configuration for submodule, if config exists it should be enabled - const submoduleConfig = find(submoduleConfigs, item => item.name === enabledSubmodule.name); - - if (submoduleConfig) { - // append {SubmoduleContainer} containing the submodule and config - carry.push({ - submodule: enabledSubmodule, - config: submoduleConfig, - idObj: undefined - }); - } - return carry; - }, []); - - // complete initialization if any submodules exist - if (submodules.length) { - // priority has been set so it loads after consentManagement (which has a priority of 50) - $$PREBID_GLOBAL$$.requestBids.before(requestBidsHook, 40); - utils.logInfo(`${MODULE_NAME} - usersync config updated for ${submodules.length} submodules`); - } - } - }); -} - -init(config, [pubCommonIdSubmodule, unifiedIdSubmodule]); diff --git a/modules/userId/index.js b/modules/userId/index.js new file mode 100644 index 00000000000..fb7a748b7ec --- /dev/null +++ b/modules/userId/index.js @@ -0,0 +1,486 @@ +/** + * This module adds User ID support to prebid.js + * @module modules/userId + */ + +/** + * @interface Submodule + */ + +/** + * @function + * @summary performs action to obtain id and return a value in the callback's response argument + * @name Submodule#getId + * @param {SubmoduleParams} configParams + * @param {ConsentData|undefined} consentData + * @param {(Object|undefined)} cacheIdObj + * @return {(Object|function)} id data or a callback, the callback is called on the auction end event + */ + +/** + * @function + * @summary decode a stored value for passing to bid requests + * @name Submodule#decode + * @param {Object|string} value + * @return {(Object|undefined)} + */ + +/** + * @property + * @summary used to link submodule with config + * @name Submodule#name + * @type {string} + */ + +/** + * @typedef {Object} SubmoduleConfig + * @property {string} name - the User ID submodule name (used to link submodule with config) + * @property {(SubmoduleStorage|undefined)} storage - browser storage config + * @property {(SubmoduleParams|undefined)} params - params config for use by the submodule.getId function + * @property {(Object|undefined)} value - if not empty, this value is added to bid requests for access in adapters + */ + +/** + * @typedef {Object} SubmoduleStorage + * @property {string} type - browser storage type (html5 or cookie) + * @property {string} name - key name to use when saving/reading to local storage or cookies + * @property {number} expires - time to live for browser storage in days + * @property {(number|undefined)} refreshInSeconds - if not empty, this value defines the maximum time span in seconds before refreshing user ID stored in browser + */ + +/** + * @typedef {Object} SubmoduleParams + * @property {(string|undefined)} partner - partner url param value + * @property {(string|undefined)} url - webservice request url used to load Id data + * @property {(string|undefined)} pid - placement id url param value + */ + +/** + * @typedef {Object} SubmoduleContainer + * @property {Submodule} submodule + * @property {SubmoduleConfig} config + * @property {(Object|undefined)} idObj - cache decoded id value (this is copied to every adUnit bid) + * @property {(function|undefined)} callback - holds reference to submodule.getId() result if it returned a function. Will be set to undefined after callback executes + */ + +/** + * @typedef {Object} ConsentData + * @property {(string|undefined)} consentString + * @property {(Object|undefined)} vendorData + * @property {(boolean|undefined)} gdprApplies + */ + +import find from 'core-js/library/fn/array/find'; +import {config} from '../../src/config'; +import events from '../../src/events'; +import * as utils from '../../src/utils'; +import {getGlobal} from '../../src/prebidGlobal'; +import {gdprDataHandler} from '../../src/adapterManager'; +import CONSTANTS from '../../src/constants.json'; +import {module} from '../../src/hook'; +import {unifiedIdSubmodule} from './unifiedIdSystem.js'; +import {pubCommonIdSubmodule} from './pubCommonIdSystem.js'; + +const MODULE_NAME = 'User ID'; +const COOKIE = 'cookie'; +const LOCAL_STORAGE = 'html5'; +const DEFAULT_SYNC_DELAY = 500; + +/** @type {string[]} */ +let validStorageTypes = []; + +/** @type {boolean} */ +let addedUserIdHook = false; + +/** @type {SubmoduleContainer[]} */ +let submodules = []; + +/** @type {SubmoduleContainer[]} */ +let initializedSubmodules; + +/** @type {SubmoduleConfig[]} */ +let configRegistry = []; + +/** @type {Submodule[]} */ +let submoduleRegistry = []; + +/** @type {(number|undefined)} */ +export let syncDelay; + +/** @param {Submodule[]} submodules */ +export function setSubmoduleRegistry(submodules) { + submoduleRegistry = submodules; +} + +/** + * @param {SubmoduleStorage} storage + * @param {(Object|string)} value + */ +function setStoredValue(storage, value) { + try { + const valueStr = utils.isPlainObject(value) ? JSON.stringify(value) : value; + const expiresStr = (new Date(Date.now() + (storage.expires * (60 * 60 * 24 * 1000)))).toUTCString(); + if (storage.type === COOKIE) { + utils.setCookie(storage.name, valueStr, expiresStr); + if (typeof storage.refreshInSeconds === 'number') { + utils.setCookie(`${storage.name}_last`, new Date().toUTCString(), expiresStr); + } + } else if (storage.type === LOCAL_STORAGE) { + localStorage.setItem(`${storage.name}_exp`, expiresStr); + localStorage.setItem(storage.name, encodeURIComponent(valueStr)); + if (typeof storage.refreshInSeconds === 'number') { + localStorage.setItem(`${storage.name}_last`, new Date().toUTCString()); + } + } + } catch (error) { + utils.logError(error); + } +} + +/** + * @param {SubmoduleStorage} storage + * @param {String|undefined} key optional key of the value + * @returns {string} + */ +function getStoredValue(storage, key = undefined) { + const storedKey = key ? `${storage.name}_${key}` : storage.name; + let storedValue; + try { + if (storage.type === COOKIE) { + storedValue = utils.getCookie(storedKey); + } else if (storage.type === LOCAL_STORAGE) { + const storedValueExp = localStorage.getItem(`${storage.name}_exp`); + // empty string means no expiration set + if (storedValueExp === '') { + storedValue = localStorage.getItem(storedKey); + } else if (storedValueExp) { + if ((new Date(storedValueExp)).getTime() - Date.now() > 0) { + storedValue = decodeURIComponent(localStorage.getItem(storedKey)); + } + } + } + // support storing a string or a stringified object + if (typeof storedValue === 'string' && storedValue.charAt(0) === '{') { + storedValue = JSON.parse(storedValue); + } + } catch (e) { + utils.logError(e); + } + return storedValue; +} + +/** + * test if consent module is present, applies, and is valid for local storage or cookies (purpose 1) + * @param {ConsentData} consentData + * @returns {boolean} + */ +function hasGDPRConsent(consentData) { + if (consentData && typeof consentData.gdprApplies === 'boolean' && consentData.gdprApplies) { + if (!consentData.consentString) { + return false; + } + if (consentData.vendorData && consentData.vendorData.purposeConsents && consentData.vendorData.purposeConsents['1'] === false) { + return false; + } + } + return true; +} + +/** + * @param {SubmoduleContainer[]} submodules + */ +function processSubmoduleCallbacks(submodules) { + submodules.forEach(function(submodule) { + submodule.callback(function callbackCompleted(idObj) { + // clear callback, this prop is used to test if all submodule callbacks are complete below + submodule.callback = undefined; + // if valid, id data should be saved to cookie/html storage + if (idObj) { + if (submodule.config.storage) { + setStoredValue(submodule.config.storage, idObj); + } + // cache decoded value (this is copied to every adUnit bid) + submodule.idObj = submodule.submodule.decode(idObj); + } else { + utils.logError(`${MODULE_NAME}: ${submodule.submodule.name} - request id responded with an empty value`); + } + }); + }); +} + +/** + * This function will create a combined object for all subModule Ids + * @param {SubmoduleContainer[]} submodules + */ +function getCombinedSubmoduleIds(submodules) { + if (!Array.isArray(submodules) || !submodules.length) { + return {}; + } + const combinedSubmoduleIds = submodules.filter(i => utils.isPlainObject(i.idObj) && Object.keys(i.idObj).length).reduce((carry, i) => { + Object.keys(i.idObj).forEach(key => { + carry[key] = i.idObj[key]; + }); + return carry; + }, {}); + + return combinedSubmoduleIds; +} + +/** + * @param {AdUnit[]} adUnits + * @param {SubmoduleContainer[]} submodules + */ +function addIdDataToAdUnitBids(adUnits, submodules) { + if ([adUnits].some(i => !Array.isArray(i) || !i.length)) { + return; + } + const combinedSubmoduleIds = getCombinedSubmoduleIds(submodules); + if (Object.keys(combinedSubmoduleIds).length) { + adUnits.forEach(adUnit => { + adUnit.bids.forEach(bid => { + // create a User ID object on the bid, + bid.userId = combinedSubmoduleIds; + }); + }); + } +} + +/** + * This is a common function that will initalize subModules if not already done and it will also execute subModule callbacks + */ +function initializeSubmodulesAndExecuteCallbacks() { + // initialize submodules only when undefined + if (typeof initializedSubmodules === 'undefined') { + initializedSubmodules = initSubmodules(submodules, gdprDataHandler.getConsentData()); + if (initializedSubmodules.length) { + // list of submodules that have callbacks that need to be executed + const submodulesWithCallbacks = initializedSubmodules.filter(item => utils.isFn(item.callback)); + + if (submodulesWithCallbacks.length) { + // wait for auction complete before processing submodule callbacks + events.on(CONSTANTS.EVENTS.AUCTION_END, function auctionEndHandler() { + events.off(CONSTANTS.EVENTS.AUCTION_END, auctionEndHandler); + + // when syncDelay is zero, process callbacks now, otherwise delay process with a setTimeout + if (syncDelay > 0) { + setTimeout(function() { + processSubmoduleCallbacks(submodulesWithCallbacks); + }, syncDelay); + } else { + processSubmoduleCallbacks(submodulesWithCallbacks); + } + }); + } + } + } +} + +/** + * Hook is executed before adapters, but after consentManagement. Consent data is requied because + * this module requires GDPR consent with Purpose #1 to save data locally. + * The two main actions handled by the hook are: + * 1. check gdpr consentData and handle submodule initialization. + * 2. append user id data (loaded from cookied/html or from the getId method) to bids to be accessed in adapters. + * @param {Object} reqBidsConfigObj required; This is the same param that's used in pbjs.requestBids. + * @param {function} fn required; The next function in the chain, used by hook.js + */ +export function requestBidsHook(fn, reqBidsConfigObj) { + // initialize submodules only when undefined + initializeSubmodulesAndExecuteCallbacks(); + // pass available user id data to bid adapters + addIdDataToAdUnitBids(reqBidsConfigObj.adUnits || getGlobal().adUnits, initializedSubmodules); + // calling fn allows prebid to continue processing + return fn.call(this, reqBidsConfigObj); +} + +/** + * This function will be exposed in global-name-space so that userIds stored by Prebid UserId module can be used by external codes as well. + * Simple use case will be passing these UserIds to A9 wrapper solution + */ +function getUserIds() { + // initialize submodules only when undefined + initializeSubmodulesAndExecuteCallbacks(); + return getCombinedSubmoduleIds(initializedSubmodules); +}; + +/** + * @param {SubmoduleContainer[]} submodules + * @param {ConsentData} consentData + * @returns {SubmoduleContainer[]} initialized submodules + */ +function initSubmodules(submodules, consentData) { + // gdpr consent with purpose one is required, otherwise exit immediately + if (!hasGDPRConsent(consentData)) { + utils.logWarn(`${MODULE_NAME} - gdpr permission not valid for local storage or cookies, exit module`); + return []; + } + return submodules.reduce((carry, submodule) => { + // There are two submodule configuration types to handle: storage or value + // 1. storage: retrieve user id data from cookie/html storage or with the submodule's getId method + // 2. value: pass directly to bids + if (submodule.config.storage) { + const storedId = getStoredValue(submodule.config.storage); + if (storedId) { + // cache decoded value (this is copied to every adUnit bid) + submodule.idObj = submodule.submodule.decode(storedId); + } + let refreshNeeded = false; + if (typeof submodule.config.storage.refreshInSeconds === 'number') { + const storedDate = new Date(getStoredValue(submodule.config.storage, 'last')); + refreshNeeded = storedDate && (Date.now() - storedDate.getTime() > submodule.config.storage.refreshInSeconds * 1000); + } + if (!storedId || refreshNeeded) { + // getId will return user id data or a function that will load the data + const getIdResult = submodule.submodule.getId(submodule.config.params, consentData, storedId); + + // If the getId result has a type of function, it is asynchronous and cannot be called until later + if (typeof getIdResult === 'function') { + submodule.callback = getIdResult; + } else if (getIdResult) { + // A getId result that is not a function is assumed to be valid user id data, which should be saved to users local storage or cookies + setStoredValue(submodule.config.storage, getIdResult); + // cache decoded value (this is copied to every adUnit bid) + submodule.idObj = submodule.submodule.decode(getIdResult); + } + } + } else if (submodule.config.value) { + // cache decoded value (this is copied to every adUnit bid) + submodule.idObj = submodule.config.value; + } else { + const result = submodule.submodule.getId(submodule.config.params, consentData, undefined); + if (typeof result === 'function') { + submodule.callback = result; + } else { + submodule.idObj = submodule.submodule.decode(); + } + } + carry.push(submodule); + return carry; + }, []); +} + +/** + * list of submodule configurations with valid 'storage' or 'value' obj definitions + * * storage config: contains values for storing/retrieving User ID data in browser storage + * * value config: object properties that are copied to bids (without saving to storage) + * @param {SubmoduleConfig[]} configRegistry + * @param {Submodule[]} submoduleRegistry + * @param {string[]} activeStorageTypes + * @returns {SubmoduleConfig[]} + */ +function getValidSubmoduleConfigs(configRegistry, submoduleRegistry, activeStorageTypes) { + if (!Array.isArray(configRegistry)) { + return []; + } + return configRegistry.reduce((carry, config) => { + // every submodule config obj must contain a valid 'name' + if (!config || utils.isEmptyStr(config.name)) { + return carry; + } + // Validate storage config contains 'type' and 'name' properties with non-empty string values + // 'type' must be a value currently enabled in the browser + if (config.storage && + !utils.isEmptyStr(config.storage.type) && + !utils.isEmptyStr(config.storage.name) && + activeStorageTypes.indexOf(config.storage.type) !== -1) { + carry.push(config); + } else if (utils.isPlainObject(config.value)) { + carry.push(config); + } else if (!config.storage && !config.value) { + carry.push(config); + } + return carry; + }, []); +} + +/** + * update submodules by validating against existing configs and storage types + */ +function updateSubmodules() { + const configs = getValidSubmoduleConfigs(configRegistry, submoduleRegistry, validStorageTypes); + if (!configs.length) { + return; + } + // do this to avoid reprocessing submodules + const addedSubmodules = submoduleRegistry.filter(i => !find(submodules, j => j.name === i.name)); + + // find submodule and the matching configuration, if found create and append a SubmoduleContainer + submodules = addedSubmodules.map(i => { + const submoduleConfig = find(configs, j => j.name === i.name); + return submoduleConfig ? { + submodule: i, + config: submoduleConfig, + callback: undefined, + idObj: undefined + } : null; + }).filter(submodule => submodule !== null); + + if (!addedUserIdHook && submodules.length) { + // priority value 40 will load after consentManagement with a priority of 50 + getGlobal().requestBids.before(requestBidsHook, 40); + utils.logInfo(`${MODULE_NAME} - usersync config updated for ${submodules.length} submodules`); + addedUserIdHook = true; + } +} + +/** + * enable submodule in User ID + * @param {Submodule} submodule + */ +export function attachIdSystem(submodule) { + if (!find(submoduleRegistry, i => i.name === submodule.name)) { + submoduleRegistry.push(submodule); + updateSubmodules(); + } +} + +/** + * test browser support for storage config types (local storage or cookie), initializes submodules but consentManagement is required, + * so a callback is added to fire after the consentManagement module. + * @param {{getConfig:function}} config + */ +export function init(config) { + submodules = []; + configRegistry = []; + addedUserIdHook = false; + initializedSubmodules = undefined; + + // list of browser enabled storage types + validStorageTypes = [ + utils.localStorageIsEnabled() ? LOCAL_STORAGE : null, + utils.cookiesAreEnabled() ? COOKIE : null + ].filter(i => i !== null); + + // exit immediately if opt out cookie or local storage keys exists. + if (validStorageTypes.indexOf(COOKIE) !== -1 && utils.getCookie('_pbjs_id_optout')) { + utils.logInfo(`${MODULE_NAME} - opt-out cookie found, exit module`); + return; + } + // _pubcid_optout is checked for compatiblility with pubCommonId + if (validStorageTypes.indexOf(LOCAL_STORAGE) !== -1 && (localStorage.getItem('_pbjs_id_optout') || localStorage.getItem('_pubcid_optout'))) { + utils.logInfo(`${MODULE_NAME} - opt-out localStorage found, exit module`); + return; + } + // listen for config userSyncs to be set + config.getConfig(conf => { + // Note: support for both 'userSync' and 'usersync' will be deprecated with Prebid.js 3.0 + const userSync = conf.userSync || conf.usersync; + if (userSync && userSync.userIds) { + configRegistry = userSync.userIds; + syncDelay = utils.isNumber(userSync.syncDelay) ? userSync.syncDelay : DEFAULT_SYNC_DELAY; + updateSubmodules(); + } + }); + + // exposing getUserIds function in global-name-space so that userIds stored in Prebid can be used by external codes. + (getGlobal()).getUserIds = getUserIds; +} + +// init config update listener to start the application +init(config); + +// add submodules after init has been called +attachIdSystem(pubCommonIdSubmodule); +attachIdSystem(unifiedIdSubmodule); + +module('userId', attachIdSystem); diff --git a/modules/userId/pubCommonIdSystem.js b/modules/userId/pubCommonIdSystem.js new file mode 100644 index 00000000000..f4d6b41a127 --- /dev/null +++ b/modules/userId/pubCommonIdSystem.js @@ -0,0 +1,42 @@ +/** + * This module adds PubCommonId to the User ID module + * The {@link module:modules/userId} module is required + * @module modules/pubCommonIdSystem + * @requires module:modules/userId + */ + +import * as utils from '../../src/utils'; + +/** @type {Submodule} */ +export const pubCommonIdSubmodule = { + /** + * used to link submodule with config + * @type {string} + */ + name: 'pubCommonId', + /** + * decode the stored id value for passing to bid requests + * @function + * @param {string} value + * @returns {{pubcid:string}} + */ + decode(value) { + return { 'pubcid': value } + }, + /** + * performs action to obtain id + * @function + * @returns {string} + */ + getId() { + // If the page includes its own pubcid object, then use that instead. + let pubcid; + try { + if (typeof window['PublisherCommonId'] === 'object') { + pubcid = window['PublisherCommonId'].getId(); + } + } catch (e) {} + // check pubcid and return if valid was otherwise create a new id + return (pubcid) || utils.generateUUID(); + } +}; diff --git a/modules/userId/unifiedIdSystem.js b/modules/userId/unifiedIdSystem.js new file mode 100644 index 00000000000..1bc369bb9fc --- /dev/null +++ b/modules/userId/unifiedIdSystem.js @@ -0,0 +1,55 @@ +/** + * This module adds UnifiedId to the User ID module + * The {@link module:modules/userId} module is required + * @module modules/unifiedIdSystem + * @requires module:modules/userId + */ + +import * as utils from '../../src/utils' +import {ajax} from '../../src/ajax'; + +/** @type {Submodule} */ +export const unifiedIdSubmodule = { + /** + * used to link submodule with config + * @type {string} + */ + name: 'unifiedId', + /** + * decode the stored id value for passing to bid requests + * @function + * @param {{TDID:string}} value + * @returns {{tdid:Object}} + */ + decode(value) { + return (value && typeof value['TDID'] === 'string') ? { 'tdid': value['TDID'] } : undefined; + }, + /** + * performs action to obtain id and return a value in the callback's response argument + * @function + * @param {SubmoduleParams} [configParams] + * @returns {function(callback:function)} + */ + getId(configParams) { + if (!configParams || (typeof configParams.partner !== 'string' && typeof configParams.url !== 'string')) { + utils.logError('User ID - unifiedId submodule requires either partner or url to be defined'); + return; + } + // use protocol relative urls for http or https + const url = configParams.url || `//match.adsrvr.org/track/rid?ttd_pid=${configParams.partner}&fmt=json`; + + return function (callback) { + ajax(url, response => { + let responseObj; + if (response) { + try { + responseObj = JSON.parse(response); + } catch (error) { + utils.logError(error); + } + } + callback(responseObj); + }, undefined, { method: 'GET', withCredentials: true }); + } + } +}; diff --git a/modules/userId.md b/modules/userId/userId.md similarity index 51% rename from modules/userId.md rename to modules/userId/userId.md index a873a76674f..623aeaa160e 100644 --- a/modules/userId.md +++ b/modules/userId/userId.md @@ -1,14 +1,21 @@ ## User ID Example Configuration -Example showing `cookie` storage for user id data for both submodules +Example showing `cookie` storage for user id data for each of the submodules ``` pbjs.setConfig({ - usersync: { + userSync: { userIds: [{ + name: "pubCommonId", + storage: { + type: "cookie", + name: "_pubcid", + expires: 60 + } + }, { name: "unifiedId", params: { partner: "prebid", - url: "http://match.adsrvr.org/track/rid?ttd_pid=prebid&fmt=json" + url: "//match.adsrvr.org/track/rid?ttd_pid=prebid&fmt=json" }, storage: { type: "cookie", @@ -16,10 +23,24 @@ pbjs.setConfig({ expires: 60 } }, { - name: "pubCommonId", + name: "id5Id", + params: { + partner: 173 //Set your real ID5 partner ID here for production, please ask for one at http://id5.io/prebid + }, storage: { type: "cookie", - name: "_pubcid", + name: "id5id", + expires: 5, // Expiration of cookies in days + refreshInSeconds: 8*3600 // User Id cache lifetime in seconds, defaulting to 'expires' + } + }, { + name: 'identityLink', + params: { + pid: '999' // Set your real identityLink placement ID here + }, + storage: { + type: 'cookie', + name: 'idl_env', expires: 60 } }], @@ -28,7 +49,7 @@ pbjs.setConfig({ }); ``` -Example showing `localStorage` for user id data for both submodules +Example showing `localStorage` for user id data for some submodules ``` pbjs.setConfig({ usersync: { @@ -50,6 +71,16 @@ pbjs.setConfig({ name: "pubcid", expires: 60 } + }, { + name: 'identityLink', + params: { + pid: '999' // Set your real identityLink placement ID here + }, + storage: { + type: 'html5', + name: 'idl_env', + expires: 60 + } }], syncDelay: 5000 } @@ -65,6 +96,10 @@ pbjs.setConfig({ value: { "providedPubCommonId": "1234567890" } + }, + { + name: "id5Id", + value: { "id5id": "ID5-abcdef" } }], syncDelay: 5000 } diff --git a/modules/userIdTargeting.js b/modules/userIdTargeting.js new file mode 100644 index 00000000000..2a19bd62fbb --- /dev/null +++ b/modules/userIdTargeting.js @@ -0,0 +1,61 @@ +import {config} from '../src/config'; +import {getGlobal} from '../src/prebidGlobal'; +import CONSTANTS from '../src/constants.json'; +import events from '../src/events'; +import { isStr, isPlainObject, isBoolean, isFn, hasOwn, logInfo } from '../src/utils'; + +const MODULE_NAME = 'userIdTargeting'; +const GAM = 'GAM'; +const GAM_KEYS_CONFIG = 'GAM_KEYS'; + +export function userIdTargeting(userIds, config) { + if (!isPlainObject(config)) { + logInfo(MODULE_NAME + ': Invalid config found, not sharing userIds externally.'); + return; + } + + const PUB_GAM_KEYS = isPlainObject(config[GAM_KEYS_CONFIG]) ? config[GAM_KEYS_CONFIG] : {}; + let SHARE_WITH_GAM = isBoolean(config[GAM]) ? config[GAM] : false; + let GAM_API; + + if (!SHARE_WITH_GAM) { + logInfo(MODULE_NAME + ': Not enabled for ' + GAM); + } + + if (window.googletag && isFn(window.googletag.pubads) && hasOwn(window.googletag.pubads(), 'setTargeting') && isFn(window.googletag.pubads().setTargeting)) { + GAM_API = window.googletag.pubads().setTargeting; + } else { + SHARE_WITH_GAM = false; + logInfo(MODULE_NAME + ': Could not find googletag.pubads().setTargeting API. Not adding User Ids in targeting.') + return; + } + + Object.keys(userIds).forEach(function(key) { + if (userIds[key]) { + // PUB_GAM_KEYS: { "tdid": '' } means the publisher does not want to send the tdid to GAM + if (SHARE_WITH_GAM && PUB_GAM_KEYS[key] !== '') { + let uidStr; + if (isStr(userIds[key])) { + uidStr = userIds[key]; + } else if (isPlainObject(userIds[key])) { + uidStr = JSON.stringify(userIds[key]) + } else { + logInfo(MODULE_NAME + ': ' + key + ' User ID is not an object or a string.'); + return; + } + GAM_API( + (hasOwn(PUB_GAM_KEYS, key) ? PUB_GAM_KEYS[key] : key), + [ uidStr ] + ); + } + } + }); +} + +export function init(config) { + events.on(CONSTANTS.EVENTS.AUCTION_END, function() { + userIdTargeting((getGlobal()).getUserIds(), config.getConfig(MODULE_NAME)); + }) +} + +init(config) diff --git a/modules/userIdTargeting.md b/modules/userIdTargeting.md new file mode 100644 index 00000000000..f99fd5308b3 --- /dev/null +++ b/modules/userIdTargeting.md @@ -0,0 +1,37 @@ +## userIdTargeting Module +- This module works with userId module. +- This module is used to pass userIds to GAM in targeting so that user ids can be used to pass in Google Exchange Bidding or can be used for targeting in GAM. + +## Sample config +``` +pbjs.setConfig({ + + // your existing userIds config + + usersync: { + userIds: [{...}, ...] + }, + + // new userIdTargeting config + + userIdTargeting: { + "GAM": true, + "GAM_KEYS": { + "tdid": "TTD_ID" // send tdid as TTD_ID + } + } +}); +``` + +## Config options +- GAM: is required to be set to true if a publisher wants to send UserIds as targeting in GAM call. This module uses ``` googletag.pubads().setTargeting('key-name', ['value']) ``` API to set GAM targeting. +- GAM_KEYS: is an optional config object to be used with ``` "GAM": true ```. If not passed then all UserIds are passed with respective key-name used in UserIds object. +If a publisher wants to pass ```UserId.tdid``` as TTD_ID in targeting then set ``` GAM_KEYS: { "tdid": "TTD_ID" }``` +If a publisher does not wants to pass ```UserId.tdid``` but wants to pass other Ids in UserId tthen set ``` GAM_KEYS: { "tdid": "" }``` + +## Including this module in Prebid +``` $ gulp build --modules=userId,userIdTargeting,pubmaticBidAdapter ``` + +## Notes +- We can add support for other external systems like GAM in future +- We have not added support for A9/APSTag as it is called in parallel with Prebid. This module executes when ```pbjs.requestBids``` is called, in practice, call to A9 is expected to execute in paralle to Prebid thus we have not covered A9 here. For sending Uids in A9, one will need to set those Ids in params key in the object passed to ```apstag.init```, ```pbjs.getUserIds``` can be used for the same. diff --git a/modules/viBidAdapter.js b/modules/viBidAdapter.js index 5166277ff81..93ead1c2380 100644 --- a/modules/viBidAdapter.js +++ b/modules/viBidAdapter.js @@ -1,69 +1,388 @@ -import * as utils from '../src/utils'; import { registerBidder } from '../src/adapters/bidderFactory'; -import { BANNER } from '../src/mediaTypes'; +import * as mediaTypes from '../src/mediaTypes'; -const BIDDER_CODE = 'vi'; -const SUPPORTED_MEDIA_TYPES = [BANNER]; +export function get(path, obj, notFound) { + path = typeof path === 'string' ? path.split('.') : path; -function isBidRequestValid(bid) { - return !!(bid.params.pubId); + while (path.length) { + const [key] = path; + if (!(obj instanceof Object) || !(key in obj)) return notFound; + obj = obj[key]; + path = path.slice(1); + } + + return obj; } -function buildRequests(bidReqs) { - let imps = []; - utils._each(bidReqs, function (bid) { - imps.push({ - id: bid.bidId, - sizes: utils.parseSizesInput(bid.sizes).map(size => size.split('x')), - bidFloor: parseFloat(bid.params.bidFloor) > 0 ? bid.params.bidFloor : 0 - }); - }); +export function merge(a, b, fn = a => a) { + const res = {}; + + for (const key in a) { + if (key in b) { + res[key] = fn(a[key], b[key]); + } else { + res[key] = a[key]; + } + } + + for (const key in b) { + if (!(key in a)) res[key] = b[key]; + } + + return res; +} + +export function ratioToPercentageCeil(x) { + return Math.ceil(x * 100); +} - const bidRequest = { - id: bidReqs[0].requestId, - imps: imps, - publisherId: utils.getBidIdParameter('pubId', bidReqs[0].params), - siteId: utils.getBidIdParameter('siteId', bidReqs[0].params), - cat: utils.getBidIdParameter('cat', bidReqs[0].params), - language: utils.getBidIdParameter('lang', bidReqs[0].params), - domain: utils.getTopWindowLocation().hostname, - page: utils.getTopWindowUrl(), - referrer: utils.getTopWindowReferrer() +export function getDocumentHeight(curDocument = document) { + return Math.max( + get('body.clientHeight', curDocument, 0), + get('body.scrollHeight', curDocument, 0), + get('body.offsetHeight', curDocument, 0), + get('documentElement.clientHeight', curDocument, 0), + get('documentElement.scrollHeight', curDocument, 0), + get('documentElement.offsetHeight', curDocument, 0) + ); +} + +export function getOffset(element) { + const rect = element.getBoundingClientRect(); + const elementWindow = getElementWindow(element); + if (!elementWindow) throw new Error('cannot get element window'); + const scrollLeft = + elementWindow.pageXOffset || get('documentElement.scrollLeft', document, 0); + const scrollTop = + elementWindow.pageYOffset || get('documentElement.scrollTop', document, 0); + return { + top: rect.top + scrollTop, + right: rect.right + scrollLeft, + bottom: rect.bottom + scrollTop, + left: rect.left + scrollLeft }; +} + +var IframeType; + +(function(IframeType) { + IframeType['safeframe'] = 'safeframe'; + IframeType['friendly'] = 'friendly'; + IframeType['nonfriendly'] = 'nonfriendly'; +})(IframeType || (IframeType = {})); + +export function getWindowParents(curWindow = window) { + const parents = []; + + while (curWindow && curWindow.parent && curWindow !== curWindow.parent) { + parents.push(curWindow.parent); + curWindow = curWindow.parent; + } + + return parents; +} + +export function getTopmostReachableWindow(curWindow = window) { + const parents = getWindowParents(curWindow); + return parents.length ? parents[parents.length - 1] : curWindow; +} + +export function topDocumentIsReachable(curWindow = window) { + if (!isInsideIframe(curWindow)) return true; + const windowParents = getWindowParents(curWindow); + + try { + const topWindow = windowParents[windowParents.length - 1]; + + return topWindow === curWindow.top && !!curWindow.top.document; + } catch (e) { + return false; + } +} + +export function isInsideIframe(curWindow = window) { + return curWindow !== curWindow.top; +} + +export function isInsideSafeframe(curWindow = window) { + return !topDocumentIsReachable(curWindow) && !!curWindow.$sf; +} + +export function isInsideFriendlyIframe(curWindow = window) { + return isInsideIframe(curWindow) && topDocumentIsReachable(curWindow); +} + +export function getIframeType(curWindow = window) { + if (!isInsideIframe(curWindow)) return; + if (isInsideSafeframe(curWindow)) return IframeType.safeframe; + if (isInsideFriendlyIframe(curWindow)) return IframeType.friendly; + return IframeType.nonfriendly; +} + +function getElementWindow(element) { + return element.ownerDocument + ? element.ownerDocument.defaultView + : element.defaultView; +} + +const NO_CUTS = { + top: 0, + right: 0, + bottom: 0, + left: 0 +}; + +export function getRectCuts(rect, vh, vw, vCuts = NO_CUTS) { + let { top, left } = rect; + const { bottom, right } = rect; + top = top + vCuts.top; + left = left + vCuts.left; + vh = vh + vCuts.bottom; + vw = vw + vCuts.right; return { - method: 'POST', - url: `//pb.vi-serve.com/prebid/bid`, - data: JSON.stringify(bidRequest), - options: {contentType: 'application/json', withCredentials: false} + bottom: Math.min(0, vh - bottom), + left: Math.min(0, left), + right: Math.min(0, vw - right), + top: Math.min(0, top) }; } -function interpretResponse(bids) { - let responses = []; - utils._each(bids.body, function(bid) { - responses.push({ - requestId: bid.id, - cpm: parseFloat(bid.price), - width: parseInt(bid.width, 10), - height: parseInt(bid.height, 10), - creativeId: bid.creativeId, - dealId: bid.dealId || null, - currency: 'USD', - netRevenue: true, - mediaType: BANNER, - ad: decodeURIComponent(`${bid.ad}`), - ttl: 60000 +export function getFrameElements(curWindow = window) { + const frameElements = []; + + while (curWindow && curWindow.frameElement) { + frameElements.unshift(curWindow.frameElement); + curWindow = + curWindow.frameElement.ownerDocument && + curWindow.frameElement.ownerDocument.defaultView; + } + + return frameElements; +} + +export function getElementCuts(element, vCuts) { + const window = getElementWindow(element); + return getRectCuts( + element.getBoundingClientRect(), + window ? window.innerHeight : 0, + window ? window.innerWidth : 0, + vCuts + ); +} + +export function area(width, height, areaCuts = NO_CUTS) { + const { top, right, bottom, left } = areaCuts; + return Math.max(0, (width + left + right) * (height + top + bottom)); +} + +export function getInViewRatio(element) { + const elements = [...getFrameElements(getElementWindow(element)), element]; + const vCuts = elements.reduce( + (vCuts, element) => getElementCuts(element, vCuts), + NO_CUTS + ); + return ( + area(element.offsetWidth || 1, element.offsetHeight || 1, vCuts) / + area(element.offsetWidth || 1, element.offsetHeight || 1) + ); +} + +export function getInViewRatioInsideTopFrame(element) { + const elements = [...getFrameElements().slice(1), element]; + const vCuts = elements.reduce( + (vCuts, element) => getElementCuts(element, vCuts), + NO_CUTS + ); + return ( + area(element.offsetWidth, element.offsetHeight, vCuts) / + area(element.offsetWidth, element.offsetHeight) + ); +} + +export function getMayBecomeVisible(element) { + return !isInsideIframe() || !!getInViewRatioInsideTopFrame(element); +} + +export function getInViewPercentage(element) { + return ratioToPercentageCeil(getInViewRatio(element)); +} + +export function getOffsetTopDocument(element) { + return [...getFrameElements(getElementWindow(element)), element].reduce( + (acc, elem) => merge(acc, getOffset(elem), (a, b) => a + b), + { + top: 0, + right: 0, + bottom: 0, + left: 0 + } + ); +} + +export function getOffsetTopDocumentPercentage(element) { + const elementWindow = getElementWindow(element); + if (!elementWindow) throw new Error('cannot get element window'); + if (!topDocumentIsReachable(elementWindow)) { + throw new Error("top window isn't reachable"); + } + const topWindow = getTopmostReachableWindow(elementWindow); + const documentHeight = getDocumentHeight(topWindow.document); + return ratioToPercentageCeil( + getOffsetTopDocument(element).top / documentHeight + ); +} + +export function getOffsetToView(element) { + const elemWindow = getElementWindow(element); + if (!elemWindow) throw new Error('cannot get element window'); + const topWindow = getTopmostReachableWindow(elemWindow); + const { top, bottom } = getOffsetTopDocument(element); + const topWindowHeight = topWindow.innerHeight; + + if (bottom < topWindow.scrollY) return bottom - topWindow.scrollY; + + if (top > topWindow.scrollY + topWindowHeight) { + return top - topWindow.scrollY - topWindowHeight; + } + + return 0; +} + +export function getOffsetToViewPercentage(element) { + return ratioToPercentageCeil( + getOffsetToView(element) / + getDocumentHeight( + getTopmostReachableWindow(getElementWindow(element)).document + ) + ); +} + +export function getViewabilityDescription(element) { + let iframeType; + try { + if (!element) { + return { + error: 'no element' + }; + } + iframeType = getIframeType(getElementWindow(element)); + if (!iframeType || iframeType === IframeType.friendly) { + const inViewPercentage = getInViewPercentage(element); + return { + inView: inViewPercentage, + hidden: !inViewPercentage && !getMayBecomeVisible(element), + offsetTop: getOffsetTopDocumentPercentage(element), + offsetView: getOffsetToViewPercentage(element), + iframeType + }; + } + return { + iframeType + }; + } catch (error) { + return { + iframeType, + error: error.message + }; + } +} + +export function mergeArrays(hashFn, ...args) { + const seen = {}; + const merged = []; + args.forEach(sizes => { + sizes.forEach(size => { + const key = hashFn(size); + if (!(key in seen)) { + seen[key] = true; + merged.push(size); + } }); }); - return responses; + return merged; } -export const spec = { - code: BIDDER_CODE, - supportedMediaTypes: SUPPORTED_MEDIA_TYPES, - isBidRequestValid, - buildRequests, - interpretResponse -} +const spec = { + code: 'vi', + supportedMediaTypes: [mediaTypes.VIDEO, mediaTypes.BANNER], + + isBidRequestValid({ adUnitCode, params: { pubId, lang, cat } = {} }) { + return [pubId, lang, cat].every(x => typeof x === 'string'); + }, + + /** + * + * @param bidRequests + * @param bidderRequest + * @return { + * {method: string, + * data: { + imps: { + bidId: string, + adUnitCode: string, + sizes: [[number, number]], + pubId: string, + lang: string, + cat: string, + iframeType: string | undefined, + error: string | null, + inView: number, + offsetTop: number, + offsetView: number, + hidden: boolean, + bidFloor: number + }[], + refererInfo: { + referer: string + reachedTop: boolean, + numIframes: number, + stack: string[] + canonicalUrl: string + } + }, + * options: {withCredentials: boolean, contentType: string}, url: string}} + */ + buildRequests(bidRequests, bidderRequest) { + return { + method: 'POST', + url: 'https://pb.vi-serve.com/prebid/bid', + data: { + refererInfo: bidderRequest.refererInfo, + imps: bidRequests.map( + ({ bidId, adUnitCode, sizes, params, mediaTypes }) => { + const slot = document.getElementById(adUnitCode); + const bannerSizes = get('banner.sizes', mediaTypes); + const playerSize = get('video.playerSize', mediaTypes); + + const sizesToMerge = []; + if (!params.useSizes) { + if (sizes) sizesToMerge.push(sizes); + if (bannerSizes) sizesToMerge.push(bannerSizes); + if (playerSize) sizesToMerge.push(playerSize); + } else if (params.useSizes === 'banner' && bannerSizes) { + sizesToMerge.push(bannerSizes); + } else if (params.useSizes === 'video' && playerSize) { + sizesToMerge.push(playerSize); + } + return { + bidId, + adUnitCode, + sizes: mergeArrays(x => x.join(','), ...sizesToMerge), + ...getViewabilityDescription(slot), + ...params + }; + } + ) + }, + options: { + contentType: 'application/json', + withCredentials: true + } + }; + }, + interpretResponse({ body }) { + return body; + } +}; registerBidder(spec); diff --git a/modules/viBidAdapter.md b/modules/viBidAdapter.md index 23288024fcc..2608ccc4adb 100644 --- a/modules/viBidAdapter.md +++ b/modules/viBidAdapter.md @@ -38,4 +38,5 @@ var adUnits = [{ | `lang` | required | Ad language, in ISO 639-1 language code format | 'en-US', 'es-ES', 'de' | | `cat` | required | Ad IAB category (top-level or subcategory), single one supported | 'IAB1', 'IAB9-1' | | `bidFloor` | optional | Lowest value of expected bid price | 0.001 | +| `useSizes` | optional | Specifies from which section of the config sizes are taken, possible values are 'banner', 'video'. If omitted, sizes from both sections are merged. | 'banner' | diff --git a/modules/videoreachBidAdapter.js b/modules/videoreachBidAdapter.js new file mode 100644 index 00000000000..363355292ca --- /dev/null +++ b/modules/videoreachBidAdapter.js @@ -0,0 +1,97 @@ +import {registerBidder} from '../src/adapters/bidderFactory'; +const utils = require('../src/utils'); +const BIDDER_CODE = 'videoreach'; +const ENDPOINT_URL = '//a.videoreach.com/hb/'; + +export const spec = { + code: BIDDER_CODE, + supportedMediaTypes: ['banner'], + + isBidRequestValid: function(bid) { + return !!(bid.params.TagId); + }, + + buildRequests: function(validBidRequests, bidderRequest) { + var data = { + referrer: utils.getTopWindowUrl(), + data: validBidRequests.map(function(bid) { + return { + TagId: utils.getValue(bid.params, 'TagId'), + bidId: utils.getBidIdParameter('bidId', bid), + bidderRequestId: utils.getBidIdParameter('bidderRequestId', bid), + auctionId: utils.getBidIdParameter('auctionId', bid), + transactionId: utils.getBidIdParameter('transactionId', bid) + } + }) + }; + + if (bidderRequest && bidderRequest.gdprConsent) { + data.gdpr = { + consent_string: bidderRequest.gdprConsent.consentString, + consent_required: bidderRequest.gdprConsent.gdprApplies + }; + } + + return { + method: 'POST', + url: ENDPOINT_URL, + data: JSON.stringify(data) + }; + }, + + interpretResponse: function(serverResponse) { + const bidResponses = []; + serverResponse = serverResponse.body; + + if (serverResponse.responses) { + serverResponse.responses.forEach(function (bid) { + const bidResponse = { + cpm: bid.cpm, + width: bid.width, + height: bid.height, + currency: bid.currency, + netRevenue: true, + ttl: bid.ttl, + ad: bid.ad, + requestId: bid.bidId, + creativeId: bid.creativeId + }; + bidResponses.push(bidResponse); + }); + } + return bidResponses; + }, + + getUserSyncs: function(syncOptions, responses, gdprConsent) { + const syncs = []; + + if (syncOptions.pixelEnabled && responses.length && responses[0].body.responses.length) { + const SyncPixels = responses[0].body.responses[0].sync; + + let params = ''; + if (gdprConsent && typeof gdprConsent.consentString === 'string') { + if (typeof gdprConsent.gdprApplies === 'boolean') { + params += 'gdpr=' + gdprConsent.gdprApplies + '&gdpr_consent=' + gdprConsent.consentString; + } else { + params += 'gdpr_consent=' + gdprConsent.consentString; + } + } + + var gdpr; + if (SyncPixels) { + SyncPixels.forEach(sync => { + gdpr = (params) ? ((sync.split('?')[1] ? '&' : '?') + params) : ''; + + syncs.push({ + type: 'image', + url: sync + gdpr + }); + }); + } + } + + return syncs; + } +}; + +registerBidder(spec); diff --git a/modules/videoreachBidAdapter.md b/modules/videoreachBidAdapter.md new file mode 100644 index 00000000000..a68c9b26aeb --- /dev/null +++ b/modules/videoreachBidAdapter.md @@ -0,0 +1,27 @@ +# Overview + +**Module Name**: Video Reach Bidder Adapter +**Module Type**: Bidder Adapter +**Maintainer**: hello@videoreach.com + +# Description + +Video Reach Bidder Adapter for Prebid.js. + +Use `videoreach` as bidder. + +`TagId` ist required. + +## AdUnits configuration example +``` + var adUnits = [{ + code: 'your-slot', //use exactly the same code as your slot div id. + sizes: [[1, 1]], + bids: [{ + bidder: 'videoreach', + params: { + TagId: 'XXXXX' + } + }] + }]; +``` diff --git a/modules/visxBidAdapter.js b/modules/visxBidAdapter.js old mode 100755 new mode 100644 index 574061b6ce3..2f9ec73c569 --- a/modules/visxBidAdapter.js +++ b/modules/visxBidAdapter.js @@ -25,6 +25,8 @@ export const spec = { buildRequests: function(validBidRequests, bidderRequest) { const auids = []; const bidsMap = {}; + const slotsMapByUid = {}; + const sizeMap = {}; const bids = validBidRequests || []; const currency = config.getConfig(`currency.bidderCurrencyDefault.${BIDDER_CODE}`) || @@ -33,30 +35,59 @@ export const spec = { let reqId; bids.forEach(bid => { - if (!bidsMap[bid.params.uid]) { - bidsMap[bid.params.uid] = [bid]; - auids.push(bid.params.uid); + reqId = bid.bidderRequestId; + const {params: {uid}, adUnitCode} = bid; + auids.push(uid); + const sizesId = utils.parseSizesInput(bid.sizes); + + if (!slotsMapByUid[uid]) { + slotsMapByUid[uid] = {}; + } + const slotsMap = slotsMapByUid[uid]; + if (!slotsMap[adUnitCode]) { + slotsMap[adUnitCode] = {adUnitCode, bids: [bid], parents: []}; } else { - bidsMap[bid.params.uid].push(bid); + slotsMap[adUnitCode].bids.push(bid); } - reqId = bid.bidderRequestId; + const slot = slotsMap[adUnitCode]; + + sizesId.forEach((sizeId) => { + sizeMap[sizeId] = true; + if (!bidsMap[uid]) { + bidsMap[uid] = {}; + } + + if (!bidsMap[uid][sizeId]) { + bidsMap[uid][sizeId] = [slot]; + } else { + bidsMap[uid][sizeId].push(slot); + } + slot.parents.push({parent: bidsMap[uid], key: sizeId, uid}); + }); }); const payload = { - u: utils.getTopWindowUrl(), pt: 'net', auids: auids.join(','), + sizes: utils.getKeys(sizeMap).join(','), r: reqId, cur: currency, + wrapperType: 'Prebid_js', + wrapperVersion: '$prebid.version$' }; - if (bidderRequest && bidderRequest.gdprConsent) { - if (bidderRequest.gdprConsent.consentString) { - payload.gdpr_consent = bidderRequest.gdprConsent.consentString; + if (bidderRequest) { + if (bidderRequest.refererInfo && bidderRequest.refererInfo.referer) { + payload.u = encodeURIComponent(bidderRequest.refererInfo.referer); + } + if (bidderRequest.gdprConsent) { + if (bidderRequest.gdprConsent.consentString) { + payload.gdpr_consent = bidderRequest.gdprConsent.consentString; + } + payload.gdpr_applies = + (typeof bidderRequest.gdprConsent.gdprApplies === 'boolean') + ? Number(bidderRequest.gdprConsent.gdprApplies) : 1; } - payload.gdpr_applies = - (typeof bidderRequest.gdprConsent.gdprApplies === 'boolean') - ? Number(bidderRequest.gdprConsent.gdprApplies) : 1; } return { @@ -69,6 +100,7 @@ export const spec = { interpretResponse: function(serverResponse, bidRequest) { serverResponse = serverResponse && serverResponse.body; const bidResponses = []; + const bidsWithoutSizeMatching = []; const bidsMap = bidRequest.bidsMap; const currency = bidRequest.data.cur; @@ -81,7 +113,10 @@ export const spec = { if (!errorMessage && serverResponse.seatbid) { serverResponse.seatbid.forEach(respItem => { - _addBidResponse(_getBidFromResponse(respItem), bidsMap, currency, bidResponses); + _addBidResponse(_getBidFromResponse(respItem), bidsMap, currency, bidResponses, bidsWithoutSizeMatching); + }); + bidsWithoutSizeMatching.forEach(serverBid => { + _addBidResponse(serverBid, bidsMap, currency, bidResponses); }); } if (errorMessage) utils.logError(errorMessage); @@ -117,7 +152,7 @@ function _getBidFromResponse(respItem) { return respItem && respItem.bid && respItem.bid[0]; } -function _addBidResponse(serverBid, bidsMap, currency, bidResponses) { +function _addBidResponse(serverBid, bidsMap, currency, bidResponses, bidsWithoutSizeMatching) { if (!serverBid) return; let errorMessage; if (!serverBid.auid) errorMessage = LOG_ERROR_MESS.noAuid + JSON.stringify(serverBid); @@ -125,9 +160,14 @@ function _addBidResponse(serverBid, bidsMap, currency, bidResponses) { else { const awaitingBids = bidsMap[serverBid.auid]; if (awaitingBids) { - awaitingBids.forEach(bid => { - const bidResponse = { + const sizeId = bidsWithoutSizeMatching ? `${serverBid.w}x${serverBid.h}` : Object.keys(awaitingBids)[0]; + if (awaitingBids[sizeId]) { + const slot = awaitingBids[sizeId][0]; + + const bid = slot.bids.shift(); + bidResponses.push({ requestId: bid.bidId, + bidderCode: spec.code, cpm: serverBid.price, width: serverBid.w, height: serverBid.h, @@ -137,9 +177,25 @@ function _addBidResponse(serverBid, bidsMap, currency, bidResponses) { ttl: TIME_TO_LIVE, ad: serverBid.adm, dealId: serverBid.dealid - }; - bidResponses.push(bidResponse); - }); + }); + + if (!slot.bids.length) { + slot.parents.forEach(({parent, key, uid}) => { + const index = parent[key].indexOf(slot); + if (index > -1) { + parent[key].splice(index, 1); + } + if (!parent[key].length) { + delete parent[key]; + if (!utils.getKeys(parent).length) { + delete bidsMap[uid]; + } + } + }); + } + } else { + bidsWithoutSizeMatching && bidsWithoutSizeMatching.push(serverBid); + } } else { errorMessage = LOG_ERROR_MESS.noPlacementCode + serverBid.auid; } diff --git a/modules/visxBidAdapter.md b/modules/visxBidAdapter.md old mode 100755 new mode 100644 diff --git a/modules/yieldlabBidAdapter.js b/modules/yieldlabBidAdapter.js index 1bbb3f11a2e..9af3de24cb1 100644 --- a/modules/yieldlabBidAdapter.js +++ b/modules/yieldlabBidAdapter.js @@ -2,11 +2,13 @@ import * as utils from '../src/utils' import { registerBidder } from '../src/adapters/bidderFactory' import find from 'core-js/library/fn/array/find' import { VIDEO, BANNER } from '../src/mediaTypes' +import { Renderer } from '../src/Renderer' const ENDPOINT = 'https://ad.yieldlab.net' const BIDDER_CODE = 'yieldlab' const BID_RESPONSE_TTL_SEC = 300 const CURRENCY_CODE = 'EUR' +const OUTSTREAMPLAYER_URL = 'https://ad2.movad.net/dynamic.ad?a=o193092&ma_loadEvent=ma-start-event' export const spec = { code: BIDDER_CODE, @@ -93,8 +95,23 @@ export const spec = { } if (isVideo(bidRequest)) { + const playersize = getPlayerSize(bidRequest) + if (playersize) { + bidResponse.width = playersize[0] + bidResponse.height = playersize[1] + } bidResponse.mediaType = VIDEO bidResponse.vastUrl = `${ENDPOINT}/d/${matchedBid.id}/${bidRequest.params.supplyId}/${customsize[0]}x${customsize[1]}?ts=${timestamp}${extId}` + + if (isOutstream(bidRequest)) { + const renderer = Renderer.install({ + id: bidRequest.bidId, + url: OUTSTREAMPLAYER_URL, + loaded: false + }) + renderer.setRender(outstreamRender) + bidResponse.renderer = renderer + } } bidResponses.push(bidResponse) @@ -106,13 +123,33 @@ export const spec = { /** * Is this a video format? - * @param {String} format + * @param {Object} format * @returns {Boolean} */ function isVideo (format) { return utils.deepAccess(format, 'mediaTypes.video') } +/** + * Is this an outstream context? + * @param {Object} format + * @returns {Boolean} + */ +function isOutstream (format) { + let context = utils.deepAccess(format, 'mediaTypes.video.context') + return (context === 'outstream') +} + +/** + * Gets optional player size + * @param {Object} format + * @returns {Array} + */ +function getPlayerSize (format) { + let playerSize = utils.deepAccess(format, 'mediaTypes.video.playerSize') + return (playerSize && utils.isArray(playerSize[0])) ? playerSize[0] : playerSize +} + /** * Expands a 'WxH' string as a 2-element [W, H] array * @param {String} size @@ -137,4 +174,18 @@ function createQueryString (obj) { return str.join('&') } +/** + * Handles an outstream response after the library is loaded + * @param {Object} bid + */ +function outstreamRender(bid) { + bid.renderer.push(() => { + window.ma_width = bid.width + window.ma_height = bid.height + window.ma_vastUrl = bid.vastUrl + window.ma_container = bid.adUnitCode + window.document.dispatchEvent(new Event('ma-start-event')) + }); +} + registerBidder(spec) diff --git a/modules/yieldlabBidAdapter.md b/modules/yieldlabBidAdapter.md index de93baf42ae..37897b83f12 100644 --- a/modules/yieldlabBidAdapter.md +++ b/modules/yieldlabBidAdapter.md @@ -34,7 +34,7 @@ Module that connects to Yieldlab's demand sources sizes: [[640, 480]], mediaTypes: { video: { - context: "instream" + context: "instream" // or "outstream" } }, bids: [{ diff --git a/modules/yieldmoBidAdapter.js b/modules/yieldmoBidAdapter.js index d904791d29a..fd09cbaa4ea 100644 --- a/modules/yieldmoBidAdapter.js +++ b/modules/yieldmoBidAdapter.js @@ -43,12 +43,17 @@ export const spec = { bidRequests.forEach((request) => { serverRequest.p.push(addPlacement(request)); - const userId = getUserId(request) - if (userId) { - const pubcid = userId.pubcid; + const pubcid = getId(request, 'pubcid'); + if (pubcid) { serverRequest.pubcid = pubcid; - } else { - serverRequest.pubcid = request.crumbs.pubcid; + } else if (request.crumbs) { + if (request.crumbs.pubcid) { + serverRequest.pubcid = request.crumbs.pubcid; + } + } + const tdid = getId(request, 'tdid'); + if (tdid) { + serverRequest.tdid = tdid; } }); serverRequest.p = '[' + serverRequest.p.toString() + ']'; @@ -103,8 +108,13 @@ function addPlacement(request) { callback_id: request.bidId, sizes: request.sizes } - if (request.params && request.params.placementId) { - placementInfo.ym_placement_id = request.params.placementId + if (request.params) { + if (request.params.placementId) { + placementInfo.ym_placement_id = request.params.placementId; + } + if (request.params.bidFloor) { + placementInfo.bidFloor = request.params.bidFloor; + } } return JSON.stringify(placementInfo); } @@ -311,10 +321,16 @@ function isMraid() { return !!(window.mraid); } -function getUserId(request) { - let userId; - if (request && request.userId && typeof request.userId === 'object') { - userId = request.userId; +/** + * Gets an id from the userId object if it exists + * @param {*} request + * @param {*} idType + * @returns an id if there is one, or undefined + */ +function getId(request, idType) { + let id; + if (request && request.userId && request.userId[idType] && typeof request.userId === 'object') { + id = request.userId[idType]; } - return userId; + return id; } diff --git a/modules/yieldmoBidAdapter.md b/modules/yieldmoBidAdapter.md index 8c60202d7ea..d1e34a41ecb 100644 --- a/modules/yieldmoBidAdapter.md +++ b/modules/yieldmoBidAdapter.md @@ -4,7 +4,6 @@ Module Name: Yieldmo Bid Adapter Module Type: Bidder Adapter Maintainer: opensource@yieldmo.com -Note: Our ads will only render in mobile ``` # Description @@ -23,7 +22,8 @@ var adUnits = [ bids: [{ bidder: 'yieldmo', params: { - placementId: '1779781193098233305' // string with at most 19 characters (may include numbers only) + placementId: '1779781193098233305', // string with at most 19 characters (may include numbers only) + bidFloor: .28 // optional param } }] } diff --git a/modules/yieldnexusBidAdapter.js b/modules/yieldnexusBidAdapter.js index cf891b025aa..23b1d21334b 100644 --- a/modules/yieldnexusBidAdapter.js +++ b/modules/yieldnexusBidAdapter.js @@ -88,12 +88,23 @@ export const spec = { if (bidRequest.mediaTypes && bidRequest.mediaTypes.video) { imp.video = { - w: bidRequest.sizes.length ? bidRequest.sizes[0][0] : 300, - h: bidRequest.sizes.length ? bidRequest.sizes[0][1] : 250, protocols: bidRequest.params.protocols || [1, 2, 3, 4, 5, 6], pos: bidRequest.params.pos || 0, topframe: topFrame }; + + let playerSize = bidRequest.mediaTypes.video.playerSize; + if (playerSize && utils.isArray(playerSize[0])) { + imp.video.w = playerSize[0][0]; + imp.video.h = playerSize[0][1]; + } else if (playerSize && utils.isNumber(playerSize[0])) { + imp.video.w = playerSize[0]; + imp.video.h = playerSize[1]; + } else { + playerSize = utils.isArray(bidRequest.sizes) ? bidRequest.sizes[0] : [300, 250]; + imp.video.w = playerSize[0]; + imp.video.h = playerSize[1]; + } } if (!bidRequest.mediaTypes || bidRequest.mediaTypes.banner) { diff --git a/modules/yieldoneBidAdapter.js b/modules/yieldoneBidAdapter.js index 7abb94736df..c706a6e7d45 100644 --- a/modules/yieldoneBidAdapter.js +++ b/modules/yieldoneBidAdapter.js @@ -1,11 +1,13 @@ import * as utils from '../src/utils'; import {config} from '../src/config'; import {registerBidder} from '../src/adapters/bidderFactory'; +import { Renderer } from '../src/Renderer'; import { BANNER, VIDEO } from '../src/mediaTypes'; const BIDDER_CODE = 'yieldone'; -const ENDPOINT_URL = '//y.one.impact-ad.jp/h_bid'; -const USER_SYNC_URL = '//y.one.impact-ad.jp/push_sync'; +const ENDPOINT_URL = 'https://y.one.impact-ad.jp/h_bid'; +const USER_SYNC_URL = 'https://y.one.impact-ad.jp/push_sync'; +const VIDEO_PLAYER_URL = 'https://img.ak.impact-ad.jp/ic/pone/ivt/firstview/js/dac-video-prebid.min.js'; export const spec = { code: BIDDER_CODE, @@ -35,15 +37,15 @@ export const spec = { }; const videoMediaType = utils.deepAccess(bidRequest, 'mediaTypes.video'); - if (bidRequest.mediaType === VIDEO || videoMediaType) { + if ((utils.isEmpty(bidRequest.mediaType) && utils.isEmpty(bidRequest.mediaTypes)) || + (bidRequest.mediaType === BANNER || (bidRequest.mediaTypes && bidRequest.mediaTypes[BANNER]))) { + const sizes = utils.deepAccess(bidRequest, 'mediaTypes.banner.sizes') || bidRequest.sizes; + payload.sz = utils.parseSizesInput(sizes).join(','); + } else if (bidRequest.mediaType === VIDEO || videoMediaType) { const sizes = utils.deepAccess(bidRequest, 'mediaTypes.video.playerSize') || bidRequest.sizes; const size = utils.parseSizesInput(sizes)[0]; payload.w = size.split('x')[0]; payload.h = size.split('x')[1]; - } else if ((utils.isEmpty(bidRequest.mediaType) && utils.isEmpty(bidRequest.mediaTypes)) || - (bidRequest.mediaType === BANNER || (bidRequest.mediaTypes && bidRequest.mediaTypes[BANNER]))) { - const sizes = utils.deepAccess(bidRequest, 'mediaTypes.banner.sizes') || bidRequest.sizes; - payload.sz = utils.parseSizesInput(sizes).join(','); } return { @@ -84,6 +86,7 @@ export const spec = { } else if (response.adm) { bidResponse.mediaType = VIDEO; bidResponse.vastXml = response.adm; + bidResponse.renderer = newRenderer(response); } bidResponses.push(bidResponse); @@ -97,6 +100,29 @@ export const spec = { url: USER_SYNC_URL }]; } + }, +} + +function newRenderer(response) { + const renderer = Renderer.install({ + id: response.uid, + url: VIDEO_PLAYER_URL, + loaded: false, + }); + + try { + renderer.setRender(outstreamRender); + } catch (err) { + utils.logWarn('Prebid Error calling setRender on newRenderer', err); } + + return renderer; } + +function outstreamRender(bid) { + bid.renderer.push(() => { + window.DACIVTPREBID.renderPrebid(bid); + }); +} + registerBidder(spec); diff --git a/package-lock.json b/package-lock.json index 00f5427b9f1..bb8263638fb 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,49 +1,49 @@ { "name": "prebid.js", - "version": "2.8.0", + "version": "2.33.0-pre", "lockfileVersion": 1, "requires": true, "dependencies": { "@babel/code-frame": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.0.0.tgz", - "integrity": "sha512-OfC2uemaknXr87bdLUkWog7nYuliM9Ij5HUcajsVcMCpQrcLmtxRbVFTIqmcSkSeYRBFBRxs2FiUqFJDLdiebA==", + "version": "7.5.5", + "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.5.5.tgz", + "integrity": "sha512-27d4lZoomVyo51VegxI20xZPuSHusqbQag/ztrBC7wegWoQ1nLREPVSKSW8byhTlzTKyNE4ifaTA6lCp7JjpFw==", "dev": true, "requires": { "@babel/highlight": "^7.0.0" } }, "@babel/core": { - "version": "7.4.0", - "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.4.0.tgz", - "integrity": "sha512-Dzl7U0/T69DFOTwqz/FJdnOSWS57NpjNfCwMKHABr589Lg8uX1RrlBIJ7L5Dubt/xkLsx0xH5EBFzlBVes1ayA==", - "dev": true, - "requires": { - "@babel/code-frame": "^7.0.0", - "@babel/generator": "^7.4.0", - "@babel/helpers": "^7.4.0", - "@babel/parser": "^7.4.0", - "@babel/template": "^7.4.0", - "@babel/traverse": "^7.4.0", - "@babel/types": "^7.4.0", + "version": "7.6.0", + "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.6.0.tgz", + "integrity": "sha512-FuRhDRtsd6IptKpHXAa+4WPZYY2ZzgowkbLBecEDDSje1X/apG7jQM33or3NdOmjXBKWGOg4JmSiRfUfuTtHXw==", + "dev": true, + "requires": { + "@babel/code-frame": "^7.5.5", + "@babel/generator": "^7.6.0", + "@babel/helpers": "^7.6.0", + "@babel/parser": "^7.6.0", + "@babel/template": "^7.6.0", + "@babel/traverse": "^7.6.0", + "@babel/types": "^7.6.0", "convert-source-map": "^1.1.0", "debug": "^4.1.0", "json5": "^2.1.0", - "lodash": "^4.17.11", + "lodash": "^4.17.13", "resolve": "^1.3.2", "semver": "^5.4.1", "source-map": "^0.5.0" } }, "@babel/generator": { - "version": "7.4.0", - "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.4.0.tgz", - "integrity": "sha512-/v5I+a1jhGSKLgZDcmAUZ4K/VePi43eRkUs3yePW1HB1iANOD5tqJXwGSG4BZhSksP8J9ejSlwGeTiiOFZOrXQ==", + "version": "7.6.0", + "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.6.0.tgz", + "integrity": "sha512-Ms8Mo7YBdMMn1BYuNtKuP/z0TgEIhbcyB8HVR6PPNYp4P61lMsABiS4A3VG1qznjXVCf3r+fVHhm4efTYVsySA==", "dev": true, "requires": { - "@babel/types": "^7.4.0", + "@babel/types": "^7.6.0", "jsesc": "^2.5.1", - "lodash": "^4.17.11", + "lodash": "^4.17.13", "source-map": "^0.5.0", "trim-right": "^1.0.1" } @@ -68,25 +68,25 @@ } }, "@babel/helper-call-delegate": { - "version": "7.4.0", - "resolved": "https://registry.npmjs.org/@babel/helper-call-delegate/-/helper-call-delegate-7.4.0.tgz", - "integrity": "sha512-SdqDfbVdNQCBp3WhK2mNdDvHd3BD6qbmIc43CAyjnsfCmgHMeqgDcM3BzY2lchi7HBJGJ2CVdynLWbezaE4mmQ==", + "version": "7.4.4", + "resolved": "https://registry.npmjs.org/@babel/helper-call-delegate/-/helper-call-delegate-7.4.4.tgz", + "integrity": "sha512-l79boDFJ8S1c5hvQvG+rc+wHw6IuH7YldmRKsYtpbawsxURu/paVy57FZMomGK22/JckepaikOkY0MoAmdyOlQ==", "dev": true, "requires": { - "@babel/helper-hoist-variables": "^7.4.0", - "@babel/traverse": "^7.4.0", - "@babel/types": "^7.4.0" + "@babel/helper-hoist-variables": "^7.4.4", + "@babel/traverse": "^7.4.4", + "@babel/types": "^7.4.4" } }, "@babel/helper-define-map": { - "version": "7.4.0", - "resolved": "https://registry.npmjs.org/@babel/helper-define-map/-/helper-define-map-7.4.0.tgz", - "integrity": "sha512-wAhQ9HdnLIywERVcSvX40CEJwKdAa1ID4neI9NXQPDOHwwA+57DqwLiPEVy2AIyWzAk0CQ8qx4awO0VUURwLtA==", + "version": "7.5.5", + "resolved": "https://registry.npmjs.org/@babel/helper-define-map/-/helper-define-map-7.5.5.tgz", + "integrity": "sha512-fTfxx7i0B5NJqvUOBBGREnrqbTxRh7zinBANpZXAVDlsZxYdclDp467G1sQ8VZYMnAURY3RpBUAgOYT9GfzHBg==", "dev": true, "requires": { "@babel/helper-function-name": "^7.1.0", - "@babel/types": "^7.4.0", - "lodash": "^4.17.11" + "@babel/types": "^7.5.5", + "lodash": "^4.17.13" } }, "@babel/helper-explode-assignable-expression": { @@ -120,21 +120,21 @@ } }, "@babel/helper-hoist-variables": { - "version": "7.4.0", - "resolved": "https://registry.npmjs.org/@babel/helper-hoist-variables/-/helper-hoist-variables-7.4.0.tgz", - "integrity": "sha512-/NErCuoe/et17IlAQFKWM24qtyYYie7sFIrW/tIQXpck6vAu2hhtYYsKLBWQV+BQZMbcIYPU/QMYuTufrY4aQw==", + "version": "7.4.4", + "resolved": "https://registry.npmjs.org/@babel/helper-hoist-variables/-/helper-hoist-variables-7.4.4.tgz", + "integrity": "sha512-VYk2/H/BnYbZDDg39hr3t2kKyifAm1W6zHRfhx8jGjIHpQEBv9dry7oQ2f3+J703TLu69nYdxsovl0XYfcnK4w==", "dev": true, "requires": { - "@babel/types": "^7.4.0" + "@babel/types": "^7.4.4" } }, "@babel/helper-member-expression-to-functions": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/@babel/helper-member-expression-to-functions/-/helper-member-expression-to-functions-7.0.0.tgz", - "integrity": "sha512-avo+lm/QmZlv27Zsi0xEor2fKcqWG56D5ae9dzklpIaY7cQMK5N8VSpaNVPPagiqmy7LrEjK1IWdGMOqPu5csg==", + "version": "7.5.5", + "resolved": "https://registry.npmjs.org/@babel/helper-member-expression-to-functions/-/helper-member-expression-to-functions-7.5.5.tgz", + "integrity": "sha512-5qZ3D1uMclSNqYcXqiHoA0meVdv+xUEex9em2fqMnrk/scphGlGgg66zjMrPJESPwrFJ6sbfFQYUSa0Mz7FabA==", "dev": true, "requires": { - "@babel/types": "^7.0.0" + "@babel/types": "^7.5.5" } }, "@babel/helper-module-imports": { @@ -147,17 +147,17 @@ } }, "@babel/helper-module-transforms": { - "version": "7.2.2", - "resolved": "https://registry.npmjs.org/@babel/helper-module-transforms/-/helper-module-transforms-7.2.2.tgz", - "integrity": "sha512-YRD7I6Wsv+IHuTPkAmAS4HhY0dkPobgLftHp0cRGZSdrRvmZY8rFvae/GVu3bD00qscuvK3WPHB3YdNpBXUqrA==", + "version": "7.5.5", + "resolved": "https://registry.npmjs.org/@babel/helper-module-transforms/-/helper-module-transforms-7.5.5.tgz", + "integrity": "sha512-jBeCvETKuJqeiaCdyaheF40aXnnU1+wkSiUs/IQg3tB85up1LyL8x77ClY8qJpuRJUcXQo+ZtdNESmZl4j56Pw==", "dev": true, "requires": { "@babel/helper-module-imports": "^7.0.0", "@babel/helper-simple-access": "^7.1.0", - "@babel/helper-split-export-declaration": "^7.0.0", - "@babel/template": "^7.2.2", - "@babel/types": "^7.2.2", - "lodash": "^4.17.10" + "@babel/helper-split-export-declaration": "^7.4.4", + "@babel/template": "^7.4.4", + "@babel/types": "^7.5.5", + "lodash": "^4.17.13" } }, "@babel/helper-optimise-call-expression": { @@ -176,12 +176,12 @@ "dev": true }, "@babel/helper-regex": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/@babel/helper-regex/-/helper-regex-7.0.0.tgz", - "integrity": "sha512-TR0/N0NDCcUIUEbqV6dCO+LptmmSQFQ7q70lfcEB4URsjD0E1HzicrwUH+ap6BAQ2jhCX9Q4UqZy4wilujWlkg==", + "version": "7.5.5", + "resolved": "https://registry.npmjs.org/@babel/helper-regex/-/helper-regex-7.5.5.tgz", + "integrity": "sha512-CkCYQLkfkiugbRDO8eZn6lRuR8kzZoGXCg3149iTk5se7g6qykSpy3+hELSwquhu+TgHn8nkLiBwHvNX8Hofcw==", "dev": true, "requires": { - "lodash": "^4.17.10" + "lodash": "^4.17.13" } }, "@babel/helper-remap-async-to-generator": { @@ -198,15 +198,15 @@ } }, "@babel/helper-replace-supers": { - "version": "7.4.0", - "resolved": "https://registry.npmjs.org/@babel/helper-replace-supers/-/helper-replace-supers-7.4.0.tgz", - "integrity": "sha512-PVwCVnWWAgnal+kJ+ZSAphzyl58XrFeSKSAJRiqg5QToTsjL+Xu1f9+RJ+d+Q0aPhPfBGaYfkox66k86thxNSg==", + "version": "7.5.5", + "resolved": "https://registry.npmjs.org/@babel/helper-replace-supers/-/helper-replace-supers-7.5.5.tgz", + "integrity": "sha512-XvRFWrNnlsow2u7jXDuH4jDDctkxbS7gXssrP4q2nUD606ukXHRvydj346wmNg+zAgpFx4MWf4+usfC93bElJg==", "dev": true, "requires": { - "@babel/helper-member-expression-to-functions": "^7.0.0", + "@babel/helper-member-expression-to-functions": "^7.5.5", "@babel/helper-optimise-call-expression": "^7.0.0", - "@babel/traverse": "^7.4.0", - "@babel/types": "^7.4.0" + "@babel/traverse": "^7.5.5", + "@babel/types": "^7.5.5" } }, "@babel/helper-simple-access": { @@ -220,12 +220,12 @@ } }, "@babel/helper-split-export-declaration": { - "version": "7.4.0", - "resolved": "https://registry.npmjs.org/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.4.0.tgz", - "integrity": "sha512-7Cuc6JZiYShaZnybDmfwhY4UYHzI6rlqhWjaIqbsJGsIqPimEYy5uh3akSRLMg65LSdSEnJ8a8/bWQN6u2oMGw==", + "version": "7.4.4", + "resolved": "https://registry.npmjs.org/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.4.4.tgz", + "integrity": "sha512-Ro/XkzLf3JFITkW6b+hNxzZ1n5OQ80NvIUdmHspih1XAhtN3vPTuUFT4eQnela+2MaZ5ulH+iyP513KJrxbN7Q==", "dev": true, "requires": { - "@babel/types": "^7.4.0" + "@babel/types": "^7.4.4" } }, "@babel/helper-wrap-function": { @@ -241,20 +241,20 @@ } }, "@babel/helpers": { - "version": "7.4.2", - "resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.4.2.tgz", - "integrity": "sha512-gQR1eQeroDzFBikhrCccm5Gs2xBjZ57DNjGbqTaHo911IpmSxflOQWMAHPw/TXk8L3isv7s9lYzUkexOeTQUYg==", + "version": "7.6.0", + "resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.6.0.tgz", + "integrity": "sha512-W9kao7OBleOjfXtFGgArGRX6eCP0UEcA2ZWEWNkJdRZnHhW4eEbeswbG3EwaRsnQUAEGWYgMq1HsIXuNNNy2eQ==", "dev": true, "requires": { - "@babel/template": "^7.4.0", - "@babel/traverse": "^7.4.0", - "@babel/types": "^7.4.0" + "@babel/template": "^7.6.0", + "@babel/traverse": "^7.6.0", + "@babel/types": "^7.6.0" } }, "@babel/highlight": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.0.0.tgz", - "integrity": "sha512-UFMC4ZeFC48Tpvj7C8UgLvtkaUuovQX+5xNWrsIoMG8o2z+XFKjKaN9iVmS84dPwVN00W4wPmqvYoZF3EGAsfw==", + "version": "7.5.0", + "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.5.0.tgz", + "integrity": "sha512-7dV4eu9gBxoM0dAnj/BCFDW9LFU0zvTrkq0ugM7pnHEgguOEeOz1so2ZghEdzviYzQEED0r4EAgpsBChKy1TRQ==", "dev": true, "requires": { "chalk": "^2.0.0", @@ -263,9 +263,9 @@ } }, "@babel/parser": { - "version": "7.4.2", - "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.4.2.tgz", - "integrity": "sha512-9fJTDipQFvlfSVdD/JBtkiY0br9BtfvW2R8wo6CX/Ej2eMuV0gWPk1M67Mt3eggQvBqYW1FCEk8BN7WvGm/g5g==", + "version": "7.6.0", + "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.6.0.tgz", + "integrity": "sha512-+o2q111WEx4srBs7L9eJmcwi655eD8sXniLqMB93TBK9GrNzGrxDWSjiqz2hLU0Ha8MTXFIP0yd9fNdP+m43ZQ==", "dev": true }, "@babel/plugin-proposal-async-generator-functions": { @@ -279,6 +279,16 @@ "@babel/plugin-syntax-async-generators": "^7.2.0" } }, + "@babel/plugin-proposal-dynamic-import": { + "version": "7.5.0", + "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-dynamic-import/-/plugin-proposal-dynamic-import-7.5.0.tgz", + "integrity": "sha512-x/iMjggsKTFHYC6g11PL7Qy58IK8H5zqfm9e6hu4z1iH2IRyAp9u9dL80zA6R76yFovETFLKz2VJIC2iIPBuFw==", + "dev": true, + "requires": { + "@babel/helper-plugin-utils": "^7.0.0", + "@babel/plugin-syntax-dynamic-import": "^7.2.0" + } + }, "@babel/plugin-proposal-json-strings": { "version": "7.2.0", "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-json-strings/-/plugin-proposal-json-strings-7.2.0.tgz", @@ -290,9 +300,9 @@ } }, "@babel/plugin-proposal-object-rest-spread": { - "version": "7.4.0", - "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-object-rest-spread/-/plugin-proposal-object-rest-spread-7.4.0.tgz", - "integrity": "sha512-uTNi8pPYyUH2eWHyYWWSYJKwKg34hhgl4/dbejEjL+64OhbHjTX7wEVWMQl82tEmdDsGeu77+s8HHLS627h6OQ==", + "version": "7.5.5", + "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-object-rest-spread/-/plugin-proposal-object-rest-spread-7.5.5.tgz", + "integrity": "sha512-F2DxJJSQ7f64FyTVl5cw/9MWn6naXGdk3Q3UhDbFEEHv+EilCPoeRD3Zh/Utx1CJz4uyKlQ4uH+bJPbEhMV7Zw==", "dev": true, "requires": { "@babel/helper-plugin-utils": "^7.0.0", @@ -310,13 +320,13 @@ } }, "@babel/plugin-proposal-unicode-property-regex": { - "version": "7.4.0", - "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-unicode-property-regex/-/plugin-proposal-unicode-property-regex-7.4.0.tgz", - "integrity": "sha512-h/KjEZ3nK9wv1P1FSNb9G079jXrNYR0Ko+7XkOx85+gM24iZbPn0rh4vCftk+5QKY7y1uByFataBTmX7irEF1w==", + "version": "7.4.4", + "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-unicode-property-regex/-/plugin-proposal-unicode-property-regex-7.4.4.tgz", + "integrity": "sha512-j1NwnOqMG9mFUOH58JTFsA/+ZYzQLUZ/drqWUqxCYLGeu2JFZL8YrNC9hBxKmWtAuOCHPcRpgv7fhap09Fb4kA==", "dev": true, "requires": { "@babel/helper-plugin-utils": "^7.0.0", - "@babel/helper-regex": "^7.0.0", + "@babel/helper-regex": "^7.4.4", "regexpu-core": "^4.5.4" } }, @@ -329,6 +339,15 @@ "@babel/helper-plugin-utils": "^7.0.0" } }, + "@babel/plugin-syntax-dynamic-import": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-dynamic-import/-/plugin-syntax-dynamic-import-7.2.0.tgz", + "integrity": "sha512-mVxuJ0YroI/h/tbFTPGZR8cv6ai+STMKNBq0f8hFxsxWjl94qqhsb+wXbpNMDPU3cfR1TIsVFzU3nXyZMqyK4w==", + "dev": true, + "requires": { + "@babel/helper-plugin-utils": "^7.0.0" + } + }, "@babel/plugin-syntax-json-strings": { "version": "7.2.0", "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-json-strings/-/plugin-syntax-json-strings-7.2.0.tgz", @@ -366,9 +385,9 @@ } }, "@babel/plugin-transform-async-to-generator": { - "version": "7.4.0", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-async-to-generator/-/plugin-transform-async-to-generator-7.4.0.tgz", - "integrity": "sha512-EeaFdCeUULM+GPFEsf7pFcNSxM7hYjoj5fiYbyuiXobW4JhFnjAv9OWzNwHyHcKoPNpAfeRDuW6VyaXEDUBa7g==", + "version": "7.5.0", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-async-to-generator/-/plugin-transform-async-to-generator-7.5.0.tgz", + "integrity": "sha512-mqvkzwIGkq0bEF1zLRRiTdjfomZJDV33AH3oQzHVGkI2VzEmXLpKKOBvEVaFZBJdN0XTyH38s9j/Kiqr68dggg==", "dev": true, "requires": { "@babel/helper-module-imports": "^7.0.0", @@ -386,28 +405,28 @@ } }, "@babel/plugin-transform-block-scoping": { - "version": "7.4.0", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-block-scoping/-/plugin-transform-block-scoping-7.4.0.tgz", - "integrity": "sha512-AWyt3k+fBXQqt2qb9r97tn3iBwFpiv9xdAiG+Gr2HpAZpuayvbL55yWrsV3MyHvXk/4vmSiedhDRl1YI2Iy5nQ==", + "version": "7.6.0", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-block-scoping/-/plugin-transform-block-scoping-7.6.0.tgz", + "integrity": "sha512-tIt4E23+kw6TgL/edACZwP1OUKrjOTyMrFMLoT5IOFrfMRabCgekjqFd5o6PaAMildBu46oFkekIdMuGkkPEpA==", "dev": true, "requires": { "@babel/helper-plugin-utils": "^7.0.0", - "lodash": "^4.17.11" + "lodash": "^4.17.13" } }, "@babel/plugin-transform-classes": { - "version": "7.4.0", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-classes/-/plugin-transform-classes-7.4.0.tgz", - "integrity": "sha512-XGg1Mhbw4LDmrO9rSTNe+uI79tQPdGs0YASlxgweYRLZqo/EQktjaOV4tchL/UZbM0F+/94uOipmdNGoaGOEYg==", + "version": "7.5.5", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-classes/-/plugin-transform-classes-7.5.5.tgz", + "integrity": "sha512-U2htCNK/6e9K7jGyJ++1p5XRU+LJjrwtoiVn9SzRlDT2KubcZ11OOwy3s24TjHxPgxNwonCYP7U2K51uVYCMDg==", "dev": true, "requires": { "@babel/helper-annotate-as-pure": "^7.0.0", - "@babel/helper-define-map": "^7.4.0", + "@babel/helper-define-map": "^7.5.5", "@babel/helper-function-name": "^7.1.0", "@babel/helper-optimise-call-expression": "^7.0.0", "@babel/helper-plugin-utils": "^7.0.0", - "@babel/helper-replace-supers": "^7.4.0", - "@babel/helper-split-export-declaration": "^7.4.0", + "@babel/helper-replace-supers": "^7.5.5", + "@babel/helper-split-export-declaration": "^7.4.4", "globals": "^11.1.0" } }, @@ -421,29 +440,29 @@ } }, "@babel/plugin-transform-destructuring": { - "version": "7.4.0", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-destructuring/-/plugin-transform-destructuring-7.4.0.tgz", - "integrity": "sha512-HySkoatyYTY3ZwLI8GGvkRWCFrjAGXUHur5sMecmCIdIharnlcWWivOqDJI76vvmVZfzwb6G08NREsrY96RhGQ==", + "version": "7.6.0", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-destructuring/-/plugin-transform-destructuring-7.6.0.tgz", + "integrity": "sha512-2bGIS5P1v4+sWTCnKNDZDxbGvEqi0ijeqM/YqHtVGrvG2y0ySgnEEhXErvE9dA0bnIzY9bIzdFK0jFA46ASIIQ==", "dev": true, "requires": { "@babel/helper-plugin-utils": "^7.0.0" } }, "@babel/plugin-transform-dotall-regex": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-dotall-regex/-/plugin-transform-dotall-regex-7.2.0.tgz", - "integrity": "sha512-sKxnyHfizweTgKZf7XsXu/CNupKhzijptfTM+bozonIuyVrLWVUvYjE2bhuSBML8VQeMxq4Mm63Q9qvcvUcciQ==", + "version": "7.4.4", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-dotall-regex/-/plugin-transform-dotall-regex-7.4.4.tgz", + "integrity": "sha512-P05YEhRc2h53lZDjRPk/OektxCVevFzZs2Gfjd545Wde3k+yFDbXORgl2e0xpbq8mLcKJ7Idss4fAg0zORN/zg==", "dev": true, "requires": { "@babel/helper-plugin-utils": "^7.0.0", - "@babel/helper-regex": "^7.0.0", - "regexpu-core": "^4.1.3" + "@babel/helper-regex": "^7.4.4", + "regexpu-core": "^4.5.4" } }, "@babel/plugin-transform-duplicate-keys": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-duplicate-keys/-/plugin-transform-duplicate-keys-7.2.0.tgz", - "integrity": "sha512-q+yuxW4DsTjNceUiTzK0L+AfQ0zD9rWaTLiUqHA8p0gxx7lu1EylenfzjeIWNkPy6e/0VG/Wjw9uf9LueQwLOw==", + "version": "7.5.0", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-duplicate-keys/-/plugin-transform-duplicate-keys-7.5.0.tgz", + "integrity": "sha512-igcziksHizyQPlX9gfSjHkE2wmoCH3evvD2qR5w29/Dk0SMKE/eOI7f1HhBdNhR/zxJDqrgpoDTq5YSLH/XMsQ==", "dev": true, "requires": { "@babel/helper-plugin-utils": "^7.0.0" @@ -460,18 +479,18 @@ } }, "@babel/plugin-transform-for-of": { - "version": "7.4.0", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-for-of/-/plugin-transform-for-of-7.4.0.tgz", - "integrity": "sha512-vWdfCEYLlYSxbsKj5lGtzA49K3KANtb8qCPQ1em07txJzsBwY+cKJzBHizj5fl3CCx7vt+WPdgDLTHmydkbQSQ==", + "version": "7.4.4", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-for-of/-/plugin-transform-for-of-7.4.4.tgz", + "integrity": "sha512-9T/5Dlr14Z9TIEXLXkt8T1DU7F24cbhwhMNUziN3hB1AXoZcdzPcTiKGRn/6iOymDqtTKWnr/BtRKN9JwbKtdQ==", "dev": true, "requires": { "@babel/helper-plugin-utils": "^7.0.0" } }, "@babel/plugin-transform-function-name": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-function-name/-/plugin-transform-function-name-7.2.0.tgz", - "integrity": "sha512-kWgksow9lHdvBC2Z4mxTsvc7YdY7w/V6B2vy9cTIPtLEE9NhwoWivaxdNM/S37elu5bqlLP/qOY906LukO9lkQ==", + "version": "7.4.4", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-function-name/-/plugin-transform-function-name-7.4.4.tgz", + "integrity": "sha512-iU9pv7U+2jC9ANQkKeNF6DrPy4GBa4NWQtl6dHB4Pb3izX2JOEvDTFarlNsBj/63ZEzNNIAMs3Qw4fNCcSOXJA==", "dev": true, "requires": { "@babel/helper-function-name": "^7.1.0", @@ -487,35 +506,47 @@ "@babel/helper-plugin-utils": "^7.0.0" } }, - "@babel/plugin-transform-modules-amd": { + "@babel/plugin-transform-member-expression-literals": { "version": "7.2.0", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-modules-amd/-/plugin-transform-modules-amd-7.2.0.tgz", - "integrity": "sha512-mK2A8ucqz1qhrdqjS9VMIDfIvvT2thrEsIQzbaTdc5QFzhDjQv2CkJJ5f6BXIkgbmaoax3zBr2RyvV/8zeoUZw==", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-member-expression-literals/-/plugin-transform-member-expression-literals-7.2.0.tgz", + "integrity": "sha512-HiU3zKkSU6scTidmnFJ0bMX8hz5ixC93b4MHMiYebmk2lUVNGOboPsqQvx5LzooihijUoLR/v7Nc1rbBtnc7FA==", "dev": true, "requires": { - "@babel/helper-module-transforms": "^7.1.0", "@babel/helper-plugin-utils": "^7.0.0" } }, - "@babel/plugin-transform-modules-commonjs": { - "version": "7.4.0", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-modules-commonjs/-/plugin-transform-modules-commonjs-7.4.0.tgz", - "integrity": "sha512-iWKAooAkipG7g1IY0eah7SumzfnIT3WNhT4uYB2kIsvHnNSB6MDYVa5qyICSwaTBDBY2c4SnJ3JtEa6ltJd6Jw==", + "@babel/plugin-transform-modules-amd": { + "version": "7.5.0", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-modules-amd/-/plugin-transform-modules-amd-7.5.0.tgz", + "integrity": "sha512-n20UsQMKnWrltocZZm24cRURxQnWIvsABPJlw/fvoy9c6AgHZzoelAIzajDHAQrDpuKFFPPcFGd7ChsYuIUMpg==", "dev": true, "requires": { "@babel/helper-module-transforms": "^7.1.0", "@babel/helper-plugin-utils": "^7.0.0", - "@babel/helper-simple-access": "^7.1.0" + "babel-plugin-dynamic-import-node": "^2.3.0" + } + }, + "@babel/plugin-transform-modules-commonjs": { + "version": "7.6.0", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-modules-commonjs/-/plugin-transform-modules-commonjs-7.6.0.tgz", + "integrity": "sha512-Ma93Ix95PNSEngqomy5LSBMAQvYKVe3dy+JlVJSHEXZR5ASL9lQBedMiCyVtmTLraIDVRE3ZjTZvmXXD2Ozw3g==", + "dev": true, + "requires": { + "@babel/helper-module-transforms": "^7.4.4", + "@babel/helper-plugin-utils": "^7.0.0", + "@babel/helper-simple-access": "^7.1.0", + "babel-plugin-dynamic-import-node": "^2.3.0" } }, "@babel/plugin-transform-modules-systemjs": { - "version": "7.4.0", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-modules-systemjs/-/plugin-transform-modules-systemjs-7.4.0.tgz", - "integrity": "sha512-gjPdHmqiNhVoBqus5qK60mWPp1CmYWp/tkh11mvb0rrys01HycEGD7NvvSoKXlWEfSM9TcL36CpsK8ElsADptQ==", + "version": "7.5.0", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-modules-systemjs/-/plugin-transform-modules-systemjs-7.5.0.tgz", + "integrity": "sha512-Q2m56tyoQWmuNGxEtUyeEkm6qJYFqs4c+XyXH5RAuYxObRNz9Zgj/1g2GMnjYp2EUyEy7YTrxliGCXzecl/vJg==", "dev": true, "requires": { - "@babel/helper-hoist-variables": "^7.4.0", - "@babel/helper-plugin-utils": "^7.0.0" + "@babel/helper-hoist-variables": "^7.4.4", + "@babel/helper-plugin-utils": "^7.0.0", + "babel-plugin-dynamic-import-node": "^2.3.0" } }, "@babel/plugin-transform-modules-umd": { @@ -529,51 +560,69 @@ } }, "@babel/plugin-transform-named-capturing-groups-regex": { - "version": "7.4.2", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-named-capturing-groups-regex/-/plugin-transform-named-capturing-groups-regex-7.4.2.tgz", - "integrity": "sha512-NsAuliSwkL3WO2dzWTOL1oZJHm0TM8ZY8ZSxk2ANyKkt5SQlToGA4pzctmq1BEjoacurdwZ3xp2dCQWJkME0gQ==", + "version": "7.6.0", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-named-capturing-groups-regex/-/plugin-transform-named-capturing-groups-regex-7.6.0.tgz", + "integrity": "sha512-jem7uytlmrRl3iCAuQyw8BpB4c4LWvSpvIeXKpMb+7j84lkx4m4mYr5ErAcmN5KM7B6BqrAvRGjBIbbzqCczew==", "dev": true, "requires": { - "regexp-tree": "^0.1.0" + "regexp-tree": "^0.1.13" } }, "@babel/plugin-transform-new-target": { - "version": "7.4.0", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-new-target/-/plugin-transform-new-target-7.4.0.tgz", - "integrity": "sha512-6ZKNgMQmQmrEX/ncuCwnnw1yVGoaOW5KpxNhoWI7pCQdA0uZ0HqHGqenCUIENAnxRjy2WwNQ30gfGdIgqJXXqw==", + "version": "7.4.4", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-new-target/-/plugin-transform-new-target-7.4.4.tgz", + "integrity": "sha512-r1z3T2DNGQwwe2vPGZMBNjioT2scgWzK9BCnDEh+46z8EEwXBq24uRzd65I7pjtugzPSj921aM15RpESgzsSuA==", "dev": true, "requires": { "@babel/helper-plugin-utils": "^7.0.0" } }, "@babel/plugin-transform-object-super": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-object-super/-/plugin-transform-object-super-7.2.0.tgz", - "integrity": "sha512-VMyhPYZISFZAqAPVkiYb7dUe2AsVi2/wCT5+wZdsNO31FojQJa9ns40hzZ6U9f50Jlq4w6qwzdBB2uwqZ00ebg==", + "version": "7.5.5", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-object-super/-/plugin-transform-object-super-7.5.5.tgz", + "integrity": "sha512-un1zJQAhSosGFBduPgN/YFNvWVpRuHKU7IHBglLoLZsGmruJPOo6pbInneflUdmq7YvSVqhpPs5zdBvLnteltQ==", "dev": true, "requires": { "@babel/helper-plugin-utils": "^7.0.0", - "@babel/helper-replace-supers": "^7.1.0" + "@babel/helper-replace-supers": "^7.5.5" } }, "@babel/plugin-transform-parameters": { - "version": "7.4.0", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-parameters/-/plugin-transform-parameters-7.4.0.tgz", - "integrity": "sha512-Xqv6d1X+doyiuCGDoVJFtlZx0onAX0tnc3dY8w71pv/O0dODAbusVv2Ale3cGOwfiyi895ivOBhYa9DhAM8dUA==", + "version": "7.4.4", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-parameters/-/plugin-transform-parameters-7.4.4.tgz", + "integrity": "sha512-oMh5DUO1V63nZcu/ZVLQFqiihBGo4OpxJxR1otF50GMeCLiRx5nUdtokd+u9SuVJrvvuIh9OosRFPP4pIPnwmw==", "dev": true, "requires": { - "@babel/helper-call-delegate": "^7.4.0", + "@babel/helper-call-delegate": "^7.4.4", "@babel/helper-get-function-arity": "^7.0.0", "@babel/helper-plugin-utils": "^7.0.0" } }, + "@babel/plugin-transform-property-literals": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-property-literals/-/plugin-transform-property-literals-7.2.0.tgz", + "integrity": "sha512-9q7Dbk4RhgcLp8ebduOpCbtjh7C0itoLYHXd9ueASKAG/is5PQtMR5VJGka9NKqGhYEGn5ITahd4h9QeBMylWQ==", + "dev": true, + "requires": { + "@babel/helper-plugin-utils": "^7.0.0" + } + }, "@babel/plugin-transform-regenerator": { - "version": "7.4.0", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-regenerator/-/plugin-transform-regenerator-7.4.0.tgz", - "integrity": "sha512-SZ+CgL4F0wm4npojPU6swo/cK4FcbLgxLd4cWpHaNXY/NJ2dpahODCqBbAwb2rDmVszVb3SSjnk9/vik3AYdBw==", + "version": "7.4.5", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-regenerator/-/plugin-transform-regenerator-7.4.5.tgz", + "integrity": "sha512-gBKRh5qAaCWntnd09S8QC7r3auLCqq5DI6O0DlfoyDjslSBVqBibrMdsqO+Uhmx3+BlOmE/Kw1HFxmGbv0N9dA==", "dev": true, "requires": { - "regenerator-transform": "^0.13.4" + "regenerator-transform": "^0.14.0" + } + }, + "@babel/plugin-transform-reserved-words": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-reserved-words/-/plugin-transform-reserved-words-7.2.0.tgz", + "integrity": "sha512-fz43fqW8E1tAB3DKF19/vxbpib1fuyCwSPE418ge5ZxILnBhWyhtPgz8eh1RCGGJlwvksHkyxMxh0eenFi+kFw==", + "dev": true, + "requires": { + "@babel/helper-plugin-utils": "^7.0.0" } }, "@babel/plugin-transform-shorthand-properties": { @@ -605,9 +654,9 @@ } }, "@babel/plugin-transform-template-literals": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-template-literals/-/plugin-transform-template-literals-7.2.0.tgz", - "integrity": "sha512-FkPix00J9A/XWXv4VoKJBMeSkyY9x/TqIh76wzcdfl57RJJcf8CehQ08uwfhCDNtRQYtHQKBTwKZDEyjE13Lwg==", + "version": "7.4.4", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-template-literals/-/plugin-transform-template-literals-7.4.4.tgz", + "integrity": "sha512-mQrEC4TWkhLN0z8ygIvEL9ZEToPhG5K7KDW3pzGqOfIGZ28Jb0POUkeWcoz8HnHvhFy6dwAT1j8OzqN8s804+g==", "dev": true, "requires": { "@babel/helper-annotate-as-pure": "^7.0.0", @@ -624,105 +673,110 @@ } }, "@babel/plugin-transform-unicode-regex": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-unicode-regex/-/plugin-transform-unicode-regex-7.2.0.tgz", - "integrity": "sha512-m48Y0lMhrbXEJnVUaYly29jRXbQ3ksxPrS1Tg8t+MHqzXhtBYAvI51euOBaoAlZLPHsieY9XPVMf80a5x0cPcA==", + "version": "7.4.4", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-unicode-regex/-/plugin-transform-unicode-regex-7.4.4.tgz", + "integrity": "sha512-il+/XdNw01i93+M9J9u4T7/e/Ue/vWfNZE4IRUQjplu2Mqb/AFTDimkw2tdEdSH50wuQXZAbXSql0UphQke+vA==", "dev": true, "requires": { "@babel/helper-plugin-utils": "^7.0.0", - "@babel/helper-regex": "^7.0.0", - "regexpu-core": "^4.1.3" + "@babel/helper-regex": "^7.4.4", + "regexpu-core": "^4.5.4" } }, "@babel/preset-env": { - "version": "7.4.2", - "resolved": "https://registry.npmjs.org/@babel/preset-env/-/preset-env-7.4.2.tgz", - "integrity": "sha512-OEz6VOZaI9LW08CWVS3d9g/0jZA6YCn1gsKIy/fut7yZCJti5Lm1/Hi+uo/U+ODm7g4I6gULrCP+/+laT8xAsA==", + "version": "7.6.0", + "resolved": "https://registry.npmjs.org/@babel/preset-env/-/preset-env-7.6.0.tgz", + "integrity": "sha512-1efzxFv/TcPsNXlRhMzRnkBFMeIqBBgzwmZwlFDw5Ubj0AGLeufxugirwZmkkX/ayi3owsSqoQ4fw8LkfK9SYg==", "dev": true, "requires": { "@babel/helper-module-imports": "^7.0.0", "@babel/helper-plugin-utils": "^7.0.0", "@babel/plugin-proposal-async-generator-functions": "^7.2.0", + "@babel/plugin-proposal-dynamic-import": "^7.5.0", "@babel/plugin-proposal-json-strings": "^7.2.0", - "@babel/plugin-proposal-object-rest-spread": "^7.4.0", + "@babel/plugin-proposal-object-rest-spread": "^7.5.5", "@babel/plugin-proposal-optional-catch-binding": "^7.2.0", - "@babel/plugin-proposal-unicode-property-regex": "^7.4.0", + "@babel/plugin-proposal-unicode-property-regex": "^7.4.4", "@babel/plugin-syntax-async-generators": "^7.2.0", + "@babel/plugin-syntax-dynamic-import": "^7.2.0", "@babel/plugin-syntax-json-strings": "^7.2.0", "@babel/plugin-syntax-object-rest-spread": "^7.2.0", "@babel/plugin-syntax-optional-catch-binding": "^7.2.0", "@babel/plugin-transform-arrow-functions": "^7.2.0", - "@babel/plugin-transform-async-to-generator": "^7.4.0", + "@babel/plugin-transform-async-to-generator": "^7.5.0", "@babel/plugin-transform-block-scoped-functions": "^7.2.0", - "@babel/plugin-transform-block-scoping": "^7.4.0", - "@babel/plugin-transform-classes": "^7.4.0", + "@babel/plugin-transform-block-scoping": "^7.6.0", + "@babel/plugin-transform-classes": "^7.5.5", "@babel/plugin-transform-computed-properties": "^7.2.0", - "@babel/plugin-transform-destructuring": "^7.4.0", - "@babel/plugin-transform-dotall-regex": "^7.2.0", - "@babel/plugin-transform-duplicate-keys": "^7.2.0", + "@babel/plugin-transform-destructuring": "^7.6.0", + "@babel/plugin-transform-dotall-regex": "^7.4.4", + "@babel/plugin-transform-duplicate-keys": "^7.5.0", "@babel/plugin-transform-exponentiation-operator": "^7.2.0", - "@babel/plugin-transform-for-of": "^7.4.0", - "@babel/plugin-transform-function-name": "^7.2.0", + "@babel/plugin-transform-for-of": "^7.4.4", + "@babel/plugin-transform-function-name": "^7.4.4", "@babel/plugin-transform-literals": "^7.2.0", - "@babel/plugin-transform-modules-amd": "^7.2.0", - "@babel/plugin-transform-modules-commonjs": "^7.4.0", - "@babel/plugin-transform-modules-systemjs": "^7.4.0", + "@babel/plugin-transform-member-expression-literals": "^7.2.0", + "@babel/plugin-transform-modules-amd": "^7.5.0", + "@babel/plugin-transform-modules-commonjs": "^7.6.0", + "@babel/plugin-transform-modules-systemjs": "^7.5.0", "@babel/plugin-transform-modules-umd": "^7.2.0", - "@babel/plugin-transform-named-capturing-groups-regex": "^7.4.2", - "@babel/plugin-transform-new-target": "^7.4.0", - "@babel/plugin-transform-object-super": "^7.2.0", - "@babel/plugin-transform-parameters": "^7.4.0", - "@babel/plugin-transform-regenerator": "^7.4.0", + "@babel/plugin-transform-named-capturing-groups-regex": "^7.6.0", + "@babel/plugin-transform-new-target": "^7.4.4", + "@babel/plugin-transform-object-super": "^7.5.5", + "@babel/plugin-transform-parameters": "^7.4.4", + "@babel/plugin-transform-property-literals": "^7.2.0", + "@babel/plugin-transform-regenerator": "^7.4.5", + "@babel/plugin-transform-reserved-words": "^7.2.0", "@babel/plugin-transform-shorthand-properties": "^7.2.0", "@babel/plugin-transform-spread": "^7.2.0", "@babel/plugin-transform-sticky-regex": "^7.2.0", - "@babel/plugin-transform-template-literals": "^7.2.0", + "@babel/plugin-transform-template-literals": "^7.4.4", "@babel/plugin-transform-typeof-symbol": "^7.2.0", - "@babel/plugin-transform-unicode-regex": "^7.2.0", - "@babel/types": "^7.4.0", - "browserslist": "^4.4.2", - "core-js-compat": "^3.0.0", + "@babel/plugin-transform-unicode-regex": "^7.4.4", + "@babel/types": "^7.6.0", + "browserslist": "^4.6.0", + "core-js-compat": "^3.1.1", "invariant": "^2.2.2", "js-levenshtein": "^1.1.3", - "semver": "^5.3.0" + "semver": "^5.5.0" } }, "@babel/template": { - "version": "7.4.0", - "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.4.0.tgz", - "integrity": "sha512-SOWwxxClTTh5NdbbYZ0BmaBVzxzTh2tO/TeLTbF6MO6EzVhHTnff8CdBXx3mEtazFBoysmEM6GU/wF+SuSx4Fw==", + "version": "7.6.0", + "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.6.0.tgz", + "integrity": "sha512-5AEH2EXD8euCk446b7edmgFdub/qfH1SN6Nii3+fyXP807QRx9Q73A2N5hNwRRslC2H9sNzaFhsPubkS4L8oNQ==", "dev": true, "requires": { "@babel/code-frame": "^7.0.0", - "@babel/parser": "^7.4.0", - "@babel/types": "^7.4.0" + "@babel/parser": "^7.6.0", + "@babel/types": "^7.6.0" } }, "@babel/traverse": { - "version": "7.4.0", - "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.4.0.tgz", - "integrity": "sha512-/DtIHKfyg2bBKnIN+BItaIlEg5pjAnzHOIQe5w+rHAw/rg9g0V7T4rqPX8BJPfW11kt3koyjAnTNwCzb28Y1PA==", + "version": "7.6.0", + "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.6.0.tgz", + "integrity": "sha512-93t52SaOBgml/xY74lsmt7xOR4ufYvhb5c5qiM6lu4J/dWGMAfAh6eKw4PjLes6DI6nQgearoxnFJk60YchpvQ==", "dev": true, "requires": { - "@babel/code-frame": "^7.0.0", - "@babel/generator": "^7.4.0", + "@babel/code-frame": "^7.5.5", + "@babel/generator": "^7.6.0", "@babel/helper-function-name": "^7.1.0", - "@babel/helper-split-export-declaration": "^7.4.0", - "@babel/parser": "^7.4.0", - "@babel/types": "^7.4.0", + "@babel/helper-split-export-declaration": "^7.4.4", + "@babel/parser": "^7.6.0", + "@babel/types": "^7.6.0", "debug": "^4.1.0", "globals": "^11.1.0", - "lodash": "^4.17.11" + "lodash": "^4.17.13" } }, "@babel/types": { - "version": "7.4.0", - "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.4.0.tgz", - "integrity": "sha512-aPvkXyU2SPOnztlgo8n9cEiXW755mgyvueUPcpStqdzoSPm0fjO0vQBjLkt3JKJW7ufikfcnMTTPsN1xaTsBPA==", + "version": "7.6.1", + "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.6.1.tgz", + "integrity": "sha512-X7gdiuaCmA0uRjCmRtYJNAVCc/q+5xSgsfKJHqMN4iNLILX39677fJE1O40arPMh0TTtS9ItH67yre6c7k6t0g==", "dev": true, "requires": { "esutils": "^2.0.2", - "lodash": "^4.17.11", + "lodash": "^4.17.13", "to-fast-properties": "^2.0.0" } }, @@ -784,9 +838,9 @@ "dev": true }, "@sinonjs/commons": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/@sinonjs/commons/-/commons-1.4.0.tgz", - "integrity": "sha512-9jHK3YF/8HtJ9wCAbG+j8cD0i0+ATS9A7gXFqS36TblLPNy6rEEc+SB0imo91eCboGaBYGV/MT1/br/J+EE7Tw==", + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/@sinonjs/commons/-/commons-1.6.0.tgz", + "integrity": "sha512-w4/WHG7C4WWFyE5geCieFJF6MZkbW4VAriol5KlmQXpAQdxvV0p26sqNZOW6Qyw6Y0l9K4g+cHvvczR2sEEpqg==", "dev": true, "requires": { "type-detect": "4.0.8" @@ -799,25 +853,17 @@ "dev": true, "requires": { "samsam": "1.3.0" - }, - "dependencies": { - "samsam": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/samsam/-/samsam-1.3.0.tgz", - "integrity": "sha512-1HwIYD/8UlOtFS3QO3w7ey+SdSDFE4HRNLZoZRYVQefrOY3l17epswImeB1ijgJFQJodIaHcwkp3r/myBjFVbg==", - "dev": true - } } }, "@sinonjs/samsam": { - "version": "3.3.1", - "resolved": "https://registry.npmjs.org/@sinonjs/samsam/-/samsam-3.3.1.tgz", - "integrity": "sha512-wRSfmyd81swH0hA1bxJZJ57xr22kC07a1N4zuIL47yTS04bDk6AoCkczcqHEjcRPmJ+FruGJ9WBQiJwMtIElFw==", + "version": "3.3.3", + "resolved": "https://registry.npmjs.org/@sinonjs/samsam/-/samsam-3.3.3.tgz", + "integrity": "sha512-bKCMKZvWIjYD0BLGnNrxVuw4dkWCYsLqFOUWw8VgKF/+5Y+mE7LfHWPIYoDXowH+3a9LsWDMo0uAP8YDosPvHQ==", "dev": true, "requires": { - "@sinonjs/commons": "^1.0.2", + "@sinonjs/commons": "^1.3.0", "array-from": "^2.1.1", - "lodash": "^4.17.11" + "lodash": "^4.17.15" } }, "@sinonjs/text-encoding": { @@ -826,12 +872,6 @@ "integrity": "sha512-+iTbntw2IZPb/anVDbypzfQa+ay64MW0Zo8aJ8gZPWMMK6/OubMVb6lUPMagqjOPnmtauXnFCACVl3O7ogjeqQ==", "dev": true }, - "@types/node": { - "version": "8.10.45", - "resolved": "https://registry.npmjs.org/@types/node/-/node-8.10.45.tgz", - "integrity": "sha512-tGVTbA+i3qfXsLbq9rEq/hezaHY55QxQLeXQL2ejNgFAxxrgu8eMmYIOsRcl7hN1uTLVsKOOYacV/rcJM3sfgQ==", - "dev": true - }, "JSONStream": { "version": "1.3.5", "resolved": "https://registry.npmjs.org/JSONStream/-/JSONStream-1.3.5.tgz", @@ -849,13 +889,13 @@ "dev": true }, "accepts": { - "version": "1.3.5", - "resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.5.tgz", - "integrity": "sha1-63d99gEXI6OxTopywIBcjoZ0a9I=", + "version": "1.3.7", + "resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.7.tgz", + "integrity": "sha512-Il80Qs2WjYlJIBNzNkK6KYqlVMTbZLXgHx2oT0pU/fjRHyEp+PEfEPY0R3WCwAGVOtauxh1hOxNgIf5bv7dQpA==", "dev": true, "requires": { - "mime-types": "~2.1.18", - "negotiator": "0.6.1" + "mime-types": "~2.1.24", + "negotiator": "0.6.2" } }, "acorn": { @@ -898,6 +938,12 @@ } } }, + "acorn-walk": { + "version": "6.2.0", + "resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-6.2.0.tgz", + "integrity": "sha512-7evsyfH1cLOCdAzZAd43Cic04yKydNx0cF+7tiA19p1XnLLPU4dpCQOqpjqwokFe//vS0QqfqqjCS2JkiIs0cA==", + "dev": true + }, "after": { "version": "0.8.2", "resolved": "https://registry.npmjs.org/after/-/after-0.8.2.tgz", @@ -905,9 +951,9 @@ "dev": true }, "agent-base": { - "version": "4.2.1", - "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-4.2.1.tgz", - "integrity": "sha512-JVwXMr9nHYTUXsBFKUqhJwvlcYU/blreOEUkhNR2eXZIvwd+c+o5V4MgDPKWnMS/56awN3TRzIP+KoPn+roQtg==", + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-4.3.0.tgz", + "integrity": "sha512-salcGninV0nPrwpGNn4VTXBb1SOuXQBiqbrNXoeizJsHrsL6ERFM2Ne3JUSBWRE6aeNJI2ROP/WEEIDUiDe3cg==", "dev": true, "requires": { "es6-promisify": "^5.0.0" @@ -960,13 +1006,10 @@ "dev": true }, "ansi-colors": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/ansi-colors/-/ansi-colors-1.1.0.tgz", - "integrity": "sha512-SFKX67auSNoVR38N3L+nvsPjOE0bybKTYbkf5tRvushrAPQ9V75huw0ZxBkKVeRU9kqH3d6HA4xTckbwZ4ixmA==", - "dev": true, - "requires": { - "ansi-wrap": "^0.1.0" - } + "version": "3.2.3", + "resolved": "https://registry.npmjs.org/ansi-colors/-/ansi-colors-3.2.3.tgz", + "integrity": "sha512-LEHHyuhlPY3TmuUYMh2oz89lTShfvgbmzaBcxve9t/9Wuy7Dwf4yoAKcND7KFT1HAQfqZ12qtc+DUrBMeKF9nw==", + "dev": true }, "ansi-escapes": { "version": "3.2.0", @@ -1049,6 +1092,58 @@ "default-require-extensions": "^1.0.0" } }, + "archiver": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/archiver/-/archiver-2.1.1.tgz", + "integrity": "sha1-/2YrSnggFJSj7lRNOjP+dJZQnrw=", + "dev": true, + "requires": { + "archiver-utils": "^1.3.0", + "async": "^2.0.0", + "buffer-crc32": "^0.2.1", + "glob": "^7.0.0", + "lodash": "^4.8.0", + "readable-stream": "^2.0.0", + "tar-stream": "^1.5.0", + "zip-stream": "^1.2.0" + }, + "dependencies": { + "async": { + "version": "2.6.3", + "resolved": "https://registry.npmjs.org/async/-/async-2.6.3.tgz", + "integrity": "sha512-zflvls11DCy+dQWzTW2dzuilv8Z5X/pjfmZOWba6TNIVDm+2UDaJmXSOXlasHKfNBs8oo3M0aT50fDEWfKZjXg==", + "dev": true, + "requires": { + "lodash": "^4.17.14" + } + } + } + }, + "archiver-utils": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/archiver-utils/-/archiver-utils-1.3.0.tgz", + "integrity": "sha1-5QtMCccL89aA4y/xt5lOn52JUXQ=", + "dev": true, + "requires": { + "glob": "^7.0.0", + "graceful-fs": "^4.1.0", + "lazystream": "^1.0.0", + "lodash": "^4.8.0", + "normalize-path": "^2.0.0", + "readable-stream": "^2.0.0" + }, + "dependencies": { + "normalize-path": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-2.1.1.tgz", + "integrity": "sha1-GrKLVW4Zg2Oowab35vogE3/mrtk=", + "dev": true, + "requires": { + "remove-trailing-separator": "^1.0.1" + } + } + } + }, "archy": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/archy/-/archy-1.0.0.tgz", @@ -1118,12 +1213,28 @@ "integrity": "sha1-3wEKoSh+Fku9pvlyOwqWoexBh6E=", "dev": true }, + "array-flatten": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz", + "integrity": "sha1-ml9pkFGx5wczKPKgCJaLZOopVdI=", + "dev": true + }, "array-from": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/array-from/-/array-from-2.1.1.tgz", "integrity": "sha1-z+nYwmYoudxa7MYqn12PHzUsEZU=", "dev": true }, + "array-includes": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/array-includes/-/array-includes-3.0.3.tgz", + "integrity": "sha1-GEtI9i2S10UrsxsyMWXH+L0CJm0=", + "dev": true, + "requires": { + "define-properties": "^1.1.2", + "es-abstract": "^1.7.0" + } + }, "array-initial": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/array-initial/-/array-initial-1.1.0.tgz", @@ -1223,11 +1334,12 @@ } }, "assert": { - "version": "1.4.1", - "resolved": "https://registry.npmjs.org/assert/-/assert-1.4.1.tgz", - "integrity": "sha1-mZEtWRg2tab1s0XA8H7vwI/GXZE=", + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/assert/-/assert-1.5.0.tgz", + "integrity": "sha512-EDsgawzwoun2CZkCgtxJbv392v4nbk9XDD06zI+kQYoBM/3RBWLlEyJARDOmhAAosBjWACEkKL6S+lIZtcAubA==", "dev": true, "requires": { + "object-assign": "^4.1.1", "util": "0.10.3" }, "dependencies": { @@ -1266,12 +1378,6 @@ "integrity": "sha1-WWZ/QfrdTyDMvCu5a41Pf3jsA2c=", "dev": true }, - "ast-types": { - "version": "0.12.2", - "resolved": "https://registry.npmjs.org/ast-types/-/ast-types-0.12.2.tgz", - "integrity": "sha512-8c83xDLJM/dLDyXNLiR6afRRm4dPKN6KAnKqytRK3DBJul9lA+atxdQkNDkSVPdTqea5HiRq3lnnOIZ0MBpvdg==", - "dev": true - }, "async": { "version": "1.5.2", "resolved": "https://registry.npmjs.org/async/-/async-1.5.2.tgz", @@ -1279,35 +1385,27 @@ "dev": true }, "async-done": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/async-done/-/async-done-1.3.1.tgz", - "integrity": "sha512-R1BaUeJ4PMoLNJuk+0tLJgjmEqVsdN118+Z8O+alhnQDQgy0kmD5Mqi0DNEmMx2LM0Ed5yekKu+ZXYvIHceicg==", + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/async-done/-/async-done-1.3.2.tgz", + "integrity": "sha512-uYkTP8dw2og1tu1nmza1n1CMW0qb8gWWlwqMmLb7MhBVs4BXrFziT6HXUd+/RlRA/i4H9AkofYloUbs1fwMqlw==", "dev": true, "requires": { "end-of-stream": "^1.1.0", "once": "^1.3.2", - "process-nextick-args": "^1.0.7", + "process-nextick-args": "^2.0.0", "stream-exhaust": "^1.0.1" - }, - "dependencies": { - "process-nextick-args": { - "version": "1.0.7", - "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-1.0.7.tgz", - "integrity": "sha1-FQ4gt1ZZCtP5EJPyWk8q2L/zC6M=", - "dev": true - } } }, "async-each": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/async-each/-/async-each-1.0.2.tgz", - "integrity": "sha512-6xrbvN0MOBKSJDdonmSSz2OwFSgxRaVtBDes26mj9KIGtDo+g9xosFRSC+i1gQh2oAN/tQ62AI/pGZGQjVOiRg==", + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/async-each/-/async-each-1.0.3.tgz", + "integrity": "sha512-z/WhQ5FPySLdvREByI2vZiTWwCnF0moMJ1hK9YQwDTHKh6I7/uSckMetoRGb5UBZPC1z0jlw+n/XCgjeH7y1AQ==", "dev": true }, "async-limiter": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/async-limiter/-/async-limiter-1.0.0.tgz", - "integrity": "sha512-jp/uFnooOiO+L211eZOoSyzpOITMXx1rBITauYykG3BRYPu8h0UcxsPNB04RR5vo4Tyz3+ay17tR6JVf9qzYWg==", + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/async-limiter/-/async-limiter-1.0.1.tgz", + "integrity": "sha512-csOlWGAcRFJaI6m+F2WKdnMKr4HhdhFVBk0H/QbJFMCr+uO2kwohwXQPxw/9OCxp05r5ghVBFSyioixx3gfkNQ==", "dev": true }, "async-settle": { @@ -1633,15 +1731,15 @@ } }, "babel-loader": { - "version": "8.0.5", - "resolved": "https://registry.npmjs.org/babel-loader/-/babel-loader-8.0.5.tgz", - "integrity": "sha512-NTnHnVRd2JnRqPC0vW+iOQWU5pchDbYXsG2E6DMXEpMfUcQKclF9gmf3G3ZMhzG7IG9ji4coL0cm+FxeWxDpnw==", + "version": "8.0.6", + "resolved": "https://registry.npmjs.org/babel-loader/-/babel-loader-8.0.6.tgz", + "integrity": "sha512-4BmWKtBOBm13uoUwd08UwjZlaw3O9GWf456R9j+5YykFZ6LUIjIKLc0zEZf+hauxPOJs96C8k6FvYD09vWzhYw==", "dev": true, "requires": { "find-cache-dir": "^2.0.0", "loader-utils": "^1.0.2", "mkdirp": "^0.5.1", - "util.promisify": "^1.0.0" + "pify": "^4.0.1" } }, "babel-messages": { @@ -1662,6 +1760,15 @@ "babel-runtime": "^6.22.0" } }, + "babel-plugin-dynamic-import-node": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/babel-plugin-dynamic-import-node/-/babel-plugin-dynamic-import-node-2.3.0.tgz", + "integrity": "sha512-o6qFkpeQEBxcqt0XYlWzAVxNCSCZdUgcR8IRlhD/8DylxjjO4foPcvTW0GGKa/cVt3rvxZ7o5ippJ+/0nvLhlQ==", + "dev": true, + "requires": { + "object.assign": "^4.1.0" + } + }, "babel-plugin-syntax-async-functions": { "version": "6.13.0", "resolved": "https://registry.npmjs.org/babel-plugin-syntax-async-functions/-/babel-plugin-syntax-async-functions-6.13.0.tgz", @@ -2486,9 +2593,9 @@ "dev": true }, "bail": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/bail/-/bail-1.0.3.tgz", - "integrity": "sha512-1X8CnjFVQ+a+KW36uBNMTU5s8+v5FzeqrP7hTG5aTb4aPreSbZJlhwPon9VKMuEVgV++JM+SQrALY3kr7eswdg==", + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/bail/-/bail-1.0.4.tgz", + "integrity": "sha512-S8vuDB4w6YpRhICUDET3guPlQpaJl7od94tpZ0Fvnyp+MKW/HyDTcRDck+29C9g+d/qQHnddRH3+94kZdrW0Ww==", "dev": true }, "balanced-match": { @@ -2559,9 +2666,9 @@ "dev": true }, "base64-js": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.3.0.tgz", - "integrity": "sha512-ccav/yGvoa80BQDljCxsmmQ3Xvx60/UpBIij5QN21W3wBi/hhIC9OoO+KLpu9IJTS9j4DRVJ3aDDF9cMSoa2lw==", + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.3.1.tgz", + "integrity": "sha512-mLQ4i2QO1ytvGWFWmcngKO//JXAQueZvwEKtjgQFM4jIK0kU+ytMfplL8j+n5mspOfjHwoAg+9yhb7BwAHm36g==", "dev": true }, "base64id": { @@ -2600,6 +2707,18 @@ "callsite": "1.0.0" } }, + "bfj": { + "version": "6.1.2", + "resolved": "https://registry.npmjs.org/bfj/-/bfj-6.1.2.tgz", + "integrity": "sha512-BmBJa4Lip6BPRINSZ0BPEIfB1wUY/9rwbwvIHQA1KjX9om29B6id0wnWXq7m3bn5JrUVjeOTnVuhPT1FiHwPGw==", + "dev": true, + "requires": { + "bluebird": "^3.5.5", + "check-types": "^8.0.3", + "hoopy": "^0.1.4", + "tryer": "^1.0.1" + } + }, "big.js": { "version": "5.2.2", "resolved": "https://registry.npmjs.org/big.js/-/big.js-5.2.2.tgz", @@ -2607,9 +2726,9 @@ "dev": true }, "binary-extensions": { - "version": "1.13.0", - "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-1.13.0.tgz", - "integrity": "sha512-EgmjVLMn22z7eGGv3kcnHwSnJXmFHjISTY9E/S5lIcTD3Oxw05QTcBLNkJFzcb3cNueUdF/IN4U+d78V0zO8Hw==", + "version": "1.13.1", + "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-1.13.1.tgz", + "integrity": "sha512-Un7MIEDdUC5gNpcGDV97op1Ywk748MpHcFTHoYs6qnj1Z3j7I53VG3nwZhKzoBZmbdRNnb6WRdFlwl7tSDuZGw==", "dev": true }, "binaryextensions": { @@ -2618,6 +2737,16 @@ "integrity": "sha512-xVNN69YGDghOqCCtA6FI7avYrr02mTJjOgB0/f1VPD3pJC8QEvjTKWc4epDx8AqxxA75NI0QpVM2gPJXUbE4Tg==", "dev": true }, + "bl": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/bl/-/bl-1.2.2.tgz", + "integrity": "sha512-e8tQYnZodmebYDWGH7KMRvtzKXaJHx3BbilrgZCfvyLUYdKpK1t5PSPmpkny/SgiTSCnjfLW7v5rlONXVFkQEA==", + "dev": true, + "requires": { + "readable-stream": "^2.3.5", + "safe-buffer": "^5.1.1" + } + }, "blob": { "version": "0.0.5", "resolved": "https://registry.npmjs.org/blob/-/blob-0.0.5.tgz", @@ -2625,9 +2754,9 @@ "dev": true }, "bluebird": { - "version": "3.5.3", - "resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.5.3.tgz", - "integrity": "sha512-/qKPUQlaW1OyR51WeCPBvRnAlnZFUJkCSG5HzGnuIqhgyJtF+T94lFnn33eiazjRm2LAHVy2guNnaq48X9SJuw==", + "version": "3.5.5", + "resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.5.5.tgz", + "integrity": "sha512-5am6HnnfN+urzt4yfg7IgTbotDjIT/u8AJpEt0sIU9FtXfVeezXAPKswrG+xKUCOYAINpSdgZVDU6QFh+cuH3w==", "dev": true }, "bn.js": { @@ -2649,27 +2778,27 @@ } }, "body-parser": { - "version": "1.18.3", - "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.18.3.tgz", - "integrity": "sha1-WykhmP/dVTs6DyDe0FkrlWlVyLQ=", + "version": "1.19.0", + "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.19.0.tgz", + "integrity": "sha512-dhEPs72UPbDnAQJ9ZKMNTP6ptJaionhP5cBb541nXPlW60Jepo9RV/a4fX4XWW9CuFNK22krhrj1+rgzifNCsw==", "dev": true, "requires": { - "bytes": "3.0.0", + "bytes": "3.1.0", "content-type": "~1.0.4", "debug": "2.6.9", "depd": "~1.1.2", - "http-errors": "~1.6.3", - "iconv-lite": "0.4.23", + "http-errors": "1.7.2", + "iconv-lite": "0.4.24", "on-finished": "~2.3.0", - "qs": "6.5.2", - "raw-body": "2.3.3", - "type-is": "~1.6.16" + "qs": "6.7.0", + "raw-body": "2.4.0", + "type-is": "~1.6.17" }, "dependencies": { "bytes": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.0.0.tgz", - "integrity": "sha1-0ygVQE1olpn4Wk6k+odV3ROpYEg=", + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.0.tgz", + "integrity": "sha512-zauLjrfCG+xvoyaqLoV8bLVXXNGC4JqlxFCutSDWA6fJrTo2ZuvLYTqZ7aHBLZSMOopbzwv8f+wZcVzfVTI2Dg==", "dev": true }, "debug": { @@ -2681,32 +2810,54 @@ "ms": "2.0.0" } }, - "iconv-lite": { - "version": "0.4.23", - "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.23.tgz", - "integrity": "sha512-neyTUVFtahjf0mB3dZT77u+8O0QB89jFdnBkd5P1JgYPbPaia3gXXOVL2fq8VyU2gMMD7SaN7QukTB/pmXYvDA==", + "http-errors": { + "version": "1.7.2", + "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.7.2.tgz", + "integrity": "sha512-uUQBt3H/cSIVfch6i1EuPNy/YsRSOUBXTVfZ+yR7Zjez3qjBz6i9+i4zjNaoqcoFVI4lQJ5plg63TvGfRSDCRg==", "dev": true, "requires": { - "safer-buffer": ">= 2.1.2 < 3" + "depd": "~1.1.2", + "inherits": "2.0.3", + "setprototypeof": "1.1.1", + "statuses": ">= 1.5.0 < 2", + "toidentifier": "1.0.0" } }, + "inherits": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", + "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=", + "dev": true + }, "ms": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", "dev": true }, + "qs": { + "version": "6.7.0", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.7.0.tgz", + "integrity": "sha512-VCdBRNFTX1fyE7Nb6FYoURo/SPe62QCaAyzJvUjwRaIsc+NePBEniHlvxFmmX56+HZphIGtV0XeCirBtpDrTyQ==", + "dev": true + }, "raw-body": { - "version": "2.3.3", - "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.3.3.tgz", - "integrity": "sha512-9esiElv1BrZoI3rCDuOuKCBRbuApGGaDPQfjSflGxdy4oyzqghxu6klEkkVIvBje+FF0BX9coEv8KqW6X/7njw==", + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.4.0.tgz", + "integrity": "sha512-4Oz8DUIwdvoa5qMJelxipzi/iJIi40O5cGV1wNYp5hvZP8ZN0T+jiNkL0QepXs+EsQ9XJ8ipEDoiH70ySUJP3Q==", "dev": true, "requires": { - "bytes": "3.0.0", - "http-errors": "1.6.3", - "iconv-lite": "0.4.23", + "bytes": "3.1.0", + "http-errors": "1.7.2", + "iconv-lite": "0.4.24", "unpipe": "1.0.0" } + }, + "setprototypeof": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.1.1.tgz", + "integrity": "sha512-JvdAWfbXeIGaZ9cILp38HntZSFSo3mWg6xGcJJsd+d4aRMOqauag1C63dJfDw7OaMYwEbHMOxEZ1lqVRYP2OAw==", + "dev": true } } }, @@ -2850,61 +3001,45 @@ } }, "browserslist": { - "version": "4.5.2", - "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.5.2.tgz", - "integrity": "sha512-zmJVLiKLrzko0iszd/V4SsjTaomFeoVzQGYYOYgRgsbh7WNh95RgDB0CmBdFWYs/3MyFSt69NypjL/h3iaddKQ==", + "version": "4.7.0", + "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.7.0.tgz", + "integrity": "sha512-9rGNDtnj+HaahxiVV38Gn8n8Lr8REKsel68v1sPFfIGEK6uSXTY3h9acgiT1dZVtOOUtifo/Dn8daDQ5dUgVsA==", "dev": true, "requires": { - "caniuse-lite": "^1.0.30000951", - "electron-to-chromium": "^1.3.116", - "node-releases": "^1.1.11" + "caniuse-lite": "^1.0.30000989", + "electron-to-chromium": "^1.3.247", + "node-releases": "^1.1.29" } }, "browserstack": { - "version": "1.5.2", - "resolved": "https://registry.npmjs.org/browserstack/-/browserstack-1.5.2.tgz", - "integrity": "sha512-+6AFt9HzhKykcPF79W6yjEUJcdvZOV0lIXdkORXMJftGrDl0OKWqRF4GHqpDNkxiceDT/uB7Fb/aDwktvXX7dg==", + "version": "1.5.3", + "resolved": "https://registry.npmjs.org/browserstack/-/browserstack-1.5.3.tgz", + "integrity": "sha512-AO+mECXsW4QcqC9bxwM29O7qWa7bJT94uBFzeb5brylIQwawuEziwq20dPYbins95GlWzOawgyDNdjYAo32EKg==", "dev": true, "requires": { "https-proxy-agent": "^2.2.1" } }, "browserstack-local": { - "version": "1.3.7", - "resolved": "https://registry.npmjs.org/browserstack-local/-/browserstack-local-1.3.7.tgz", - "integrity": "sha512-ilZlmiy7XYJxsztYan7XueHVr3Ix9EVh/mCiYN1G53wRPEW/hg1KMsseM6UExzVbexEqFEfwjkBLeFlSqxh+bQ==", + "version": "1.4.2", + "resolved": "https://registry.npmjs.org/browserstack-local/-/browserstack-local-1.4.2.tgz", + "integrity": "sha512-fRaynjF0MvtyyfPRy2NFnVwxLyNtD28K/v9xRsIjUVf7xLc80NIm7Nfr3KXlFmWizhG91PL/UAOXlHkoxQjaNw==", "dev": true, "requires": { "https-proxy-agent": "^2.2.1", "is-running": "^2.0.0", "ps-tree": "=1.1.1", - "sinon": "^1.17.6", "temp-fs": "^0.9.9" - }, - "dependencies": { - "sinon": { - "version": "1.17.7", - "resolved": "https://registry.npmjs.org/sinon/-/sinon-1.17.7.tgz", - "integrity": "sha1-RUKk9JugxFwF6y6d2dID4rjv4L8=", - "dev": true, - "requires": { - "formatio": "1.1.1", - "lolex": "1.3.2", - "samsam": "1.1.2", - "util": ">=0.10.3 <1" - } - } } }, "buffer": { - "version": "4.9.1", - "resolved": "https://registry.npmjs.org/buffer/-/buffer-4.9.1.tgz", - "integrity": "sha1-bRu2AbB6TvztlwlBMgkwJ8lbwpg=", + "version": "5.4.2", + "resolved": "https://registry.npmjs.org/buffer/-/buffer-5.4.2.tgz", + "integrity": "sha512-iy9koArjAFCzGnx3ZvNA6Z0clIbbFgbdWQ0mKD3hO0krOrZh8UgA6qMKcZvwLJxS+D6iVR76+5/pV56yMNYTag==", "dev": true, "requires": { "base64-js": "^1.0.2", - "ieee754": "^1.1.4", - "isarray": "^1.0.0" + "ieee754": "^1.1.4" } }, "buffer-alloc": { @@ -2923,6 +3058,12 @@ "integrity": "sha512-TEM2iMIEQdJ2yjPJoSIsldnleVaAk1oW3DBVUykyOLsEsFmEc9kn+SFFPz+gl54KQNxlDnAwCXosOS9Okx2xAg==", "dev": true }, + "buffer-crc32": { + "version": "0.2.13", + "resolved": "https://registry.npmjs.org/buffer-crc32/-/buffer-crc32-0.2.13.tgz", + "integrity": "sha1-DTM+PwDqxQqhRUq9MO+MKl2ackI=", + "dev": true + }, "buffer-equal": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/buffer-equal/-/buffer-equal-1.0.0.tgz", @@ -3064,9 +3205,9 @@ "dev": true }, "camelcase": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-4.1.0.tgz", - "integrity": "sha1-1UVjW+HjPFQmScaRc+Xeas+uNN0=", + "version": "5.3.1", + "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-5.3.1.tgz", + "integrity": "sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg==", "dev": true }, "camelcase-keys": { @@ -3088,9 +3229,9 @@ } }, "caniuse-lite": { - "version": "1.0.30000953", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30000953.tgz", - "integrity": "sha512-2stdF/q5MZTDhQ6uC65HWbSgI9UMKbc7+HKvlwH5JBIslKoD/J9dvabP4J4Uiifu3NljbHj3iMpfYflLSNt09A==", + "version": "1.0.30000989", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30000989.tgz", + "integrity": "sha512-vrMcvSuMz16YY6GSVZ0dWDTJP8jqk3iFQ/Aq5iqblPwxSVVZI+zxDyTX0VPqtQsDnfdrBDcsmhgTEOh5R8Lbpw==", "dev": true }, "caseless": { @@ -3100,9 +3241,9 @@ "dev": true }, "ccount": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/ccount/-/ccount-1.0.3.tgz", - "integrity": "sha512-Jt9tIBkRc9POUof7QA/VwWd+58fKkEEfI+/t1/eOlxKM7ZhrczNzMFefge7Ai+39y1pR/pP6cI19guHy3FSLmw==", + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/ccount/-/ccount-1.0.4.tgz", + "integrity": "sha512-fpZ81yYfzentuieinmGnphk0pLkOTMm6MZdVqwd77ROvhko6iujLNGrHH5E7utq3ygWklwfmwuG+A7P+NpqT6w==", "dev": true }, "center-align": { @@ -3129,39 +3270,6 @@ "type-detect": "^4.0.5" } }, - "chai-nightwatch": { - "version": "0.2.1", - "resolved": "https://registry.npmjs.org/chai-nightwatch/-/chai-nightwatch-0.2.1.tgz", - "integrity": "sha512-2lprSMi72sHq2ZGyPTYUDQNsd2O4z81SicascbI4bkU54Xzk5Ofunn2CbrExADGC7jBH2D8r66X/aSEl+/agXQ==", - "dev": true, - "requires": { - "assertion-error": "1.0.0", - "deep-eql": "0.1.3" - }, - "dependencies": { - "assertion-error": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-1.0.0.tgz", - "integrity": "sha1-x/hUOP3UZrx8oWq5DIFRN5el0js=", - "dev": true - }, - "deep-eql": { - "version": "0.1.3", - "resolved": "https://registry.npmjs.org/deep-eql/-/deep-eql-0.1.3.tgz", - "integrity": "sha1-71WKyrjeJSBs1xOQbXTlaTDrafI=", - "dev": true, - "requires": { - "type-detect": "0.1.1" - } - }, - "type-detect": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/type-detect/-/type-detect-0.1.1.tgz", - "integrity": "sha1-C6XsKohWQORw6k6FBZcZANrFiCI=", - "dev": true - } - } - }, "chalk": { "version": "2.4.2", "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", @@ -3174,27 +3282,27 @@ } }, "character-entities": { - "version": "1.2.2", - "resolved": "https://registry.npmjs.org/character-entities/-/character-entities-1.2.2.tgz", - "integrity": "sha512-sMoHX6/nBiy3KKfC78dnEalnpn0Az0oSNvqUWYTtYrhRI5iUIYsROU48G+E+kMFQzqXaJ8kHJZ85n7y6/PHgwQ==", + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/character-entities/-/character-entities-1.2.3.tgz", + "integrity": "sha512-yB4oYSAa9yLcGyTbB4ItFwHw43QHdH129IJ5R+WvxOkWlyFnR5FAaBNnUq4mcxsTVZGh28bHoeTHMKXH1wZf3w==", "dev": true }, "character-entities-html4": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/character-entities-html4/-/character-entities-html4-1.1.2.tgz", - "integrity": "sha512-sIrXwyna2+5b0eB9W149izTPJk/KkJTg6mEzDGibwBUkyH1SbDa+nf515Ppdi3MaH35lW0JFJDWeq9Luzes1Iw==", + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/character-entities-html4/-/character-entities-html4-1.1.3.tgz", + "integrity": "sha512-SwnyZ7jQBCRHELk9zf2CN5AnGEc2nA+uKMZLHvcqhpPprjkYhiLn0DywMHgN5ttFZuITMATbh68M6VIVKwJbcg==", "dev": true }, "character-entities-legacy": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/character-entities-legacy/-/character-entities-legacy-1.1.2.tgz", - "integrity": "sha512-9NB2VbXtXYWdXzqrvAHykE/f0QJxzaKIpZ5QzNZrrgQ7Iyxr2vnfS8fCBNVW9nUEZE0lo57nxKRqnzY/dKrwlA==", + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/character-entities-legacy/-/character-entities-legacy-1.1.3.tgz", + "integrity": "sha512-YAxUpPoPwxYFsslbdKkhrGnXAtXoHNgYjlBM3WMXkWGTl5RsY3QmOyhwAgL8Nxm9l5LBThXGawxKPn68y6/fww==", "dev": true }, "character-reference-invalid": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/character-reference-invalid/-/character-reference-invalid-1.1.2.tgz", - "integrity": "sha512-7I/xceXfKyUJmSAn/jw8ve/9DyOP7XxufNYLI9Px7CmsKgEUaZLUTax6nZxGQtaoiZCjpu6cHPj20xC/vqRReQ==", + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/character-reference-invalid/-/character-reference-invalid-1.1.3.tgz", + "integrity": "sha512-VOq6PRzQBam/8Jm6XBGk2fNEnHXAdGd6go0rtd4weAGECBamHDwwCQSOT12TACIYUZegUXnV6xBXqUssijtxIg==", "dev": true }, "chardet": { @@ -3209,10 +3317,16 @@ "integrity": "sha1-V00xLt2Iu13YkS6Sht1sCu1KrII=", "dev": true }, + "check-types": { + "version": "8.0.3", + "resolved": "https://registry.npmjs.org/check-types/-/check-types-8.0.3.tgz", + "integrity": "sha512-YpeKZngUmG65rLudJ4taU7VLkOCTMhNl/u4ctNC56LQS/zJTyNH0Lrtwm1tfTsbLlwvlfsA2d1c8vCf/Kh2KwQ==", + "dev": true + }, "chokidar": { - "version": "2.1.5", - "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-2.1.5.tgz", - "integrity": "sha512-i0TprVWp+Kj4WRPtInjexJ8Q+BqTE909VpH8xVhXrJkoc5QC8VO9TryGOqTr+2hljzc1sC62t22h5tZePodM/A==", + "version": "2.1.8", + "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-2.1.8.tgz", + "integrity": "sha512-ZmZUazfOzf0Nve7duiCKD23PFSCs4JPoYyccjUFF3aQkQadqBhfzhjkwBH2mNOG9cTBwhamM37EIsIkZw3nRgg==", "dev": true, "requires": { "anymatch": "^2.0.0", @@ -3284,14 +3398,31 @@ "dev": true }, "cliui": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/cliui/-/cliui-3.2.0.tgz", - "integrity": "sha1-EgYBU3qRbSmUD5NNo7SNWFo5IT0=", + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/cliui/-/cliui-4.1.0.tgz", + "integrity": "sha512-4FG+RSG9DL7uEwRUZXZn3SS34DiDPfzP0VOiEwtUWlE+AR2EIg+hSyvrIgUUfhdgR/UkAeW2QHgeP+hWrXs7jQ==", "dev": true, "requires": { - "string-width": "^1.0.1", - "strip-ansi": "^3.0.1", + "string-width": "^2.1.1", + "strip-ansi": "^4.0.0", "wrap-ansi": "^2.0.0" + }, + "dependencies": { + "ansi-regex": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.0.tgz", + "integrity": "sha1-7QMXwyIGT3lGbAKWa922Bas32Zg=", + "dev": true + }, + "strip-ansi": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz", + "integrity": "sha1-qEeQIusaw2iocTibY1JixQXuNo8=", + "dev": true, + "requires": { + "ansi-regex": "^3.0.0" + } + } } }, "clone": { @@ -3322,9 +3453,9 @@ "dev": true }, "cloneable-readable": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/cloneable-readable/-/cloneable-readable-1.1.2.tgz", - "integrity": "sha512-Bq6+4t+lbM8vhTs/Bef5c5AdEMtapp/iFb6+s4/Hh9MVTt8OLKH7ZOOZSCT+Ys7hsHvqv0GuMPJ1lnQJVHvxpg==", + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/cloneable-readable/-/cloneable-readable-1.1.3.tgz", + "integrity": "sha512-2EF8zTQOxYq70Y4XKtorQupqF0m49MBz2/yf5Bj+MHjvpG3Hy7sImifnqD6UA+TKYxeSV+u6qqQPawN5UvnpKQ==", "dev": true, "requires": { "inherits": "^2.0.1", @@ -3345,9 +3476,9 @@ "dev": true }, "collapse-white-space": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/collapse-white-space/-/collapse-white-space-1.0.4.tgz", - "integrity": "sha512-YfQ1tAUZm561vpYD+5eyWN8+UsceQbSrqqlc/6zDY2gtAE+uZLSdkkovhnGpmCThsvKBFakq4EdY/FF93E8XIw==", + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/collapse-white-space/-/collapse-white-space-1.0.5.tgz", + "integrity": "sha512-703bOOmytCYAX9cXYqoikYIx6twmFCXsnzRQheBcTG3nzKYBR4P/+wkYeH+Mvj7qUz8zZDtdyzbxfnEi/kYzRQ==", "dev": true }, "collection-map": { @@ -3408,27 +3539,24 @@ } }, "combined-stream": { - "version": "1.0.7", - "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.7.tgz", - "integrity": "sha512-brWl9y6vOB1xYPZcpZde3N9zDByXTosAeMDo4p1wzo6UMOX4vumB+TP1RZ76sfE6Md68Q0NJSrE/gbezd4Ul+w==", + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", + "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", "dev": true, "requires": { "delayed-stream": "~1.0.0" } }, "comma-separated-tokens": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/comma-separated-tokens/-/comma-separated-tokens-1.0.5.tgz", - "integrity": "sha512-Cg90/fcK93n0ecgYTAz1jaA3zvnQ0ExlmKY1rdbyHqAx6BHxwoJc+J7HDu0iuQ7ixEs1qaa+WyQ6oeuBpYP1iA==", - "dev": true, - "requires": { - "trim": "0.0.1" - } + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/comma-separated-tokens/-/comma-separated-tokens-1.0.7.tgz", + "integrity": "sha512-Jrx3xsP4pPv4AwJUDWY9wOXGtwPXARej6Xd99h4TUGotmf8APuquKMpK+dnD3UgyxK7OEWaisjZz+3b5jtL6xQ==", + "dev": true }, "commander": { - "version": "2.15.1", - "resolved": "https://registry.npmjs.org/commander/-/commander-2.15.1.tgz", - "integrity": "sha512-VlfT9F3V0v+jr4yxPc5gg9s62/fIVWsd2Bk2iD435um1NlGMYdVCq+MjcXnhYq2icNOizHr1kK+5TI6H0Hy0ag==", + "version": "2.20.0", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.0.tgz", + "integrity": "sha512-7j2y+40w61zy6YC2iRNpUe/NwhNyoXrYpHMrSunaMG64nRnaf96zO/KMQR4OyN/UnE5KLyEBnKHd4aG3rskjpQ==", "dev": true }, "commondir": { @@ -3444,9 +3572,9 @@ "dev": true }, "component-emitter": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/component-emitter/-/component-emitter-1.2.1.tgz", - "integrity": "sha1-E3kY1teCg/ffemt8WmPhQOaUJeY=", + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/component-emitter/-/component-emitter-1.3.0.tgz", + "integrity": "sha512-Rd3se6QB+sO1TwqZjscQrurpEPIfO0/yYnSin6Q/rD3mOutHvUrCAhJub3r90uNb+SESBuE0QYoB90YdfatsRg==", "dev": true }, "component-inherit": { @@ -3455,6 +3583,29 @@ "integrity": "sha1-ZF/ErfWLcrZJ1crmUTVhnbJv8UM=", "dev": true }, + "compress-commons": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/compress-commons/-/compress-commons-1.2.2.tgz", + "integrity": "sha1-UkqfEJA/OoEzibAiXSfEi7dRiQ8=", + "dev": true, + "requires": { + "buffer-crc32": "^0.2.1", + "crc32-stream": "^2.0.0", + "normalize-path": "^2.0.0", + "readable-stream": "^2.0.0" + }, + "dependencies": { + "normalize-path": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-2.1.1.tgz", + "integrity": "sha1-GrKLVW4Zg2Oowab35vogE3/mrtk=", + "dev": true, + "requires": { + "remove-trailing-separator": "^1.0.1" + } + } + } + }, "concat-map": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", @@ -3491,14 +3642,14 @@ } }, "connect": { - "version": "3.6.6", - "resolved": "https://registry.npmjs.org/connect/-/connect-3.6.6.tgz", - "integrity": "sha1-Ce/2xVr3I24TcTWnJXSFi2eG9SQ=", + "version": "3.7.0", + "resolved": "https://registry.npmjs.org/connect/-/connect-3.7.0.tgz", + "integrity": "sha512-ZqRXc+tZukToSNmh5C2iWMSoV3X1YUcPbqEM4DkEG5tNQXrQUZCNVGGv3IuicnkMtPfGf3Xtp8WCXs295iQ1pQ==", "dev": true, "requires": { "debug": "2.6.9", - "finalhandler": "1.1.0", - "parseurl": "~1.3.2", + "finalhandler": "1.1.2", + "parseurl": "~1.3.3", "utils-merge": "1.0.1" }, "dependencies": { @@ -3546,6 +3697,15 @@ "integrity": "sha1-/ozxhP9mcLa67wGp1IYaXL7EEgo=", "dev": true }, + "content-disposition": { + "version": "0.5.3", + "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.3.tgz", + "integrity": "sha512-ExO0774ikEObIAEV9kDo50o+79VCUdEB6n6lzKgGwupcVeRlhrj3qGAfwq8G6uBJjkqLrhT0qEYFcWng8z1z0g==", + "dev": true, + "requires": { + "safe-buffer": "5.1.2" + } + }, "content-type": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.4.tgz", @@ -3573,6 +3733,12 @@ "integrity": "sha1-5+Ch+e9DtMi6klxcWpboBtFoc7s=", "dev": true }, + "cookie-signature": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.6.tgz", + "integrity": "sha1-4wOogrNCzD7oylE6eZmXNNqzriw=", + "dev": true + }, "copy-descriptor": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/copy-descriptor/-/copy-descriptor-0.1.1.tgz", @@ -3590,36 +3756,28 @@ } }, "core-js": { - "version": "2.6.5", - "resolved": "https://registry.npmjs.org/core-js/-/core-js-2.6.5.tgz", - "integrity": "sha512-klh/kDpwX8hryYL14M9w/xei6vrv6sE8gTHDG7/T/+SEovB/G4ejwcfE/CBzO6Edsu+OETZMZ3wcX/EjUkrl5A==" + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/core-js/-/core-js-2.6.9.tgz", + "integrity": "sha512-HOpZf6eXmnl7la+cUdMnLvUxKNqLUzJvgIziQ0DiF3JwSImNphIqdGqzj6hIKyX04MmV0poclQ7+wjWvxQyR2A==" }, "core-js-compat": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/core-js-compat/-/core-js-compat-3.0.0.tgz", - "integrity": "sha512-W/Ppz34uUme3LmXWjMgFlYyGnbo1hd9JvA0LNQ4EmieqVjg2GPYbj3H6tcdP2QGPGWdRKUqZVbVKLNIFVs/HiA==", + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/core-js-compat/-/core-js-compat-3.2.1.tgz", + "integrity": "sha512-MwPZle5CF9dEaMYdDeWm73ao/IflDH+FjeJCWEADcEgFSE9TLimFKwJsfmkwzI8eC0Aj0mgvMDjeQjrElkz4/A==", "dev": true, "requires": { - "browserslist": "^4.5.1", - "core-js": "3.0.0", - "core-js-pure": "3.0.0", - "semver": "^5.6.0" + "browserslist": "^4.6.6", + "semver": "^6.3.0" }, "dependencies": { - "core-js": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/core-js/-/core-js-3.0.0.tgz", - "integrity": "sha512-WBmxlgH2122EzEJ6GH8o9L/FeoUKxxxZ6q6VUxoTlsE4EvbTWKJb447eyVxTEuq0LpXjlq/kCB2qgBvsYRkLvQ==", + "semver": { + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", + "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", "dev": true } } }, - "core-js-pure": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/core-js-pure/-/core-js-pure-3.0.0.tgz", - "integrity": "sha512-yPiS3fQd842RZDgo/TAKGgS0f3p2nxssF1H65DIZvZv0Od5CygP8puHXn3IQiM/39VAvgCbdaMQpresrbGgt9g==", - "dev": true - }, "core-util-is": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", @@ -3627,19 +3785,38 @@ "dev": true }, "coveralls": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/coveralls/-/coveralls-3.0.3.tgz", - "integrity": "sha512-viNfeGlda2zJr8Gj1zqXpDMRjw9uM54p7wzZdvLRyOgnAfCe974Dq4veZkjJdxQXbmdppu6flEajFYseHYaUhg==", + "version": "3.0.6", + "resolved": "https://registry.npmjs.org/coveralls/-/coveralls-3.0.6.tgz", + "integrity": "sha512-Pgh4v3gCI4T/9VijVrm8Ym5v0OgjvGLKj3zTUwkvsCiwqae/p6VLzpsFNjQS2i6ewV7ef+DjFJ5TSKxYt/mCrA==", "dev": true, "requires": { "growl": "~> 1.10.0", - "js-yaml": "^3.11.0", + "js-yaml": "^3.13.1", "lcov-parse": "^0.0.10", "log-driver": "^1.2.7", "minimist": "^1.2.0", "request": "^2.86.0" } }, + "crc": { + "version": "3.8.0", + "resolved": "https://registry.npmjs.org/crc/-/crc-3.8.0.tgz", + "integrity": "sha512-iX3mfgcTMIq3ZKLIsVFAbv7+Mc10kxabAGQb8HvjA1o3T1PIYprbakQ65d3I+2HGHt6nSKkM9PYjgoJO2KcFBQ==", + "dev": true, + "requires": { + "buffer": "^5.1.0" + } + }, + "crc32-stream": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/crc32-stream/-/crc32-stream-2.0.0.tgz", + "integrity": "sha1-483TtN8xaN10494/u8t7KX/pCPQ=", + "dev": true, + "requires": { + "crc": "^3.4.4", + "readable-stream": "^2.0.0" + } + }, "create-ecdh": { "version": "4.0.3", "resolved": "https://registry.npmjs.org/create-ecdh/-/create-ecdh-4.0.3.tgz", @@ -3678,12 +3855,14 @@ } }, "cross-spawn": { - "version": "5.1.0", - "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-5.1.0.tgz", - "integrity": "sha1-6L0O/uWPz/b4+UUQoKVUu/ojVEk=", + "version": "6.0.5", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-6.0.5.tgz", + "integrity": "sha512-eTVLrBSt7fjbDygz805pMnstIs2VTBNkRm0qxZd+M7A5XDdxVRWO5MxGBXZhjY4cqLYLdtrGqRf8mBPmzwSpWQ==", "dev": true, "requires": { - "lru-cache": "^4.0.1", + "nice-try": "^1.0.4", + "path-key": "^2.0.1", + "semver": "^5.5.0", "shebang-command": "^1.2.0", "which": "^1.2.9" } @@ -3732,6 +3911,21 @@ } } }, + "css-parse": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/css-parse/-/css-parse-2.0.0.tgz", + "integrity": "sha1-pGjuZnwW2BzPBcWMONKpfHgNv9Q=", + "dev": true, + "requires": { + "css": "^2.0.0" + } + }, + "css-value": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/css-value/-/css-value-0.0.1.tgz", + "integrity": "sha1-Xv1sLupeof1rasV+wEJ7GEUkJOo=", + "dev": true + }, "currently-unhandled": { "version": "0.4.1", "resolved": "https://registry.npmjs.org/currently-unhandled/-/currently-unhandled-0.4.1.tgz", @@ -3748,12 +3942,13 @@ "dev": true }, "d": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/d/-/d-1.0.0.tgz", - "integrity": "sha1-dUu1v+VUUdpppYuU1F9MWwRi1Y8=", + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/d/-/d-1.0.1.tgz", + "integrity": "sha512-m62ShEObQ39CfralilEQRjH6oAMtNCV1xJyEx5LpRYUVN+EviphDgUc/F3hnYbADmkiNs67Y+3ylmlG7Lnu+FA==", "dev": true, "requires": { - "es5-ext": "^0.10.9" + "es5-ext": "^0.10.50", + "type": "^1.0.1" } }, "dashdash": { @@ -3765,15 +3960,6 @@ "assert-plus": "^1.0.0" } }, - "data-uri-to-buffer": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/data-uri-to-buffer/-/data-uri-to-buffer-2.0.0.tgz", - "integrity": "sha512-YbKCNLPPP4inc0E5If4OaalBc7gpaM2MRv77Pv2VThVComLKfbGYtJcdDCViDyp1Wd4SebhHLz94vp91zbK6bw==", - "dev": true, - "requires": { - "@types/node": "^8.0.7" - } - }, "date-format": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/date-format/-/date-format-1.2.0.tgz", @@ -3863,6 +4049,12 @@ "integrity": "sha1-s2nW+128E+7PUk+RsHD+7cNXzzQ=", "dev": true }, + "deepmerge": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/deepmerge/-/deepmerge-2.0.1.tgz", + "integrity": "sha512-VIPwiMJqJ13ZQfaCsIFnp5Me9tnjURiaIFxfz7EH0Ci0dTSQpZtSLrqOicXqEd/z2r+z+Klk9GzmnRsgpgbOsQ==", + "dev": true + }, "default-compare": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/default-compare/-/default-compare-1.0.0.tgz", @@ -3962,25 +4154,6 @@ "integrity": "sha1-yY2bzvdWdBiOEQlpFRGZ45sfppM=", "dev": true }, - "degenerator": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/degenerator/-/degenerator-1.0.4.tgz", - "integrity": "sha1-/PSQo37OJmRk2cxDGrmMWBnO0JU=", - "dev": true, - "requires": { - "ast-types": "0.x.x", - "escodegen": "1.x.x", - "esprima": "3.x.x" - }, - "dependencies": { - "esprima": { - "version": "3.1.3", - "resolved": "https://registry.npmjs.org/esprima/-/esprima-3.1.3.tgz", - "integrity": "sha1-/cpRzuYTOJXjyI1TXOSdv/YqRjM=", - "dev": true - } - } - }, "delayed-stream": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", @@ -4010,9 +4183,9 @@ "dev": true }, "detab": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/detab/-/detab-2.0.1.tgz", - "integrity": "sha512-/hhdqdQc5thGrqzjyO/pz76lDZ5GSuAs6goxOaKTsvPk7HNnzAyFN5lyHgqpX4/s1i66K8qMGj+VhA9504x7DQ==", + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/detab/-/detab-2.0.2.tgz", + "integrity": "sha512-Q57yPrxScy816TTE1P/uLRXLDKjXhvYTbfxS/e6lPD+YrqghbsMlGB9nQzj/zVtSPaF0DFPSdO916EWO4sQUyQ==", "dev": true, "requires": { "repeat-string": "^1.5.4" @@ -4033,6 +4206,12 @@ "repeating": "^2.0.0" } }, + "detect-libc": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-1.0.3.tgz", + "integrity": "sha1-+hN8S9aY7fVc1c0CrFWfkaTEups=", + "dev": true + }, "detect-newline": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/detect-newline/-/detect-newline-2.1.0.tgz", @@ -4090,6 +4269,11 @@ } } }, + "dlv": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/dlv/-/dlv-1.1.3.tgz", + "integrity": "sha512-+HlytyjlPKnIG8XuRG8WvmBP8xs8P71y+SKKS6ZXWoEgLuePxtDoUEiH7WkdePWrQ5JBpE6aoVqfZfJUQkjXwA==" + }, "doctrine": { "version": "1.5.0", "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-1.5.0.tgz", @@ -4167,12 +4351,62 @@ "yargs": "^9.0.1" }, "dependencies": { - "ansi-regex": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.0.tgz", - "integrity": "sha1-7QMXwyIGT3lGbAKWa922Bas32Zg=", + "camelcase": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-4.1.0.tgz", + "integrity": "sha1-1UVjW+HjPFQmScaRc+Xeas+uNN0=", "dev": true }, + "cliui": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/cliui/-/cliui-3.2.0.tgz", + "integrity": "sha1-EgYBU3qRbSmUD5NNo7SNWFo5IT0=", + "dev": true, + "requires": { + "string-width": "^1.0.1", + "strip-ansi": "^3.0.1", + "wrap-ansi": "^2.0.0" + }, + "dependencies": { + "string-width": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz", + "integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=", + "dev": true, + "requires": { + "code-point-at": "^1.0.0", + "is-fullwidth-code-point": "^1.0.0", + "strip-ansi": "^3.0.0" + } + } + } + }, + "cross-spawn": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-5.1.0.tgz", + "integrity": "sha1-6L0O/uWPz/b4+UUQoKVUu/ojVEk=", + "dev": true, + "requires": { + "lru-cache": "^4.0.1", + "shebang-command": "^1.2.0", + "which": "^1.2.9" + } + }, + "execa": { + "version": "0.7.0", + "resolved": "https://registry.npmjs.org/execa/-/execa-0.7.0.tgz", + "integrity": "sha1-lEvs00zEHuMqY6n68nrVpl/Fl3c=", + "dev": true, + "requires": { + "cross-spawn": "^5.0.1", + "get-stream": "^3.0.0", + "is-stream": "^1.1.0", + "npm-run-path": "^2.0.0", + "p-finally": "^1.0.0", + "signal-exit": "^3.0.0", + "strip-eof": "^1.0.0" + } + }, "find-up": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/find-up/-/find-up-2.1.0.tgz", @@ -4182,12 +4416,36 @@ "locate-path": "^2.0.0" } }, - "is-fullwidth-code-point": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz", - "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=", + "get-caller-file": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-1.0.3.tgz", + "integrity": "sha512-3t6rVToeoZfYSGd8YoLFR2DJkiQrIiUrGcjvFX2mDw3bn6k2OtwHN0TNCLbBO+w8qTvimhDkv+LSscbJY1vE6w==", + "dev": true + }, + "invert-kv": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/invert-kv/-/invert-kv-1.0.0.tgz", + "integrity": "sha1-EEqOSqym09jNFXqO+L+rLXo//bY=", "dev": true }, + "is-fullwidth-code-point": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz", + "integrity": "sha1-754xOG8DGn8NZDr4L95QxFfvAMs=", + "dev": true, + "requires": { + "number-is-nan": "^1.0.0" + } + }, + "lcid": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/lcid/-/lcid-1.0.0.tgz", + "integrity": "sha1-MIrMr6C8SDo4Z7S28rlQYlHRuDU=", + "dev": true, + "requires": { + "invert-kv": "^1.0.0" + } + }, "load-json-file": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/load-json-file/-/load-json-file-2.0.0.tgz", @@ -4218,6 +4476,32 @@ "path-exists": "^3.0.0" } }, + "mem": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/mem/-/mem-1.1.0.tgz", + "integrity": "sha1-Xt1StIXKHZAP5kiVUFOZoN+kX3Y=", + "dev": true, + "requires": { + "mimic-fn": "^1.0.0" + } + }, + "mimic-fn": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-1.2.0.tgz", + "integrity": "sha512-jf84uxzwiuiIVKiOLpfYk7N46TSy8ubTonmneY9vrpHNAnp0QBt2BxWV9dO3/j+BoVAb+a5G6YDPW3M5HOdMWQ==", + "dev": true + }, + "os-locale": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/os-locale/-/os-locale-2.1.0.tgz", + "integrity": "sha512-3sslG3zJbEYcaC4YVAvDorjGxc7tv6KVATnLPZONiljsUncvihe9BQoVCEs0RZ1kmf4Hk9OBqlZfJZWI4GanKA==", + "dev": true, + "requires": { + "execa": "^0.7.0", + "lcid": "^1.0.0", + "mem": "^1.1.0" + } + }, "p-limit": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-1.3.0.tgz", @@ -4285,24 +4569,17 @@ "path-type": "^2.0.0" } }, - "string-width": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-2.1.1.tgz", - "integrity": "sha512-nOqH59deCq9SRHlxq1Aw85Jnt4w6KvLKqWVik6oA9ZklXLNIOlqg4F2yrT1MVaTjAqvVwdfeZ7w7aCvJD7ugkw==", - "dev": true, - "requires": { - "is-fullwidth-code-point": "^2.0.0", - "strip-ansi": "^4.0.0" - } + "require-main-filename": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/require-main-filename/-/require-main-filename-1.0.1.tgz", + "integrity": "sha1-l/cXtp1IeE9fUmpsWqj/3aBVpNE=", + "dev": true }, - "strip-ansi": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz", - "integrity": "sha1-qEeQIusaw2iocTibY1JixQXuNo8=", - "dev": true, - "requires": { - "ansi-regex": "^3.0.0" - } + "y18n": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/y18n/-/y18n-3.2.1.tgz", + "integrity": "sha1-bRX7qITAhnnA136I53WegR4H+kE=", + "dev": true }, "yargs": { "version": "9.0.1", @@ -4336,6 +4613,15 @@ } } } + }, + "yargs-parser": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-7.0.0.tgz", + "integrity": "sha1-jQrELxbqVd69MyyvTEA4s+P139k=", + "dev": true, + "requires": { + "camelcase": "^4.1.0" + } } } }, @@ -4357,6 +4643,11 @@ "integrity": "sha512-jnjyiM6eRyZl2H+W8Q/zLMA481hzi0eszAaBUzIVnmYVDBbnLxVNnfu1HgEBvCbL+71FrxMl3E6lpKH7Ge3OXA==", "dev": true }, + "dset": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/dset/-/dset-2.0.1.tgz", + "integrity": "sha512-nI29OZMRYq36hOcifB6HTjajNAAiBKSXsyWZrq+VniusseuP2OpNlTiYgsaNRSGvpyq5Wjbc2gQLyBdTyWqhnQ==" + }, "duplexer": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/duplexer/-/duplexer-0.1.1.tgz", @@ -4423,21 +4714,21 @@ "dev": true }, "ejs": { - "version": "2.6.1", - "resolved": "https://registry.npmjs.org/ejs/-/ejs-2.6.1.tgz", - "integrity": "sha512-0xy4A/twfrRCnkhfk8ErDi5DqdAsAqeGxht4xkCUrsvhhbQNs7E+4jV0CN7+NKIY0aHE72+XvqtBIXzD31ZbXQ==", + "version": "2.5.9", + "resolved": "https://registry.npmjs.org/ejs/-/ejs-2.5.9.tgz", + "integrity": "sha512-GJCAeDBKfREgkBtgrYSf9hQy9kTb3helv0zGdzqhM7iAkW8FA/ZF97VQDbwFiwIT8MQLLOe5VlPZOEvZAqtUAQ==", "dev": true }, "electron-to-chromium": { - "version": "1.3.119", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.3.119.tgz", - "integrity": "sha512-3mtqcAWa4HgG+Djh/oNXlPH0cOH6MmtwxN1nHSaReb9P0Vn51qYPqYwLeoSuAX9loU1wrOBhFbiX3CkeIxPfgg==", + "version": "1.3.254", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.3.254.tgz", + "integrity": "sha512-7I5/OkgR6JKy6RFLJeru0kc0RMmmMu1UnkHBKInFKRrg1/4EQKIqOaUqITSww/SZ1LqWwp1qc/LLoIGy449eYw==", "dev": true }, "elliptic": { - "version": "6.4.1", - "resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.4.1.tgz", - "integrity": "sha512-BsXLz5sqX8OHcsh7CqBMztyXARmGQ3LWPtGjJi6DiJHq5C/qvi9P3OqgswKSDftbu8+IoI/QDTAm2fFnQ9SZSQ==", + "version": "6.5.1", + "resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.5.1.tgz", + "integrity": "sha512-xvJINNLbTeWQjrl6X+7eQCrIy/YPv5XCpKW6kB5mKvtnGILoLDcySuwomfdzt0BMdLNVnuRNTuzKNHj0bva1Cg==", "dev": true, "requires": { "bn.js": "^4.4.0", @@ -4450,9 +4741,9 @@ } }, "emoji-regex": { - "version": "6.1.1", - "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-6.1.1.tgz", - "integrity": "sha1-xs0OwbBkLio8Z6ETfvxeeW2k+I4=", + "version": "7.0.3", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-7.0.3.tgz", + "integrity": "sha512-CwBLREIQ7LvYFB0WyRvwhq5N5qPhc6PMjD6bYggFlI5YyDgl+0vxq5VHbMOFqLg7hfWzmu8T5Z1QofhmTIhItA==", "dev": true }, "emojis-list": { @@ -4526,6 +4817,12 @@ "yeast": "0.1.2" }, "dependencies": { + "component-emitter": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/component-emitter/-/component-emitter-1.2.1.tgz", + "integrity": "sha1-E3kY1teCg/ffemt8WmPhQOaUJeY=", + "dev": true + }, "debug": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz", @@ -4603,17 +4900,21 @@ } }, "es-abstract": { - "version": "1.13.0", - "resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.13.0.tgz", - "integrity": "sha512-vDZfg/ykNxQVwup/8E1BZhVzFfBxs9NqMzGcvIJrqg5k2/5Za2bWo40dK2J1pgLngZ7c+Shh8lwYtLGyrwPutg==", + "version": "1.14.2", + "resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.14.2.tgz", + "integrity": "sha512-DgoQmbpFNOofkjJtKwr87Ma5EW4Dc8fWhD0R+ndq7Oc456ivUfGOOP6oAZTTKl5/CcNMP+EN+e3/iUzgE0veZg==", "dev": true, "requires": { "es-to-primitive": "^1.2.0", "function-bind": "^1.1.1", "has": "^1.0.3", + "has-symbols": "^1.0.0", "is-callable": "^1.1.4", "is-regex": "^1.0.4", - "object-keys": "^1.0.12" + "object-inspect": "^1.6.0", + "object-keys": "^1.1.1", + "string.prototype.trimleft": "^2.0.0", + "string.prototype.trimright": "^2.0.0" } }, "es-to-primitive": { @@ -4628,9 +4929,9 @@ } }, "es5-ext": { - "version": "0.10.49", - "resolved": "https://registry.npmjs.org/es5-ext/-/es5-ext-0.10.49.tgz", - "integrity": "sha512-3NMEhi57E31qdzmYp2jwRArIUsj1HI/RxbQ4bgnSB+AIKIxsAmTiK83bYMifIcpWvEc3P1X30DhUKOqEtF/kvg==", + "version": "0.10.51", + "resolved": "https://registry.npmjs.org/es5-ext/-/es5-ext-0.10.51.tgz", + "integrity": "sha512-oRpWzM2WcLHVKpnrcyB7OW8j/s67Ba04JCm0WnNv3RiABSvs7mrQlutB8DBv793gKcp0XENR8Il8WxGTlZ73gQ==", "dev": true, "requires": { "es6-iterator": "~2.0.3", @@ -4639,9 +4940,9 @@ } }, "es5-shim": { - "version": "4.5.12", - "resolved": "https://registry.npmjs.org/es5-shim/-/es5-shim-4.5.12.tgz", - "integrity": "sha512-MjoCAHE6P2Dirme70Cxd9i2Ng8rhXiaVSsxDWdSwimfLERJL/ypR2ed2rTYkeeYrMk8gq281dzKLiGcdrmc8qg==", + "version": "4.5.13", + "resolved": "https://registry.npmjs.org/es5-shim/-/es5-shim-4.5.13.tgz", + "integrity": "sha512-xi6hh6gsvDE0MaW4Vp1lgNEBpVcCXRWfPXj5egDvtgLz4L9MEvNwYEMdJH+JJinWkwa8c3c3o5HduV7dB/e1Hw==", "dev": true }, "es6-iterator": { @@ -4670,9 +4971,9 @@ } }, "es6-promise": { - "version": "4.2.6", - "resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-4.2.6.tgz", - "integrity": "sha512-aRVgGdnmW2OiySVPUC9e6m+plolMAJKjZnQlCwNSuK5yQ0JN61DZSO1X1Ufd1foqWRAlig0rhduTCHe7sVtK5Q==", + "version": "4.2.8", + "resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-4.2.8.tgz", + "integrity": "sha512-HJDGx5daxeIvxdBxvG2cb9g4tEvwIk3i8+nhX0yGrYmZUzbkdg8QbDevheDB8gd0//uPj4c1EQua8Q+MViT0/w==", "dev": true }, "es6-promisify": { @@ -4695,27 +4996,39 @@ "es6-iterator": "~2.0.1", "es6-symbol": "3.1.1", "event-emitter": "~0.3.5" + }, + "dependencies": { + "es6-symbol": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/es6-symbol/-/es6-symbol-3.1.1.tgz", + "integrity": "sha1-vwDvT9q2uhtG7Le2KbTH7VcVzHc=", + "dev": true, + "requires": { + "d": "1", + "es5-ext": "~0.10.14" + } + } } }, "es6-symbol": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/es6-symbol/-/es6-symbol-3.1.1.tgz", - "integrity": "sha1-vwDvT9q2uhtG7Le2KbTH7VcVzHc=", + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/es6-symbol/-/es6-symbol-3.1.2.tgz", + "integrity": "sha512-/ZypxQsArlv+KHpGvng52/Iz8by3EQPxhmbuz8yFG89N/caTFBSbcXONDw0aMjy827gQg26XAjP4uXFvnfINmQ==", "dev": true, "requires": { - "d": "1", - "es5-ext": "~0.10.14" + "d": "^1.0.1", + "es5-ext": "^0.10.51" } }, "es6-weak-map": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/es6-weak-map/-/es6-weak-map-2.0.2.tgz", - "integrity": "sha1-XjqzIlH/0VOKH45f+hNXdy+S2W8=", + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/es6-weak-map/-/es6-weak-map-2.0.3.tgz", + "integrity": "sha512-p5um32HOTO1kP+w7PRnB+5lQ43Z6muuMuIMffvDN8ZB4GcnjLBV6zGStpbASIMk4DCAvEaamhe2zhyCb/QXXsA==", "dev": true, "requires": { "d": "1", - "es5-ext": "^0.10.14", - "es6-iterator": "^2.0.1", + "es5-ext": "^0.10.46", + "es6-iterator": "^2.0.3", "es6-symbol": "^3.1.1" } }, @@ -4832,6 +5145,17 @@ "integrity": "sha1-7QMXwyIGT3lGbAKWa922Bas32Zg=", "dev": true }, + "cross-spawn": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-5.1.0.tgz", + "integrity": "sha1-6L0O/uWPz/b4+UUQoKVUu/ojVEk=", + "dev": true, + "requires": { + "lru-cache": "^4.0.1", + "shebang-command": "^1.2.0", + "which": "^1.2.9" + } + }, "debug": { "version": "3.2.6", "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.6.tgz", @@ -4895,9 +5219,9 @@ } }, "eslint-module-utils": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/eslint-module-utils/-/eslint-module-utils-2.3.0.tgz", - "integrity": "sha512-lmDJgeOOjk8hObTysjqH7wyMi+nsHwwvfBykwfhjR1LNdd7C2uFJBvx4OpWYpXOw4df1yE1cDEVd1yLHitk34w==", + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/eslint-module-utils/-/eslint-module-utils-2.4.1.tgz", + "integrity": "sha512-H6DOj+ejw7Tesdgbfs4jeS4YMFrT8uI8xwd1gtQqXssaR0EQ26L+2O/w6wkYFy2MymON0fTwHmXBvvfLNZVZEw==", "dev": true, "requires": { "debug": "^2.6.8", @@ -4974,21 +5298,22 @@ } }, "eslint-plugin-import": { - "version": "2.16.0", - "resolved": "https://registry.npmjs.org/eslint-plugin-import/-/eslint-plugin-import-2.16.0.tgz", - "integrity": "sha512-z6oqWlf1x5GkHIFgrSvtmudnqM6Q60KM4KvpWi5ubonMjycLjndvd5+8VAZIsTlHC03djdgJuyKG6XO577px6A==", + "version": "2.18.2", + "resolved": "https://registry.npmjs.org/eslint-plugin-import/-/eslint-plugin-import-2.18.2.tgz", + "integrity": "sha512-5ohpsHAiUBRNaBWAF08izwUGlbrJoJJ+W9/TBwsGoR1MnlgfwMIKrFeSjWbt6moabiXW9xNvtFz+97KHRfI4HQ==", "dev": true, "requires": { + "array-includes": "^3.0.3", "contains-path": "^0.1.0", "debug": "^2.6.9", "doctrine": "1.5.0", "eslint-import-resolver-node": "^0.3.2", - "eslint-module-utils": "^2.3.0", + "eslint-module-utils": "^2.4.0", "has": "^1.0.3", - "lodash": "^4.17.11", "minimatch": "^3.0.4", + "object.values": "^1.1.0", "read-pkg-up": "^2.0.0", - "resolve": "^1.9.0" + "resolve": "^1.11.0" }, "dependencies": { "debug": { @@ -5128,6 +5453,10 @@ } } }, + "eslint-plugin-prebid": { + "version": "file:plugins/eslint", + "dev": true + }, "eslint-plugin-promise": { "version": "3.8.0", "resolved": "https://registry.npmjs.org/eslint-plugin-promise/-/eslint-plugin-promise-3.8.0.tgz", @@ -5151,9 +5480,9 @@ } }, "eslint-visitor-keys": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-1.0.0.tgz", - "integrity": "sha512-qzm/XxIbxm/FHyH341ZrbnMUpe+5Bocte9xkmFMzPMjRaZMcXww+MpBptFvtU+79L362nqiLhekCxCxDPaUMBQ==", + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-1.1.0.tgz", + "integrity": "sha512-8y9YjtM1JBJU/A9Kc+SbaOV4y29sSWckBwMHa+FGtVj5gN/sbnKDf6xJUl+8g7FAij9LVaP8C24DUiH/f/2Z9A==", "dev": true }, "espree": { @@ -5191,21 +5520,15 @@ } }, "estraverse": { - "version": "4.2.0", - "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-4.2.0.tgz", - "integrity": "sha1-De4/7TH81GlhjOc0IJn8GvoL2xM=", - "dev": true - }, - "estree-walker": { - "version": "0.3.1", - "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-0.3.1.tgz", - "integrity": "sha1-5rGlHPcpJSTnI3wxLl/mZgwc4ao=", + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-4.3.0.tgz", + "integrity": "sha512-39nnKffWz8xN1BU/2c79n9nB9HDzo0niYUqx6xyqUnyoAnQyyWpOTdZEeiCch8BBu515t4wp9ZmgVfVhn9EBpw==", "dev": true }, "esutils": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.2.tgz", - "integrity": "sha1-Cr9PHKpbyx96nYrMbepPqqBLrJs=", + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.3.tgz", + "integrity": "sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==", "dev": true }, "etag": { @@ -5248,9 +5571,9 @@ } }, "eventemitter3": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/eventemitter3/-/eventemitter3-3.1.0.tgz", - "integrity": "sha512-ivIvhpq/Y0uSjcHDcOIccjmYjGLcP09MFGE7ysAwkAvkXfpZlC985pH2/ui64DKazbTW/4kN3yqozUxlXzI6cA==", + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/eventemitter3/-/eventemitter3-3.1.2.tgz", + "integrity": "sha512-tvtQIeLVHjDkJYnzf2dgVMxfuSGJeM/7UCG17TT4EumTfNtF+0nebF/4zWOIkCreAbtNqhGEboB6BWrwqNaw4Q==", "dev": true }, "events": { @@ -5270,18 +5593,29 @@ } }, "execa": { - "version": "0.7.0", - "resolved": "https://registry.npmjs.org/execa/-/execa-0.7.0.tgz", - "integrity": "sha1-lEvs00zEHuMqY6n68nrVpl/Fl3c=", + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/execa/-/execa-1.0.0.tgz", + "integrity": "sha512-adbxcyWV46qiHyvSp50TKt05tB4tK3HcmF7/nxfAdhnox83seTDbwnaqKO4sXRy7roHAIFqJP/Rw/AuEbX61LA==", "dev": true, "requires": { - "cross-spawn": "^5.0.1", - "get-stream": "^3.0.0", + "cross-spawn": "^6.0.0", + "get-stream": "^4.0.0", "is-stream": "^1.1.0", "npm-run-path": "^2.0.0", "p-finally": "^1.0.0", "signal-exit": "^3.0.0", "strip-eof": "^1.0.0" + }, + "dependencies": { + "get-stream": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-4.1.0.tgz", + "integrity": "sha512-GMat4EJ5161kIy2HevLlr4luNjBgvmj413KaQA7jt4V8B4RDsfpHk7WQ9GVqfYyyx8OS/L66Kox+rJRNklLK7w==", + "dev": true, + "requires": { + "pump": "^3.0.0" + } + } } }, "expand-braces": { @@ -5401,29 +5735,150 @@ "homedir-polyfill": "^1.0.1" } }, - "extend": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/extend/-/extend-3.0.2.tgz", - "integrity": "sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g==", - "dev": true - }, - "extend-shallow": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-3.0.2.tgz", - "integrity": "sha1-Jqcarwc7OfshJxcnRhMcJwQCjbg=", + "express": { + "version": "4.17.1", + "resolved": "https://registry.npmjs.org/express/-/express-4.17.1.tgz", + "integrity": "sha512-mHJ9O79RqluphRrcw2X/GTh3k9tVv8YcoyY4Kkh4WDMUYKRZUq0h1o0w2rrrxBqM7VoeUVqgb27xlEMXTnYt4g==", "dev": true, "requires": { - "assign-symbols": "^1.0.0", - "is-extendable": "^1.0.1" - }, - "dependencies": { - "is-extendable": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-1.0.1.tgz", - "integrity": "sha512-arnXMxT1hhoKo9k1LZdmlNyJdDDfy2v0fXjFlmok4+i8ul/6WlbVge9bhM74OpNPQPMGUToDtz+KXa1PneJxOA==", + "accepts": "~1.3.7", + "array-flatten": "1.1.1", + "body-parser": "1.19.0", + "content-disposition": "0.5.3", + "content-type": "~1.0.4", + "cookie": "0.4.0", + "cookie-signature": "1.0.6", + "debug": "2.6.9", + "depd": "~1.1.2", + "encodeurl": "~1.0.2", + "escape-html": "~1.0.3", + "etag": "~1.8.1", + "finalhandler": "~1.1.2", + "fresh": "0.5.2", + "merge-descriptors": "1.0.1", + "methods": "~1.1.2", + "on-finished": "~2.3.0", + "parseurl": "~1.3.3", + "path-to-regexp": "0.1.7", + "proxy-addr": "~2.0.5", + "qs": "6.7.0", + "range-parser": "~1.2.1", + "safe-buffer": "5.1.2", + "send": "0.17.1", + "serve-static": "1.14.1", + "setprototypeof": "1.1.1", + "statuses": "~1.5.0", + "type-is": "~1.6.18", + "utils-merge": "1.0.1", + "vary": "~1.1.2" + }, + "dependencies": { + "cookie": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.4.0.tgz", + "integrity": "sha512-+Hp8fLp57wnUSt0tY0tHEXh4voZRDnoIrZPqlo3DPiI4y9lwg/jqx+1Om94/W6ZaPDOUbnjOt/99w66zk+l1Xg==", + "dev": true + }, + "debug": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", "dev": true, "requires": { - "is-plain-object": "^2.0.4" + "ms": "2.0.0" + } + }, + "http-errors": { + "version": "1.7.3", + "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.7.3.tgz", + "integrity": "sha512-ZTTX0MWrsQ2ZAhA1cejAwDLycFsd7I7nVtnkT3Ol0aqodaKW+0CTZDQ1uBv5whptCnc8e8HeRRJxRs0kmm/Qfw==", + "dev": true, + "requires": { + "depd": "~1.1.2", + "inherits": "2.0.4", + "setprototypeof": "1.1.1", + "statuses": ">= 1.5.0 < 2", + "toidentifier": "1.0.0" + } + }, + "ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", + "dev": true + }, + "path-to-regexp": { + "version": "0.1.7", + "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.7.tgz", + "integrity": "sha1-32BBeABfUi8V60SQ5yR6G/qmf4w=", + "dev": true + }, + "qs": { + "version": "6.7.0", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.7.0.tgz", + "integrity": "sha512-VCdBRNFTX1fyE7Nb6FYoURo/SPe62QCaAyzJvUjwRaIsc+NePBEniHlvxFmmX56+HZphIGtV0XeCirBtpDrTyQ==", + "dev": true + }, + "send": { + "version": "0.17.1", + "resolved": "https://registry.npmjs.org/send/-/send-0.17.1.tgz", + "integrity": "sha512-BsVKsiGcQMFwT8UxypobUKyv7irCNRHk1T0G680vk88yf6LBByGcZJOTJCrTP2xVN6yI+XjPJcNuE3V4fT9sAg==", + "dev": true, + "requires": { + "debug": "2.6.9", + "depd": "~1.1.2", + "destroy": "~1.0.4", + "encodeurl": "~1.0.2", + "escape-html": "~1.0.3", + "etag": "~1.8.1", + "fresh": "0.5.2", + "http-errors": "~1.7.2", + "mime": "1.6.0", + "ms": "2.1.1", + "on-finished": "~2.3.0", + "range-parser": "~1.2.1", + "statuses": "~1.5.0" + }, + "dependencies": { + "ms": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz", + "integrity": "sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg==", + "dev": true + } + } + }, + "setprototypeof": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.1.1.tgz", + "integrity": "sha512-JvdAWfbXeIGaZ9cILp38HntZSFSo3mWg6xGcJJsd+d4aRMOqauag1C63dJfDw7OaMYwEbHMOxEZ1lqVRYP2OAw==", + "dev": true + } + } + }, + "extend": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/extend/-/extend-3.0.2.tgz", + "integrity": "sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g==", + "dev": true + }, + "extend-shallow": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-3.0.2.tgz", + "integrity": "sha1-Jqcarwc7OfshJxcnRhMcJwQCjbg=", + "dev": true, + "requires": { + "assign-symbols": "^1.0.0", + "is-extendable": "^1.0.1" + }, + "dependencies": { + "is-extendable": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-1.0.1.tgz", + "integrity": "sha512-arnXMxT1hhoKo9k1LZdmlNyJdDDfy2v0fXjFlmok4+i8ul/6WlbVge9bhM74OpNPQPMGUToDtz+KXa1PneJxOA==", + "dev": true, + "requires": { + "is-plain-object": "^2.0.4" } } } @@ -5555,6 +6010,15 @@ "websocket-driver": ">=0.5.1" } }, + "fibers": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/fibers/-/fibers-3.1.1.tgz", + "integrity": "sha512-dl3Ukt08rHVQfY8xGD0ODwyjwrRALtaghuqGH2jByYX1wpY+nAnRQjJ6Dbqq0DnVgNVQ9yibObzbF4IlPyiwPw==", + "dev": true, + "requires": { + "detect-libc": "^1.0.3" + } + }, "figures": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/figures/-/figures-2.0.0.tgz", @@ -5574,12 +6038,6 @@ "object-assign": "^4.0.1" } }, - "file-uri-to-path": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz", - "integrity": "sha512-0Zt+s3L7Vf1biwWZ29aARiVYLx7iMGnEUl9x33fbB/j3jR81u/O2LbqK+Bm1CDSNDKVtJ/YjwY7TUd5SkeLQLw==", - "dev": true - }, "filename-regex": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/filename-regex/-/filename-regex-2.0.1.tgz", @@ -5596,6 +6054,12 @@ "minimatch": "^3.0.3" } }, + "filesize": { + "version": "3.6.1", + "resolved": "https://registry.npmjs.org/filesize/-/filesize-3.6.1.tgz", + "integrity": "sha512-7KjR1vv6qnicaPMi1iiTcI85CyYwRO/PSFCu6SvqL8jN2Wjt/NIYQTFtFs7fSDCYOstUkEWIQGFUg5YZQfjlcg==", + "dev": true + }, "fill-range": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-4.0.0.tgz", @@ -5620,17 +6084,17 @@ } }, "finalhandler": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.1.0.tgz", - "integrity": "sha1-zgtoVbRYU+eRsvzGgARtiCU91/U=", + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.1.2.tgz", + "integrity": "sha512-aAWcW57uxVNrQZqFXjITpW3sIUQmHGG3qSb9mUah9MgMC4NeWhNOlNjXEYq3HjRAvL6arUviZGGJsBg6z0zsWA==", "dev": true, "requires": { "debug": "2.6.9", - "encodeurl": "~1.0.1", + "encodeurl": "~1.0.2", "escape-html": "~1.0.3", "on-finished": "~2.3.0", - "parseurl": "~1.3.2", - "statuses": "~1.3.1", + "parseurl": "~1.3.3", + "statuses": "~1.5.0", "unpipe": "~1.0.0" }, "dependencies": { @@ -5684,9 +6148,9 @@ } }, "fined": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/fined/-/fined-1.1.1.tgz", - "integrity": "sha512-jQp949ZmEbiYHk3gkbdtpJ0G1+kgtLQBNdP5edFP7Fh+WAYceLQz6yO1SBj72Xkg8GVyTB3bBzAYrHJVh5Xd5g==", + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/fined/-/fined-1.2.0.tgz", + "integrity": "sha512-ZYDqPLGxDkDhDZBjZBb+oD1+j0rA4E0pXY50eplAAOPg2N/gUBSSk5IM1/QhPfyVo19lJ+CvXpqfvk+b2p/8Ng==", "dev": true, "requires": { "expand-tilde": "^2.0.2", @@ -5702,6 +6166,23 @@ "integrity": "sha512-lNaHNVymajmk0OJMBn8fVUAU1BtDeKIqKoVhk4xAALB57aALg6b4W0MfJ/cUE0g9YBXy5XhSlPIpYIJ7HaY/3Q==", "dev": true }, + "flat": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/flat/-/flat-4.1.0.tgz", + "integrity": "sha512-Px/TiLIznH7gEDlPXcUD4KnBusa6kR6ayRUVcnEAbreRIuhkqow/mun59BuRXwoYk7ZQOLW1ZM05ilIvK38hFw==", + "dev": true, + "requires": { + "is-buffer": "~2.0.3" + }, + "dependencies": { + "is-buffer": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-2.0.3.tgz", + "integrity": "sha512-U15Q7MXTuZlrbymiz95PJpZxu8IlipAp4dtS3wOdgPXx3mqBnslrWU14kxfHB+Py/+2PVKSr37dMAgM2A4uArw==", + "dev": true + } + } + }, "flat-cache": { "version": "1.3.4", "resolved": "https://registry.npmjs.org/flat-cache/-/flat-cache-1.3.4.tgz", @@ -5726,9 +6207,9 @@ } }, "flatted": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/flatted/-/flatted-2.0.0.tgz", - "integrity": "sha512-R+H8IZclI8AAkSBRQJLVOsxwAoHd6WC40b4QTNWIjzAa6BXOBfQcM587MXDTVPeYaopFNWHUFLx7eNmHDSxMWg==", + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/flatted/-/flatted-2.0.1.tgz", + "integrity": "sha512-a1hQMktqW9Nmqr5aktAux3JMNqaucxGcjtjWnZLHX7yyPCmlSV3M54nGYbqT8K+0GhF3NBgmJCc3ma+WOgX8Jg==", "dev": true }, "flush-write-stream": { @@ -5742,12 +6223,12 @@ } }, "follow-redirects": { - "version": "1.7.0", - "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.7.0.tgz", - "integrity": "sha512-m/pZQy4Gj287eNy94nivy5wchN3Kp+Q5WgUPNy5lJSZ3sgkVKSYV/ZChMAQVIgx1SqfZ2zBZtPA2YlXIWxxJOQ==", + "version": "1.9.0", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.9.0.tgz", + "integrity": "sha512-CRcPzsSIbXyVDl0QI01muNDu69S8trU4jArW9LpOt2WtC6LyUJetcIrmfHsRBx7/Jb6GHJUiuqyYxPooFfNt6A==", "dev": true, "requires": { - "debug": "^3.2.6" + "debug": "^3.0.0" }, "dependencies": { "debug": { @@ -5805,14 +6286,11 @@ "mime-types": "^2.1.12" } }, - "formatio": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/formatio/-/formatio-1.1.1.tgz", - "integrity": "sha1-XtPM1jZVEJc4NGXZlhmRAOhhYek=", - "dev": true, - "requires": { - "samsam": "~1.1" - } + "forwarded": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.1.2.tgz", + "integrity": "sha1-mMI9qxF1ZXuMBXPozszZGw/xjIQ=", + "dev": true }, "fragment-cache": { "version": "0.2.1", @@ -5854,6 +6332,12 @@ "null-check": "^1.0.0" } }, + "fs-constants": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs-constants/-/fs-constants-1.0.0.tgz", + "integrity": "sha512-y6OAwoSIf7FyjMIv94u+b5rdheZEjzR63GTyZJm5qh4Bi+2YgwLCcI/fPFZkL5PSixOt6ZNKm+w+Hfp/Bciwow==", + "dev": true + }, "fs-extra": { "version": "0.6.4", "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-0.6.4.tgz", @@ -5910,14 +6394,14 @@ "dev": true }, "fsevents": { - "version": "1.2.7", - "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-1.2.7.tgz", - "integrity": "sha512-Pxm6sI2MeBD7RdD12RYsqaP0nMiwx8eZBXCa6z2L+mRHm2DYrOYwihmhjpkdjUHwQhslWQjRpEgNq4XvBmaAuw==", + "version": "1.2.9", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-1.2.9.tgz", + "integrity": "sha512-oeyj2H3EjjonWcFjD5NvZNE9Rqe4UW+nQBU2HNeKw0koVLEFIhtyETyAakeAM3de7Z/SW5kcA+fZUait9EApnw==", "dev": true, "optional": true, "requires": { - "nan": "^2.9.2", - "node-pre-gyp": "^0.10.0" + "nan": "^2.12.1", + "node-pre-gyp": "^0.12.0" }, "dependencies": { "abbrev": { @@ -5989,12 +6473,12 @@ "optional": true }, "debug": { - "version": "2.6.9", + "version": "4.1.1", "bundled": true, "dev": true, "optional": true, "requires": { - "ms": "2.0.0" + "ms": "^2.1.1" } }, "deep-extend": { @@ -6159,24 +6643,24 @@ } }, "ms": { - "version": "2.0.0", + "version": "2.1.1", "bundled": true, "dev": true, "optional": true }, "needle": { - "version": "2.2.4", + "version": "2.3.0", "bundled": true, "dev": true, "optional": true, "requires": { - "debug": "^2.1.2", + "debug": "^4.1.0", "iconv-lite": "^0.4.4", "sax": "^1.2.4" } }, "node-pre-gyp": { - "version": "0.10.3", + "version": "0.12.0", "bundled": true, "dev": true, "optional": true, @@ -6204,13 +6688,13 @@ } }, "npm-bundled": { - "version": "1.0.5", + "version": "1.0.6", "bundled": true, "dev": true, "optional": true }, "npm-packlist": { - "version": "1.2.0", + "version": "1.4.1", "bundled": true, "dev": true, "optional": true, @@ -6346,7 +6830,7 @@ "optional": true }, "semver": { - "version": "5.6.0", + "version": "5.7.0", "bundled": true, "dev": true, "optional": true @@ -6438,46 +6922,10 @@ } } }, - "ftp": { - "version": "0.3.10", - "resolved": "https://registry.npmjs.org/ftp/-/ftp-0.3.10.tgz", - "integrity": "sha1-kZfYYa2BQvPmPVqDv+TFn3MwiF0=", - "dev": true, - "requires": { - "readable-stream": "1.1.x", - "xregexp": "2.0.0" - }, - "dependencies": { - "isarray": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", - "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=", - "dev": true - }, - "readable-stream": { - "version": "1.1.14", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.1.14.tgz", - "integrity": "sha1-fPTFTvZI44EwhMY23SB54WbAgdk=", - "dev": true, - "requires": { - "core-util-is": "~1.0.0", - "inherits": "~2.0.1", - "isarray": "0.0.1", - "string_decoder": "~0.10.x" - } - }, - "string_decoder": { - "version": "0.10.31", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", - "integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=", - "dev": true - } - } - }, "fun-hooks": { - "version": "0.8.1", - "resolved": "https://registry.npmjs.org/fun-hooks/-/fun-hooks-0.8.1.tgz", - "integrity": "sha512-qhyQAO6vhmzzwOJ2SvqeCvL2dqBCw3NeuIpNOfMPv2bucFYXLur9UbXTiUAbm7EE2TrdLgIKJZkO0DfwEY+KVQ==" + "version": "0.9.6", + "resolved": "https://registry.npmjs.org/fun-hooks/-/fun-hooks-0.9.6.tgz", + "integrity": "sha512-0+CUJWTcx/vtm3qfvb9IfILItgDAq28lEsdEzu8622ttSVfFStDQTaSpU/sn2NyFXo5dN2qwwPLcqB/CvDkacg==" }, "function-bind": { "version": "1.1.1", @@ -6491,10 +6939,19 @@ "integrity": "sha1-GwqzvVU7Kg1jmdKcDj6gslIHgyc=", "dev": true }, + "gaze": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/gaze/-/gaze-1.1.3.tgz", + "integrity": "sha512-BRdNm8hbWzFzWHERTrejLqwHDfS4GibPoq5wjTPIoJHoBtKGPg3xAFfxmM+9ztbXelxcf2hwQcaz1PtmFeue8g==", + "dev": true, + "requires": { + "globule": "^1.0.0" + } + }, "get-caller-file": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-1.0.3.tgz", - "integrity": "sha512-3t6rVToeoZfYSGd8YoLFR2DJkiQrIiUrGcjvFX2mDw3bn6k2OtwHN0TNCLbBO+w8qTvimhDkv+LSscbJY1vE6w==", + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz", + "integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==", "dev": true }, "get-func-name": { @@ -6521,33 +6978,6 @@ "integrity": "sha1-jpQ9E1jcN1VQVOy+LtsFqhdO3hQ=", "dev": true }, - "get-uri": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/get-uri/-/get-uri-2.0.3.tgz", - "integrity": "sha512-x5j6Ks7FOgLD/GlvjKwgu7wdmMR55iuRHhn8hj/+gA+eSbxQvZ+AEomq+3MgVEZj1vpi738QahGbCCSIDtXtkw==", - "dev": true, - "requires": { - "data-uri-to-buffer": "2", - "debug": "4", - "extend": "~3.0.2", - "file-uri-to-path": "1", - "ftp": "~0.3.10", - "readable-stream": "3" - }, - "dependencies": { - "readable-stream": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.2.0.tgz", - "integrity": "sha512-RV20kLjdmpZuTF1INEb9IA3L68Nmi+Ri7ppZqo78wj//Pn62fCoJyV9zalccNzDD/OuJpMG4f+pfMl8+L6QdGw==", - "dev": true, - "requires": { - "inherits": "^2.0.3", - "string_decoder": "^1.1.1", - "util-deprecate": "^1.0.1" - } - } - } - }, "get-value": { "version": "2.0.6", "resolved": "https://registry.npmjs.org/get-value/-/get-value-2.0.6.tgz", @@ -6590,12 +7020,20 @@ "dev": true, "requires": { "emoji-regex": ">=6.0.0 <=6.1.1" + }, + "dependencies": { + "emoji-regex": { + "version": "6.1.1", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-6.1.1.tgz", + "integrity": "sha1-xs0OwbBkLio8Z6ETfvxeeW2k+I4=", + "dev": true + } } }, "glob": { - "version": "7.1.3", - "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.3.tgz", - "integrity": "sha512-vcfuiIxogLV4DlGBHIUOwI0IbrJ8HWPc4MU7HzviGeNho/UJDfi6B5p3sHeWIQ0KGIU0Jpxi5ZHxemQfLkkAwQ==", + "version": "7.1.4", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.4.tgz", + "integrity": "sha512-hkLPepehmnKk41pUGm3sYxoFs/umurYfYJCerbXEyFIWcAzvpipAgVkBqqT9RBKMGjnq6kMuyYwha6csxbiM1A==", "dev": true, "requires": { "fs.realpath": "^1.0.0", @@ -6720,17 +7158,28 @@ } }, "globals": { - "version": "11.11.0", - "resolved": "https://registry.npmjs.org/globals/-/globals-11.11.0.tgz", - "integrity": "sha512-WHq43gS+6ufNOEqlrDBxVEbb8ntfXrfAUU2ZOpCxrBdGKW3gyv8mCxAfIBD0DroPKGrJ2eSsXsLtY9MPntsyTw==", + "version": "11.12.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-11.12.0.tgz", + "integrity": "sha512-WOBp/EEGUiIsJSp7wcv/y6MO+lV9UoncWqxuFfm8eBwzWNgyfBd6Gz+IeKQ9jCmyhoH99g15M3T+QaVHFjizVA==", "dev": true }, "globals-docs": { - "version": "2.4.0", - "resolved": "https://registry.npmjs.org/globals-docs/-/globals-docs-2.4.0.tgz", - "integrity": "sha512-B69mWcqCmT3jNYmSxRxxOXWfzu3Go8NQXPfl2o0qPd1EEFhwW0dFUg9ztTu915zPQzqwIhWAlw6hmfIcCK4kkQ==", + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/globals-docs/-/globals-docs-2.4.1.tgz", + "integrity": "sha512-qpPnUKkWnz8NESjrCvnlGklsgiQzlq+rcCxoG5uNQ+dNA7cFMCmn231slLAwS2N/PlkzZ3COL8CcS10jXmLHqg==", "dev": true }, + "globule": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/globule/-/globule-1.2.1.tgz", + "integrity": "sha512-g7QtgWF4uYSL5/dn71WxubOrS7JVGCnFPEnoeChJmBnyR9Mw8nGoEwOgJL/RC2Te0WhbsEUCejfH8SZNJ+adYQ==", + "dev": true, + "requires": { + "glob": "~7.1.1", + "lodash": "~4.17.10", + "minimatch": "~3.0.2" + } + }, "glogg": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/glogg/-/glogg-1.0.2.tgz", @@ -6774,9 +7223,15 @@ } }, "graceful-fs": { - "version": "4.1.15", - "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.15.tgz", - "integrity": "sha512-6uHUhOPEBgQ24HM+r6b/QwWfZq+yiFcipKFrOFiBEnWdy5sdzYoi+pJeQaPI5qOLRFqWmAXUPQNsielzdLoecA==", + "version": "4.2.2", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.2.tgz", + "integrity": "sha512-IItsdsea19BoLC7ELy13q1iJFNmd7ofZH5+X/pJr90/nRoPEX0DJo1dHDbgtYWOhJhcCgMDTOw84RZ72q6lB+Q==", + "dev": true + }, + "grapheme-splitter": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/grapheme-splitter/-/grapheme-splitter-1.0.4.tgz", + "integrity": "sha512-bzh50DW9kTPM00T8y4o8vQg89Di9oLJVLW/KaOGIXJWP/iqCN6WKYkbNOF04vFLJhwcpYUh9ydh/+5vpOqV4YQ==", "dev": true }, "growl": { @@ -6786,23 +7241,43 @@ "dev": true }, "gulp": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/gulp/-/gulp-4.0.0.tgz", - "integrity": "sha1-lXZsYB2t5Kd+0+eyttwDiBtZY2Y=", + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/gulp/-/gulp-4.0.2.tgz", + "integrity": "sha512-dvEs27SCZt2ibF29xYgmnwwCYZxdxhQ/+LFWlbAW8y7jt68L/65402Lz3+CKy0Ov4rOs+NERmDq7YlZaDqUIfA==", "dev": true, "requires": { - "glob-watcher": "^5.0.0", - "gulp-cli": "^2.0.0", - "undertaker": "^1.0.0", + "glob-watcher": "^5.0.3", + "gulp-cli": "^2.2.0", + "undertaker": "^1.2.1", "vinyl-fs": "^3.0.0" }, "dependencies": { + "ansi-colors": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/ansi-colors/-/ansi-colors-1.1.0.tgz", + "integrity": "sha512-SFKX67auSNoVR38N3L+nvsPjOE0bybKTYbkf5tRvushrAPQ9V75huw0ZxBkKVeRU9kqH3d6HA4xTckbwZ4ixmA==", + "dev": true, + "requires": { + "ansi-wrap": "^0.1.0" + } + }, "camelcase": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-3.0.0.tgz", "integrity": "sha1-MvxLn82vhF/N9+c7uXysImHwqwo=", "dev": true }, + "cliui": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/cliui/-/cliui-3.2.0.tgz", + "integrity": "sha1-EgYBU3qRbSmUD5NNo7SNWFo5IT0=", + "dev": true, + "requires": { + "string-width": "^1.0.1", + "strip-ansi": "^3.0.1", + "wrap-ansi": "^2.0.0" + } + }, "find-up": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/find-up/-/find-up-1.1.2.tgz", @@ -6813,10 +7288,16 @@ "pinkie-promise": "^2.0.0" } }, + "get-caller-file": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-1.0.3.tgz", + "integrity": "sha512-3t6rVToeoZfYSGd8YoLFR2DJkiQrIiUrGcjvFX2mDw3bn6k2OtwHN0TNCLbBO+w8qTvimhDkv+LSscbJY1vE6w==", + "dev": true + }, "gulp-cli": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/gulp-cli/-/gulp-cli-2.1.0.tgz", - "integrity": "sha512-txzgdFVlEPShBZus6JJyGyKJoBVDq6Do0ZQgIgx5RAsmhNVTDjymmOxpQvo3c20m66FldilS68ZXj2Q9w5dKbA==", + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/gulp-cli/-/gulp-cli-2.2.0.tgz", + "integrity": "sha512-rGs3bVYHdyJpLqR0TUBnlcZ1O5O++Zs4bA0ajm+zr3WFCfiSLjGwoCBqFs18wzN+ZxahT9DkOK5nDf26iDsWjA==", "dev": true, "requires": { "ansi-colors": "^1.0.1", @@ -6839,6 +7320,30 @@ "yargs": "^7.1.0" } }, + "invert-kv": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/invert-kv/-/invert-kv-1.0.0.tgz", + "integrity": "sha1-EEqOSqym09jNFXqO+L+rLXo//bY=", + "dev": true + }, + "is-fullwidth-code-point": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz", + "integrity": "sha1-754xOG8DGn8NZDr4L95QxFfvAMs=", + "dev": true, + "requires": { + "number-is-nan": "^1.0.0" + } + }, + "lcid": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/lcid/-/lcid-1.0.0.tgz", + "integrity": "sha1-MIrMr6C8SDo4Z7S28rlQYlHRuDU=", + "dev": true, + "requires": { + "invert-kv": "^1.0.0" + } + }, "load-json-file": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/load-json-file/-/load-json-file-1.1.0.tgz", @@ -6917,6 +7422,23 @@ "read-pkg": "^1.0.0" } }, + "require-main-filename": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/require-main-filename/-/require-main-filename-1.0.1.tgz", + "integrity": "sha1-l/cXtp1IeE9fUmpsWqj/3aBVpNE=", + "dev": true + }, + "string-width": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz", + "integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=", + "dev": true, + "requires": { + "code-point-at": "^1.0.0", + "is-fullwidth-code-point": "^1.0.0", + "strip-ansi": "^3.0.0" + } + }, "strip-bom": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-2.0.0.tgz", @@ -6932,6 +7454,12 @@ "integrity": "sha1-u6Y8qGGUiZT/MHc2CJ47lgJsKk8=", "dev": true }, + "y18n": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/y18n/-/y18n-3.2.1.tgz", + "integrity": "sha1-bRX7qITAhnnA136I53WegR4H+kE=", + "dev": true + }, "yargs": { "version": "7.1.0", "resolved": "https://registry.npmjs.org/yargs/-/yargs-7.1.0.tgz", @@ -7180,15 +7708,16 @@ } }, "gulp-footer": { - "version": "github:prebid/gulp-footer#ff2b46e6376c7f04900357ff9f7b30f219fe5f8a", - "from": "github:prebid/gulp-footer#master", + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/gulp-footer/-/gulp-footer-2.0.2.tgz", + "integrity": "sha512-HsG5VOgKHFRqZXnHGI6oGhPDg70p9pobM+dYOnjBZVLMQUHzLG6bfaPNRJ7XG707E+vWO3TfN0CND9UrYhk94g==", "dev": true, "requires": { - "event-stream": "3.3.4", "lodash._reescape": "^3.0.0", "lodash._reevaluate": "^3.0.0", "lodash._reinterpolate": "^3.0.0", - "lodash.template": "^3.6.2" + "lodash.template": "^3.6.2", + "map-stream": "0.0.7" }, "dependencies": { "lodash._reinterpolate": { @@ -7264,22 +7793,22 @@ "dev": true }, "lodash.template": { - "version": "4.4.0", - "resolved": "https://registry.npmjs.org/lodash.template/-/lodash.template-4.4.0.tgz", - "integrity": "sha1-5zoDhcg1VZF0bgILmWecaQ5o+6A=", + "version": "4.5.0", + "resolved": "https://registry.npmjs.org/lodash.template/-/lodash.template-4.5.0.tgz", + "integrity": "sha512-84vYFxIkmidUiFxidA/KjjH9pAycqW+h980j7Fuz5qxRtO9pgB7MDFTdys1N7A5mcucRiDyEq4fusljItR1T/A==", "dev": true, "requires": { - "lodash._reinterpolate": "~3.0.0", + "lodash._reinterpolate": "^3.0.0", "lodash.templatesettings": "^4.0.0" } }, "lodash.templatesettings": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/lodash.templatesettings/-/lodash.templatesettings-4.1.0.tgz", - "integrity": "sha1-K01OlbpEDZFf8IvImeRVNmZxMxY=", + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/lodash.templatesettings/-/lodash.templatesettings-4.2.0.tgz", + "integrity": "sha512-stgLz+i3Aa9mZgnjr/O+v9ruKZsPsndy7qPZOchbqk2cnTU1ZaldKK+v7m54WoKIyxiuMZTKT2H81F8BeAc3ZQ==", "dev": true, "requires": { - "lodash._reinterpolate": "~3.0.0" + "lodash._reinterpolate": "^3.0.0" } } } @@ -7341,24 +7870,12 @@ } }, "gulp-match": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/gulp-match/-/gulp-match-1.0.3.tgz", - "integrity": "sha1-kcfA1/Kb7NZgbVfYCn+Hdqh6uo4=", - "dev": true, - "requires": { - "minimatch": "^3.0.3" - } - }, - "gulp-optimize-js": { "version": "1.1.0", - "resolved": "https://registry.npmjs.org/gulp-optimize-js/-/gulp-optimize-js-1.1.0.tgz", - "integrity": "sha1-X9FcaLNvbh5zh3hPhXhDX3VpYkU=", + "resolved": "https://registry.npmjs.org/gulp-match/-/gulp-match-1.1.0.tgz", + "integrity": "sha512-DlyVxa1Gj24DitY2OjEsS+X6tDpretuxD6wTfhXE/Rw2hweqc1f6D/XtsJmoiCwLWfXgR87W9ozEityPCVzGtQ==", "dev": true, "requires": { - "gulp-util": "^3.0.7", - "lodash": "^4.16.2", - "optimize-js": "^1.0.0", - "through2": "^2.0.1" + "minimatch": "^3.0.3" } }, "gulp-replace": { @@ -7585,10 +8102,20 @@ "glogg": "^1.0.0" } }, + "gzip-size": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/gzip-size/-/gzip-size-5.1.1.tgz", + "integrity": "sha512-FNHi6mmoHvs1mxZAds4PpdCS6QG8B4C1krxJsMutgxl5t3+GlRTzzI3NEkifXx2pVsOvJdOGSmIgDhQ55FwdPA==", + "dev": true, + "requires": { + "duplexer": "^0.1.1", + "pify": "^4.0.1" + } + }, "handlebars": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/handlebars/-/handlebars-4.1.1.tgz", - "integrity": "sha512-3Zhi6C0euYZL5sM0Zcy7lInLXKQ+YLcF/olbN010mzGQ4XVm50JeyBnMqofHh696GrciGruC7kCcApPDJvVgwA==", + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/handlebars/-/handlebars-4.2.0.tgz", + "integrity": "sha512-Kb4xn5Qh1cxAKvQnzNWZ512DhABzyFNmsaJf3OAkWNa4NkaqWcNI8Tao8Tasi0/F4JD9oyG0YxuFyvyR57d+Gw==", "dev": true, "requires": { "neo-async": "^2.6.0", @@ -7622,9 +8149,9 @@ }, "dependencies": { "ajv": { - "version": "6.10.0", - "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.10.0.tgz", - "integrity": "sha512-nffhOpkymDECQyR0mnsUtoCE8RlX38G0rYP+wgLWFyZuUyuuojSSvi/+euOiQBIn63whYwYVIIH1TvE3tu4OEg==", + "version": "6.10.2", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.10.2.tgz", + "integrity": "sha512-TXtUUEYHuaTEbLZWIKUr5pmBuhDLy+8KYtPYdcV8qC+pOZL+NKqYwvWSRrVXHn+ZmRRAu8vJTAznH7Oag6RVRw==", "dev": true, "requires": { "fast-deep-equal": "^2.0.1", @@ -7777,15 +8304,15 @@ } }, "hast-util-is-element": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/hast-util-is-element/-/hast-util-is-element-1.0.2.tgz", - "integrity": "sha512-4MEtyofNi3ZunPFrp9NpTQdNPN24xvLX3M+Lr/RGgPX6TLi+wR4/DqeoyQ7lwWcfUp4aevdt4RR0r7ZQPFbHxw==", + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/hast-util-is-element/-/hast-util-is-element-1.0.3.tgz", + "integrity": "sha512-C62CVn7jbjp89yOhhy7vrkSaB7Vk906Gtcw/Ihd+Iufnq+2pwOZjdPmpzpKLWJXPJBMDX3wXg4FqmdOayPcewA==", "dev": true }, "hast-util-sanitize": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/hast-util-sanitize/-/hast-util-sanitize-1.3.0.tgz", - "integrity": "sha512-rQeetoD08jHmDOUYN6h9vTuE0hQN4wymhtkQZ6whHtcjaLpjw5RYAbcdxx9cMgMWERDsSs79UpqHuBLlUHKeOw==", + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/hast-util-sanitize/-/hast-util-sanitize-1.3.1.tgz", + "integrity": "sha512-AIeKHuHx0Wk45nSkGVa2/ujQYTksnDl8gmmKo/mwQi7ag7IBZ8cM3nJ2G86SajbjGP/HRpud6kMkPtcM2i0Tlw==", "dev": true, "requires": { "xtend": "^4.0.1" @@ -7808,24 +8335,32 @@ "stringify-entities": "^1.0.1", "unist-util-is": "^2.0.0", "xtend": "^4.0.1" + }, + "dependencies": { + "unist-util-is": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-2.1.3.tgz", + "integrity": "sha512-4WbQX2iwfr/+PfM4U3zd2VNXY+dWtZsN1fLnWEi2QQXA4qyDYAZcDMfXUX0Cu6XZUHHAO9q4nyxxLT4Awk1qUA==", + "dev": true + } } }, "hast-util-whitespace": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/hast-util-whitespace/-/hast-util-whitespace-1.0.2.tgz", - "integrity": "sha512-4JT8B0HKPHBMFZdDQzexjxwhKx9TrpV/+uelvmqlPu8RqqDrnNIEHDtDZCmgE+4YmcFAtKVPLmnY3dQGRaN53A==", + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/hast-util-whitespace/-/hast-util-whitespace-1.0.3.tgz", + "integrity": "sha512-AlkYiLTTwPOyxZ8axq2/bCwRUPjIPBfrHkXuCR92B38b3lSdU22R5F/Z4DL6a2kxWpekWq1w6Nj48tWat6GeRA==", "dev": true }, "he": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/he/-/he-1.1.1.tgz", - "integrity": "sha1-k0EP0hsAlzUVH4howvJx80J+I/0=", + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/he/-/he-1.2.0.tgz", + "integrity": "sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw==", "dev": true }, "highlight.js": { - "version": "9.15.6", - "resolved": "https://registry.npmjs.org/highlight.js/-/highlight.js-9.15.6.tgz", - "integrity": "sha512-zozTAWM1D6sozHo8kqhfYgsac+B+q0PmsjXeyDrYIHHcBN0zTVT66+s2GW1GZv7DbyaROdLXKdabwS/WqPyIdQ==", + "version": "9.15.10", + "resolved": "https://registry.npmjs.org/highlight.js/-/highlight.js-9.15.10.tgz", + "integrity": "sha512-RoV7OkQm0T3os3Dd2VHLNMoaoDVx77Wygln3n9l5YV172XonWG6rgQD3XnF/BuFFZw9A0TJgmMSO8FEWQgvcXw==", "dev": true }, "hmac-drbg": { @@ -7858,16 +8393,22 @@ "parse-passwd": "^1.0.0" } }, + "hoopy": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/hoopy/-/hoopy-0.1.4.tgz", + "integrity": "sha512-HRcs+2mr52W0K+x8RzcLzuPPmVIKMSv97RGHy0Ea9y/mpcaK+xTrjICA04KAHi4GRzxliNqNJEFYWHghy3rSfQ==", + "dev": true + }, "hosted-git-info": { - "version": "2.7.1", - "resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.7.1.tgz", - "integrity": "sha512-7T/BxH19zbcCTa8XkMlbK5lTo1WtgkFi3GvdWEyNuc4Vex7/9Dqbnpsf4JMydcfj9HCg4zUWFTL3Za6lapg5/w==", + "version": "2.8.4", + "resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.8.4.tgz", + "integrity": "sha512-pzXIvANXEFrc5oFFXRMkbLPQ2rXRoDERwDLyrcUxGhaZhgP54BBSl9Oheh7Vv0T090cszWBxPjkQQ5Sq1PbBRQ==", "dev": true }, "html-void-elements": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/html-void-elements/-/html-void-elements-1.0.3.tgz", - "integrity": "sha512-SaGhCDPXJVNrQyKMtKy24q6IMdXg5FCPN3z+xizxw9l+oXQw5fOoaj/ERU5KqWhSYhXtW5bWthlDbTDLBhJQrA==", + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/html-void-elements/-/html-void-elements-1.0.4.tgz", + "integrity": "sha512-yMk3naGPLrfvUV9TdDbuYXngh/TpHbA6TrOw3HL9kS8yhwx7i309BReNg7CbAJXGE+UMJ6je5OqJ7lC63o6YuQ==", "dev": true }, "http-cache-semantics": { @@ -7888,18 +8429,18 @@ "statuses": ">= 1.4.0 < 2" }, "dependencies": { - "statuses": { - "version": "1.5.0", - "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.5.0.tgz", - "integrity": "sha1-Fhx9rBd2Wf2YEfQ3cfqZOBR4Yow=", + "inherits": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", + "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=", "dev": true } } }, "http-parser-js": { - "version": "0.5.0", - "resolved": "https://registry.npmjs.org/http-parser-js/-/http-parser-js-0.5.0.tgz", - "integrity": "sha512-cZdEF7r4gfRIq7ezX9J0T+kQmJNOub71dWbgAXVHDct80TKP4MCETtZQ31xyv38UwgzkWPYF/Xc0ge55dW9Z9w==", + "version": "0.4.10", + "resolved": "https://registry.npmjs.org/http-parser-js/-/http-parser-js-0.4.10.tgz", + "integrity": "sha1-ksnBN0w1CF912zWexWzCV8u5P6Q=", "dev": true }, "http-proxy": { @@ -7913,33 +8454,6 @@ "requires-port": "^1.0.0" } }, - "http-proxy-agent": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/http-proxy-agent/-/http-proxy-agent-2.1.0.tgz", - "integrity": "sha512-qwHbBLV7WviBl0rQsOzH6o5lwyOIvwp/BdFnvVxXORldu5TmjFfjzBcWUWS5kWAZhmv+JtiDhSuQCp4sBfbIgg==", - "dev": true, - "requires": { - "agent-base": "4", - "debug": "3.1.0" - }, - "dependencies": { - "debug": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz", - "integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==", - "dev": true, - "requires": { - "ms": "2.0.0" - } - }, - "ms": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", - "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", - "dev": true - } - } - }, "http-signature": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/http-signature/-/http-signature-1.2.0.tgz", @@ -7958,12 +8472,12 @@ "dev": true }, "https-proxy-agent": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-2.2.1.tgz", - "integrity": "sha512-HPCTS1LW51bcyMYbxUIOO4HEOlQ1/1qRaFWcyxvwaqUS9TY88aoEuHUY33kuAh1YhVVaDQhLZsnPd+XNARWZlQ==", + "version": "2.2.2", + "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-2.2.2.tgz", + "integrity": "sha512-c8Ndjc9Bkpfx/vCJueCPy0jlP4ccCCSNDp8xwCZzPjKJUm+B+u9WX2x98Qx4n1PiMNTWo3D7KK5ifNV/yJyRzg==", "dev": true, "requires": { - "agent-base": "^4.1.0", + "agent-base": "^4.3.0", "debug": "^3.1.0" }, "dependencies": { @@ -7978,6 +8492,12 @@ } } }, + "humanize-duration": { + "version": "3.15.3", + "resolved": "https://registry.npmjs.org/humanize-duration/-/humanize-duration-3.15.3.tgz", + "integrity": "sha512-BMz6w8p3NVa6QP9wDtqUkXfwgBqDaZ5z/np0EYdoWrLqL849Onp6JWMXMhbHtuvO9jUThLN5H1ThRQ8dUWnYkA==", + "dev": true + }, "iconv-lite": { "version": "0.4.24", "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", @@ -8031,9 +8551,9 @@ } }, "inherits": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", - "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=", + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", "dev": true }, "ini": { @@ -8070,22 +8590,6 @@ "integrity": "sha1-7QMXwyIGT3lGbAKWa922Bas32Zg=", "dev": true }, - "is-fullwidth-code-point": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz", - "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=", - "dev": true - }, - "string-width": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-2.1.1.tgz", - "integrity": "sha512-nOqH59deCq9SRHlxq1Aw85Jnt4w6KvLKqWVik6oA9ZklXLNIOlqg4F2yrT1MVaTjAqvVwdfeZ7w7aCvJD7ugkw==", - "dev": true, - "requires": { - "is-fullwidth-code-point": "^2.0.0", - "strip-ansi": "^4.0.0" - } - }, "strip-ansi": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz", @@ -8123,15 +8627,15 @@ } }, "invert-kv": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/invert-kv/-/invert-kv-1.0.0.tgz", - "integrity": "sha1-EEqOSqym09jNFXqO+L+rLXo//bY=", + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/invert-kv/-/invert-kv-2.0.0.tgz", + "integrity": "sha512-wPVv/y/QQ/Uiirj/vh3oP+1Ww+AWehmi1g5fFWGPF6IpCBCDVrhgHRMvrLfdYcwDh3QJbGXDW4JAuzxElLSqKA==", "dev": true }, - "ip": { - "version": "1.1.5", - "resolved": "https://registry.npmjs.org/ip/-/ip-1.1.5.tgz", - "integrity": "sha1-vd7XARQpCCjAoDnnLvJfWq7ENUo=", + "ipaddr.js": { + "version": "1.9.0", + "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.0.tgz", + "integrity": "sha512-M4Sjn6N/+O6/IXSJseKqHoFc+5FdGJ22sXqnjTpdZweHK64MzEPAyQZyEU3R/KRv2GLoa7nNtg/C2Ev6m7z+eA==", "dev": true }, "is-absolute": { @@ -8165,9 +8669,9 @@ } }, "is-alphabetical": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/is-alphabetical/-/is-alphabetical-1.0.2.tgz", - "integrity": "sha512-V0xN4BYezDHcBSKb1QHUFMlR4as/XEuCZBzMJUU4n7+Cbt33SmUnSol+pnXFvLxSHNq2CemUXNdaXV6Flg7+xg==", + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/is-alphabetical/-/is-alphabetical-1.0.3.tgz", + "integrity": "sha512-eEMa6MKpHFzw38eKm56iNNi6GJ7lf6aLLio7Kr23sJPAECscgRtZvOBYybejWDQ2bM949Y++61PY+udzj5QMLA==", "dev": true }, "is-alphanumeric": { @@ -8177,9 +8681,9 @@ "dev": true }, "is-alphanumerical": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/is-alphanumerical/-/is-alphanumerical-1.0.2.tgz", - "integrity": "sha512-pyfU/0kHdISIgslFfZN9nfY1Gk3MquQgUm1mJTjdkEPpkAKNWuBTSqFwewOpR7N351VkErCiyV71zX7mlQQqsg==", + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/is-alphanumerical/-/is-alphanumerical-1.0.3.tgz", + "integrity": "sha512-A1IGAPO5AW9vSh7omxIlOGwIqEvpW/TA+DksVOPM5ODuxKlZS09+TEM1E3275lJqO2oJ38vDpeAL3DCIiHE6eA==", "dev": true, "requires": { "is-alphabetical": "^1.0.0", @@ -8240,9 +8744,9 @@ "dev": true }, "is-decimal": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/is-decimal/-/is-decimal-1.0.2.tgz", - "integrity": "sha512-TRzl7mOCchnhchN+f3ICUCzYvL9ul7R+TYOsZ8xia++knyZAJfv/uA1FvQXsAnYIl1T3B2X5E/J7Wb1QXiIBXg==", + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/is-decimal/-/is-decimal-1.0.3.tgz", + "integrity": "sha512-bvLSwoDg2q6Gf+E2LEPiklHZxxiSi3XAh4Mav65mKqTfCO1HM3uBs24TjEH8iJX3bbDdLXKJXBTmGzuTUuAEjQ==", "dev": true }, "is-descriptor": { @@ -8307,27 +8811,24 @@ } }, "is-fullwidth-code-point": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz", - "integrity": "sha1-754xOG8DGn8NZDr4L95QxFfvAMs=", - "dev": true, - "requires": { - "number-is-nan": "^1.0.0" - } + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz", + "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=", + "dev": true }, "is-glob": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.0.tgz", - "integrity": "sha1-lSHHaEXMJhCoUgPd8ICpWML/q8A=", + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.1.tgz", + "integrity": "sha512-5G0tKtBTFImOqDnLB2hG6Bp2qcKEFduo4tZu9MT/H6NQv/ghhy30o55ufafxJ/LdH79LLs2Kfrn85TLKyA7BUg==", "dev": true, "requires": { "is-extglob": "^2.1.1" } }, "is-hexadecimal": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/is-hexadecimal/-/is-hexadecimal-1.0.2.tgz", - "integrity": "sha512-but/G3sapV3MNyqiDBLrOi4x8uCIw0RY3o/Vb5GT0sMFHrVV7731wFSVy41T5FO1og7G0gXLJh0MkgPRouko/A==", + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/is-hexadecimal/-/is-hexadecimal-1.0.3.tgz", + "integrity": "sha512-zxQ9//Q3D/34poZf8fiy3m3XVpbQc7ren15iKqrTtLPwkPD/t3Scy9Imp63FujULGxuK0ZlCwoo5xNpktFgbOA==", "dev": true }, "is-negated-glob": { @@ -8420,9 +8921,9 @@ "dev": true }, "is-retry-allowed": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/is-retry-allowed/-/is-retry-allowed-1.1.0.tgz", - "integrity": "sha1-EaBgVotnM5REAz0BJaYaINVk+zQ=", + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/is-retry-allowed/-/is-retry-allowed-1.2.0.tgz", + "integrity": "sha512-RUbUeKwvm3XG2VYamhJL1xFktgjvPzL0Hq8C+6yrWIswDy3BIXGqCxhxkc30N9jqK311gVU137K8Ei55/zVJRg==", "dev": true }, "is-running": { @@ -8483,9 +8984,9 @@ "dev": true }, "is-whitespace-character": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/is-whitespace-character/-/is-whitespace-character-1.0.2.tgz", - "integrity": "sha512-SzM+T5GKUCtLhlHFKt2SDAX2RFzfS6joT91F2/WSi9LxgFdsnhfPK/UIA+JhRR2xuyLdrCys2PiFDrtn1fU5hQ==", + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/is-whitespace-character/-/is-whitespace-character-1.0.3.tgz", + "integrity": "sha512-SNPgMLz9JzPccD3nPctcj8sZlX9DAMJSKH8bP7Z6bohCwuNgX8xbWr1eTAYXX9Vpi/aSn8Y1akL9WgM3t43YNQ==", "dev": true }, "is-windows": { @@ -8495,15 +8996,15 @@ "dev": true }, "is-word-character": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/is-word-character/-/is-word-character-1.0.2.tgz", - "integrity": "sha512-T3FlsX8rCHAH8e7RE7PfOPZVFQlcV3XRF9eOOBQ1uf70OxO7CjjSOjeImMPCADBdYWcStAbVbYvJ1m2D3tb+EA==", + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/is-word-character/-/is-word-character-1.0.3.tgz", + "integrity": "sha512-0wfcrFgOOOBdgRNT9H33xe6Zi6yhX/uoc4U8NBZGeQQB0ctU1dnlNTyL9JM2646bHDTpsDm1Brb3VPoCIMrd/A==", "dev": true }, "is-wsl": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/is-wsl/-/is-wsl-1.1.0.tgz", - "integrity": "sha1-HxbkqiKwTRM2tmGIpmrzxgDDpm0=", + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/is-wsl/-/is-wsl-2.1.0.tgz", + "integrity": "sha512-pFTjpv/x5HRj8kbZ/Msxi9VrvtOMRBqaDi3OIcbwPI3OuH+r3lLxVWukLITBaOGJIbA/w2+M1eVmVa4XNQlAmQ==", "dev": true }, "isarray": { @@ -8623,12 +9124,12 @@ }, "dependencies": { "async": { - "version": "2.6.2", - "resolved": "https://registry.npmjs.org/async/-/async-2.6.2.tgz", - "integrity": "sha512-H1qVYh1MYhEEFLsP97cVKqCGo7KfCyTt6uEWqsTBr9SO84oK9Uwbyd/yCW+6rKJLHksBNUVWZDAjfS+Ccx0Bbg==", + "version": "2.6.3", + "resolved": "https://registry.npmjs.org/async/-/async-2.6.3.tgz", + "integrity": "sha512-zflvls11DCy+dQWzTW2dzuilv8Z5X/pjfmZOWba6TNIVDm+2UDaJmXSOXlasHKfNBs8oo3M0aT50fDEWfKZjXg==", "dev": true, "requires": { - "lodash": "^4.17.11" + "lodash": "^4.17.14" } } } @@ -8727,9 +9228,9 @@ } }, "rimraf": { - "version": "2.6.3", - "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.3.tgz", - "integrity": "sha512-mwqeW5XsA2qAejG46gYdENaxXjx9onRNCfn7L0duuP4hCuTIi/QO7PDK07KJfp1d+izWPrzEJDcSqBa0OZQriA==", + "version": "2.7.1", + "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.7.1.tgz", + "integrity": "sha512-uWjbaKIK3T1OSVptzX7Nl6PvQ3qAGtKEtVRjRuazjfL3Bx5eI409VZSqgND+4UNnmzLVdPj9FqFJNPqBZFve4w==", "dev": true, "requires": { "glob": "^7.1.3" @@ -8780,9 +9281,9 @@ "dev": true }, "js-yaml": { - "version": "3.13.0", - "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.13.0.tgz", - "integrity": "sha512-pZZoSxcCYco+DIKBTimr67J6Hy+EYGZDY/HCWC+iAEA9h1ByhMXAIVUXMcMFpOCxQ/xjXmPI2MkDL5HRm5eFrQ==", + "version": "3.13.1", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.13.1.tgz", + "integrity": "sha512-YfbcO7jXDdyj0DGxYVSlSeQNHbD7XPWvrVWeVUujrQEoZzWJIRrCPoyk6kL6IAjAG2IolMK4T0hNUe0HOUs5Jw==", "dev": true, "requires": { "argparse": "^1.0.7", @@ -8935,15 +9436,15 @@ }, "dependencies": { "mime": { - "version": "2.4.0", - "resolved": "https://registry.npmjs.org/mime/-/mime-2.4.0.tgz", - "integrity": "sha512-ikBcWwyqXQSHKtciCcctu9YfPbFYZ4+gbHEmE0Q8jzcTYQg5dHCr3g2wwAZjPoJfQVXZq6KXAjpXOTf5/cjT7w==", + "version": "2.4.4", + "resolved": "https://registry.npmjs.org/mime/-/mime-2.4.4.tgz", + "integrity": "sha512-LRxmNwziLPT828z+4YkNzloCFC2YM4wrB99k+AV5ZbEyfGNWfG8SO1FUXLmLDBSo89NrJZ4DIWeLjy1CHGhMGA==", "dev": true }, "rimraf": { - "version": "2.6.3", - "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.3.tgz", - "integrity": "sha512-mwqeW5XsA2qAejG46gYdENaxXjx9onRNCfn7L0duuP4hCuTIi/QO7PDK07KJfp1d+izWPrzEJDcSqBa0OZQriA==", + "version": "2.7.1", + "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.7.1.tgz", + "integrity": "sha512-uWjbaKIK3T1OSVptzX7Nl6PvQ3qAGtKEtVRjRuazjfL3Bx5eI409VZSqgND+4UNnmzLVdPj9FqFJNPqBZFve4w==", "dev": true, "requires": { "glob": "^7.1.3" @@ -8967,9 +9468,9 @@ } }, "karma-browserstack-launcher": { - "version": "1.5.0", - "resolved": "https://registry.npmjs.org/karma-browserstack-launcher/-/karma-browserstack-launcher-1.5.0.tgz", - "integrity": "sha512-WFJaVwF+1DAgdS81Kbv1/UG1eIfEEzlt9CWLqzm306/MqrIYOxjUVmOdXrEpCefDR7gTl6CQ5Ym+t8RwUPGvJQ==", + "version": "1.5.1", + "resolved": "https://registry.npmjs.org/karma-browserstack-launcher/-/karma-browserstack-launcher-1.5.1.tgz", + "integrity": "sha512-zt9Ukow5A9WZHZXCFVO/h5kRsAdaZYeMNJK9Uan8v42amQXt3B/DZVxl24NCcAIxufKjW13UWd9iJ9knG9OCYw==", "dev": true, "requires": { "browserstack": "~1.5.1", @@ -9013,10 +9514,13 @@ } }, "karma-firefox-launcher": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/karma-firefox-launcher/-/karma-firefox-launcher-1.1.0.tgz", - "integrity": "sha512-LbZ5/XlIXLeQ3cqnCbYLn+rOVhuMIK9aZwlP6eOLGzWdo1UVp7t6CN3DP4SafiRLjexKwHeKHDm0c38Mtd3VxA==", - "dev": true + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/karma-firefox-launcher/-/karma-firefox-launcher-1.2.0.tgz", + "integrity": "sha512-j9Zp8M8+VLq1nI/5xZGfzeaEPtGQ/vk3G+Y8vpmFWLvKLNZ2TDjD6cu2dUu7lDbu1HXNgatsAX4jgCZTkR9qhQ==", + "dev": true, + "requires": { + "is-wsl": "^2.1.0" + } }, "karma-ie-launcher": { "version": "1.0.0", @@ -9121,12 +9625,12 @@ }, "dependencies": { "async": { - "version": "2.6.2", - "resolved": "https://registry.npmjs.org/async/-/async-2.6.2.tgz", - "integrity": "sha512-H1qVYh1MYhEEFLsP97cVKqCGo7KfCyTt6uEWqsTBr9SO84oK9Uwbyd/yCW+6rKJLHksBNUVWZDAjfS+Ccx0Bbg==", + "version": "2.6.3", + "resolved": "https://registry.npmjs.org/async/-/async-2.6.3.tgz", + "integrity": "sha512-zflvls11DCy+dQWzTW2dzuilv8Z5X/pjfmZOWba6TNIVDm+2UDaJmXSOXlasHKfNBs8oo3M0aT50fDEWfKZjXg==", "dev": true, "requires": { - "lodash": "^4.17.11" + "lodash": "^4.17.14" } } } @@ -9178,12 +9682,12 @@ } }, "lcid": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/lcid/-/lcid-1.0.0.tgz", - "integrity": "sha1-MIrMr6C8SDo4Z7S28rlQYlHRuDU=", + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/lcid/-/lcid-2.0.0.tgz", + "integrity": "sha512-avPEb8P8EGnwXKClwsNUgryVjllcRqtMYa49NTsbQagYuT1DcXnl1915oxWjoyGrXR6zH/Y0Zc96xWsPcoDKeA==", "dev": true, "requires": { - "invert-kv": "^1.0.0" + "invert-kv": "^2.0.0" } }, "lcov-parse": { @@ -9292,85 +9796,17 @@ } }, "lodash": { - "version": "4.17.11", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.11.tgz", - "integrity": "sha512-cQKh8igo5QUhZ7lg38DYWAxMvjSAKG0A8wGSVimP07SIUEK2UO+arSRKbRZWtelMtN5V0Hkwh5ryOto/SshYIg==", - "dev": true - }, - "lodash._arraycopy": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/lodash._arraycopy/-/lodash._arraycopy-3.0.0.tgz", - "integrity": "sha1-due3wfH7klRzdIeKVi7Qaj5Q9uE=", - "dev": true - }, - "lodash._arrayeach": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/lodash._arrayeach/-/lodash._arrayeach-3.0.0.tgz", - "integrity": "sha1-urFWsqkNPxu9XGU0AzSeXlkz754=", + "version": "4.17.15", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.15.tgz", + "integrity": "sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A==", "dev": true }, - "lodash._baseassign": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/lodash._baseassign/-/lodash._baseassign-3.2.0.tgz", - "integrity": "sha1-jDigmVAPIVrQnlnxci/QxSv+Ck4=", - "dev": true, - "requires": { - "lodash._basecopy": "^3.0.0", - "lodash.keys": "^3.0.0" - }, - "dependencies": { - "lodash.keys": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/lodash.keys/-/lodash.keys-3.1.2.tgz", - "integrity": "sha1-TbwEcrFWvlCgsoaFXRvQsMZWCYo=", - "dev": true, - "requires": { - "lodash._getnative": "^3.0.0", - "lodash.isarguments": "^3.0.0", - "lodash.isarray": "^3.0.0" - } - } - } - }, - "lodash._baseclone": { - "version": "3.3.0", - "resolved": "https://registry.npmjs.org/lodash._baseclone/-/lodash._baseclone-3.3.0.tgz", - "integrity": "sha1-MDUZv2OT/n5C802LYw73eU41Qrc=", - "dev": true, - "requires": { - "lodash._arraycopy": "^3.0.0", - "lodash._arrayeach": "^3.0.0", - "lodash._baseassign": "^3.0.0", - "lodash._basefor": "^3.0.0", - "lodash.isarray": "^3.0.0", - "lodash.keys": "^3.0.0" - }, - "dependencies": { - "lodash.keys": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/lodash.keys/-/lodash.keys-3.1.2.tgz", - "integrity": "sha1-TbwEcrFWvlCgsoaFXRvQsMZWCYo=", - "dev": true, - "requires": { - "lodash._getnative": "^3.0.0", - "lodash.isarguments": "^3.0.0", - "lodash.isarray": "^3.0.0" - } - } - } - }, "lodash._basecopy": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/lodash._basecopy/-/lodash._basecopy-3.0.1.tgz", "integrity": "sha1-jaDmqHbPNEwK2KVIghEd08XHyjY=", "dev": true }, - "lodash._basefor": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/lodash._basefor/-/lodash._basefor-3.0.3.tgz", - "integrity": "sha1-dVC06SGO8J+tJDQ7YSAhx5tMIMI=", - "dev": true - }, "lodash._basetostring": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/lodash._basetostring/-/lodash._basetostring-3.0.1.tgz", @@ -9383,12 +9819,6 @@ "integrity": "sha1-W3dXYoAr3j0yl1A+JjAIIP32Ybc=", "dev": true }, - "lodash._bindcallback": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/lodash._bindcallback/-/lodash._bindcallback-3.0.1.tgz", - "integrity": "sha1-5THCdkTPi1epnhftlbNcdIeJOS4=", - "dev": true - }, "lodash._escapehtmlchar": { "version": "2.4.1", "resolved": "https://registry.npmjs.org/lodash._escapehtmlchar/-/lodash._escapehtmlchar-2.4.1.tgz", @@ -9477,22 +9907,11 @@ "lodash._objecttypes": "~2.4.1" } }, - "lodash.assign": { - "version": "4.2.0", - "resolved": "https://registry.npmjs.org/lodash.assign/-/lodash.assign-4.2.0.tgz", - "integrity": "sha1-DZnzzNem0mHRm9rrkkUAXShYCOc=", - "dev": true - }, "lodash.clone": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/lodash.clone/-/lodash.clone-3.0.3.tgz", - "integrity": "sha1-hGiMc9MrWpDKJWFpY/GJJSqZcEM=", - "dev": true, - "requires": { - "lodash._baseclone": "^3.0.0", - "lodash._bindcallback": "^3.0.0", - "lodash._isiterateecall": "^3.0.0" - } + "version": "4.5.0", + "resolved": "https://registry.npmjs.org/lodash.clone/-/lodash.clone-4.5.0.tgz", + "integrity": "sha1-GVhwRQ9aExkkeN9Lw9I9LeoZB7Y=", + "dev": true }, "lodash.defaults": { "version": "2.4.1", @@ -9504,12 +9923,6 @@ "lodash.keys": "~2.4.1" } }, - "lodash.defaultsdeep": { - "version": "4.6.0", - "resolved": "https://registry.npmjs.org/lodash.defaultsdeep/-/lodash.defaultsdeep-4.6.0.tgz", - "integrity": "sha1-vsECT4WxvZbL6kBbI8FK1kQ6b4E=", - "dev": true - }, "lodash.escape": { "version": "2.4.1", "resolved": "https://registry.npmjs.org/lodash.escape/-/lodash.escape-2.4.1.tgz", @@ -9559,12 +9972,6 @@ "lodash.isobject": "~2.4.1" } }, - "lodash.merge": { - "version": "4.6.1", - "resolved": "https://registry.npmjs.org/lodash.merge/-/lodash.merge-4.6.1.tgz", - "integrity": "sha512-AOYza4+Hf5z1/0Hztxpm2/xiPZgi/cjMqdnKTUWTBSKchJlxXXuUSxCCl8rJlf4g6yww/j6mA8nC8Hw/EZWxKQ==", - "dev": true - }, "lodash.restparam": { "version": "3.6.1", "resolved": "https://registry.npmjs.org/lodash.restparam/-/lodash.restparam-3.6.1.tgz", @@ -9667,9 +10074,9 @@ } }, "lolex": { - "version": "1.3.2", - "resolved": "https://registry.npmjs.org/lolex/-/lolex-1.3.2.tgz", - "integrity": "sha1-fD2mL/yzDw9agKJWbKJORdigHzE=", + "version": "2.7.5", + "resolved": "https://registry.npmjs.org/lolex/-/lolex-2.7.5.tgz", + "integrity": "sha512-l9x0+1offnKKIzYVjyXU2SiwhXDLekRzKyhnbyldPHvC7BvLPVpdNUNR2KeMAiCN2D/kLNttZgQD5WjSxuBx3Q==", "dev": true }, "longest": { @@ -9679,9 +10086,9 @@ "dev": true }, "longest-streak": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/longest-streak/-/longest-streak-2.0.2.tgz", - "integrity": "sha512-TmYTeEYxiAmSVdpbnQDXGtvYOIRsCMg89CVZzwzc2o7GFL1CjoiRPjH5ec0NFAVlAx3fVof9dX/t6KKRAo2OWA==", + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/longest-streak/-/longest-streak-2.0.3.tgz", + "integrity": "sha512-9lz5IVdpwsKLMzQi0MQ+oD9EA0mIGcWYP7jXMTZVXP8D42PwuAk+M/HBFYQoxt1G5OR8m7aSIgb1UymfWGBWEw==", "dev": true }, "loose-envify": { @@ -9728,15 +10135,6 @@ "es5-ext": "~0.10.2" } }, - "magic-string": { - "version": "0.16.0", - "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.16.0.tgz", - "integrity": "sha1-lw67DacZMwEoX7GqZQ85vdgetFo=", - "dev": true, - "requires": { - "vlq": "^0.2.1" - } - }, "make-dir": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-2.1.0.tgz", @@ -9771,6 +10169,15 @@ "kind-of": "^6.0.2" } }, + "map-age-cleaner": { + "version": "0.1.3", + "resolved": "https://registry.npmjs.org/map-age-cleaner/-/map-age-cleaner-0.1.3.tgz", + "integrity": "sha512-bJzx6nMoP6PDLPBFmg7+xRKeFZvFboMrGlxmNj9ClvX53KrmvM5bXFXEWjbz4cz1AFn+jWJ9z/DJSz7hrs0w3w==", + "dev": true, + "requires": { + "p-defer": "^1.0.0" + } + }, "map-cache": { "version": "0.2.2", "resolved": "https://registry.npmjs.org/map-cache/-/map-cache-0.2.2.tgz", @@ -9799,15 +10206,15 @@ } }, "markdown-escapes": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/markdown-escapes/-/markdown-escapes-1.0.2.tgz", - "integrity": "sha512-lbRZ2mE3Q9RtLjxZBZ9+IMl68DKIXaVAhwvwn9pmjnPLS0h/6kyBMgNhqi1xFJ/2yv6cSyv0jbiZavZv93JkkA==", + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/markdown-escapes/-/markdown-escapes-1.0.3.tgz", + "integrity": "sha512-XUi5HJhhV5R74k8/0H2oCbCiYf/u4cO/rX8tnGkRvrqhsr5BRNU6Mg0yt/8UIx1iIS8220BNJsDb7XnILhLepw==", "dev": true }, "markdown-table": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/markdown-table/-/markdown-table-1.1.2.tgz", - "integrity": "sha512-NcWuJFHDA8V3wkDgR/j4+gZx+YQwstPgfQDV8ndUeWWzta3dnDTBxpVzqS9lkmJAuV5YX35lmyojl6HO5JXAgw==", + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/markdown-table/-/markdown-table-1.1.3.tgz", + "integrity": "sha512-1RUZVgQlpJSPWYbFSpmudq5nHY1doEIv89gBtF0s4gW1GF2XorxcA/70M5vq7rLv0a6mhOUccRsqkwhwLCIQ2Q==", "dev": true }, "matchdep": { @@ -9863,18 +10270,18 @@ } }, "mdast-util-compact": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/mdast-util-compact/-/mdast-util-compact-1.0.2.tgz", - "integrity": "sha512-d2WS98JSDVbpSsBfVvD9TaDMlqPRz7ohM/11G0rp5jOBb5q96RJ6YLszQ/09AAixyzh23FeIpCGqfaamEADtWg==", + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/mdast-util-compact/-/mdast-util-compact-1.0.3.tgz", + "integrity": "sha512-nRiU5GpNy62rZppDKbLwhhtw5DXoFMqw9UNZFmlPsNaQCZ//WLjGKUwWMdJrUH+Se7UvtO2gXtAMe0g/N+eI5w==", "dev": true, "requires": { "unist-util-visit": "^1.1.0" } }, "mdast-util-definitions": { - "version": "1.2.3", - "resolved": "https://registry.npmjs.org/mdast-util-definitions/-/mdast-util-definitions-1.2.3.tgz", - "integrity": "sha512-P6wpRO8YVQ1iv30maMc93NLh7COvufglBE8/ldcOyYmk5EbfF0YeqlLgtqP/FOBU501Kqar1x5wYWwB3Nga74g==", + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/mdast-util-definitions/-/mdast-util-definitions-1.2.4.tgz", + "integrity": "sha512-HfUArPog1j4Z78Xlzy9Q4aHLnrF/7fb57cooTHypyGoe2XFNbcx/kWZDoOz+ra8CkUzvg3+VHV434yqEd1DRmA==", "dev": true, "requires": { "unist-util-visit": "^1.0.0" @@ -9909,9 +10316,9 @@ } }, "mdast-util-to-string": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/mdast-util-to-string/-/mdast-util-to-string-1.0.5.tgz", - "integrity": "sha512-2qLt/DEOo5F6nc2VFScQiHPzQ0XXcabquRJxKMhKte8nt42o08HUxNDPk7tt0YPxnWjAT11I1SYi0X0iPnfI5A==", + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/mdast-util-to-string/-/mdast-util-to-string-1.0.6.tgz", + "integrity": "sha512-868pp48gUPmZIhfKrLbaDneuzGiw3OTDjHc5M1kAepR2CWBJ+HpEsm252K4aXdiP5coVZaJPOqGtVU6Po8xnXg==", "dev": true }, "mdast-util-toc": { @@ -9926,6 +10333,12 @@ "unist-util-visit": "^1.1.0" }, "dependencies": { + "emoji-regex": { + "version": "6.1.1", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-6.1.1.tgz", + "integrity": "sha1-xs0OwbBkLio8Z6ETfvxeeW2k+I4=", + "dev": true + }, "github-slugger": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/github-slugger/-/github-slugger-1.2.1.tgz", @@ -9934,6 +10347,12 @@ "requires": { "emoji-regex": ">=6.0.0 <=6.1.1" } + }, + "unist-util-is": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-2.1.3.tgz", + "integrity": "sha512-4WbQX2iwfr/+PfM4U3zd2VNXY+dWtZsN1fLnWEi2QQXA4qyDYAZcDMfXUX0Cu6XZUHHAO9q4nyxxLT4Awk1qUA==", + "dev": true } } }, @@ -9950,12 +10369,22 @@ "dev": true }, "mem": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/mem/-/mem-1.1.0.tgz", - "integrity": "sha1-Xt1StIXKHZAP5kiVUFOZoN+kX3Y=", + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/mem/-/mem-4.3.0.tgz", + "integrity": "sha512-qX2bG48pTqYRVmDB37rn/6PT7LcR8T7oAX3bf99u1Tt1nzxYfxkgqDwUwolPlXweM0XzBOBFzSx4kfp7KP1s/w==", "dev": true, "requires": { - "mimic-fn": "^1.0.0" + "map-age-cleaner": "^0.1.1", + "mimic-fn": "^2.0.0", + "p-is-promise": "^2.0.0" + }, + "dependencies": { + "p-is-promise": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/p-is-promise/-/p-is-promise-2.1.0.tgz", + "integrity": "sha512-Y3W0wlRPK8ZMRbNq97l4M5otioeA5lm1z7bkNkxCka8HSPjR0xRWmpCmc9utiaLP9Jb1eD8BgeIxTW4AIF45Pg==", + "dev": true + } } }, "memoizee": { @@ -9984,6 +10413,12 @@ "readable-stream": "^2.0.1" } }, + "memorystream": { + "version": "0.3.1", + "resolved": "https://registry.npmjs.org/memorystream/-/memorystream-0.3.1.tgz", + "integrity": "sha1-htcJCzDORV1j+64S3aUaR93K+bI=", + "dev": true + }, "meow": { "version": "3.7.0", "resolved": "https://registry.npmjs.org/meow/-/meow-3.7.0.tgz", @@ -10092,6 +10527,12 @@ } } }, + "merge-descriptors": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-1.0.1.tgz", + "integrity": "sha1-sAqqVW3YtEVoFQ7J0blT8/kMu2E=", + "dev": true + }, "merge-stream": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/merge-stream/-/merge-stream-1.0.1.tgz", @@ -10101,6 +10542,12 @@ "readable-stream": "^2.0.1" } }, + "methods": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/methods/-/methods-1.1.2.tgz", + "integrity": "sha1-VSmk1nZUE07cxSZmVoNbD4Ua/O4=", + "dev": true + }, "micromatch": { "version": "3.1.10", "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-3.1.10.tgz", @@ -10139,24 +10586,24 @@ "dev": true }, "mime-db": { - "version": "1.38.0", - "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.38.0.tgz", - "integrity": "sha512-bqVioMFFzc2awcdJZIzR3HjZFX20QhilVS7hytkKrv7xFAn8bM1gzc/FOX2awLISvWe0PV8ptFKcon+wZ5qYkg==", + "version": "1.40.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.40.0.tgz", + "integrity": "sha512-jYdeOMPy9vnxEqFRRo6ZvTZ8d9oPb+k18PKoYNYUe2stVEBPPwsln/qWzdbmaIvnhZ9v2P+CuecK+fpUfsV2mA==", "dev": true }, "mime-types": { - "version": "2.1.22", - "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.22.tgz", - "integrity": "sha512-aGl6TZGnhm/li6F7yx82bJiBZwgiEa4Hf6CNr8YO+r5UHr53tSTYZb102zyU50DOWWKeOv0uQLRL0/9EiKWCog==", + "version": "2.1.24", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.24.tgz", + "integrity": "sha512-WaFHS3MCl5fapm3oLxU4eYDw77IQM2ACcxQ9RIxfaC3ooc6PFuBMGZZsYpvoXS5D5QTWPieo1jjLdAm3TBP3cQ==", "dev": true, "requires": { - "mime-db": "~1.38.0" + "mime-db": "1.40.0" } }, "mimic-fn": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-1.2.0.tgz", - "integrity": "sha512-jf84uxzwiuiIVKiOLpfYk7N46TSy8ubTonmneY9vrpHNAnp0QBt2BxWV9dO3/j+BoVAb+a5G6YDPW3M5HOdMWQ==", + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-2.1.0.tgz", + "integrity": "sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg==", "dev": true }, "mimic-response": { @@ -10193,9 +10640,9 @@ "dev": true }, "mixin-deep": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/mixin-deep/-/mixin-deep-1.3.1.tgz", - "integrity": "sha512-8ZItLHeEgaqEvd5lYBXfm4EZSFCX29Jb9K+lAHhDKzReKBQKj3R+7NOF6tjqYi9t4oI8VUfaWITJQm86wnXGNQ==", + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/mixin-deep/-/mixin-deep-1.3.2.tgz", + "integrity": "sha512-WRoDn//mXBiJ1H40rqa3vH0toePwSsGb45iInWlTySa+Uu4k3tYUSxa2v1KqAiLtvlrSzaExqS1gtk96A9zvEA==", "dev": true, "requires": { "for-in": "^1.0.2", @@ -10230,12 +10677,6 @@ } } }, - "mkpath": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/mkpath/-/mkpath-1.0.0.tgz", - "integrity": "sha1-67Opd+evHGg65v2hK1Raa6bFhT0=", - "dev": true - }, "mocha": { "version": "5.2.0", "resolved": "https://registry.npmjs.org/mocha/-/mocha-5.2.0.tgz", @@ -10255,6 +10696,12 @@ "supports-color": "5.4.0" }, "dependencies": { + "commander": { + "version": "2.15.1", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.15.1.tgz", + "integrity": "sha512-VlfT9F3V0v+jr4yxPc5gg9s62/fIVWsd2Bk2iD435um1NlGMYdVCq+MjcXnhYq2icNOizHr1kK+5TI6H0Hy0ag==", + "dev": true + }, "debug": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz", @@ -10284,6 +10731,12 @@ "path-is-absolute": "^1.0.0" } }, + "he": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/he/-/he-1.1.1.tgz", + "integrity": "sha1-k0EP0hsAlzUVH4howvJx80J+I/0=", + "dev": true + }, "ms": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", @@ -10365,9 +10818,9 @@ } }, "ms": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz", - "integrity": "sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg==", + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", "dev": true }, "multipipe": { @@ -10427,9 +10880,9 @@ "dev": true }, "nan": { - "version": "2.13.2", - "resolved": "https://registry.npmjs.org/nan/-/nan-2.13.2.tgz", - "integrity": "sha512-TghvYc72wlMGMVMluVo9WRJc0mB8KxxF/gZ4YYFy7V2ZQX9l7rgbPg7vjS9mt6U5HXODVFVI2bOduCzwOMv/lw==", + "version": "2.14.0", + "resolved": "https://registry.npmjs.org/nan/-/nan-2.14.0.tgz", + "integrity": "sha512-INOFj37C7k3AfaNTtX8RhsTw7qRy7eLET14cROi9+5HAVbbHuIWUHEauBv5qT4Av2tWasiTY1Jw6puUNqRJXQg==", "dev": true, "optional": true }, @@ -10465,21 +10918,15 @@ "dev": true }, "negotiator": { - "version": "0.6.1", - "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.1.tgz", - "integrity": "sha1-KzJxhOiZIQEXeyhWP7XnECrNDKk=", + "version": "0.6.2", + "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.2.tgz", + "integrity": "sha512-hZXc7K2e+PgeI1eDBe/10Ard4ekbfrrqG8Ep+8Jmf4JID2bNg7NvCPOZN+kfF574pFQI7mum2AUqDidoKqcTOw==", "dev": true }, "neo-async": { - "version": "2.6.0", - "resolved": "https://registry.npmjs.org/neo-async/-/neo-async-2.6.0.tgz", - "integrity": "sha512-MFh0d/Wa7vkKO3Y3LlacqAEeHK0mckVqzDieUKTT+KGxi+zIpeVsFxymkIiRpbpDziHc290Xr9A1O4Om7otoRA==", - "dev": true - }, - "netmask": { - "version": "1.0.6", - "resolved": "https://registry.npmjs.org/netmask/-/netmask-1.0.6.tgz", - "integrity": "sha1-ICl+idhvb2QA8lDZ9Pa0wZRfzTU=", + "version": "2.6.1", + "resolved": "https://registry.npmjs.org/neo-async/-/neo-async-2.6.1.tgz", + "integrity": "sha512-iyam8fBuCUpWeKPGpaNMetEocMt364qkCsfL9JuhjXX6dRnguRVOfk2GZaDpPjcOKiiXCPINZC1GczQ7iTq3Zw==", "dev": true }, "next-tick": { @@ -10488,35 +10935,22 @@ "integrity": "sha1-yobR/ogoFpsBICCOPchCS524NCw=", "dev": true }, - "nightwatch": { - "version": "1.0.19", - "resolved": "https://registry.npmjs.org/nightwatch/-/nightwatch-1.0.19.tgz", - "integrity": "sha512-Dl+EN4wFp927nn7KRkCIJ7b0Th9PVjiwflzqsoqJOwLPcLuzSBz4FYBvHXQtUkaL4/nELVgXurw/KXqj2gcFSg==", - "dev": true, - "requires": { - "assertion-error": "^1.1.0", - "chai-nightwatch": "0.2.1", - "ejs": "^2.5.9", - "lodash.clone": "3.0.3", - "lodash.defaultsdeep": "^4.6.0", - "lodash.merge": "^4.6.1", - "minimatch": "3.0.4", - "mkpath": "1.0.0", - "mocha": "^5.1.1", - "optimist": "^0.6.1", - "proxy-agent": "^3.0.0" - } + "nice-try": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/nice-try/-/nice-try-1.0.5.tgz", + "integrity": "sha512-1nh45deeb5olNY7eX82BkPO7SSxR5SSYJiPTrTdFUVYwAl8CKMA5N9PjTYkHiRjisVcxcQ1HXdLhx2qxxJzLNQ==", + "dev": true }, "nise": { - "version": "1.4.10", - "resolved": "https://registry.npmjs.org/nise/-/nise-1.4.10.tgz", - "integrity": "sha512-sa0RRbj53dovjc7wombHmVli9ZihXbXCQ2uH3TNm03DyvOSIQbxg+pbqDKrk2oxMK1rtLGVlKxcB9rrc6X5YjA==", + "version": "1.5.2", + "resolved": "https://registry.npmjs.org/nise/-/nise-1.5.2.tgz", + "integrity": "sha512-/6RhOUlicRCbE9s+94qCUsyE+pKlVJ5AhIv+jEE7ESKwnbXqulKZ1FYU+XAtHHWE9TinYvAxDUJAb912PwPoWA==", "dev": true, "requires": { - "@sinonjs/formatio": "^3.1.0", + "@sinonjs/formatio": "^3.2.1", "@sinonjs/text-encoding": "^0.7.1", "just-extend": "^4.0.2", - "lolex": "^2.3.2", + "lolex": "^4.1.0", "path-to-regexp": "^1.7.0" }, "dependencies": { @@ -10531,17 +10965,27 @@ } }, "lolex": { - "version": "2.7.5", - "resolved": "https://registry.npmjs.org/lolex/-/lolex-2.7.5.tgz", - "integrity": "sha512-l9x0+1offnKKIzYVjyXU2SiwhXDLekRzKyhnbyldPHvC7BvLPVpdNUNR2KeMAiCN2D/kLNttZgQD5WjSxuBx3Q==", + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/lolex/-/lolex-4.2.0.tgz", + "integrity": "sha512-gKO5uExCXvSm6zbF562EvM+rd1kQDnB9AZBbiQVzf1ZmdDpxUSvpnAaVOP83N/31mRK8Ml8/VE8DMvsAZQ+7wg==", "dev": true } } }, + "node-environment-flags": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/node-environment-flags/-/node-environment-flags-1.0.5.tgz", + "integrity": "sha512-VNYPRfGfmZLx0Ye20jWzHUjyTW/c+6Wq+iLhDzUI4XmhrDd9l/FozXV3F2xOaXjvp0co0+v1YSR3CMP6g+VvLQ==", + "dev": true, + "requires": { + "object.getownpropertydescriptors": "^2.0.3", + "semver": "^5.7.0" + } + }, "node-libs-browser": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/node-libs-browser/-/node-libs-browser-2.2.0.tgz", - "integrity": "sha512-5MQunG/oyOaBdttrL40dA7bUfPORLRWMUJLQtMg7nluxUvk5XwnLdL9twQHFAjRx/y7mIMkLKT9++qPbbk6BZA==", + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/node-libs-browser/-/node-libs-browser-2.2.1.tgz", + "integrity": "sha512-h/zcD8H9kaDZ9ALUWwlBUDo6TKF8a7qBSCSEGfjTVIYeqsioSKaAX+BN7NgiMGp6iSIXZ3PxgCu8KS3b71YK5Q==", "dev": true, "requires": { "assert": "^1.1.1", @@ -10554,7 +10998,7 @@ "events": "^3.0.0", "https-browserify": "^1.0.0", "os-browserify": "^0.3.0", - "path-browserify": "0.0.0", + "path-browserify": "0.0.1", "process": "^0.11.10", "punycode": "^1.2.4", "querystring-es3": "^0.2.0", @@ -10566,9 +11010,20 @@ "tty-browserify": "0.0.0", "url": "^0.11.0", "util": "^0.11.0", - "vm-browserify": "0.0.4" + "vm-browserify": "^1.0.1" }, "dependencies": { + "buffer": { + "version": "4.9.1", + "resolved": "https://registry.npmjs.org/buffer/-/buffer-4.9.1.tgz", + "integrity": "sha1-bRu2AbB6TvztlwlBMgkwJ8lbwpg=", + "dev": true, + "requires": { + "base64-js": "^1.0.2", + "ieee754": "^1.1.4", + "isarray": "^1.0.0" + } + }, "punycode": { "version": "1.4.1", "resolved": "https://registry.npmjs.org/punycode/-/punycode-1.4.1.tgz", @@ -10578,9 +11033,9 @@ } }, "node-releases": { - "version": "1.1.11", - "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-1.1.11.tgz", - "integrity": "sha512-8v1j5KfP+s5WOTa1spNUAOfreajQPN12JXbRR0oDE+YrJBQCXBnNqUDj27EKpPLOoSiU3tKi3xGPB+JaOdUEQQ==", + "version": "1.1.30", + "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-1.1.30.tgz", + "integrity": "sha512-BHcr1g6NeUH12IL+X3Flvs4IOnl1TL0JczUhEZjDE+FXXPQcVCNr8NEPb01zqGxzhTpdyJL5GXemaCW7aw6Khw==", "dev": true, "requires": { "semver": "^5.3.0" @@ -10626,14 +11081,37 @@ } }, "now-and-later": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/now-and-later/-/now-and-later-2.0.0.tgz", - "integrity": "sha1-vGHLtFbXnLMiB85HygUTb/Ln1u4=", + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/now-and-later/-/now-and-later-2.0.1.tgz", + "integrity": "sha512-KGvQ0cB70AQfg107Xvs/Fbu+dGmZoTRJp2TaPwcwQm3/7PteUyN2BCgk8KBMPGBUXZdVwyWS8fDCGFygBm19UQ==", "dev": true, "requires": { "once": "^1.3.2" } }, + "npm-install-package": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/npm-install-package/-/npm-install-package-2.1.0.tgz", + "integrity": "sha1-1+/jz816sAYUuJbqUxGdyaslkSU=", + "dev": true + }, + "npm-run-all": { + "version": "4.1.5", + "resolved": "https://registry.npmjs.org/npm-run-all/-/npm-run-all-4.1.5.tgz", + "integrity": "sha512-Oo82gJDAVcaMdi3nuoKFavkIHBRVqQ1qvMb+9LHk/cF4P6B2m8aP04hGf7oL6wZ9BuGwX1onlLhpuoofSyoQDQ==", + "dev": true, + "requires": { + "ansi-styles": "^3.2.1", + "chalk": "^2.4.1", + "cross-spawn": "^6.0.5", + "memorystream": "^0.3.1", + "minimatch": "^3.0.4", + "pidtree": "^0.3.0", + "read-pkg": "^3.0.0", + "shell-quote": "^1.6.1", + "string.prototype.padend": "^3.0.0" + } + }, "npm-run-path": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/npm-run-path/-/npm-run-path-2.0.2.tgz", @@ -10704,10 +11182,16 @@ } } }, + "object-inspect": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.6.0.tgz", + "integrity": "sha512-GJzfBZ6DgDAmnuaM3104jR4s1Myxr3Y3zfIyN4z3UdqN69oSRacNK8UhnobDdC+7J2AHCjGwxQubNJfE70SXXQ==", + "dev": true + }, "object-keys": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/object-keys/-/object-keys-1.1.0.tgz", - "integrity": "sha512-6OO5X1+2tYkNyNEx6TsCxEqFfRWaqx6EtMiSbGrw8Ob8v9Ne+Hl8rBAgLBZn5wjEz3s/s6U1WXFUFOcxxAwUpg==", + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/object-keys/-/object-keys-1.1.1.tgz", + "integrity": "sha512-NuAESUOUMrlIXOfHKzD6bpPu3tYt3xvjNdRIQ+FeT0lNb4K8WR70CaDxhuNguS2XG+GjkyMwOzsN5ZktImfhLA==", "dev": true }, "object-visit": { @@ -10803,9 +11287,21 @@ "make-iterator": "^1.0.0" } }, - "on-finished": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.3.0.tgz", + "object.values": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/object.values/-/object.values-1.1.0.tgz", + "integrity": "sha512-8mf0nKLAoFX6VlNVdhGj31SVYpaNFtUnuoOXWyFEstsWRgU837AK+JYM0iAxwkSzGRbwn8cbFmgbyxj1j4VbXg==", + "dev": true, + "requires": { + "define-properties": "^1.1.3", + "es-abstract": "^1.12.0", + "function-bind": "^1.1.1", + "has": "^1.0.3" + } + }, + "on-finished": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.3.0.tgz", "integrity": "sha1-IPEzZIGwg811M3mSoWlxqi2QaUc=", "dev": true, "requires": { @@ -10828,8 +11324,22 @@ "dev": true, "requires": { "mimic-fn": "^1.0.0" + }, + "dependencies": { + "mimic-fn": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-1.2.0.tgz", + "integrity": "sha512-jf84uxzwiuiIVKiOLpfYk7N46TSy8ubTonmneY9vrpHNAnp0QBt2BxWV9dO3/j+BoVAb+a5G6YDPW3M5HOdMWQ==", + "dev": true + } } }, + "opener": { + "version": "1.5.1", + "resolved": "https://registry.npmjs.org/opener/-/opener-1.5.1.tgz", + "integrity": "sha512-goYSy5c2UXE4Ra1xixabeVh1guIX/ZV/YokJksb6q2lubWu6UbvPQ20p542/sFIll1nl8JnCyK9oBaOcCWXwvA==", + "dev": true + }, "opn": { "version": "5.5.0", "resolved": "https://registry.npmjs.org/opn/-/opn-5.5.0.tgz", @@ -10837,6 +11347,14 @@ "dev": true, "requires": { "is-wsl": "^1.1.0" + }, + "dependencies": { + "is-wsl": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/is-wsl/-/is-wsl-1.1.0.tgz", + "integrity": "sha1-HxbkqiKwTRM2tmGIpmrzxgDDpm0=", + "dev": true + } } }, "optimist": { @@ -10863,168 +11381,6 @@ } } }, - "optimize-js": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/optimize-js/-/optimize-js-1.0.3.tgz", - "integrity": "sha1-QyavhlfEpf8y2vcmYxdU9yq3/bw=", - "dev": true, - "requires": { - "acorn": "^3.3.0", - "concat-stream": "^1.5.1", - "estree-walker": "^0.3.0", - "magic-string": "^0.16.0", - "yargs": "^4.8.1" - }, - "dependencies": { - "acorn": { - "version": "3.3.0", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-3.3.0.tgz", - "integrity": "sha1-ReN/s56No/JbruP/U2niu18iAXo=", - "dev": true - }, - "camelcase": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-3.0.0.tgz", - "integrity": "sha1-MvxLn82vhF/N9+c7uXysImHwqwo=", - "dev": true - }, - "find-up": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/find-up/-/find-up-1.1.2.tgz", - "integrity": "sha1-ay6YIrGizgpgq2TWEOzK1TyyTQ8=", - "dev": true, - "requires": { - "path-exists": "^2.0.0", - "pinkie-promise": "^2.0.0" - } - }, - "load-json-file": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/load-json-file/-/load-json-file-1.1.0.tgz", - "integrity": "sha1-lWkFcI1YtLq0wiYbBPWfMcmTdMA=", - "dev": true, - "requires": { - "graceful-fs": "^4.1.2", - "parse-json": "^2.2.0", - "pify": "^2.0.0", - "pinkie-promise": "^2.0.0", - "strip-bom": "^2.0.0" - } - }, - "os-locale": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/os-locale/-/os-locale-1.4.0.tgz", - "integrity": "sha1-IPnxeuKe00XoveWDsT0gCYA8FNk=", - "dev": true, - "requires": { - "lcid": "^1.0.0" - } - }, - "parse-json": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/parse-json/-/parse-json-2.2.0.tgz", - "integrity": "sha1-9ID0BDTvgHQfhGkJn43qGPVaTck=", - "dev": true, - "requires": { - "error-ex": "^1.2.0" - } - }, - "path-exists": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-2.1.0.tgz", - "integrity": "sha1-D+tsZPD8UY2adU3V77YscCJ2H0s=", - "dev": true, - "requires": { - "pinkie-promise": "^2.0.0" - } - }, - "path-type": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/path-type/-/path-type-1.1.0.tgz", - "integrity": "sha1-WcRPfuSR2nBNpBXaWkBwuk+P5EE=", - "dev": true, - "requires": { - "graceful-fs": "^4.1.2", - "pify": "^2.0.0", - "pinkie-promise": "^2.0.0" - } - }, - "pify": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz", - "integrity": "sha1-7RQaasBDqEnqWISY59yosVMw6Qw=", - "dev": true - }, - "read-pkg": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/read-pkg/-/read-pkg-1.1.0.tgz", - "integrity": "sha1-9f+qXs0pyzHAR0vKfXVra7KePyg=", - "dev": true, - "requires": { - "load-json-file": "^1.0.0", - "normalize-package-data": "^2.3.2", - "path-type": "^1.0.0" - } - }, - "read-pkg-up": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/read-pkg-up/-/read-pkg-up-1.0.1.tgz", - "integrity": "sha1-nWPBMnbAZZGNV/ACpX9AobZD+wI=", - "dev": true, - "requires": { - "find-up": "^1.0.0", - "read-pkg": "^1.0.0" - } - }, - "strip-bom": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-2.0.0.tgz", - "integrity": "sha1-YhmoVhZSBJHzV4i9vxRHqZx+aw4=", - "dev": true, - "requires": { - "is-utf8": "^0.2.0" - } - }, - "which-module": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/which-module/-/which-module-1.0.0.tgz", - "integrity": "sha1-u6Y8qGGUiZT/MHc2CJ47lgJsKk8=", - "dev": true - }, - "yargs": { - "version": "4.8.1", - "resolved": "https://registry.npmjs.org/yargs/-/yargs-4.8.1.tgz", - "integrity": "sha1-wMQpJMpKqmsObaFznfshZDn53cA=", - "dev": true, - "requires": { - "cliui": "^3.2.0", - "decamelize": "^1.1.1", - "get-caller-file": "^1.0.1", - "lodash.assign": "^4.0.3", - "os-locale": "^1.4.0", - "read-pkg-up": "^1.0.1", - "require-directory": "^2.1.1", - "require-main-filename": "^1.0.1", - "set-blocking": "^2.0.0", - "string-width": "^1.0.1", - "which-module": "^1.0.0", - "window-size": "^0.2.0", - "y18n": "^3.2.1", - "yargs-parser": "^2.4.1" - } - }, - "yargs-parser": { - "version": "2.4.1", - "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-2.4.1.tgz", - "integrity": "sha1-hVaN488VD/SfpRgl8DqMiA3cxcQ=", - "dev": true, - "requires": { - "camelcase": "^3.0.0", - "lodash.assign": "^4.0.6" - } - } - } - }, "optionator": { "version": "0.8.2", "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.8.2.tgz", @@ -11061,14 +11417,14 @@ "dev": true }, "os-locale": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/os-locale/-/os-locale-2.1.0.tgz", - "integrity": "sha512-3sslG3zJbEYcaC4YVAvDorjGxc7tv6KVATnLPZONiljsUncvihe9BQoVCEs0RZ1kmf4Hk9OBqlZfJZWI4GanKA==", + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/os-locale/-/os-locale-3.1.0.tgz", + "integrity": "sha512-Z8l3R4wYWM40/52Z+S265okfFj8Kt2cC2MKY+xNi3kFs+XGI7WXu/I309QQQYbRW4ijiZ+yxs9pqEhJh0DqW3Q==", "dev": true, "requires": { - "execa": "^0.7.0", - "lcid": "^1.0.0", - "mem": "^1.1.0" + "execa": "^1.0.0", + "lcid": "^2.0.0", + "mem": "^4.0.0" } }, "os-tmpdir": { @@ -11083,6 +11439,12 @@ "integrity": "sha512-HNa1A8LvB1kie7cERyy21VNeHb2CWJJYqyyC2o3klWFfMGlFmWv2Z7sFgZH8ZiaYL95ydToKTFVXgMV/Os0bBQ==", "dev": true }, + "p-defer": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/p-defer/-/p-defer-1.0.0.tgz", + "integrity": "sha1-n26xgvbJqozXQwBKfU+WsZaw+ww=", + "dev": true + }, "p-finally": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/p-finally/-/p-finally-1.0.0.tgz", @@ -11096,9 +11458,9 @@ "dev": true }, "p-limit": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.2.0.tgz", - "integrity": "sha512-pZbTJpoUsCzV48Mc9Nh51VbwO0X9cuPFE8gYwx9BTCt9SF8/b7Zljd2fVgOxhIF/HDTKgpVzs+GPhyKfjLLFRQ==", + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.2.1.tgz", + "integrity": "sha512-85Tk+90UCVWvbDavCLKPOLC9vvY8OwEX/RtKF+/1OADJMVlFfEHOiMTPVyxg7mk/dKa+ipdHm0OUkTvCpMTuwg==", "dev": true, "requires": { "p-try": "^2.0.0" @@ -11123,78 +11485,11 @@ } }, "p-try": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/p-try/-/p-try-2.1.0.tgz", - "integrity": "sha512-H2RyIJ7+A3rjkwKC2l5GGtU4H1vkxKCAGsWasNVd0Set+6i4znxbWy6/j16YDPJDWxhsgZiKAstMEP8wCdSpjA==", + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/p-try/-/p-try-2.2.0.tgz", + "integrity": "sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==", "dev": true }, - "pac-proxy-agent": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/pac-proxy-agent/-/pac-proxy-agent-3.0.0.tgz", - "integrity": "sha512-AOUX9jES/EkQX2zRz0AW7lSx9jD//hQS8wFXBvcnd/J2Py9KaMJMqV/LPqJssj1tgGufotb2mmopGPR15ODv1Q==", - "dev": true, - "requires": { - "agent-base": "^4.2.0", - "debug": "^3.1.0", - "get-uri": "^2.0.0", - "http-proxy-agent": "^2.1.0", - "https-proxy-agent": "^2.2.1", - "pac-resolver": "^3.0.0", - "raw-body": "^2.2.0", - "socks-proxy-agent": "^4.0.1" - }, - "dependencies": { - "bytes": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.0.0.tgz", - "integrity": "sha1-0ygVQE1olpn4Wk6k+odV3ROpYEg=", - "dev": true - }, - "debug": { - "version": "3.2.6", - "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.6.tgz", - "integrity": "sha512-mel+jf7nrtEl5Pn1Qx46zARXKDpBbvzezse7p7LqINmdoIk8PYP5SySaxEmYv6TZ0JyEKA1hsCId6DIhgITtWQ==", - "dev": true, - "requires": { - "ms": "^2.1.1" - } - }, - "iconv-lite": { - "version": "0.4.23", - "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.23.tgz", - "integrity": "sha512-neyTUVFtahjf0mB3dZT77u+8O0QB89jFdnBkd5P1JgYPbPaia3gXXOVL2fq8VyU2gMMD7SaN7QukTB/pmXYvDA==", - "dev": true, - "requires": { - "safer-buffer": ">= 2.1.2 < 3" - } - }, - "raw-body": { - "version": "2.3.3", - "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.3.3.tgz", - "integrity": "sha512-9esiElv1BrZoI3rCDuOuKCBRbuApGGaDPQfjSflGxdy4oyzqghxu6klEkkVIvBje+FF0BX9coEv8KqW6X/7njw==", - "dev": true, - "requires": { - "bytes": "3.0.0", - "http-errors": "1.6.3", - "iconv-lite": "0.4.23", - "unpipe": "1.0.0" - } - } - } - }, - "pac-resolver": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/pac-resolver/-/pac-resolver-3.0.0.tgz", - "integrity": "sha512-tcc38bsjuE3XZ5+4vP96OfhOugrX+JcnpUbhfuc4LuXBLQhoTthOstZeoQJBDnQUDYzYmdImKsbz0xSl1/9qeA==", - "dev": true, - "requires": { - "co": "^4.6.0", - "degenerator": "^1.0.4", - "ip": "^1.1.5", - "netmask": "^1.0.6", - "thunkify": "^2.1.2" - } - }, "pako": { "version": "1.0.10", "resolved": "https://registry.npmjs.org/pako/-/pako-1.0.10.tgz", @@ -11225,21 +11520,144 @@ } }, "parse-domain": { - "version": "2.1.7", - "resolved": "https://registry.npmjs.org/parse-domain/-/parse-domain-2.1.7.tgz", - "integrity": "sha512-yb0VWRwDCe96ML49b3xg+4wScbocpIrFSAdkml8eKq/deH3FiFPBpsC6RTC9ZUtnDhInmXPfNIHsN/v62+TAMA==", + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/parse-domain/-/parse-domain-2.3.2.tgz", + "integrity": "sha512-ywE9/YZwJZ8b2viJybvAyu9xO+4qbuLr0Jx73zoL8bHsDdDrFKWKGJKKEuvyNT0ZN1whQGnUAwdQMnsU0dqlPA==", "dev": true, "requires": { "chai": "^4.2.0", "got": "^8.3.2", "mkdirp": "^0.5.1", - "mocha": "^5.2.0" + "mocha": "^6.1.4", + "npm-run-all": "^4.1.5" + }, + "dependencies": { + "ansi-regex": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.0.tgz", + "integrity": "sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg==", + "dev": true + }, + "debug": { + "version": "3.2.6", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.6.tgz", + "integrity": "sha512-mel+jf7nrtEl5Pn1Qx46zARXKDpBbvzezse7p7LqINmdoIk8PYP5SySaxEmYv6TZ0JyEKA1hsCId6DIhgITtWQ==", + "dev": true, + "requires": { + "ms": "^2.1.1" + } + }, + "diff": { + "version": "3.5.0", + "resolved": "https://registry.npmjs.org/diff/-/diff-3.5.0.tgz", + "integrity": "sha512-A46qtFgd+g7pDZinpnwiRJtxbC1hpgf0uzP3iG89scHk0AUC7A1TGxf5OiiOUv/JMZR8GOt8hL900hV0bOy5xA==", + "dev": true + }, + "glob": { + "version": "7.1.3", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.3.tgz", + "integrity": "sha512-vcfuiIxogLV4DlGBHIUOwI0IbrJ8HWPc4MU7HzviGeNho/UJDfi6B5p3sHeWIQ0KGIU0Jpxi5ZHxemQfLkkAwQ==", + "dev": true, + "requires": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + } + }, + "mocha": { + "version": "6.2.0", + "resolved": "https://registry.npmjs.org/mocha/-/mocha-6.2.0.tgz", + "integrity": "sha512-qwfFgY+7EKAAUAdv7VYMZQknI7YJSGesxHyhn6qD52DV8UcSZs5XwCifcZGMVIE4a5fbmhvbotxC0DLQ0oKohQ==", + "dev": true, + "requires": { + "ansi-colors": "3.2.3", + "browser-stdout": "1.3.1", + "debug": "3.2.6", + "diff": "3.5.0", + "escape-string-regexp": "1.0.5", + "find-up": "3.0.0", + "glob": "7.1.3", + "growl": "1.10.5", + "he": "1.2.0", + "js-yaml": "3.13.1", + "log-symbols": "2.2.0", + "minimatch": "3.0.4", + "mkdirp": "0.5.1", + "ms": "2.1.1", + "node-environment-flags": "1.0.5", + "object.assign": "4.1.0", + "strip-json-comments": "2.0.1", + "supports-color": "6.0.0", + "which": "1.3.1", + "wide-align": "1.1.3", + "yargs": "13.2.2", + "yargs-parser": "13.0.0", + "yargs-unparser": "1.5.0" + } + }, + "ms": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz", + "integrity": "sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg==", + "dev": true + }, + "string-width": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-3.1.0.tgz", + "integrity": "sha512-vafcv6KjVZKSgz06oM/H6GDBrAtz8vdhQakGjFIvNrHA6y3HCF1CInLy+QLq8dTJPQ1b+KDUqDFctkdRW44e1w==", + "dev": true, + "requires": { + "emoji-regex": "^7.0.1", + "is-fullwidth-code-point": "^2.0.0", + "strip-ansi": "^5.1.0" + } + }, + "strip-ansi": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-5.2.0.tgz", + "integrity": "sha512-DuRs1gKbBqsMKIZlrffwlug8MHkcnpjs5VPmL1PAh+mA30U0DTotfDZ0d2UUsXpPmPmMMJ6W773MaA3J+lbiWA==", + "dev": true, + "requires": { + "ansi-regex": "^4.1.0" + } + }, + "supports-color": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-6.0.0.tgz", + "integrity": "sha512-on9Kwidc1IUQo+bQdhi8+Tijpo0e1SS6RoGo2guUwn5vdaxw8RXOF9Vb2ws+ihWOmh4JnCJOvaziZWP1VABaLg==", + "dev": true, + "requires": { + "has-flag": "^3.0.0" + } + }, + "yargs": { + "version": "13.2.2", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-13.2.2.tgz", + "integrity": "sha512-WyEoxgyTD3w5XRpAQNYUB9ycVH/PQrToaTXdYXRdOXvEy1l19br+VJsc0vcO8PTGg5ro/l/GY7F/JMEBmI0BxA==", + "dev": true, + "requires": { + "cliui": "^4.0.0", + "find-up": "^3.0.0", + "get-caller-file": "^2.0.1", + "os-locale": "^3.1.0", + "require-directory": "^2.1.1", + "require-main-filename": "^2.0.0", + "set-blocking": "^2.0.0", + "string-width": "^3.0.0", + "which-module": "^2.0.0", + "y18n": "^4.0.0", + "yargs-parser": "^13.0.0" + } + } } }, "parse-entities": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/parse-entities/-/parse-entities-1.2.1.tgz", - "integrity": "sha512-NBWYLQm1KSoDKk7GAHyioLTvCZ5QjdH/ASBBQTD3iLiAWJXS5bg1jEWI8nIJ+vgVvsceBVBcDGRWSo0KVQBvvg==", + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/parse-entities/-/parse-entities-1.2.2.tgz", + "integrity": "sha512-NzfpbxW/NPrzZ/yYSoQxyqUZMZXIdCfE0OIN4ESsnptHJECoUk3FZktxNuzQf4tjt5UEopnxpYJbvYuxIFDdsg==", "dev": true, "requires": { "character-entities": "^1.0.0", @@ -11362,9 +11780,9 @@ } }, "parseurl": { - "version": "1.3.2", - "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.2.tgz", - "integrity": "sha1-/CidTtiZMRlGDBViUyYs3I3mW/M=", + "version": "1.3.3", + "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz", + "integrity": "sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ==", "dev": true }, "pascalcase": { @@ -11374,9 +11792,9 @@ "dev": true }, "path-browserify": { - "version": "0.0.0", - "resolved": "https://registry.npmjs.org/path-browserify/-/path-browserify-0.0.0.tgz", - "integrity": "sha1-oLhwcpquIUAFt9UDLsLLuw+0RRo=", + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/path-browserify/-/path-browserify-0.0.1.tgz", + "integrity": "sha512-BapA40NHICOS+USX9SN4tyhq+A2RrN/Ws5F0Z5aMHDp98Fl86lX8Oti8B7uN93L4Ifv4fHOEA+pQw87gmMO/lQ==", "dev": true }, "path-dirname": { @@ -11510,6 +11928,12 @@ "integrity": "sha1-Ywn04OX6kT7BxpMHrjZLSzd8nns=", "dev": true }, + "pidtree": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/pidtree/-/pidtree-0.3.0.tgz", + "integrity": "sha512-9CT4NFlDcosssyg8KVFltgokyKZIFjoBxw8CTGy+5F38Y1eQWrt8tRayiUOXE+zVKQnYu5BR8JjCtvK3BcnBhg==", + "dev": true + }, "pify": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/pify/-/pify-4.0.1.tgz", @@ -11550,6 +11974,17 @@ "arr-diff": "^4.0.0", "arr-union": "^3.1.0", "extend-shallow": "^3.0.2" + }, + "dependencies": { + "ansi-colors": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/ansi-colors/-/ansi-colors-1.1.0.tgz", + "integrity": "sha512-SFKX67auSNoVR38N3L+nvsPjOE0bybKTYbkf5tRvushrAPQ9V75huw0ZxBkKVeRU9kqH3d6HA4xTckbwZ4ixmA==", + "dev": true, + "requires": { + "ansi-wrap": "^0.1.0" + } + } } }, "pluralize": { @@ -11601,9 +12036,9 @@ "dev": true }, "process-nextick-args": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.0.tgz", - "integrity": "sha512-MtEC1TqN0EU5nephaJ4rAtThHtC86dNN9qCuEhtshvpVBkAW5ZO7BASN9REnF9eoXGcRub+pFuKEpOHE+HbEMw==", + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz", + "integrity": "sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==", "dev": true }, "progress": { @@ -11624,39 +12059,16 @@ "integrity": "sha512-Fx65lf9/YDn3hUX08XUc0J8rSux36rEsyiv21ZGUC1mOyeM3lTRpZLcrm8aAolzS4itwVfm7TAPyxC2E5zd6xg==", "dev": true }, - "proxy-agent": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/proxy-agent/-/proxy-agent-3.1.0.tgz", - "integrity": "sha512-IkbZL4ClW3wwBL/ABFD2zJ8iP84CY0uKMvBPk/OceQe/cEjrxzN1pMHsLwhbzUoRhG9QbSxYC+Z7LBkTiBNvrA==", + "proxy-addr": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.5.tgz", + "integrity": "sha512-t/7RxHXPH6cJtP0pRG6smSr9QJidhB+3kXu0KgXnbGYMgzEnUxRQ4/LDdfOwZEMyIh3/xHb8PX3t+lfL9z+YVQ==", "dev": true, "requires": { - "agent-base": "^4.2.0", - "debug": "^3.1.0", - "http-proxy-agent": "^2.1.0", - "https-proxy-agent": "^2.2.1", - "lru-cache": "^4.1.2", - "pac-proxy-agent": "^3.0.0", - "proxy-from-env": "^1.0.0", - "socks-proxy-agent": "^4.0.1" - }, - "dependencies": { - "debug": { - "version": "3.2.6", - "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.6.tgz", - "integrity": "sha512-mel+jf7nrtEl5Pn1Qx46zARXKDpBbvzezse7p7LqINmdoIk8PYP5SySaxEmYv6TZ0JyEKA1hsCId6DIhgITtWQ==", - "dev": true, - "requires": { - "ms": "^2.1.1" - } - } + "forwarded": "~0.1.2", + "ipaddr.js": "1.9.0" } }, - "proxy-from-env": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.0.0.tgz", - "integrity": "sha1-M8UDmPcOp+uW0h97gXYwpVeRx+4=", - "dev": true - }, "prr": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/prr/-/prr-1.0.1.tgz", @@ -11679,9 +12091,9 @@ "dev": true }, "psl": { - "version": "1.1.31", - "resolved": "https://registry.npmjs.org/psl/-/psl-1.1.31.tgz", - "integrity": "sha512-/6pt4+C+T+wZUieKR620OpzN/LlnNKuWjy1iFLQ/UG35JqHlR/89MP1d96dUfkf6Dne3TuLQzOYEYshJ+Hx8mw==", + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/psl/-/psl-1.4.0.tgz", + "integrity": "sha512-HZzqCGPecFLyoRj5HLfuDSKYTJkAfB5thKBIkRHtGjWwY7p1dAyveIbXIq4tO0KYfDF2tHqPUgY9SDnGm00uFw==", "dev": true }, "public-encrypt": { @@ -11699,9 +12111,9 @@ } }, "pump": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/pump/-/pump-2.0.1.tgz", - "integrity": "sha512-ruPMNRkN3MHP1cWJc9OWr+T/xDP0jhXYCLfJcBuX54hhfIBnaQmAUMfDcG4DM5UMWByBbJY69QSphm3jtDKIkA==", + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/pump/-/pump-3.0.0.tgz", + "integrity": "sha512-LwZy+p3SFs1Pytd/jYct4wpv49HiYCqd9Rlc5ZVdk0V+8Yzv6jR5Blk3TRmPL1ft69TxP0IMZGJ+WPFU2BFhww==", "dev": true, "requires": { "end-of-stream": "^1.1.0", @@ -11717,6 +12129,18 @@ "duplexify": "^3.6.0", "inherits": "^2.0.3", "pump": "^2.0.0" + }, + "dependencies": { + "pump": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/pump/-/pump-2.0.1.tgz", + "integrity": "sha512-ruPMNRkN3MHP1cWJc9OWr+T/xDP0jhXYCLfJcBuX54hhfIBnaQmAUMfDcG4DM5UMWByBbJY69QSphm3jtDKIkA==", + "dev": true, + "requires": { + "end-of-stream": "^1.1.0", + "once": "^1.3.1" + } + } } }, "punycode": { @@ -11810,9 +12234,9 @@ } }, "range-parser": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.0.tgz", - "integrity": "sha1-9JvmtIeJTdxA3MlKMi9hEJLgDV4=", + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.1.tgz", + "integrity": "sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg==", "dev": true }, "raw-body": { @@ -11951,9 +12375,9 @@ "dev": true }, "regenerate-unicode-properties": { - "version": "8.0.2", - "resolved": "https://registry.npmjs.org/regenerate-unicode-properties/-/regenerate-unicode-properties-8.0.2.tgz", - "integrity": "sha512-SbA/iNrBUf6Pv2zU8Ekv1Qbhv92yxL4hiDa2siuxs4KKn4oOoMDHXjAf7+Nz9qinUQ46B1LcWEi/PhJfPWpZWQ==", + "version": "8.1.0", + "resolved": "https://registry.npmjs.org/regenerate-unicode-properties/-/regenerate-unicode-properties-8.1.0.tgz", + "integrity": "sha512-LGZzkgtLY79GeXLm8Dp0BVLdQlWICzBnJz/ipWUgo59qBaZ+BHtq51P2q1uVZlppMuUAT37SDk39qUbjTWB7bA==", "dev": true, "requires": { "regenerate": "^1.4.0" @@ -11965,9 +12389,9 @@ "integrity": "sha512-MguG95oij0fC3QV3URf4V2SDYGJhJnJGqvIIgdECeODCT98wSWDAJ94SSuVpYQUoTcGUIL6L4yNB7j1DFFHSBg==" }, "regenerator-transform": { - "version": "0.13.4", - "resolved": "https://registry.npmjs.org/regenerator-transform/-/regenerator-transform-0.13.4.tgz", - "integrity": "sha512-T0QMBjK3J0MtxjPmdIMXm72Wvj2Abb0Bd4HADdfijwMdoIsyQZ6fWC7kDFhk2YinBBEMZDL7Y7wh0J1sGx3S4A==", + "version": "0.14.1", + "resolved": "https://registry.npmjs.org/regenerator-transform/-/regenerator-transform-0.14.1.tgz", + "integrity": "sha512-flVuee02C3FKRISbxhXl9mGzdbWUVHubl1SMaknjxkFB1/iqpJhArQUvRxOOPEc/9tAiX0BaQ28FJH10E4isSQ==", "dev": true, "requires": { "private": "^0.1.6" @@ -11993,9 +12417,9 @@ } }, "regexp-tree": { - "version": "0.1.5", - "resolved": "https://registry.npmjs.org/regexp-tree/-/regexp-tree-0.1.5.tgz", - "integrity": "sha512-nUmxvfJyAODw+0B13hj8CFVAxhe7fDEAgJgaotBu3nnR+IgGgZq59YedJP5VYTlkEfqjuK6TuRpnymKdatLZfQ==", + "version": "0.1.13", + "resolved": "https://registry.npmjs.org/regexp-tree/-/regexp-tree-0.1.13.tgz", + "integrity": "sha512-hwdV/GQY5F8ReLZWO+W1SRoN5YfpOKY6852+tBFcma72DKBIcHjPRIlIvQN35bCOljuAfP2G2iB0FC/w236mUw==", "dev": true }, "regexpp": { @@ -12005,13 +12429,13 @@ "dev": true }, "regexpu-core": { - "version": "4.5.4", - "resolved": "https://registry.npmjs.org/regexpu-core/-/regexpu-core-4.5.4.tgz", - "integrity": "sha512-BtizvGtFQKGPUcTy56o3nk1bGRp4SZOTYrDtGNlqCQufptV5IkkLN6Emw+yunAJjzf+C9FQFtvq7IoA3+oMYHQ==", + "version": "4.5.5", + "resolved": "https://registry.npmjs.org/regexpu-core/-/regexpu-core-4.5.5.tgz", + "integrity": "sha512-FpI67+ky9J+cDizQUJlIlNZFKual/lUkFr1AG6zOCpwZ9cLrg8UUVakyUQJD7fCDIe9Z2nwTQJNPyonatNmDFQ==", "dev": true, "requires": { "regenerate": "^1.4.0", - "regenerate-unicode-properties": "^8.0.2", + "regenerate-unicode-properties": "^8.1.0", "regjsgen": "^0.5.0", "regjsparser": "^0.6.0", "unicode-match-property-ecmascript": "^1.0.4", @@ -12088,18 +12512,18 @@ } }, "remark-reference-links": { - "version": "4.0.3", - "resolved": "https://registry.npmjs.org/remark-reference-links/-/remark-reference-links-4.0.3.tgz", - "integrity": "sha512-Q9d7JaK5r0JDBo3TInfrodBuI3xulI8htCr8jlX+0oXosF3GaebJbo5y228VYFoV6xJ+syDukkUGMKNlwSJWjQ==", + "version": "4.0.4", + "resolved": "https://registry.npmjs.org/remark-reference-links/-/remark-reference-links-4.0.4.tgz", + "integrity": "sha512-+2X8hwSQqxG4tvjYZNrTcEC+bXp8shQvwRGG6J/rnFTvBoU4G0BBviZoqKGZizLh/DG+0gSYhiDDWCqyxXW1iQ==", "dev": true, "requires": { "unist-util-visit": "^1.0.0" } }, "remark-slug": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/remark-slug/-/remark-slug-5.1.1.tgz", - "integrity": "sha512-r591rdoDPJkSSAVvEaTVUkqbMp7c7AyZfif14V0Dp66GQkOHzaPAS6wyhawSbqpS0ZdTnfJS+TltFoxzi6bdIA==", + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/remark-slug/-/remark-slug-5.1.2.tgz", + "integrity": "sha512-DWX+Kd9iKycqyD+/B+gEFO3jjnt7Yg1O05lygYSNTe5i5PIxxxPjp5qPBDxPIzp5wreF7+1ROCwRgjEcqmzr3A==", "dev": true, "requires": { "github-slugger": "^1.0.0", @@ -12252,6 +12676,27 @@ "uuid": "^3.3.2" } }, + "request-promise": { + "version": "4.2.4", + "resolved": "https://registry.npmjs.org/request-promise/-/request-promise-4.2.4.tgz", + "integrity": "sha512-8wgMrvE546PzbR5WbYxUQogUnUDfM0S7QIFZMID+J73vdFARkFy+HElj4T+MWYhpXwlLp0EQ8Zoj8xUA0he4Vg==", + "dev": true, + "requires": { + "bluebird": "^3.5.0", + "request-promise-core": "1.1.2", + "stealthy-require": "^1.1.1", + "tough-cookie": "^2.3.3" + } + }, + "request-promise-core": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/request-promise-core/-/request-promise-core-1.1.2.tgz", + "integrity": "sha512-UHYyq1MO8GsefGEt7EprS8UrXsm1TxEvFUX1IMTuSLU2Rh7fTIdFtl8xD7JiEYiWU2dl+NYAjCTksTehQUxPag==", + "dev": true, + "requires": { + "lodash": "^4.17.11" + } + }, "require-directory": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", @@ -12259,9 +12704,9 @@ "dev": true }, "require-main-filename": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/require-main-filename/-/require-main-filename-1.0.1.tgz", - "integrity": "sha1-l/cXtp1IeE9fUmpsWqj/3aBVpNE=", + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/require-main-filename/-/require-main-filename-2.0.0.tgz", + "integrity": "sha512-NKN5kMDylKuldxYLSUfrbo5Tuzh4hd+2E8NPPX02mZtn1VuREQToYe/ZdlJy+J3uCpfaiGF05e7B8W0iXbQHmg==", "dev": true }, "require-uncached": { @@ -12272,6 +12717,14 @@ "requires": { "caller-path": "^0.1.0", "resolve-from": "^1.0.0" + }, + "dependencies": { + "resolve-from": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-1.0.1.tgz", + "integrity": "sha1-Jsv+k10a7uq7Kbw/5a6wHpPUQiY=", + "dev": true + } } }, "requires-port": { @@ -12281,9 +12734,9 @@ "dev": true }, "resolve": { - "version": "1.10.0", - "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.10.0.tgz", - "integrity": "sha512-3sUr9aq5OfSg2S9pNtPA9hL1FVEAjvfOC4leW0SNf/mpnaakz2a9femSd6LqAww2RaFctwyf1lCqnTHuF1rxDg==", + "version": "1.12.0", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.12.0.tgz", + "integrity": "sha512-B/dOmuoAik5bKcD6s6nXDCjzUKnaDvdkRyAk6rsmsKLipWj4797iothd7jmmUhWTfinVMU+wc56rYKsit2Qy4w==", "dev": true, "requires": { "path-parse": "^1.0.6" @@ -12300,9 +12753,9 @@ } }, "resolve-from": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-1.0.1.tgz", - "integrity": "sha1-Jsv+k10a7uq7Kbw/5a6wHpPUQiY=", + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-5.0.0.tgz", + "integrity": "sha512-qYg9KP24dD5qka9J47d0aVky0N+b4fTU89LN9iDnjB5waksiC49rvMB0PrUJQGoTmH50XPiqOvAjDfaijGxYZw==", "dev": true }, "resolve-options": { @@ -12346,9 +12799,15 @@ "dev": true }, "rfdc": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/rfdc/-/rfdc-1.1.2.tgz", - "integrity": "sha512-92ktAgvZhBzYTIK0Mja9uen5q5J3NRVMoDkJL2VMwq6SXjVCgqvQeVP2XAaUY6HT+XpQYeLSjb3UoitBryKmdA==", + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/rfdc/-/rfdc-1.1.4.tgz", + "integrity": "sha512-5C9HXdzK8EAqN7JDif30jqsBzavB7wLpaubisuQIGHWf2gUXSpzy6ArX/+Da8RjFpagWsCn+pIgxTMAmKw9Zug==", + "dev": true + }, + "rgb2hex": { + "version": "0.1.9", + "resolved": "https://registry.npmjs.org/rgb2hex/-/rgb2hex-0.1.9.tgz", + "integrity": "sha512-32iuQzhOjyT+cv9aAFRBJ19JgHwzQwbjUhH3Fj2sWW2EEGAW8fpFrDFP5ndoKDxJaLO06x1hE3kyuIFrUQtybQ==", "dev": true }, "right-align": { @@ -12428,9 +12887,9 @@ "dev": true }, "samsam": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/samsam/-/samsam-1.1.2.tgz", - "integrity": "sha1-vsEf3IOp/aBjQBIQ5AF2wwJNFWc=", + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/samsam/-/samsam-1.3.0.tgz", + "integrity": "sha512-1HwIYD/8UlOtFS3QO3w7ey+SdSDFE4HRNLZoZRYVQefrOY3l17epswImeB1ijgJFQJodIaHcwkp3r/myBjFVbg==", "dev": true }, "schema-utils": { @@ -12443,9 +12902,9 @@ } }, "semver": { - "version": "5.6.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-5.6.0.tgz", - "integrity": "sha512-RS9R6R35NYgQn++fkDWaOmqGoj4Ek9gGs+DPxNUZKuwE183xjJroKvyo1IzVFeXvUrvmALy6FWD5xrdJT25gMg==", + "version": "5.7.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz", + "integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==", "dev": true }, "semver-greatest-satisfied-range": { @@ -12528,29 +12987,94 @@ "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", "dev": true, "requires": { - "ms": "2.0.0" + "ms": "2.0.0" + } + }, + "ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", + "dev": true + } + } + }, + "serve-static": { + "version": "1.14.1", + "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.14.1.tgz", + "integrity": "sha512-JMrvUwE54emCYWlTI+hGrGv5I8dEwmco/00EvkzIIsR7MqrHonbD9pO2MOfFnpFntl7ecpZs+3mW+XbQZu9QCg==", + "dev": true, + "requires": { + "encodeurl": "~1.0.2", + "escape-html": "~1.0.3", + "parseurl": "~1.3.3", + "send": "0.17.1" + }, + "dependencies": { + "debug": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "dev": true, + "requires": { + "ms": "2.0.0" + }, + "dependencies": { + "ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", + "dev": true + } + } + }, + "http-errors": { + "version": "1.7.3", + "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.7.3.tgz", + "integrity": "sha512-ZTTX0MWrsQ2ZAhA1cejAwDLycFsd7I7nVtnkT3Ol0aqodaKW+0CTZDQ1uBv5whptCnc8e8HeRRJxRs0kmm/Qfw==", + "dev": true, + "requires": { + "depd": "~1.1.2", + "inherits": "2.0.4", + "setprototypeof": "1.1.1", + "statuses": ">= 1.5.0 < 2", + "toidentifier": "1.0.0" + } + }, + "ms": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz", + "integrity": "sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg==", + "dev": true + }, + "send": { + "version": "0.17.1", + "resolved": "https://registry.npmjs.org/send/-/send-0.17.1.tgz", + "integrity": "sha512-BsVKsiGcQMFwT8UxypobUKyv7irCNRHk1T0G680vk88yf6LBByGcZJOTJCrTP2xVN6yI+XjPJcNuE3V4fT9sAg==", + "dev": true, + "requires": { + "debug": "2.6.9", + "depd": "~1.1.2", + "destroy": "~1.0.4", + "encodeurl": "~1.0.2", + "escape-html": "~1.0.3", + "etag": "~1.8.1", + "fresh": "0.5.2", + "http-errors": "~1.7.2", + "mime": "1.6.0", + "ms": "2.1.1", + "on-finished": "~2.3.0", + "range-parser": "~1.2.1", + "statuses": "~1.5.0" } }, - "ms": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", - "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", + "setprototypeof": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.1.1.tgz", + "integrity": "sha512-JvdAWfbXeIGaZ9cILp38HntZSFSo3mWg6xGcJJsd+d4aRMOqauag1C63dJfDw7OaMYwEbHMOxEZ1lqVRYP2OAw==", "dev": true } } }, - "serve-static": { - "version": "1.13.2", - "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.13.2.tgz", - "integrity": "sha512-p/tdJrO4U387R9oMjb1oj7qSMaMfmOyd4j9hOFoxZe2baQszgHcSWjuya/CiT5kgZZKRudHNOA0pYXOl8rQ5nw==", - "dev": true, - "requires": { - "encodeurl": "~1.0.2", - "escape-html": "~1.0.3", - "parseurl": "~1.3.2", - "send": "0.16.2" - } - }, "set-blocking": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/set-blocking/-/set-blocking-2.0.0.tgz", @@ -12558,9 +13082,9 @@ "dev": true }, "set-value": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/set-value/-/set-value-2.0.0.tgz", - "integrity": "sha512-hw0yxk9GT/Hr5yJEYnHNKYXkIA8mVJgd9ditYZCe16ZczcaELYYcfvaXesNACk2O8O0nTiPQcQhGUQj8JLzeeg==", + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/set-value/-/set-value-2.0.1.tgz", + "integrity": "sha512-JxHc1weCN68wRY0fhCoXpyK55m/XPHafOmK4UWD7m2CI14GMcFypt4w/0+NV5f/ZMby2F6S2wwA7fgynh9gWSw==", "dev": true, "requires": { "extend-shallow": "^2.0.1", @@ -12617,6 +13141,12 @@ "integrity": "sha1-2kL0l0DAtC2yypcoVxyxkMmO/qM=", "dev": true }, + "shell-quote": { + "version": "1.7.2", + "resolved": "https://registry.npmjs.org/shell-quote/-/shell-quote-1.7.2.tgz", + "integrity": "sha512-mRz/m/JVscCrkMyPqHc/bczi3OQHkLTqXHEFu0zDhK/qfv3UcOA4SVmRCLmos4bhjr9ekVQubj/R7waKapmiQg==", + "dev": true + }, "shelljs": { "version": "0.8.3", "resolved": "https://registry.npmjs.org/shelljs/-/shelljs-0.8.3.tgz", @@ -12654,12 +13184,6 @@ "resolved": "https://registry.npmjs.org/diff/-/diff-3.5.0.tgz", "integrity": "sha512-A46qtFgd+g7pDZinpnwiRJtxbC1hpgf0uzP3iG89scHk0AUC7A1TGxf5OiiOUv/JMZR8GOt8hL900hV0bOy5xA==", "dev": true - }, - "lolex": { - "version": "2.7.5", - "resolved": "https://registry.npmjs.org/lolex/-/lolex-2.7.5.tgz", - "integrity": "sha512-l9x0+1offnKKIzYVjyXU2SiwhXDLekRzKyhnbyldPHvC7BvLPVpdNUNR2KeMAiCN2D/kLNttZgQD5WjSxuBx3Q==", - "dev": true } } }, @@ -12676,22 +13200,8 @@ "dev": true, "requires": { "is-fullwidth-code-point": "^2.0.0" - }, - "dependencies": { - "is-fullwidth-code-point": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz", - "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=", - "dev": true - } } }, - "smart-buffer": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/smart-buffer/-/smart-buffer-4.0.2.tgz", - "integrity": "sha512-JDhEpTKzXusOqXZ0BUIdH+CjFdO/CR3tLlf5CN34IypI+xMmXW1uB16OOY8z3cICbJlDAVJzNbwBhNO0wt9OAw==", - "dev": true - }, "snapdragon": { "version": "0.8.2", "resolved": "https://registry.npmjs.org/snapdragon/-/snapdragon-0.8.2.tgz", @@ -12873,6 +13383,12 @@ "to-array": "0.1.4" }, "dependencies": { + "component-emitter": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/component-emitter/-/component-emitter-1.2.1.tgz", + "integrity": "sha1-E3kY1teCg/ffemt8WmPhQOaUJeY=", + "dev": true + }, "debug": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz", @@ -12901,6 +13417,12 @@ "isarray": "2.0.1" }, "dependencies": { + "component-emitter": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/component-emitter/-/component-emitter-1.2.1.tgz", + "integrity": "sha1-E3kY1teCg/ffemt8WmPhQOaUJeY=", + "dev": true + }, "debug": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz", @@ -12924,26 +13446,6 @@ } } }, - "socks": { - "version": "2.3.2", - "resolved": "https://registry.npmjs.org/socks/-/socks-2.3.2.tgz", - "integrity": "sha512-pCpjxQgOByDHLlNqlnh/mNSAxIUkyBBuwwhTcV+enZGbDaClPvHdvm6uvOwZfFJkam7cGhBNbb4JxiP8UZkRvQ==", - "dev": true, - "requires": { - "ip": "^1.1.5", - "smart-buffer": "4.0.2" - } - }, - "socks-proxy-agent": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/socks-proxy-agent/-/socks-proxy-agent-4.0.2.tgz", - "integrity": "sha512-NT6syHhI9LmuEMSK6Kd2V7gNv5KFZoLE7V5udWmn0de+3Mkj3UMA/AJPLyeNUVmElCurSHtUdM3ETpR3z770Wg==", - "dev": true, - "requires": { - "agent-base": "~4.2.1", - "socks": "~2.3.2" - } - }, "sort-keys": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/sort-keys/-/sort-keys-1.1.2.tgz", @@ -12994,13 +13496,10 @@ "dev": true }, "space-separated-tokens": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/space-separated-tokens/-/space-separated-tokens-1.1.2.tgz", - "integrity": "sha512-G3jprCEw+xFEs0ORweLmblJ3XLymGGr6hxZYTYZjIlvDti9vOBUjRQa1Rzjt012aRrocKstHwdNi+F7HguPsEA==", - "dev": true, - "requires": { - "trim": "0.0.1" - } + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/space-separated-tokens/-/space-separated-tokens-1.1.4.tgz", + "integrity": "sha512-UyhMSmeIqZrQn2UdjYpxEkwY9JUrn8pP+7L4f91zRzOQuI8MF1FGLfYU9DKCYeLdo7LXMxwrX5zKFy7eeeVHuA==", + "dev": true }, "sparkles": { "version": "1.0.1", @@ -13035,9 +13534,9 @@ } }, "spdx-license-ids": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/spdx-license-ids/-/spdx-license-ids-3.0.3.tgz", - "integrity": "sha512-uBIcIl3Ih6Phe3XHK1NqboJLdGfwr1UN3k6wSD1dZpmPsIkb8AGNbZYJ1fOBk834+Gxy8rpfDxrS6XLEMZMY2g==", + "version": "3.0.5", + "resolved": "https://registry.npmjs.org/spdx-license-ids/-/spdx-license-ids-3.0.5.tgz", + "integrity": "sha512-J+FWzZoynJEXGphVIS+XEh3kFSjZX/1i9gFBaWQcB+/tmpe2qUsSBABpcxqxnAxFdiUFEgAX1bjYGQvIZmoz9Q==", "dev": true }, "split": { @@ -13088,9 +13587,9 @@ "dev": true }, "state-toggle": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/state-toggle/-/state-toggle-1.0.1.tgz", - "integrity": "sha512-Qe8QntFrrpWTnHwvwj2FZTgv+PKIsp0B9VxLzLLbSpPXWOgRgc5LVj/aTiSfK1RqIeF9jeC1UeOH8Q8y60A7og==", + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/state-toggle/-/state-toggle-1.0.2.tgz", + "integrity": "sha512-8LpelPGR0qQM4PnfLiplOQNJcIN1/r2Gy0xKB2zKnIW2YzPMt2sR4I/+gtPjhN7Svh9kw+zqEg2SFwpBO9iNiw==", "dev": true }, "static-extend": { @@ -13115,9 +13614,15 @@ } }, "statuses": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.3.1.tgz", - "integrity": "sha1-+vUbnrdKrvOzrPStX2Gr8ky3uT4=", + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.5.0.tgz", + "integrity": "sha1-Fhx9rBd2Wf2YEfQ3cfqZOBR4Yow=", + "dev": true + }, + "stealthy-require": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/stealthy-require/-/stealthy-require-1.1.1.tgz", + "integrity": "sha1-NbCYdbT/SfJqd35QmzCQoyJr8ks=", "dev": true }, "stream-array": { @@ -13248,14 +13753,61 @@ "dev": true }, "string-width": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz", - "integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=", + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-2.1.1.tgz", + "integrity": "sha512-nOqH59deCq9SRHlxq1Aw85Jnt4w6KvLKqWVik6oA9ZklXLNIOlqg4F2yrT1MVaTjAqvVwdfeZ7w7aCvJD7ugkw==", + "dev": true, + "requires": { + "is-fullwidth-code-point": "^2.0.0", + "strip-ansi": "^4.0.0" + }, + "dependencies": { + "ansi-regex": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.0.tgz", + "integrity": "sha1-7QMXwyIGT3lGbAKWa922Bas32Zg=", + "dev": true + }, + "strip-ansi": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz", + "integrity": "sha1-qEeQIusaw2iocTibY1JixQXuNo8=", + "dev": true, + "requires": { + "ansi-regex": "^3.0.0" + } + } + } + }, + "string.prototype.padend": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/string.prototype.padend/-/string.prototype.padend-3.0.0.tgz", + "integrity": "sha1-86rvfBcZ8XDF6rHDK/eA2W4h8vA=", + "dev": true, + "requires": { + "define-properties": "^1.1.2", + "es-abstract": "^1.4.3", + "function-bind": "^1.0.2" + } + }, + "string.prototype.trimleft": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/string.prototype.trimleft/-/string.prototype.trimleft-2.1.0.tgz", + "integrity": "sha512-FJ6b7EgdKxxbDxc79cOlok6Afd++TTs5szo+zJTUyow3ycrRfJVE2pq3vcN53XexvKZu/DJMDfeI/qMiZTrjTw==", + "dev": true, + "requires": { + "define-properties": "^1.1.3", + "function-bind": "^1.1.1" + } + }, + "string.prototype.trimright": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/string.prototype.trimright/-/string.prototype.trimright-2.1.0.tgz", + "integrity": "sha512-fXZTSV55dNBwv16uw+hh5jkghxSnc5oHq+5K/gXgizHwAvMetdAJlHqqoFC1FSDVPYWLkAKl2cxpUT41sV7nSg==", "dev": true, "requires": { - "code-point-at": "^1.0.0", - "is-fullwidth-code-point": "^1.0.0", - "strip-ansi": "^3.0.0" + "define-properties": "^1.1.3", + "function-bind": "^1.1.1" } }, "string_decoder": { @@ -13361,39 +13913,6 @@ "lodash": "^4.17.4", "slice-ansi": "1.0.0", "string-width": "^2.1.1" - }, - "dependencies": { - "ansi-regex": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.0.tgz", - "integrity": "sha1-7QMXwyIGT3lGbAKWa922Bas32Zg=", - "dev": true - }, - "is-fullwidth-code-point": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz", - "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=", - "dev": true - }, - "string-width": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-2.1.1.tgz", - "integrity": "sha512-nOqH59deCq9SRHlxq1Aw85Jnt4w6KvLKqWVik6oA9ZklXLNIOlqg4F2yrT1MVaTjAqvVwdfeZ7w7aCvJD7ugkw==", - "dev": true, - "requires": { - "is-fullwidth-code-point": "^2.0.0", - "strip-ansi": "^4.0.0" - } - }, - "strip-ansi": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz", - "integrity": "sha1-qEeQIusaw2iocTibY1JixQXuNo8=", - "dev": true, - "requires": { - "ansi-regex": "^3.0.0" - } - } } }, "tapable": { @@ -13402,6 +13921,21 @@ "integrity": "sha512-2wsvQ+4GwBvLPLWsNfLCDYGsW6xb7aeC6utq2Qh0PFwgEy7K7dsma9Jsmb2zSQj7GvYAyUGSntLtsv++GmgL1A==", "dev": true }, + "tar-stream": { + "version": "1.6.2", + "resolved": "https://registry.npmjs.org/tar-stream/-/tar-stream-1.6.2.tgz", + "integrity": "sha512-rzS0heiNf8Xn7/mpdSVVSMAWAoy9bfb1WOTYC78Z0UQKeKa/CWS8FOq0lKGNa8DWKAn9gxjCvMLYc5PGXYlK2A==", + "dev": true, + "requires": { + "bl": "^1.0.0", + "buffer-alloc": "^1.2.0", + "end-of-stream": "^1.0.0", + "fs-constants": "^1.0.0", + "readable-stream": "^2.3.0", + "to-buffer": "^1.1.1", + "xtend": "^4.0.0" + } + }, "temp-fs": { "version": "0.9.9", "resolved": "https://registry.npmjs.org/temp-fs/-/temp-fs-0.9.9.tgz", @@ -13423,9 +13957,9 @@ } }, "ternary-stream": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/ternary-stream/-/ternary-stream-2.0.1.tgz", - "integrity": "sha1-Bk5Im0tb9gumpre8fy9cJ07Pgmk=", + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/ternary-stream/-/ternary-stream-2.1.1.tgz", + "integrity": "sha512-j6ei9hxSoyGlqTmoMjOm+QNvUKDOIY6bNl4Uh1lhBvl6yjPW2iLqxDUYyfDPZknQ4KdRziFl+ec99iT4l7g0cw==", "dev": true, "requires": { "duplexify": "^3.5.0", @@ -13441,9 +13975,9 @@ "dev": true }, "textextensions": { - "version": "2.4.0", - "resolved": "https://registry.npmjs.org/textextensions/-/textextensions-2.4.0.tgz", - "integrity": "sha512-qftQXnX1DzpSV8EddtHIT0eDDEiBF8ywhFYR2lI9xrGtxqKN+CvLXhACeCIGbCpQfxxERbrkZEFb8cZcDKbVZA==", + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/textextensions/-/textextensions-2.5.0.tgz", + "integrity": "sha512-1IkVr355eHcomgK7fgj1Xsokturx6L5S2JRT5WcRdA6v5shk9sxWuO/w/VbpQexwkXJMQIa/j1dBi3oo7+HhcA==", "dev": true }, "through": { @@ -13472,12 +14006,6 @@ "xtend": "~4.0.0" } }, - "thunkify": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/thunkify/-/thunkify-2.1.2.tgz", - "integrity": "sha1-+qDp0jDFGsyVyhOjYawFyn4EVT0=", - "dev": true - }, "time-stamp": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/time-stamp/-/time-stamp-1.1.0.tgz", @@ -13491,9 +14019,9 @@ "dev": true }, "timers-browserify": { - "version": "2.0.10", - "resolved": "https://registry.npmjs.org/timers-browserify/-/timers-browserify-2.0.10.tgz", - "integrity": "sha512-YvC1SV1XdOUaL6gx5CoGroT3Gu49pK9+TZ38ErPldOWW4j49GI1HKs9DV+KGq/w6y+LZ72W1c8cKz2vzY+qpzg==", + "version": "2.0.11", + "resolved": "https://registry.npmjs.org/timers-browserify/-/timers-browserify-2.0.11.tgz", + "integrity": "sha512-60aV6sgJ5YEbzUdn9c8kYGIqOubPoUdqQCul3SBAsRCZ40s6Y5cMcrW4dt3/k/EsbLVJNl9n6Vz3fTc+k2GeKQ==", "dev": true, "requires": { "setimmediate": "^1.0.4" @@ -13565,6 +14093,12 @@ "integrity": "sha1-fSKbH8xjfkZsoIEYCDanqr/4P0M=", "dev": true }, + "to-buffer": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/to-buffer/-/to-buffer-1.1.1.tgz", + "integrity": "sha512-lx9B5iv7msuFYE3dytT+KE5tap+rNYw+K4jVkb9R/asAb+pbBSM17jtunHplhBe6RRJdZx3Pn2Jph24O32mOVg==", + "dev": true + }, "to-fast-properties": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/to-fast-properties/-/to-fast-properties-2.0.0.tgz", @@ -13622,6 +14156,12 @@ "through2": "^2.0.3" } }, + "toidentifier": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.0.tgz", + "integrity": "sha512-yaOH/Pk/VEhBWWTlhI+qXxDFXlejDGcQipMlyxda9nthulaxLZUNcUqFxokp0vcYnvteJln5FNQDRrxj3YcbVw==", + "dev": true + }, "tough-cookie": { "version": "2.4.3", "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.4.3.tgz", @@ -13647,9 +14187,9 @@ "dev": true }, "trim-lines": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/trim-lines/-/trim-lines-1.1.1.tgz", - "integrity": "sha512-X+eloHbgJGxczUk1WSjIvn7aC9oN3jVE3rQfRVKcgpavi3jxtCn0VVKtjOBj64Yop96UYn/ujJRpTbCdAF1vyg==", + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/trim-lines/-/trim-lines-1.1.2.tgz", + "integrity": "sha512-3GOuyNeTqk3FAqc3jOJtw7FTjYl94XBR5aD9QnDbK/T4CA9sW/J0l9RoaRPE9wyPP7NF331qnHnvJFBJ+IDkmQ==", "dev": true }, "trim-newlines": { @@ -13665,15 +14205,21 @@ "dev": true }, "trim-trailing-lines": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/trim-trailing-lines/-/trim-trailing-lines-1.1.1.tgz", - "integrity": "sha512-bWLv9BbWbbd7mlqqs2oQYnLD/U/ZqeJeJwbO0FG2zA1aTq+HTvxfHNKFa/HGCVyJpDiioUYaBhfiT6rgk+l4mg==", + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/trim-trailing-lines/-/trim-trailing-lines-1.1.2.tgz", + "integrity": "sha512-MUjYItdrqqj2zpcHFTkMa9WAv4JHTI6gnRQGPFLrt5L9a6tRMiDnIqYl8JBvu2d2Tc3lWJKQwlGCp0K8AvCM+Q==", "dev": true }, "trough": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/trough/-/trough-1.0.3.tgz", - "integrity": "sha512-fwkLWH+DimvA4YCy+/nvJd61nWQQ2liO/nF/RjkTpiOGi+zxZzVkhb1mvbHIIW4b/8nDsYI8uTmAlc0nNkRMOw==", + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/trough/-/trough-1.0.4.tgz", + "integrity": "sha512-tdzBRDGWcI1OpPVmChbdSKhvSVurznZ8X36AYURAcl+0o2ldlCY2XPzyXNNxwJwwyIU+rIglTCG4kxtNKBQH7Q==", + "dev": true + }, + "tryer": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/tryer/-/tryer-1.0.1.tgz", + "integrity": "sha512-c3zayb8/kWWpycWYg87P71E1S1ZL6b6IJxfb5fvsUgsf0S2MVGaDhDXXjDMpdCpfWXqptc+4mXwmiy1ypXqRAA==", "dev": true }, "tty-browserify": { @@ -13697,6 +14243,12 @@ "integrity": "sha1-WuaBd/GS1EViadEIr6k/+HQ/T2Q=", "dev": true }, + "type": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/type/-/type-1.0.3.tgz", + "integrity": "sha512-51IMtNfVcee8+9GJvj0spSuFcZHe9vSib6Xtgsny1Km9ugyz2mbS08I3rsUIRYgJohFRFU1160sgRodYz378Hg==", + "dev": true + }, "type-check": { "version": "0.3.2", "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.3.2.tgz", @@ -13713,13 +14265,13 @@ "dev": true }, "type-is": { - "version": "1.6.16", - "resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.16.tgz", - "integrity": "sha512-HRkVv/5qY2G6I8iab9cI7v1bOIdhm94dVjQCPFElW9W+3GeDOSHmy2EBYe4VTApuzolPcmgFTN3ftVJRKR2J9Q==", + "version": "1.6.18", + "resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.18.tgz", + "integrity": "sha512-TkRKr9sUTxEH8MdfuCSP7VizJyzRNMjj2J2do2Jr3Kym598JVdEksuzPQCnlFPW4ky9Q+iA+ma9BGm06XQBy8g==", "dev": true, "requires": { "media-typer": "0.3.0", - "mime-types": "~2.1.18" + "mime-types": "~2.1.24" } }, "typedarray": { @@ -13729,21 +14281,15 @@ "dev": true }, "uglify-js": { - "version": "3.5.2", - "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.5.2.tgz", - "integrity": "sha512-imog1WIsi9Yb56yRt5TfYVxGmnWs3WSGU73ieSOlMVFwhJCA9W8fqFFMMj4kgDqiS/80LGdsYnWL7O9UcjEBlg==", + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.6.0.tgz", + "integrity": "sha512-W+jrUHJr3DXKhrsS7NUVxn3zqMOFn0hL/Ei6v0anCIMoKC93TjcflTagwIHLW7SfMFfiQuktQyFVCFHGUE0+yg==", "dev": true, "requires": { - "commander": "~2.19.0", + "commander": "~2.20.0", "source-map": "~0.6.1" }, "dependencies": { - "commander": { - "version": "2.19.0", - "resolved": "https://registry.npmjs.org/commander/-/commander-2.19.0.tgz", - "integrity": "sha512-6tvAOO+D6OENvRAh524Dh9jcfKTYDQAqvqezbCW82xj5X0pSrcpxtvRKHLG0yBY6SD7PSDrJaj+0AiOcKVd1Xg==", - "dev": true - }, "source-map": { "version": "0.6.1", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", @@ -13797,12 +14343,6 @@ "yargs": "~3.10.0" } }, - "window-size": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/window-size/-/window-size-0.1.0.tgz", - "integrity": "sha1-VDjNLqk7IC76Ohn+iIeu58lPnJ0=", - "dev": true - }, "wordwrap": { "version": "0.0.2", "resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-0.0.2.tgz", @@ -13836,9 +14376,9 @@ "dev": true }, "undertaker": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/undertaker/-/undertaker-1.2.0.tgz", - "integrity": "sha1-M52kZGJS0ILcN45wgGcpl1DhG0k=", + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/undertaker/-/undertaker-1.2.1.tgz", + "integrity": "sha512-71WxIzDkgYk9ZS+spIB8iZXchFhAdEo2YU8xYqBYJ39DIUIqziK78ftm26eecoIY49X0J2MLhG4hr18Yp6/CMA==", "dev": true, "requires": { "arr-flatten": "^1.0.1", @@ -13859,9 +14399,9 @@ "dev": true }, "unherit": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/unherit/-/unherit-1.1.1.tgz", - "integrity": "sha512-+XZuV691Cn4zHsK0vkKYwBEwB74T3IZIcxrgn2E4rKwTfFyI1zCh7X7grwh9Re08fdPlarIdyWgI8aVB3F5A5g==", + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/unherit/-/unherit-1.1.2.tgz", + "integrity": "sha512-W3tMnpaMG7ZY6xe/moK04U9fBhi6wEiCYHUW5Mop/wQHf12+79EQGwxYejNdhEz2mkqkBlGwm7pxmgBKMVUj0w==", "dev": true, "requires": { "inherits": "^2.0.1", @@ -13911,38 +14451,15 @@ } }, "union-value": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/union-value/-/union-value-1.0.0.tgz", - "integrity": "sha1-XHHDTLW61dzr4+oM0IIHulqhrqQ=", + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/union-value/-/union-value-1.0.1.tgz", + "integrity": "sha512-tJfXmxMeWYnczCVs7XAEvIV7ieppALdyepWMkHkwciRpZraG/xwT+s2JN8+pr1+8jCRf80FFzvr+MpQeeoF4Xg==", "dev": true, "requires": { "arr-union": "^3.1.0", "get-value": "^2.0.6", "is-extendable": "^0.1.1", - "set-value": "^0.4.3" - }, - "dependencies": { - "extend-shallow": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", - "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", - "dev": true, - "requires": { - "is-extendable": "^0.1.0" - } - }, - "set-value": { - "version": "0.4.3", - "resolved": "https://registry.npmjs.org/set-value/-/set-value-0.4.3.tgz", - "integrity": "sha1-fbCPnT0i3H945Trzw79GZuzfzPE=", - "dev": true, - "requires": { - "extend-shallow": "^2.0.1", - "is-extendable": "^0.1.1", - "is-plain-object": "^2.0.1", - "to-object-path": "^0.3.0" - } - } + "set-value": "^2.0.1" } }, "unique-stream": { @@ -13956,36 +14473,36 @@ } }, "unist-builder": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/unist-builder/-/unist-builder-1.0.3.tgz", - "integrity": "sha512-/KB8GEaoeHRyIqClL+Kam+Y5NWJ6yEiPsAfv1M+O1p+aKGgjR89WwoEHKTyOj17L6kAlqtKpAgv2nWvdbQDEig==", + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/unist-builder/-/unist-builder-1.0.4.tgz", + "integrity": "sha512-v6xbUPP7ILrT15fHGrNyHc1Xda8H3xVhP7/HAIotHOhVPjH5dCXA097C3Rry1Q2O+HbOLCao4hfPB+EYEjHgVg==", "dev": true, "requires": { "object-assign": "^4.1.0" } }, "unist-util-generated": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/unist-util-generated/-/unist-util-generated-1.1.3.tgz", - "integrity": "sha512-qlPeDqnQnd84KIqwphzOR+l02cxjDzvEYEBl84EjmKRrX4eUmjyAo8xJv1SCDhJqNjyHRnBMZWNKAiBtXE6hBg==", + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/unist-util-generated/-/unist-util-generated-1.1.4.tgz", + "integrity": "sha512-SA7Sys3h3X4AlVnxHdvN/qYdr4R38HzihoEVY2Q2BZu8NHWDnw5OGcC/tXWjQfd4iG+M6qRFNIRGqJmp2ez4Ww==", "dev": true }, "unist-util-is": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-2.1.2.tgz", - "integrity": "sha512-YkXBK/H9raAmG7KXck+UUpnKiNmUdB+aBGrknfQ4EreE1banuzrKABx3jP6Z5Z3fMSPMQQmeXBlKpCbMwBkxVw==", + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-3.0.0.tgz", + "integrity": "sha512-sVZZX3+kspVNmLWBPAB6r+7D9ZgAFPNWm66f7YNb420RlQSbn+n8rG8dGZSkrER7ZIXGQYNm5pqC3v3HopH24A==", "dev": true }, "unist-util-position": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/unist-util-position/-/unist-util-position-3.0.2.tgz", - "integrity": "sha512-npmFu92l/+b1Ao6uGP4I1WFz9hsKv7qleZ4aliw6x0RVu6A9A3tAf57NMpFfzQ02jxRtJZuRn+C8xWT7GWnH0g==", + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/unist-util-position/-/unist-util-position-3.0.3.tgz", + "integrity": "sha512-28EpCBYFvnMeq9y/4w6pbnFmCUfzlsc41NJui5c51hOFjBA1fejcwc+5W4z2+0ECVbScG3dURS3JTVqwenzqZw==", "dev": true }, "unist-util-remove-position": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/unist-util-remove-position/-/unist-util-remove-position-1.1.2.tgz", - "integrity": "sha512-XxoNOBvq1WXRKXxgnSYbtCF76TJrRoe5++pD4cCBsssSiWSnPEktyFrFLE8LTk3JW5mt9hB0Sk5zn4x/JeWY7Q==", + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/unist-util-remove-position/-/unist-util-remove-position-1.1.3.tgz", + "integrity": "sha512-CtszTlOjP2sBGYc2zcKA/CvNdTdEs3ozbiJ63IPBxh8iZg42SCCb8m04f8z2+V1aSk5a7BxbZKEdoDjadmBkWA==", "dev": true, "requires": { "unist-util-visit": "^1.1.0" @@ -13998,21 +14515,21 @@ "dev": true }, "unist-util-visit": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-1.4.0.tgz", - "integrity": "sha512-FiGu34ziNsZA3ZUteZxSFaczIjGmksfSgdKqBfOejrrfzyUy5b7YrlzT1Bcvi+djkYDituJDy2XB7tGTeBieKw==", + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-1.4.1.tgz", + "integrity": "sha512-AvGNk7Bb//EmJZyhtRUnNMEpId/AZ5Ph/KUpTI09WHQuDZHKovQ1oEv3mfmKpWKtoMzyMC4GLBm1Zy5k12fjIw==", "dev": true, "requires": { "unist-util-visit-parents": "^2.0.0" } }, "unist-util-visit-parents": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-2.0.1.tgz", - "integrity": "sha512-6B0UTiMfdWql4cQ03gDTCSns+64Zkfo2OCbK31Ov0uMizEz+CJeAp0cgZVb5Fhmcd7Bct2iRNywejT0orpbqUA==", + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-2.1.2.tgz", + "integrity": "sha512-DyN5vD4NE3aSeB+PXYNKxzGsfocxp6asDc2XXE3b0ekO2BaRUpBicbbUygfSvYfUz1IkmjFR1YF7dPklraMZ2g==", "dev": true, "requires": { - "unist-util-is": "^2.1.2" + "unist-util-is": "^3.0.0" } }, "unpipe": { @@ -14062,9 +14579,9 @@ } }, "upath": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/upath/-/upath-1.1.2.tgz", - "integrity": "sha512-kXpym8nmDmlCBr7nKdIx8P2jNBa+pBpIUFRnKJ4dr8htyYGJFokkr2ZvERRtUN+9SY+JqXouNgUPtv6JQva/2Q==", + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/upath/-/upath-1.2.0.tgz", + "integrity": "sha512-aZwGpamFO61g3OlfT7OQCHqhGnW43ieH9WZeP7QxN/G/jS4jfqUkZxoryvJgVPEcrl5NL/ggHsSmLMHuH64Lhg==", "dev": true }, "uri-js": { @@ -14107,12 +14624,12 @@ "dev": true }, "url-parse": { - "version": "1.4.4", - "resolved": "https://registry.npmjs.org/url-parse/-/url-parse-1.4.4.tgz", - "integrity": "sha512-/92DTTorg4JjktLNLe6GPS2/RvAd/RGr6LuktmWSMLEOa6rjnlrFXNgSbSmkNvCoL2T028A0a1JaJLzRMlFoHg==", + "version": "1.4.7", + "resolved": "https://registry.npmjs.org/url-parse/-/url-parse-1.4.7.tgz", + "integrity": "sha512-d3uaVyzDB9tQoSXFvuSUNFibTd9zxd2bkVrDRvF5TmvWWQwqE4lgYJ5m+x1DbecWkw+LK4RNl2CU1hHuOKPVlg==", "dev": true, "requires": { - "querystringify": "^2.0.0", + "querystringify": "^2.1.1", "requires-port": "^1.0.0" }, "dependencies": { @@ -14170,6 +14687,14 @@ "dev": true, "requires": { "inherits": "2.0.3" + }, + "dependencies": { + "inherits": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", + "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=", + "dev": true + } } }, "util-deprecate": { @@ -14178,16 +14703,6 @@ "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=", "dev": true }, - "util.promisify": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/util.promisify/-/util.promisify-1.0.0.tgz", - "integrity": "sha512-i+6qA2MPhvoKLuxnJNpXAGhg7HphQOSUq2LKMZD0m15EiskXUkMvKdF4Uui0WYeCUGea+o2cw/ZuwehtfsrNkA==", - "dev": true, - "requires": { - "define-properties": "^1.1.2", - "object.getownpropertydescriptors": "^2.0.3" - } - }, "utils-merge": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz", @@ -14195,15 +14710,15 @@ "dev": true }, "uuid": { - "version": "3.3.2", - "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.3.2.tgz", - "integrity": "sha512-yXJmeNaw3DnnKAOKJE51sL/ZaYfWJRl1pK9dr19YFCu0ObS231AB1/LbqTKRAQ5kw8A90rA6fr4riOUpTZvQZA==", + "version": "3.3.3", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.3.3.tgz", + "integrity": "sha512-pW0No1RGHgzlpHJO1nsVrHKpOEIxkGg1xB+v0ZmdNH5OAeAwzAVrCnI2/6Mtx+Uys6iaylxa+D3g4j63IKKjSQ==", "dev": true }, "v8flags": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/v8flags/-/v8flags-3.1.2.tgz", - "integrity": "sha512-MtivA7GF24yMPte9Rp/BWGCYQNaUj86zeYxV/x2RRJMKagImbbv3u8iJC57lNhWLPcGLJmHcHmFWkNsplbbLWw==", + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/v8flags/-/v8flags-3.1.3.tgz", + "integrity": "sha512-amh9CCg3ZxkzQ48Mhcb8iX7xpAfYJgePHxWMQCBWECpOSqJUXgY26ncA61UTV0BkPqfhcy6mzwCIoP4ygxpW8w==", "dev": true, "requires": { "homedir-polyfill": "^1.0.1" @@ -14225,6 +14740,12 @@ "integrity": "sha1-HCQ6ULWVwb5Up1S/7OhWO5/42BM=", "dev": true }, + "vary": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz", + "integrity": "sha1-IpnwLG3tMNSllhsLn3RSShj2NPw=", + "dev": true + }, "verror": { "version": "1.10.0", "resolved": "https://registry.npmjs.org/verror/-/verror-1.10.0.tgz", @@ -14249,9 +14770,9 @@ } }, "vfile-location": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/vfile-location/-/vfile-location-2.0.4.tgz", - "integrity": "sha512-KRL5uXQPoUKu+NGvQVL4XLORw45W62v4U4gxJ3vRlDfI9QsT4ZN1PNXn/zQpKUulqGDpYuT0XDfp5q9O87/y/w==", + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/vfile-location/-/vfile-location-2.0.5.tgz", + "integrity": "sha512-Pa1ey0OzYBkLPxPZI3d9E+S4BmvfVwNAAXrrqGbwTVXWaX2p9kM1zZ+n35UtVM06shmWKH4RPRN8KI80qE3wNQ==", "dev": true }, "vfile-message": { @@ -14282,6 +14803,26 @@ "integrity": "sha1-6CB68cx7MNRGzHC3NLXovhj4jVE=", "dev": true }, + "is-fullwidth-code-point": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz", + "integrity": "sha1-754xOG8DGn8NZDr4L95QxFfvAMs=", + "dev": true, + "requires": { + "number-is-nan": "^1.0.0" + } + }, + "string-width": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz", + "integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=", + "dev": true, + "requires": { + "code-point-at": "^1.0.0", + "is-fullwidth-code-point": "^1.0.0", + "strip-ansi": "^3.0.0" + } + }, "supports-color": { "version": "4.5.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-4.5.0.tgz", @@ -14294,15 +14835,15 @@ } }, "vfile-sort": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/vfile-sort/-/vfile-sort-2.2.0.tgz", - "integrity": "sha512-RgxLXVWrJBWb2GuP8FsSkqK7HmbjXjnI8qx3nD6NTWhsWaelaKvJuxfh1F1d1lkCPD7imo4zzi8cf6IOMgaTnQ==", + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/vfile-sort/-/vfile-sort-2.2.1.tgz", + "integrity": "sha512-5dt7xEhC44h0uRQKhbM2JAe0z/naHphIZlMOygtMBM9Nn0pZdaX5fshhwWit9wvsuP8t/wp43nTDRRErO1WK8g==", "dev": true }, "vfile-statistics": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/vfile-statistics/-/vfile-statistics-1.1.2.tgz", - "integrity": "sha512-16wAC9eEGXdsD35LX9m/iXCRIZyX5LIrDgDtAF92rbATSqsBRbC4n05e0Rj5vt3XRpcKu0UJeWnTxWsSyvNZ+w==", + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/vfile-statistics/-/vfile-statistics-1.1.3.tgz", + "integrity": "sha512-CstaK/ebTz1W3Qp41Bt9Lj/2DmumFsCwC2sKahDNSPh0mPh7/UyMLCoU8ZBX34CRU0d61B4W41yIFsV0NKMZeA==", "dev": true }, "vinyl": { @@ -14373,27 +14914,18 @@ "vinyl-sourcemaps-apply": { "version": "0.2.1", "resolved": "https://registry.npmjs.org/vinyl-sourcemaps-apply/-/vinyl-sourcemaps-apply-0.2.1.tgz", - "integrity": "sha1-q2VJ1h0XLCsbh75cUI0jnI74dwU=", - "dev": true, - "requires": { - "source-map": "^0.5.1" - } - }, - "vlq": { - "version": "0.2.3", - "resolved": "https://registry.npmjs.org/vlq/-/vlq-0.2.3.tgz", - "integrity": "sha512-DRibZL6DsNhIgYQ+wNdWDL2SL3bKPlVrRiBqV5yuMm++op8W4kGFtaQfCs4KEJn0wBZcHVHJ3eoywX8983k1ow==", - "dev": true - }, - "vm-browserify": { - "version": "0.0.4", - "resolved": "https://registry.npmjs.org/vm-browserify/-/vm-browserify-0.0.4.tgz", - "integrity": "sha1-XX6kW7755Kb/ZflUOOCofDV9WnM=", + "integrity": "sha1-q2VJ1h0XLCsbh75cUI0jnI74dwU=", "dev": true, "requires": { - "indexof": "0.0.1" + "source-map": "^0.5.1" } }, + "vm-browserify": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/vm-browserify/-/vm-browserify-1.1.0.tgz", + "integrity": "sha512-iq+S7vZJE60yejDYM0ek6zg308+UZsdtPExWP9VZoCFCz1zkJoXFnAX7aZfd/ZwrkidzdUZL0C/ryW+JwAiIGw==", + "dev": true + }, "void-elements": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/void-elements/-/void-elements-2.0.1.tgz", @@ -14420,6 +14952,109 @@ "neo-async": "^2.5.0" } }, + "wdio-browserstack-service": { + "version": "0.1.19", + "resolved": "https://registry.npmjs.org/wdio-browserstack-service/-/wdio-browserstack-service-0.1.19.tgz", + "integrity": "sha512-ZAq20McWrQy80FQst+4cn1l5WRP9u+9DOKif2TarxYFzw/EmhdNg9TFcXBT5dxH+LcP5v47v7mXMmsO7B3+92Q==", + "dev": true, + "requires": { + "browserstack-local": "^1.3.7", + "request": "^2.81.0", + "request-promise": "^4.2.1" + } + }, + "wdio-concise-reporter": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/wdio-concise-reporter/-/wdio-concise-reporter-0.1.2.tgz", + "integrity": "sha1-+kmA768kszWfHqQz73thYxVDphQ=", + "dev": true + }, + "wdio-dot-reporter": { + "version": "0.0.10", + "resolved": "https://registry.npmjs.org/wdio-dot-reporter/-/wdio-dot-reporter-0.0.10.tgz", + "integrity": "sha512-A0TCk2JdZEn3M1DSG9YYbNRcGdx/YRw19lTiRpgwzH4qqWkO/oRDZRmi3Snn4L2j54KKTfPalBhlOtc8fojVgg==", + "dev": true + }, + "wdio-mocha-framework": { + "version": "0.6.4", + "resolved": "https://registry.npmjs.org/wdio-mocha-framework/-/wdio-mocha-framework-0.6.4.tgz", + "integrity": "sha512-GZsXwoW60/fkkfqZJR/ZAdiALaM+hW+BbnTT9x214qPR4Pe5XeyYxhJNEdyf0dNI9625cMdkyZYaWoFHN5zDcA==", + "dev": true, + "requires": { + "babel-runtime": "^6.23.0", + "mocha": "^5.2.0", + "wdio-sync": "0.7.3" + } + }, + "wdio-spec-reporter": { + "version": "0.1.5", + "resolved": "https://registry.npmjs.org/wdio-spec-reporter/-/wdio-spec-reporter-0.1.5.tgz", + "integrity": "sha512-MqvgTow8hFwhFT47q67JwyJyeynKodGRQCxF7ijKPGfsaG1NLssbXYc0JhiL7SiAyxnQxII0UxzTCd3I6sEdkg==", + "dev": true, + "requires": { + "babel-runtime": "~6.26.0", + "chalk": "^2.3.0", + "humanize-duration": "~3.15.0" + } + }, + "wdio-sync": { + "version": "0.7.3", + "resolved": "https://registry.npmjs.org/wdio-sync/-/wdio-sync-0.7.3.tgz", + "integrity": "sha512-ukASSHOQmOxaz5HTILR0jykqlHBtAPsBpMtwhpiG0aW9uc7SO7PF+E5LhVvTG4ypAh+UGmY3rTjohOsqDr39jw==", + "dev": true, + "requires": { + "babel-runtime": "^6.26.0", + "fibers": "^3.0.0", + "object.assign": "^4.0.3" + } + }, + "webdriverio": { + "version": "4.14.4", + "resolved": "https://registry.npmjs.org/webdriverio/-/webdriverio-4.14.4.tgz", + "integrity": "sha512-Knp2vzuzP5c5ybgLu+zTwy/l1Gh0bRP4zAr8NWcrStbuomm9Krn9oRF0rZucT6AyORpXinETzmeowFwIoo7mNA==", + "dev": true, + "requires": { + "archiver": "~2.1.0", + "babel-runtime": "^6.26.0", + "css-parse": "^2.0.0", + "css-value": "~0.0.1", + "deepmerge": "~2.0.1", + "ejs": "~2.5.6", + "gaze": "~1.1.2", + "glob": "~7.1.1", + "grapheme-splitter": "^1.0.2", + "inquirer": "~3.3.0", + "json-stringify-safe": "~5.0.1", + "mkdirp": "~0.5.1", + "npm-install-package": "~2.1.0", + "optimist": "~0.6.1", + "q": "~1.5.0", + "request": "^2.83.0", + "rgb2hex": "^0.1.9", + "safe-buffer": "~5.1.1", + "supports-color": "~5.0.0", + "url": "~0.11.0", + "wdio-dot-reporter": "~0.0.8", + "wgxpath": "~1.0.0" + }, + "dependencies": { + "has-flag": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-2.0.0.tgz", + "integrity": "sha1-6CB68cx7MNRGzHC3NLXovhj4jVE=", + "dev": true + }, + "supports-color": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.0.1.tgz", + "integrity": "sha512-7FQGOlSQ+AQxBNXJpVDj8efTA/FtyB5wcNE1omXXJ0cq6jm1jjDwuROlYDbnzHqdNPqliWFhcioCWSyav+xBnA==", + "dev": true, + "requires": { + "has-flag": "^2.0.0" + } + } + } + }, "webpack": { "version": "3.12.0", "resolved": "https://registry.npmjs.org/webpack/-/webpack-3.12.0.tgz", @@ -14451,9 +15086,9 @@ }, "dependencies": { "ajv": { - "version": "6.10.0", - "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.10.0.tgz", - "integrity": "sha512-nffhOpkymDECQyR0mnsUtoCE8RlX38G0rYP+wgLWFyZuUyuuojSSvi/+euOiQBIn63whYwYVIIH1TvE3tu4OEg==", + "version": "6.10.2", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.10.2.tgz", + "integrity": "sha512-TXtUUEYHuaTEbLZWIKUr5pmBuhDLy+8KYtPYdcV8qC+pOZL+NKqYwvWSRrVXHn+ZmRRAu8vJTAznH7Oag6RVRw==", "dev": true, "requires": { "fast-deep-equal": "^2.0.1", @@ -14463,24 +15098,74 @@ } }, "ajv-keywords": { - "version": "3.4.0", - "resolved": "https://registry.npmjs.org/ajv-keywords/-/ajv-keywords-3.4.0.tgz", - "integrity": "sha512-aUjdRFISbuFOl0EIZc+9e4FfZp0bDZgAdOOf30bJmw8VM9v84SHyVyxDfbWxpGYbdZD/9XoKxfHVNmxPkhwyGw==", + "version": "3.4.1", + "resolved": "https://registry.npmjs.org/ajv-keywords/-/ajv-keywords-3.4.1.tgz", + "integrity": "sha512-RO1ibKvd27e6FEShVFfPALuHI3WjSVNeK5FIsmme/LYRNxjKuNj+Dt7bucLa6NdSv3JcVTyMlm9kGR84z1XpaQ==", "dev": true }, - "ansi-regex": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.0.tgz", - "integrity": "sha1-7QMXwyIGT3lGbAKWa922Bas32Zg=", + "async": { + "version": "2.6.3", + "resolved": "https://registry.npmjs.org/async/-/async-2.6.3.tgz", + "integrity": "sha512-zflvls11DCy+dQWzTW2dzuilv8Z5X/pjfmZOWba6TNIVDm+2UDaJmXSOXlasHKfNBs8oo3M0aT50fDEWfKZjXg==", + "dev": true, + "requires": { + "lodash": "^4.17.14" + } + }, + "camelcase": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-4.1.0.tgz", + "integrity": "sha1-1UVjW+HjPFQmScaRc+Xeas+uNN0=", "dev": true }, - "async": { - "version": "2.6.2", - "resolved": "https://registry.npmjs.org/async/-/async-2.6.2.tgz", - "integrity": "sha512-H1qVYh1MYhEEFLsP97cVKqCGo7KfCyTt6uEWqsTBr9SO84oK9Uwbyd/yCW+6rKJLHksBNUVWZDAjfS+Ccx0Bbg==", + "cliui": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/cliui/-/cliui-3.2.0.tgz", + "integrity": "sha1-EgYBU3qRbSmUD5NNo7SNWFo5IT0=", + "dev": true, + "requires": { + "string-width": "^1.0.1", + "strip-ansi": "^3.0.1", + "wrap-ansi": "^2.0.0" + }, + "dependencies": { + "string-width": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz", + "integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=", + "dev": true, + "requires": { + "code-point-at": "^1.0.0", + "is-fullwidth-code-point": "^1.0.0", + "strip-ansi": "^3.0.0" + } + } + } + }, + "cross-spawn": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-5.1.0.tgz", + "integrity": "sha1-6L0O/uWPz/b4+UUQoKVUu/ojVEk=", + "dev": true, + "requires": { + "lru-cache": "^4.0.1", + "shebang-command": "^1.2.0", + "which": "^1.2.9" + } + }, + "execa": { + "version": "0.7.0", + "resolved": "https://registry.npmjs.org/execa/-/execa-0.7.0.tgz", + "integrity": "sha1-lEvs00zEHuMqY6n68nrVpl/Fl3c=", "dev": true, "requires": { - "lodash": "^4.17.11" + "cross-spawn": "^5.0.1", + "get-stream": "^3.0.0", + "is-stream": "^1.1.0", + "npm-run-path": "^2.0.0", + "p-finally": "^1.0.0", + "signal-exit": "^3.0.0", + "strip-eof": "^1.0.0" } }, "fast-deep-equal": { @@ -14498,18 +15183,33 @@ "locate-path": "^2.0.0" } }, + "get-caller-file": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-1.0.3.tgz", + "integrity": "sha512-3t6rVToeoZfYSGd8YoLFR2DJkiQrIiUrGcjvFX2mDw3bn6k2OtwHN0TNCLbBO+w8qTvimhDkv+LSscbJY1vE6w==", + "dev": true + }, "has-flag": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-2.0.0.tgz", "integrity": "sha1-6CB68cx7MNRGzHC3NLXovhj4jVE=", "dev": true }, - "is-fullwidth-code-point": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz", - "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=", + "invert-kv": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/invert-kv/-/invert-kv-1.0.0.tgz", + "integrity": "sha1-EEqOSqym09jNFXqO+L+rLXo//bY=", "dev": true }, + "is-fullwidth-code-point": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz", + "integrity": "sha1-754xOG8DGn8NZDr4L95QxFfvAMs=", + "dev": true, + "requires": { + "number-is-nan": "^1.0.0" + } + }, "json-schema-traverse": { "version": "0.4.1", "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", @@ -14522,6 +15222,15 @@ "integrity": "sha1-Hq3nrMASA0rYTiOWdn6tn6VJWCE=", "dev": true }, + "lcid": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/lcid/-/lcid-1.0.0.tgz", + "integrity": "sha1-MIrMr6C8SDo4Z7S28rlQYlHRuDU=", + "dev": true, + "requires": { + "invert-kv": "^1.0.0" + } + }, "load-json-file": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/load-json-file/-/load-json-file-2.0.0.tgz", @@ -14544,6 +15253,32 @@ "path-exists": "^3.0.0" } }, + "mem": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/mem/-/mem-1.1.0.tgz", + "integrity": "sha1-Xt1StIXKHZAP5kiVUFOZoN+kX3Y=", + "dev": true, + "requires": { + "mimic-fn": "^1.0.0" + } + }, + "mimic-fn": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-1.2.0.tgz", + "integrity": "sha512-jf84uxzwiuiIVKiOLpfYk7N46TSy8ubTonmneY9vrpHNAnp0QBt2BxWV9dO3/j+BoVAb+a5G6YDPW3M5HOdMWQ==", + "dev": true + }, + "os-locale": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/os-locale/-/os-locale-2.1.0.tgz", + "integrity": "sha512-3sslG3zJbEYcaC4YVAvDorjGxc7tv6KVATnLPZONiljsUncvihe9BQoVCEs0RZ1kmf4Hk9OBqlZfJZWI4GanKA==", + "dev": true, + "requires": { + "execa": "^0.7.0", + "lcid": "^1.0.0", + "mem": "^1.1.0" + } + }, "p-limit": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-1.3.0.tgz", @@ -14613,24 +15348,11 @@ "read-pkg": "^2.0.0" } }, - "string-width": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-2.1.1.tgz", - "integrity": "sha512-nOqH59deCq9SRHlxq1Aw85Jnt4w6KvLKqWVik6oA9ZklXLNIOlqg4F2yrT1MVaTjAqvVwdfeZ7w7aCvJD7ugkw==", - "dev": true, - "requires": { - "is-fullwidth-code-point": "^2.0.0", - "strip-ansi": "^4.0.0" - } - }, - "strip-ansi": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz", - "integrity": "sha1-qEeQIusaw2iocTibY1JixQXuNo8=", - "dev": true, - "requires": { - "ansi-regex": "^3.0.0" - } + "require-main-filename": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/require-main-filename/-/require-main-filename-1.0.1.tgz", + "integrity": "sha1-l/cXtp1IeE9fUmpsWqj/3aBVpNE=", + "dev": true }, "supports-color": { "version": "4.5.0", @@ -14641,6 +15363,12 @@ "has-flag": "^2.0.0" } }, + "y18n": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/y18n/-/y18n-3.2.1.tgz", + "integrity": "sha1-bRX7qITAhnnA136I53WegR4H+kE=", + "dev": true + }, "yargs": { "version": "8.0.2", "resolved": "https://registry.npmjs.org/yargs/-/yargs-8.0.2.tgz", @@ -14661,6 +15389,59 @@ "y18n": "^3.2.1", "yargs-parser": "^7.0.0" } + }, + "yargs-parser": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-7.0.0.tgz", + "integrity": "sha1-jQrELxbqVd69MyyvTEA4s+P139k=", + "dev": true, + "requires": { + "camelcase": "^4.1.0" + } + } + } + }, + "webpack-bundle-analyzer": { + "version": "3.4.1", + "resolved": "https://registry.npmjs.org/webpack-bundle-analyzer/-/webpack-bundle-analyzer-3.4.1.tgz", + "integrity": "sha512-Bs8D/1zF+17lhqj2OYmzi7HEVYqEVxu7lCO9Ff8BwajenOU0vAwEoV8e4ICCPNZAcqR1PCR/7o2SkW+cnCmF0A==", + "dev": true, + "requires": { + "acorn": "^6.0.7", + "acorn-walk": "^6.1.1", + "bfj": "^6.1.1", + "chalk": "^2.4.1", + "commander": "^2.18.0", + "ejs": "^2.6.1", + "express": "^4.16.3", + "filesize": "^3.6.1", + "gzip-size": "^5.0.0", + "lodash": "^4.17.15", + "mkdirp": "^0.5.1", + "opener": "^1.5.1", + "ws": "^6.0.0" + }, + "dependencies": { + "acorn": { + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-6.3.0.tgz", + "integrity": "sha512-/czfa8BwS88b9gWQVhc8eknunSA2DoJpJyTQkhheIf5E48u1N0R4q/YxxsAeqRrmK9TQ/uYfgLDfZo91UlANIA==", + "dev": true + }, + "ejs": { + "version": "2.7.1", + "resolved": "https://registry.npmjs.org/ejs/-/ejs-2.7.1.tgz", + "integrity": "sha512-kS/gEPzZs3Y1rRsbGX4UOSjtP/CeJP0CxSNZHYxGfVM/VgLcv0ZqM7C45YyTj2DI2g7+P9Dd24C+IMIg6D0nYQ==", + "dev": true + }, + "ws": { + "version": "6.2.1", + "resolved": "https://registry.npmjs.org/ws/-/ws-6.2.1.tgz", + "integrity": "sha512-GIyAXC2cB7LjvpgMt9EKS2ldqr0MTrORaleiOno6TweZ6r3TKtoFQWay/2PceJ3RuBasOHzXNn5Lrw1X0bEjqA==", + "dev": true, + "requires": { + "async-limiter": "~1.0.0" + } } } }, @@ -14707,9 +15488,9 @@ }, "dependencies": { "mime": { - "version": "2.4.0", - "resolved": "https://registry.npmjs.org/mime/-/mime-2.4.0.tgz", - "integrity": "sha512-ikBcWwyqXQSHKtciCcctu9YfPbFYZ4+gbHEmE0Q8jzcTYQg5dHCr3g2wwAZjPoJfQVXZq6KXAjpXOTf5/cjT7w==", + "version": "2.4.4", + "resolved": "https://registry.npmjs.org/mime/-/mime-2.4.4.tgz", + "integrity": "sha512-LRxmNwziLPT828z+4YkNzloCFC2YM4wrB99k+AV5ZbEyfGNWfG8SO1FUXLmLDBSo89NrJZ4DIWeLjy1CHGhMGA==", "dev": true } } @@ -14727,9 +15508,9 @@ } }, "webpack-sources": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/webpack-sources/-/webpack-sources-1.3.0.tgz", - "integrity": "sha512-OiVgSrbGu7NEnEvQJJgdSFPl2qWKkWq5lHMhgiToIiN9w34EBnjYzSYs+VbL5KoYiLNtFFa7BZIKxRED3I32pA==", + "version": "1.4.3", + "resolved": "https://registry.npmjs.org/webpack-sources/-/webpack-sources-1.4.3.tgz", + "integrity": "sha512-lgTS3Xhv1lCOKo7SA5TjKXMjpSM4sBjNV5+q2bqesbSPs5FjGmU6jjtBSkX9b4qW87vDIsCIlUPOEhbZrMdjeQ==", "dev": true, "requires": { "source-list-map": "^2.0.0", @@ -14825,6 +15606,17 @@ "pako": "~0.2.0" } }, + "buffer": { + "version": "4.9.1", + "resolved": "https://registry.npmjs.org/buffer/-/buffer-4.9.1.tgz", + "integrity": "sha1-bRu2AbB6TvztlwlBMgkwJ8lbwpg=", + "dev": true, + "requires": { + "base64-js": "^1.0.2", + "ieee754": "^1.1.4", + "isarray": "^1.0.0" + } + }, "camelcase": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-1.2.1.tgz", @@ -15035,12 +15827,6 @@ "object-assign": "^4.0.1" } }, - "lodash.clone": { - "version": "4.5.0", - "resolved": "https://registry.npmjs.org/lodash.clone/-/lodash.clone-4.5.0.tgz", - "integrity": "sha1-GVhwRQ9aExkkeN9Lw9I9LeoZB7Y=", - "dev": true - }, "memory-fs": { "version": "0.3.0", "resolved": "https://registry.npmjs.org/memory-fs/-/memory-fs-0.3.0.tgz", @@ -15124,6 +15910,12 @@ "integrity": "sha1-8/dSL073gjSNqBYbrZ7P1Rv4OnU=", "dev": true }, + "path-browserify": { + "version": "0.0.0", + "resolved": "https://registry.npmjs.org/path-browserify/-/path-browserify-0.0.0.tgz", + "integrity": "sha1-oLhwcpquIUAFt9UDLsLLuw+0RRo=", + "dev": true + }, "punycode": { "version": "1.4.1", "resolved": "https://registry.npmjs.org/punycode/-/punycode-1.4.1.tgz", @@ -15196,6 +15988,14 @@ "dev": true, "requires": { "inherits": "2.0.3" + }, + "dependencies": { + "inherits": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", + "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=", + "dev": true + } } }, "vinyl": { @@ -15209,6 +16009,15 @@ "replace-ext": "0.0.1" } }, + "vm-browserify": { + "version": "0.0.4", + "resolved": "https://registry.npmjs.org/vm-browserify/-/vm-browserify-0.0.4.tgz", + "integrity": "sha1-XX6kW7755Kb/ZflUOOCofDV9WnM=", + "dev": true, + "requires": { + "indexof": "0.0.1" + } + }, "watchpack": { "version": "0.2.9", "resolved": "https://registry.npmjs.org/watchpack/-/watchpack-0.2.9.tgz", @@ -15251,12 +16060,6 @@ "webpack-core": "~0.6.9" } }, - "window-size": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/window-size/-/window-size-0.1.0.tgz", - "integrity": "sha1-VDjNLqk7IC76Ohn+iIeu58lPnJ0=", - "dev": true - }, "wordwrap": { "version": "0.0.2", "resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-0.0.2.tgz", @@ -15278,12 +16081,13 @@ } }, "websocket-driver": { - "version": "0.7.0", - "resolved": "https://registry.npmjs.org/websocket-driver/-/websocket-driver-0.7.0.tgz", - "integrity": "sha1-DK+dLXVdk67gSdS90NP+LMoqJOs=", + "version": "0.7.3", + "resolved": "https://registry.npmjs.org/websocket-driver/-/websocket-driver-0.7.3.tgz", + "integrity": "sha512-bpxWlvbbB459Mlipc5GBzzZwhoZgGEZLuqPaR0INBGnPAY1vdBX6hPnoFXiw+3yWxDuHyQjO2oXTMyS8A5haFg==", "dev": true, "requires": { - "http-parser-js": ">=0.4.0", + "http-parser-js": ">=0.4.0 <0.4.11", + "safe-buffer": ">=5.1.0", "websocket-extensions": ">=0.1.1" } }, @@ -15293,6 +16097,12 @@ "integrity": "sha512-nqHUnMXmBzT0w570r2JpJxfiSD1IzoI+HGVdd3aZ0yNi3ngvQ4jv1dtHt5VGxfI2yj5yqImPhOK4vmIh2xMbGg==", "dev": true }, + "wgxpath": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/wgxpath/-/wgxpath-1.0.0.tgz", + "integrity": "sha1-7vikudVYzEla06mit1FZfs2a9pA=", + "dev": true + }, "which": { "version": "1.3.1", "resolved": "https://registry.npmjs.org/which/-/which-1.3.1.tgz", @@ -15308,10 +16118,19 @@ "integrity": "sha1-2e8H3Od7mQK4o6j6SzHD4/fm6Ho=", "dev": true }, + "wide-align": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/wide-align/-/wide-align-1.1.3.tgz", + "integrity": "sha512-QGkOQc8XL6Bt5PwnsExKBPuMKBxnGxWWW3fU55Xt4feHozMUhdUMaBCk290qpm/wG5u/RSKzwdAC4i51YigihA==", + "dev": true, + "requires": { + "string-width": "^1.0.2 || 2" + } + }, "window-size": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/window-size/-/window-size-0.2.0.tgz", - "integrity": "sha1-tDFbtCFKPXBY6+7okuE/ok2YsHU=", + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/window-size/-/window-size-0.1.0.tgz", + "integrity": "sha1-VDjNLqk7IC76Ohn+iIeu58lPnJ0=", "dev": true }, "wordwrap": { @@ -15328,6 +16147,28 @@ "requires": { "string-width": "^1.0.1", "strip-ansi": "^3.0.1" + }, + "dependencies": { + "is-fullwidth-code-point": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz", + "integrity": "sha1-754xOG8DGn8NZDr4L95QxFfvAMs=", + "dev": true, + "requires": { + "number-is-nan": "^1.0.0" + } + }, + "string-width": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz", + "integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=", + "dev": true, + "requires": { + "code-point-at": "^1.0.0", + "is-fullwidth-code-point": "^1.0.0", + "strip-ansi": "^3.0.0" + } + } } }, "wrappy": { @@ -15368,22 +16209,16 @@ "integrity": "sha1-wodrBhaKrcQOV9l+gRkayPQ5iz4=", "dev": true }, - "xregexp": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/xregexp/-/xregexp-2.0.0.tgz", - "integrity": "sha1-UqY+VsoLhKfzpfPWGHLxJq16WUM=", - "dev": true - }, "xtend": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.1.tgz", - "integrity": "sha1-pcbVMr5lbiPbgg77lDofBJmNY68=", + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.2.tgz", + "integrity": "sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ==", "dev": true }, "y18n": { - "version": "3.2.1", - "resolved": "https://registry.npmjs.org/y18n/-/y18n-3.2.1.tgz", - "integrity": "sha1-bRX7qITAhnnA136I53WegR4H+kE=", + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/y18n/-/y18n-4.0.0.tgz", + "integrity": "sha512-r9S/ZyXu/Xu9q1tYlpsLIsa3EeLXXk0VwlxqTcFRfg9EhMW+17kbt9G0NrgCmhGb5vT2hyhJZLfDGx+7+5Uj/w==", "dev": true }, "yallist": { @@ -15399,12 +16234,68 @@ "dev": true }, "yargs-parser": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-7.0.0.tgz", - "integrity": "sha1-jQrELxbqVd69MyyvTEA4s+P139k=", + "version": "13.0.0", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-13.0.0.tgz", + "integrity": "sha512-w2LXjoL8oRdRQN+hOyppuXs+V/fVAYtpcrRxZuF7Kt/Oc+Jr2uAcVntaUTNT6w5ihoWfFDpNY8CPx1QskxZ/pw==", + "dev": true, + "requires": { + "camelcase": "^5.0.0", + "decamelize": "^1.2.0" + } + }, + "yargs-unparser": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/yargs-unparser/-/yargs-unparser-1.5.0.tgz", + "integrity": "sha512-HK25qidFTCVuj/D1VfNiEndpLIeJN78aqgR23nL3y4N0U/91cOAzqfHlF8n2BvoNDcZmJKin3ddNSvOxSr8flw==", "dev": true, "requires": { - "camelcase": "^4.1.0" + "flat": "^4.1.0", + "lodash": "^4.17.11", + "yargs": "^12.0.5" + }, + "dependencies": { + "get-caller-file": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-1.0.3.tgz", + "integrity": "sha512-3t6rVToeoZfYSGd8YoLFR2DJkiQrIiUrGcjvFX2mDw3bn6k2OtwHN0TNCLbBO+w8qTvimhDkv+LSscbJY1vE6w==", + "dev": true + }, + "require-main-filename": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/require-main-filename/-/require-main-filename-1.0.1.tgz", + "integrity": "sha1-l/cXtp1IeE9fUmpsWqj/3aBVpNE=", + "dev": true + }, + "yargs": { + "version": "12.0.5", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-12.0.5.tgz", + "integrity": "sha512-Lhz8TLaYnxq/2ObqHDql8dX8CJi97oHxrjUcYtzKbbykPtVW9WB+poxI+NM2UIzsMgNCZTIf0AQwsjK5yMAqZw==", + "dev": true, + "requires": { + "cliui": "^4.0.0", + "decamelize": "^1.2.0", + "find-up": "^3.0.0", + "get-caller-file": "^1.0.1", + "os-locale": "^3.0.0", + "require-directory": "^2.1.1", + "require-main-filename": "^1.0.1", + "set-blocking": "^2.0.0", + "string-width": "^2.0.0", + "which-module": "^2.0.0", + "y18n": "^3.2.1 || ^4.0.0", + "yargs-parser": "^11.1.1" + } + }, + "yargs-parser": { + "version": "11.1.1", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-11.1.1.tgz", + "integrity": "sha512-C6kB/WJDiaxONLJQnF8ccx9SEeoTTLek8RVbaOIsrAUS8VrBEXfmeSnCZxygc+XC2sNMBIwOOnfcxiynjHsVSQ==", + "dev": true, + "requires": { + "camelcase": "^5.0.0", + "decamelize": "^1.2.0" + } + } } }, "yeast": { @@ -15412,6 +16303,18 @@ "resolved": "https://registry.npmjs.org/yeast/-/yeast-0.1.2.tgz", "integrity": "sha1-AI4G2AlDIMNy28L47XagymyKxBk=", "dev": true + }, + "zip-stream": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/zip-stream/-/zip-stream-1.2.0.tgz", + "integrity": "sha1-qLxF9MG0lpnGuQGYuqyqzbzUugQ=", + "dev": true, + "requires": { + "archiver-utils": "^1.3.0", + "compress-commons": "^1.2.0", + "lodash": "^4.8.0", + "readable-stream": "^2.0.0" + } } } } diff --git a/package.json b/package.json index c46c75c4dce..314323914a1 100755 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "prebid.js", - "version": "2.10.0-pre", + "version": "2.34.0-pre", "description": "Header Bidding Management Library", "main": "src/prebid.js", "scripts": { @@ -21,7 +21,7 @@ "author": "the prebid.js contributors", "license": "Apache-2.0", "engines": { - "node": ">=4.0" + "node": ">=8.9.0" }, "devDependencies": { "@babel/core": "^7.2.2", @@ -31,13 +31,14 @@ "chai": "^4.2.0", "coveralls": "^3.0.2", "documentation": "^5.2.2", - "ejs": "^2.5.1", "es5-shim": "^4.5.2", "eslint-config-standard": "^10.2.1", "eslint-plugin-import": "^2.2.0", "eslint-plugin-node": "^5.1.0", + "eslint-plugin-prebid": "file:./plugins/eslint", "eslint-plugin-promise": "^3.5.0", "eslint-plugin-standard": "^3.0.1", + "execa": "^1.0.0", "faker": "^3.1.0", "fs.extra": "^1.3.2", "gulp": "^4.0.0", @@ -45,11 +46,10 @@ "gulp-concat": "^2.6.0", "gulp-connect": "^5.7.0", "gulp-eslint": "^4.0.0", - "gulp-footer": "github:prebid/gulp-footer#master", + "gulp-footer": "^2.0.2", "gulp-header": "^1.7.1", "gulp-if": "^2.0.2", "gulp-js-escape": "^1.0.1", - "gulp-optimize-js": "^1.1.0", "gulp-replace": "^1.0.0", "gulp-shell": "^0.5.2", "gulp-sourcemaps": "^2.6.0", @@ -78,13 +78,19 @@ "karma-webpack": "^3.0.5", "lodash": "^4.17.4", "mocha": "^5.0.0", - "nightwatch": "^1.0.6", "opn": "^5.4.0", "querystringify": "0.0.3", + "resolve-from": "^5.0.0", "sinon": "^4.1.3", "through2": "^2.0.3", "url-parse": "^1.0.5", + "wdio-browserstack-service": "^0.1.17", + "wdio-concise-reporter": "^0.1.2", + "wdio-mocha-framework": "^0.6.3", + "wdio-spec-reporter": "^0.1.5", + "webdriverio": "^4.13.2", "webpack": "^3.0.0", + "webpack-bundle-analyzer": "^3.3.2", "webpack-stream": "^3.2.0", "yargs": "^1.3.1" }, @@ -92,7 +98,9 @@ "babel-plugin-transform-object-assign": "^6.22.0", "core-js": "^2.4.1", "crypto-js": "^3.1.9-1", - "fun-hooks": "^0.8.1", + "dlv": "1.1.3", + "dset": "2.0.1", + "fun-hooks": "^0.9.5", "jsencrypt": "^3.0.0-rc.1", "just-clone": "^1.0.2" } diff --git a/plugins/eslint/package.json b/plugins/eslint/package.json new file mode 100644 index 00000000000..fa18ad83718 --- /dev/null +++ b/plugins/eslint/package.json @@ -0,0 +1,8 @@ +{ + "name": "eslint-plugin-prebid", + "version": "1.0.0", + "description": "validates module imports can be found without custom webpack resolvers, are in module whitelist, and not module entry points", + "main": "validateImports.js", + "author": "the prebid.js contributors", + "license": "Apache-2.0" +} diff --git a/plugins/eslint/validateImports.js b/plugins/eslint/validateImports.js new file mode 100644 index 00000000000..193455a47fd --- /dev/null +++ b/plugins/eslint/validateImports.js @@ -0,0 +1,65 @@ + +let path = require('path'); +let _ = require('lodash'); +let resolveFrom = require('resolve-from'); + +function flagErrors(context, node, importPath) { + let absFileDir = path.dirname(context.getFilename()); + let absImportPath = path.resolve(absFileDir, importPath); + + try { + resolveFrom(absFileDir, importPath); + } catch (e) { + return context.report(node, `import "${importPath}" cannot be resolved`); + } + + if ( + Array.isArray(_.get(context, ['options', 0])) && + importPath.match(/^\w+/) && + !context.options[0].some(name => importPath.startsWith(name)) + ) { + context.report(node, `import "${importPath}" not in import whitelist`); + } else { + let absModulePath = path.resolve(__dirname, '../../modules'); + + // don't allow import of any files directly within modules folder or index.js files within modules' sub-folders + if ( + path.dirname(absImportPath) === absModulePath || ( + absImportPath.startsWith(absModulePath) && + path.basename(absImportPath) === 'index.js' + ) + ) { + context.report(node, `import "${importPath}" cannot require module entry point`); + } + } +} + +module.exports = { + rules: { + 'validate-imports': { + meta: { + docs: { + description: 'validates module imports can be found without custom webpack resolvers, are in module whitelist, and not module entry points' + } + }, + create: function(context) { + return { + "CallExpression[callee.name='require']"(node) { + let importPath = _.get(node, ['arguments', 0, 'value']); + if (importPath) { + flagErrors(context, node, importPath); + } + }, + ImportDeclaration(node) { + let importPath = node.source.value.trim(); + flagErrors(context, node, importPath); + }, + "ExportNamedDeclaration[source]"(node) { + let importPath = node.source.value.trim(); + flagErrors(context, node, importPath); + } + } + } + } + } +}; diff --git a/src/adapterManager.js b/src/adapterManager.js index 75415c4035f..6b1bc9508c8 100644 --- a/src/adapterManager.js +++ b/src/adapterManager.js @@ -118,7 +118,8 @@ function getAdUnitCopyForPrebidServer(adUnits) { adUnitsCopy.forEach((adUnit) => { // filter out client side bids adUnit.bids = adUnit.bids.filter((bid) => { - return includes(adaptersServerSide, bid.bidder) && (!doingS2STesting() || bid.finalSource !== s2sTestingModule.CLIENT); + return includes(adaptersServerSide, bid.bidder) && + (!doingS2STesting() || bid.finalSource !== s2sTestingModule.CLIENT); }).map((bid) => { bid.bid_id = utils.getUniqueIdentifierStr(); return bid; @@ -170,20 +171,33 @@ adapterManager.makeBidRequests = function(adUnits, auctionStart, auctionId, cbTi let clientBidderCodes = bidderCodes; let clientTestAdapters = []; + if (_s2sConfig.enabled) { // if s2sConfig.bidderControl testing is turned on if (doingS2STesting()) { // get all adapters doing client testing - clientTestAdapters = s2sTestingModule.getSourceBidderMap(adUnits)[s2sTestingModule.CLIENT]; + const bidderMap = s2sTestingModule.getSourceBidderMap(adUnits); + clientTestAdapters = bidderMap[s2sTestingModule.CLIENT]; } // these are called on the s2s adapter let adaptersServerSide = _s2sConfig.bidders; // don't call these client side (unless client request is needed for testing) - clientBidderCodes = bidderCodes.filter((elm) => { - return !includes(adaptersServerSide, elm) || includes(clientTestAdapters, elm); - }); + clientBidderCodes = bidderCodes.filter(elm => + !includes(adaptersServerSide, elm) || includes(clientTestAdapters, elm) + ); + + const adUnitsContainServerRequests = adUnits => Boolean( + find(adUnits, adUnit => find(adUnit.bids, bid => ( + bid.bidSource || + (_s2sConfig.bidderControl && _s2sConfig.bidderControl[bid.bidder]) + ) && bid.finalSource === s2sTestingModule.SERVER)) + ); + + if (isTestingServerOnly() && adUnitsContainServerRequests(adUnits)) { + clientBidderCodes.length = 0; + } let adUnitsS2SCopy = getAdUnitCopyForPrebidServer(adUnits); let tid = utils.generateUUID(); @@ -252,7 +266,7 @@ adapterManager.makeBidRequests = function(adUnits, auctionStart, auctionId, cbTi return bidRequests; }; -adapterManager.callBids = (adUnits, bidRequests, addBidResponse, doneCb, requestCallbacks, requestBidsTimeout) => { +adapterManager.callBids = (adUnits, bidRequests, addBidResponse, doneCb, requestCallbacks, requestBidsTimeout, onTimelyResponse) => { if (!bidRequests.length) { utils.logWarn('callBids executed with no bidRequests. Were they filtered by labels or sizing?'); return; @@ -323,7 +337,7 @@ adapterManager.callBids = (adUnits, bidRequests, addBidResponse, doneCb, request request: requestCallbacks.request.bind(null, bidRequest.bidderCode), done: requestCallbacks.done } : undefined); - adapter.callBids(bidRequest, addBidResponse.bind(bidRequest), doneCb.bind(bidRequest), ajax); + adapter.callBids(bidRequest, addBidResponse.bind(bidRequest), doneCb.bind(bidRequest), ajax, onTimelyResponse); }); } @@ -331,6 +345,10 @@ function doingS2STesting() { return _s2sConfig && _s2sConfig.enabled && _s2sConfig.testing && s2sTestingModule; } +function isTestingServerOnly() { + return Boolean(doingS2STesting() && _s2sConfig.testServerOnly); +}; + function getSupportedMediaTypes(bidderCode) { let result = []; if (includes(adapterManager.videoAdapters, bidderCode)) result.push('video'); diff --git a/src/adapters/analytics/example2.js b/src/adapters/analytics/example2.js index 6888507010d..b04e8874e48 100644 --- a/src/adapters/analytics/example2.js +++ b/src/adapters/analytics/example2.js @@ -1,4 +1,4 @@ -import { ajax } from 'src/ajax'; +import { ajax } from '../../../src/ajax'; /** * example2.js - analytics adapter for Example2 Analytics Endpoint example diff --git a/src/adapters/bidderFactory.js b/src/adapters/bidderFactory.js index 3306011d6aa..90cab154fd4 100644 --- a/src/adapters/bidderFactory.js +++ b/src/adapters/bidderFactory.js @@ -168,7 +168,7 @@ export function newBidder(spec) { return Object.freeze(spec); }, registerSyncs, - callBids: function(bidderRequest, addBidResponse, done, ajax) { + callBids: function(bidderRequest, addBidResponse, done, ajax, onTimelyResponse) { if (!Array.isArray(bidderRequest.bids)) { return; } @@ -267,6 +267,8 @@ export function newBidder(spec) { // If the adapter code fails, no bids should be added. After all the bids have been added, make // sure to call the `onResponse` function so that we're one step closer to calling done(). function onSuccess(response, responseObj) { + onTimelyResponse(spec.code); + try { response = JSON.parse(response); } catch (e) { /* response might not be JSON... that's ok. */ } @@ -316,6 +318,8 @@ export function newBidder(spec) { // If the server responds with an error, there's not much we can do. Log it, and make sure to // call onResponse() so that we're one step closer to calling done(). function onFailure(err) { + onTimelyResponse(spec.code); + logError(`Server call for ${spec.code} failed: ${err}. Continuing without bids.`); onResponse(); } diff --git a/src/auction.js b/src/auction.js index 7cb08af7402..fd29aec4b16 100644 --- a/src/auction.js +++ b/src/auction.js @@ -48,7 +48,7 @@ * @property {function(): void} callBids - sends requests to all adapters for bids */ -import { uniques, flatten, timestamp, adUnitsFilter, deepAccess, getBidRequest, getValue } from './utils'; +import { flatten, timestamp, adUnitsFilter, deepAccess, getBidRequest, getValue } from './utils'; import { parse as parseURL } from './url'; import { getPriceBucketString } from './cpmBucketManager'; import { getNativeTargeting } from './native'; @@ -58,7 +58,6 @@ import { config } from './config'; import { userSync } from './userSync'; import { hook } from './hook'; import find from 'core-js/library/fn/array/find'; -import includes from 'core-js/library/fn/array/includes'; import { OUTSTREAM } from './video'; const { syncUsers } = userSync; @@ -90,7 +89,7 @@ const queuedCalls = []; * * @returns {Auction} auction instance */ -export function newAuction({adUnits, adUnitCodes, callback, cbTimeout, labels}) { +export function newAuction({adUnits, adUnitCodes, callback, cbTimeout, labels, auctionId}) { let _adUnits = adUnits; let _labels = labels; let _adUnitCodes = adUnitCodes; @@ -99,12 +98,13 @@ export function newAuction({adUnits, adUnitCodes, callback, cbTimeout, labels}) let _noBids = []; let _auctionStart; let _auctionEnd; - let _auctionId = utils.generateUUID(); + let _auctionId = auctionId || utils.generateUUID(); let _auctionStatus; let _callback = callback; let _timer; let _timeout = cbTimeout; let _winningBids = []; + let _timelyBidders = new Set(); function addBidRequests(bidderRequests) { _bidderRequests = _bidderRequests.concat(bidderRequests) }; function addBidReceived(bidsReceived) { _bidsReceived = _bidsReceived.concat(bidsReceived); } @@ -140,27 +140,29 @@ export function newAuction({adUnits, adUnitCodes, callback, cbTimeout, labels}) clearTimeout(_timer); } - if (_callback != null) { + if (_auctionEnd === undefined) { let timedOutBidders = []; if (timedOut) { utils.logMessage(`Auction ${_auctionId} timedOut`); - timedOutBidders = getTimedOutBids(_bidderRequests, _bidsReceived); + timedOutBidders = getTimedOutBids(_bidderRequests, _timelyBidders); if (timedOutBidders.length) { events.emit(CONSTANTS.EVENTS.BID_TIMEOUT, timedOutBidders); } } - try { - _auctionStatus = AUCTION_COMPLETED; - _auctionEnd = Date.now(); - - events.emit(CONSTANTS.EVENTS.AUCTION_END, getProperties()); + _auctionStatus = AUCTION_COMPLETED; + _auctionEnd = Date.now(); - const adUnitCodes = _adUnitCodes; - const bids = _bidsReceived - .filter(utils.bind.call(adUnitsFilter, this, adUnitCodes)) - .reduce(groupByPlacement, {}); - _callback.apply($$PREBID_GLOBAL$$, [bids, timedOut]); + events.emit(CONSTANTS.EVENTS.AUCTION_END, getProperties()); + try { + if (_callback != null) { + const adUnitCodes = _adUnitCodes; + const bids = _bidsReceived + .filter(utils.bind.call(adUnitsFilter, this, adUnitCodes)) + .reduce(groupByPlacement, {}); + _callback.apply($$PREBID_GLOBAL$$, [bids, timedOut]); + _callback = null; + } } catch (e) { utils.logError('Error executing bidsBackHandler', null, e); } finally { @@ -175,7 +177,6 @@ export function newAuction({adUnits, adUnitCodes, callback, cbTimeout, labels}) syncUsers(userSyncConfig.syncDelay); } } - _callback = null; } } @@ -186,6 +187,10 @@ export function newAuction({adUnits, adUnitCodes, callback, cbTimeout, labels}) executeCallback(false, true); } + function onTimelyResponse(bidderCode) { + _timelyBidders.add(bidderCode); + } + function callBids() { _auctionStatus = AUCTION_STARTED; _auctionStart = Date.now(); @@ -240,7 +245,7 @@ export function newAuction({adUnits, adUnitCodes, callback, cbTimeout, labels}) } } } - }, _timeout); + }, _timeout, onTimelyResponse); } }; @@ -505,6 +510,41 @@ function setupBidTargeting(bidObject, bidderRequest) { bidObject.adserverTargeting = Object.assign(bidObject.adserverTargeting || {}, keyValues); } +/** + * This function returns the price granularity defined. It can be either publisher defined or default value + * @param {string} mediaType + * @returns {string} granularity + */ +export const getPriceGranularity = (mediaType) => { + // Use the config value 'mediaTypeGranularity' if it has been set for mediaType, else use 'priceGranularity' + const mediaTypeGranularity = config.getConfig(`mediaTypePriceGranularity.${mediaType}`); + const granularity = (typeof mediaType === 'string' && mediaTypeGranularity) ? ((typeof mediaTypeGranularity === 'string') ? mediaTypeGranularity : 'custom') : config.getConfig('priceGranularity'); + return granularity; +} + +/** + * This function returns a function to get bid price by price granularity + * @param {string} granularity + * @returns {function} + */ +export const getPriceByGranularity = (granularity) => { + return (bid) => { + if (granularity === CONSTANTS.GRANULARITY_OPTIONS.AUTO) { + return bid.pbAg; + } else if (granularity === CONSTANTS.GRANULARITY_OPTIONS.DENSE) { + return bid.pbDg; + } else if (granularity === CONSTANTS.GRANULARITY_OPTIONS.LOW) { + return bid.pbLg; + } else if (granularity === CONSTANTS.GRANULARITY_OPTIONS.MEDIUM) { + return bid.pbMg; + } else if (granularity === CONSTANTS.GRANULARITY_OPTIONS.HIGH) { + return bid.pbHg; + } else if (granularity === CONSTANTS.GRANULARITY_OPTIONS.CUSTOM) { + return bid.pbCg; + } + } +} + /** * @param {string} mediaType * @param {string} bidderCode @@ -525,9 +565,7 @@ export function getStandardBidderSettings(mediaType, bidderCode) { }; } const TARGETING_KEYS = CONSTANTS.TARGETING_KEYS; - // Use the config value 'mediaTypeGranularity' if it has been set for mediaType, else use 'priceGranularity' - const mediaTypeGranularity = config.getConfig(`mediaTypePriceGranularity.${mediaType}`); - const granularity = (typeof mediaType === 'string' && mediaTypeGranularity) ? ((typeof mediaTypeGranularity === 'string') ? mediaTypeGranularity : 'custom') : config.getConfig('priceGranularity'); + const granularity = getPriceGranularity(mediaType); let bidderSettings = $$PREBID_GLOBAL$$.bidderSettings; if (!bidderSettings[CONSTANTS.JSON_MAPPING.BD_SETTING_STANDARD]) { @@ -537,21 +575,7 @@ export function getStandardBidderSettings(mediaType, bidderCode) { bidderSettings[CONSTANTS.JSON_MAPPING.BD_SETTING_STANDARD][CONSTANTS.JSON_MAPPING.ADSERVER_TARGETING] = [ createKeyVal(TARGETING_KEYS.BIDDER, 'bidderCode'), createKeyVal(TARGETING_KEYS.AD_ID, 'adId'), - createKeyVal(TARGETING_KEYS.PRICE_BUCKET, function(bidResponse) { - if (granularity === CONSTANTS.GRANULARITY_OPTIONS.AUTO) { - return bidResponse.pbAg; - } else if (granularity === CONSTANTS.GRANULARITY_OPTIONS.DENSE) { - return bidResponse.pbDg; - } else if (granularity === CONSTANTS.GRANULARITY_OPTIONS.LOW) { - return bidResponse.pbLg; - } else if (granularity === CONSTANTS.GRANULARITY_OPTIONS.MEDIUM) { - return bidResponse.pbMg; - } else if (granularity === CONSTANTS.GRANULARITY_OPTIONS.HIGH) { - return bidResponse.pbHg; - } else if (granularity === CONSTANTS.GRANULARITY_OPTIONS.CUSTOM) { - return bidResponse.pbCg; - } - }), + createKeyVal(TARGETING_KEYS.PRICE_BUCKET, getPriceByGranularity(granularity)), createKeyVal(TARGETING_KEYS.SIZE, 'size'), createKeyVal(TARGETING_KEYS.DEAL, 'dealId'), createKeyVal(TARGETING_KEYS.SOURCE, 'source'), @@ -690,7 +714,7 @@ function groupByPlacement(bidsByPlacement, bid) { /** * Returns a list of bids that we haven't received a response yet where the bidder did not call done * @param {BidRequest[]} bidderRequests List of bids requested for auction instance - * @param {BidReceived[]} bidsReceived List of bids received for auction instance + * @param {Set} timelyBidders Set of bidders which responded in time * * @typedef {Object} TimedOutBid * @property {string} bidId The id representing the bid @@ -700,21 +724,9 @@ function groupByPlacement(bidsByPlacement, bid) { * * @return {Array} List of bids that Prebid hasn't received a response for */ -function getTimedOutBids(bidderRequests, bidsReceived) { - const bidRequestedWithoutDoneCodes = bidderRequests - .filter(bidderRequest => !bidderRequest.doneCbCallCount) - .map(bid => bid.bidderCode) - .filter(uniques); - - const bidReceivedCodes = bidsReceived - .map(bid => bid.bidder) - .filter(uniques); - - const timedOutBidderCodes = bidRequestedWithoutDoneCodes - .filter(bidder => !includes(bidReceivedCodes, bidder)); - +function getTimedOutBids(bidderRequests, timelyBidders) { const timedOutBids = bidderRequests - .map(bid => (bid.bids || []).filter(bid => includes(timedOutBidderCodes, bid.bidder))) + .map(bid => (bid.bids || []).filter(bid => !timelyBidders.has(bid.bidder))) .reduce(flatten, []) .map(bid => ({ bidId: bid.bidId, diff --git a/src/auctionManager.js b/src/auctionManager.js index a8ca246e148..53ff154bfd1 100644 --- a/src/auctionManager.js +++ b/src/auctionManager.js @@ -76,8 +76,8 @@ export function newAuctionManager() { .filter(uniques); }; - auctionManager.createAuction = function({ adUnits, adUnitCodes, callback, cbTimeout, labels }) { - const auction = newAuction({ adUnits, adUnitCodes, callback, cbTimeout, labels }); + auctionManager.createAuction = function({ adUnits, adUnitCodes, callback, cbTimeout, labels, auctionId }) { + const auction = newAuction({ adUnits, adUnitCodes, callback, cbTimeout, labels, auctionId }); _addAuction(auction); return auction; }; diff --git a/src/config.js b/src/config.js index a1a8af629d8..ec26c3d51d0 100644 --- a/src/config.js +++ b/src/config.js @@ -1,19 +1,15 @@ /* * Module for getting and setting Prebid configuration. - * - * Prebid previously defined these properties directly on the global object: - * pbjs.logging = true; - * - * Defining and access properties in this way is now deprecated, but these will - * continue to work during a deprecation window. */ import { isValidPriceConfig } from './cpmBucketManager'; import find from 'core-js/library/fn/array/find'; import includes from 'core-js/library/fn/array/includes'; -import { hook } from './hook'; +import { parseQS } from './url'; + const utils = require('./utils'); +const CONSTANTS = require('./constants'); -const DEFAULT_DEBUG = false; +const DEFAULT_DEBUG = (parseQS(window.location.search)[CONSTANTS.DEBUG_MODE] || '').toUpperCase() === 'TRUE'; const DEFAULT_BIDDER_TIMEOUT = 3000; const DEFAULT_PUBLISHER_DOMAIN = window.location.origin; const DEFAULT_ENABLE_SEND_ALL_BIDS = true; @@ -231,7 +227,7 @@ export function newConfig() { * Sets configuration given an object containing key-value pairs and calls * listeners that were added by the `subscribe` function */ - let setConfig = hook('async', function setConfig(options) { + function setConfig(options) { if (typeof options !== 'object') { utils.logError('setConfig options must be an object'); return; @@ -251,7 +247,7 @@ export function newConfig() { }); callSubscribers(topicalConfig); - }); + } /** * Sets configuration defaults which setConfig values can be applied on top of diff --git a/src/constants.json b/src/constants.json index a181df3f684..99e2bd792b9 100644 --- a/src/constants.json +++ b/src/constants.json @@ -72,6 +72,7 @@ "body": "hb_native_body", "body2": "hb_native_body2", "privacyLink": "hb_native_privacy", + "privacyIcon": "hb_native_privicon", "sponsoredBy": "hb_native_brand", "image": "hb_native_image", "icon": "hb_native_icon", diff --git a/src/hook.js b/src/hook.js index 7727155e8aa..220e1c39111 100644 --- a/src/hook.js +++ b/src/hook.js @@ -1,5 +1,5 @@ -import funHooks from 'fun-hooks'; +import funHooks from 'fun-hooks/no-eval'; export let hook = funHooks({ ready: funHooks.SYNC | funHooks.ASYNC | funHooks.QUEUE @@ -13,3 +13,16 @@ export function setupBeforeHookFnOnce(baseFn, hookFn, priority = 15) { baseFn.before(hookFn, priority); } } + +export function module(name, install) { + hook('async', function (submodules) { + submodules.forEach(args => install(...args)); + }, name)([]); // will be queued until hook.ready() called in pbjs.processQueue(); +} + +export function submodule(name, ...args) { + getHook(name).before((next, modules) => { + modules.push(args); + next(modules); + }); +} diff --git a/src/native.js b/src/native.js index c9a67ca7541..6252eb133b3 100644 --- a/src/native.js +++ b/src/native.js @@ -132,7 +132,6 @@ export function nativeBidIsValid(bid, bidRequests) { */ export function fireNativeTrackers(message, adObject) { let trackers; - if (message.action === 'click') { trackers = adObject['native'] && adObject['native'].clickTrackers; } else { diff --git a/src/prebid.js b/src/prebid.js index 7b8548d8070..efa1198d36c 100644 --- a/src/prebid.js +++ b/src/prebid.js @@ -260,16 +260,17 @@ $$PREBID_GLOBAL$$.setTargetingForGPTAsync = function (adUnit, customSlotMatching /** * Set query string targeting on all AST (AppNexus Seller Tag) ad units. Note that this function has to be called after all ad units on page are defined. For working example code, see [Using Prebid.js with AppNexus Publisher Ad Server](http://prebid.org/dev-docs/examples/use-prebid-with-appnexus-ad-server.html). + * @param {(string|string[])} adUnitCode adUnitCode or array of adUnitCodes * @alias module:pbjs.setTargetingForAst */ -$$PREBID_GLOBAL$$.setTargetingForAst = function() { +$$PREBID_GLOBAL$$.setTargetingForAst = function(adUnitCodes) { utils.logInfo('Invoking $$PREBID_GLOBAL$$.setTargetingForAn', arguments); if (!targeting.isApntagDefined()) { utils.logError('window.apntag is not defined on the page'); return; } - targeting.setTargetingForAst(); + targeting.setTargetingForAst(adUnitCodes); // emit event events.emit(SET_TARGETING, targeting.getAllTargeting()); @@ -324,7 +325,16 @@ $$PREBID_GLOBAL$$.renderAd = function (doc, id) { const message = `Error trying to write ad. Ad render call ad id ${id} was prevented from writing to the main document.`; emitAdRenderFail(PREVENT_WRITING_ON_MAIN_DOCUMENT, message, bid); } else if (ad) { - doc.open('text/html', 'replace'); + // will check if browser is firefox and below version 67, if so execute special doc.open() + // for details see: https://github.com/prebid/Prebid.js/pull/3524 + // TODO remove this browser specific code at later date (when Firefox < 67 usage is mostly gone) + if (navigator.userAgent && navigator.userAgent.toLowerCase().indexOf('firefox/') > -1) { + const firefoxVerRegx = /firefox\/([\d\.]+)/; + let firefoxVer = navigator.userAgent.toLowerCase().match(firefoxVerRegx)[1]; // grabs the text in the 1st matching group + if (firefoxVer && parseInt(firefoxVer, 10) < 67) { + doc.open('text/html', 'replace'); + } + } doc.write(ad); doc.close(); setRenderSize(doc, width, height); @@ -380,12 +390,12 @@ $$PREBID_GLOBAL$$.removeAdUnit = function (adUnitCode) { } adUnitCodes.forEach((adUnitCode) => { - for (let i = 0; i < $$PREBID_GLOBAL$$.adUnits.length; i++) { + for (let i = $$PREBID_GLOBAL$$.adUnits.length - 1; i >= 0; i--) { if ($$PREBID_GLOBAL$$.adUnits[i].code === adUnitCode) { $$PREBID_GLOBAL$$.adUnits.splice(i, 1); } } - }) + }); }; /** @@ -395,9 +405,10 @@ $$PREBID_GLOBAL$$.removeAdUnit = function (adUnitCode) { * @param {Array} requestOptions.adUnits * @param {Array} requestOptions.adUnitCodes * @param {Array} requestOptions.labels + * @param {String} requestOptions.auctionId * @alias module:pbjs.requestBids */ -$$PREBID_GLOBAL$$.requestBids = hook('async', function ({ bidsBackHandler, timeout, adUnits, adUnitCodes, labels } = {}) { +$$PREBID_GLOBAL$$.requestBids = hook('async', function ({ bidsBackHandler, timeout, adUnits, adUnitCodes, labels, auctionId } = {}) { events.emit(REQUEST_BIDS); const cbTimeout = timeout || config.getConfig('bidderTimeout'); adUnits = adUnits || $$PREBID_GLOBAL$$.adUnits; @@ -466,7 +477,7 @@ $$PREBID_GLOBAL$$.requestBids = hook('async', function ({ bidsBackHandler, timeo return; } - const auction = auctionManager.createAuction({adUnits, adUnitCodes, callback: bidsBackHandler, cbTimeout, labels}); + const auction = auctionManager.createAuction({adUnits, adUnitCodes, callback: bidsBackHandler, cbTimeout, labels, auctionId}); let adUnitsLen = adUnits.length; if (adUnitsLen > 15) { diff --git a/src/secureCreatives.js b/src/secureCreatives.js index 8505923c493..df7abe4ebee 100644 --- a/src/secureCreatives.js +++ b/src/secureCreatives.js @@ -31,7 +31,7 @@ function receiveMessage(ev) { return bid.adId === data.adId; }); - if (data.message === 'Prebid Request') { + if (adObject && data.message === 'Prebid Request') { _sendAdToCreative(adObject, data.adServerDomain, ev.source); // save winning bids @@ -45,7 +45,7 @@ function receiveMessage(ev) { // message: 'Prebid Native', // adId: '%%PATTERN:hb_adid%%' // }), '*'); - if (data.message === 'Prebid Native') { + if (adObject && data.message === 'Prebid Native') { if (data.action === 'assetRequest') { const message = getAssetMessage(data, adObject); ev.source.postMessage(JSON.stringify(message), ev.origin); @@ -81,7 +81,7 @@ export function _sendAdToCreative(adObject, remoteDomain, source) { function resizeRemoteCreative({ adUnitCode, width, height }) { // resize both container div + iframe - ['div', 'iframe'].forEach(elmType => { + ['div:last-child', 'div:last-child iframe'].forEach(elmType => { let element = getElementByAdUnit(elmType); if (element) { let elementStyle = element.style; diff --git a/src/sizeMapping.js b/src/sizeMapping.js index 04c9773a1af..cde3b4a4d15 100644 --- a/src/sizeMapping.js +++ b/src/sizeMapping.js @@ -88,9 +88,9 @@ export function resolveStatus({labels = [], labelAll = false, activeLabels = []} let results = { active: ( - allMediaTypes.length > 1 || (allMediaTypes.length === 1 && allMediaTypes[0] !== 'banner') + allMediaTypes.every(type => type !== 'banner') ) || ( - allMediaTypes[0] === 'banner' && deepAccess(mediaTypes, 'banner.sizes.length') > 0 && ( + allMediaTypes.some(type => type === 'banner') && deepAccess(mediaTypes, 'banner.sizes.length') > 0 && ( labels.length === 0 || ( (!labelAll && ( labels.some(label => maps.labels[label]) || diff --git a/src/targeting.js b/src/targeting.js index 90897b8d956..33108f9a6a4 100644 --- a/src/targeting.js +++ b/src/targeting.js @@ -1,4 +1,4 @@ -import { uniques, isGptPubadsDefined, getHighestCpm, getOldestHighestCpmBid, groupBy, isAdUnitCodeMatchingSlot, timestamp, deepAccess } from './utils'; +import { uniques, isGptPubadsDefined, getHighestCpm, getOldestHighestCpmBid, groupBy, isAdUnitCodeMatchingSlot, timestamp, deepAccess, deepClone, logError, logWarn, logInfo } from './utils'; import { config } from './config'; import { NATIVE_TARGETING_KEYS } from './native'; import { auctionManager } from './auctionManager'; @@ -43,6 +43,40 @@ export function getHighestCpmBidsFromBidPool(bidsReceived, highestCpmCallback) { return bids; } +/** +* A descending sort function that will sort the list of objects based on the following two dimensions: +* - bids with a deal are sorted before bids w/o a deal +* - then sort bids in each grouping based on the hb_pb value +* eg: the following list of bids would be sorted like: +* [{ +* "hb_adid": "vwx", +* "hb_pb": "28", +* "hb_deal": "7747" +* }, { +* "hb_adid": "jkl", +* "hb_pb": "10", +* "hb_deal": "9234" +* }, { +* "hb_adid": "stu", +* "hb_pb": "50" +* }, { +* "hb_adid": "def", +* "hb_pb": "2" +* }] +*/ +export function sortByDealAndPriceBucket(a, b) { + if (a.adUnitTargeting.hb_deal !== undefined && b.adUnitTargeting.hb_deal === undefined) { + return -1; + } + + if ((a.adUnitTargeting.hb_deal === undefined && b.adUnitTargeting.hb_deal !== undefined)) { + return 1; + } + + // assuming both values either have a deal or don't have a deal - sort by the hb_pb param + return b.adUnitTargeting.hb_pb - a.adUnitTargeting.hb_pb; +} + /** * @typedef {Object.} targeting * @property {string} targeting_key @@ -95,6 +129,40 @@ export function newTargeting(auctionManager) { }); }; + /** + * checks if bid has targeting set and belongs based on matching ad unit codes + * @return {boolean} true or false + */ + function bidShouldBeAddedToTargeting(bid, adUnitCodes) { + return bid.adserverTargeting && adUnitCodes && + ((utils.isArray(adUnitCodes) && includes(adUnitCodes, bid.adUnitCode)) || + (typeof adUnitCodes === 'string' && bid.adUnitCode === adUnitCodes)); + }; + + /** + * Returns targeting for any bids which have deals if alwaysIncludeDeals === true + */ + function getDealBids(adUnitCodes, bidsReceived) { + if (config.getConfig('targetingControls.alwaysIncludeDeals') === true) { + const standardKeys = TARGETING_KEYS.concat(NATIVE_TARGETING_KEYS); + + // we only want the top bid from bidders who have multiple entries per ad unit code + const bids = getHighestCpmBidsFromBidPool(bidsReceived, getHighestCpm); + + // populate targeting keys for the remaining bids if they have a dealId + return bids.map(bid => { + if (bid.dealId && bidShouldBeAddedToTargeting(bid, adUnitCodes)) { + return { + [bid.adUnitCode]: getTargetingMap(bid, standardKeys.filter( + key => typeof bid.adserverTargeting[key] !== 'undefined') + ) + }; + } + }).filter(bid => bid); // removes empty elements in array + } + return []; + }; + /** * Returns all ad server targeting for all ad units. * @param {string=} adUnitCode @@ -107,7 +175,7 @@ export function newTargeting(auctionManager) { // `alwaysUseBid=true`. If sending all bids is enabled, add targeting for losing bids. var targeting = getWinningBidTargeting(adUnitCodes, bidsReceived) .concat(getCustomBidTargeting(adUnitCodes, bidsReceived)) - .concat(config.getConfig('enableSendAllBids') ? getBidLandscapeTargeting(adUnitCodes, bidsReceived) : []); + .concat(config.getConfig('enableSendAllBids') ? getBidLandscapeTargeting(adUnitCodes, bidsReceived) : getDealBids(adUnitCodes, bidsReceived)); // store a reference of the targeting keys targeting.map(adUnitCode => { @@ -122,8 +190,13 @@ export function newTargeting(auctionManager) { targeting = flattenTargeting(targeting); - // make sure at least there is a entry per adUnit code in the targetingSet so receivers of SET_TARGETING call's can know what ad units are being invoked + const auctionKeysThreshold = config.getConfig('targetingControls.auctionKeyMaxChars'); + if (auctionKeysThreshold) { + logInfo(`Detected 'targetingControls.auctionKeyMaxChars' was active for this auction; set with a limit of ${auctionKeysThreshold} characters. Running checks on auction keys...`); + targeting = filterTargetingKeys(targeting, auctionKeysThreshold); + } + // make sure at least there is a entry per adUnit code in the targetingSet so receivers of SET_TARGETING call's can know what ad units are being invoked adUnitCodes.forEach(code => { if (!targeting[code]) { targeting[code] = {}; @@ -133,6 +206,54 @@ export function newTargeting(auctionManager) { return targeting; }; + // create an encoded string variant based on the keypairs of the provided object + // - note this will encode the characters between the keys (ie = and &) + function convertKeysToQueryForm(keyMap) { + return Object.keys(keyMap).reduce(function (queryString, key) { + let encodedKeyPair = `${key}%3d${encodeURIComponent(keyMap[key])}%26`; + return queryString += encodedKeyPair; + }, ''); + } + + function filterTargetingKeys(targeting, auctionKeysThreshold) { + // read each targeting.adUnit object and sort the adUnits into a list of adUnitCodes based on priorization setting (eg CPM) + let targetingCopy = deepClone(targeting); + + let targetingMap = Object.keys(targetingCopy).map(adUnitCode => { + return { + adUnitCode, + adUnitTargeting: targetingCopy[adUnitCode] + }; + }).sort(sortByDealAndPriceBucket); + + // iterate through the targeting based on above list and transform the keys into the query-equivalent and count characters + return targetingMap.reduce(function (accMap, currMap, index, arr) { + let adUnitQueryString = convertKeysToQueryForm(currMap.adUnitTargeting); + + // for the last adUnit - trim last encoded ampersand from the converted query string + if ((index + 1) === arr.length) { + adUnitQueryString = adUnitQueryString.slice(0, -3); + } + + // if under running threshold add to result + let code = currMap.adUnitCode; + let querySize = adUnitQueryString.length; + if (querySize <= auctionKeysThreshold) { + auctionKeysThreshold -= querySize; + logInfo(`AdUnit '${code}' auction keys comprised of ${querySize} characters. Deducted from running threshold; new limit is ${auctionKeysThreshold}`, targetingCopy[code]); + + accMap[code] = targetingCopy[code]; + } else { + logWarn(`The following keys for adUnitCode '${code}' exceeded the current limit of the 'auctionKeyMaxChars' setting.\nThe key-set size was ${querySize}, the current allotted amount was ${auctionKeysThreshold}.\n`, targetingCopy[code]); + } + + if ((index + 1) === arr.length && Object.keys(accMap).length === 0) { + logError('No auction targeting keys were permitted due to the setting in setConfig(targetingControls.auctionKeyMaxChars). Please review setup and consider adjusting.'); + } + return accMap; + }, {}); + } + /** * Converts targeting array and flattens to make it easily iteratable * e.g: Sample input to this function @@ -248,13 +369,14 @@ export function newTargeting(auctionManager) { }; /** + * @param {(string|string[])} adUnitCode adUnitCode or array of adUnitCodes * Sets targeting for AST */ - targeting.setTargetingForAst = function() { - let astTargeting = targeting.getAllTargeting(); + targeting.setTargetingForAst = function(adUnitCodes) { + let astTargeting = targeting.getAllTargeting(adUnitCodes); try { - targeting.resetPresetTargetingAST(); + targeting.resetPresetTargetingAST(adUnitCodes); } catch (e) { utils.logError('unable to reset targeting for AST' + e) } @@ -355,7 +477,7 @@ export function newTargeting(auctionManager) { } function getCustomKeys() { - let standardKeys = getStandardKeys(); + let standardKeys = getStandardKeys().concat(NATIVE_TARGETING_KEYS); return function(key) { return standardKeys.indexOf(key) === -1; } @@ -401,11 +523,7 @@ export function newTargeting(auctionManager) { // populate targeting keys for the remaining bids return bids.map(bid => { - if ( - bid.adserverTargeting && adUnitCodes && - ((utils.isArray(adUnitCodes) && includes(adUnitCodes, bid.adUnitCode)) || - (typeof adUnitCodes === 'string' && bid.adUnitCode === adUnitCodes)) - ) { + if (bidShouldBeAddedToTargeting(bid, adUnitCodes)) { return { [bid.adUnitCode]: getTargetingMap(bid, standardKeys.filter( key => typeof bid.adserverTargeting[key] !== 'undefined') diff --git a/src/userSync.js b/src/userSync.js index 8e0b919572e..e2bd4e3f04a 100644 --- a/src/userSync.js +++ b/src/userSync.js @@ -24,8 +24,8 @@ export function newUserSync(userSyncDependencies) { // Let getDefaultQueue() set the defaults let queue = getDefaultQueue(); - // Whether or not user syncs have been trigger on this page load - let hasFired = false; + // Whether or not user syncs have been trigger on this page load for a specific bidder + let hasFiredBidder = new Set(); // How many bids for each adapter let numAdapterBids = {}; @@ -33,7 +33,7 @@ export function newUserSync(userSyncDependencies) { let permittedPixels = { image: false, iframe: false - } + }; // Use what is in config by default let usConfig = userSyncDependencies.config; @@ -61,7 +61,7 @@ export function newUserSync(userSyncDependencies) { * @private */ function fireSyncs() { - if (!usConfig.syncEnabled || !userSyncDependencies.browserSupportsCookies || (!usConfig.enableOverride && hasFired)) { + if (!usConfig.syncEnabled || !userSyncDependencies.browserSupportsCookies) { return; } @@ -75,7 +75,16 @@ export function newUserSync(userSyncDependencies) { } // Reset the user sync queue queue = getDefaultQueue(); - hasFired = true; + } + + function forEachFire(queue, fn) { + // Randomize the order of the pixels before firing + // This is to avoid giving any bidder who has registered multiple syncs + // any preferential treatment and balancing them out + utils.shuffle(queue).forEach((sync) => { + fn(sync); + hasFiredBidder.add(sync[0]); + }); } /** @@ -87,10 +96,7 @@ export function newUserSync(userSyncDependencies) { if (!(usConfig.pixelEnabled || permittedPixels.image)) { return; } - // Randomize the order of the pixels before firing - // This is to avoid giving any bidder who has registered multiple syncs - // any preferential treatment and balancing them out - utils.shuffle(queue.image).forEach((sync) => { + forEachFire(queue.image, (sync) => { let [bidderName, trackingPixelUrl] = sync; utils.logMessage(`Invoking image pixel user sync for bidder: ${bidderName}`); // Create image object and add the src url @@ -107,8 +113,7 @@ export function newUserSync(userSyncDependencies) { if (!(usConfig.iframeEnabled || permittedPixels.iframe)) { return; } - // Randomize the order of these syncs just like the pixels above - utils.shuffle(queue.iframe).forEach((sync) => { + forEachFire(queue.iframe, (sync) => { let [bidderName, iframeUrl] = sync; utils.logMessage(`Invoking iframe user sync for bidder: ${bidderName}`); // Insert iframe into DOM @@ -146,6 +151,9 @@ export function newUserSync(userSyncDependencies) { * userSync.registerSync('image', 'rubicon', 'http://example.com/pixel') */ publicApi.registerSync = (type, bidder, url) => { + if (hasFiredBidder.has(bidder)) { + return utils.logMessage(`already fired syncs for "${bidder}", ignoring registerSync call`); + } if (!usConfig.syncEnabled || !utils.isArray(queue[type])) { return utils.logWarn(`User sync type "${type}" not supported`); } @@ -156,13 +164,9 @@ export function newUserSync(userSyncDependencies) { return utils.logWarn(`Number of user syncs exceeded for "${bidder}"`); } - if (usConfig.filterSettings) { - if (shouldBidderBeBlocked(type, bidder)) { - return utils.logWarn(`Bidder '${bidder}' is not permitted to register their userSync ${type} pixels as per filterSettings config.`); - } - // TODO remove this else if code that supports deprecated fields (sometime in 2.x); for now - only run if filterSettings config is not present - } else if (usConfig.enabledBidders && usConfig.enabledBidders.length && usConfig.enabledBidders.indexOf(bidder) < 0) { - return utils.logWarn(`Bidder "${bidder}" not permitted to register their userSync pixels.`); + const canBidderRegisterSync = publicApi.canBidderRegisterSync(type, bidder); + if (!canBidderRegisterSync) { + return utils.logWarn(`Bidder "${bidder}" not permitted to register their "${type}" userSync pixels.`); } // the bidder's pixel has passed all checks and is allowed to register @@ -262,6 +266,21 @@ export function newUserSync(userSyncDependencies) { } }; + publicApi.canBidderRegisterSync = (type, bidder) => { + if (usConfig.filterSettings) { + if (shouldBidderBeBlocked(type, bidder)) { + return false; + } + // TODO remove this else if code that supports deprecated fields (sometime in 2.x); for now - only run if filterSettings config is not present + } else if (usConfig.enabledBidders && usConfig.enabledBidders.length && usConfig.enabledBidders.indexOf(bidder) < 0) { + return false + } else if (type === 'iframe' && !(usConfig.iframeEnabled || permittedPixels.iframe)) { + return false; + } else if (type === 'image' && !(usConfig.pixelEnabled || permittedPixels.image)) { + return false; + } + return true; + } return publicApi; } diff --git a/src/utils.js b/src/utils.js index ea80e970786..21a1943b1a1 100644 --- a/src/utils.js +++ b/src/utils.js @@ -5,7 +5,8 @@ import includes from 'core-js/library/fn/array/includes'; import { parse } from './url'; const CONSTANTS = require('./constants'); -var _loggingChecked = false; +export { default as deepAccess } from 'dlv/index'; +export { default as deepSetValue } from 'dset'; var tArr = 'Array'; var tStr = 'String'; @@ -221,15 +222,27 @@ export function parseSizesInput(sizeObj) { return parsedSizes; } -// parse a GPT style sigle size array, (i.e [300,250]) +// Parse a GPT style single size array, (i.e [300, 250]) // into an AppNexus style string, (i.e. 300x250) export function parseGPTSingleSizeArray(singleSize) { - // if we aren't exactly 2 items in this array, it is invalid - if (isArray(singleSize) && singleSize.length === 2 && (!isNaN(singleSize[0]) && !isNaN(singleSize[1]))) { + if (isValidGPTSingleSize(singleSize)) { return singleSize[0] + 'x' + singleSize[1]; } } +// Parse a GPT style single size array, (i.e [300, 250]) +// into OpenRTB-compatible (imp.banner.w/h, imp.banner.format.w/h, imp.video.w/h) object(i.e. {w:300, h:250}) +export function parseGPTSingleSizeArrayToRtbSize(singleSize) { + if (isValidGPTSingleSize(singleSize)) { + return {w: singleSize[0], h: singleSize[1]}; + } +} + +function isValidGPTSingleSize(singleSize) { + // if we aren't exactly 2 items in this array, it is invalid + return isArray(singleSize) && singleSize.length === 2 && (!isNaN(singleSize[0]) && !isNaN(singleSize[1])); +} + /** * @deprecated This function will be removed soon. Use http://prebid.org/dev-docs/bidder-adaptor.html#referrers */ @@ -354,12 +367,6 @@ export function hasConsoleLogger() { } export function debugTurnedOn() { - if (config.getConfig('debug') === false && _loggingChecked === false) { - const debug = getParameterByName(CONSTANTS.DEBUG_MODE).toUpperCase() === 'TRUE'; - config.setConfig({ debug }); - _loggingChecked = true; - } - return !!config.getConfig('debug'); } @@ -564,7 +571,7 @@ export function _map(object, callback) { return output; } -var hasOwn = function (objectToCheck, propertyToCheckFor) { +export function hasOwn(objectToCheck, propertyToCheckFor) { if (objectToCheck.hasOwnProperty) { return objectToCheck.hasOwnProperty(propertyToCheckFor); } else { @@ -966,26 +973,6 @@ export function groupBy(xs, key) { }, {}); } -/** - * deepAccess utility function useful for doing safe access (will not throw exceptions) of deep object paths. - * @param {Object} obj The object containing the values you would like to access. - * @param {string|number} path Object path to the value you would like to access. Non-strings are coerced to strings. - * @returns {*} The value found at the specified object path, or undefined if path is not found. - */ -export function deepAccess(obj, path) { - if (!obj) { - return; - } - path = String(path).split('.'); - for (let i = 0; i < path.length; i++) { - obj = obj[path[i]]; - if (typeof obj === 'undefined') { - return; - } - } - return obj; -} - /** * Returns content for a friendly iframe to execute a URL in script tag * @param {string} url URL to be executed in a script tag in a friendly iframe @@ -1150,6 +1137,53 @@ export function convertCamelToUnderscore(value) { return value.replace(/(?:^|\.?)([A-Z])/g, function (x, y) { return '_' + y.toLowerCase() }).replace(/^_/, ''); } +/** + * Returns a new object with undefined properties removed from given object + * @param obj the object to clean + */ +export function cleanObj(obj) { + return Object.keys(obj).reduce((newObj, key) => { + if (typeof obj[key] !== 'undefined') { + newObj[key] = obj[key]; + } + return newObj; + }, {}) +} + +/** + * Create a new object with selected properties. Also allows property renaming and transform functions. + * @param obj the original object + * @param properties An array of desired properties + */ +export function pick(obj, properties) { + if (typeof obj !== 'object') { + return {}; + } + return properties.reduce((newObj, prop, i) => { + if (typeof prop === 'function') { + return newObj; + } + + let newProp = prop; + let match = prop.match(/^(.+?)\sas\s(.+?)$/i); + + if (match) { + prop = match[1]; + newProp = match[2]; + } + + let value = obj[prop]; + if (typeof properties[i + 1] === 'function') { + value = properties[i + 1](value, newObj); + } + if (typeof value !== 'undefined') { + newObj[newProp] = value; + } + + return newObj; + }, {}); +} + /** * Converts an object of arrays (either strings or numbers) into an array of objects containing key and value properties * normally read from bidder params diff --git a/src/video.js b/src/video.js index 9cf25016d46..57f44a76764 100644 --- a/src/video.js +++ b/src/video.js @@ -6,6 +6,7 @@ import { hook } from './hook'; const VIDEO_MEDIA_TYPE = 'video'; export const OUTSTREAM = 'outstream'; +export const INSTREAM = 'instream'; /** * Helper functions for working with video-enabled adUnits @@ -48,7 +49,7 @@ export const checkVideoBidSetup = hook('sync', function(bid, bidRequest, videoMe if (!config.getConfig('cache.url') && bid.vastXml && !bid.vastUrl) { logError(` This bid contains only vastXml and will not work when a prebid cache url is not specified. - Try enabling prebid cache with pbjs.setConfig({ cache: {url: "..."} }); + Try enabling prebid cache with $$PREBID_GLOBAL$$.setConfig({ cache: {url: "..."} }); `); return false; } diff --git a/test/fixtures/fixtures.js b/test/fixtures/fixtures.js index 050ff90bc7a..2637bb30de6 100644 --- a/test/fixtures/fixtures.js +++ b/test/fixtures/fixtures.js @@ -1484,3 +1484,64 @@ export function createBidReceived({bidder, cpm, auctionId, responseTimestamp, ad } return bid; } + +export function getServerTestingsAds() { + return [ + { + code: 'test_div_1', + sizes: [[728, 90]], + bids: [ + { + 'bidSource': { 'client': 0, 'server': 100 }, + 'bidder': 'rubicon' + }, + { + 'bidSource': { 'client': 100, 'server': 0 }, + 'bidder': 'appnexus' + } + ] + }, + { + code: 'test_div_2', + sizes: [[300, 250]], + bids: [ + { + 'bidSource': { 'client': 100, 'server': 0 }, + 'bidder': 'rubicon' + }, + { + 'bidSource': { 'client': 100, 'server': 0 }, + 'bidder': 'appnexus' + } + ] + }, + { + code: 'test_div_3', + sizes: [[300, 250]], + bids: [{ bidder: 'adequant' }] + }, + { + code: 'test_div_4', + sizes: [[300, 250]], + bids: [{ bidder: 'openx' }] + } + ]; +}; + +export const getServerTestingConfig = (config, override = {}) => + Object.assign({}, config, { + enabled: true, + testing: true, + testServerOnly: true, + bidders: ['appnexus', 'rubicon', 'openx'], + bidderControl: { + rubicon: { + bidSource: { server: 100, client: 0 }, + includeSourceKvp: true + }, + appnexus: { + bidSource: { server: 0, client: 100 }, + includeSourceKvp: true + } + } + }, override); diff --git a/test/helpers/testing-utils.js b/test/helpers/testing-utils.js new file mode 100644 index 00000000000..21d5992873e --- /dev/null +++ b/test/helpers/testing-utils.js @@ -0,0 +1,4 @@ +module.exports = { + host: (process.env.TEST_SERVER_HOST) ? process.env.TEST_SERVER_HOST : 'localhost', + protocol: (process.env.TEST_SERVER_PROTOCOL) ? 'https' : 'http' +} diff --git a/test/pages/banner.html b/test/pages/banner.html new file mode 100644 index 00000000000..03f3b9b9e54 --- /dev/null +++ b/test/pages/banner.html @@ -0,0 +1,94 @@ + + + + + + + Prebid.js Banner Example + + + + + + + + + + + + + + + +

    Prebid.js Banner Ad Unit Test

    +
    + +
    +
    + + + diff --git a/test/pages/native.html b/test/pages/native.html new file mode 100644 index 00000000000..0823f486848 --- /dev/null +++ b/test/pages/native.html @@ -0,0 +1,123 @@ + + + + + + + Prebid.js Native Example + + + + + + + + + + + + + + + +

    Prebid.js Native Ad Unit Test

    +
    +

    No response

    + +
    + + + diff --git a/test/pages/outstream.html b/test/pages/outstream.html new file mode 100644 index 00000000000..56e443a519b --- /dev/null +++ b/test/pages/outstream.html @@ -0,0 +1,168 @@ + + + + + + + Prebid.js Video Outstream Example + + + + + + + + + + + + +
    +

    + In scelerisque sem sed tortor posuere sagittis. Fusce scelerisque odio at tincidunt ultricies. Fusce egestas, erat + non finibus dictum, nulla arcu viverra nibh, at bibendum ligula nisi egestas magna. Nulla eu finibus nulla. + Pellentesque at mi eget turpis + consequat scelerisque. Sed lacinia, nisi sit amet egestas vestibulum, elit odio iaculis leo, et lacinia risus enim + non lacus. Cras nec neque eget nunc gravida maximus. Ut hendrerit convallis sollicitudin. Donec cursus erat vel + metus gravida, + et pretium justo iaculis. Curabitur condimentum blandit augue, quis interdum leo. Vivamus dapibus est nec dui + efficitur, eu imperdiet nulla sollicitudin. Suspendisse laoreet velit vitae arcu mollis, ac interdum lorem + venenatis. Aenean + nec purus varius, accumsan ex at, luctus arcu. Quisque consectetur tortor eros, placerat lacinia eros aliquam a. + Proin non porttitor libero. +

    +

    + Proin eget vulputate est. Nunc sit amet neque a tortor ullamcorper suscipit non eu neque. Quisque at massa in + metus feugiat rutrum. Nulla et orci orci. Aliquam erat volutpat. Cras tincidunt metus lectus, sed suscipit augue + mollis vitae. Sed quis condimentum + tortor, sit amet consectetur erat. Nulla pellentesque turpis lacus, eu venenatis massa fringilla at. Duis sed + pharetra turpis. Maecenas vel porttitor neque. Praesent quis felis sapien. Donec suscipit euismod dui, vitae + fermentum nisi ornare + in. +

    +

    + Suspendisse tempor felis accumsan orci finibus, imperdiet mollis arcu imperdiet. In eu dolor condimentum, pulvinar + nisl a, sollicitudin nunc. Ut vel lectus libero. Praesent rhoncus leo tortor, at mollis nulla sagittis eget. + Quisque tempus tempor augue + sed rutrum. Sed vitae volutpat quam. Proin vestibulum eros metus, a luctus erat condimentum eu. Vivamus + ullamcorper ultricies dui, ac malesuada leo finibus semper. Cras diam augue, imperdiet sed efficitur id, aliquam + sed purus. Praesent + eget turpis quis sapien interdum sagittis. Vivamus placerat nunc a tempus fermentum. Praesent laoreet leo at + tellus porta, ut viverra tortor pharetra. Quisque elit velit, eleifend eget imperdiet vel, suscipit ac nisi. + Aliquam egestas mauris + ut massa fringilla laoreet. +

    +
    +

    Prebid Outstream Video Ad

    + +
    +

    + Quisque ac luctus nisi, vitae ornare arcu. Proin fermentum sapien vitae odio vestibulum porta. Suspendisse + faucibus sapien enim, et faucibus urna tempus et. Integer porttitor justo sed faucibus blandit. Morbi semper + lectus vitae semper facilisis. Quisque + molestie accumsan arcu, eget bibendum dui euismod et. Sed in mattis lacus, nec lacinia sem. Fusce sed tortor + posuere, iaculis justo varius, elementum est. +

    +

    + Etiam condimentum, eros commodo semper tristique, lorem leo pharetra massa, eget cursus justo enim id urna. Sed + imperdiet mauris vitae ante bibendum elementum. Etiam eu dui porttitor leo imperdiet cursus. Maecenas consequat, + neque a dapibus viverra, nunc + velit volutpat nibh, ut cursus sem tortor ac arcu. Praesent convallis lacus vel nisi aliquam, in posuere libero + scelerisque. Curabitur et lacinia nisl. Nunc id ligula neque. Phasellus non eros et leo ultrices ultricies. Nulla + facilisi. + Donec ut augue urna. Suspendisse sodales nisi at ex faucibus, et tempus magna fermentum. Proin non arcu interdum, + pulvinar est at, vehicula odio. Morbi nec maximus sem. Ut eu tristique urna. +

    +

    + Pellentesque eget quam sem. Nam interdum eleifend leo, mattis sagittis metus ornare tristique. Cras pretium odio + lectus, vitae viverra massa consequat eget. Suspendisse porttitor pretium lectus in scelerisque. Phasellus euismod + porta lectus eget pharetra. + Ut et viverra mi, ut imperdiet lacus. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere + cubilia Curae; Nunc tempus sapien sit amet tortor rhoncus dignissim. Sed at augue et sem lacinia feugiat. Nulla + vitae convallis + urna. Morbi scelerisque erat quis nibh pretium, non elementum elit consectetur. Proin in feugiat nisl. +

    +

    + Morbi et ipsum purus. Integer ut pulvinar metus. Fusce maximus ex nec purus sollicitudin gravida. Vivamus dapibus + volutpat erat nec tristique. Aliquam mi dolor, pretium non elementum quis, viverra non est. Pellentesque egestas, + lectus a posuere imperdiet, + nisi sem elementum neque, eu volutpat arcu turpis venenatis magna. Curabitur non neque consectetur, vulputate urna + sed, vestibulum lacus. Aenean mollis, risus non pulvinar egestas, lectus lectus finibus dui, sit amet pretium + metus mauris + vitae nibh. In non ultricies odio. +

    +
    + + + diff --git a/test/pages/video.html b/test/pages/video.html index c6a72b6e26b..e040b65fe23 100644 --- a/test/pages/video.html +++ b/test/pages/video.html @@ -32,7 +32,7 @@ code: 'video1', sizes: [640,480], mediaTypes: { - video: {context: 'instream'} + video: {context: 'instream', playerSize: [640, 480]} }, bids: [ { diff --git a/test/spec/auctionmanager_spec.js b/test/spec/auctionmanager_spec.js index 9c936ace421..577b1bec333 100644 --- a/test/spec/auctionmanager_spec.js +++ b/test/spec/auctionmanager_spec.js @@ -1,4 +1,4 @@ -import { getKeyValueTargetingPairs, auctionCallbacks } from 'src/auction'; +import { getKeyValueTargetingPairs, auctionCallbacks, AUCTION_COMPLETED } from 'src/auction'; import CONSTANTS from 'src/constants.json'; import { adjustBids } from 'src/auction'; import * as auctionModule from 'src/auction'; @@ -628,17 +628,15 @@ describe('auctionmanager.js', function () { before(function () { makeRequestsStub = sinon.stub(adapterManager, 'makeBidRequests'); - - ajaxStub = sinon.stub(ajaxLib, 'ajaxBuilder').callsFake(mockAjaxBuilder); }); after(function () { - ajaxStub.restore(); adapterManager.makeBidRequests.restore(); }); describe('when auction timeout is 3000', function () { before(function () { + ajaxStub = sinon.stub(ajaxLib, 'ajaxBuilder').callsFake(mockAjaxBuilder); makeRequestsStub.returns(TEST_BID_REQS); }); beforeEach(function () { @@ -661,6 +659,10 @@ describe('auctionmanager.js', function () { auctionModule.newAuction.restore(); }); + after(function () { + ajaxStub.restore(); + }); + function checkPbDg(cpm, expected, msg) { return function() { bids[0].cpm = cpm; @@ -755,6 +757,7 @@ describe('auctionmanager.js', function () { describe('when auction timeout is 20', function () { let eventsEmitSpy; + let server; before(function () { bids = [mockBid(), mockBid({ bidderCode: BIDDER_CODE1 })]; @@ -764,6 +767,8 @@ describe('auctionmanager.js', function () { }); beforeEach(function () { + server = sinon.createFakeServer(); + adUnits = [{ code: ADUNIT_CODE, bids: [ @@ -772,35 +777,79 @@ describe('auctionmanager.js', function () { }]; adUnitCodes = [ADUNIT_CODE]; - auction = auctionModule.newAuction({adUnits, adUnitCodes, callback: function() {}, cbTimeout: 20}); - createAuctionStub = sinon.stub(auctionModule, 'newAuction'); - createAuctionStub.returns(auction); - - spec = mockBidder(BIDDER_CODE, [bids[0]]); - registerBidder(spec); + eventsEmitSpy = sinon.spy(events, 'emit'); + }); + afterEach(function () { + server.restore(); + events.emit.restore(); + }); - // Timeout is checked when bid is received. If that bid is the only one - // auction is waiting for, timeout is not emitted, so we need to add a - // second bidder to get timeout event. - let spec1 = mockBidder(BIDDER_CODE1, [bids[1]]); + it('should emit BID_TIMEOUT and AUCTION_END for timed out bids', function (done) { + const spec1 = mockBidder(BIDDER_CODE, [bids[0]]); registerBidder(spec1); + const spec2 = mockBidder(BIDDER_CODE1, [bids[1]]); + registerBidder(spec2); - eventsEmitSpy = sinon.spy(events, 'emit'); + function respondToRequest(requestIndex) { + server.requests[requestIndex].respond(200, {}, 'response body'); + } + function auctionCallback() { + const bidTimeoutCall = eventsEmitSpy.withArgs(CONSTANTS.EVENTS.BID_TIMEOUT).getCalls()[0]; + const timedOutBids = bidTimeoutCall.args[1]; + assert.equal(timedOutBids.length, 1); + assert.equal(timedOutBids[0].bidder, BIDDER_CODE1); + + const auctionEndCall = eventsEmitSpy.withArgs(CONSTANTS.EVENTS.AUCTION_END).getCalls()[0]; + const auctionProps = auctionEndCall.args[1]; + assert.equal(auctionProps.adUnits, adUnits); + assert.equal(auctionProps.timeout, 20); + assert.equal(auctionProps.auctionStatus, AUCTION_COMPLETED) + done(); + } + auction = auctionModule.newAuction({adUnits, adUnitCodes, callback: auctionCallback, cbTimeout: 20}); - // make all timestamp calls 5 minutes apart - let callCount = 0; - sinon.stub(utils, 'timestamp').callsFake(function() { - return new Date().getTime() + (callCount++ * 1000 * 60 * 5); - }); + auction.callBids(); + respondToRequest(0); }); - afterEach(function () { - auctionModule.newAuction.restore(); - events.emit.restore(); - utils.timestamp.restore(); + it('should NOT emit BID_TIMEOUT when all bidders responded in time', function (done) { + const spec1 = mockBidder(BIDDER_CODE, [bids[0]]); + registerBidder(spec1); + const spec2 = mockBidder(BIDDER_CODE1, [bids[1]]); + registerBidder(spec2); + + function respondToRequest(requestIndex) { + server.requests[requestIndex].respond(200, {}, 'response body'); + } + function auctionCallback() { + assert.ok(eventsEmitSpy.withArgs(CONSTANTS.EVENTS.BID_TIMEOUT).notCalled, 'did not emit event BID_TIMEOUT'); + done(); + } + auction = auctionModule.newAuction({adUnits, adUnitCodes, callback: auctionCallback, cbTimeout: 20}); + + auction.callBids(); + respondToRequest(0); + respondToRequest(1); }); - it('should emit BID_TIMEOUT for timed out bids', function () { + it('should NOT emit BID_TIMEOUT for bidders which responded in time but with an empty bid', function (done) { + const spec1 = mockBidder(BIDDER_CODE, []); + registerBidder(spec1); + const spec2 = mockBidder(BIDDER_CODE1, []); + registerBidder(spec2); + + function respondToRequest(requestIndex) { + server.requests[requestIndex].respond(200, {}, 'response body'); + } + function auctionCallback() { + const bidTimeoutCall = eventsEmitSpy.withArgs(CONSTANTS.EVENTS.BID_TIMEOUT).getCalls()[0]; + const timedOutBids = bidTimeoutCall.args[1]; + assert.equal(timedOutBids.length, 1); + assert.equal(timedOutBids[0].bidder, BIDDER_CODE1); + done(); + } + auction = auctionModule.newAuction({adUnits, adUnitCodes, callback: auctionCallback, cbTimeout: 20}); + auction.callBids(); - assert.ok(eventsEmitSpy.calledWith(CONSTANTS.EVENTS.BID_TIMEOUT), 'emitted events BID_TIMEOUT'); + respondToRequest(0); }); }); }); diff --git a/test/spec/debugging_spec.js b/test/spec/debugging_spec.js index d07f7fc3373..ba9702b0324 100644 --- a/test/spec/debugging_spec.js +++ b/test/spec/debugging_spec.js @@ -13,6 +13,7 @@ describe('bid overrides', function () { afterEach(function () { window.sessionStorage.clear(); + config.resetConfig(); sandbox.restore(); }); diff --git a/test/spec/e2e/banner/basic_banner_ad.spec.js b/test/spec/e2e/banner/basic_banner_ad.spec.js new file mode 100644 index 00000000000..ee01ce627db --- /dev/null +++ b/test/spec/e2e/banner/basic_banner_ad.spec.js @@ -0,0 +1,48 @@ +const expect = require('chai').expect; +const { host, protocol } = require('../../../helpers/testing-utils'); + +const TEST_PAGE_URL = `${protocol}://${host}:9999/test/pages/banner.html`; +const CREATIVE_IFRAME_CSS_SELECTOR = 'iframe[id="google_ads_iframe_/19968336/header-bid-tag-0_0"]'; + +const EXPECTED_TARGETING_KEYS = { + hb_format: 'banner', + hb_source: 'client', + hb_pb: '0.50', + hb_bidder: 'appnexus', + hb_format_appnexus: 'banner', + hb_source_appnexus: 'client', + hb_pb_appnexus: '0.50', + hb_bidder_appnexus: 'appnexus' +} + +describe('Prebid.js Banner Ad Unit Test', function () { + before(function loadTestPage() { + browser.url(TEST_PAGE_URL).pause(3000); + try { + browser.waitForExist(CREATIVE_IFRAME_CSS_SELECTOR, 2000); + const creativeIframe = $(CREATIVE_IFRAME_CSS_SELECTOR).value; + browser.frame(creativeIframe); + } catch (e) { + // If creative Iframe didn't load, repeat the steps again! + // Due to some reason if the Ad server doesn't respond, the test case will time out after 60000 ms as defined in file wdio.conf.js + loadTestPage(); + } + }); + + it('should load the targeting keys with correct values', function () { + const result = browser.execute(function () { + return window.top.pbjs.getAdserverTargeting('div-gpt-ad-1460505748561-1'); + }); + + const targetingKeys = result.value['div-gpt-ad-1460505748561-1']; + + expect(targetingKeys).to.include(EXPECTED_TARGETING_KEYS); + expect(targetingKeys.hb_adid).to.be.a('string'); + expect(targetingKeys.hb_adid_appnexus).to.be.a('string'); + expect(targetingKeys.hb_size).to.satisfy((size) => size === '300x250' || '300x600'); + }); + + it('should render the Banner Ad on the page', function () { + expect(browser.isVisible('body > div[class="GoogleActiveViewElement"] > a > img')).to.be.true; + }); +}); diff --git a/test/spec/e2e/common/globals.js b/test/spec/e2e/common/globals.js deleted file mode 100644 index 3e781d5fa21..00000000000 --- a/test/spec/e2e/common/globals.js +++ /dev/null @@ -1,9 +0,0 @@ -var HtmlReporter = require('nightwatch-html-reporter'); -var reporter = new HtmlReporter({ - openBrowser: true, - reportsDirectory: __dirname + '/reports', - themeName: 'cover', -}); -module.exports = { - reporter: reporter.fn -}; diff --git a/test/spec/e2e/common/utils.js b/test/spec/e2e/common/utils.js deleted file mode 100644 index 2c9fee68eda..00000000000 --- a/test/spec/e2e/common/utils.js +++ /dev/null @@ -1,16 +0,0 @@ -module.exports = { - findIframeInDiv: function(divid) { - var div = document.getElementById(divid); - var iframes = div.getElementsByTagName('iframe'); - console.log(iframes.length); - try { - if (iframes.length === 1 && iframes[0].contentWindow.document.body.innerHTML === '') { - return false; - } else { - return true; - } - } catch (e) { - return true; - } - } -}; diff --git a/test/spec/e2e/custom-assertions/first.js b/test/spec/e2e/custom-assertions/first.js deleted file mode 100644 index e393e8c15a0..00000000000 --- a/test/spec/e2e/custom-assertions/first.js +++ /dev/null @@ -1,64 +0,0 @@ -/** - * Checks if the given attribute of an element has the expected value. - * - * ``` - * this.demoTest = function (client) { - * browser.assert.attributeEquals('body', 'data-attr', 'some value'); - * }; - * ``` - * - * @method attributeEquals - * @param {string} selector The selector (CSS / Xpath) used to locate the element. - * @param {string} attribute The attribute name - * @param {string} expected The expected value of the attribute to check. - * @param {string} [message] Optional log message to display in the output. If missing, one is displayed by default. - * @api assertions - */ - -var util = require('util'); -exports.assertion = function(expected, msg) { - var DEFAULT_MSG = 'Testing if attribute %s of <%s> equals "%s".'; - - this.message = msg; - - this.expected = function() { - return expected; - }; - - this.pass = function(value) { - return value === expected; - }; - - this.failure = function(result) { - var failed = false; - return failed; - }; - - this.value = function(result) { - console.log('**********'); - console.log(result); - return result.value; - }; - - this.command = function(callback) { - var _this = this; - var execcallback = function(result) { - // console.log(_this); - console.log('**********'); - console.log(result); - console.log(callback.toString()); - if (callback) { - return callback.call(_this, result.value); - } - }; - - this.api.execute(function() { - // cusotm logic - return 'hello'; - }, [], execcallback); - - // var result = {'value':'hello'}; - - return this; - }; -}; diff --git a/test/spec/e2e/custom-reporter/junit.xml.ejs b/test/spec/e2e/custom-reporter/junit.xml.ejs deleted file mode 100644 index f03e0ee38e5..00000000000 --- a/test/spec/e2e/custom-reporter/junit.xml.ejs +++ /dev/null @@ -1,32 +0,0 @@ - - - - - <% for (var item in module.completed) { - var testcase = module.completed[item]; - var assertions = testcase.assertions %> - <% - for (var i = 0; i < assertions.length; i++) { %><% if (assertions[i].failure) { %> <%= assertions[i].stackTrace %><% } %> -<% if (assertions[i].screenshots && assertions[i].screenshots.length > 0) { %><% for (var j = 0; j < assertions[i].screenshots.length; j++) { %>[[ATTACHMENT|<%= assertions[i].screenshots[j] %>]]<% } %><% } %> - <% } - if (testcase.failed > 0 && testcase.stackTrace) { - %><%= testcase.stackTrace %><% } %> - <% if (systemerr != '') {%> - - <%= systemerr %> - <% } %> - <% } %> - <% if (module.skipped && (module.skipped.length > 0)) { %> - <% for (var j = 0; j < module.skipped.length; j++) { %> - - - - <% } %> - <% } %> - - diff --git a/test/spec/e2e/custom-reporter/pbjs-html-reporter.js b/test/spec/e2e/custom-reporter/pbjs-html-reporter.js deleted file mode 100644 index 85be2a397a5..00000000000 --- a/test/spec/e2e/custom-reporter/pbjs-html-reporter.js +++ /dev/null @@ -1,113 +0,0 @@ -var fs = require('fs.extra'); -var path = require('path'); -var ejs = require('ejs'); - -module.exports = new function() { - var tmpl = __dirname + '/junit.xml.ejs'; - var tmplData; - var globalResults; - - function loadTemplate(cb) { - if (tmplData) { - cb(tmplData); - return; - } - fs.readFile(tmpl, function (err, data) { - if (err) { - throw err; - } - tmplData = data.toString(); - cb(tmplData); - }); - } - - function adaptAssertions(module) { - Object.keys(module.completed).forEach(function(item) { - var testcase = module.completed[item]; - var assertions = testcase.assertions; - for (var i = 0; i < assertions.length; i++) { - if (assertions[i].stackTrace) { - assertions[i].stackTrace = stackTraceFilter(assertions[i].stackTrace.split('\n')); - } - } - - if (testcase.failed > 0 && testcase.stackTrace) { - var stackParts = testcase.stackTrace.split('\n'); - var errorMessage = stackParts.shift(); - testcase.stackTrace = stackTraceFilter(stackParts); - testcase.message = errorMessage; - } - }); - } - - function writeReport(moduleKey, data, opts, callback) { - var module = globalResults.modules[moduleKey]; - var pathParts = moduleKey.split(path.sep); - var moduleName = pathParts.pop(); - var output_folder = opts.output_folder; - adaptAssertions(module); - - var rendered = ejs.render(data, { - module: module, - moduleName: moduleName, - systemerr: globalResults.errmessages.join('\n'), - }); - - if (pathParts.length) { - output_folder = path.join(output_folder, pathParts.join(path.sep)); - fs.mkdirpSync(output_folder); - } - - var filename = path.join(output_folder, opts.filename_prefix + moduleName + '.xml'); - fs.writeFile(filename, rendered, function(err) { - callback(err); - globalResults.errmessages.length = 0; - }); - } - - function stackTraceFilter(parts) { - var stack = parts.reduce(function(list, line) { - if (contains(line, [ - 'node_modules', - '(node.js:', - '(events.js:' - ])) { - return list; - } - - list.push(line); - return list; - }, []); - - return stack.join('\n'); - } - - function contains(str, text) { - if (Object.prototype.toString.call(text) === '[object Array]') { - for (var i = 0; i < text.length; i++) { - if (contains(str, text[i])) { - return true; - } - } - } - return str.indexOf(text) > -1; - } - - this.write = function(results, options, callback) { - options.filename_prefix = process.env.__NIGHTWATCH_ENV + '_'; - globalResults = results; - var keys = Object.keys(results.modules); - - loadTemplate(function createReport(data) { - var moduleKey = keys.shift(); - - writeReport(moduleKey, data, options, function(err) { - if (err || (keys.length === 0)) { - callback(err); - } else { - createReport(data); - } - }); - }); - }; -}(); diff --git a/test/spec/e2e/gpt-examples/all_bidders_instant_load.html b/test/spec/e2e/gpt-examples/all_bidders_instant_load.html deleted file mode 100644 index bf31b769431..00000000000 --- a/test/spec/e2e/gpt-examples/all_bidders_instant_load.html +++ /dev/null @@ -1,830 +0,0 @@ - - - - - - - - - -

    Prebid.js Test3

    - -

    adequant

    -
    -

    No response

    - -
    - -

    adform

    -
    -

    No response

    - -
    - - -

    aol

    -
    -

    No response

    - -
    - -

    appnexus

    -
    -

    No response

    - -
    - -

    indexExchange

    -
    -

    No response

    - -
    - -

    openx

    -
    -

    No response

    - -
    - -

    pubmatic

    -
    -

    No response

    - -
    - -

    pulsepoint

    -
    -

    No response

    - -
    - -

    rubicon

    -
    -

    No response

    - -
    - -

    sonobi

    -
    -

    No response

    - -
    - -

    sovrn

    -
    -

    No response

    - -
    - -

    springserve

    -
    -

    No response

    - -
    - -

    triplelift

    -
    -

    No response

    - -
    - -

    yieldbot

    -
    -

    No response

    - -
    - -

    nginad

    -
    -

    No response

    - -
    - -

    brightcom

    -
    -

    No response

    - -
    - -

    sekindo

    -
    -

    No response

    - -
    - -

    kruxlink

    -
    -

    No response

    - -
    - -

    AdMedia

    -
    -

    No response

    - -
    - - - - - - - - - - diff --git a/test/spec/e2e/gpt-examples/e2e_default.html b/test/spec/e2e/gpt-examples/e2e_default.html deleted file mode 100644 index 9e0437d6275..00000000000 --- a/test/spec/e2e/gpt-examples/e2e_default.html +++ /dev/null @@ -1,117 +0,0 @@ - - - - - - - - - - - - - - - - - - -

    Prebid.js TestCase1

    - - -
    - -
    -
    - -
    - - - \ No newline at end of file diff --git a/test/spec/e2e/gpt-examples/gpt_default.html b/test/spec/e2e/gpt-examples/gpt_default.html deleted file mode 100644 index 93ec054b59a..00000000000 --- a/test/spec/e2e/gpt-examples/gpt_default.html +++ /dev/null @@ -1,684 +0,0 @@ - - - - - - - - - - -

    Prebid.js Test3

    - - -
    - -
    - -
    - -
    -
    - -
    -
    - -
    -
    - -
    -
    - -
    -
    - -
    -
    - -
    - -
    - -
    - -
    - -
    - -
    - -
    - -
    - -
    - -
    - - -
    - -
    - -
    - -
    -
    - -
    -
    - -
    - - - -
    - -
    - - - - - - - - - diff --git a/test/spec/e2e/gpt-examples/gpt_outstream.html b/test/spec/e2e/gpt-examples/gpt_outstream.html deleted file mode 100644 index 42ba48c98e7..00000000000 --- a/test/spec/e2e/gpt-examples/gpt_outstream.html +++ /dev/null @@ -1,250 +0,0 @@ - - - - - Prebid.js outstream video example - - - - - -

    Prebid Outstream Video Ads

    - -
    -

    -In scelerisque sem sed tortor posuere sagittis. Fusce scelerisque odio at tincidunt ultricies. Fusce egestas, erat non finibus dictum, nulla arcu viverra nibh, at bibendum ligula nisi egestas magna. Nulla eu finibus nulla. Pellentesque at mi eget turpis consequat scelerisque. Sed lacinia, nisi sit amet egestas vestibulum, elit odio iaculis leo, et lacinia risus enim non lacus. Cras nec neque eget nunc gravida maximus. Ut hendrerit convallis sollicitudin. Donec cursus erat vel metus gravida, et pretium justo iaculis. Curabitur condimentum blandit augue, quis interdum leo. Vivamus dapibus est nec dui efficitur, eu imperdiet nulla sollicitudin. Suspendisse laoreet velit vitae arcu mollis, ac interdum lorem venenatis. Aenean nec purus varius, accumsan ex at, luctus arcu. Quisque consectetur tortor eros, placerat lacinia eros aliquam a. Proin non porttitor libero. -

    -

    -Proin eget vulputate est. Nunc sit amet neque a tortor ullamcorper suscipit non eu neque. Quisque at massa in metus feugiat rutrum. Nulla et orci orci. Aliquam erat volutpat. Cras tincidunt metus lectus, sed suscipit augue mollis vitae. Sed quis condimentum tortor, sit amet consectetur erat. Nulla pellentesque turpis lacus, eu venenatis massa fringilla at. Duis sed pharetra turpis. Maecenas vel porttitor neque. Praesent quis felis sapien. Donec suscipit euismod dui, vitae fermentum nisi ornare in. -

    -

    -Suspendisse tempor felis accumsan orci finibus, imperdiet mollis arcu imperdiet. In eu dolor condimentum, pulvinar nisl a, sollicitudin nunc. Ut vel lectus libero. Praesent rhoncus leo tortor, at mollis nulla sagittis eget. Quisque tempus tempor augue sed rutrum. Sed vitae volutpat quam. Proin vestibulum eros metus, a luctus erat condimentum eu. Vivamus ullamcorper ultricies dui, ac malesuada leo finibus semper. Cras diam augue, imperdiet sed efficitur id, aliquam sed purus. Praesent eget turpis quis sapien interdum sagittis. Vivamus placerat nunc a tempus fermentum. Praesent laoreet leo at tellus porta, ut viverra tortor pharetra. Quisque elit velit, eleifend eget imperdiet vel, suscipit ac nisi. Aliquam egestas mauris ut massa fringilla laoreet. -

    -

    -Quisque ac luctus nisi, vitae ornare arcu. Proin fermentum sapien vitae odio vestibulum porta. Suspendisse faucibus sapien enim, et faucibus urna tempus et. Integer porttitor justo sed faucibus blandit. Morbi semper lectus vitae semper facilisis. Quisque molestie accumsan arcu, eget bibendum dui euismod et. Sed in mattis lacus, nec lacinia sem. Fusce sed tortor posuere, iaculis justo varius, elementum est. -

    -

    -Etiam condimentum, eros commodo semper tristique, lorem leo pharetra massa, eget cursus justo enim id urna. Sed imperdiet mauris vitae ante bibendum elementum. Etiam eu dui porttitor leo imperdiet cursus. Maecenas consequat, neque a dapibus viverra, nunc velit volutpat nibh, ut cursus sem tortor ac arcu. Praesent convallis lacus vel nisi aliquam, in posuere libero scelerisque. Curabitur et lacinia nisl. Nunc id ligula neque. Phasellus non eros et leo ultrices ultricies. Nulla facilisi. Donec ut augue urna. Suspendisse sodales nisi at ex faucibus, et tempus magna fermentum. Proin non arcu interdum, pulvinar est at, vehicula odio. Morbi nec maximus sem. Ut eu tristique urna. -

    -

    -Pellentesque eget quam sem. Nam interdum eleifend leo, mattis sagittis metus ornare tristique. Cras pretium odio lectus, vitae viverra massa consequat eget. Suspendisse porttitor pretium lectus in scelerisque. Phasellus euismod porta lectus eget pharetra. Ut et viverra mi, ut imperdiet lacus. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Nunc tempus sapien sit amet tortor rhoncus dignissim. Sed at augue et sem lacinia feugiat. Nulla vitae convallis urna. Morbi scelerisque erat quis nibh pretium, non elementum elit consectetur. Proin in feugiat nisl. -

    -

    -Morbi et ipsum purus. Integer ut pulvinar metus. Fusce maximus ex nec purus sollicitudin gravida. Vivamus dapibus volutpat erat nec tristique. Aliquam mi dolor, pretium non elementum quis, viverra non est. Pellentesque egestas, lectus a posuere imperdiet, nisi sem elementum neque, eu volutpat arcu turpis venenatis magna. Curabitur non neque consectetur, vulputate urna sed, vestibulum lacus. Aenean mollis, risus non pulvinar egestas, lectus lectus finibus dui, sit amet pretium metus mauris vitae nibh. In non ultricies odio. -

    -

    -Donec dictum sem ac risus molestie lobortis. Maecenas at justo vehicula, iaculis orci eget, eleifend nunc. In non justo imperdiet, blandit leo in, interdum mi. Proin feugiat libero et erat dictum efficitur. Nunc auctor lacus feugiat erat euismod cursus. Sed vehicula ante vel quam pretium blandit. Maecenas congue quis mauris vitae efficitur. Cras sit amet justo at sem dictum ornare vitae eu ex. Nunc ornare odio nec leo consectetur cursus. Mauris eu dolor tellus. Etiam dignissim ut nunc et mollis. Cras at pulvinar velit, ut tincidunt velit. Cras vitae fermentum ante. Aenean interdum dolor in scelerisque consectetur. -

    -

    -Curabitur auctor leo sit amet massa faucibus ultrices. Maecenas dignissim libero ac cursus cursus. Curabitur eget sapien leo. Phasellus pretium blandit facilisis. Proin egestas urna a sagittis tempus. Donec in nibh ex. Vestibulum efficitur felis aliquam urna ultrices, at gravida nibh pretium. Morbi dictum vulputate pretium. Donec at nisi rutrum, pharetra nunc a, placerat felis. Quisque rhoncus congue fermentum. Quisque pharetra est at nisl sagittis suscipit. Maecenas scelerisque porta eleifend. Mauris nulla leo, consectetur at eros vel, elementum pretium diam. -

    -

    -In nisi libero, porta ut ullamcorper a, dapibus nec velit. Vestibulum congue rhoncus congue. Nulla a libero sit amet risus feugiat hendrerit id placerat ex. In hac habitasse platea dictumst. Pellentesque ut ullamcorper risus. Nunc et ipsum nisi. Vivamus a interdum diam, hendrerit pellentesque orci. -

    -

    -Vestibulum ut massa blandit, maximus sem vitae, vulputate mauris. Nam condimentum velit a facilisis dignissim. Nunc venenatis pharetra dapibus. Praesent ullamcorper risus sit amet molestie consectetur. Cras mauris felis, consequat et enim a, ultricies pretium enim. Nulla porttitor nunc mi, sed posuere magna venenatis non. Donec lobortis consectetur mauris, fermentum auctor dui dignissim sed. Sed vel venenatis urna. Donec velit velit, imperdiet non vulputate non, eleifend sed nisi. -

    -

    -Proin et turpis velit. Donec tempus dictum dolor, eget eleifend lacus. Donec eu felis in ante iaculis ultrices. Mauris varius, turpis quis venenatis convallis, enim dolor ornare justo, in dictum ipsum purus quis dolor. Ut condimentum feugiat lectus ut auctor. Maecenas luctus consequat erat, nec pretium urna pulvinar in. Donec gravida rhoncus aliquet. Cras aliquet odio eget orci hendrerit, non posuere velit dignissim. Nunc tempus aliquam iaculis. Nunc viverra lobortis mauris et malesuada. Donec congue suscipit mauris. Phasellus efficitur, leo at mollis maximus, lorem mauris pretium urna, nec scelerisque ante neque eu erat. Nam rhoncus malesuada velit nec ultricies. -

    -
    -

    Prebid Outstream Video Ad

    - -
    - -

    -Proin blandit in arcu sed porttitor. Morbi in erat vel risus mollis interdum. Proin vel odio semper, porttitor risus sed, tristique odio. Donec viverra massa et dui scelerisque, ac sagittis odio viverra. Aliquam lacinia enim sit amet dapibus ultrices. Nulla mollis, massa eget interdum egestas, lectus eros pretium eros, vel consectetur velit odio vel odio. Proin euismod aliquam finibus. Phasellus facilisis mollis est, non consequat lectus volutpat nec. -

    -

    -Ut vel ultricies erat. Pellentesque non ipsum quis odio ornare tempus in cursus ex. In a turpis non quam pulvinar tincidunt. Maecenas tortor neque, dapibus a quam aliquet, dictum pellentesque leo. Sed aliquet tellus est, in tempus magna congue ut. Phasellus at tincidunt lorem, id fringilla risus. Nunc vel pulvinar massa. Aliquam erat volutpat. Phasellus semper interdum justo at eleifend. Curabitur feugiat quam sed mollis facilisis. -

    -

    -Quisque consectetur sem a elit aliquet facilisis. Quisque dignissim velit at quam rhoncus dignissim. Proin feugiat sem at turpis ultrices imperdiet. Integer vel eros vel ante ultricies dapibus vitae eget dui. Fusce sollicitudin semper tortor at molestie. Pellentesque nec metus sed mauris aliquet iaculis. Mauris malesuada tortor nec mi dictum, feugiat euismod enim gravida. Vestibulum dapibus ut nulla vel euismod. Nunc lobortis, mauris at pretium faucibus, ligula diam venenatis nulla, in mattis sapien arcu feugiat dolor. In at dui leo. Cras elementum condimentum turpis. -

    -

    -Donec eget dolor ac nulla lobortis bibendum. Praesent commodo accumsan ligula eget commodo. Suspendisse sit amet dignissim metus. Sed ut eros viverra, viverra lectus eget, ornare eros. Mauris elementum lacinia dapibus. Donec magna nisl, suscipit quis mattis eget, tincidunt sed sapien. Curabitur elementum nulla eget lorem gravida dapibus. Nunc vel dolor et libero pretium interdum vitae eget mauris. Vestibulum et erat in nulla sollicitudin luctus ut quis nulla. -

    -

    -Maecenas iaculis pellentesque quam at fringilla. Donec dui elit, suscipit eget varius id, suscipit efficitur metus. Nulla rutrum ultrices tempor. Vivamus hendrerit justo ac fermentum euismod. Vestibulum tempus pulvinar tempus. Curabitur congue neque luctus dolor vehicula, non efficitur metus fringilla. Nam a imperdiet ex. Integer at est hendrerit, rutrum justo eu, ornare odio. Etiam convallis sapien a purus vehicula, eget gravida purus semper. Fusce ex enim, volutpat ac feugiat et, rhoncus vel tortor. Aenean ultrices libero sed neque fermentum tempor. Morbi tincidunt dui turpis, non mollis est dignissim at. Suspendisse molestie convallis interdum. Donec sit amet fermentum purus. -

    -

    -Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Aliquam et ex orci. Vivamus rutrum est vel porta imperdiet. Cras ultricies tortor dolor, nec mollis felis ullamcorper vel. Praesent scelerisque vehicula sem, nec feugiat mauris tempus ac. Donec at enim non sem commodo sodales. Ut sit amet risus sit amet ante viverra venenatis. Aliquam sodales mollis est eget ultricies. Etiam pulvinar sapien et ipsum elementum pharetra. -

    -

    -Nam blandit metus erat, sit amet congue ipsum cursus sed. In a commodo ante, sit amet tincidunt quam. Aenean lobortis et nibh in venenatis. Aliquam faucibus purus quis neque consectetur, quis consequat risus maximus. Proin mollis imperdiet felis, eget tempus ipsum scelerisque ut. Sed euismod interdum augue sed varius. Sed volutpat tellus ut risus porta accumsan. -

    -

    -Mauris aliquet eu arcu sed pharetra. Duis nec leo volutpat libero finibus malesuada in eget velit. Aliquam facilisis urna mauris, et aliquam ipsum dictum finibus. Donec eget mi fermentum, vehicula odio at, molestie orci. In a hendrerit lectus. Aenean congue ipsum ac imperdiet suscipit. Maecenas eleifend pretium metus id mollis. -

    -
    -

    Prebid Outstream Video Ad

    - -
    - -

    -Ut vel ultricies erat. Pellentesque non ipsum quis odio ornare tempus in cursus ex. In a turpis non quam pulvinar tincidunt. Maecenas tortor neque, dapibus a quam aliquet, dictum pellentesque leo. Sed aliquet tellus est, in tempus magna congue ut. Phasellus at tincidunt lorem, id fringilla risus. Nunc vel pulvinar massa. Aliquam erat volutpat. Phasellus semper interdum justo at eleifend. Curabitur feugiat quam sed mollis facilisis. -

    -

    -Quisque consectetur sem a elit aliquet facilisis. Quisque dignissim velit at quam rhoncus dignissim. Proin feugiat sem at turpis ultrices imperdiet. Integer vel eros vel ante ultricies dapibus vitae eget dui. Fusce sollicitudin semper tortor at molestie. Pellentesque nec metus sed mauris aliquet iaculis. Mauris malesuada tortor nec mi dictum, feugiat euismod enim gravida. Vestibulum dapibus ut nulla vel euismod. Nunc lobortis, mauris at pretium faucibus, ligula diam venenatis nulla, in mattis sapien arcu feugiat dolor. In at dui leo. Cras elementum condimentum turpis. -

    -

    -Donec eget dolor ac nulla lobortis bibendum. Praesent commodo accumsan ligula eget commodo. Suspendisse sit amet dignissim metus. Sed ut eros viverra, viverra lectus eget, ornare eros. Mauris elementum lacinia dapibus. Donec magna nisl, suscipit quis mattis eget, tincidunt sed sapien. Curabitur elementum nulla eget lorem gravida dapibus. Nunc vel dolor et libero pretium interdum vitae eget mauris. Vestibulum et erat in nulla sollicitudin luctus ut quis nulla. -

    -

    -Maecenas iaculis pellentesque quam at fringilla. Donec dui elit, suscipit eget varius id, suscipit efficitur metus. Nulla rutrum ultrices tempor. Vivamus hendrerit justo ac fermentum euismod. Vestibulum tempus pulvinar tempus. Curabitur congue neque luctus dolor vehicula, non efficitur metus fringilla. Nam a imperdiet ex. Integer at est hendrerit, rutrum justo eu, ornare odio. Etiam convallis sapien a purus vehicula, eget gravida purus semper. Fusce ex enim, volutpat ac feugiat et, rhoncus vel tortor. Aenean ultrices libero sed neque fermentum tempor. Morbi tincidunt dui turpis, non mollis est dignissim at. Suspendisse molestie convallis interdum. Donec sit amet fermentum purus. -

    - -
    - - - diff --git a/test/spec/e2e/gpt-examples/gpt_yieldbot.html b/test/spec/e2e/gpt-examples/gpt_yieldbot.html deleted file mode 100644 index 12766c537f6..00000000000 --- a/test/spec/e2e/gpt-examples/gpt_yieldbot.html +++ /dev/null @@ -1,241 +0,0 @@ - - - - - - - - - - -
    -
    - Yieldbot integration test mode: - -
      -
    • START (i.e.force bids to be returned)
    • -
    • STOP
    • -
    -
    - -

    Prebid.js Yieldbot Adapter Test

    -
    -
    - -
    -

    Lorem ipsum dolor. Sit amet proin. Integer cursus mi mus curabitur euismod vel quos duis bibendum nec interdum porta dolor a viverra nisl fusce. Volutpat sit at. Donec nisl taciti. Eget eu lobortis. Excepteur diam orci lacus nibh pharetra. Justo neque maecenas. Viverra molestie dolor ante rutrum vivamus libero urna suscipit leo praesent ultricies. In dignissim qui ante bibendum in. Habitasse ac arcu non nulla augue. Felis lectus non tempus in aliquam. Sit porttitor nec. Sodales non sit eu duis.

    -
    - -
    -

    Donec feugiat ornare a amet optio. Vitae sit sapien. Vitae nec justo. Fusce ac in semper ligula duis eget vel sit. Augue mauris sit. A adipisicing orci est augue dapibus ullamcorper faucibus fermentum. Et phasellus in tempus vivamus praesent. Nisl dui porttitor. Iaculis vulputate eros ut interdum eu. Lacus quis magna varius in quis. Congue erat porttitor sit eu vitae pharetra scelerisque nec. Dolor dui vel ut velit vestibulum. Lectus ullamcorper mi. Curabitur ipsum pellentesque sed erat est est sapien in tempor sodales viverra. Dui volutpat morbi eleifend fringilla quis. Neque erat erat. Rhoncus sed posuere. Dapibus fusce ut lacus mus est pede sed quisquam. Quis aliquam pellentesque. Wisi ac odio eu wisi amet ut ipsum a erat aliquam nunc.

    -

    Dis vitae penatibus. Mollis mauris bibendum. Porta orci amet dolor sed felis in neque per cursus molestie pellentesque. Quis accusamus vel sed dapibus orci congue ut eros. Nec faucibus inceptos. Hendrerit in eget nulla tellus lacinia. Fusce ut ut mattis.

    -

    Vivamus mauris metus. Ridiculus habitant lorem in nulla in quam eros ut. Libero aliquam platea. In enim consectetuer eget mattis accumsan aenean faucibus tincidunt. Amet donec vitae wisi pellentesque magna non lacinia qui. In erat in maecenas amet dui. Aliquam elit vel. Ligula sodales lacus. Nisl a purus. Pharetra velit porttitor vel vel non turpis viverra fringilla lorem arcu pellentesque sed aliquet nonummy quisque dapibus ullamcorper. Mollis ipsum nulla. Tempor tempus vitae. Luctus amet vel. Suspendisse sagittis vestibulum fusce eu.

    -

    Urna et felis bibendum felis sit vestibulum wisi pharetra quisque ac quis cursus suspendisse quisque aenean luctus curabitur. Eget nec leo. Mi placerat cras nulla et integer eget in sed. Non magni parturient. Egestas iaculis malesuada. Nec a duis. Pede condimentum ullamcorper. Augue arcu tellus. In velit in in duis odio dictum wisi proin quis eget sit. Felis tempus inceptos. Turpis risus eu. Mi vivamus consequat. Lectus dui imperdiet amet orci vehicula in vel pellentesque habitant suscipit aliquam. Proin porttitor vitae ultricies a in. Est duis pede. Tristique velit vestibulum odio sodales morbi magna ut vitae. Elementum imperdiet sodales ultrices tortor mollis vehicula lorem varius pellentesque mi ut sit turpis feugiat. In convallis urna. Justo aliquam sed quis scelerisque nonummy. Lobortis rhoncus ornare. Pellentesque leo quam at beatae in. Erat lorem tempus. Molestie faucibus a id mauris montes. Sed orci vulputate. Libero justo curabitur. Amet orci ante. Non felis est erat cras purus id at id nibh nunc facilisis amet metus sagittis pellentesque eros amet. Vitae sit nulla vitae wisi diam. Tincidunt ipsum eleifend semper tortor non. Tellus amet aliquet.

    -

    Dis vitae penatibus. Mollis mauris bibendum. Porta orci amet dolor sed felis in neque per cursus molestie pellentesque. Quis accusamus vel sed dapibus orci congue ut eros. Nec faucibus inceptos. Hendrerit in eget nulla tellus lacinia. Fusce ut ut mattis.

    -

    Vivamus mauris metus. Ridiculus habitant lorem in nulla in quam eros ut. Libero aliquam platea. In enim consectetuer eget mattis accumsan aenean faucibus tincidunt. Amet donec vitae wisi pellentesque magna non lacinia qui. In erat in maecenas amet dui. Aliquam elit vel. Ligula sodales lacus. Nisl a purus. Pharetra velit porttitor vel vel non turpis viverra fringilla lorem arcu pellentesque sed aliquet nonummy quisque dapibus ullamcorper. Mollis ipsum nulla. Tempor tempus vitae. Luctus amet vel. Suspendisse sagittis vestibulum fusce eu.

    -

    Urna et felis bibendum felis sit vestibulum wisi pharetra quisque ac quis cursus suspendisse quisque aenean luctus curabitur. Eget nec leo. Mi placerat cras nulla et integer eget in sed. Non magni parturient. Egestas iaculis malesuada. Nec a duis. Pede condimentum ullamcorper. Augue arcu tellus. In velit in in duis odio dictum wisi proin quis eget sit. Felis tempus inceptos. Turpis risus eu. Mi vivamus consequat. Lectus dui imperdiet amet orci vehicula in vel pellentesque habitant suscipit aliquam. Proin porttitor vitae ultricies a in. Est duis pede. Tristique velit vestibulum odio sodales morbi magna ut vitae. Elementum imperdiet sodales ultrices tortor mollis vehicula lorem varius pellentesque mi ut sit turpis feugiat. In convallis urna. Justo aliquam sed quis scelerisque nonummy. Lobortis rhoncus ornare. Pellentesque leo quam at beatae in. Erat lorem tempus. Molestie faucibus a id mauris montes. Sed orci vulputate. Libero justo curabitur. Amet orci ante. Non felis est erat cras purus id at id nibh nunc facilisis amet metus sagittis pellentesque eros amet. Vitae sit nulla vitae wisi diam. Tincidunt ipsum eleifend semper tortor non. Tellus amet aliquet.

    -
    -
    - -
    -
    - -
    -
    -

    Dis vitae penatibus. Mollis mauris bibendum. Porta orci amet dolor sed felis in neque per cursus molestie pellentesque. Quis accusamus vel sed dapibus orci congue ut eros. Nec faucibus inceptos. Hendrerit in eget nulla tellus lacinia. Fusce ut ut mattis.

    -
    - - diff --git a/test/spec/e2e/longform/basic_w_custom_adserver_translation.spec.js b/test/spec/e2e/longform/basic_w_custom_adserver_translation.spec.js new file mode 100644 index 00000000000..82310738246 --- /dev/null +++ b/test/spec/e2e/longform/basic_w_custom_adserver_translation.spec.js @@ -0,0 +1,68 @@ +const includes = require('core-js/library/fn/array/includes'); +const expect = require('chai').expect; +const testServer = require('../../../helpers/testing-utils'); + +const host = testServer.host; +const protocol = testServer.protocol; + +const validDurations = ['15s', '30s']; +const validCats = ['Food', 'Retail Stores/Chains', 'Pet Food/Supplies', 'Travel/Hotels/Airlines', 'Automotive', 'Health Care Services']; +const validCpms = ['15.00', '14.00', '13.00', '10.00']; +const customKeyRegex = /\d{2}\.\d{2}_\d{1,3}_\d{2}s/; +const uuidRegex = /(\d|\w){8}-((\d|\w){4}-){3}(\d|\w){12}/; + +describe('longform ads using custom adserver translation file', function() { + this.retries(3); + it('process the bids successfully', function() { + browser + .url(protocol + '://' + host + ':9999/integrationExamples/longform/basic_w_custom_adserver_translation.html?pbjs_debug=true') + .pause(10000); + + const loadPrebidBtnXpath = '//*[@id="loadPrebidRequestBtn"]'; + browser.waitForExist(loadPrebidBtnXpath); + $(loadPrebidBtnXpath).click(); + browser.pause(3000); + + const listOfCpmsXpath = '/html/body/div[1]/div/div/div/div[1]/div[2]/div/table/tbody/tr/td[2]'; + const listOfCategoriesXpath = '/html/body/div[1]/div/div/div/div[1]/div[2]/div/table/tbody/tr/td[3]'; + const listOfDurationsXpath = '/html/body/div[1]/div/div/div/div[1]/div[2]/div/table/tbody/tr/td[4]'; + + browser.waitForExist(listOfCpmsXpath); + + let listOfCpms = $$(listOfCpmsXpath); + let listOfCats = $$(listOfCategoriesXpath); + let listOfDuras = $$(listOfDurationsXpath); + + expect(listOfCpms.length).to.equal(listOfCats.length).and.to.equal(listOfDuras.length); + for (let i = 0; i < listOfCpms.length; i++) { + let cpm = listOfCpms[i].getText(); + let cat = listOfCats[i].getText(); + let dura = listOfDuras[i].getText(); + expect(includes(validCpms, cpm), `Could not find CPM ${cpm} in accepted list`).to.equal(true); + expect(includes(validCats, cat), `Could not find Category ${cat} in accepted list`).to.equal(true); + expect(includes(validDurations, dura), `Could not find Duration ${dura} in accepted list`).to.equal(true); + } + }); + + it('formats the targeting keys properly', function () { + const listOfKeyElementsXpath = '/html/body/div[1]/div/div/div/div[2]/div[2]/div/table/tbody/tr/td[1]'; + const listOfKeyValuesXpath = '/html/body/div[1]/div/div/div/div[2]/div[2]/div/table/tbody/tr/td[2]'; + browser.waitForExist(listOfKeyElementsXpath); + browser.waitForExist(listOfKeyValuesXpath); + + let listOfKeyElements = $$(listOfKeyElementsXpath); + let listOfKeyValues = $$(listOfKeyValuesXpath); + + let firstKey = listOfKeyElements[0].getText(); + expect(firstKey).to.equal('hb_pb_cat_dur'); + + let firstKeyValue = listOfKeyValues[0].getText(); + expect(firstKeyValue).match(customKeyRegex); + + let lastKey = listOfKeyElements[listOfKeyElements.length - 1].getText(); + expect(lastKey).to.equal('hb_cache_id'); + + let lastKeyValue = listOfKeyValues[listOfKeyValues.length - 1].getText(); + expect(lastKeyValue).to.match(uuidRegex); + }); +}) diff --git a/test/spec/e2e/longform/basic_w_requireExactDuration.spec.js b/test/spec/e2e/longform/basic_w_requireExactDuration.spec.js new file mode 100644 index 00000000000..224ff1cbc34 --- /dev/null +++ b/test/spec/e2e/longform/basic_w_requireExactDuration.spec.js @@ -0,0 +1,68 @@ +const includes = require('core-js/library/fn/array/includes'); +const expect = require('chai').expect; +const testServer = require('../../../helpers/testing-utils'); + +const host = testServer.host; +const protocol = testServer.protocol; + +const validDurations = ['15s', '30s']; +const validCats = ['Food', 'Retail Stores/Chains', 'Pet Food/Supplies', 'Travel/Hotels/Airlines', 'Automotive', 'Health Care Services']; +const validCpms = ['15.00', '14.00', '13.00', '10.00']; +const customKeyRegex = /\d{2}\.\d{2}_\d{1,3}_\d{2}s/; +const uuidRegex = /(\d|\w){8}-((\d|\w){4}-){3}(\d|\w){12}/; + +describe('longform ads using requireExactDuration field', function() { + this.retries(3); + it('process the bids successfully', function() { + browser + .url(protocol + '://' + host + ':9999/integrationExamples/longform/basic_w_requireExactDuration.html?pbjs_debug=true') + .pause(10000); + + const loadPrebidBtnXpath = '//*[@id="loadPrebidRequestBtn"]'; + browser.waitForExist(loadPrebidBtnXpath); + $(loadPrebidBtnXpath).click(); + browser.pause(3000); + + const listOfCpmsXpath = '/html/body/div[1]/div/div/div/div[1]/div[2]/div/table/tbody/tr/td[2]'; + const listOfCategoriesXpath = '/html/body/div[1]/div/div/div/div[1]/div[2]/div/table/tbody/tr/td[3]'; + const listOfDurationsXpath = '/html/body/div[1]/div/div/div/div[1]/div[2]/div/table/tbody/tr/td[4]'; + + browser.waitForExist(listOfCpmsXpath); + + let listOfCpms = $$(listOfCpmsXpath); + let listOfCats = $$(listOfCategoriesXpath); + let listOfDuras = $$(listOfDurationsXpath); + + expect(listOfCpms.length).to.equal(listOfCats.length).and.to.equal(listOfDuras.length); + for (let i = 0; i < listOfCpms.length; i++) { + let cpm = listOfCpms[i].getText(); + let cat = listOfCats[i].getText(); + let dura = listOfDuras[i].getText(); + expect(includes(validCpms, cpm), `Could not find CPM ${cpm} in accepted list`).to.equal(true); + expect(includes(validCats, cat), `Could not find Category ${cat} in accepted list`).to.equal(true); + expect(includes(validDurations, dura), `Could not find Duration ${dura} in accepted list`).to.equal(true); + } + }); + + it('formats the targeting keys properly', function () { + const listOfKeyElementsXpath = '/html/body/div[1]/div/div/div/div[2]/div[2]/div/table/tbody/tr/td[1]'; + const listOfKeyValuesXpath = '/html/body/div[1]/div/div/div/div[2]/div[2]/div/table/tbody/tr/td[2]'; + browser.waitForExist(listOfKeyElementsXpath); + browser.waitForExist(listOfKeyValuesXpath); + + let listOfKeyElements = $$(listOfKeyElementsXpath); + let listOfKeyValues = $$(listOfKeyValuesXpath); + + let firstKey = listOfKeyElements[0].getText(); + expect(firstKey).to.equal('hb_pb_cat_dur'); + + let firstKeyValue = listOfKeyValues[0].getText(); + expect(firstKeyValue).match(customKeyRegex); + + let lastKey = listOfKeyElements[listOfKeyElements.length - 1].getText(); + expect(lastKey).to.equal('hb_cache_id'); + + let lastKeyValue = listOfKeyValues[listOfKeyValues.length - 1].getText(); + expect(lastKeyValue).to.match(uuidRegex); + }); +}) diff --git a/test/spec/e2e/longform/basic_wo_brandCategoryExclusion.spec.js b/test/spec/e2e/longform/basic_wo_brandCategoryExclusion.spec.js new file mode 100644 index 00000000000..95237366d0e --- /dev/null +++ b/test/spec/e2e/longform/basic_wo_brandCategoryExclusion.spec.js @@ -0,0 +1,63 @@ +const includes = require('core-js/library/fn/array/includes'); +const expect = require('chai').expect; +const testServer = require('../../../helpers/testing-utils'); + +const host = testServer.host; +const protocol = testServer.protocol; + +const validDurations = ['15s', '30s']; +const validCpms = ['15.00', '14.00', '13.00', '10.00']; +const customKeyRegex = /\d{2}\.\d{2}_\d{2}s/; +const uuidRegex = /(\d|\w){8}-((\d|\w){4}-){3}(\d|\w){12}/; + +describe('longform ads without using brandCategoryExclusion', function() { + this.retries(3); + it('process the bids successfully', function() { + browser + .url(protocol + '://' + host + ':9999/integrationExamples/longform/basic_wo_brandCategoryExclusion.html?pbjs_debug=true') + .pause(10000); + + const loadPrebidBtnXpath = '//*[@id="loadPrebidRequestBtn"]'; + browser.waitForExist(loadPrebidBtnXpath); + $(loadPrebidBtnXpath).click(); + browser.pause(3000); + + const listOfCpmsXpath = '/html/body/div[1]/div/div/div/div[1]/div[2]/div/table/tbody/tr/td[2]'; + const listOfDurationsXpath = '/html/body/div[1]/div/div/div/div[1]/div[2]/div/table/tbody/tr/td[4]'; + + browser.waitForExist(listOfCpmsXpath); + + let listOfCpms = $$(listOfCpmsXpath); + let listOfDuras = $$(listOfDurationsXpath); + + expect(listOfCpms.length).to.equal(listOfDuras.length); + for (let i = 0; i < listOfCpms.length; i++) { + let cpm = listOfCpms[i].getText(); + let dura = listOfDuras[i].getText(); + expect(includes(validCpms, cpm), `Could not find CPM ${cpm} in accepted list`).to.equal(true); + expect(includes(validDurations, dura), `Could not find Duration ${dura} in accepted list`).to.equal(true); + } + }); + + it('formats the targeting keys properly', function () { + const listOfKeyElementsXpath = '/html/body/div[1]/div/div/div/div[2]/div[2]/div/table/tbody/tr/td[1]'; + const listOfKeyValuesXpath = '/html/body/div[1]/div/div/div/div[2]/div[2]/div/table/tbody/tr/td[2]'; + browser.waitForExist(listOfKeyElementsXpath); + browser.waitForExist(listOfKeyValuesXpath); + + let listOfKeyElements = $$(listOfKeyElementsXpath); + let listOfKeyValues = $$(listOfKeyValuesXpath); + + let firstKey = listOfKeyElements[0].getText(); + expect(firstKey).to.equal('hb_pb_cat_dur'); + + let firstKeyValue = listOfKeyValues[0].getText(); + expect(firstKeyValue).match(customKeyRegex); + + let lastKey = listOfKeyElements[listOfKeyElements.length - 1].getText(); + expect(lastKey).to.equal('hb_cache_id'); + + let lastKeyValue = listOfKeyValues[listOfKeyValues.length - 1].getText(); + expect(lastKeyValue).to.match(uuidRegex); + }); +}) diff --git a/test/spec/e2e/longform/basic_wo_requireExactDuration.spec.js b/test/spec/e2e/longform/basic_wo_requireExactDuration.spec.js new file mode 100644 index 00000000000..6b628067138 --- /dev/null +++ b/test/spec/e2e/longform/basic_wo_requireExactDuration.spec.js @@ -0,0 +1,68 @@ +const includes = require('core-js/library/fn/array/includes'); +const expect = require('chai').expect; +const testServer = require('../../../helpers/testing-utils'); + +const host = testServer.host; +const protocol = testServer.protocol; + +const validDurations = ['15s', '30s']; +const validCats = ['Food', 'Retail Stores/Chains', 'Pet Food/Supplies', 'Travel/Hotels/Airlines', 'Automotive', 'Health Care Services']; +const validCpms = ['15.00', '14.00', '13.00', '10.00']; +const customKeyRegex = /\d{2}\.\d{2}_\d{1,3}_\d{2}s/; +const uuidRegex = /(\d|\w){8}-((\d|\w){4}-){3}(\d|\w){12}/; + +describe('longform ads not using requireExactDuration field', function() { + this.retries(3); + it('process the bids successfully', function() { + browser + .url(protocol + '://' + host + ':9999/integrationExamples/longform/basic_wo_requireExactDuration.html?pbjs_debug=true') + .pause(10000); + + const loadPrebidBtnXpath = '//*[@id="loadPrebidRequestBtn"]'; + browser.waitForExist(loadPrebidBtnXpath); + $(loadPrebidBtnXpath).click(); + browser.pause(3000); + + const listOfCpmsXpath = '/html/body/div[1]/div/div/div/div[1]/div[2]/div/table/tbody/tr/td[2]'; + const listOfCategoriesXpath = '/html/body/div[1]/div/div/div/div[1]/div[2]/div/table/tbody/tr/td[3]'; + const listOfDurationsXpath = '/html/body/div[1]/div/div/div/div[1]/div[2]/div/table/tbody/tr/td[4]'; + + browser.waitForExist(listOfCpmsXpath); + + let listOfCpms = $$(listOfCpmsXpath); + let listOfCats = $$(listOfCategoriesXpath); + let listOfDuras = $$(listOfDurationsXpath); + + expect(listOfCpms.length).to.equal(listOfCats.length).and.to.equal(listOfDuras.length); + for (let i = 0; i < listOfCpms.length; i++) { + let cpm = listOfCpms[i].getText(); + let cat = listOfCats[i].getText(); + let dura = listOfDuras[i].getText(); + expect(includes(validCpms, cpm), `Could not find CPM ${cpm} in accepted list`).to.equal(true); + expect(includes(validCats, cat), `Could not find Category ${cat} in accepted list`).to.equal(true); + expect(includes(validDurations, dura), `Could not find Duration ${dura} in accepted list`).to.equal(true); + } + }); + + it('formats the targeting keys properly', function () { + const listOfKeyElementsXpath = '/html/body/div[1]/div/div/div/div[2]/div[2]/div/table/tbody/tr/td[1]'; + const listOfKeyValuesXpath = '/html/body/div[1]/div/div/div/div[2]/div[2]/div/table/tbody/tr/td[2]'; + browser.waitForExist(listOfKeyElementsXpath); + browser.waitForExist(listOfKeyValuesXpath); + + let listOfKeyElements = $$(listOfKeyElementsXpath); + let listOfKeyValues = $$(listOfKeyValuesXpath); + + let firstKey = listOfKeyElements[0].getText(); + expect(firstKey).to.equal('hb_pb_cat_dur'); + + let firstKeyValue = listOfKeyValues[0].getText(); + expect(firstKeyValue).match(customKeyRegex); + + let lastKey = listOfKeyElements[listOfKeyElements.length - 1].getText(); + expect(lastKey).to.equal('hb_cache_id'); + + let lastKeyValue = listOfKeyValues[listOfKeyValues.length - 1].getText(); + expect(lastKeyValue).to.match(uuidRegex); + }); +}) diff --git a/test/spec/e2e/native/basic_native_ad.spec.js b/test/spec/e2e/native/basic_native_ad.spec.js new file mode 100644 index 00000000000..ed09228b532 --- /dev/null +++ b/test/spec/e2e/native/basic_native_ad.spec.js @@ -0,0 +1,59 @@ +const expect = require('chai').expect; +const { host, protocol } = require('../../../helpers/testing-utils'); + +const TEST_PAGE_URL = `${protocol}://${host}:9999/test/pages/native.html`; +const CREATIVE_IFRAME_CSS_SELECTOR = 'iframe[id="google_ads_iframe_/19968336/prebid_native_example_1_0"]'; + +const EXPECTED_TARGETING_KEYS = { + hb_source: 'client', + hb_source_appnexus: 'client', + hb_pb_appnexus: '10.00', + hb_native_title_appn: 'This is a Prebid Native Creative', + hb_native_linkurl: 'http://prebid.org/dev-docs/show-native-ads.html', + hb_format: 'native', + hb_native_brand: 'Prebid.org', + hb_size: '0x0', + hb_bidder_appnexus: 'appnexus', + hb_native_linkurl_ap: 'http://prebid.org/dev-docs/show-native-ads.html', + hb_native_title: 'This is a Prebid Native Creative', + hb_pb: '10.00', + hb_native_brand_appn: 'Prebid.org', + hb_bidder: 'appnexus', + hb_format_appnexus: 'native', + hb_size_appnexus: '0x0' +} + +describe('Prebid.js Native Ad Unit Test', function () { + before(function loadTestPage() { + browser.url(TEST_PAGE_URL).pause(3000); + try { + browser.waitForExist(CREATIVE_IFRAME_CSS_SELECTOR, 2000); + } catch (e) { + // If creative Iframe didn't load, repeat the steps again! + // Due to some reason if the Ad server doesn't respond, the test case will time out after 60000 ms as defined in file wdio.conf.js + loadTestPage(); + } + }); + + it('should load the targeting keys with correct values', function () { + const result = browser.execute(function () { + return window.pbjs.getAdserverTargeting('/19968336/prebid_native_example_2'); + }); + + const targetingKeys = result.value['/19968336/prebid_native_example_2']; + expect(targetingKeys).to.include(EXPECTED_TARGETING_KEYS); + expect(targetingKeys.hb_adid).to.be.a('string'); + expect(targetingKeys.hb_native_body).to.be.a('string'); + expect(targetingKeys.hb_native_body_appne).to.be.a('string'); + expect(targetingKeys.hb_native_icon).to.be.a('string'); + expect(targetingKeys.hb_native_icon_appne).to.be.a('string'); + expect(targetingKeys.hb_native_image).to.be.a('string'); + expect(targetingKeys.hb_adid_appnexus).to.be.a('string'); + }); + + it('should render the native ad on the page', function () { + const creativeIframe = $(CREATIVE_IFRAME_CSS_SELECTOR).value; + browser.frame(creativeIframe); + expect(browser.isVisible('body > div[class="GoogleActiveViewElement"] > div[class="card"]')).to.be.true; + }); +}); diff --git a/test/spec/e2e/outstream/basic_outstream_video_ad.spec.js b/test/spec/e2e/outstream/basic_outstream_video_ad.spec.js new file mode 100644 index 00000000000..15b0bb29309 --- /dev/null +++ b/test/spec/e2e/outstream/basic_outstream_video_ad.spec.js @@ -0,0 +1,53 @@ +const expect = require('chai').expect; +const { host, protocol } = require('../../../helpers/testing-utils'); + +const TEST_PAGE_URL = `${protocol}://${host}:9999/test/pages/outstream.html`; +const CREATIVE_IFRAME_CSS_SELECTOR = 'div[id="video_ad_unit_1"] > div:nth-child(2) > iframe:nth-child(1)'; + +const EXPECTED_TARGETING_KEYS = { + hb_cache_id: '', + hb_uuid: '', + hb_format: 'video', + hb_source: 'client', + hb_size: '640x480', + hb_pb: '10.00', + hb_bidder: 'appnexus', + hb_format_appnexus: 'video', + hb_source_appnexus: 'client', + hb_size_appnexus: '640x480', + hb_pb_appnexus: '10.00', + hb_bidder_appnexus: 'appnexus' +}; + +describe('Prebid.js Outstream Video Ad Test', function () { + before(function loadTestPage() { + browser + .url(TEST_PAGE_URL) + .scroll(0, 300) + .pause(3000); + try { + browser.waitForExist(CREATIVE_IFRAME_CSS_SELECTOR, 5000); + } catch (e) { + // If creative Iframe didn't load, repeat the steps again! + // Due to some reason if the Ad server doesn't respond, the test case will time out after 60000 ms as defined in file wdio.conf.js + loadTestPage(); + } + }); + + it('should load the targeting keys with correct values', function () { + const result = browser.execute(function () { + return window.pbjs.getAdserverTargeting('video_ad_unit_2'); + }); + + const targetingKeys = result.value['video_ad_unit_2']; + expect(targetingKeys).to.include(EXPECTED_TARGETING_KEYS); + expect(targetingKeys.hb_adid).to.be.a('string'); + expect(targetingKeys.hb_adid_appnexus).to.be.a('string'); + }); + + it('should render the native ad on the page', function() { + const creativeIframe = $(CREATIVE_IFRAME_CSS_SELECTOR).value; + browser.frame(creativeIframe); + expect(browser.isVisible('body > div[class="video-js"] > video')); + }); +}); diff --git a/test/spec/e2e/testcase1/dom-group/allbidders_dom_spec.js b/test/spec/e2e/testcase1/dom-group/allbidders_dom_spec.js deleted file mode 100644 index 5803ad5ceb3..00000000000 --- a/test/spec/e2e/testcase1/dom-group/allbidders_dom_spec.js +++ /dev/null @@ -1,125 +0,0 @@ -// var verify = require('verify'); -var util = require('../../common/utils.js'); - -module.exports = { - 'adequant ad rendering': function (browser) { - browser - .url('http://an.localhost:9999/test/spec/e2e/gpt-examples/all_bidders_instant_load.html') - .waitForElementVisible('body', 5000) - .pause(7000) - .execute(util.findIframeInDiv, ['div-1'], function(result) { - this.verify.equal(result.value, true, 'adequant ad not rendered'); - }); - }, - 'adform ad rendering': function (browser) { - browser - .execute(util.findIframeInDiv, ['div-2'], function(result) { - this.verify.equal(result.value, true, 'adform ad not rendered'); - }); - }, - 'aol ad rendering': function (browser) { - browser - .execute(util.findIframeInDiv, ['div-3'], function(result) { - this.verify.equal(result.value, true, 'aol ad not rendered'); - }); - }, - 'appnexus ad rendering': function (browser) { - browser - .execute(util.findIframeInDiv, ['div-4'], function(result) { - this.verify.equal(result.value, true, 'appnexus ad not rendered'); - }); - }, - 'indexExchange ad rendering': function (browser) { - browser - .execute(util.findIframeInDiv, ['div-5'], function(result) { - this.verify.equal(result.value, true, 'indexExchange ad not rendered'); - }); - }, - 'openx ad rendering': function (browser) { - browser - .execute(util.findIframeInDiv, ['div-6'], function(result) { - this.verify.equal(result.value, true, 'openx ad not rendered'); - }); - }, - 'pubmatic ad rendering': function (browser) { - browser - .execute(util.findIframeInDiv, ['div-7'], function(result) { - this.verify.equal(result.value, true, 'pubmatic ad not rendered'); - }); - }, - 'pulsepoint ad rendering': function (browser) { - browser - .execute(util.findIframeInDiv, ['div-8'], function(result) { - this.verify.equal(result.value, true, 'pulsepoint ad not rendered'); - }); - }, - 'rubicon ad rendering': function (browser) { - browser - .execute(util.findIframeInDiv, ['div-9'], function(result) { - this.verify.equal(result.value, true, 'rubicon ad not rendered'); - }); - }, - 'sonobi ad rendering': function (browser) { - browser - .execute(util.findIframeInDiv, ['div-10'], function(result) { - this.verify.equal(result.value, true, 'sonobi ad not rendered'); - }); - }, - 'sovrn ad rendering': function (browser) { - browser - .execute(util.findIframeInDiv, ['div-11'], function(result) { - this.verify.equal(result.value, true, 'sovrn ad not rendered'); - }); - }, - 'springserve ad rendering': function (browser) { - browser - .execute(util.findIframeInDiv, ['div-12'], function(result) { - this.verify.equal(result.value, true, 'springserve ad not rendered'); - }); - }, - 'triplelift ad rendering': function (browser) { - browser - .execute(util.findIframeInDiv, ['div-13'], function(result) { - this.verify.equal(result.value, true, 'triplelift ad not rendered'); - }); - }, - 'yieldbot ad rendering': function (browser) { - browser - .execute(util.findIframeInDiv, ['div-14'], function(result) { - this.verify.equal(result.value, true, 'yieldbot ad not rendered'); - }); - }, - 'nginad ad rendering': function (browser) { - browser - .execute(util.findIframeInDiv, ['div-15'], function(result) { - this.verify.equal(result.value, true, 'nginad ad not rendered'); - }); - }, - 'brightcom ad rendering': function (browser) { - browser - .execute(util.findIframeInDiv, ['div-16'], function(result) { - this.verify.equal(result.value, true, 'brightcom ad not rendered'); - }); - }, - 'sekindo ad rendering': function (browser) { - browser - .execute(util.findIframeInDiv, ['div-17'], function(result) { - this.verify.equal(result.value, true, 'sekindo ad not rendered'); - }); - }, - 'kruxlink ad rendering': function (browser) { - browser - .execute(util.findIframeInDiv, ['div-18'], function(result) { - this.verify.equal(result.value, true, 'kruxlink ad not rendered'); - }); - }, - 'AdMedia ad rendering': function (browser) { - browser - .execute(util.findIframeInDiv, ['div-19'], function(result) { - this.verify.equal(result.value, true, 'AdMedia ad not rendered'); - }); - }, - after: function(browser) { - browser.end(); - } -}; diff --git a/test/spec/e2e/testcase1/dom-group/dom_spec.js b/test/spec/e2e/testcase1/dom-group/dom_spec.js deleted file mode 100644 index a58030c32b7..00000000000 --- a/test/spec/e2e/testcase1/dom-group/dom_spec.js +++ /dev/null @@ -1,51 +0,0 @@ -// var assert = require('assert'); - -module.exports = { - - 'Test rendering ad div-2': function (browser) { - var checkAdRendering2 = function() { - var div = document.getElementById('div-2'); - var iframes = div.getElementsByTagName('iframe'); - try { - if (iframes.length == 1 && iframes[0].contentWindow.document.body.innerHTML == '') { - return false; - } else { - return true; - } - } catch (e) { - return true; - } - } - - browser - .url('http://an.localhost:9999/test/spec/e2e/gpt-examples/e2e_default.html') - .waitForElementVisible('body', 3000) - .pause(3000) - .execute(checkAdRendering2, [], function(result) { - this.assert.equal(result.value, true, 'Ad of div-2 not rendered'); - }); - }, - 'Test rendering ad div-1': function (browser) { - var checkAdRendering = function() { - var div = document.getElementById('div-1'); - var iframes = div.getElementsByTagName('iframe'); - try { - if (iframes.length == 1 && iframes[0].contentWindow.document.body.innerHTML == '') { - return false; - } else { - return true; - } - } catch (e) { - return true; - } - } - - browser - .execute(checkAdRendering, [], function(result) { - this.assert.equal(result.value, true, 'Ad of div-1 not rendered'); - }); - }, - after: function(browser) { - browser.end(); - } -}; diff --git a/test/spec/e2e/testcase1/pbjsapi-group/adservertargeting_spec.js b/test/spec/e2e/testcase1/pbjsapi-group/adservertargeting_spec.js deleted file mode 100644 index 796707641cd..00000000000 --- a/test/spec/e2e/testcase1/pbjsapi-group/adservertargeting_spec.js +++ /dev/null @@ -1,62 +0,0 @@ -var assert = require('assert'); -var utils = require('util'); - -module.exports = { - 'AdserverTargeting Test Case 1': function (browser) { - browser - .url('http://localhost:9999/test/spec/e2e/gpt-examples/gpt_default.html') - .waitForElementVisible('body', 3000) - .pause(3000) - .execute(function() { - if (typeof window.pbjs.bidderSettings === 'undefined') { - var pbjsBidderSettingsObject = [ - 'hb_bidder', - 'hb_adid', - 'hb_pb', - 'hb_size' - ]; - } else { - var pbjsBidderSettings = window.pbjs.bidderSettings; - var pbjsBidderSettingsObject = {}; - Object.keys(pbjsBidderSettings).forEach(function (prop) { - // if(prop == 'standard') return; - var value = pbjsBidderSettings[prop]; - var bs = value.adserverTargeting.map(function(item) { - return item.key; - }); - pbjsBidderSettings.standard.adserverTargeting.map(function(value) { - if (bs.indexOf(value.key) == -1) { - bs.push(value.key) - } - }); - pbjsBidderSettingsObject[prop] = bs; - }); - } - - var adserverTargetingObject = {}; - var adserverTargeting = window.pbjs.getAdserverTargeting(); - Object.keys(adserverTargeting).forEach(function(value) { - if (Object.keys(adserverTargeting[value]).length == 0) return; - adserverTargetingObject[adserverTargeting[value].hb_bidder] = Object.keys(adserverTargeting[value]) - }); - - return [pbjsBidderSettingsObject, adserverTargetingObject]; - }, [], function(result) { - Object.keys(result.value[1]).forEach(function(key) { - if (utils.isArray(result.value[0])) { - assert.deepEqual(result.value[0].sort(), result.value[1][key].sort()); - } else { - if (result.value[0].hasOwnProperty(key)) { - var obj1 = result.value[0][key].sort(); - } else { - var obj1 = result.value[0]['standard'].sort(); - } - assert.deepEqual(obj1, result.value[1][key].sort()); - } - }); - }); - }, - after: function(browser) { - browser.end(); - } -}; diff --git a/test/spec/e2e/testcase1/pbjsapi-group/getbidresponses_spec.js b/test/spec/e2e/testcase1/pbjsapi-group/getbidresponses_spec.js deleted file mode 100644 index c7921709c0f..00000000000 --- a/test/spec/e2e/testcase1/pbjsapi-group/getbidresponses_spec.js +++ /dev/null @@ -1,34 +0,0 @@ -// var assert = require('assert'); -var assert = require('chai').assert; -var utils = require('util'); - -module.exports = { - 'bidReceived not empty': function(browser) { - browser - .url('http://localhost:9999/test/spec/e2e/gpt-examples/gpt_default.html') - .waitForElementVisible('body', 3000) - .pause(5000) - .execute(function() { - return window.pbjs._bidsReceived.length; - }, [], function(result) { - // browser.assert.first(false, 'Bid response empty'); - assert.isOk(result.value, 'Bid response empty'); - }); - }, - 'check keys': function(browser) { - browser - .execute(function() { - return window.pbjs._bidsReceived; - }, [], function(result) { - // minimum expected keys in bid received - var expected = ['bidderCode', 'width', 'height', 'adId', 'cpm', 'requestId', 'bidder', 'adUnitCode', 'timeToRespond']; - Object.keys(result.value).forEach(function(key) { - var compare = Object.keys(result.value[key]); - assert.includeMembers(compare, expected, 'include members'); - }); - }); - }, - after: function(browser) { - browser.end(); - } -}; diff --git a/test/spec/modules/33acrossBidAdapter_spec.js b/test/spec/modules/33acrossBidAdapter_spec.js index 1fc77a7e14d..08ea0a863ee 100644 --- a/test/spec/modules/33acrossBidAdapter_spec.js +++ b/test/spec/modules/33acrossBidAdapter_spec.js @@ -337,8 +337,8 @@ describe('33acrossBidAdapter:', function () { utils.getWindowTop.restore(); utils.getWindowSelf.restore(); - sandbox.stub(utils, 'getWindowTop').returns(win); - sandbox.stub(utils, 'getWindowSelf').returns({}); + sandbox.stub(utils, 'getWindowTop').returns({}); + sandbox.stub(utils, 'getWindowSelf').returns(win); expect(spec.buildRequests(bidRequests)).to.deep.equal([ serverRequest ]); }); @@ -618,73 +618,140 @@ describe('33acrossBidAdapter:', function () { ]; }); - context('when gdpr does not apply', function() { - let gdprConsent; + context('when iframe is not enabled', function() { + it('returns empty sync array', function() { + const syncOptions = {}; + + spec.buildRequests(bidRequests); + + expect(spec.getUserSyncs(syncOptions)).to.deep.equal([]); + }); + }); + context('when iframe is enabled', function() { + let syncOptions; beforeEach(function() { - gdprConsent = { - gdprApplies: false + syncOptions = { + iframeEnabled: true }; }); - context('when iframe is not enabled', function() { - it('returns empty sync array', function() { - const syncOptions = {}; + context('when there is no gdpr consent data', function() { + it('returns sync urls with undefined consent string as param', function() { + spec.buildRequests(bidRequests); + const syncResults = spec.getUserSyncs(syncOptions, {}, undefined); + const expectedSyncs = [ + { + type: 'iframe', + url: `${syncs[0].url}&gdpr_consent=undefined` + }, + { + type: 'iframe', + url: `${syncs[1].url}&gdpr_consent=undefined` + } + ] + + expect(syncResults).to.deep.equal(expectedSyncs); + }) + }); + + context('when gdpr applies but there is no consent string', function() { + it('returns sync urls with undefined consent string as param and gdpr=1', function() { spec.buildRequests(bidRequests); - expect(spec.getUserSyncs(syncOptions, {}, gdprConsent)).to.deep.equal([]); + const syncResults = spec.getUserSyncs(syncOptions, {}, {gdprApplies: true}); + const expectedSyncs = [ + { + type: 'iframe', + url: `${syncs[0].url}&gdpr_consent=undefined&gdpr=1` + }, + { + type: 'iframe', + url: `${syncs[1].url}&gdpr_consent=undefined&gdpr=1` + } + ]; + + expect(syncResults).to.deep.equal(expectedSyncs); }); }); - context('when iframe is enabled', function() { - it('returns sync array equal to number of unique siteIDs', function() { - const syncOptions = { - iframeEnabled: true - }; - + context('when gdpr applies and there is consent string', function() { + it('returns sync urls with gdpr_consent=consent string as param and gdpr=1', function() { spec.buildRequests(bidRequests); - expect(spec.getUserSyncs(syncOptions, {}, gdprConsent)).to.deep.equal(syncs); + const syncResults = spec.getUserSyncs(syncOptions, {}, {gdprApplies: true, consentString: 'consent123A'}); + const expectedSyncs = [ + { + type: 'iframe', + url: `${syncs[0].url}&gdpr_consent=consent123A&gdpr=1` + }, + { + type: 'iframe', + url: `${syncs[1].url}&gdpr_consent=consent123A&gdpr=1` + } + ]; + + expect(syncResults).to.deep.equal(expectedSyncs); }); }); - }); - - context('when consent data is not defined', function() { - context('when iframe is not enabled', function() { - it('returns empty sync array', function() { - const syncOptions = {}; + context('when gdpr does not apply and there is no consent string', function() { + it('returns sync urls with undefined consent string as param and gdpr=0', function() { spec.buildRequests(bidRequests); - expect(spec.getUserSyncs(syncOptions)).to.deep.equal([]); + const syncResults = spec.getUserSyncs(syncOptions, {}, {gdprApplies: false}); + const expectedSyncs = [ + { + type: 'iframe', + url: `${syncs[0].url}&gdpr_consent=undefined&gdpr=0` + }, + { + type: 'iframe', + url: `${syncs[1].url}&gdpr_consent=undefined&gdpr=0` + } + ]; + expect(syncResults).to.deep.equal(expectedSyncs); }); }); - context('when iframe is enabled', function() { - it('returns sync array equal to number of unique siteIDs', function() { - const syncOptions = { - iframeEnabled: true - }; - + context('when gdpr is unknown and there is consent string', function() { + it('returns sync urls with only consent string as param', function() { spec.buildRequests(bidRequests); - expect(spec.getUserSyncs(syncOptions)).to.deep.equal(syncs); + const syncResults = spec.getUserSyncs(syncOptions, {}, {consentString: 'consent123A'}); + const expectedSyncs = [ + { + type: 'iframe', + url: `${syncs[0].url}&gdpr_consent=consent123A` + }, + { + type: 'iframe', + url: `${syncs[1].url}&gdpr_consent=consent123A` + } + ]; + expect(syncResults).to.deep.equal(expectedSyncs); }); }); - }); - context('when gdpr applies', function() { - it('returns empty sync array', function() { - const syncOptions = {}; - const gdprConsent = { - gdprApplies: true - }; - - spec.buildRequests(bidRequests); + context('when gdpr does not apply and there is consent string (yikes!)', function() { + it('returns sync urls with consent string as param and gdpr=0', function() { + spec.buildRequests(bidRequests); - expect(spec.getUserSyncs(syncOptions, {}, gdprConsent)).to.deep.equal([]); + const syncResults = spec.getUserSyncs(syncOptions, {}, {gdprApplies: false, consentString: 'consent123A'}); + const expectedSyncs = [ + { + type: 'iframe', + url: `${syncs[0].url}&gdpr_consent=consent123A&gdpr=0` + }, + { + type: 'iframe', + url: `${syncs[1].url}&gdpr_consent=consent123A&gdpr=0` + } + ]; + expect(syncResults).to.deep.equal(expectedSyncs); + }); }); - }) + }); }); }); diff --git a/test/spec/modules/aardvarkBidAdapter_spec.js b/test/spec/modules/aardvarkBidAdapter_spec.js index 628f19f8fd2..b532fa4264a 100644 --- a/test/spec/modules/aardvarkBidAdapter_spec.js +++ b/test/spec/modules/aardvarkBidAdapter_spec.js @@ -1,5 +1,6 @@ import { expect } from 'chai'; -import { spec } from 'modules/aardvarkBidAdapter'; +import * as utils from 'src/utils'; +import { spec, resetUserSync } from 'modules/aardvarkBidAdapter'; describe('aardvarkAdapterTest', function () { describe('forming valid bidRequests', function () { @@ -37,7 +38,8 @@ describe('aardvarkAdapterTest', function () { sizes: [300, 250], bidId: '1abgs362e0x48a8', bidderRequestId: '70deaff71c281d', - auctionId: '5c66da22-426a-4bac-b153-77360bef5337' + auctionId: '5c66da22-426a-4bac-b153-77360bef5337', + userId: { tdid: 'eff98622-b5fd-44fa-9a49-6e846922d532' } }, { bidder: 'aardvark', @@ -54,21 +56,27 @@ describe('aardvarkAdapterTest', function () { auctionId: 'e97cafd0-ebfc-4f5c-b7c9-baa0fd335a4a' }]; + const bidderRequest = { + refererInfo: { + referer: 'http://example.com' + } + }; + it('should use HTTP GET method', function () { - const requests = spec.buildRequests(bidRequests); - requests.forEach(function(requestItem) { + const requests = spec.buildRequests(bidRequests, bidderRequest); + requests.forEach(function (requestItem) { expect(requestItem.method).to.equal('GET'); }); }); it('should call the correct bidRequest url', function () { - const requests = spec.buildRequests(bidRequests); + const requests = spec.buildRequests(bidRequests, bidderRequest); expect(requests.length).to.equal(1); expect(requests[0].url).to.match(new RegExp('^\/\/adzone.pub.com/xiby/TdAx_RAZd/aardvark\?')); }); it('should have correct data', function () { - const requests = spec.buildRequests(bidRequests); + const requests = spec.buildRequests(bidRequests, bidderRequest); expect(requests.length).to.equal(1); expect(requests[0].data.version).to.equal(1); expect(requests[0].data.jsonp).to.equal(false); @@ -76,6 +84,13 @@ describe('aardvarkAdapterTest', function () { expect(requests[0].data.rtkreferer).to.not.be.undefined; expect(requests[0].data.RAZd).to.equal('22aidtbx5eabd9'); }); + + it('should have tdid, it is available in bidRequest', function () { + const requests = spec.buildRequests(bidRequests, bidderRequest); + requests.forEach(function (requestItem) { + expect(requestItem.data.tdid).to.equal('eff98622-b5fd-44fa-9a49-6e846922d532'); + }); + }); }); describe('splitting multi-auction ad units into own requests', function () { @@ -108,22 +123,28 @@ describe('aardvarkAdapterTest', function () { auctionId: 'e97cafd0-ebfc-4f5c-b7c9-baa0fd335a4a' }]; + const bidderRequest = { + refererInfo: { + referer: 'http://example.com' + } + }; + it('should use HTTP GET method', function () { - const requests = spec.buildRequests(bidRequests); - requests.forEach(function(requestItem) { + const requests = spec.buildRequests(bidRequests, bidderRequest); + requests.forEach(function (requestItem) { expect(requestItem.method).to.equal('GET'); }); }); it('should call the correct bidRequest urls for each auction', function () { - const requests = spec.buildRequests(bidRequests); + const requests = spec.buildRequests(bidRequests, bidderRequest); expect(requests[0].url).to.match(new RegExp('^\/\/bidder.rtk.io/Toby/TdAx/aardvark\?')); expect(requests[0].data.categories.length).to.equal(2); expect(requests[1].url).to.match(new RegExp('^\/\/adzone.pub.com/xiby/RAZd/aardvark\?')); }); it('should have correct data', function () { - const requests = spec.buildRequests(bidRequests); + const requests = spec.buildRequests(bidRequests, bidderRequest); expect(requests.length).to.equal(2); expect(requests[0].data.version).to.equal(1); expect(requests[0].data.jsonp).to.equal(false); @@ -136,6 +157,13 @@ describe('aardvarkAdapterTest', function () { expect(requests[1].data.rtkreferer).to.not.be.undefined; expect(requests[1].data.RAZd).to.equal('22aidtbx5eabd9'); }); + + it('should have no tdid, it is not available in bidRequest', function () { + const requests = spec.buildRequests(bidRequests, bidderRequest); + requests.forEach(function (requestItem) { + expect(requestItem.data.tdid).to.be.undefined; + }); + }); }); describe('GDPR conformity', function () { @@ -157,6 +185,9 @@ describe('aardvarkAdapterTest', function () { gdprConsent: { consentString: 'awefasdfwefasdfasd', gdprApplies: true + }, + refererInfo: { + referer: 'http://example.com' } }; @@ -184,7 +215,10 @@ describe('aardvarkAdapterTest', function () { }]; const bidderRequest = { - gdprConsent: undefined + gdprConsent: undefined, + refererInfo: { + referer: 'http://example.com' + } }; it('should transmit correct data', function () { @@ -219,6 +253,7 @@ describe('aardvarkAdapterTest', function () { cid: '1abgs362e0x48a8', adm: '', ttl: 200, + ex: 'extraproperty' } ], headers: {} @@ -234,6 +269,7 @@ describe('aardvarkAdapterTest', function () { expect(result[0].currency).to.equal('USD'); expect(result[0].ttl).to.equal(200); expect(result[0].dealId).to.equal('dealing'); + expect(result[0].ex).to.be.undefined; expect(result[0].ad).to.not.be.undefined; expect(result[1].requestId).to.equal('1abgs362e0x48a8'); @@ -243,6 +279,7 @@ describe('aardvarkAdapterTest', function () { expect(result[1].currency).to.equal('USD'); expect(result[1].ttl).to.equal(200); expect(result[1].ad).to.not.be.undefined; + expect(result[1].ex).to.equal('extraproperty'); }); it('should handle nobid responses', function () { @@ -260,4 +297,126 @@ describe('aardvarkAdapterTest', function () { expect(result.length).to.equal(0); }); }); + + describe('getUserSyncs', function () { + const syncOptions = { + iframeEnabled: true + }; + + it('should produce sync url', function () { + const syncs = spec.getUserSyncs(syncOptions); + expect(syncs.length).to.equal(1); + expect(syncs[0].type).to.equal('iframe'); + expect(syncs[0].url).to.equal('//sync.rtk.io/cs'); + }); + + it('should return empty, as we sync only once', function () { + const syncs = spec.getUserSyncs(syncOptions); + expect(syncs.length).to.equal(0); + }); + + it('should reset hasSynced flag, allowing another sync', function () { + resetUserSync(); + + const syncs = spec.getUserSyncs(syncOptions); + expect(syncs.length).to.equal(1); + }); + + it('should return empty when iframe disallowed', function () { + resetUserSync(); + + const noIframeOptions = { iframeEnabled: false }; + const syncs = spec.getUserSyncs(noIframeOptions); + expect(syncs.length).to.equal(0); + }); + + it('should produce sync url with gdpr params', function () { + const gdprConsent = { + gdprApplies: true, + consentString: 'BOEFEAyOEFEAyAHABDENAI4AAAB9vABAASA' + }; + + resetUserSync(); + + const syncs = spec.getUserSyncs(syncOptions, null, gdprConsent); + expect(syncs.length).to.equal(1); + expect(syncs[0].type).to.equal('iframe'); + expect(syncs[0].url).to.equal('//sync.rtk.io/cs?g=1&c=BOEFEAyOEFEAyAHABDENAI4AAAB9vABAASA'); + }); + }); + + describe('reading window.top properties', function () { + const bidCategories = ['bcat1', 'bcat2', 'bcat3']; + const bidRequests = [{ + bidder: 'aardvark', + params: { + ai: 'xiby', + sc: 'TdAx', + host: 'adzone.pub.com', + categories: bidCategories + }, + adUnitCode: 'RTK_aaaa', + transactionId: '1b8389fe-615c-482d-9f1a-177fb8f7d5b0', + sizes: [300, 250], + bidId: '1abgs362e0x48a8', + bidderRequestId: '70deaff71c281d', + auctionId: '5c66da22-426a-4bac-b153-77360bef5337', + userId: { tdid: 'eff98622-b5fd-44fa-9a49-6e846922d532' } + }]; + + const bidderRequest = { + refererInfo: { + referer: 'http://example.com' + } + }; + + const topWin = { + innerWidth: 1366, + innerHeight: 768, + rtkcategories: ['cat1', 'cat2', 'cat3'] + }; + + let sandbox; + beforeEach(function () { + sandbox = sinon.createSandbox(); + }); + + afterEach(function () { + sandbox.restore(); + }); + + it('should have window.top dimensions', function () { + sandbox.stub(utils, 'getWindowTop').returns(topWin); + + const requests = spec.buildRequests(bidRequests, bidderRequest); + requests.forEach(function (requestItem) { + expect(requestItem.data.w).to.equal(topWin.innerWidth); + expect(requestItem.data.h).to.equal(topWin.innerHeight); + }); + }); + + it('should have window dimensions, as backup', function () { + sandbox.stub(utils, 'getWindowTop').returns(undefined); + + const requests = spec.buildRequests(bidRequests, bidderRequest); + requests.forEach(function (requestItem) { + expect(requestItem.data.w).to.equal(window.innerWidth); + expect(requestItem.data.h).to.equal(window.innerHeight); + }); + }); + + it('should have window.top & bid categories', function () { + sandbox.stub(utils, 'getWindowTop').returns(topWin); + + const requests = spec.buildRequests(bidRequests, bidderRequest); + requests.forEach(function (requestItem) { + utils._each(topWin.categories, function (cat) { + expect(requestItem.data.categories).to.contain(cat); + }); + utils._each(bidCategories, function (cat) { + expect(requestItem.data.categories).to.contain(cat); + }); + }); + }); + }); }); diff --git a/test/spec/modules/adformBidAdapter_spec.js b/test/spec/modules/adformBidAdapter_spec.js index d3054794485..f50474ae500 100644 --- a/test/spec/modules/adformBidAdapter_spec.js +++ b/test/spec/modules/adformBidAdapter_spec.js @@ -2,6 +2,7 @@ import {assert, expect} from 'chai'; import * as url from 'src/url'; import {spec} from 'modules/adformBidAdapter'; import { BANNER, VIDEO } from 'src/mediaTypes'; +import { config } from 'src/config'; describe('Adform adapter', function () { let serverResponse, bidRequest, bidResponses; @@ -50,6 +51,24 @@ describe('Adform adapter', function () { assert.equal(request.method, 'GET'); }); + it('should pass request currency from config', function () { + config.setConfig({ currency: { adServerCurrency: 'PLN' } }); + let request = parseUrl(spec.buildRequests(bids).url); + + request.items.forEach(item => { + assert.equal(item.rcur, 'PLN'); + }); + }); + + it('should prefer bid currency over global config', function () { + config.setConfig({ currency: { adServerCurrency: 'PLN' } }); + bids[0].params.rcur = 'USD'; + let request = parseUrl(spec.buildRequests(bids).url); + const currencies = request.items.map(item => item.rcur); + + assert.deepEqual(currencies, [ 'USD', 'PLN', 'PLN', 'PLN', 'PLN', 'PLN', 'PLN' ]); + }); + it('should correctly form bid items', function () { let bidList = bids; let request = spec.buildRequests(bidList); @@ -286,6 +305,8 @@ describe('Adform adapter', function () { }); beforeEach(function () { + config.setConfig({ currency: {} }); + let sizes = [[250, 300], [300, 250], [300, 600]]; let placementCode = ['div-01', 'div-02', 'div-03', 'div-04', 'div-05']; let params = [{ mid: 1, url: 'some// there' }, {adxDomain: null, mid: 2, someVar: 'someValue', pt: 'gross'}, { adxDomain: null, mid: 3, pdom: 'home' }, {mid: 5, pt: 'net'}, {mid: 6, pt: 'gross'}]; diff --git a/test/spec/modules/adformOpenRTBBidAdapter_spec.js b/test/spec/modules/adformOpenRTBBidAdapter_spec.js index 5c0009ab1c7..32795c24ef6 100644 --- a/test/spec/modules/adformOpenRTBBidAdapter_spec.js +++ b/test/spec/modules/adformOpenRTBBidAdapter_spec.js @@ -3,6 +3,7 @@ import {assert, expect} from 'chai'; import * as url from 'src/url'; import {spec} from 'modules/adformOpenRTBBidAdapter'; import { NATIVE } from 'src/mediaTypes'; +import { config } from 'src/config'; describe('AdformOpenRTB adapter', function () { let serverResponse, bidRequest, bidResponses; @@ -144,6 +145,15 @@ describe('AdformOpenRTB adapter', function () { }); }); + it('should send currency if defined', function () { + config.setConfig({ currency: { adServerCurrency: 'EUR' } }); + let validBidRequests = [{ params: {} }]; + let refererInfo = { referer: 'page' }; + let request = JSON.parse(spec.buildRequests(validBidRequests, { refererInfo }).data); + + assert.deepEqual(request.cur, [ 'EUR' ]); + }); + describe('priceType', function () { it('should send default priceType', function () { let validBidRequests = [{ @@ -262,13 +272,102 @@ describe('AdformOpenRTB adapter', function () { let assets = JSON.parse(spec.buildRequests(validBidRequests, { refererInfo: { referer: 'page' } }).data).imp[0].native.request.assets; assert.ok(assets[0].title); assert.equal(assets[0].title.len, 140); - assert.deepEqual(assets[1].img, { type: 3, wmin: 150, hmin: 50 }); - assert.deepEqual(assets[2].img, { type: 1, wmin: 50, hmin: 50 }); + assert.deepEqual(assets[1].img, { type: 3, w: 150, h: 50 }); + assert.deepEqual(assets[2].img, { type: 1, w: 50, h: 50 }); assert.deepEqual(assets[3].data, { type: 2, len: 140 }); assert.deepEqual(assets[4].data, { type: 1 }); assert.deepEqual(assets[5].data, { type: 12 }); assert.ok(!assets[6]); }); + + describe('icon/image sizing', function () { + it('should flatten sizes and utilise first pair', function () { + const validBidRequests = [{ + bidId: 'bidId', + params: { siteId: 'siteId', mid: 1000 }, + nativeParams: { + image: { + sizes: [[200, 300], [100, 200]] + }, + } + }]; + + let assets = JSON.parse(spec.buildRequests(validBidRequests, { refererInfo: { referer: 'page' } }).data).imp[0].native.request.assets; + assert.ok(assets[0].img); + assert.equal(assets[0].img.w, 200); + assert.equal(assets[0].img.h, 300); + }); + }); + + it('should utilise aspect_ratios', function () { + const validBidRequests = [{ + bidId: 'bidId', + params: { siteId: 'siteId', mid: 1000 }, + nativeParams: { + image: { + aspect_ratios: [{ + min_width: 100, + ratio_height: 3, + ratio_width: 1 + }] + }, + icon: { + aspect_ratios: [{ + min_width: 10, + ratio_height: 5, + ratio_width: 2 + }] + } + } + }]; + + let assets = JSON.parse(spec.buildRequests(validBidRequests, { refererInfo: { referer: 'page' } }).data).imp[0].native.request.assets; + assert.ok(assets[0].img); + assert.equal(assets[0].img.wmin, 100); + assert.equal(assets[0].img.hmin, 300); + + assert.ok(assets[1].img); + assert.equal(assets[1].img.wmin, 10); + assert.equal(assets[1].img.hmin, 25); + }); + + it('should not throw error if aspect_ratios config is not defined', function () { + const validBidRequests = [{ + bidId: 'bidId', + params: { siteId: 'siteId', mid: 1000 }, + nativeParams: { + image: { + aspect_ratios: [] + }, + icon: { + aspect_ratios: [] + } + } + }]; + + assert.doesNotThrow(() => spec.buildRequests(validBidRequests, { refererInfo: { referer: 'page' } })); + }); + }); + + it('should expect any dimensions if min_width not passed', function () { + const validBidRequests = [{ + bidId: 'bidId', + params: { siteId: 'siteId', mid: 1000 }, + nativeParams: { + image: { + aspect_ratios: [{ + ratio_height: 3, + ratio_width: 1 + }] + } + } + }]; + + let assets = JSON.parse(spec.buildRequests(validBidRequests, { refererInfo: { referer: 'page' } }).data).imp[0].native.request.assets; + assert.ok(assets[0].img); + assert.equal(assets[0].img.wmin, 0); + assert.equal(assets[0].img.hmin, 0); + assert.ok(!assets[1]); }); }); }); @@ -285,9 +384,9 @@ describe('AdformOpenRTB adapter', function () { let serverResponse = { body: { seatbid: [{ - bid: [{impid: 'impid1', native: {ver: '1.1', link: { url: 'link' }, assets: [{id: 1, title: {text: 'Asset title text'}}]}}] + bid: [{impid: '1', native: {ver: '1.1', link: { url: 'link' }, assets: [{id: 1, title: {text: 'Asset title text'}}]}}] }, { - bid: [{impid: 'impid2', native: {ver: '1.1', link: { url: 'link' }, assets: [{id: 1, data: {value: 'Asset title text'}}]}}] + bid: [{impid: '2', native: {ver: '1.1', link: { url: 'link' }, assets: [{id: 1, data: {value: 'Asset title text'}}]}}] }] } }; @@ -318,6 +417,71 @@ describe('AdformOpenRTB adapter', function () { bids = spec.interpretResponse(serverResponse, bidRequest); assert.equal(spec.interpretResponse(serverResponse, bidRequest).length, 2); }); + + it('should parse seatbids', function () { + let serverResponse = { + body: { + seatbid: [{ + bid: [ + {impid: '1', native: {ver: '1.1', link: { url: 'link1' }, assets: [{id: 1, title: {text: 'Asset title text'}}]}}, + {impid: '4', native: {ver: '1.1', link: { url: 'link4' }, assets: [{id: 1, title: {text: 'Asset title text'}}]}} + ] + }, { + bid: [{impid: '2', native: {ver: '1.1', link: { url: 'link2' }, assets: [{id: 1, data: {value: 'Asset title text'}}]}}] + }] + } + }; + let bidRequest = { + data: {}, + bids: [ + { + bidId: 'bidId1', + params: { siteId: 'siteId', mid: 1000 }, + nativeParams: { + title: { required: true, len: 140 }, + image: { required: false, wmin: 836, hmin: 627, w: 325, h: 300, mimes: ['image/jpg', 'image/gif'] }, + body: { len: 140 } + } + }, + { + bidId: 'bidId2', + params: { siteId: 'siteId', mid: 1000 }, + nativeParams: { + title: { required: true, len: 140 }, + image: { required: false, wmin: 836, hmin: 627, w: 325, h: 300, mimes: ['image/jpg', 'image/gif'] }, + body: { len: 140 } + } + }, + { + bidId: 'bidId3', + params: { siteId: 'siteId', mid: 1000 }, + nativeParams: { + title: { required: true, len: 140 }, + image: { required: false, wmin: 836, hmin: 627, w: 325, h: 300, mimes: ['image/jpg', 'image/gif'] }, + body: { len: 140 } + } + }, + { + bidId: 'bidId4', + params: { siteId: 'siteId', mid: 1000 }, + nativeParams: { + title: { required: true, len: 140 }, + image: { required: false, wmin: 836, hmin: 627, w: 325, h: 300, mimes: ['image/jpg', 'image/gif'] }, + body: { len: 140 } + } + } + ] + }; + + bids = spec.interpretResponse(serverResponse, bidRequest).map(bid => { + const { requestId, native: { clickUrl } } = bid; + return [ requestId, clickUrl ]; + }); + + assert.equal(bids.length, 3); + assert.deepEqual(bids, [[ 'bidId1', 'link1' ], [ 'bidId2', 'link2' ], [ 'bidId4', 'link4' ]]); + }); + it('should set correct values to bid', function () { let serverResponse = { body: { @@ -326,7 +490,7 @@ describe('AdformOpenRTB adapter', function () { seatbid: [{ bid: [ { - impid: 'impid1', + impid: '1', price: 93.1231, crid: '12312312', native: { @@ -369,7 +533,7 @@ describe('AdformOpenRTB adapter', function () { it('should set correct native params', function () { const bid = [ { - impid: 'impid1', + impid: '1', price: 93.1231, crid: '12312312', native: { diff --git a/test/spec/modules/adgenerationBidAdapter_spec.js b/test/spec/modules/adgenerationBidAdapter_spec.js index 28bccd7844e..2b8834f1e1d 100644 --- a/test/spec/modules/adgenerationBidAdapter_spec.js +++ b/test/spec/modules/adgenerationBidAdapter_spec.js @@ -199,7 +199,7 @@ describe('AdgenerationAdapter', function () { results: [], }, banner: { - ad: '
    ', + ad: '
    ', beacon: '', cpm: 36.0008, displaytype: '1', @@ -215,11 +215,11 @@ describe('AdgenerationAdapter', function () { dealid: 'fd5sa5fa7f', ttl: 1000, results: [ - {ad: '
    '}, + {ad: '
    '}, ] }, native: { - ad: '↵ ↵ ↵ ↵ ↵
    ↵ ', + ad: '↵ ↵ ↵ ↵ ↵
    ↵ ', beacon: '', cpm: 36.0008, displaytype: '1', @@ -261,7 +261,7 @@ describe('AdgenerationAdapter', function () { id: 2, img: { h: 250, - url: 'https://s3-ap-northeast-1.amazonaws.com/sdk-temp/adg-sample-ad/img/300x250.png', + url: 'https://sdk-temp.s3-ap-northeast-1.amazonaws.com/adg-sample-ad/img/300x250.png', w: 300 }, required: 1 @@ -291,10 +291,10 @@ describe('AdgenerationAdapter', function () { required: 0 } ], - imptrackers: ['https://s3-ap-northeast-1.amazonaws.com/adg-dummy-dsp/1x1.gif'], + imptrackers: ['https://adg-dummy-dsp.s3-ap-northeast-1.amazonaws.com/1x1.gif'], link: { clicktrackers: [ - 'https://s3-ap-northeast-1.amazonaws.com/adg-dummy-dsp/1x1_clicktracker_access.gif' + 'https://adg-dummy-dsp.s3-ap-northeast-1.amazonaws.com/1x1_clicktracker_access.gif' ], url: 'https://supership.jp' }, @@ -322,7 +322,7 @@ describe('AdgenerationAdapter', function () { currency: 'JPY', netRevenue: true, ttl: 1000, - ad: '
    ', + ad: '
    ', }, native: { requestId: '2f6ac468a9c15e', @@ -334,11 +334,11 @@ describe('AdgenerationAdapter', function () { currency: 'JPY', netRevenue: true, ttl: 1000, - ad: '↵
    ', + ad: '↵
    ', native: { title: 'Title', image: { - url: 'https://s3-ap-northeast-1.amazonaws.com/sdk-temp/adg-sample-ad/img/300x250.png', + url: 'https://sdk-temp.s3-ap-northeast-1.amazonaws.com/adg-sample-ad/img/300x250.png', height: 250, width: 300 }, @@ -352,8 +352,8 @@ describe('AdgenerationAdapter', function () { cta: 'CTA', privacyLink: 'https://supership.jp/optout/#', clickUrl: 'https://supership.jp', - clickTrackers: ['https://s3-ap-northeast-1.amazonaws.com/adg-dummy-dsp/1x1_clicktracker_access.gif'], - impressionTrackers: ['https://s3-ap-northeast-1.amazonaws.com/adg-dummy-dsp/1x1.gif'] + clickTrackers: ['https://adg-dummy-dsp.s3-ap-northeast-1.amazonaws.com/1x1_clicktracker_access.gif'], + impressionTrackers: ['https://adg-dummy-dsp.s3-ap-northeast-1.amazonaws.com/1x1.gif'] }, mediaType: NATIVE } diff --git a/test/spec/modules/adheseBidAdapter_spec.js b/test/spec/modules/adheseBidAdapter_spec.js index 68beedd4b35..348fb772319 100644 --- a/test/spec/modules/adheseBidAdapter_spec.js +++ b/test/spec/modules/adheseBidAdapter_spec.js @@ -64,6 +64,9 @@ describe('AdheseAdapter', function () { gdprConsent: { gdprApplies: true, consentString: 'CONSENT_STRING' + }, + refererInfo: { + referer: 'http://prebid.org/dev-docs/subjects?_d=1' } }; @@ -91,6 +94,12 @@ describe('AdheseAdapter', function () { expect(req.url).to.contain('/xtCONSENT_STRING'); }); + it('should include referer param in base64url format', function () { + let req = spec.buildRequests([ minimalBid() ], bidderRequest); + + expect(req.url).to.contain('/xfaHR0cDovL3ByZWJpZC5vcmcvZGV2LWRvY3Mvc3ViamVjdHM_X2Q9MQ'); + }); + it('should include bids', function () { let bid = minimalBid(); let req = spec.buildRequests([ bid ], bidderRequest); diff --git a/test/spec/modules/adkernelAdnBidAdapter_spec.js b/test/spec/modules/adkernelAdnBidAdapter_spec.js index 833a8e27f95..1147520131b 100644 --- a/test/spec/modules/adkernelAdnBidAdapter_spec.js +++ b/test/spec/modules/adkernelAdnBidAdapter_spec.js @@ -18,8 +18,7 @@ describe('AdkernelAdn adapter', function () { } }, adUnitCode: 'ad-unit-1', - }, - bid2_pub1 = { + }, bid2_pub1 = { bidder: 'adkernelAdn', transactionId: 'transact0', bidderRequestId: 'req0', @@ -34,8 +33,7 @@ describe('AdkernelAdn adapter', function () { sizes: [[300, 250]] } } - }, - bid1_pub2 = { + }, bid1_pub2 = { bidder: 'adkernelAdn', transactionId: 'transact2', bidderRequestId: 'req1', @@ -60,17 +58,15 @@ describe('AdkernelAdn adapter', function () { mediaTypes: { video: { context: 'instream', - playerSize: [640, 300] - } - }, - adUnitCode: 'video_wrapper', - params: { - pubId: 7, - video: { + playerSize: [640, 300], mimes: ['video/mp4', 'video/webm'], api: [1, 2], protocols: [5, 6] } + }, + adUnitCode: 'video_wrapper', + params: { + pubId: 7 } }, bid_video2 = { bidder: 'adkernelAdn', @@ -85,11 +81,23 @@ describe('AdkernelAdn adapter', function () { context: 'instream' } }, - adUnitCode: 'video_wrapper2', params: { pubId: 7 } + }, bid_multiformat = { + bidder: 'adkernelAdn', + transactionId: 'f82c64b8-c602-42a4-9791-4a268f6559ed', + bidderRequestId: 'req-001', + auctionId: 'auc-001', + bidId: 'Bid_01', + sizes: [[300, 250], [300, 200]], + mediaTypes: { + banner: {sizes: [[300, 250], [300, 200]]}, + video: {context: 'instream', playerSize: [[640, 480]]} + }, + adUnitCode: 'ad-unit-1', + params: {pubId: 7} }; const response = { @@ -137,9 +145,11 @@ describe('AdkernelAdn adapter', function () { describe('input parameters validation', () => { it('empty request shouldn\'t generate exception', () => { - expect(spec.isBidRequestValid({bidderCode: 'adkernelAdn' + expect(spec.isBidRequestValid({ + bidderCode: 'adkernelAdn' })).to.be.equal(false); }); + it('request without pubid should be ignored', () => { expect(spec.isBidRequestValid({ bidder: 'adkernelAdn', @@ -148,6 +158,7 @@ describe('AdkernelAdn adapter', function () { sizes: [[300, 250]] })).to.be.equal(false); }); + it('request with invalid pubid should be ignored', () => { expect(spec.isBidRequestValid({ bidder: 'adkernelAdn', @@ -158,6 +169,7 @@ describe('AdkernelAdn adapter', function () { sizes: [[300, 250]] })).to.be.equal(false); }); + it('request with totally invalid host should be ignored', () => { expect(spec.isBidRequestValid({ bidder: 'adkernelAdn', @@ -169,6 +181,7 @@ describe('AdkernelAdn adapter', function () { sizes: [[300, 250]] })).to.be.equal(false); }); + it('valid request should be accepted', () => { expect(spec.isBidRequestValid({ bidder: 'adkernelAdn', @@ -205,19 +218,24 @@ describe('AdkernelAdn adapter', function () { it('should have request id', function () { expect(tagRequest).to.have.property('id'); }); + it('should have transaction id', function () { expect(tagRequest).to.have.property('tid'); }); + it('should have sizes', function () { expect(tagRequest.imp[0].banner).to.have.property('format'); expect(tagRequest.imp[0].banner.format).to.be.eql(['300x250', '300x200']); }); + it('should have impression id', function () { expect(tagRequest.imp[0]).to.have.property('id', 'bidid_1'); }); + it('should have tagid', function () { expect(tagRequest.imp[0]).to.have.property('tagid', 'ad-unit-1'); }); + it('should create proper site block', function () { expect(tagRequest.site).to.have.property('page', 'https://example.com/index.html'); expect(tagRequest.site).to.have.property('secure', 1); @@ -256,16 +274,19 @@ describe('AdkernelAdn adapter', function () { expect(tagRequest.imp[0]).to.have.property('video'); expect(tagRequest.imp[1]).to.have.property('video'); }); + it('should have tagid', () => { expect(tagRequest.imp[0]).to.have.property('tagid', 'video_wrapper'); expect(tagRequest.imp[1]).to.have.property('tagid', 'video_wrapper2'); }); + it('should have size', () => { expect(tagRequest.imp[0].video).to.have.property('w', 640); expect(tagRequest.imp[0].video).to.have.property('h', 300); expect(tagRequest.imp[1].video).to.have.property('w', 1920); expect(tagRequest.imp[1].video).to.have.property('h', 1080); }); + it('should have video params', () => { expect(tagRequest.imp[0].video).to.have.property('mimes'); expect(tagRequest.imp[0].video.mimes).to.be.eql(['video/mp4', 'video/webm']); @@ -276,6 +297,21 @@ describe('AdkernelAdn adapter', function () { }); }); + describe('multiformat request building', function () { + let [_, tagRequests] = buildRequest([bid_multiformat]); + + it('should contain single request', function () { + expect(tagRequests).to.have.length(1); + expect(tagRequests[0].imp).to.have.length(1); + }); + + it('should contain banner-only impression', function () { + expect(tagRequests[0].imp).to.have.length(1); + expect(tagRequests[0].imp[0]).to.have.property('banner'); + expect(tagRequests[0].imp[0]).to.not.have.property('video'); + }); + }); + describe('requests routing', function () { it('should issue a request for each publisher', function () { let [pbRequests, tagRequests] = buildRequest([bid1_pub1, bid_video1]); @@ -285,6 +321,7 @@ describe('AdkernelAdn adapter', function () { expect(tagRequests[0].imp).to.have.length(1); expect(tagRequests[1].imp).to.have.length(1); }); + it('should issue a request for each host', function () { let [pbRequests, tagRequests] = buildRequest([bid1_pub1, bid1_pub2]); expect(pbRequests).to.have.length(2); @@ -297,12 +334,15 @@ describe('AdkernelAdn adapter', function () { describe('responses processing', function () { let responses; + before(function () { responses = spec.interpretResponse({body: response}); }); + it('should parse all responses', function () { expect(responses).to.have.length(3); }); + it('should return fully-initialized bid-response', function () { let resp = responses[0]; expect(resp).to.have.property('bidderCode', 'adkernelAdn'); @@ -317,6 +357,7 @@ describe('AdkernelAdn adapter', function () { expect(resp).to.have.property('ad'); expect(resp.ad).to.have.string(''); }); + it('should return fully-initialized video bid-response', function () { let resp = responses[2]; expect(resp).to.have.property('bidderCode', 'adkernelAdn'); @@ -329,6 +370,7 @@ describe('AdkernelAdn adapter', function () { expect(resp).to.have.property('vastUrl', 'http://vast.com/vast.xml'); expect(resp).to.not.have.property('ad'); }); + it('should perform usersync', function () { let syncs = spec.getUserSyncs({iframeEnabled: false}, [{body: response}]); expect(syncs).to.have.length(0); @@ -337,11 +379,13 @@ describe('AdkernelAdn adapter', function () { expect(syncs[0]).to.have.property('type', 'iframe'); expect(syncs[0]).to.have.property('url', 'https://dsp.adkernel.com/sync'); }); + it('should handle user-sync only response', function () { let [pbRequests, tagRequests] = buildRequest([bid1_pub1]); let resp = spec.interpretResponse({body: usersyncOnlyResponse}, pbRequests[0]); expect(resp).to.have.length(0); }); + it('shouldn\' fail on empty response', function () { let syncs = spec.getUserSyncs({iframeEnabled: true}, [{body: ''}]); expect(syncs).to.have.length(0); diff --git a/test/spec/modules/adkernelBidAdapter_spec.js b/test/spec/modules/adkernelBidAdapter_spec.js index 1d2d2215f02..621b9971304 100644 --- a/test/spec/modules/adkernelBidAdapter_spec.js +++ b/test/spec/modules/adkernelBidAdapter_spec.js @@ -5,9 +5,11 @@ import * as utils from 'src/utils'; describe('Adkernel adapter', function () { const bid1_zone1 = { bidder: 'adkernel', - bidId: 'Bid_01', params: {zoneId: 1, host: 'rtb.adkernel.com'}, adUnitCode: 'ad-unit-1', + bidId: 'Bid_01', + bidderRequestId: 'req-001', + auctionId: 'auc-001', mediaTypes: { banner: { sizes: [[300, 250], [300, 200]] @@ -15,19 +17,23 @@ describe('Adkernel adapter', function () { } }, bid2_zone2 = { bidder: 'adkernel', - bidId: 'Bid_02', params: {zoneId: 2, host: 'rtb.adkernel.com'}, adUnitCode: 'ad-unit-2', + bidId: 'Bid_02', + bidderRequestId: 'req-001', + auctionId: 'auc-001', mediaTypes: { banner: { - sizes: [728, 90] + sizes: [[728, 90]] } } }, bid3_host2 = { bidder: 'adkernel', - bidId: 'Bid_02', params: {zoneId: 1, host: 'rtb-private.adkernel.com'}, adUnitCode: 'ad-unit-2', + bidId: 'Bid_02', + bidderRequestId: 'req-001', + auctionId: 'auc-001', mediaTypes: { banner: { sizes: [[728, 90]] @@ -35,9 +41,11 @@ describe('Adkernel adapter', function () { } }, bid_without_zone = { bidder: 'adkernel', - bidId: 'Bid_W', params: {host: 'rtb-private.adkernel.com'}, adUnitCode: 'ad-unit-1', + bidId: 'Bid_W', + bidderRequestId: 'req-002', + auctionId: 'auc-002', mediaTypes: { banner: { sizes: [[728, 90]] @@ -45,9 +53,11 @@ describe('Adkernel adapter', function () { } }, bid_without_host = { bidder: 'adkernel', - bidId: 'Bid_W', params: {zoneId: 1}, adUnitCode: 'ad-unit-1', + bidId: 'Bid_W', + bidderRequestId: 'req-002', + auctionId: 'auc-002', mediaTypes: { banner: { sizes: [[728, 90]] @@ -55,9 +65,11 @@ describe('Adkernel adapter', function () { } }, bid_with_wrong_zoneId = { bidder: 'adkernel', - bidId: 'Bid_02', params: {zoneId: 'wrong id', host: 'rtb.adkernel.com'}, adUnitCode: 'ad-unit-2', + bidId: 'Bid_02', + bidderRequestId: 'req-002', + auctionId: 'auc-002', mediaTypes: { banner: { sizes: [[728, 90]] @@ -72,7 +84,8 @@ describe('Adkernel adapter', function () { sizes: [[640, 480]], params: { zoneId: 1, - host: 'rtb.adkernel.com' + host: 'rtb.adkernel.com', + video: {api: [1, 2]} }, mediaTypes: { video: { @@ -81,6 +94,19 @@ describe('Adkernel adapter', function () { } }, adUnitCode: 'ad-unit-1' + }, bid_multiformat = { + bidder: 'adkernel', + params: {zoneId: 1, host: 'rtb.adkernel.com'}, + mediaTypes: { + banner: {sizes: [[300, 250], [300, 200]]}, + video: {context: 'instream', playerSize: [[640, 480]]} + }, + adUnitCode: 'ad-unit-1', + transactionId: 'f82c64b8-c602-42a4-9791-4a268f6559ed', + sizes: [[300, 250], [300, 200]], + bidId: 'Bid_01', + bidderRequestId: 'req-001', + auctionId: 'auc-001' }; const bidResponse1 = { @@ -183,6 +209,11 @@ describe('Adkernel adapter', function () { expect(bidRequest.imp[0]).to.have.property('banner'); }); + it('should have id', function () { + expect(bidRequest.imp[0]).to.have.property('id'); + expect(bidRequest.imp[0].id).to.be.eql('Bid_01'); + }); + it('should have w/h', function () { expect(bidRequest.imp[0].banner).to.have.property('format'); expect(bidRequest.imp[0].banner.format).to.be.eql([{w: 300, h: 250}, {w: 300, h: 200}]); @@ -257,6 +288,27 @@ describe('Adkernel adapter', function () { it('should have tagid', function () { expect(bidRequests[0].imp[0]).to.have.property('tagid', 'ad-unit-1'); }); + + it('should have openrtb video impression parameters', function() { + expect(bidRequests[0].imp[0].video).to.have.property('api'); + expect(bidRequests[0].imp[0].video.api).to.be.eql([1, 2]); + }); + }); + + describe('multiformat request building', function () { + let _, bidRequests; + before(function () { + [_, bidRequests] = buildRequest([bid_multiformat]); + }); + it('should contain single request', function () { + expect(bidRequests).to.have.length(1); + expect(bidRequests[0].imp).to.have.length(1); + }); + it('should contain banner-only impression', function () { + expect(bidRequests[0].imp).to.have.length(1); + expect(bidRequests[0].imp[0]).to.have.property('banner'); + expect(bidRequests[0].imp[0]).to.not.have.property('video'); + }); }); describe('requests routing', function () { @@ -327,8 +379,8 @@ describe('Adkernel adapter', function () { describe('adapter configuration', () => { it('should have aliases', () => { - expect(spec.aliases).to.have.lengthOf(1); - expect(spec.aliases[0]).to.be.equal('headbidding'); + expect(spec.aliases).to.have.lengthOf(3); + expect(spec.aliases).to.be.eql(['headbidding', 'adsolut', 'oftmediahb']); }); }); }); diff --git a/test/spec/modules/admanBidAdapter_spec.js b/test/spec/modules/admanBidAdapter_spec.js index 2af040103cc..37a097427d5 100644 --- a/test/spec/modules/admanBidAdapter_spec.js +++ b/test/spec/modules/admanBidAdapter_spec.js @@ -86,7 +86,7 @@ describe('admanBidAdapter', function() { expect(payload.gdpr).to.exist; expect(payload.bids).to.exist.and.to.be.an('array').and.to.have.lengthOf(1); - expect(payload.referrer).to.exist; + expect(payload.referer).to.exist; const bid = payload.bids[0]; expect(bid).to.exist; diff --git a/test/spec/modules/adpod_spec.js b/test/spec/modules/adpod_spec.js index a47c77d25ac..8b7701c5631 100644 --- a/test/spec/modules/adpod_spec.js +++ b/test/spec/modules/adpod_spec.js @@ -99,6 +99,10 @@ describe('adpod.js', function () { auctionId: 'no_defer_123', mediaType: 'video', cpm: 5, + pbMg: '5.00', + adserverTargeting: { + hb_pb: '5.00' + }, meta: { adServerCatId: 'test' }, @@ -114,6 +118,10 @@ describe('adpod.js', function () { auctionId: 'no_defer_123', mediaType: 'video', cpm: 12, + pbMg: '12.00', + adserverTargeting: { + hb_pb: '12.00' + }, meta: { adServerCatId: 'value' }, @@ -175,6 +183,10 @@ describe('adpod.js', function () { auctionId: 'full_abc123', mediaType: 'video', cpm: 10, + pbMg: '10.00', + adserverTargeting: { + hb_pb: '10.00' + }, meta: { adServerCatId: 'airline' }, @@ -189,6 +201,10 @@ describe('adpod.js', function () { auctionId: 'full_abc123', mediaType: 'video', cpm: 15, + pbMg: '15.00', + adserverTargeting: { + hb_pb: '15.00' + }, meta: { adServerCatId: 'airline' }, @@ -247,6 +263,10 @@ describe('adpod.js', function () { auctionId: 'timer_abc234', mediaType: 'video', cpm: 15, + pbMg: '15.00', + adserverTargeting: { + hb_pb: '15.00' + }, meta: { adServerCatId: 'airline' }, @@ -300,6 +320,10 @@ describe('adpod.js', function () { auctionId: 'multi_call_abc345', mediaType: 'video', cpm: 15, + pbMg: '15.00', + adserverTargeting: { + hb_pb: '15.00' + }, meta: { adServerCatId: 'airline' }, @@ -314,6 +338,10 @@ describe('adpod.js', function () { auctionId: 'multi_call_abc345', mediaType: 'video', cpm: 15, + pbMg: '15.00', + adserverTargeting: { + hb_pb: '15.00' + }, meta: { adServerCatId: 'news' }, @@ -328,6 +356,10 @@ describe('adpod.js', function () { auctionId: 'multi_call_abc345', mediaType: 'video', cpm: 10, + pbMg: '10.00', + adserverTargeting: { + hb_pb: '10.00' + }, meta: { adServerCatId: 'sports' }, @@ -395,6 +427,10 @@ describe('adpod.js', function () { auctionId: 'no_category_abc345', mediaType: 'video', cpm: 10, + pbMg: '10.00', + adserverTargeting: { + hb_pb: '10.00' + }, meta: { adServerCatId: undefined }, @@ -409,6 +445,10 @@ describe('adpod.js', function () { auctionId: 'no_category_abc345', mediaType: 'video', cpm: 15, + pbMg: '15.00', + adserverTargeting: { + hb_pb: '15.00' + }, meta: { adServerCatId: undefined }, @@ -525,6 +565,10 @@ describe('adpod.js', function () { auctionId: 'duplicate_def123', mediaType: 'video', cpm: 5, + pbMg: '5.00', + adserverTargeting: { + hb_pb: '5.00' + }, meta: { adServerCatId: 'tech' }, @@ -539,6 +583,10 @@ describe('adpod.js', function () { auctionId: 'duplicate_def123', mediaType: 'video', cpm: 5, + pbMg: '5.00', + adserverTargeting: { + hb_pb: '5.00' + }, meta: { adServerCatId: 'tech' }, @@ -642,6 +690,82 @@ describe('adpod.js', function () { expect(logWarnStub.calledOnce).to.equal(true); expect(auctionBids.length).to.equal(0); }); + + it('should use bid.adserverTargeting.hb_pb when custom price granularity is configured', function() { + storeStub.callsFake(fakeStoreFn); + + const customConfigObject = { + 'buckets': [{ + 'precision': 2, // default is 2 if omitted - means 2.1234 rounded to 2 decimal places = 2.12 + 'min': 0, + 'max': 5, + 'increment': 0.01 // from $0 to $5, 1-cent increments + }, + { + 'precision': 2, + 'min': 5, + 'max': 8, + 'increment': 0.05 // from $5 to $8, round down to the previous 5-cent increment + }, + { + 'precision': 2, + 'min': 8, + 'max': 40, + 'increment': 0.5 // from $8 to $40, round down to the previous 50-cent increment + }] + }; + config.setConfig({ + priceGranularity: customConfigObject, + adpod: { + brandCategoryExclusion: true + } + }); + + let bidResponse1 = { + adId: 'cat_ad1', + auctionId: 'test_category_abc345', + mediaType: 'video', + cpm: 15, + pbAg: '15.00', + pbCg: '15.00', + pbDg: '15.00', + pbHg: '15.00', + pbLg: '5.00', + pbMg: '15.00', + adserverTargeting: { + hb_pb: '15.00', + }, + meta: { + adServerCatId: 'test' + }, + video: { + context: ADPOD, + durationSeconds: 15, + durationBucket: 15 + } + }; + + let bidderRequest = { + adUnitCode: 'adpod_5', + auctionId: 'test_category_abc345', + mediaTypes: { + video: { + context: ADPOD, + playerSize: [300, 300], + adPodDurationSec: 45, + durationRangeSec: [15, 30], + requireExactDuration: false + } + } + }; + + callPrebidCacheHook(callbackFn, auctionInstance, bidResponse1, afterBidAddedSpy, bidderRequest); + + expect(callbackResult).to.be.null; + expect(afterBidAddedSpy.calledOnce).to.equal(true); + expect(storeStub.called).to.equal(false); + expect(auctionBids.length).to.equal(1); + }); }); describe('checkAdUnitSetupHook', function () { @@ -689,6 +813,32 @@ describe('adpod.js', function () { expect(logWarnStub.calledOnce).to.equal(true); }); + it('removes an incorrectly setup adpod adunit - required fields are using invalid values', function() { + let adUnits = [{ + code: 'test1', + mediaTypes: { + video: { + context: ADPOD, + durationRangeSec: [-5, 15, 30, 45], + adPodDurationSec: 300 + } + } + }]; + + checkAdUnitSetupHook(callbackFn, adUnits); + + expect(results).to.deep.equal([]); + expect(logWarnStub.calledOnce).to.equal(true); + + adUnits[0].mediaTypes.video.durationRangeSec = [15, 30, 45]; + adUnits[0].mediaTypes.video.adPodDurationSec = 0; + + checkAdUnitSetupHook(callbackFn, adUnits); + + expect(results).to.deep.equal([]); + expect(logWarnStub.calledTwice).to.equal(true); + }); + it('removes an incorrectly setup adpod adunit - attempting to use multi-format adUnit', function() { let adUnits = [{ code: 'multi_test1', @@ -995,53 +1145,83 @@ describe('adpod.js', function () { it('should sort bids array', function() { let bids = [{ cpm: 10.12345, + adserverTargeting: { + hb_pb: '10.00', + }, video: { durationBucket: 15 } }, { cpm: 15, + adserverTargeting: { + hb_pb: '15.00', + }, video: { durationBucket: 15 } }, { cpm: 15.00, + adserverTargeting: { + hb_pb: '15.00', + }, video: { durationBucket: 30 } }, { cpm: 5.45, + adserverTargeting: { + hb_pb: '5.00', + }, video: { durationBucket: 5 } }, { cpm: 20.1234567, + adserverTargeting: { + hb_pb: '20.10', + }, video: { durationBucket: 60 } }] bids.sort(sortByPricePerSecond); let sortedBids = [{ - cpm: 5.45, + cpm: 15, + adserverTargeting: { + hb_pb: '15.00', + }, video: { - durationBucket: 5 + durationBucket: 15 } }, { - cpm: 15, + cpm: 5.45, + adserverTargeting: { + hb_pb: '5.00', + }, video: { - durationBucket: 15 + durationBucket: 5 } }, { cpm: 10.12345, + adserverTargeting: { + hb_pb: '10.00', + }, video: { durationBucket: 15 } }, { cpm: 15.00, + adserverTargeting: { + hb_pb: '15.00', + }, video: { durationBucket: 30 } }, { cpm: 20.1234567, + adserverTargeting: { + hb_pb: '20.10', + }, video: { durationBucket: 60 } diff --git a/test/spec/modules/adxcgBidAdapter_spec.js b/test/spec/modules/adxcgBidAdapter_spec.js index 0277e0ab964..5bac9523b18 100644 --- a/test/spec/modules/adxcgBidAdapter_spec.js +++ b/test/spec/modules/adxcgBidAdapter_spec.js @@ -133,6 +133,56 @@ describe('AdxcgAdapter', function () { }) }) + describe('userid pubcid should be passed to querystring', function () { + let bid = [{ + 'bidder': 'adxcg', + 'params': { + 'adzoneid': '1' + }, + 'adUnitCode': 'adunit-code', + 'sizes': [[300, 250], [640, 360], [1, 1]], + 'bidId': '84ab500420319d', + 'bidderRequestId': '7101db09af0db2', + 'auctionId': '1d1a030790a475', + }] + + let bidderRequests = {}; + + bid[0].userId = {'pubcid': 'pubcidabcd'}; + + it('should send pubcid if available', function () { + let request = spec.buildRequests(bid, bidderRequests) + let parsedRequestUrl = url.parse(request.url) + let query = parsedRequestUrl.search + expect(query.pubcid).to.equal('pubcidabcd') + }) + }) + + describe('userid tdid should be passed to querystring', function () { + let bid = [{ + 'bidder': 'adxcg', + 'params': { + 'adzoneid': '1' + }, + 'adUnitCode': 'adunit-code', + 'sizes': [[300, 250], [640, 360], [1, 1]], + 'bidId': '84ab500420319d', + 'bidderRequestId': '7101db09af0db2', + 'auctionId': '1d1a030790a475', + }] + + let bidderRequests = {}; + + bid[0].userId = {'tdid': 'tdidabcd'}; + + it('should send pubcid if available', function () { + let request = spec.buildRequests(bid, bidderRequests) + let parsedRequestUrl = url.parse(request.url) + let query = parsedRequestUrl.search + expect(query.tdid).to.equal('tdidabcd'); + }) + }) + describe('response handler', function () { let BIDDER_REQUEST = { 'bidder': 'adxcg', diff --git a/test/spec/modules/adyoulikeBidAdapter_spec.js b/test/spec/modules/adyoulikeBidAdapter_spec.js index 26898d3f57e..7edb9416b03 100644 --- a/test/spec/modules/adyoulikeBidAdapter_spec.js +++ b/test/spec/modules/adyoulikeBidAdapter_spec.js @@ -7,7 +7,6 @@ import { newBidder } from 'src/adapters/bidderFactory'; describe('Adyoulike Adapter', function () { const canonicalUrl = 'http://canonical.url/?t=%26'; const defaultDC = 'hb-api'; - const bidderCode = 'adyoulike'; const bidRequestWithEmptyPlacement = [ { 'bidId': 'bid_id_0', @@ -18,7 +17,6 @@ describe('Adyoulike Adapter', function () { } ]; const bidRequestWithEmptySizes = { - 'bidderCode': 'adyoulike', 'bids': [ { 'bidId': 'bid_id_0', @@ -134,7 +132,7 @@ describe('Adyoulike Adapter', function () { ]; const adapter = newBidder(spec); - let getEndpoint = (dc = defaultDC) => `http://${dc}.omnitagjs.com/hb-api/prebid`; + let getEndpoint = (dc = defaultDC) => `https://${dc}.omnitagjs.com/hb-api/prebid`; describe('inherited functions', function () { it('exists and is a function', function () { @@ -193,7 +191,6 @@ describe('Adyoulike Adapter', function () { it('should add gdpr consent information to the request', function () { let consentString = 'BOJ8RZsOJ8RZsABAB8AAAAAZ+A=='; let bidderRequest = { - 'bidderCode': 'adyoulike', 'auctionId': '1d1a030790a475', 'bidderRequestId': '22edbae2733bf6', 'timeout': 3000, @@ -306,13 +303,11 @@ describe('Adyoulike Adapter', function () { expect(result.length).to.equal(2); - expect(result[0].bidderCode).to.equal(bidderCode); expect(result[0].cpm).to.equal(0.5); expect(result[0].ad).to.equal('placement_0'); expect(result[0].width).to.equal(300); expect(result[0].height).to.equal(300); - expect(result[1].bidderCode).to.equal(bidderCode); expect(result[1].cpm).to.equal(0.6); expect(result[1].ad).to.equal('placement_1'); expect(result[1].width).to.equal(300); diff --git a/test/spec/modules/ajaBidAdapter_spec.js b/test/spec/modules/ajaBidAdapter_spec.js index f2a85ba1ff1..642ac2f0df4 100644 --- a/test/spec/modules/ajaBidAdapter_spec.js +++ b/test/spec/modules/ajaBidAdapter_spec.js @@ -48,10 +48,17 @@ describe('AjaAdapter', function () { } ]; + let bidderRequest = { + refererInfo: { + referer: 'http://hoge.com' + } + }; + it('sends bid request to ENDPOINT via GET', function () { - const requests = spec.buildRequests(bidRequests); + const requests = spec.buildRequests(bidRequests, bidderRequest); expect(requests[0].url).to.equal(ENDPOINT); expect(requests[0].method).to.equal('GET'); + expect(requests[0].data).to.equal('asi=123456&skt=5&prebid_id=30b31c1838de1e&prebid_ver=$prebid.version$&page_url=http%3A%2F%2Fhoge.com&'); }); }); diff --git a/test/spec/modules/aolBidAdapter_spec.js b/test/spec/modules/aolBidAdapter_spec.js index 7817c939b69..8386c2c2462 100644 --- a/test/spec/modules/aolBidAdapter_spec.js +++ b/test/spec/modules/aolBidAdapter_spec.js @@ -76,8 +76,8 @@ let getPixels = () => { }; describe('AolAdapter', function () { - const MARKETPLACE_URL = '//adserver-us.adtech.advertising.com/pubapi/3.0/'; - const NEXAGE_URL = '//hb.nexage.com/bidRequest?'; + const MARKETPLACE_URL = 'https://adserver-us.adtech.advertising.com/pubapi/3.0/'; + const NEXAGE_URL = 'https://c2shb.ssp.yahoo.com/bidRequest?'; const ONE_DISPLAY_TTL = 60; const ONE_MOBILE_TTL = 3600; @@ -152,7 +152,7 @@ describe('AolAdapter', function () { it('should return request for Marketplace endpoint', function () { let bidRequest = getDefaultBidRequest(); let [request] = spec.buildRequests(bidRequest.bids); - expect(request.url).to.contain(MARKETPLACE_URL); + expect(request.url.indexOf(MARKETPLACE_URL)).to.equal(0); }); it('should return request for Marketplace via onedisplay bidder code', function () { @@ -164,7 +164,7 @@ describe('AolAdapter', function () { }); let [request] = spec.buildRequests(bidRequest.bids); - expect(request.url).to.contain(MARKETPLACE_URL); + expect(request.url.indexOf(MARKETPLACE_URL)).to.equal(0); }); it('should return Marketplace request via onedisplay bidder code when' + @@ -178,7 +178,7 @@ describe('AolAdapter', function () { }); let [request] = spec.buildRequests(bidRequest.bids); - expect(request.url).to.contain(MARKETPLACE_URL); + expect(request.url.indexOf(MARKETPLACE_URL)).to.equal(0); }); it('should return Marketplace request via onedisplay bidder code when' + @@ -192,7 +192,7 @@ describe('AolAdapter', function () { }); let [request] = spec.buildRequests(bidRequest.bids); - expect(request.url).to.contain(MARKETPLACE_URL); + expect(request.url.indexOf(MARKETPLACE_URL)).to.equal(0); }); it('should not resolve endpoint for onedisplay bidder code ' + @@ -218,10 +218,37 @@ describe('AolAdapter', function () { } }); let [request] = spec.buildRequests(bidRequest.bids); - expect(request.url).to.contain('adserver-eu.adtech.advertising.com/pubapi/3.0/'); + expect(request.url.indexOf('https://adserver-eu.adtech.advertising.com/pubapi/3.0/')) + .to.equal(0); }); - it('should return Marketplace URL for eu region when server option is present', function () { + it('should return insecure MP URL if insecure server option is present', function () { + let bidRequest = createCustomBidRequest({ + params: { + placement: 1234567, + network: '9599.1', + server: 'http://adserver-eu.adtech.advertising.com' + } + }); + let [request] = spec.buildRequests(bidRequest.bids); + expect(request.url.indexOf('http://adserver-eu.adtech.advertising.com/pubapi/3.0/')) + .to.equal(0); + }); + + it('should return a secure MP URL if relative proto server option is present', function () { + let bidRequest = createCustomBidRequest({ + params: { + placement: 1234567, + network: '9599.1', + server: '//adserver-eu.adtech.advertising.com' + } + }); + let [request] = spec.buildRequests(bidRequest.bids); + expect(request.url.indexOf('https://adserver-eu.adtech.advertising.com/pubapi/3.0/')) + .to.equal(0); + }); + + it('should return a secure MP URL when server option without protocol is present', function () { let bidRequest = createCustomBidRequest({ params: { placement: 1234567, @@ -230,7 +257,8 @@ describe('AolAdapter', function () { } }); let [request] = spec.buildRequests(bidRequest.bids); - expect(request.url).to.contain('adserver-eu.adtech.advertising.com/pubapi/3.0/'); + expect(request.url.indexOf('https://adserver-eu.adtech.advertising.com/pubapi/3.0/')) + .to.equal(0); }); it('should return default Marketplace URL in case of unknown region config option', function () { @@ -242,7 +270,7 @@ describe('AolAdapter', function () { } }); let [request] = spec.buildRequests(bidRequest.bids); - expect(request.url).to.contain(MARKETPLACE_URL); + expect(request.url.indexOf(MARKETPLACE_URL)).to.equal(0); }); it('should return url with pubapi bid option', function () { @@ -358,13 +386,13 @@ describe('AolAdapter', function () { it('should return One Mobile url with different host when host option is present', function () { let bidParams = Object.assign({ - host: 'qa-hb.nexage.com' + host: 'http://qa-hb.nexage.com' }, getNexageGetBidParams()); let bidRequest = createCustomBidRequest({ params: bidParams }); let [request] = spec.buildRequests(bidRequest.bids); - expect(request.url).to.contain('qa-hb.nexage.com/bidRequest?'); + expect(request.url).to.contain('http://qa-hb.nexage.com/bidRequest?'); }); it('should return One Mobile url when One Mobile and Marketplace params are present', function () { @@ -431,7 +459,7 @@ describe('AolAdapter', function () { } }); let [request] = spec.buildRequests(bidRequest.bids); - expect(request.url).to.contain('hb.nexage.com/bidRequest?dcn=54321123&pos=footer-2324&cmd=bid' + + expect(request.url).to.equal('https://c2shb.ssp.yahoo.com/bidRequest?dcn=54321123&pos=footer-2324&cmd=bid' + '¶m1=val1¶m2=val2¶m3=val3¶m4=val4'); }); @@ -455,7 +483,7 @@ describe('AolAdapter', function () { }); it('should not return request object for One Mobile POST endpoint' + - 'if required parameterers are missed', () => { + 'if required parameters are missed', () => { let bidRequest = createCustomBidRequest({ params: { imp: [] diff --git a/test/spec/modules/appierAnalyticsAdapter_spec.js b/test/spec/modules/appierAnalyticsAdapter_spec.js new file mode 100644 index 00000000000..07b9796a4cb --- /dev/null +++ b/test/spec/modules/appierAnalyticsAdapter_spec.js @@ -0,0 +1,709 @@ +import { + appierAnalyticsAdapter, getCpmInUsd, parseBidderCode, parseAdUnitCode, + ANALYTICS_VERSION, BIDDER_STATUS +} from 'modules/appierAnalyticsAdapter'; +import {expect} from 'chai'; +const events = require('src/events'); +const constants = require('src/constants.json'); + +const affiliateId = 'WhctHaViHtI'; +const configId = 'd9cc9a9be9b240eda17cf1c9a8a4b29c'; +const serverUrl = 'https://analytics.server.url/v1'; +const autoPick = 'none'; +const predictionId = '2a91ca5de54a4a2e89950af439f7a27f'; +const auctionId = 'b0b39610-b941-4659-a87c-de9f62d3e13e'; + +describe('Appier Prebid AnalyticsAdapter Testing', function () { + describe('event tracking and message cache manager', function () { + let xhr; + + beforeEach(function () { + const configOptions = { + affiliateId: affiliateId, + configId: configId, + server: serverUrl, + autoPick: autoPick, + predictionId: predictionId, + sampling: 0, + adSampling: 1, + }; + + appierAnalyticsAdapter.enableAnalytics({ + provider: 'appierAnalytics', + options: configOptions + }); + xhr = sinon.useFakeXMLHttpRequest(); + }); + + afterEach(function () { + appierAnalyticsAdapter.disableAnalytics(); + xhr.restore(); + }); + + describe('#getCpmInUsd()', function() { + it('should get bid cpm as currency is USD', function() { + const receivedBids = [ + { + auctionId: auctionId, + adUnitCode: 'adunit_1', + bidder: 'appier', + bidderCode: 'APPIER', + requestId: 'a1b2c3d4', + timeToRespond: 72, + cpm: 0.1, + currency: 'USD', + originalCpm: 0.1, + originalCurrency: 'USD', + ad: 'fake ad1' + }, + ] + const result = getCpmInUsd(receivedBids[0]); + expect(result).to.equal(0.1); + }); + }); + + describe('#parseBidderCode()', function() { + it('should get lower case bidder code from bidderCode field value', function() { + const receivedBids = [ + { + auctionId: auctionId, + adUnitCode: 'adunit_1', + bidder: 'appier', + bidderCode: 'APPIER', + requestId: 'a1b2c3d4', + timeToRespond: 72, + cpm: 0.1, + currency: 'USD', + originalCpm: 0.1, + originalCurrency: 'USD', + ad: 'fake ad1' + }, + ]; + const result = parseBidderCode(receivedBids[0]); + expect(result).to.equal('appier'); + }); + it('should get lower case bidder code from bidder field value as bidderCode field is missing', function() { + const receivedBids = [ + { + auctionId: auctionId, + adUnitCode: 'adunit_1', + bidder: 'APPIER', + bidderCode: '', + requestId: 'a1b2c3d4', + timeToRespond: 72, + cpm: 0.1, + currency: 'USD', + originalCpm: 0.1, + originalCurrency: 'USD', + ad: 'fake ad1' + }, + ]; + const result = parseBidderCode(receivedBids[0]); + expect(result).to.equal('appier'); + }); + }); + + describe('#parseAdUnitCode()', function() { + it('should get lower case adUnit code from adUnitCode field value', function() { + const receivedBids = [ + { + auctionId: auctionId, + adUnitCode: 'ADUNIT', + bidder: 'appier', + bidderCode: 'APPIER', + requestId: 'a1b2c3d4', + timeToRespond: 72, + cpm: 0.1, + currency: 'USD', + originalCpm: 0.1, + originalCurrency: 'USD', + ad: 'fake ad1' + }, + ]; + const result = parseAdUnitCode(receivedBids[0]); + expect(result).to.equal('adunit'); + }); + }); + + describe('#getCachedAuction()', function() { + const existing = {timeoutBids: [{}]}; + appierAnalyticsAdapter.cachedAuctions['test_auction_id'] = existing; + + it('should get the existing cached object if it exists', function() { + const result = appierAnalyticsAdapter.getCachedAuction('test_auction_id'); + + expect(result).to.equal(existing); + }); + + it('should create a new object and store it in the cache on cache miss', function() { + const result = appierAnalyticsAdapter.getCachedAuction('no_such_id'); + + expect(result).to.deep.include({ + timeoutBids: [], + }); + }); + }); + + describe('when formatting JSON payload sent to backend', function() { + const receivedBids = [ + { + auctionId: auctionId, + adUnitCode: 'adunit_1', + bidder: 'appier', + bidderCode: 'appier', + requestId: 'a1b2c3d4', + timeToRespond: 72, + cpm: 0.1, + currency: 'USD', + originalCpm: 0.1, + originalCurrency: 'USD', + ad: 'fake ad1' + }, + { + auctionId: auctionId, + adUnitCode: 'adunit_1', + bidder: 'reippa', + bidderCode: 'reippa', + requestId: 'b2c3d4e5', + timeToRespond: 100, + cpm: 0.08, + currency: 'USD', + originalCpm: 0.08, + originalCurrency: 'USD', + ad: 'fake ad2' + }, + { + auctionId: auctionId, + adUnitCode: 'adunit_2', + bidder: 'appier', + bidderCode: 'appier', + requestId: 'c3d4e5f6', + timeToRespond: 120, + cpm: 0.09, + currency: 'USD', + originalCpm: 0.09, + originalCurrency: 'USD', + ad: 'fake ad3' + }, + ]; + const highestCpmBids = [ + { + auctionId: auctionId, + adUnitCode: 'adunit_1', + bidder: 'appier', + bidderCode: 'appier', + // No requestId + timeToRespond: 72, + cpm: 0.1, + currency: 'USD', + originalCpm: 0.1, + originalCurrency: 'USD', + ad: 'fake ad1' + } + ]; + const noBids = [ + { + auctionId: auctionId, + adUnitCode: 'adunit_2', + bidder: 'appier', + bidderCode: 'appier', + bidId: 'a1b2c3d4', + } + ]; + const timeoutBids = [ + { + auctionId: auctionId, + adUnitCode: 'adunit_2', + bidder: 'reippa', + bidderCode: 'reippa', + bidId: '00123d4c', + } + ]; + const withoutOriginalCpmBids = [ + { + auctionId: auctionId, + adUnitCode: 'adunit_2', + bidder: 'appier', + bidderCode: 'appier', + requestId: 'c3d4e5f6', + timeToRespond: 120, + cpm: 0.29, + currency: 'USD', + originalCpm: '', + originalCurrency: 'USD', + ad: 'fake ad3' + }, + ]; + const withoutOriginalCurrencyBids = [ + { + auctionId: auctionId, + adUnitCode: 'adunit_2', + bidder: 'appier', + bidderCode: 'appier', + requestId: 'c3d4e5f6', + timeToRespond: 120, + cpm: 0.09, + currency: 'USD', + originalCpm: 0.09, + originalCurrency: '', + ad: 'fake ad3' + }, + ]; + function assertHavingRequiredMessageFields(message) { + expect(message).to.include({ + version: ANALYTICS_VERSION, + auctionId: auctionId, + affiliateId: affiliateId, + configId: configId, + // referrer: window.location.href, + sampling: 0, + adSampling: 1, + prebid: '$prebid.version$', + // autoPick: 'manual', + }); + } + + describe('#createCommonMessage', function() { + it('should correctly serialize some common fields', function() { + const message = appierAnalyticsAdapter.createCommonMessage(auctionId); + + assertHavingRequiredMessageFields(message); + }); + }); + + describe('#serializeBidResponse', function() { + it('should handle BID properly and serialize bid price related fields', function() { + const result = appierAnalyticsAdapter.serializeBidResponse(receivedBids[0], BIDDER_STATUS.BID); + + expect(result).to.include({ + prebidWon: false, + isTimeout: false, + status: BIDDER_STATUS.BID, + time: 72, + cpm: 0.1, + currency: 'USD', + originalCpm: 0.1, + originalCurrency: 'USD', + cpmUsd: 0.1, + }); + }); + + it('should handle NO_BID properly and set status to noBid', function() { + const result = appierAnalyticsAdapter.serializeBidResponse(noBids[0], BIDDER_STATUS.NO_BID); + + expect(result).to.include({ + prebidWon: false, + isTimeout: false, + status: BIDDER_STATUS.NO_BID, + }); + }); + + it('should handle BID_WON properly and serialize bid price related fields', function() { + const result = appierAnalyticsAdapter.serializeBidResponse(receivedBids[0], BIDDER_STATUS.BID_WON); + + expect(result).to.include({ + prebidWon: true, + isTimeout: false, + status: BIDDER_STATUS.BID_WON, + time: 72, + cpm: 0.1, + currency: 'USD', + originalCpm: 0.1, + originalCurrency: 'USD', + cpmUsd: 0.1, + }); + }); + + it('should handle TIMEOUT properly and set status to timeout and isTimeout to true', function() { + const result = appierAnalyticsAdapter.serializeBidResponse(noBids[0], BIDDER_STATUS.TIMEOUT); + + expect(result).to.include({ + prebidWon: false, + isTimeout: true, + status: BIDDER_STATUS.TIMEOUT, + }); + }); + + it('should handle BID_WON properly and fill originalCpm field with cpm in missing originalCpm case', function() { + const result = appierAnalyticsAdapter.serializeBidResponse(withoutOriginalCpmBids[0], BIDDER_STATUS.BID_WON); + + expect(result).to.include({ + prebidWon: true, + isTimeout: false, + status: BIDDER_STATUS.BID_WON, + time: 120, + cpm: 0.29, + currency: 'USD', + originalCpm: 0.29, + originalCurrency: 'USD', + cpmUsd: 0.29, + }); + }); + + it('should handle BID_WON properly and fill originalCurrency field with currency in missing originalCurrency case', function() { + const result = appierAnalyticsAdapter.serializeBidResponse(withoutOriginalCurrencyBids[0], BIDDER_STATUS.BID_WON); + expect(result).to.include({ + prebidWon: true, + isTimeout: false, + status: BIDDER_STATUS.BID_WON, + time: 120, + cpm: 0.09, + currency: 'USD', + originalCpm: 0.09, + originalCurrency: 'USD', + cpmUsd: 0.09, + }); + }); + }); + + describe('#addBidResponseToMessage()', function() { + it('should add a bid response in the output message, grouped by adunit_id and bidder', function() { + const message = { + adUnits: {} + }; + appierAnalyticsAdapter.addBidResponseToMessage(message, noBids[0], BIDDER_STATUS.NO_BID); + + expect(message.adUnits).to.deep.include({ + 'adunit_2': { + 'appier': { + prebidWon: false, + isTimeout: false, + status: BIDDER_STATUS.NO_BID, + } + } + }); + }); + }); + + describe('#createBidMessage()', function() { + it('should format auction message sent to the backend', function() { + const args = { + auctionId: auctionId, + timestamp: 1234567890, + timeout: 3000, + auctionEnd: 1234567990, + adUnitCodes: ['adunit_1', 'adunit_2'], + bidsReceived: receivedBids, + noBids: noBids + }; + + const result = appierAnalyticsAdapter.createBidMessage(args, highestCpmBids, timeoutBids); + + assertHavingRequiredMessageFields(result); + expect(result).to.deep.include({ + auctionElapsed: 100, + timeout: 3000, + adUnits: { + 'adunit_1': { + 'appier': { + prebidWon: true, + isTimeout: false, + status: BIDDER_STATUS.BID, + time: 72, + cpm: 0.1, + currency: 'USD', + originalCpm: 0.1, + originalCurrency: 'USD', + cpmUsd: 0.1, + }, + 'reippa': { + prebidWon: false, + isTimeout: false, + status: BIDDER_STATUS.BID, + time: 100, + cpm: 0.08, + currency: 'USD', + originalCpm: 0.08, + originalCurrency: 'USD', + cpmUsd: 0.08, + } + }, + 'adunit_2': { + // this bid result exists in both bid and noBid arrays and should be treated as bid + 'appier': { + prebidWon: false, + isTimeout: false, + time: 120, + cpm: 0.09, + currency: 'USD', + originalCpm: 0.09, + originalCurrency: 'USD', + cpmUsd: 0.09, + status: BIDDER_STATUS.BID, + }, + 'reippa': { + prebidWon: false, + isTimeout: true, + status: BIDDER_STATUS.TIMEOUT, + } + } + } + }); + }); + }); + + describe('#createImpressionMessage()', function() { + it('should format message sent to the backend with the bid result', function() { + const bid = receivedBids[0]; + const result = appierAnalyticsAdapter.createImpressionMessage(bid); + + assertHavingRequiredMessageFields(result); + expect(result.adUnits).to.deep.include({ + 'adunit_1': { + 'appier': { + prebidWon: true, + isTimeout: false, + status: BIDDER_STATUS.BID_WON, + time: 72, + cpm: 0.1, + currency: 'USD', + originalCpm: 0.1, + originalCurrency: 'USD', + cpmUsd: 0.1, + } + } + }); + }); + }); + + describe('#createCreativeMessage()', function() { + it('should generate message sent to the backend with ad html grouped by adunit and bidder', function() { + const result = appierAnalyticsAdapter.createCreativeMessage(auctionId, receivedBids); + + assertHavingRequiredMessageFields(result); + expect(result.adUnits).to.deep.include({ + 'adunit_1': { + 'appier': { + ad: 'fake ad1' + }, + 'reippa': { + ad: 'fake ad2' + }, + }, + 'adunit_2': { + 'appier': { + ad: 'fake ad3' + } + } + }); + }); + }); + describe('#handleBidTimeout()', function() { + it('should cached the timeout bid as BID_TIMEOUT event was triggered', function() { + appierAnalyticsAdapter.cachedAuctions['test_timeout_auction_id'] = { 'timeoutBids': [] }; + const args = [{ + auctionId: 'test_timeout_auction_id', + timestamp: 1234567890, + timeout: 3000, + auctionEnd: 1234567990, + bidsReceived: receivedBids, + noBids: noBids + }]; + + appierAnalyticsAdapter.handleBidTimeout(args); + const result = appierAnalyticsAdapter.getCachedAuction('test_timeout_auction_id'); + expect(result).to.deep.include({ + timeoutBids: [{ + auctionId: 'test_timeout_auction_id', + timestamp: 1234567890, + timeout: 3000, + auctionEnd: 1234567990, + bidsReceived: receivedBids, + noBids: noBids + }] + }); + }); + }); + describe('#handleBidWon()', function() { + it('should call createImpressionMessage once as BID_WON event was triggered', function() { + sinon.spy(appierAnalyticsAdapter, 'createImpressionMessage'); + const receivedBids = [ + { + auctionId: auctionId, + adUnitCode: 'adunit_1', + bidder: 'appier', + bidderCode: 'appier', + requestId: 'a1b2c3d4', + timeToRespond: 72, + cpm: 0.1, + currency: 'USD', + originalCpm: 0.1, + originalCurrency: 'USD', + ad: 'fake ad1' + }, + ] + + appierAnalyticsAdapter.handleBidWon(receivedBids[0]); + sinon.assert.callCount(appierAnalyticsAdapter.createImpressionMessage, 1); + appierAnalyticsAdapter.createImpressionMessage.restore(); + }); + }); + }); + }); + + describe('Appier Analytics Adapter track handler ', function () { + const configOptions = { + affiliateId: affiliateId, + configId: configId, + server: serverUrl, + autoPick: autoPick, + sampling: 1, + adSampling: 1, + }; + + beforeEach(function () { + sinon.stub(events, 'getEvents').returns([]); + appierAnalyticsAdapter.enableAnalytics({ + provider: 'appierAnalytics', + options: configOptions + }); + }); + + afterEach(function () { + appierAnalyticsAdapter.disableAnalytics(); + events.getEvents.restore(); + }); + + it('should call handleBidWon as BID_WON trigger event', function() { + sinon.spy(appierAnalyticsAdapter, 'handleBidWon'); + events.emit(constants.EVENTS.BID_WON, {}); + sinon.assert.callCount(appierAnalyticsAdapter.handleBidWon, 1); + appierAnalyticsAdapter.handleBidWon.restore(); + }); + + it('should call handleBidTimeout as BID_TIMEOUT trigger event', function() { + sinon.spy(appierAnalyticsAdapter, 'handleBidTimeout'); + events.emit(constants.EVENTS.BID_TIMEOUT, {}); + sinon.assert.callCount(appierAnalyticsAdapter.handleBidTimeout, 1); + appierAnalyticsAdapter.handleBidTimeout.restore(); + }); + + it('should call handleAuctionEnd as AUCTION_END trigger event', function() { + sinon.spy(appierAnalyticsAdapter, 'handleAuctionEnd'); + events.emit(constants.EVENTS.AUCTION_END, {}); + sinon.assert.callCount(appierAnalyticsAdapter.handleAuctionEnd, 1); + appierAnalyticsAdapter.handleAuctionEnd.restore(); + }); + + it('should call createCreativeMessage as AUCTION_END trigger event in adSampled is true', function() { + const configOptions = { + options: { + affiliateId: affiliateId, + configId: configId, + server: serverUrl, + autoPick: autoPick, + sampling: 1, + adSampling: 1, + adSampled: true, + } + }; + const args = { + auctionId: 'test_timeout_auction_id', + timestamp: 1234567890, + timeout: 3000, + auctionEnd: 1234567990, + }; + appierAnalyticsAdapter.initConfig(configOptions); + sinon.stub(appierAnalyticsAdapter, 'sendEventMessage').returns({}); + sinon.stub(appierAnalyticsAdapter, 'createBidMessage').returns({}); + sinon.spy(appierAnalyticsAdapter, 'createCreativeMessage'); + events.emit(constants.EVENTS.AUCTION_END, args); + sinon.assert.callCount(appierAnalyticsAdapter.createCreativeMessage, 1); + appierAnalyticsAdapter.sendEventMessage.restore(); + appierAnalyticsAdapter.createBidMessage.restore(); + appierAnalyticsAdapter.createCreativeMessage.restore(); + }); + }); + + describe('enableAnalytics and config parser', function () { + const configOptions = { + affiliateId: affiliateId, + configId: configId, + server: serverUrl, + autoPick: autoPick, + sampling: 0, + adSampling: 1, + }; + + beforeEach(function () { + appierAnalyticsAdapter.enableAnalytics({ + provider: 'appierAnalytics', + options: configOptions + }); + }); + + afterEach(function () { + appierAnalyticsAdapter.disableAnalytics(); + }); + + it('should parse config correctly with optional values', function () { + expect(appierAnalyticsAdapter.getAnalyticsOptions().options).to.deep.equal(configOptions); + expect(appierAnalyticsAdapter.getAnalyticsOptions().affiliateId).to.equal(configOptions.affiliateId); + expect(appierAnalyticsAdapter.getAnalyticsOptions().configId).to.equal(configOptions.configId); + expect(appierAnalyticsAdapter.getAnalyticsOptions().server).to.equal(configOptions.server); + expect(appierAnalyticsAdapter.getAnalyticsOptions().autoPick).to.equal(configOptions.autoPick); + expect(appierAnalyticsAdapter.getAnalyticsOptions().sampled).to.equal(false); + expect(appierAnalyticsAdapter.getAnalyticsOptions().adSampled).to.equal(true); + }); + + it('should not enable Analytics when affiliateId is missing', function () { + const configOptions = { + options: { + configId: configId + } + }; + const validConfig = appierAnalyticsAdapter.initConfig(configOptions); + expect(validConfig).to.equal(false); + }); + + it('should use DEFAULT_SERVER when server is missing', function () { + const configOptions = { + options: { + configId: configId, + affiliateId: affiliateId + } + }; + appierAnalyticsAdapter.initConfig(configOptions); + expect(appierAnalyticsAdapter.getAnalyticsOptions().server).to.equal('https://prebid-analytics.c.appier.net/v1'); + }); + + it('should use null when autoPick is missing', function () { + const configOptions = { + options: { + configId: configId, + affiliateId: affiliateId + } + }; + appierAnalyticsAdapter.initConfig(configOptions); + expect(appierAnalyticsAdapter.getAnalyticsOptions().autoPick).to.equal(null); + }); + + it('should not enable Analytics when configId is missing', function () { + const configOptions = { + options: { + affiliateId: affiliateId + } + }; + const validConfig = appierAnalyticsAdapter.initConfig(configOptions); + expect(validConfig).to.equal(false); + }); + + it('should fall back to default value when sampling factor is not number', function () { + const configOptions = { + options: { + affiliateId: affiliateId, + configId: configId, + sampling: 'string', + adSampling: 'string' + } + }; + appierAnalyticsAdapter.enableAnalytics({ + provider: 'appierAnalytics', + options: configOptions + }); + + expect(appierAnalyticsAdapter.getAnalyticsOptions().sampled).to.equal(false); + expect(appierAnalyticsAdapter.getAnalyticsOptions().adSampled).to.equal(true); + }); + }); +}); diff --git a/test/spec/modules/appnexusBidAdapter_spec.js b/test/spec/modules/appnexusBidAdapter_spec.js index 71f7e74fe47..ef3f3eef6b3 100644 --- a/test/spec/modules/appnexusBidAdapter_spec.js +++ b/test/spec/modules/appnexusBidAdapter_spec.js @@ -2,6 +2,7 @@ import { expect } from 'chai'; import { spec } from 'modules/appnexusBidAdapter'; import { newBidder } from 'src/adapters/bidderFactory'; import * as bidderFactory from 'src/adapters/bidderFactory'; +import { auctionManager } from 'src/auctionManager'; import { deepClone } from 'src/utils'; import { config } from 'src/config'; @@ -55,6 +56,7 @@ describe('AppNexusAdapter', function () { }); describe('buildRequests', function () { + let getAdUnitsStub; let bidRequests = [ { 'bidder': 'appnexus', @@ -66,9 +68,20 @@ describe('AppNexusAdapter', function () { 'bidId': '30b31c1838de1e', 'bidderRequestId': '22edbae2733bf6', 'auctionId': '1d1a030790a475', + 'transactionId': '04f2659e-c005-4eb1-a57c-fa93145e3843' } ]; + beforeEach(function() { + getAdUnitsStub = sinon.stub(auctionManager, 'getAdUnits').callsFake(function() { + return []; + }); + }); + + afterEach(function() { + getAdUnitsStub.restore(); + }); + it('should parse out private sizes', function () { let bidRequest = Object.assign({}, bidRequests[0], @@ -98,7 +111,27 @@ describe('AppNexusAdapter', function () { }); it('should populate the ad_types array on all requests', function () { + let adUnits = [{ + code: 'adunit-code', + mediaTypes: { + banner: { + sizes: [[300, 250], [300, 600]] + } + }, + bids: [{ + bidder: 'appnexus', + params: { + placementId: '10433394' + } + }], + transactionId: '04f2659e-c005-4eb1-a57c-fa93145e3843' + }]; + ['banner', 'video', 'native'].forEach(type => { + getAdUnitsStub.callsFake(function(...args) { + return adUnits; + }); + const bidRequest = Object.assign({}, bidRequests[0]); bidRequest.mediaTypes = {}; bidRequest.mediaTypes[type] = {}; @@ -107,9 +140,21 @@ describe('AppNexusAdapter', function () { const payload = JSON.parse(request.data); expect(payload.tags[0].ad_types).to.deep.equal([type]); + + if (type === 'banner') { + delete adUnits[0].mediaTypes; + } }); }); + it('should not populate the ad_types array when adUnit.mediaTypes is undefined', function() { + const bidRequest = Object.assign({}, bidRequests[0]); + const request = spec.buildRequests([bidRequest]); + const payload = JSON.parse(request.data); + + expect(payload.tags[0].ad_types).to.not.exist; + }); + it('should populate the ad_types array on outstream requests', function () { const bidRequest = Object.assign({}, bidRequests[0]); bidRequest.mediaTypes = {}; @@ -150,6 +195,48 @@ describe('AppNexusAdapter', function () { }); }); + it('should add video property when adUnit includes a renderer', function () { + const videoData = { + mediaTypes: { + video: { + context: 'outstream', + mimes: ['video/mp4'] + } + }, + params: { + placementId: '10433394', + video: { + skippable: true, + playback_method: ['auto_play_sound_off'] + } + } + }; + + let bidRequest1 = deepClone(bidRequests[0]); + bidRequest1 = Object.assign({}, bidRequest1, videoData, { + renderer: { + url: 'http://test.renderer.url', + render: function () {} + } + }); + + let bidRequest2 = deepClone(bidRequests[0]); + bidRequest2.adUnitCode = 'adUnit_code_2'; + bidRequest2 = Object.assign({}, bidRequest2, videoData); + + const request = spec.buildRequests([bidRequest1, bidRequest2]); + const payload = JSON.parse(request.data); + expect(payload.tags[0].video).to.deep.equal({ + skippable: true, + playback_method: ['auto_play_sound_off'], + custom_renderer_present: true + }); + expect(payload.tags[1].video).to.deep.equal({ + skippable: true, + playback_method: ['auto_play_sound_off'] + }); + }); + it('should attach valid user params to the tag', function () { let bidRequest = Object.assign({}, bidRequests[0], @@ -157,7 +244,7 @@ describe('AppNexusAdapter', function () { params: { placementId: '10433394', user: { - external_uid: '123', + externalUid: '123', foobar: 'invalid' } } @@ -169,7 +256,7 @@ describe('AppNexusAdapter', function () { expect(payload.user).to.exist; expect(payload.user).to.deep.equal({ - external_uid: '123', + externalUid: '123', }); }); @@ -354,7 +441,8 @@ describe('AppNexusAdapter', function () { title: {required: true}, body: {required: true}, body2: {required: true}, - image: {required: true, sizes: [{ width: 100, height: 100 }]}, + image: {required: true, sizes: [100, 100]}, + icon: {required: true}, cta: {required: false}, rating: {required: true}, sponsoredBy: {required: true}, @@ -378,6 +466,7 @@ describe('AppNexusAdapter', function () { description: {required: true}, desc2: {required: true}, main_image: {required: true, sizes: [{ width: 100, height: 100 }]}, + icon: {required: true}, ctatext: {required: false}, rating: {required: true}, sponsored_by: {required: true}, @@ -388,58 +477,8 @@ describe('AppNexusAdapter', function () { likes: {required: true}, phone: {required: true}, price: {required: true}, - saleprice: {required: true} - }); - }); - - it('sets minimum native asset params when not provided on adunit', function () { - let bidRequest = Object.assign({}, - bidRequests[0], - { - mediaType: 'native', - nativeParams: { - image: {required: true}, - } - } - ); - - const request = spec.buildRequests([bidRequest]); - const payload = JSON.parse(request.data); - - expect(payload.tags[0].native.layouts[0]).to.deep.equal({ - main_image: {required: true, sizes: [{}]}, - }); - }); - - it('does not overwrite native ad unit params with mimimum params', function () { - let bidRequest = Object.assign({}, - bidRequests[0], - { - mediaType: 'native', - nativeParams: { - image: { - aspect_ratios: [{ - min_width: 100, - ratio_width: 2, - ratio_height: 3, - }] - } - } - } - ); - - const request = spec.buildRequests([bidRequest]); - const payload = JSON.parse(request.data); - - expect(payload.tags[0].native.layouts[0]).to.deep.equal({ - main_image: { - required: true, - aspect_ratios: [{ - min_width: 100, - ratio_width: 2, - ratio_height: 3, - }] - }, + saleprice: {required: true}, + privacy_supported: true }); }); @@ -620,6 +659,22 @@ describe('AppNexusAdapter', function () { rd_stk: bidderRequest.refererInfo.stack.map((url) => encodeURIComponent(url)).join(',') }); }); + + it('should populate tpids array when userId is available', function () { + const bidRequest = Object.assign({}, bidRequests[0], { + userId: { + criteortus: { + appnexus: { + userid: 'sample-userid' + } + } + } + }); + + const request = spec.buildRequests([bidRequest]); + const payload = JSON.parse(request.data); + expect(payload.tpuids).to.deep.equal([{provider: 'criteo', user_id: 'sample-userid'}]); + }); }) describe('interpretResponse', function () { @@ -655,6 +710,9 @@ describe('AppNexusAdapter', function () { 'cpm_publisher_currency': 0.5, 'publisher_currency_code': '$', 'client_initiated_ad_counting': true, + 'viewability': { + 'config': '' + }, 'rtb': { 'banner': { 'content': '', @@ -722,7 +780,7 @@ describe('AppNexusAdapter', function () { expect(result.length).to.equal(0); }); - it('handles non-banner media responses', function () { + it('handles outstream video responses', function () { let response = { 'tags': [{ 'uuid': '84ab500420319d', @@ -732,16 +790,57 @@ describe('AppNexusAdapter', function () { 'notify_url': 'imptracker.com', 'rtb': { 'video': { - 'content': '' + 'content': '' } + }, + 'javascriptTrackers': '' + }] + }] + }; + let bidderRequest = { + bids: [{ + bidId: '84ab500420319d', + adUnitCode: 'code', + mediaTypes: { + video: { + context: 'outstream' } + } + }] + } + + let result = spec.interpretResponse({ body: response }, {bidderRequest}); + expect(result[0]).to.have.property('vastXml'); + expect(result[0]).to.have.property('vastImpUrl'); + expect(result[0]).to.have.property('mediaType', 'video'); + }); + + it('handles instream video responses', function () { + let response = { + 'tags': [{ + 'uuid': '84ab500420319d', + 'ads': [{ + 'ad_type': 'video', + 'cpm': 0.500000, + 'notify_url': 'imptracker.com', + 'rtb': { + 'video': { + 'asset_url': 'http://sample.vastURL.com/here/vid' + } + }, + 'javascriptTrackers': '' }] }] }; let bidderRequest = { bids: [{ bidId: '84ab500420319d', - adUnitCode: 'code' + adUnitCode: 'code', + mediaTypes: { + video: { + context: 'instream' + } + } }] } @@ -762,9 +861,12 @@ describe('AppNexusAdapter', function () { 'notify_url': 'imptracker.com', 'rtb': { 'video': { - 'content': '', + 'asset_url': 'http://sample.vastURL.com/here/adpod', 'duration_ms': 30000, } + }, + 'viewability': { + 'config': '' } }] }] @@ -784,6 +886,7 @@ describe('AppNexusAdapter', function () { bfStub.returns('1'); let result = spec.interpretResponse({ body: response }, {bidderRequest}); + expect(result[0]).to.have.property('vastUrl'); expect(result[0].video.context).to.equal('adpod'); expect(result[0].video.durationSeconds).to.equal(30); }); @@ -821,7 +924,8 @@ describe('AppNexusAdapter', function () { 'saleprice': 'FREE', 'phone': '1234567890', 'address': '28 W 23rd St, New York, NY 10010', - 'privacy_link': 'http://appnexus.com/?url=privacy_url' + 'privacy_link': 'http://appnexus.com/?url=privacy_url', + 'javascriptTrackers': '' }; let bidderRequest = { bids: [{ @@ -849,6 +953,11 @@ describe('AppNexusAdapter', function () { options: { adText: 'configured' } + }, + mediaTypes: { + video: { + context: 'outstream' + } } }] }; @@ -873,5 +982,19 @@ describe('AppNexusAdapter', function () { let result = spec.interpretResponse({ body: responseWithDeal }, {bidderRequest}); expect(Object.keys(result[0].appnexus)).to.include.members(['buyerMemberId', 'dealPriority', 'dealCode']); }); + + it('should add advertiser id', function() { + let responseAdvertiserId = deepClone(response); + responseAdvertiserId.tags[0].ads[0].advertiser_id = '123'; + + let bidderRequest = { + bids: [{ + bidId: '3db3773286ee59', + adUnitCode: 'code' + }] + } + let result = spec.interpretResponse({ body: responseAdvertiserId }, {bidderRequest}); + expect(Object.keys(result[0].meta)).to.include.members(['advertiserId']); + }) }); }); diff --git a/test/spec/modules/beachfrontBidAdapter_spec.js b/test/spec/modules/beachfrontBidAdapter_spec.js index 652dae4a74a..4598a4e00c7 100644 --- a/test/spec/modules/beachfrontBidAdapter_spec.js +++ b/test/spec/modules/beachfrontBidAdapter_spec.js @@ -1,4 +1,5 @@ import { expect } from 'chai'; +import sinon from 'sinon'; import { spec, VIDEO_ENDPOINT, BANNER_ENDPOINT, OUTSTREAM_SRC, DEFAULT_MIMES } from 'modules/beachfrontBidAdapter'; import { parse as parseUrl } from 'src/url'; @@ -225,11 +226,12 @@ describe('BeachfrontAdapter', function () { const mimes = ['video/webm']; const playbackmethod = 2; const maxduration = 30; + const placement = 4; bidRequest.mediaTypes = { video: {} }; - bidRequest.params.video = { mimes, playbackmethod, maxduration }; + bidRequest.params.video = { mimes, playbackmethod, maxduration, placement }; const requests = spec.buildRequests([ bidRequest ]); const data = requests[0].data; - expect(data.imp[0].video).to.deep.contain({ mimes, playbackmethod, maxduration }); + expect(data.imp[0].video).to.deep.contain({ mimes, playbackmethod, maxduration, placement }); }); it('must add GDPR consent data to the request', function () { @@ -531,6 +533,63 @@ describe('BeachfrontAdapter', function () { url: OUTSTREAM_SRC }); }); + + it('should initialize a player for outstream bids', () => { + const width = 640; + const height = 480; + const bidRequest = bidRequests[0]; + bidRequest.mediaTypes = { + video: { + context: 'outstream', + playerSize: [ width, height ] + } + }; + const serverResponse = { + bidPrice: 5.00, + url: 'http://reachms.bfmio.com/getmu?aid=bid:19c4a196-fb21-4c81-9a1a-ecc5437a39da', + cmpId: '123abc' + }; + const bidResponse = spec.interpretResponse({ body: serverResponse }, { bidRequest }); + window.Beachfront = { Player: sinon.spy() }; + bidResponse.adUnitCode = bidRequest.adUnitCode; + bidResponse.renderer.render(bidResponse); + sinon.assert.calledWith(window.Beachfront.Player, bidResponse.adUnitCode, sinon.match({ + adTagUrl: bidResponse.vastUrl, + width: bidResponse.width, + height: bidResponse.height, + expandInView: false, + collapseOnComplete: true + })); + delete window.Beachfront; + }); + + it('should configure outstream player settings from the bidder params', () => { + const width = 640; + const height = 480; + const bidRequest = bidRequests[0]; + bidRequest.mediaTypes = { + video: { + context: 'outstream', + playerSize: [ width, height ] + } + }; + bidRequest.params.player = { + expandInView: true, + collapseOnComplete: false, + progressColor: 'green' + }; + const serverResponse = { + bidPrice: 5.00, + url: 'http://reachms.bfmio.com/getmu?aid=bid:19c4a196-fb21-4c81-9a1a-ecc5437a39da', + cmpId: '123abc' + }; + const bidResponse = spec.interpretResponse({ body: serverResponse }, { bidRequest }); + window.Beachfront = { Player: sinon.spy() }; + bidResponse.adUnitCode = bidRequest.adUnitCode; + bidResponse.renderer.render(bidResponse); + sinon.assert.calledWith(window.Beachfront.Player, bidResponse.adUnitCode, sinon.match(bidRequest.params.player)); + delete window.Beachfront; + }); }); describe('for banner bids', function () { @@ -661,7 +720,7 @@ describe('BeachfrontAdapter', function () { }); it('should return user syncs defined the bid response', function () { - const syncUrl = 'http://sync.bfmio.com/sync_iframe?ifpl=5&ifg=1&id=test&gdpr=0&gc=&gce=0'; + const syncUrl = 'https://sync.bfmio.com/sync_iframe?ifpl=5&ifg=1&id=test&gdpr=0&gc=&gce=0'; const syncOptions = { iframeEnabled: true, pixelEnabled: true @@ -679,7 +738,7 @@ describe('BeachfrontAdapter', function () { }); it('should not return user syncs if iframes are disabled', function () { - const syncUrl = 'http://sync.bfmio.com/sync_iframe?ifpl=5&ifg=1&id=test&gdpr=0&gc=&gce=0'; + const syncUrl = 'https://sync.bfmio.com/sync_iframe?ifpl=5&ifg=1&id=test&gdpr=0&gc=&gce=0'; const syncOptions = { iframeEnabled: false, pixelEnabled: true diff --git a/test/spec/modules/bidglassAdapter_spec.js b/test/spec/modules/bidglassAdapter_spec.js new file mode 100644 index 00000000000..00a47fc997a --- /dev/null +++ b/test/spec/modules/bidglassAdapter_spec.js @@ -0,0 +1,103 @@ +import { expect } from 'chai'; +import { spec } from 'modules/bidglassBidAdapter'; +import { newBidder } from 'src/adapters/bidderFactory'; + +describe('Bid Glass Adapter', function () { + const adapter = newBidder(spec); + + describe('isBidRequestValid', function () { + let bid = { + 'bidder': 'bidglass', + 'params': { + 'adUnitId': '3' + }, + 'adUnitCode': 'bidglass-testunit', + 'sizes': [[300, 250], [300, 600]], + 'bidId': '30b31c1838de1e', + 'bidderRequestId': '22edbae2733bf6', + 'auctionId': '1d1a030790a475', + }; + + it('should return true when required params found', function () { + expect(spec.isBidRequestValid(bid)).to.equal(true); + }); + + it('should return false when required params are not passed', function () { + let bid = Object.assign({}, bid); + delete bid.params; + bid.params = {}; + expect(spec.isBidRequestValid(bid)).to.equal(false); + }); + }); + + describe('buildRequests', function () { + const bidRequests = [{ + 'bidder': 'bidglass', + 'params': { + 'adUnitId': '3' + }, + 'adUnitCode': 'bidglass-testunit', + 'sizes': [[300, 250], [300, 600]], + 'bidId': '30b31c1838de1e', + 'bidderRequestId': '22edbae2733bf6', + 'auctionId': '1d1a030790a475', + }]; + + const request = spec.buildRequests(bidRequests); + + it('sends bid request to our endpoint via POST', function () { + expect(request.method).to.equal('POST'); + }); + + it('sets withCredentials to false', function () { + expect(request.options.withCredentials).to.equal(false); + }); + }); + + describe('interpretResponse', function () { + let response; + beforeEach(function () { + response = { + body: { + 'bidResponses': [{ + 'ad': '', + 'cpm': '0.01', + 'creativeId': '-1', + 'width': '300', + 'height': '250', + 'requestId': '30b31c1838de1e' + }] + } + }; + }); + + it('should get the correct bid response', function () { + let expectedResponse = [{ + 'requestId': '30b31c1838de1e', + 'cpm': 0.01, + 'width': 300, + 'height': 250, + 'creativeId': '-1', + 'dealId': null, + 'currency': 'USD', + 'mediaType': 'banner', + 'netRevenue': true, + 'ttl': 10, + 'ad': '' + }]; + + let result = spec.interpretResponse(response); + expect(Object.keys(result[0])).to.deep.equal(Object.keys(expectedResponse[0])); + }); + + it('handles empty bid response', function () { + let response = { + body: { + 'bidResponses': [] + } + }; + let result = spec.interpretResponse(response); + expect(result.length).to.equal(0); + }); + }); +}); diff --git a/test/spec/modules/bucksenseBidAdapter_spec.js b/test/spec/modules/bucksenseBidAdapter_spec.js new file mode 100644 index 00000000000..17b5c3ceff5 --- /dev/null +++ b/test/spec/modules/bucksenseBidAdapter_spec.js @@ -0,0 +1,147 @@ +import {expect} from 'chai'; +import {spec} from 'modules/bucksenseBidAdapter'; + +describe('Bucksense Adapter', function() { + const BIDDER_CODE = 'bucksense'; + const BID_ID = '12345'; + const PLACE_ID = '1000'; + + function getValidBidObject() { + return { + bidder: BIDDER_CODE, + params: { + placementId: PLACE_ID, + } + } + }; + + describe('isBidRequestValid', function() { + var bid; + + beforeEach(function() { + bid = getValidBidObject(); + }); + + it('returns true when valid bid request is sent', function() { + expect(spec.isBidRequestValid(bid)).to.be.true; + }); + + it('returns true when valid test bid request is sent', function() { + bid.params['test'] = 1; + expect(spec.isBidRequestValid(bid)).to.be.true; + }); + + it('returns false when bidder not set to "bucksense"', function() { + bid.bidder = 'dummy'; + expect(spec.isBidRequestValid(bid)).to.be.false; + }); + + it('returns false when params not set', function() { + delete bid.params; + expect(spec.isBidRequestValid(bid)).to.be.false; + }); + }); + + describe('buildRequests', function() { + var bid, bidRequestObj; + + beforeEach(function() { + bid = getValidBidObject(); + bidRequestObj = { + 'bidderCode': 'bucksense', + 'auctionId': '73540558-86cb-4eef-895f-bf99c5353bd7', + 'bidderRequestId': '1feebcb5938c7e', + 'bids': [ + { + 'bidder': 'bucksense', + 'params': { + 'placementId': 1000 + }, + 'mediaTypes': { + 'banner': { + 'sizes': [ [ 300, 250 ], [ 300, 600 ] ] + } + }, + 'adUnitCode': 'test-div', + 'transactionId': '52b3ed07-2a09-4f58-a426-75acc7602c96', + 'sizes': [ [ 300, 250 ], [ 300, 600 ] ], + 'bidId': '22aecdacdcd773', + 'bidderRequestId': '1feebcb5938c7e', + 'auctionId': '73540558-86cb-4eef-895f-bf99c5353bd7', + 'src': 'client', + 'bidRequestsCount': 1 + } + ], + 'auctionStart': 1557176022728, + 'timeout': 1000, + 'refererInfo': { + 'referer': 'http://stefanod.hera.pe/prebid/?pbjs_debug=true', + 'reachedTop': true, + 'numIframes': 0, + 'stack': [ + 'http://stefanod.hera.pe/prebid/?pbjs_debug=true' + ] + }, + 'start': 1557176022731 + }; + }); + + it('should build a very basic request', function() { + var request = spec.buildRequests([bid], bidRequestObj); + expect(request[0].method).to.equal('POST'); + }); + + it('bidRequest data', function () { + var request = spec.buildRequests([bid], bidRequestObj); + expect(request[0].data).to.exist; + }); + }); + + describe('interpretResponse', function() { + var serverResponse; + var serverRequest; + + beforeEach(function() { + serverRequest = { + 'method': 'POST', + 'url': 'https://prebid.bksn.se:445/prebidjs/', + 'data': { + 'pub_id': 'prebid.org', + 'pl_id': '1000', + 'secure': 0, + 'href': 'http://prebid.org/developers.html', + 'bid_id': '27aaf8e96d9fd5', + 'params': { + 'placementId': '1000' + }, + 'sizes': [ [ 300, 250 ], [ 300, 600 ] ] + } + }; + + serverResponse = { + body: { + 'requestId': '', + 'cpm': 0.3, + 'width': 300, + 'height': 250, + 'ttl': 360, + 'creativeId': 'creative002', + 'currency': 'USD', + 'netRevenue': false, + 'ad': '
    ' + } + }; + }); + + it('should return an array of bid responses', function() { + var responses = spec.interpretResponse(serverResponse, serverRequest); + expect(responses).to.be.an('array').with.length(1); + }); + + it('should return an array of bid responses', function() { + serverResponse = {}; + var responses = spec.interpretResponse(serverResponse, serverRequest); + expect(responses).to.be.an('array').with.length(0); + }); + }); +}); diff --git a/test/spec/modules/buzzoolaBidAdapter_spec.js b/test/spec/modules/buzzoolaBidAdapter_spec.js new file mode 100644 index 00000000000..e6f22d1da20 --- /dev/null +++ b/test/spec/modules/buzzoolaBidAdapter_spec.js @@ -0,0 +1,279 @@ +import {expect} from 'chai'; +import {spec} from 'modules/buzzoolaBidAdapter'; +import {newBidder} from 'src/adapters/bidderFactory'; +import {executeRenderer, Renderer} from '../../../src/Renderer'; +import {deepClone} from '../../../src/utils'; + +const ENDPOINT = 'https://exchange.buzzoola.com/ssp/prebidjs'; +const RENDERER_SRC = 'https://tube.buzzoola.com/new/build/buzzlibrary.js'; + +const INVALID_BIDS = [{ + 'bidder': 'buzzoola', + 'mediaTypes': {'banner': {'sizes': [[240, 400], [300, 600]]}}, + 'sizes': [[240, 400], [300, 600]] +}, { + 'bidder': 'buzzoola', + 'params': {'placementId': 417846}, + 'sizes': [[240, 400], [300, 600]] +}, { + 'bidder': 'buzzoola', + 'mediaTypes': { + 'video': { + 'playerSize': [[640, 380]], + 'mimes': ['video/mp4'], + 'minduration': 1, + 'maxduration': 2 + } + } +}, { + 'bidder': 'buzzoola', + 'params': {'placementId': 417845} +}]; + +const BANNER_BID = { + 'bidder': 'buzzoola', + 'params': {'placementId': 417846}, + 'mediaTypes': {'banner': {'sizes': [[240, 400], [300, 600]]}}, + 'sizes': [[240, 400], [300, 600]], + 'bidId': '2a11641ada3c6a' +}; + +const BANNER_BID_REQUEST = { + bidderCode: 'buzzoola', + bids: [BANNER_BID] +}; + +const BANNER_RESPONSE = [{ + 'requestId': '2a11641ada3c6a', + 'cpm': 5.583115, + 'width': 240, + 'height': 400, + 'creativeId': '11773', + 'dealId': '', + 'currency': 'RUB', + 'netRevenue': true, + 'ttl': 10800, + 'ad': '
    ', + 'mediaType': 'banner' +}]; + +const REQUIRED_BANNER_FIELDS = [ + 'requestId', + 'cpm', + 'width', + 'height', + 'ad', + 'ttl', + 'creativeId', + 'netRevenue', + 'currency', + 'mediaType' +]; + +const VIDEO_BID = { + 'bidder': 'buzzoola', + 'params': {'placementId': 417845}, + 'mediaTypes': { + 'video': { + 'context': 'instream', + 'playerSize': [[640, 380]], + 'mimes': ['video/mp4'], + 'minduration': 1, + 'maxduration': 2 + } + }, + 'bidId': '325a54271dc40a' +}; + +const VIDEO_BID_REQUEST = { + bidderCode: 'buzzoola', + bids: [VIDEO_BID] +}; + +const VIDEO_RESPONSE = [{ + 'requestId': '325a54271dc40a', + 'cpm': 4.6158956756756755, + 'width': 640, + 'height': 380, + 'creativeId': '11774', + 'dealId': '', + 'currency': 'RUB', + 'netRevenue': true, + 'ttl': 10800, + 'ad': '{"crs":[{"advertiser_id":165,"title":"qa//PrebidJStestVideoURL","description":"qa//PrebidJStest","duration":0,"ya_id":"55038886","raw_content":"{\\"main_content\\": \\"https://tube.buzzoola.com/xstatic/o42/mcaug/2.mp4\\"}","content":{"main_content":"https://tube.buzzoola.com/xstatic/o42/mcaug/2.mp4"},"content_type":"video_url","sponsor_link":"","sponsor_name":"","overlay":"","overlay_start_after":0,"overlay_close_after":0,"action_button_title":"","tracking_url":{},"iframe_domains":[],"soc_share_url":"https://tube.buzzoola.com/share.html","player_show_skip_button_before_play":false,"player_show_skip_button_seconds":5,"player_show_title":true,"player_data_attributes":{"expandable":"default","overroll":"default"},"click_event_view":"default","share_panel_position":"left","auto_play":true,"logo_url":{},"share_buttons":["vkontakte","facebook","twitter","moimir","odnoklassniki","embed"],"player_show_panels":false,"thumbnail":"","tracking_js":{},"click_event_url":"https://exchange.buzzoola.com/event/f9382ceb-49c2-4683-50d8-5c516c53cd69/14795a96-6261-49dc-7241-207333ab1490/m7JVQI9Y7J35_gEDugNO2bIiP2qTqPKfuLrqqh_LoJu0tD6PoLEglMXUBzVpSg75c-unsaijXpIERGosa1adogXgqjDml4Pm/click/0/","vpaid_js_url":"https://tube.buzzoola.com/new/js/lib/vpaid_js_proxy.js","skip_clickthru":false,"landing_link_text":"","sound_enabled_by_default":false,"landing_link_position":"right","displayed_price":"","js_wrapper_url":"","enable_moat":false,"branding_template":"","event_url":"https://exchange.buzzoola.com/event/f9382ceb-49c2-4683-50d8-5c516c53cd69/14795a96-6261-49dc-7241-207333ab1490/m7JVQI9Y7J35_gEDugNO2bIiP2qTqPKfuLrqqh_LoJu0tD6PoLEglMXUBzVpSg75c-unsaijXpIERGosa1adogXgqjDml4Pm/","resend_event_url":"https://exchange.buzzoola.com/resend_event/f9382ceb-49c2-4683-50d8-5c516c53cd69/14795a96-6261-49dc-7241-207333ab1490/m7JVQI9Y7J35_gEDugNO2bIiP2qTqPKfuLrqqh_LoJu0tD6PoLEglMXUBzVpSg75c-unsaijXpIERGosa1adogXgqjDml4Pm/","creative_hash":"m7JVQI9Y7J35_gEDugNO2bIiP2qTqPKfuLrqqh_LoJu0tD6PoLEglMXUBzVpSg75c-unsaijXpIERGosa1adogXgqjDml4Pm","custom_html":"","custom_js":"","height":0,"width":0,"campaign_id":5758,"line_item_id":17319,"creative_id":11774,"extra":{"imp_id":"14795a96-6261-49dc-7241-207333ab1490","rtime":"2019-08-27 13:58:36"},"subcontent":"vast","auction_settings":{"price":"4.6158956756756755","currency":"RUB","event_name":"player_seen","time_slice":0},"hash_to_embed":"kbDH64c7yFYkSu0KCwSkoUD2bNHAnUTHBERqLGtWnaIF4Kow5peD5g","need_ad":false}],"tracking_urls":{"ctor":["https://www.tns-counter.ru/V13a****buzzola_com/ru/CP1251/tmsec=buzzola_total/1322650417245790778","https://www.tns-counter.ru/V13a****buzzoola_kz/ru/UTF-8/tmsec=buzzoola_video/5395765100939533275","https://buzzoolaru.solution.weborama.fr/fcgi-bin/dispatch.fcgi?a.A=ev&a.si=3071&a.te=37&a.aap=1&a.agi=862&a.evn=PrebidJS.test&g.ra=4581478478720298652","https://x01.aidata.io/0.gif?pid=BUZZOOLA&id=dbdb5b13-e719-4987-7f6a-a882322bbfce","https://top-fwz1.mail.ru/counter?id=3026769","https://www.tns-counter.ru/V13a****buzzola_com/ru/UTF-8/tmsec=buzzola_inread/542059452789128996","https://dm.hybrid.ai/match?id=111&vid=dbdb5b13-e719-4987-7f6a-a882322bbfce","https://px.adhigh.net/p/cm/buzzoola?u=dbdb5b13-e719-4987-7f6a-a882322bbfce","https://ssp1.rtb.beeline.ru/userbind?src=buz&ssp_user_id=dbdb5b13-e719-4987-7f6a-a882322bbfce","https://sync.upravel.com/image?source=buzzoola&id=dbdb5b13-e719-4987-7f6a-a882322bbfce","https://relap.io/api/partners/bzcs.gif?uid=dbdb5b13-e719-4987-7f6a-a882322bbfce","https://x.bidswitch.net/sync?ssp=sspicyads","https://inv-nets.admixer.net/adxcm.aspx?ssp=3C5173FC-CA30-4692-9116-009C19CB1BF9&rurl=%2F%2Fexchange.buzzoola.com%2Fcookiesync%2Fdsp%2Fadmixer-video%2F%24%24visitor_cookie%24%24","https://sync.datamind.ru/cookie/accepter?source=buzzoola&id=dbdb5b13-e719-4987-7f6a-a882322bbfce","https://dmp.vihub.ru/match?sysid=buz&redir=no&uid=dbdb5b13-e719-4987-7f6a-a882322bbfce","https://ad.adriver.ru/cgi-bin/rle.cgi?sid=1&ad=608223&bt=21&pid=2551979&bid=6150299&bn=6150299&rnd=1279444531737367663","https://reichelcormier.bid/point/?method=match&type=ssp&key=4677290772f9000878093d69c199bfba&id=3509&extUid=dbdb5b13-e719-4987-7f6a-a882322bbfce","https://sync.republer.com/match?src=buzzoola&id=dbdb5b13-e719-4987-7f6a-a882322bbfce","https://sm.rtb.mts.ru/p?id=dbdb5b13-e719-4987-7f6a-a882322bbfce&ssp=buzzoola","https://cm.mgid.com/m?cdsp=371151&adu=https%3A%2F%2Fexchange.buzzoola.com%2Fcookiesync%2Fdsp%2Fmarketgid-native%2F%7Bmuidn%7D","https://dmp.gotechnology.io/dmp/syncsspdmp?sspid=122258"]},"tracking_js":{"ctor":["https://buzzoola.fraudscore.mobi/dooJ9sheeeDaZ3fe.js?s=268671&l=417845"]},"placement":{"placement_id":417845,"unit_type":"inread","unit_settings":{"align":"left","autoplay_enable_sound":false,"creatives_amount":1,"debug_mode":false,"expandable":"never","sound_control":"default","target":"","width":"100%"},"unit_settings_list":["width","sound_control","debug_mode","target","creatives_amount","expandable","container_height","align","height"]},"uuid":"dbdb5b13-e719-4987-7f6a-a882322bbfce","auction_id":"f9382ceb-49c2-4683-50d8-5c516c53cd69","env":"prod"}', + 'vastXml': '\n00:00:30', + 'mediaType': 'video' +}]; + +const RENDERER_DATA = { + data: JSON.parse(VIDEO_RESPONSE[0].ad) +}; +RENDERER_DATA.data.placement.unit_settings.width = '' + VIDEO_RESPONSE[0].width; +RENDERER_DATA.data.placement.unit_settings.height = RENDERER_DATA.data.placement.unit_settings.container_height = '' + VIDEO_RESPONSE[0].height; + +const REQUIRED_VIDEO_FIELDS = [ + 'requestId', + 'cpm', + 'width', + 'height', + 'ad', + 'ttl', + 'creativeId', + 'netRevenue', + 'currency', + 'vastXml', + 'mediaType' +]; + +describe('buzzoolaBidAdapter', () => { + const adapter = newBidder(spec); + + describe('inherited functions', () => { + it('exists and is a function', () => { + expect(adapter.callBids).to.exist.and.to.be.a('function'); + }); + }); + + describe('isBidRequestValid', () => { + it('should return true when required params found', () => { + expect(spec.isBidRequestValid(VIDEO_BID)).to.be.true; + }); + + it('should return false when required params are not passed', () => { + INVALID_BIDS.forEach(bid => { + expect(spec.isBidRequestValid(bid)).to.be.false; + }); + }); + }); + + describe('buildRequests', () => { + let videoBidRequests = [VIDEO_BID]; + let bannerBidRequests = [BANNER_BID]; + + const bannerRequest = spec.buildRequests(bannerBidRequests, BANNER_BID_REQUEST); + const videoRequest = spec.buildRequests(videoBidRequests, VIDEO_BID_REQUEST); + + it('sends bid request to ENDPOINT via POST', () => { + expect(videoRequest.method).to.equal('POST'); + expect(bannerRequest.method).to.equal('POST'); + }); + + it('sends bid request to correct ENDPOINT', () => { + expect(videoRequest.url).to.equal(ENDPOINT); + expect(bannerRequest.url).to.equal(ENDPOINT); + }); + + it('sends correct video bid parameters', () => { + expect(videoRequest.data).to.deep.equal(VIDEO_BID_REQUEST); + }); + + it('sends correct banner bid parameters', () => { + expect(bannerRequest.data).to.deep.equal(BANNER_BID_REQUEST); + }); + }); + + describe('interpretResponse', () => { + const noBidServerResponse = []; + const emptyResponse = ''; + + function nobidServerResponseCheck(request, response = noBidServerResponse) { + const noBidResult = spec.interpretResponse({body: response}, {data: request}); + + expect(noBidResult.length).to.equal(0); + } + + function bidServerResponseCheck(response, request, fields) { + const result = spec.interpretResponse({body: response}, {data: request}); + + expect(result).to.deep.equal(response); + result.forEach(bid => { + fields.forEach(field => { + expect(bid).to.have.own.property(field); + }) + }); + } + + it('handles video nobid responses', () => { + nobidServerResponseCheck(VIDEO_BID_REQUEST); + }); + + it('handles banner nobid responses', () => { + nobidServerResponseCheck(BANNER_BID_REQUEST); + }); + + it('handles video empty responses', () => { + nobidServerResponseCheck(VIDEO_BID_REQUEST, emptyResponse); + }); + + it('handles banner empty responses', () => { + nobidServerResponseCheck(BANNER_BID_REQUEST, emptyResponse); + }); + + it('should get correct video bid response', () => { + bidServerResponseCheck(VIDEO_RESPONSE, VIDEO_BID_REQUEST, REQUIRED_VIDEO_FIELDS); + }); + + it('should get correct banner bid response', () => { + bidServerResponseCheck(BANNER_RESPONSE, BANNER_BID_REQUEST, REQUIRED_BANNER_FIELDS); + }); + }); + + describe('outstream renderer', () => { + let result; + let renderer; + + before(() => { + const adContainer = document.createElement('div'); + adContainer.id = 'adUnitCode'; + document.body.appendChild(adContainer); + + const outstreamVideoBid = deepClone(VIDEO_BID); + outstreamVideoBid.mediaTypes.video.context = 'outstream'; + + const outstreamVideoRequest = deepClone(VIDEO_BID_REQUEST); + outstreamVideoRequest.bids = [outstreamVideoBid]; + + const scriptElement = document.createElement('div'); + + const scriptStub = sinon.stub(document, 'createElement'); + scriptStub.withArgs('script').returns(scriptElement); + + result = spec.interpretResponse({body: VIDEO_RESPONSE}, {data: outstreamVideoRequest})[0]; + renderer = result.renderer; + + result.adUnitCode = 'adUnitCode'; + + scriptElement.onload && scriptElement.onload(); + + scriptStub.restore(); + }); + + it('should add renderer for outstream video', () => { + expect(result).to.have.own.property('renderer'); + }); + + it('should be instance of Renderer', () => { + expect(renderer).to.be.instanceof(Renderer); + }); + + it('should have valid src', () => { + expect(renderer.url).to.equal(RENDERER_SRC); + }); + + it('should create player instance', () => { + window.Buzzoola = { + Core: { + install: () => {} + } + }; + const spy = sinon.spy(window.Buzzoola.Core, 'install'); + executeRenderer(renderer, result); + expect(spy.called).to.be.true; + + const spyCall = spy.getCall(0); + + expect(spyCall.args[0]).to.be.instanceof(Element); + expect(spyCall.args[1]).to.deep.equal(RENDERER_DATA); + }); + }); +}); diff --git a/test/spec/modules/cedatoBidAdapter_spec.js b/test/spec/modules/cedatoBidAdapter_spec.js index d6c1333c262..969c06a64a2 100644 --- a/test/spec/modules/cedatoBidAdapter_spec.js +++ b/test/spec/modules/cedatoBidAdapter_spec.js @@ -4,7 +4,7 @@ import {spec} from 'modules/cedatoBidAdapter'; describe('the cedato adapter', function () { function getValidBidObject() { return { - bidId: 123, + bidId: '2f4a613a702b6c', mediaTypes: { banner: { sizes: [[300, 250]] @@ -48,9 +48,10 @@ describe('the cedato adapter', function () { }); describe('interpretResponse', function() { - var serverResponse; + var bid, serverResponse, bidderRequest; beforeEach(function() { + bid = getValidBidObject(); serverResponse = { body: { bidid: '0.36157306192821', @@ -65,7 +66,7 @@ describe('the cedato adapter', function () { }, id: '0.75549202124378', adomain: 'cedato.com', - uuid: '2f4a613a702b6c', + uuid: bid.bidId, crid: '1450133326', adm: "
    \n\n\n", h: 250, @@ -77,10 +78,13 @@ describe('the cedato adapter', function () { cur: 'USD' } }; + bidderRequest = { + bids: [bid] + }; }); it('should return an array of bid responses', function() { - var responses = spec.interpretResponse(serverResponse); + var responses = spec.interpretResponse(serverResponse, {bidderRequest}); expect(responses).to.be.an('array').with.length(1); }); }); diff --git a/test/spec/modules/cleanmedianetBidAdapter_spec.js b/test/spec/modules/cleanmedianetBidAdapter_spec.js index d68505604bc..09f76806fd7 100644 --- a/test/spec/modules/cleanmedianetBidAdapter_spec.js +++ b/test/spec/modules/cleanmedianetBidAdapter_spec.js @@ -246,6 +246,26 @@ describe('CleanmedianetAdapter', function() { response = spec.buildRequests([bidRequestWithPosEquals2], bidRequest)[0]; expect(response.data.imp[0].video.ext.context).to.equal(null); }); + it('builds request video object correctly with multi-dimensions size array', function () { + let bidRequestWithVideo = utils.deepClone(bidRequest); + bidRequestWithVideo.mediaTypes.video = { + playerSize: [[304, 254], [305, 255]], + context: 'instream' + }; + + let response = spec.buildRequests([bidRequestWithVideo], bidRequest)[0]; + expect(response.data.imp[1].video.w).to.equal(304); + expect(response.data.imp[1].video.h).to.equal(254); + + bidRequestWithVideo = utils.deepClone(bidRequest); + bidRequestWithVideo.mediaTypes.video = { + playerSize: [304, 254] + }; + + response = spec.buildRequests([bidRequestWithVideo], bidRequest)[0]; + expect(response.data.imp[1].video.w).to.equal(304); + expect(response.data.imp[1].video.h).to.equal(254); + }); it('builds request with gdpr consent', function() { let response = spec.buildRequests([bidRequest], bidRequest)[0]; diff --git a/test/spec/modules/consentManagement_spec.js b/test/spec/modules/consentManagement_spec.js index 40c96c38eb0..6be96427750 100644 --- a/test/spec/modules/consentManagement_spec.js +++ b/test/spec/modules/consentManagement_spec.js @@ -1,4 +1,4 @@ -import {setConfig, requestBidsHook, resetConsentData, userCMP, consentTimeout, allowAuction, staticConsentData} from 'modules/consentManagement'; +import {setConsentConfig, requestBidsHook, resetConsentData, userCMP, consentTimeout, allowAuction, staticConsentData} from 'modules/consentManagement'; import {gdprDataHandler} from 'src/adapterManager'; import * as utils from 'src/utils'; import { config } from 'src/config'; @@ -7,8 +7,8 @@ let assert = require('chai').assert; let expect = require('chai').expect; describe('consentManagement', function () { - describe('setConfig tests:', function () { - describe('empty setConfig value', function () { + describe('setConsentConfig tests:', function () { + describe('empty setConsentConfig value', function () { beforeEach(function () { sinon.stub(utils, 'logInfo'); }); @@ -19,7 +19,7 @@ describe('consentManagement', function () { }); it('should use system default values', function () { - setConfig({}); + setConsentConfig({}); expect(userCMP).to.be.equal('iab'); expect(consentTimeout).to.be.equal(10000); expect(allowAuction).to.be.true; @@ -27,7 +27,7 @@ describe('consentManagement', function () { }); }); - describe('valid setConfig value', function () { + describe('valid setConsentConfig value', function () { afterEach(function () { config.resetConfig(); $$PREBID_GLOBAL$$.requestBids.removeAll(); @@ -39,14 +39,14 @@ describe('consentManagement', function () { allowAuctionWithoutConsent: false }; - setConfig(allConfig); + setConsentConfig(allConfig); expect(userCMP).to.be.equal('iab'); expect(consentTimeout).to.be.equal(7500); expect(allowAuction).to.be.false; }); }); - describe('static consent string setConfig value', () => { + describe('static consent string setConsentConfig value', () => { afterEach(() => { config.resetConfig(); $$PREBID_GLOBAL$$.requestBids.removeAll(); @@ -447,7 +447,7 @@ describe('consentManagement', function () { } }; - setConfig(staticConfig); + setConsentConfig(staticConfig); expect(userCMP).to.be.equal('static'); expect(consentTimeout).to.be.equal(0); // should always return without a timeout when config is used expect(allowAuction).to.be.false; @@ -495,7 +495,7 @@ describe('consentManagement', function () { let badCMPConfig = { cmpApi: 'bad' }; - setConfig(badCMPConfig); + setConsentConfig(badCMPConfig); expect(userCMP).to.be.equal(badCMPConfig.cmpApi); requestBidsHook(() => { @@ -508,7 +508,7 @@ describe('consentManagement', function () { }); it('should throw proper errors when CMP is not found', function () { - setConfig(goodConfigWithCancelAuction); + setConsentConfig(goodConfigWithCancelAuction); requestBidsHook(() => { didHookReturn = true; @@ -546,7 +546,7 @@ describe('consentManagement', function () { cmpStub = sinon.stub(window, '__cmp').callsFake((...args) => { args[2](testConsentData); }); - setConfig(goodConfigWithAllowAuction); + setConsentConfig(goodConfigWithAllowAuction); requestBidsHook(() => {}, {}); cmpStub.restore(); @@ -610,7 +610,7 @@ describe('consentManagement', function () { args[2](testConsentData.data.msgName, testConsentData.data); }); - setConfig(goodConfigWithAllowAuction); + setConsentConfig(goodConfigWithAllowAuction); requestBidsHook(() => { didHookReturn = true; }, {adUnits: [{ sizes: [[300, 250]] }]}); @@ -684,7 +684,7 @@ describe('consentManagement', function () { function testIFramedPage(testName, messageFormatString) { it(`should return the consent string from a postmessage + addEventListener response - ${testName}`, (done) => { stringifyResponse = messageFormatString; - setConfig(goodConfigWithAllowAuction); + setConsentConfig(goodConfigWithAllowAuction); requestBidsHook(() => { let consent = gdprDataHandler.getConsentData(); sinon.assert.notCalled(utils.logWarn); @@ -726,7 +726,7 @@ describe('consentManagement', function () { args[2](testConsentData); }); - setConfig(goodConfigWithAllowAuction); + setConsentConfig(goodConfigWithAllowAuction); requestBidsHook(() => { didHookReturn = true; @@ -748,7 +748,7 @@ describe('consentManagement', function () { args[2](testConsentData); }); - setConfig(goodConfigWithCancelAuction); + setConsentConfig(goodConfigWithCancelAuction); requestBidsHook(() => { didHookReturn = true; @@ -768,7 +768,7 @@ describe('consentManagement', function () { args[2](testConsentData); }); - setConfig(goodConfigWithAllowAuction); + setConsentConfig(goodConfigWithAllowAuction); requestBidsHook(() => { didHookReturn = true; diff --git a/test/spec/modules/conversantBidAdapter_spec.js b/test/spec/modules/conversantBidAdapter_spec.js index 34991252fa8..bfe3c6e8fa1 100644 --- a/test/spec/modules/conversantBidAdapter_spec.js +++ b/test/spec/modules/conversantBidAdapter_spec.js @@ -375,6 +375,19 @@ describe('Conversant adapter tests', function() { expect(payload).to.have.deep.nested.property('user.ext.fpc', 12345); }); + it('Verify User ID publisher commond id support', function() { + // clone bidRequests + let requests = utils.deepClone(bidRequests) + + // add pubcid to every entry + requests.forEach((unit) => { + Object.assign(unit, {userId: {pubcid: 67890}}); + }); + // construct http post payload + const payload = spec.buildRequests(requests).data; + expect(payload).to.have.deep.nested.property('user.ext.fpc', 67890); + }); + it('Verify GDPR bid request', function() { // add gdpr info const bidRequest = { diff --git a/test/spec/modules/cosmosBidAdapter_spec.js b/test/spec/modules/cosmosBidAdapter_spec.js new file mode 100644 index 00000000000..348f5ae3ddf --- /dev/null +++ b/test/spec/modules/cosmosBidAdapter_spec.js @@ -0,0 +1,355 @@ +import { expect } from 'chai'; +import { spec } from 'modules/cosmosBidAdapter'; +import * as utils from 'src/utils'; +const constants = require('src/constants.json'); + +describe('Cosmos adapter', function () { + let bannerBidRequests; + let bannerBidResponse; + let videoBidRequests; + let videoBidResponse; + + beforeEach(function () { + bannerBidRequests = [ + { + bidder: 'cosmos', + mediaTypes: { + banner: { + sizes: [[300, 250], [300, 600]], + } + }, + params: { + publisherId: '1001', + currency: 'USD', + geo: { + lat: '09.5', + lon: '21.2', + } + }, + bidId: '29f8bd96defe76' + } + ]; + + videoBidRequests = + [ + { + mediaTypes: { + video: { + mimes: ['video/mp4', 'video/x-flv'], + context: 'instream' + } + }, + bidder: 'cosmos', + params: { + publisherId: 1001, + video: { + skippable: true, + minduration: 5, + maxduration: 30 + } + }, + bidId: '39f5cc6eff9b37' + } + ]; + + bannerBidResponse = { + 'body': { + 'id': '93D3BAD6-E2E2-49FB-9D89-920B1761C865', + 'seatbid': [{ + 'bid': [{ + 'id': '82DAAE22-FF66-4FAB-84AB-347B0C5CD02C', + 'impid': '29f8bd96defe76', + 'price': 1.858309, + 'adm': '

    COSMOS\"Connecting Advertisers and Publishers directly\"

    ', + 'adid': 'v55jutrh', + 'adomain': ['febreze.com'], + 'iurl': 'https://thetradedesk-t-general.s3.amazonaws.com/AdvertiserLogos/vgl908z.png', + 'cid': '1234', + 'crid': 'v55jutrh', + 'w': 300, + 'h': 250, + 'ext': { + 'prebid': { + 'type': 'banner' + } + } + }], + 'seat': 'zeta' + }] + } + }; + + videoBidResponse = { + 'body': { + 'id': '93D3BAD6-E2E2-49FB-9D89-920B1761C865', + 'seatbid': [{ + 'bid': [{ + 'id': '82DAAE22-FF66-4FAB-84AB-347B0C5CD02C', + 'impid': '39f5cc6eff9b37', + 'price': 0.858309, + 'adm': 'CosmosHQVAST 2.0 Instream Test 1VAST 2.0 Instream Test 1https://track.cosmoshq.com/event?data=%7B%22id%22%3A%221566011421045%22%2C%22bid%22%3A%2282DAAE22-FF66-4FAB-84AB-347B0C5CD02C%22%2C%22ts%22%3A%2220190817031021%22%2C%22pid%22%3A1001%2C%22plcid%22%3A1%2C%22aid%22%3A1%2C%22did%22%3A1%2C%22cid%22%3A%2222918%22%2C%22af%22%3A3%2C%22at%22%3A1%2C%22w%22%3A300%2C%22h%22%3A250%2C%22crid%22%3A%22v55jutrh%22%2C%22pp%22%3A0.858309%2C%22cp%22%3A0.858309%2C%22mg%22%3A0%7D&type=1http://track.dsp.impression.com/impression00:00:60http://sync.cosmoshq.com/static/video/SampleVideo_1280x720_10mb.mp4', + 'adid': 'v55jutrh', + 'adomain': ['febreze.com'], + 'iurl': 'https://thetradedesk-t-general.s3.amazonaws.com/AdvertiserLogos/vgl908z.png', + 'cid': '1234', + 'crid': 'v55jutrh', + 'w': 300, + 'h': 250, + 'ext': { + 'prebid': { + 'type': 'video' + } + } + }], + 'seat': 'zeta' + }] + } + }; + }); + + describe('isBidRequestValid', function () { + describe('validate the bid object: valid bid', function () { + it('valid bid case', function () { + let validBid = { + bidder: 'cosmos', + params: { + publisherId: 1001, + tagId: 1 + } + }, + isValid = spec.isBidRequestValid(validBid); + expect(isValid).to.equal(true); + }); + + it('validate the bid object: nil/empty bid object', function () { + let validBid = { + }, + isValid = spec.isBidRequestValid(validBid); + expect(isValid).to.equal(false); + }); + + it('validate the bid object: publisherId not passed', function () { + let validBid = { + bidder: 'cosmos', + params: { + tagId: 1 + } + }, + isValid = spec.isBidRequestValid(validBid); + expect(isValid).to.equal(false); + }); + + it('validate the bid object: publisherId is not number', function () { + let validBid = { + bidder: 'cosmos', + params: { + publisherId: '301', + tagId: 1 + } + }, + isValid = spec.isBidRequestValid(validBid); + expect(isValid).to.equal(false); + }); + + it('validate the bid object: mimes absent', function () { + let validBid = { + bidder: 'cosmos', + mediaTypes: { + video: {} + }, + params: { + publisherId: 1001 + } + }, + isValid = spec.isBidRequestValid(validBid); + expect(isValid).to.equal(false); + }); + + it('validate the bid object: mimes present', function () { + let validBid = { + bidder: 'cosmos', + mediaTypes: { + video: { + mimes: ['video/mp4', 'application/javascript'] + } + }, + params: { + publisherId: 1001 + } + }, + isValid = spec.isBidRequestValid(validBid); + expect(isValid).to.equal(true); + }); + + it('validate the bid object: tagId is not passed', function () { + let validBid = { + bidder: 'cosmos', + params: { + publisherId: 1001 + } + }, + isValid = spec.isBidRequestValid(validBid); + expect(isValid).to.equal(true); + }); + }); + + describe('buildRequests', function () { + it('build request object: buildRequests function should not modify original bannerBidRequests object', function () { + let originalBidRequests = utils.deepClone(bannerBidRequests); + let request = spec.buildRequests(bannerBidRequests); + expect(bannerBidRequests).to.deep.equal(originalBidRequests); + }); + + it('build request object: endpoint check', function () { + let request = spec.buildRequests(bannerBidRequests); + expect(request[0].url).to.equal('//bid.cosmoshq.com/openrtb2/bids'); + expect(request[0].method).to.equal('POST'); + }); + + it('build request object: request params check', function () { + let request = spec.buildRequests(bannerBidRequests); + let data = JSON.parse(request[0].data); + expect(data.site.publisher.id).to.equal(bannerBidRequests[0].params.publisherId); // publisher Id + expect(data.imp[0].bidfloorcur).to.equal(bannerBidRequests[0].params.currency); + }); + + it('build request object: request params check without tagId', function () { + delete bannerBidRequests[0].params.tagId; + let request = spec.buildRequests(bannerBidRequests); + let data = JSON.parse(request[0].data); + expect(data.site.publisher.id).to.equal(bannerBidRequests[0].params.publisherId); // publisher Id + expect(data.imp[0].tagid).to.equal(undefined); // tagid + expect(data.imp[0].bidfloorcur).to.equal(bannerBidRequests[0].params.currency); + }); + + it('build request object: request params multi size format object check', function () { + let bidRequest = [ + { + bidder: 'cosmos', + mediaTypes: { + banner: { + sizes: [[300, 250], [300, 600]], + } + }, + params: { + publisherId: 1001, + currency: 'USD' + } + } + ]; + /* case 1 - size passed in adslot */ + let request = spec.buildRequests(bidRequest); + let data = JSON.parse(request[0].data); + expect(data.imp[0].banner.w).to.equal(300); // width + expect(data.imp[0].banner.h).to.equal(250); // height + + /* case 2 - size passed in adslot as well as in sizes array */ + bidRequest[0].sizes = [[300, 600], [300, 250]]; + bidRequest[0].mediaTypes = { + banner: { + sizes: [[300, 600], [300, 250]] + } + }; + request = spec.buildRequests(bidRequest); + data = JSON.parse(request[0].data); + + expect(data.imp[0].banner.w).to.equal(300); // width + expect(data.imp[0].banner.h).to.equal(600); // height + + /* case 3 - size passed in sizes but not in adslot */ + bidRequest[0].params.tagId = 1; + bidRequest[0].sizes = [[300, 250], [300, 600]]; + bidRequest[0].mediaTypes = { + banner: { + sizes: [[300, 250], [300, 600]] + } + }; + request = spec.buildRequests(bidRequest); + data = JSON.parse(request[0].data); + + expect(data.imp[0].banner.w).to.equal(300); // width + expect(data.imp[0].banner.h).to.equal(250); // height + expect(data.imp[0].banner.format).exist.and.to.be.an('array'); + expect(data.imp[0].banner.format[0]).exist.and.to.be.an('object'); + expect(data.imp[0].banner.format[0].w).to.equal(300); // width + expect(data.imp[0].banner.format[0].h).to.equal(250); // height + }); + + it('build request object: request params currency check', function () { + let bidRequest = [ + { + bidder: 'cosmos', + mediaTypes: { + banner: { + sizes: [[300, 250], [300, 600]], + } + }, + params: { + publisherId: 1001, + tagId: 1, + currency: 'USD' + }, + sizes: [[300, 250], [300, 600]] + } + ]; + + /* case 1 - + currency specified in adunits + output: imp[0] use currency specified in bannerBidRequests[0].params.currency + + */ + let request = spec.buildRequests(bidRequest); + let data = JSON.parse(request[0].data); + expect(data.imp[0].bidfloorcur).to.equal(bidRequest[0].params.currency); + + /* case 2 - + currency specified in adunit + output: imp[0] use default currency - USD + + */ + delete bidRequest[0].params.currency; + request = spec.buildRequests(bidRequest); + data = JSON.parse(request[0].data); + expect(data.imp[0].bidfloorcur).to.equal('USD'); + }); + + it('build request object: request params check for video ad', function () { + let request = spec.buildRequests(videoBidRequests); + let data = JSON.parse(request[0].data); + expect(data.imp[0].video).to.exist; + expect(data.imp[0]['video']['mimes']).to.exist.and.to.be.an('array'); + expect(data.imp[0]['video']['mimes'][0]).to.equal(videoBidRequests[0].mediaTypes.video['mimes'][0]); + expect(data.imp[0]['video']['mimes'][1]).to.equal(videoBidRequests[0].mediaTypes.video['mimes'][1]); + expect(data.imp[0]['video']['minduration']).to.equal(videoBidRequests[0].params.video['minduration']); + expect(data.imp[0]['video']['maxduration']).to.equal(videoBidRequests[0].params.video['maxduration']); + }); + + describe('interpretResponse', function () { + it('check for banner response', function () { + let request = spec.buildRequests(bannerBidRequests); + let data = JSON.parse(request[0].data); + let response = spec.interpretResponse(bannerBidResponse, request[0]); + expect(response).to.be.an('array').with.length.above(0); + expect(response[0].requestId).to.equal(bannerBidResponse.body.seatbid[0].bid[0].impid); + expect(response[0].cpm).to.equal((bannerBidResponse.body.seatbid[0].bid[0].price).toFixed(2)); + expect(response[0].width).to.equal(bannerBidResponse.body.seatbid[0].bid[0].w); + expect(response[0].height).to.equal(bannerBidResponse.body.seatbid[0].bid[0].h); + if (bannerBidResponse.body.seatbid[0].bid[0].crid) { + expect(response[0].creativeId).to.equal(bannerBidResponse.body.seatbid[0].bid[0].crid); + } else { + expect(response[0].creativeId).to.equal(bannerBidResponse.body.seatbid[0].bid[0].id); + } + expect(response[0].dealId).to.equal(bannerBidResponse.body.seatbid[0].bid[0].dealid); + expect(response[0].currency).to.equal('USD'); + expect(response[0].netRevenue).to.equal(false); + expect(response[0].ttl).to.equal(300); + }); + it('check for video response', function () { + let request = spec.buildRequests(videoBidRequests); + let data = JSON.parse(request[0].data); + let response = spec.interpretResponse(videoBidResponse, request[0]); + }); + }); + }); + }); +}); diff --git a/test/spec/modules/cpmstarBidAdapter_spec.js b/test/spec/modules/cpmstarBidAdapter_spec.js new file mode 100755 index 00000000000..3dd06a484d9 --- /dev/null +++ b/test/spec/modules/cpmstarBidAdapter_spec.js @@ -0,0 +1,158 @@ +import { expect } from 'chai'; +import { spec } from 'modules/cpmstarBidAdapter'; +import { deepClone } from 'src/utils'; + +describe('Cpmstar Bid Adapter', function () { + describe('isBidRequestValid', function () { + it('should return true since the bid is valid', + function () { + var bid = { params: { placementId: 123456 } }; + expect(spec.isBidRequestValid(bid)).to.equal(true); + }) + + it('should return false since the bid is invalid', function () { + var bid = { params: { placementId: '' } }; + expect(spec.isBidRequestValid(bid)).to.equal(false); + }) + + it('should return a valid player size', function() { + var bid = { mediaTypes: { + video: { + playerSize: [[960, 540]] + } + }} + expect(spec.getPlayerSize(bid)[0]).to.equal(960); + expect(spec.getPlayerSize(bid)[1]).to.equal(540); + }) + + it('should return a default player size', function() { + var bid = { mediaTypes: { + video: { + playerSize: null + } + }} + expect(spec.getPlayerSize(bid)[0]).to.equal(640); + expect(spec.getPlayerSize(bid)[1]).to.equal(440); + }) + }); + + describe('buildRequests', function () { + const valid_bid_requests = [{ + 'bidder': 'cpmstar', + 'params': { + 'placementId': '57' + }, + 'sizes': [[300, 250]], + 'bidId': 'bidId' + }]; + + const bidderRequest = { + refererInfo: { + referer: 'referer', + reachedTop: false, + } + + }; + + it('should produce a valid production request', function () { + var requests = spec.buildRequests(valid_bid_requests, bidderRequest); + expect(requests[0]).to.have.property('method'); + expect(requests[0]).to.have.property('url'); + expect(requests[0]).to.have.property('bidRequest'); + expect(requests[0].url).to.include('//server.cpmstar.com/view.aspx'); + }); + it('should produce a valid staging request', function () { + var stgReq = deepClone(valid_bid_requests); + stgReq[0].params.endpoint = 'staging'; + var requests = spec.buildRequests(stgReq, bidderRequest); + expect(requests[0]).to.have.property('method'); + expect(requests[0]).to.have.property('url'); + expect(requests[0]).to.have.property('bidRequest'); + expect(requests[0].url).to.include('//staging.server.cpmstar.com/view.aspx'); + }); + it('should produce a valid dev request', function () { + var devReq = deepClone(valid_bid_requests); + devReq[0].params.endpoint = 'dev'; + var requests = spec.buildRequests(devReq, bidderRequest); + expect(requests[0]).to.have.property('method'); + expect(requests[0]).to.have.property('url'); + expect(requests[0]).to.have.property('bidRequest'); + expect(requests[0].url).to.include('//dev.server.cpmstar.com/view.aspx'); + }); + }) + + describe('interpretResponse', function () { + const request = { + bidRequest: { + mediaType: 'BANNER' + } + }; + const serverResponse = { + body: [{ + creatives: [{ + cpm: 1, + width: 0, + height: 0, + currency: 'USD', + netRevenue: true, + ttl: 1, + creativeid: '1234', + requestid: '11123', + code: 'no idea', + media: 'banner', + } + ], + }] + }; + + it('should return a valid bidresponse array', function () { + var r = spec.interpretResponse(serverResponse, request) + var c = serverResponse.body[0].creatives[0]; + expect(r[0].length).to.not.equal(0); + expect(r[0].requestId).equal(c.requestid); + expect(r[0].creativeId).equal(c.creativeid); + expect(r[0].cpm).equal(c.cpm); + expect(r[0].width).equal(c.width); + expect(r[0].height).equal(c.height); + expect(r[0].currency).equal(c.currency); + expect(r[0].netRevenue).equal(c.netRevenue); + expect(r[0].ttl).equal(c.ttl); + expect(r[0].ad).equal(c.code); + }); + + it('should return a valid bidresponse array from a non-array-body', function () { + var r = spec.interpretResponse({ body: serverResponse.body[0] }, request) + var c = serverResponse.body[0].creatives[0]; + expect(r[0].length).to.not.equal(0); + expect(r[0].requestId).equal(c.requestid); + expect(r[0].creativeId).equal(c.creativeid); + expect(r[0].cpm).equal(c.cpm); + expect(r[0].width).equal(c.width); + expect(r[0].height).equal(c.height); + expect(r[0].currency).equal(c.currency); + expect(r[0].netRevenue).equal(c.netRevenue); + expect(r[0].ttl).equal(c.ttl); + expect(r[0].ad).equal(c.code); + }); + + it('should return undefined due to an invalid cpm value', function () { + var badServer = deepClone(serverResponse); + badServer.body[0].creatives[0].cpm = 0; + var c = spec.interpretResponse(badServer, request); + expect(c).to.be.undefined; + }); + + it('should return undefined due to a bad response', function () { + var badServer = deepClone(serverResponse); + badServer.body[0].creatives[0].code = null; + var c = spec.interpretResponse(badServer, request); + expect(c).to.be.undefined; + }); + + it('should return a valid response with a dealId', function () { + var dealServer = deepClone(serverResponse); + dealServer.body[0].creatives[0].dealId = 'deal'; + expect(spec.interpretResponse(dealServer, request)[0].dealId).to.equal('deal'); + }); + }); +}); diff --git a/test/spec/modules/criteoBidAdapter_spec.js b/test/spec/modules/criteoBidAdapter_spec.js index 8a5bea97cb8..f85e5957950 100755 --- a/test/spec/modules/criteoBidAdapter_spec.js +++ b/test/spec/modules/criteoBidAdapter_spec.js @@ -1,14 +1,25 @@ import { expect } from 'chai'; -import { cryptoVerify, spec, FAST_BID_PUBKEY } from 'modules/criteoBidAdapter'; +import { tryGetCriteoFastBid, spec, PROFILE_ID_PUBLISHERTAG, ADAPTER_VERSION, PUBLISHER_TAG_URL } from 'modules/criteoBidAdapter'; import { createBid } from 'src/bidfactory'; import CONSTANTS from 'src/constants.json'; import * as utils from 'src/utils'; +import { config } from '../../../src/config'; +import { VIDEO } from '../../../src/mediaTypes'; describe('The Criteo bidding adapter', function () { + let utilsMock; + beforeEach(function () { - // Remove FastBid to avoid side effects. + // Remove FastBid to avoid side effects localStorage.removeItem('criteo_fast_bid'); + utilsMock = sinon.mock(utils); + }); + + afterEach(function() { + global.Criteo = undefined; + utilsMock.restore(); }); + describe('isBidRequestValid', function () { it('should return false when given an invalid bid', function () { const bid = { @@ -51,10 +62,314 @@ describe('The Criteo bidding adapter', function () { const isValid = spec.isBidRequestValid(bid); expect(isValid).to.equal(true); }); + + it('should return true when given a valid video bid request', function () { + expect(spec.isBidRequestValid({ + bidder: 'criteo', + mediaTypes: { + video: { + context: 'instream', + mimes: ['video/mpeg'], + playerSize: [640, 480], + protocols: [5, 6], + maxduration: 30, + api: [1, 2] + } + }, + params: { + networkId: 456, + video: { + skip: 1, + placement: 1, + playbackmethod: 1 + } + }, + })).to.equal(true); + + expect(spec.isBidRequestValid({ + bidder: 'criteo', + mediaTypes: { + video: { + context: 'outstream', + mimes: ['video/mpeg'], + playerSize: [640, 480], + protocols: [5, 6], + maxduration: 30, + api: [1, 2] + } + }, + params: { + networkId: 456, + video: { + skip: 1, + placement: 2, + playbackmethod: 1 + } + }, + })).to.equal(true); + }); + + it('should return false when given an invalid video bid request', function () { + expect(spec.isBidRequestValid({ + bidder: 'criteo', + mediaTypes: { + video: { + mimes: ['video/mpeg'], + playerSize: [640, 480], + protocols: [5, 6], + maxduration: 30, + api: [1, 2] + } + }, + params: { + networkId: 456, + video: { + skip: 1, + placement: 1, + playbackmethod: 1 + } + }, + })).to.equal(false); + + expect(spec.isBidRequestValid({ + bidder: 'criteo', + mediaTypes: { + video: { + context: 'instream', + mimes: ['video/mpeg'], + playerSize: [640, 480], + protocols: [5, 6], + maxduration: 30, + api: [1, 2] + } + }, + params: { + networkId: 456, + video: { + skip: 1, + placement: 2, + playbackmethod: 1 + } + }, + })).to.equal(false); + + expect(spec.isBidRequestValid({ + bidder: 'criteo', + mediaTypes: { + video: { + context: 'outstream', + mimes: ['video/mpeg'], + playerSize: [640, 480], + protocols: [5, 6], + maxduration: 30, + api: [1, 2] + } + }, + params: { + networkId: 456, + video: { + skip: 1, + placement: 1, + playbackmethod: 1 + } + }, + })).to.equal(false); + + expect(spec.isBidRequestValid({ + bidder: 'criteo', + mediaTypes: { + video: { + context: 'adpod', + mimes: ['video/mpeg'], + playerSize: [640, 480], + protocols: [5, 6], + maxduration: 30, + api: [1, 2] + } + }, + params: { + networkId: 456, + video: { + skip: 1, + placement: 1, + playbackmethod: 1 + } + }, + })).to.equal(false); + + expect(spec.isBidRequestValid({ + bidder: 'criteo', + mediaTypes: { + video: { + context: 'instream', + playerSize: [640, 480], + protocols: [5, 6], + maxduration: 30, + api: [1, 2] + } + }, + params: { + networkId: 456, + video: { + skip: 1, + placement: 1, + playbackmethod: 1 + } + }, + })).to.equal(false); + + expect(spec.isBidRequestValid({ + bidder: 'criteo', + mediaTypes: { + video: { + context: 'instream', + mimes: ['video/mpeg'], + protocols: [5, 6], + maxduration: 30, + api: [1, 2] + } + }, + params: { + networkId: 456, + video: { + skip: 1, + placement: 1, + playbackmethod: 1 + } + }, + })).to.equal(false); + + expect(spec.isBidRequestValid({ + bidder: 'criteo', + mediaTypes: { + video: { + context: 'instream', + mimes: ['video/mpeg'], + playerSize: [640, 480], + maxduration: 30, + api: [1, 2] + } + }, + params: { + networkId: 456, + video: { + skip: 1, + placement: 1, + playbackmethod: 1 + } + }, + })).to.equal(false); + + expect(spec.isBidRequestValid({ + bidder: 'criteo', + mediaTypes: { + video: { + context: 'instream', + mimes: ['video/mpeg'], + playerSize: [640, 480], + protocols: [5, 6], + api: [1, 2] + } + }, + params: { + networkId: 456, + video: { + skip: 1, + placement: 1, + playbackmethod: 1 + } + }, + })).to.equal(false); + + expect(spec.isBidRequestValid({ + bidder: 'criteo', + mediaTypes: { + video: { + context: 'instream', + mimes: ['video/mpeg'], + playerSize: [640, 480], + protocols: [5, 6], + maxduration: 30 + } + }, + params: { + networkId: 456, + video: { + skip: 1, + placement: 1, + playbackmethod: 1 + } + }, + })).to.equal(false); + + expect(spec.isBidRequestValid({ + bidder: 'criteo', + mediaTypes: { + video: { + context: 'instream', + mimes: ['video/mpeg'], + playerSize: [640, 480], + protocols: [5, 6], + maxduration: 30, + api: [1, 2] + } + }, + params: { + networkId: 456, + video: { + placement: 1, + playbackmethod: 1 + } + }, + })).to.equal(false); + + expect(spec.isBidRequestValid({ + bidder: 'criteo', + mediaTypes: { + video: { + context: 'instream', + mimes: ['video/mpeg'], + playerSize: [640, 480], + protocols: [5, 6], + maxduration: 30, + api: [1, 2] + } + }, + params: { + networkId: 456, + video: { + skip: 1, + playbackmethod: 1 + } + }, + })).to.equal(false); + + expect(spec.isBidRequestValid({ + bidder: 'criteo', + mediaTypes: { + video: { + context: 'instream', + mimes: ['video/mpeg'], + playerSize: [640, 480], + protocols: [5, 6], + maxduration: 30, + api: [1, 2] + } + }, + params: { + networkId: 456, + video: { + skip: 1, + placement: 1 + } + }, + })).to.equal(false); + }); }); describe('buildRequests', function () { - const bidderRequest = { timeout: 3000, + const bidderRequest = { + timeout: 3000, gdprConsent: { gdprApplies: 1, consentString: 'concentDataString', @@ -66,7 +381,14 @@ describe('The Criteo bidding adapter', function () { }, }; + afterEach(function () { + config.resetConfig(); + }); + it('should properly build a zoneId request', function () { + const publisherUrl = 'https://criteo.com?pbt_debug=1&pbt_nolog=1'; + utilsMock.expects('getTopWindowUrl').withExactArgs().once().returns(publisherUrl); + const bidRequests = [ { bidder: 'criteo', @@ -75,14 +397,17 @@ describe('The Criteo bidding adapter', function () { sizes: [[728, 90]], params: { zoneId: 123, + publisherSubId: '123', + nativeCallback: function() {}, + integrationMode: 'amp' }, }, ]; const request = spec.buildRequests(bidRequests, bidderRequest); - expect(request.url).to.match(/^\/\/bidder\.criteo\.com\/cdb\?profileId=207&av=\d+&wv=[^&]+&cb=\d/); + expect(request.url).to.match(/^\/\/bidder\.criteo\.com\/cdb\?profileId=207&av=\d+&wv=[^&]+&cb=\d+&im=1&debug=1&nolog=1/); expect(request.method).to.equal('POST'); const ortbRequest = request.data; - expect(ortbRequest.publisher.url).to.equal(utils.getTopWindowUrl()); + expect(ortbRequest.publisher.url).to.equal(publisherUrl); expect(ortbRequest.slots).to.have.lengthOf(1); expect(ortbRequest.slots[0].impid).to.equal('bid-123'); expect(ortbRequest.slots[0].transactionid).to.equal('transaction-123'); @@ -112,7 +437,11 @@ describe('The Criteo bidding adapter', function () { bidder: 'criteo', adUnitCode: 'bid-123', transactionId: 'transaction-123', - sizes: [[300, 250], [728, 90]], + mediaTypes: { + banner: { + sizes: [[300, 250], [728, 90]] + } + }, params: { networkId: 456, }, @@ -198,6 +527,116 @@ describe('The Criteo bidding adapter', function () { expect(ortbRequest.gdprConsent.gdprApplies).to.equal(undefined); expect(ortbRequest.gdprConsent.consentGiven).to.equal(undefined); }); + + it('should properly build a video request', function () { + const bidRequests = [ + { + bidder: 'criteo', + adUnitCode: 'bid-123', + transactionId: 'transaction-123', + sizes: [[728, 90]], + mediaTypes: { + video: { + playerSize: [640, 480], + mimes: ['video/mp4', 'video/x-flv'], + maxduration: 30, + api: [1, 2], + protocols: [2, 3] + } + }, + params: { + zoneId: 123, + video: { + skip: 1, + minduration: 5, + startdelay: 5, + playbackmethod: [1, 3], + placement: 2 + } + }, + }, + ]; + const request = spec.buildRequests(bidRequests, bidderRequest); + expect(request.url).to.match(/^\/\/bidder\.criteo\.com\/cdb\?profileId=207&av=\d+&wv=[^&]+&cb=\d/); + expect(request.method).to.equal('POST'); + const ortbRequest = request.data; + expect(ortbRequest.slots[0].video.mimes).to.deep.equal(['video/mp4', 'video/x-flv']); + expect(ortbRequest.slots[0].video.playersizes).to.deep.equal(['640x480']); + expect(ortbRequest.slots[0].video.maxduration).to.equal(30); + expect(ortbRequest.slots[0].video.api).to.deep.equal([1, 2]); + expect(ortbRequest.slots[0].video.protocols).to.deep.equal([2, 3]); + expect(ortbRequest.slots[0].video.skip).to.equal(1); + expect(ortbRequest.slots[0].video.minduration).to.equal(5); + expect(ortbRequest.slots[0].video.startdelay).to.equal(5); + expect(ortbRequest.slots[0].video.playbackmethod).to.deep.equal([1, 3]); + expect(ortbRequest.slots[0].video.placement).to.equal(2); + }); + + it('should properly build a video request with more than one player size', function () { + const bidRequests = [ + { + bidder: 'criteo', + adUnitCode: 'bid-123', + transactionId: 'transaction-123', + sizes: [[728, 90]], + mediaTypes: { + video: { + playerSize: [[640, 480], [800, 600]], + mimes: ['video/mp4', 'video/x-flv'], + maxduration: 30, + api: [1, 2], + protocols: [2, 3] + } + }, + params: { + zoneId: 123, + video: { + skip: 1, + minduration: 5, + startdelay: 5, + playbackmethod: [1, 3], + placement: 2 + } + }, + }, + ]; + const request = spec.buildRequests(bidRequests, bidderRequest); + expect(request.url).to.match(/^\/\/bidder\.criteo\.com\/cdb\?profileId=207&av=\d+&wv=[^&]+&cb=\d/); + expect(request.method).to.equal('POST'); + const ortbRequest = request.data; + expect(ortbRequest.slots[0].video.mimes).to.deep.equal(['video/mp4', 'video/x-flv']); + expect(ortbRequest.slots[0].video.playersizes).to.deep.equal(['640x480', '800x600']); + expect(ortbRequest.slots[0].video.maxduration).to.equal(30); + expect(ortbRequest.slots[0].video.api).to.deep.equal([1, 2]); + expect(ortbRequest.slots[0].video.protocols).to.deep.equal([2, 3]); + expect(ortbRequest.slots[0].video.skip).to.equal(1); + expect(ortbRequest.slots[0].video.minduration).to.equal(5); + expect(ortbRequest.slots[0].video.startdelay).to.equal(5); + expect(ortbRequest.slots[0].video.playbackmethod).to.deep.equal([1, 3]); + expect(ortbRequest.slots[0].video.placement).to.equal(2); + }); + + it('should properly build a request with ceh', function () { + const bidRequests = [ + { + bidder: 'criteo', + adUnitCode: 'bid-123', + transactionId: 'transaction-123', + sizes: [[728, 90]], + params: { + zoneId: 123, + }, + }, + ]; + config.setConfig({ + criteo: { + ceh: 'hashedemail' + } + }); + const request = spec.buildRequests(bidRequests, bidderRequest); + expect(request.data.user).to.not.be.null; + expect(request.data.user.ceh).to.equal('hashedemail'); + }); }); describe('interpretResponse', function () { @@ -217,6 +656,7 @@ describe('The Criteo bidding adapter', function () { creative: 'test-ad', width: 728, height: 90, + dealCode: 'myDealCode', }], }, }; @@ -236,6 +676,7 @@ describe('The Criteo bidding adapter', function () { expect(bids[0].ad).to.equal('test-ad'); expect(bids[0].width).to.equal(728); expect(bids[0].height).to.equal(90); + expect(bids[0].dealId).to.equal('myDealCode'); }); it('should properly parse a bid responsewith with a zoneId', function () { @@ -271,6 +712,39 @@ describe('The Criteo bidding adapter', function () { expect(bids[0].height).to.equal(90); }); + it('should properly parse a bid responsewith with a video', function () { + const response = { + body: { + slots: [{ + impid: 'test-requestId', + bidId: 'abc123', + cpm: 1.23, + displayurl: 'http://test-ad', + width: 728, + height: 90, + zoneid: 123, + video: true + }], + }, + }; + const request = { + bidRequests: [{ + adUnitCode: 'test-requestId', + bidId: 'test-bidId', + params: { + zoneId: 123, + }, + }] + }; + const bids = spec.interpretResponse(response, request); + expect(bids).to.have.lengthOf(1); + expect(bids[0].requestId).to.equal('test-bidId'); + expect(bids[0].adId).to.equal('abc123'); + expect(bids[0].cpm).to.equal(1.23); + expect(bids[0].vastUrl).to.equal('http://test-ad'); + expect(bids[0].mediaType).to.equal(VIDEO); + }); + it('should properly parse a bid responsewith with a zoneId passed as a string', function () { const response = { body: { @@ -337,20 +811,187 @@ describe('The Criteo bidding adapter', function () { }); }); - describe('cryptoVerify', function () { - const TEST_HASH = 'vBeD8Q7GU6lypFbzB07W8hLGj7NL+p7dI9ro2tCxkrmyv0F6stNuoNd75Us33iNKfEoW+cFWypelr6OJPXxki2MXWatRhJuUJZMcK4VBFnxi3Ro+3a0xEfxE4jJm4eGe98iC898M+/YFHfp+fEPEnS6pEyw124ONIFZFrcejpHU='; + describe('tryGetCriteoFastBid', function () { + const VALID_HASH = 'vBeD8Q7GU6lypFbzB07W8hLGj7NL+p7dI9ro2tCxkrmyv0F6stNuoNd75Us33iNKfEoW+cFWypelr6OJPXxki2MXWatRhJuUJZMcK4VBFnxi3Ro+3a0xEfxE4jJm4eGe98iC898M+/YFHfp+fEPEnS6pEyw124ONIFZFrcejpHU='; + const INVALID_HASH = 'invalid'; + const VALID_PUBLISHER_TAG = 'test'; + const INVALID_PUBLISHER_TAG = 'test invalid'; + + const FASTBID_LOCAL_STORAGE_KEY = 'criteo_fast_bid'; + + it('should verify valid hash with valid publisher tag', function () { + localStorage.setItem(FASTBID_LOCAL_STORAGE_KEY, '// Hash: ' + VALID_HASH + '\n' + VALID_PUBLISHER_TAG); + + utilsMock.expects('logInfo').withExactArgs('Using Criteo FastBid').once(); + utilsMock.expects('logWarn').withExactArgs('No hash found in FastBid').never(); + utilsMock.expects('logWarn').withExactArgs('Invalid Criteo FastBid found').never(); + + tryGetCriteoFastBid(); + + expect(localStorage.getItem(FASTBID_LOCAL_STORAGE_KEY)).to.equals('// Hash: ' + VALID_HASH + '\n' + VALID_PUBLISHER_TAG); + utilsMock.verify(); + }); + + it('should verify valid hash with invalid publisher tag', function () { + localStorage.setItem(FASTBID_LOCAL_STORAGE_KEY, '// Hash: ' + VALID_HASH + '\n' + INVALID_PUBLISHER_TAG); + + utilsMock.expects('logInfo').withExactArgs('Using Criteo FastBid').never(); + utilsMock.expects('logWarn').withExactArgs('No hash found in FastBid').never(); + utilsMock.expects('logWarn').withExactArgs('Invalid Criteo FastBid found').once(); + + tryGetCriteoFastBid(); + + expect(localStorage.getItem(FASTBID_LOCAL_STORAGE_KEY)).to.be.null; + utilsMock.verify(); + }); + + it('should verify invalid hash with valid publisher tag', function () { + localStorage.setItem(FASTBID_LOCAL_STORAGE_KEY, '// Hash: ' + INVALID_HASH + '\n' + VALID_PUBLISHER_TAG); + + utilsMock.expects('logInfo').withExactArgs('Using Criteo FastBid').never(); + utilsMock.expects('logWarn').withExactArgs('No hash found in FastBid').never(); + utilsMock.expects('logWarn').withExactArgs('Invalid Criteo FastBid found').once(); + + tryGetCriteoFastBid(); + + expect(localStorage.getItem(FASTBID_LOCAL_STORAGE_KEY)).to.be.null; + utilsMock.verify(); + }); + + it('should verify missing hash', function () { + localStorage.setItem(FASTBID_LOCAL_STORAGE_KEY, VALID_PUBLISHER_TAG); + + utilsMock.expects('logInfo').withExactArgs('Using Criteo FastBid').never(); + utilsMock.expects('logWarn').withExactArgs('No hash found in FastBid').once(); + utilsMock.expects('logWarn').withExactArgs('Invalid Criteo FastBid found').never(); + + tryGetCriteoFastBid(); + + expect(localStorage.getItem(FASTBID_LOCAL_STORAGE_KEY)).to.be.null; + utilsMock.verify(); + }); + }); + + describe('when pubtag prebid adapter is available', function () { + it('should forward response to pubtag when calling interpretResponse', () => { + const response = {}; + const request = {}; + + const adapter = { interpretResponse: function() {} }; + const adapterMock = sinon.mock(adapter); + adapterMock.expects('interpretResponse').withExactArgs(response, request).once().returns('ok'); + const prebidAdapter = { GetAdapter: function() {} }; + const prebidAdapterMock = sinon.mock(prebidAdapter); + prebidAdapterMock.expects('GetAdapter').withExactArgs(request).once().returns(adapter); + + global.Criteo = { + PubTag: { + Adapters: { + Prebid: prebidAdapter + } + } + }; + + expect(spec.interpretResponse(response, request)).equal('ok'); + adapterMock.verify(); + prebidAdapterMock.verify(); + }); + + it('should forward bid to pubtag when calling onBidWon', () => { + const bid = { auctionId: 123 }; + + const adapter = { handleBidWon: function() {} }; + const adapterMock = sinon.mock(adapter); + adapterMock.expects('handleBidWon').withExactArgs(bid).once(); + const prebidAdapter = { GetAdapter: function() {} }; + const prebidAdapterMock = sinon.mock(prebidAdapter); + prebidAdapterMock.expects('GetAdapter').withExactArgs(bid.auctionId).once().returns(adapter); + + global.Criteo = { + PubTag: { + Adapters: { + Prebid: prebidAdapter + } + } + }; + + spec.onBidWon(bid); + adapterMock.verify(); + prebidAdapterMock.verify(); + }); + + it('should forward bid to pubtag when calling onSetTargeting', () => { + const bid = { auctionId: 123 }; + + const adapter = { handleSetTargeting: function() {} }; + const adapterMock = sinon.mock(adapter); + adapterMock.expects('handleSetTargeting').withExactArgs(bid).once(); + const prebidAdapter = { GetAdapter: function() {} }; + const prebidAdapterMock = sinon.mock(prebidAdapter); + prebidAdapterMock.expects('GetAdapter').withExactArgs(bid.auctionId).once().returns(adapter); + + global.Criteo = { + PubTag: { + Adapters: { + Prebid: prebidAdapter + } + } + }; - it('should verify right signature', function () { - expect(cryptoVerify(FAST_BID_PUBKEY, TEST_HASH, 'test')).to.equal(true); + spec.onSetTargeting(bid); + adapterMock.verify(); + prebidAdapterMock.verify(); }); - it('should verify wrong signature', function () { - expect(cryptoVerify(FAST_BID_PUBKEY, TEST_HASH, 'test wrong')).to.equal(false); + it('should forward bid to pubtag when calling onTimeout', () => { + const timeoutData = { auctionId: 123 }; + + const adapter = { handleBidTimeout: function() {} }; + const adapterMock = sinon.mock(adapter); + adapterMock.expects('handleBidTimeout').once(); + const prebidAdapter = { GetAdapter: function() {} }; + const prebidAdapterMock = sinon.mock(prebidAdapter); + prebidAdapterMock.expects('GetAdapter').withExactArgs(timeoutData.auctionId).once().returns(adapter); + + global.Criteo = { + PubTag: { + Adapters: { + Prebid: prebidAdapter + } + } + }; + + spec.onTimeout(timeoutData); + adapterMock.verify(); + prebidAdapterMock.verify(); }); - it('should return undefined with incompatible browsers', function () { - // Here use a null hash to make the call to crypto library fail and simulate a browser failure - expect(cryptoVerify(FAST_BID_PUBKEY, null, 'test')).to.be.false; + it('should return a POST method with url & data from pubtag', () => { + const bidRequests = { }; + const bidderRequest = { }; + + const prebidAdapter = { buildCdbUrl: function() {}, buildCdbRequest: function() {} }; + const prebidAdapterMock = sinon.mock(prebidAdapter); + prebidAdapterMock.expects('buildCdbUrl').once().returns('cdbUrl'); + prebidAdapterMock.expects('buildCdbRequest').once().returns('cdbRequest'); + + const adapters = { Prebid: function() {} }; + const adaptersMock = sinon.mock(adapters); + adaptersMock.expects('Prebid').withExactArgs(PROFILE_ID_PUBLISHERTAG, ADAPTER_VERSION, bidRequests, bidderRequest, '$prebid.version$').once().returns(prebidAdapter); + + global.Criteo = { + PubTag: { + Adapters: adapters + } + }; + + const buildRequestsResult = spec.buildRequests(bidRequests, bidderRequest); + expect(buildRequestsResult.method).equal('POST'); + expect(buildRequestsResult.url).equal('cdbUrl'); + expect(buildRequestsResult.data).equal('cdbRequest'); + + adaptersMock.verify(); + prebidAdapterMock.verify(); }); }); }); diff --git a/test/spec/modules/criteortusIdSystem_spec.js b/test/spec/modules/criteortusIdSystem_spec.js new file mode 100644 index 00000000000..578f14d066d --- /dev/null +++ b/test/spec/modules/criteortusIdSystem_spec.js @@ -0,0 +1,88 @@ +import { criteortusIdSubmodule } from 'modules/criteortusIdSystem'; +import * as utils from 'src/utils'; + +describe('Criteo RTUS', function() { + let xhr; + let requests; + let getCookieStub; + let logErrorStub; + + beforeEach(function () { + xhr = sinon.useFakeXMLHttpRequest(); + requests = []; + xhr.onCreate = request => requests.push(request); + getCookieStub = sinon.stub(utils, 'getCookie'); + logErrorStub = sinon.stub(utils, 'logError'); + }); + + afterEach(function () { + xhr.restore(); + getCookieStub.restore(); + logErrorStub.restore(); + }); + + it('should log error when configParams are not passed', function() { + criteortusIdSubmodule.getId(); + expect(logErrorStub.calledOnce).to.be.true; + }) + + it('should call criteo endpoint to get user id', function() { + getCookieStub.returns(null); + let configParams = { + clientIdentifier: { + 'sampleBidder': 1 + } + } + + let response = { 'status': 'ok', 'userid': 'sample-userid' } + let callBackSpy = sinon.spy(); + let submoduleCallback = criteortusIdSubmodule.getId(configParams); + submoduleCallback(callBackSpy); + requests[0].respond( + 200, + { 'Content-Type': 'text/plain' }, + JSON.stringify(response) + ); + expect(callBackSpy.calledOnce).to.be.true; + expect(callBackSpy.calledWith({'sampleBidder': response})).to.be.true; + }) + + it('should get uid from cookie and not call endpoint', function() { + let response = {'appnexus': {'status': 'ok', 'userid': 'sample-userid'}} + getCookieStub.returns(JSON.stringify(response)); + let configParams = { + clientIdentifier: { + 'sampleBidder': 1 + } + } + let uid = criteortusIdSubmodule.getId(configParams); + expect(requests.length).to.equal(0); + }) + + it('should call criteo endpoint for multiple bidders', function() { + getCookieStub.returns(null); + let configParams = { + clientIdentifier: { + 'sampleBidder': 1, + 'sampleBidder2': 2 + } + } + + let response = { 'status': 'ok', 'userid': 'sample-userid' } + let callBackSpy = sinon.spy(); + let submoduleCallback = criteortusIdSubmodule.getId(configParams); + submoduleCallback(callBackSpy); + requests[0].respond( + 200, + { 'Content-Type': 'text/plain' }, + JSON.stringify(response) + ); + expect(callBackSpy.calledOnce).to.be.false; + requests[1].respond( + 200, + { 'Content-Type': 'text/plain' }, + JSON.stringify(response) + ); + expect(callBackSpy.calledOnce).to.be.true; + }) +}); diff --git a/test/spec/modules/currency_spec.js b/test/spec/modules/currency_spec.js index 9fb32102749..98f51b72251 100644 --- a/test/spec/modules/currency_spec.js +++ b/test/spec/modules/currency_spec.js @@ -191,6 +191,34 @@ describe('currency', function () { expect(innerBid.getCpmInNewCurrency('JPY')).to.equal('100.000'); }); + it('uses rates specified in json when provided and consider boosted bid', function () { + setConfig({ + adServerCurrency: 'USD', + rates: { + USD: { + JPY: 100 + } + } + }); + + var bid = { cpm: 100, currency: 'JPY', bidder: 'rubicon' }; + var innerBid; + + addBidResponseHook(function(adCodeId, bid) { + innerBid = bid; + }, 'elementId', bid); + + expect(innerBid.cpm).to.equal('1.0000'); + expect(typeof innerBid.getCpmInNewCurrency).to.equal('function'); + expect(innerBid.getCpmInNewCurrency('JPY')).to.equal('100.000'); + + // Boosting the bid now + innerBid.cpm *= 10; + expect(innerBid.cpm).to.equal(10.0000); + expect(typeof innerBid.getCpmInNewCurrency).to.equal('function'); + expect(innerBid.getCpmInNewCurrency('JPY')).to.equal('1000.000'); + }); + it('uses default rates when currency file fails to load', function () { setConfig({}); diff --git a/test/spec/modules/datablocksBidAdapter_spec.js b/test/spec/modules/datablocksBidAdapter_spec.js new file mode 100644 index 00000000000..07989b86535 --- /dev/null +++ b/test/spec/modules/datablocksBidAdapter_spec.js @@ -0,0 +1,287 @@ +import { expect } from 'chai'; +import { spec } from '../../../modules/datablocksBidAdapter'; + +let bid = { + bidId: '2dd581a2b6281d', + bidder: 'datablocks', + bidderRequestId: '145e1d6a7837c9', + params: { + sourceId: 7560, + host: 'v5demo.datablocks.net' + }, + adUnitCode: '/19968336/header-bid-tag-0', + auctionId: '74f78609-a92d-4cf1-869f-1b244bbfb5d2', + mediaTypes: { + banner: { + sizes: [ + [300, 250] + ] + } + }, + sizes: [ + [300, 250] + ], + transactionId: '1ccbee15-f6f6-46ce-8998-58fe5542e8e1' +}; + +let bid2 = { + bidId: '2dd581a2b624324g', + bidder: 'datablocks', + bidderRequestId: '145e1d6a7837543', + params: { + sourceId: 7560, + host: 'v5demo.datablocks.net' + }, + adUnitCode: '/19968336/header-bid-tag-0', + auctionId: '74f78609-a92d-4cf1-869f-1b244bbfb5d2', + mediaTypes: { + banner: { + sizes: + [728, 90] + } + }, + transactionId: '1ccbee15-f6f6-46ce-8998-58fe55425432' +}; + +let nativeBid = { + adUnitCode: '/19968336/header-bid-tag-0', + auctionId: '160c78a4-f808-410f-b682-d8728f3a79ee', + bidId: '332045ee374a99', + bidder: 'datablocks', + bidderRequestId: '15d9012765e36c', + mediaTypes: { + native: { + title: { + required: true + }, + body: { + required: true + }, + image: { + required: true + } + } + }, + nativeParams: { + title: { + required: true + }, + body: { + required: true, + data: { + len: 250 + } + }, + image: { + required: true, + sizes: [728, 90] + } + }, + params: { + sourceId: 7560, + host: 'v5demo.datablocks.net' + }, + transactionId: '0a4e9788-4def-4b94-bc25-564d7cac99f6' +} + +const bidderRequest = { + auctionId: '8bfef1be-d3ac-4d18-8859-754c7b4cf017', + auctionStart: Date.now(), + biddeCode: 'datablocks', + bidderRequestId: '10c47a5fc3c41', + bids: [bid, bid2, nativeBid], + refererInfo: { + numIframes: 0, + reachedTop: true, + referer: 'http://v5demo.datablocks.net/test', + stack: ['http://v5demo.datablocks.net/test'] + }, + start: Date.now(), + timeout: 10000 +}; + +let resObject = { + body: { + id: '10c47a5fc3c41', + bidid: '166895245-28-11347-1', + seatbid: [{ + seat: '7560', + bid: [{ + id: '1090738570', + impid: '2966b257c81d27', + price: 24.000000, + adm: 'RON', + cid: '55', + adid: '177654', + crid: '177656', + cat: [], + api: [], + w: 300, + h: 250 + }, { + id: '1090738571', + impid: '2966b257c81d28', + price: 24.000000, + adm: 'RON', + cid: '55', + adid: '177654', + crid: '177656', + cat: [], + api: [], + w: 728, + h: 90 + }, { + id: '1090738570', + impid: '15d9012765e36c', + price: 24.000000, + adm: '{"native":{"ver":"1.2","assets":[{"id":1,"required":1,"title":{"text":"Example Title"}},{"id":2,"required":1,"data":{"value":"Example Body"}},{"id":3,"required":1,"img":{"url":"http://example.image.com/"}}],"link":{"url":"http://click.example.com/c/264597/?fcid=29699699045816"},"imptrackers":["http://impression.example.com/i/264597/?fcid=29699699045816"]}}', + cid: '132145', + adid: '154321', + crid: '177432', + cat: [], + api: [] + }] + }], + cur: 'USD', + ext: {} + } +}; +let bidRequest = { + method: 'POST', + url: '//v5demo.datablocks.net/search/?sid=7560', + options: { + withCredentials: false + }, + data: { + device: { + ip: 'peer', + ua: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_0) Ap…ML, like Gecko) Chrome/73.0.3683.86 Safari/537.36', + js: 1, + language: 'en' + }, + id: '10c47a5fc3c41', + imp: [{ + banner: { w: 300, h: 250 }, + id: '2966b257c81d27', + secure: false, + tagid: '/19968336/header-bid-tag-0' + }, { + banner: { w: 728, h: 90 }, + id: '2966b257c81d28', + secure: false, + tagid: '/19968336/header-bid-tag-0' + }, { + id: '15d9012765e36c', + native: {request: '{"native":{"assets":[{"id":"1","required":true,"title":{"len":140}},{"id":"2","required":true,"data":{"type":2}},{"id":"3","img":{"w":728,"h":90,"type":3}}]}}'}, + secure: false, + tagid: '/19968336/header-bid-tag-0' + }], + site: { + domain: '', + id: 'blank', + page: 'http://v5demo.datablocks.net/test' + } + } +} + +describe('DatablocksAdapter', function() { + describe('isBidRequestValid', function() { + it('Should return true when sourceId and Host are set', function() { + expect(spec.isBidRequestValid(bid)).to.be.true; + }); + it('Should return false when host/sourceId is not set', function() { + let moddedBid = Object.assign({}, bid); + delete moddedBid.params.sourceId; + delete moddedBid.params.host; + expect(spec.isBidRequestValid(bid)).to.be.false; + }); + }); + + describe('buildRequests', function() { + let requests = spec.buildRequests([bid, bid2, nativeBid], bidderRequest); + it('Creates an array of request objects', function() { + expect(requests).to.be.an('array').that.is.not.empty; + }); + + requests.forEach(request => { + expect(request).to.exist; + it('Returns POST method', function() { + expect(request.method).to.exist; + expect(request.method).to.equal('POST'); + }); + it('Returns valid URL', function() { + expect(request.url).to.exist; + expect(request.url).to.equal('//v5demo.datablocks.net/search/?sid=7560'); + }); + + it('Should be a valid openRTB request', function() { + let data = request.data; + expect(data).to.be.an('object'); + expect(data).to.have.all.keys('device', 'imp', 'site', 'id'); + expect(data.id).to.be.a('string'); + + let imps = data['imp']; + imps.forEach((imp, index) => { + let curBid = bidderRequest.bids[index]; + if (imp.banner) { + expect(imp).to.have.all.keys('banner', 'id', 'secure', 'tagid'); + expect(imp.banner).to.be.a('object'); + } else if (imp.native) { + expect(imp).to.have.all.keys('native', 'id', 'secure', 'tagid'); + expect(imp.native).to.have.all.keys('request'); + expect(imp.native.request).to.be.a('string'); + let native = JSON.parse(imp.native.request); + expect(native).to.be.a('object'); + } else { + expect(true).to.equal(false); + } + + expect(imp.id).to.be.a('string'); + expect(imp.id).to.equal(curBid.bidId); + expect(imp.tagid).to.be.a('string'); + expect(imp.tagid).to.equal(curBid.adUnitCode); + expect(imp.secure).to.equal(false); + }) + + expect(data.device.ip).to.equal('peer'); + }); + }) + + it('Returns empty data if no valid requests are passed', function() { + let request = spec.buildRequests([]); + expect(request).to.be.an('array').that.is.empty; + }); + }); + describe('interpretResponse', function() { + let serverResponses = spec.interpretResponse(resObject, bidRequest); + it('Returns an array of valid server responses if response object is valid', function() { + expect(serverResponses).to.be.an('array').that.is.not.empty; + for (let i = 0; i < serverResponses.length; i++) { + let dataItem = serverResponses[i]; + expect(Object.keys(dataItem)).to.include('cpm', 'ttl', 'creativeId', + 'netRevenue', 'currency', 'mediaType', 'requestId'); + expect(dataItem.requestId).to.be.a('string'); + expect(dataItem.cpm).to.be.a('number'); + expect(dataItem.ttl).to.be.a('number'); + expect(dataItem.creativeId).to.be.a('string'); + expect(dataItem.netRevenue).to.be.a('boolean'); + expect(dataItem.currency).to.be.a('string'); + expect(dataItem.mediaType).to.be.a('string'); + + if (dataItem.mediaType == 'banner') { + expect(dataItem.ad).to.be.a('string'); + expect(dataItem.width).to.be.a('number'); + expect(dataItem.height).to.be.a('number'); + } else if (dataItem.mediaType == 'native') { + expect(dataItem.native.title).to.be.a('string'); + expect(dataItem.native.body).to.be.a('string'); + expect(dataItem.native.clickUrl).to.be.a('string'); + } + } + it('Returns an empty array if invalid response is passed', function() { + serverResponses = spec.interpretResponse('invalid_response'); + expect(serverResponses).to.be.an('array').that.is.empty; + }); + }); + }); +}); diff --git a/test/spec/modules/dfpAdServerVideo_spec.js b/test/spec/modules/dfpAdServerVideo_spec.js index 30cf91c2e17..bd417189aef 100644 --- a/test/spec/modules/dfpAdServerVideo_spec.js +++ b/test/spec/modules/dfpAdServerVideo_spec.js @@ -1,12 +1,14 @@ import { expect } from 'chai'; import parse from 'url-parse'; -import buildDfpVideoUrl from 'modules/dfpAdServerVideo'; +import { buildDfpVideoUrl, buildAdpodVideoUrl } from 'modules/dfpAdServerVideo'; import { parseQS } from 'src/url'; import adUnit from 'test/fixtures/video/adUnit'; import * as utils from 'src/utils'; import { config } from 'src/config'; import { targeting } from 'src/targeting'; +import { auctionManager } from 'src/auctionManager'; +import * as adpod from 'modules/adpod'; const bid = { videoCacheKey: 'abc', @@ -296,4 +298,246 @@ describe('The DFP video support module', function () { expect(customParams).to.have.property('hb_uuid', 'def'); expect(customParams).to.have.property('hb_cache_id', 'def'); }); + + describe('adpod unit tests', function () { + let amStub; + let amGetAdUnitsStub; + let xhr; + let requests; + + before(function () { + let adUnits = [{ + code: 'adUnitCode-1', + mediaTypes: { + video: { + context: 'adpod', + playerSize: [640, 480], + adPodDurationSec: 60, + durationRangeSec: [15, 30], + requireExactDuration: true + } + }, + bids: [ + { + bidder: 'appnexus', + params: { + placementId: 14542875, + } + } + ] + }]; + + amGetAdUnitsStub = sinon.stub(auctionManager, 'getAdUnits'); + amGetAdUnitsStub.returns(adUnits); + amStub = sinon.stub(auctionManager, 'getBidsReceived'); + }); + + beforeEach(function () { + xhr = sinon.useFakeXMLHttpRequest(); + requests = []; + xhr.onCreate = request => requests.push(request); + + config.setConfig({ + adpod: { + brandCategoryExclusion: true, + deferCaching: false + } + }); + }) + + afterEach(function() { + config.resetConfig(); + xhr.restore(); + }); + + after(function () { + amGetAdUnitsStub.restore(); + amStub.restore(); + }); + + it('should return masterTag url', function() { + amStub.returns(getBidsReceived()); + let url; + parse(buildAdpodVideoUrl({ + code: 'adUnitCode-1', + callback: handleResponse, + params: { + 'iu': 'my/adUnit', + 'description_url': 'someUrl.com', + } + })); + + function handleResponse(err, masterTag) { + if (err) { + return; + } + url = parse(masterTag); + + expect(url.protocol).to.equal('https:'); + expect(url.host).to.equal('pubads.g.doubleclick.net'); + + const queryParams = parseQS(url.query); + expect(queryParams).to.have.property('correlator'); + expect(queryParams).to.have.property('description_url', 'someUrl.com'); + expect(queryParams).to.have.property('env', 'vp'); + expect(queryParams).to.have.property('gdfp_req', '1'); + expect(queryParams).to.have.property('iu', 'my/adUnit'); + expect(queryParams).to.have.property('output', 'xml_vast3'); + expect(queryParams).to.have.property('sz', '640x480'); + expect(queryParams).to.have.property('unviewed_position_start', '1'); + expect(queryParams).to.have.property('url'); + expect(queryParams).to.have.property('cust_params'); + + const custParams = parseQS(decodeURIComponent(queryParams.cust_params)); + expect(custParams).to.have.property('hb_cache_id', '123'); + expect(custParams).to.have.property('hb_pb_cat_dur', '15.00_395_15s,15.00_406_30s,10.00_395_15s'); + } + }); + + it('should return masterTag url with correct custom params when brandCategoryExclusion is false', function() { + config.setConfig({ + adpod: { + brandCategoryExclusion: false, + } + }); + function getBids() { + let bids = [ + createBid(10, 'adUnitCode-1', 15, '10.00_15s', '123', '395', '10.00'), + createBid(15, 'adUnitCode-1', 15, '15.00_15s', '123', '395', '15.00'), + createBid(25, 'adUnitCode-1', 30, '15.00_30s', '123', '406', '25.00'), + ]; + bids.forEach((bid) => { + delete bid.meta; + }); + return bids; + } + amStub.returns(getBids()); + let url; + parse(buildAdpodVideoUrl({ + code: 'adUnitCode-1', + callback: handleResponse, + params: { + 'iu': 'my/adUnit', + 'description_url': 'someUrl.com', + } + })); + + function handleResponse(err, masterTag) { + if (err) { + return; + } + url = parse(masterTag); + expect(url.protocol).to.equal('https:'); + expect(url.host).to.equal('pubads.g.doubleclick.net'); + + const queryParams = parseQS(url.query); + expect(queryParams).to.have.property('correlator'); + expect(queryParams).to.have.property('description_url', 'someUrl.com'); + expect(queryParams).to.have.property('env', 'vp'); + expect(queryParams).to.have.property('gdfp_req', '1'); + expect(queryParams).to.have.property('iu', 'my/adUnit'); + expect(queryParams).to.have.property('output', 'xml_vast3'); + expect(queryParams).to.have.property('sz', '640x480'); + expect(queryParams).to.have.property('unviewed_position_start', '1'); + expect(queryParams).to.have.property('url'); + expect(queryParams).to.have.property('cust_params'); + + const custParams = parseQS(decodeURIComponent(queryParams.cust_params)); + expect(custParams).to.have.property('hb_cache_id', '123'); + expect(custParams).to.have.property('hb_pb_cat_dur', '10.00_15s,15.00_15s,15.00_30s'); + } + }); + + it('should handle error when cache fails', function() { + config.setConfig({ + adpod: { + brandCategoryExclusion: true, + deferCaching: true + } + }); + amStub.returns(getBidsReceived()); + + parse(buildAdpodVideoUrl({ + code: 'adUnitCode-1', + callback: handleResponse, + params: { + 'iu': 'my/adUnit', + 'description_url': 'someUrl.com', + } + })); + + requests[0].respond(503, { + 'Content-Type': 'plain/text', + }, 'The server could not save anything at the moment.'); + + function handleResponse(err, masterTag) { + expect(masterTag).to.be.null; + expect(err).to.be.an('error'); + } + }); + }) }); + +function getBidsReceived() { + return [ + createBid(10, 'adUnitCode-1', 15, '10.00_395_15s', '123', '395', '10.00'), + createBid(15, 'adUnitCode-1', 15, '15.00_395_15s', '123', '395', '15.00'), + createBid(25, 'adUnitCode-1', 30, '15.00_406_30s', '123', '406', '25.00'), + ] +} + +function createBid(cpm, adUnitCode, durationBucket, priceIndustryDuration, uuid, label, hbpb) { + return { + 'bidderCode': 'appnexus', + 'width': 640, + 'height': 360, + 'statusMessage': 'Bid available', + 'adId': '28f24ced14586c', + 'mediaType': 'video', + 'source': 'client', + 'requestId': '28f24ced14586c', + 'cpm': cpm, + 'creativeId': 97517771, + 'currency': 'USD', + 'netRevenue': true, + 'ttl': 3600, + 'adUnitCode': adUnitCode, + 'video': { + 'context': 'adpod', + 'durationBucket': durationBucket + }, + 'appnexus': { + 'buyerMemberId': 9325 + }, + 'vastUrl': 'http://some-vast-url.com', + 'vastImpUrl': 'http://some-vast-imp-url.com', + 'auctionId': 'ec266b31-d652-49c5-8295-e83fafe5532b', + 'responseTimestamp': 1548442460888, + 'requestTimestamp': 1548442460827, + 'bidder': 'appnexus', + 'timeToRespond': 61, + 'pbLg': '5.00', + 'pbMg': '5.00', + 'pbHg': '5.00', + 'pbAg': '5.00', + 'pbDg': '5.00', + 'pbCg': '', + 'size': '640x360', + 'adserverTargeting': { + 'hb_bidder': 'appnexus', + 'hb_adid': '28f24ced14586c', + 'hb_pb': hbpb, + 'hb_size': '640x360', + 'hb_source': 'client', + 'hb_format': 'video', + 'hb_pb_cat_dur': priceIndustryDuration, + 'hb_cache_id': uuid + }, + 'customCacheKey': `${priceIndustryDuration}_${uuid}`, + 'meta': { + 'iabSubCatId': 'iab-1', + 'adServerCatId': label + }, + 'videoCacheKey': '4cf395af-8fee-4960-af0e-88d44e399f14' + } +} diff --git a/test/spec/modules/digitrustIdSystem_spec.js b/test/spec/modules/digitrustIdSystem_spec.js new file mode 100644 index 00000000000..55035bc4b4e --- /dev/null +++ b/test/spec/modules/digitrustIdSystem_spec.js @@ -0,0 +1,50 @@ +import { + digiTrustIdSubmodule, + surfaceTestHook +} from 'modules/digiTrustIdSystem'; + +let assert = require('chai').assert; +let expect = require('chai').expect; + +var testHook = null; + +describe('DigiTrust Id System', function () { + it('Should create the test hook', function (done) { + testHook = surfaceTestHook(); + assert.isNotNull(testHook, 'The test hook failed to surface'); + var conf = { + init: { + member: 'unit_test', + site: 'foo' + }, + callback: function (result) { + } + }; + testHook.initDigitrustFacade(conf); + window.DigiTrust.getUser(conf); + expect(window.DigiTrust).to.exist; + expect(window.DigiTrust.isMock).to.be.true; + done(); + }); + + it('Should report as client', function (done) { + delete window.DigiTrust; + testHook = surfaceTestHook(); + + var conf = { + init: { + member: 'unit_test', + site: 'foo' + }, + callback: function (result) { + expect(window.DigiTrust).to.exist; + expect(result).to.exist; + expect(window.DigiTrust.isMock).to.be.true; + } + }; + testHook.initDigitrustFacade(conf); + expect(window.DigiTrust).to.exist; + expect(window.DigiTrust.isClient).to.be.true; + done(); + }); +}); diff --git a/test/spec/modules/emoteevBidAdapter_spec.js b/test/spec/modules/emoteevBidAdapter_spec.js index a5f5c439e6f..aa97b58ec38 100644 --- a/test/spec/modules/emoteevBidAdapter_spec.js +++ b/test/spec/modules/emoteevBidAdapter_spec.js @@ -1,26 +1,56 @@ -import {expect} from 'chai'; import { - AK_PBJS_VERSION, - EMOTEEV_BASE_URL, - EMOTEEV_BASE_URL_STAGING, - emoteevDebug, - emoteevEnv, - emoteevOverrides, - akUrl, + assert, expect +} from 'chai'; +import { + ADAPTER_VERSION, + DOMAIN, + DOMAIN_DEVELOPMENT, + DOMAIN_STAGING, + domain, + BIDDER_PATH, + bidderUrl, + buildRequests, conformBidRequest, DEFAULT_ENV, - ENDPOINT_PATH, - endpointUrl, + DEVELOPMENT, + EVENTS_PATH, + eventsUrl, + FOOTER, + gdprConsent, + getDeviceDimensions, + getDeviceInfo, + getDocumentDimensions, + getUserSyncs, + getViewDimensions, + IN_CONTENT, + interpretResponse, + isBidRequestValid, + ON_ADAPTER_CALLED, + ON_BID_WON, + ON_BIDDER_TIMEOUT, + onBidWon, + onAdapterCalled, + onTimeout, + OVERLAY, PRODUCTION, + requestsPayload, + resolveDebug, + resolveEnv, spec, STAGING, - USER_SYNC_IFRAME_URL_PATH, - USER_SYNC_IMAGE_URL_PATH, + USER_SYNC_IFRAME_PATH, + USER_SYNC_IMAGE_PATH, userSyncIframeUrl, userSyncImageUrl, + validateSizes, + validateContext, + validateExternalId, + VENDOR_ID, + WALLPAPER, } from 'modules/emoteevBidAdapter'; -import {newBidder} from 'src/adapters/bidderFactory'; -import {config} from 'src/config'; +import * as url from '../../../src/url'; +import * as utils from '../../../src/utils'; +import {config} from '../../../src/config'; const cannedValidBidRequests = [{ adUnitCode: '/19968336/header-bid-tag-1', @@ -30,7 +60,11 @@ const cannedValidBidRequests = [{ bidder: 'emoteev', bidderRequestId: '1203b39fecc6a5', crumbs: {pubcid: 'f3371d16-4e8b-42b5-a770-7e5be1fdf03d'}, - params: {adSpaceId: 5084}, + params: { + adSpaceId: 5084, + context: IN_CONTENT, + externalId: 42 + }, sizes: [[300, 250], [250, 300], [300, 600]], transactionId: '58dbd732-7a39-45f1-b23e-1c24051a941c', }]; @@ -48,7 +82,11 @@ const cannedBidderRequest = { stack: ['http://localhost:9999/integrationExamples/gpt/hello_world_emoteev.html'] }, start: 1544200012839, - timeout: 3000 + timeout: 3000, + gdprConsent: { + gdprApplies: true, + vendorData: {vendorConsents: {[VENDOR_ID]: true}}, + } }; const serverResponse = { @@ -68,108 +106,15 @@ const serverResponse = }; describe('emoteevBidAdapter', function () { - const adapter = newBidder(spec); - - describe('inherited functions', function () { - it('exists and is a function', function () { - expect(adapter.callBids).to.exist.and.to.be.a('function'); - }); - }); - - describe('conformBidRequest', function () { - it('returns a bid-request', function () { - expect(conformBidRequest(cannedValidBidRequests[0])).to.deep.equal({ - params: cannedValidBidRequests[0].params, - crumbs: cannedValidBidRequests[0].crumbs, - sizes: cannedValidBidRequests[0].sizes, - bidId: cannedValidBidRequests[0].bidId, - bidderRequestId: cannedValidBidRequests[0].bidderRequestId, - }); - }) - }); - - describe('emoteevDebug', function () { - expect(emoteevDebug(null, null)).to.deep.equal(false) - }); - describe('emoteevDebug', function () { - expect(emoteevDebug(null, true)).to.deep.equal(true) - }); - describe('emoteevDebug', function () { - expect(emoteevDebug(JSON.stringify(true), null)).to.deep.equal(true) - }); - - describe('emoteevEnv', function () { - expect(emoteevEnv(null, null)).to.deep.equal(DEFAULT_ENV) - }); - describe('emoteevEnv', function () { - expect(emoteevEnv(null, STAGING)).to.deep.equal(STAGING) - }); - describe('emoteevEnv', function () { - expect(emoteevEnv(STAGING, null)).to.deep.equal(STAGING) - }); - - describe('emoteevOverrides', function () { - expect(emoteevOverrides(null, null)).to.deep.equal({}) - }); - describe('emoteevOverrides', function () { - expect(emoteevOverrides(JSON.stringify({a: 1}), null)).to.deep.equal({a: 1}) - }); - describe('emoteevOverrides', function () { - expect(emoteevOverrides('incorrect', null)).to.deep.equal({}) - }); // expect no exception - describe('emoteevOverrides', function () { - expect(emoteevOverrides(null, {a: 1})).to.deep.equal({a: 1}) - }); - - describe('akUrl', function () { - expect(akUrl(null)).to.deep.equal(EMOTEEV_BASE_URL) - }); - describe('akUrl', function () { - expect(akUrl('anything')).to.deep.equal(EMOTEEV_BASE_URL) - }); - describe('akUrl', function () { - expect(akUrl(STAGING)).to.deep.equal(EMOTEEV_BASE_URL_STAGING) - }); - describe('akUrl', function () { - expect(akUrl('production')).to.deep.equal(EMOTEEV_BASE_URL) - }); - - describe('endpointUrl', function () { - expect(endpointUrl(null, null)).to.deep.equal(EMOTEEV_BASE_URL.concat(ENDPOINT_PATH)) - }); - describe('endpointUrl', function () { - expect(endpointUrl(null, STAGING)).to.deep.equal(EMOTEEV_BASE_URL_STAGING.concat(ENDPOINT_PATH)) - }); - describe('endpointUrl', function () { - expect(endpointUrl(STAGING, null)).to.deep.equal(EMOTEEV_BASE_URL_STAGING.concat(ENDPOINT_PATH)) - }); - - describe('userSyncIframeUrl', function () { - expect(userSyncIframeUrl(null, null)).to.deep.equal(EMOTEEV_BASE_URL.concat(USER_SYNC_IFRAME_URL_PATH)) - }); - describe('userSyncIframeUrl', function () { - expect(userSyncIframeUrl(null, STAGING)).to.deep.equal(EMOTEEV_BASE_URL_STAGING.concat(USER_SYNC_IFRAME_URL_PATH)) - }); - describe('userSyncIframeUrl', function () { - expect(userSyncIframeUrl(STAGING, null)).to.deep.equal(EMOTEEV_BASE_URL_STAGING.concat(USER_SYNC_IFRAME_URL_PATH)) - }); - - describe('userSyncImageUrl', function () { - expect(userSyncImageUrl(null, null)).to.deep.equal(EMOTEEV_BASE_URL.concat(USER_SYNC_IMAGE_URL_PATH)) - }); - describe('userSyncImageUrl', function () { - expect(userSyncImageUrl(null, STAGING)).to.deep.equal(EMOTEEV_BASE_URL_STAGING.concat(USER_SYNC_IMAGE_URL_PATH)) - }); - describe('userSyncImageUrl', function () { - expect(userSyncImageUrl(STAGING, null)).to.deep.equal(EMOTEEV_BASE_URL_STAGING.concat(USER_SYNC_IMAGE_URL_PATH)) - }); - describe('isBidRequestValid', function () { - it('should return true when required params found', function () { + it('should return true when valid', function () { const validBid = { bidder: 'emoteev', + bidId: '23a45b4e3', params: { adSpaceId: 12345, + context: IN_CONTENT, + externalId: 42 }, mediaTypes: { banner: { @@ -177,14 +122,19 @@ describe('emoteevBidAdapter', function () { } }, }; - expect(spec.isBidRequestValid(validBid)).to.equal(true); + expect(isBidRequestValid(validBid)).to.equal(true); + + expect(spec.isBidRequestValid(validBid)).to.exist.and.to.be.a('boolean'); + expect(spec.isBidRequestValid({})).to.exist.and.to.be.a('boolean'); }); it('should return false when required params are invalid', function () { - expect(spec.isBidRequestValid({ + expect(isBidRequestValid({ bidder: '', // invalid bidder params: { adSpaceId: 12345, + context: IN_CONTENT, + externalId: 42 }, mediaTypes: { banner: { @@ -192,10 +142,12 @@ describe('emoteevBidAdapter', function () { } }, })).to.equal(false); - expect(spec.isBidRequestValid({ + expect(isBidRequestValid({ bidder: 'emoteev', params: { adSpaceId: '', // invalid adSpaceId + context: IN_CONTENT, + externalId: 42 }, mediaTypes: { banner: { @@ -203,10 +155,38 @@ describe('emoteevBidAdapter', function () { } }, })).to.equal(false); - expect(spec.isBidRequestValid({ + expect(isBidRequestValid({ bidder: 'emoteev', params: { adSpaceId: 12345, + context: 'something', // invalid context + externalId: 42 + }, + mediaTypes: { + banner: { + sizes: [[750, 200]] + } + }, + })).to.equal(false); + expect(isBidRequestValid({ + bidder: 'emoteev', + params: { + adSpaceId: 12345, + context: IN_CONTENT, + externalId: 'lol' // invalid externalId + }, + mediaTypes: { + banner: { + sizes: [[750, 200]] + } + }, + })).to.equal(false); + expect(isBidRequestValid({ + bidder: 'emoteev', + params: { + adSpaceId: 12345, + context: IN_CONTENT, + externalId: 42 }, mediaTypes: { banner: { @@ -219,131 +199,668 @@ describe('emoteevBidAdapter', function () { describe('buildRequests', function () { const + env = DEFAULT_ENV, + debug = true, currency = 'EUR', - emoteevEnv = STAGING, - emoteevDebug = true, - emoteevOverrides = { - iAmOverride: 'iAmOverride' - }; - config.setConfig({ // asynchronous - currency, - emoteev: { - env: STAGING, - debug: emoteevDebug, - overrides: emoteevOverrides - } - }); + request = buildRequests(env, debug, currency, cannedValidBidRequests, cannedBidderRequest); - config.getConfig('emoteev', function () { - const request = spec.buildRequests(cannedValidBidRequests, cannedBidderRequest); - - it('creates a request object with correct method, url and data', function () { - expect(request).to.exist.and.have.all.keys( - 'method', - 'url', - 'data', - ); - expect(request.method).to.equal('POST'); - expect(request.url).to.equal(endpointUrl(emoteevEnv, emoteevEnv)); - - let requestData = JSON.parse(request.data); - expect(requestData).to.exist.and.have.all.keys( - 'akPbjsVersion', - 'bidRequests', - 'currency', - 'debug', - 'iAmOverride', - 'language', - 'refererInfo', - 'deviceInfo', - 'userAgent', - ); - - expect(requestData.bidRequests[0]).to.exist.and.have.all.keys( - 'params', - 'crumbs', - 'sizes', - 'bidId', - 'bidderRequestId', - ); - - expect(requestData.akPbjsVersion).to.deep.equal(AK_PBJS_VERSION); - expect(requestData.bidRequests[0].params).to.deep.equal(cannedValidBidRequests[0].params); - expect(requestData.bidRequests[0].crumbs).to.deep.equal(cannedValidBidRequests[0].crumbs); - expect(requestData.bidRequests[0].mediaTypes).to.deep.equal(cannedValidBidRequests[0].mediaTypes); - expect(requestData.bidRequests[0].bidId).to.deep.equal(cannedValidBidRequests[0].bidId); - expect(requestData.bidRequests[0].bidderRequestId).to.deep.equal(cannedValidBidRequests[0].bidderRequestId); - expect(requestData.currency).to.deep.equal(currency); - expect(requestData.debug).to.deep.equal(emoteevDebug); - expect(requestData.iAmOverride).to.deep.equal('iAmOverride'); - expect(requestData.language).to.deep.equal(navigator.language); - expect(requestData.deviceInfo).to.exist.and.have.all.keys( - 'browserWidth', - 'browserHeight', - 'deviceWidth', - 'deviceHeight', - 'documentWidth', - 'documentHeight', - 'webGL', - ); - expect(requestData.userAgent).to.deep.equal(navigator.userAgent); - }); - }); + expect(request).to.exist.and.have.all.keys( + 'method', + 'url', + 'data', + ); + + expect(request.method).to.equal('POST'); + expect(request.url).to.equal(bidderUrl(env)); + + expect(spec.buildRequests(cannedValidBidRequests, cannedBidderRequest)).to.exist.and.to.be.an('object'); }); describe('interpretResponse', function () { it('bid objects from response', function () { - const bidResponses = spec.interpretResponse(serverResponse); - expect(bidResponses).to.be.an('array').that.is.not.empty; // yes, syntax is correct - expect(bidResponses[0]).to.have.all.keys( - 'requestId', - 'cpm', - 'width', - 'height', - 'ad', - 'ttl', - 'creativeId', - 'netRevenue', - 'currency', - ); - - expect(bidResponses[0].requestId).to.equal(cannedValidBidRequests[0].bidId); - expect(bidResponses[0].cpm).to.equal(serverResponse.body[0].cpm); - expect(bidResponses[0].width).to.equal(serverResponse.body[0].width); - expect(bidResponses[0].height).to.equal(serverResponse.body[0].height); - expect(bidResponses[0].ad).to.equal(serverResponse.body[0].ad); - expect(bidResponses[0].ttl).to.equal(serverResponse.body[0].ttl); - expect(bidResponses[0].creativeId).to.equal(serverResponse.body[0].creativeId); - expect(bidResponses[0].netRevenue).to.equal(serverResponse.body[0].netRevenue); - expect(bidResponses[0].currency).to.equal(serverResponse.body[0].currency); + const bidResponses = interpretResponse(serverResponse); + expect(bidResponses).to.be.an('array').that.is.not.empty; + expect(bidResponses[0]).to.have.property('requestId', cannedValidBidRequests[0].bidId); + expect(bidResponses[0]).to.have.property('cpm', serverResponse.body[0].cpm); + expect(bidResponses[0]).to.have.property('width', serverResponse.body[0].width); + expect(bidResponses[0]).to.have.property('height', serverResponse.body[0].height); + expect(bidResponses[0]).to.have.property('ad', serverResponse.body[0].ad); + expect(bidResponses[0]).to.have.property('ttl', serverResponse.body[0].ttl); + expect(bidResponses[0]).to.have.property('creativeId', serverResponse.body[0].creativeId); + expect(bidResponses[0]).to.have.property('netRevenue', serverResponse.body[0].netRevenue); + expect(bidResponses[0]).to.have.property('currency', serverResponse.body[0].currency); }); }); - describe('getUserSyncs', function () { - config.setConfig({emoteevEnv: PRODUCTION}); - expect(spec.getUserSyncs({ - iframeEnabled: true - }, [{}])).to.deep.equal([{ - type: 'iframe', - url: EMOTEEV_BASE_URL.concat(USER_SYNC_IFRAME_URL_PATH) - }]); + describe('onAdapterCalled', function () { + const + bidRequest = cannedValidBidRequests[0], + url = onAdapterCalled(DEFAULT_ENV, bidRequest); + + expect(url).to.have.property('protocol'); + expect(url).to.have.property('hostname'); + expect(url).to.have.property('pathname', EVENTS_PATH); + expect(url).to.have.nested.property('search.eventName', ON_ADAPTER_CALLED); + expect(url).to.have.nested.property('search.pubcId', bidRequest.crumbs.pubcid); + expect(url).to.have.nested.property('search.bidId', bidRequest.bidId); + expect(url).to.have.nested.property('search.adSpaceId', bidRequest.params.adSpaceId); + expect(url).to.have.nested.property('search.cache_buster'); + }); + + describe('onBidWon', function () { + const + pubcId = cannedValidBidRequests[0].crumbs.pubcid, + bidObject = serverResponse.body[0], + url = onBidWon(DEFAULT_ENV, pubcId, bidObject); - expect(spec.getUserSyncs({ - pixelEnabled: true - }, [{}])).to.deep.equal([{ + expect(url).to.have.property('protocol'); + expect(url).to.have.property('hostname'); + expect(url).to.have.property('pathname', EVENTS_PATH); + expect(url).to.have.nested.property('search.eventName', ON_BID_WON); + expect(url).to.have.nested.property('search.pubcId', pubcId); + expect(url).to.have.nested.property('search.bidId', bidObject.requestId); + expect(url).to.have.nested.property('search.cache_buster'); + }); + + describe('onTimeout', function () { + const + data = { + ...cannedValidBidRequests[0], + timeout: 123, + }, + url = onTimeout(DEFAULT_ENV, data); + + expect(url).to.have.property('protocol'); + expect(url).to.have.property('hostname'); + expect(url).to.have.property('pathname', EVENTS_PATH); + expect(url).to.have.nested.property('search.eventName', ON_BIDDER_TIMEOUT); + expect(url).to.have.nested.property('search.bidId', data.bidId); + expect(url).to.have.nested.property('search.pubcId', data.crumbs.pubcid); + expect(url).to.have.nested.property('search.adSpaceId', data.params.adSpaceId); + expect(url).to.have.nested.property('search.timeout', data.timeout); + expect(url).to.have.nested.property('search.cache_buster'); + }); + + describe('getUserSyncs', function () { + expect(getUserSyncs( + DEFAULT_ENV, + { + iframeEnabled: false, + pixelEnabled: false + })).to.deep.equal([]); + expect(getUserSyncs( + PRODUCTION, + { + iframeEnabled: false, + pixelEnabled: true + })).to.deep.equal([{ type: 'image', - url: EMOTEEV_BASE_URL.concat(USER_SYNC_IMAGE_URL_PATH) + url: userSyncImageUrl(PRODUCTION) }]); - - expect(spec.getUserSyncs({ - iframeEnabled: true, - pixelEnabled: true - }, [{}])).to.deep.equal([{ + expect(getUserSyncs( + STAGING, + { + iframeEnabled: true, + pixelEnabled: false + })).to.deep.equal([{ type: 'iframe', - url: EMOTEEV_BASE_URL.concat(USER_SYNC_IFRAME_URL_PATH) - }, { + url: userSyncIframeUrl(STAGING) + }]); + expect(getUserSyncs( + DEVELOPMENT, + { + iframeEnabled: true, + pixelEnabled: true + })).to.deep.equal([{ type: 'image', - url: EMOTEEV_BASE_URL.concat(USER_SYNC_IMAGE_URL_PATH) + url: userSyncImageUrl(DEVELOPMENT) + }, { + type: 'iframe', + url: userSyncIframeUrl(DEVELOPMENT) }]); }); + + describe('domain', function () { + expect(domain(null)).to.deep.equal(DOMAIN); + expect(domain('anything')).to.deep.equal(DOMAIN); + expect(domain(PRODUCTION)).to.deep.equal(DOMAIN); + expect(domain(STAGING)).to.deep.equal(DOMAIN_STAGING); + expect(domain(DEVELOPMENT)).to.deep.equal(DOMAIN_DEVELOPMENT); + }); + + describe('eventsUrl', function () { + expect(eventsUrl(null)).to.deep.equal(url.format({ + protocol: 'https', + hostname: domain(DEFAULT_ENV), + pathname: EVENTS_PATH + })); + expect(eventsUrl('anything')).to.deep.equal(url.format({ + protocol: 'https', + hostname: domain(DEFAULT_ENV), + pathname: EVENTS_PATH + })); + expect(eventsUrl(PRODUCTION)).to.deep.equal(url.format({ + protocol: 'https', + hostname: domain(PRODUCTION), + pathname: EVENTS_PATH + })); + expect(eventsUrl(STAGING)).to.deep.equal(url.format({ + protocol: 'https', + hostname: domain(STAGING), + pathname: EVENTS_PATH + })); + expect(eventsUrl(DEVELOPMENT)).to.deep.equal(url.format({ + hostname: domain(DEVELOPMENT), + pathname: EVENTS_PATH + })); + }); + + describe('bidderUrl', function () { + expect(bidderUrl(null)).to.deep.equal(url.format({ + protocol: 'https', + hostname: domain(DEFAULT_ENV), + pathname: BIDDER_PATH + })); + expect(bidderUrl('anything')).to.deep.equal(url.format({ + protocol: 'https', + hostname: domain(DEFAULT_ENV), + pathname: BIDDER_PATH + })); + expect(bidderUrl(PRODUCTION)).to.deep.equal(url.format({ + protocol: 'https', + hostname: domain(PRODUCTION), + pathname: BIDDER_PATH + })); + expect(bidderUrl(STAGING)).to.deep.equal(url.format({ + protocol: 'https', + hostname: domain(STAGING), + pathname: BIDDER_PATH + })); + expect(bidderUrl(DEVELOPMENT)).to.deep.equal(url.format({ + hostname: domain(DEVELOPMENT), + pathname: BIDDER_PATH + })); + }); + + describe('userSyncIframeUrl', function () { + expect(userSyncIframeUrl(null)).to.deep.equal(url.format({ + protocol: 'https', + hostname: domain(DEFAULT_ENV), + pathname: USER_SYNC_IFRAME_PATH + })); + expect(userSyncIframeUrl('anything')).to.deep.equal(url.format({ + protocol: 'https', + hostname: domain(DEFAULT_ENV), + pathname: USER_SYNC_IFRAME_PATH + })); + expect(userSyncIframeUrl(PRODUCTION)).to.deep.equal(url.format({ + protocol: 'https', + hostname: domain(PRODUCTION), + pathname: USER_SYNC_IFRAME_PATH + })); + expect(userSyncIframeUrl(STAGING)).to.deep.equal(url.format({ + protocol: 'https', + hostname: domain(STAGING), + pathname: USER_SYNC_IFRAME_PATH + })); + expect(userSyncIframeUrl(DEVELOPMENT)).to.deep.equal(url.format({ + hostname: domain(DEVELOPMENT), + pathname: USER_SYNC_IFRAME_PATH + })); + }); + + describe('userSyncImageUrl', function () { + expect(userSyncImageUrl(null)).to.deep.equal(url.format({ + protocol: 'https', + hostname: domain(DEFAULT_ENV), + pathname: USER_SYNC_IMAGE_PATH + })); + expect(userSyncImageUrl('anything')).to.deep.equal(url.format({ + protocol: 'https', + hostname: domain(DEFAULT_ENV), + pathname: USER_SYNC_IMAGE_PATH + })); + expect(userSyncImageUrl(PRODUCTION)).to.deep.equal(url.format({ + protocol: 'https', + hostname: domain(PRODUCTION), + pathname: USER_SYNC_IMAGE_PATH + })); + expect(userSyncImageUrl(STAGING)).to.deep.equal(url.format({ + protocol: 'https', + hostname: domain(STAGING), + pathname: USER_SYNC_IMAGE_PATH + })); + expect(userSyncImageUrl(DEVELOPMENT)).to.deep.equal(url.format({ + hostname: domain(DEVELOPMENT), + pathname: USER_SYNC_IMAGE_PATH + })); + }); + + describe('conformBidRequest', function () { + expect(conformBidRequest(cannedValidBidRequests[0])).to.deep.equal({ + params: cannedValidBidRequests[0].params, + crumbs: cannedValidBidRequests[0].crumbs, + sizes: cannedValidBidRequests[0].sizes, + bidId: cannedValidBidRequests[0].bidId, + bidderRequestId: cannedValidBidRequests[0].bidderRequestId, + }); + }); + + describe('gdprConsent', function () { + describe('gdpr applies, consent given', function () { + const bidderRequest = { + ...cannedBidderRequest, + gdprConsent: { + gdprApplies: true, + vendorData: {vendorConsents: {[VENDOR_ID]: true}}, + } + }; + expect(gdprConsent(bidderRequest)).to.deep.equal(true); + }); + describe('gdpr applies, consent withdrawn', function () { + const bidderRequest = { + ...cannedBidderRequest, + gdprConsent: { + gdprApplies: true, + vendorData: {vendorConsents: {[VENDOR_ID]: false}}, + } + }; + expect(gdprConsent(bidderRequest)).to.deep.equal(false); + }); + describe('gdpr applies, consent unknown', function () { + const bidderRequest = { + ...cannedBidderRequest, + gdprConsent: { + gdprApplies: true, + vendorData: {}, + } + }; + expect(gdprConsent(bidderRequest)).to.deep.equal(undefined); + }); + }); + + describe('requestsPayload', function () { + const + currency = 'EUR', + debug = true; + + const payload = requestsPayload(debug, currency, cannedValidBidRequests, cannedBidderRequest); + + expect(payload).to.exist.and.have.all.keys( + 'akPbjsVersion', + 'bidRequests', + 'currency', + 'debug', + 'language', + 'refererInfo', + 'deviceInfo', + 'userAgent', + 'gdprApplies', + 'gdprConsent', + ); + + expect(payload.bidRequests[0]).to.exist.and.have.all.keys( + 'params', + 'crumbs', + 'sizes', + 'bidId', + 'bidderRequestId', + ); + + expect(payload.akPbjsVersion).to.deep.equal(ADAPTER_VERSION); + expect(payload.bidRequests[0].params).to.deep.equal(cannedValidBidRequests[0].params); + expect(payload.bidRequests[0].crumbs).to.deep.equal(cannedValidBidRequests[0].crumbs); + expect(payload.bidRequests[0].mediaTypes).to.deep.equal(cannedValidBidRequests[0].mediaTypes); + expect(payload.bidRequests[0].bidId).to.deep.equal(cannedValidBidRequests[0].bidId); + expect(payload.bidRequests[0].bidderRequestId).to.deep.equal(cannedValidBidRequests[0].bidderRequestId); + expect(payload.currency).to.deep.equal(currency); + expect(payload.debug).to.deep.equal(debug); + expect(payload.language).to.deep.equal(navigator.language); + expect(payload.deviceInfo).to.exist.and.have.all.keys( + 'browserWidth', + 'browserHeight', + 'deviceWidth', + 'deviceHeight', + 'documentWidth', + 'documentHeight', + 'webGL', + ); + expect(payload.userAgent).to.deep.equal(navigator.userAgent); + expect(payload.gdprApplies).to.deep.equal(cannedBidderRequest.gdprConsent.gdprApplies); + }); + + describe('getViewDimensions', function () { + const window = { + innerWidth: 1024, + innerHeight: 768 + }; + const documentWithElement = { + documentElement: + { + clientWidth: 512, + clientHeight: 384 + } + }; + const documentWithBody = { + body: + { + clientWidth: 512, + clientHeight: 384 + } + }; + expect(getViewDimensions(window, documentWithElement)).to.deep.equal({ + width: 1024, + height: 768 + }); + expect(getViewDimensions(window, documentWithBody)).to.deep.equal({width: 1024, height: 768}); + expect(getViewDimensions(window, documentWithElement)).to.deep.equal({ + width: 1024, + height: 768 + }); + expect(getViewDimensions(window, documentWithBody)).to.deep.equal({width: 1024, height: 768}); + expect(getViewDimensions({}, documentWithElement)).to.deep.equal({width: 512, height: 384}); + expect(getViewDimensions({}, documentWithBody)).to.deep.equal({width: 512, height: 384}); + }); + + describe('getDeviceDimensions', function () { + const window = {screen: {width: 1024, height: 768}}; + expect(getDeviceDimensions(window)).to.deep.equal({width: 1024, height: 768}); + expect(getDeviceDimensions({})).to.deep.equal({width: '', height: ''}); + }); + + describe('getDocumentDimensions', function () { + expect(getDocumentDimensions({ + documentElement: { + clientWidth: 1, + clientHeight: 1, + offsetWidth: 0, + offsetHeight: 0, + scrollWidth: 0, + scrollHeight: 0, + }, + })).to.deep.equal({width: 1, height: 1}); + + expect(getDocumentDimensions({ + documentElement: { + clientWidth: 1, + clientHeight: 1, + offsetWidth: 0, + offsetHeight: 0, + scrollWidth: 0, + scrollHeight: 0, + }, + body: { + scrollHeight: 0, + offsetHeight: 0, + } + })).to.deep.equal({width: 1, height: 1}); + + expect(getDocumentDimensions({ + documentElement: { + clientWidth: 0, + clientHeight: 0, + offsetWidth: 1, + offsetHeight: 1, + scrollWidth: 0, + scrollHeight: 0, + }, + body: { + scrollHeight: 0, + offsetHeight: 0, + } + })).to.deep.equal({width: 1, height: 1}); + + expect(getDocumentDimensions({ + documentElement: { + clientWidth: 0, + clientHeight: 0, + offsetWidth: 0, + offsetHeight: 0, + scrollWidth: 1, + scrollHeight: 1, + }, + body: { + scrollHeight: 0, + offsetHeight: 0, + } + })).to.deep.equal({width: 1, height: 1}); + + expect(getDocumentDimensions({ + documentElement: { + clientWidth: undefined, + clientHeight: undefined, + offsetWidth: undefined, + offsetHeight: undefined, + scrollWidth: undefined, + scrollHeight: undefined, + }, + body: { + scrollHeight: undefined, + offsetHeight: undefined, + } + })).to.deep.equal({width: '', height: ''}); + }); + + // describe('isWebGLEnabled', function () { + // it('handles no webgl', function () { + // const + // document = new Document(), + // canvas = sinon.createStubInstance(HTMLCanvasElement); + // sinon.stub(document, 'createElement').withArgs('canvas').returns(canvas); + // canvas.getContext.withArgs('webgl').returns(undefined); + // canvas.getContext.withArgs('experimental-webgl').returns(undefined); + // expect(isWebGLEnabled(document)).to.equal(false); + // }); + // + // it('handles webgl exception', function () { + // const + // document = new Document(), + // canvas = sinon.createStubInstance(HTMLCanvasElement); + // sinon.stub(document, 'createElement').withArgs('canvas').returns(canvas); + // canvas.getContext.withArgs('webgl').throws(DOMException); + // expect(isWebGLEnabled(document)).to.equal(false); + // }); + // + // it('handles experimental webgl', function () { + // const + // document = new Document(), + // canvas = sinon.createStubInstance(HTMLCanvasElement); + // sinon.stub(document, 'createElement').withArgs('canvas').returns(canvas); + // canvas.getContext.withArgs('webgl').returns(undefined); + // canvas.getContext.withArgs('experimental-webgl').returns(true); + // expect(isWebGLEnabled(document)).to.equal(true); + // }); + // + // it('handles experimental webgl exception', function () { + // const + // document = new Document(), + // canvas = sinon.createStubInstance(HTMLCanvasElement); + // sinon.stub(document, 'createElement').withArgs('canvas').returns(canvas); + // canvas.getContext.withArgs('webgl').returns(undefined); + // canvas.getContext.withArgs('experimental-webgl').throws(DOMException); + // expect(isWebGLEnabled(document)).to.equal(false); + // }); + // + // it('handles webgl', function () { + // const + // document = new Document(), + // canvas = sinon.createStubInstance(HTMLCanvasElement); + // sinon.stub(document, 'createElement').withArgs('canvas').returns(canvas); + // canvas.getContext.withArgs('webgl').returns(true); + // expect(isWebGLEnabled(document)).to.equal(true); + // }); + // }); + + describe('getDeviceInfo', function () { + expect(getDeviceInfo( + {width: 1, height: 2}, + {width: 3, height: 4}, + {width: 5, height: 6}, + true + )).to.deep.equal({ + deviceWidth: 1, + deviceHeight: 2, + browserWidth: 3, + browserHeight: 4, + documentWidth: 5, + documentHeight: 6, + webGL: true + }); + }); + + describe('resolveEnv', function () { + it('defaults to production', function () { + expect(resolveEnv({}, null)).to.deep.equal(DEFAULT_ENV); + }); + expect(resolveEnv({}, PRODUCTION)).to.deep.equal(PRODUCTION); + expect(resolveEnv({}, STAGING)).to.deep.equal(STAGING); + expect(resolveEnv({}, DEVELOPMENT)).to.deep.equal(DEVELOPMENT); + expect(resolveEnv({emoteev: {env: PRODUCTION}}, null)).to.deep.equal(PRODUCTION); + expect(resolveEnv({emoteev: {env: STAGING}}, null)).to.deep.equal(STAGING); + expect(resolveEnv({emoteev: {env: DEVELOPMENT}}, null)).to.deep.equal(DEVELOPMENT); + it('prioritizes parameter over configuration', function () { + expect(resolveEnv({emoteev: {env: STAGING}}, DEVELOPMENT)).to.deep.equal(DEVELOPMENT); + }); + }); + + describe('resolveDebug', function () { + it('defaults to production', function () { + expect(resolveDebug({}, null)).to.deep.equal(false); + }); + expect(resolveDebug({}, 'false')).to.deep.equal(false); + expect(resolveDebug({}, 'true')).to.deep.equal(true); + expect(resolveDebug({debug: true}, null)).to.deep.equal(true); + it('prioritizes parameter over configuration', function () { + expect(resolveDebug({debug: true}, 'false')).to.deep.equal(false); + }); + }); + + describe('side effects', function () { + let triggerPixelSpy; + let getCookieSpy; + let getConfigSpy; + let getParameterByNameSpy; + beforeEach(function () { + triggerPixelSpy = sinon.spy(utils, 'triggerPixel'); + getCookieSpy = sinon.spy(utils, 'getCookie'); + getConfigSpy = sinon.spy(config, 'getConfig'); + getParameterByNameSpy = sinon.spy(utils, 'getParameterByName'); + }); + afterEach(function () { + triggerPixelSpy.restore(); + getCookieSpy.restore(); + getConfigSpy.restore(); + getParameterByNameSpy.restore(); + }); + + describe('isBidRequestValid', function () { + it('has intended side-effects', function () { + const validBidRequest = { + bidder: 'emoteev', + bidId: '23a45b4e3', + params: { + adSpaceId: 12345, + }, + mediaTypes: { + banner: { + sizes: [[750, 200]] + } + }, + }; + spec.isBidRequestValid(validBidRequest); + sinon.assert.notCalled(utils.triggerPixel); + sinon.assert.notCalled(utils.getCookie); + sinon.assert.notCalled(config.getConfig); + sinon.assert.notCalled(utils.getParameterByName); + }); + it('has intended side-effects', function () { + const invalidBidRequest = {}; + spec.isBidRequestValid(invalidBidRequest); + sinon.assert.notCalled(utils.triggerPixel); + sinon.assert.notCalled(utils.getCookie); + sinon.assert.notCalled(config.getConfig); + sinon.assert.notCalled(utils.getParameterByName); + }); + }); + describe('buildRequests', function () { + it('has intended side-effects', function () { + spec.buildRequests(cannedValidBidRequests, cannedBidderRequest); + sinon.assert.notCalled(utils.triggerPixel); + sinon.assert.notCalled(utils.getCookie); + sinon.assert.callCount(config.getConfig, 3); + sinon.assert.callCount(utils.getParameterByName, 2); + }); + }); + describe('interpretResponse', function () { + it('has intended side-effects', function () { + spec.interpretResponse(serverResponse); + sinon.assert.notCalled(utils.triggerPixel); + sinon.assert.notCalled(utils.getCookie); + sinon.assert.notCalled(config.getConfig); + sinon.assert.notCalled(utils.getParameterByName); + }); + }); + describe('onBidWon', function () { + it('has intended side-effects', function () { + const bidObject = serverResponse.body[0]; + spec.onBidWon(bidObject); + sinon.assert.calledOnce(utils.triggerPixel); + sinon.assert.calledOnce(utils.getCookie); + sinon.assert.calledOnce(config.getConfig); + sinon.assert.calledOnce(utils.getParameterByName); + }); + }); + describe('onTimeout', function () { + it('has intended side-effects', function () { + spec.onTimeout(cannedValidBidRequests[0]); + sinon.assert.calledOnce(utils.triggerPixel); + sinon.assert.notCalled(utils.getCookie); + sinon.assert.calledOnce(config.getConfig); + sinon.assert.calledOnce(utils.getParameterByName); + }); + }); + describe('getUserSyncs', function () { + it('has intended side-effects', function () { + spec.getUserSyncs({}); + sinon.assert.notCalled(utils.triggerPixel); + sinon.assert.notCalled(utils.getCookie); + sinon.assert.calledOnce(config.getConfig); + sinon.assert.calledOnce(utils.getParameterByName); + }); + }); + }); + + describe('validateSizes', function () { + it('only accepts valid array of sizes', function () { + expect(validateSizes([])).to.deep.equal(false); + expect(validateSizes([[]])).to.deep.equal(false); + expect(validateSizes([[450, 450], undefined])).to.deep.equal(false); + expect(validateSizes([[450, 450], 'size'])).to.deep.equal(false); + expect(validateSizes([[1, 1]])).to.deep.equal(true); + expect(validateSizes([[1, 1], [450, 450]])).to.deep.equal(true); + }); + }); + + describe('validateContext', function () { + it('only accepts valid context', function () { + expect(validateContext(IN_CONTENT)).to.deep.equal(true); + expect(validateContext(FOOTER)).to.deep.equal(true); + expect(validateContext(OVERLAY)).to.deep.equal(true); + expect(validateContext(WALLPAPER)).to.deep.equal(true); + expect(validateContext(null)).to.deep.equal(false); + expect(validateContext('anything else')).to.deep.equal(false); + }); + }); + + describe('validateExternalId', function () { + it('only accepts a positive integer or null', function () { + expect(validateExternalId(0)).to.deep.equal(false); + expect(validateExternalId(42)).to.deep.equal(true); + expect(validateExternalId(42.0)).to.deep.equal(true); // edge case: valid externalId + expect(validateExternalId(3.14159)).to.deep.equal(false); + expect(validateExternalId('externalId')).to.deep.equal(false); + expect(validateExternalId(undefined)).to.deep.equal(true); + expect(validateExternalId(null)).to.deep.equal(true); + }); + }); }); diff --git a/test/spec/modules/emx_digitalBidAdapter_spec.js b/test/spec/modules/emx_digitalBidAdapter_spec.js index 85256c20bd9..16f17174f88 100644 --- a/test/spec/modules/emx_digitalBidAdapter_spec.js +++ b/test/spec/modules/emx_digitalBidAdapter_spec.js @@ -4,167 +4,239 @@ import * as utils from 'src/utils'; import { newBidder } from 'src/adapters/bidderFactory'; describe('emx_digital Adapter', function () { - const adapter = newBidder(spec); - - describe('required function', function () { + describe('callBids', function () { + const adapter = newBidder(spec); it('exists and is a function', function () { expect(adapter.callBids).to.exist.and.to.be.a('function'); }); }); describe('isBidRequestValid', function () { - let bid = { - 'bidder': 'emx_digital', - 'params': { - 'tagid': '25251' - }, - 'mediaTypes': { - 'banner': { - 'sizes': [ - [300, 250], - [300, 600] - ] - } - }, - 'adUnitCode': 'adunit-code', - 'sizes': [ - [300, 250], - [300, 600] - ], - 'bidId': '30b31c2501de1e', - 'bidderRequestId': '22edbae3120bf6', - 'auctionId': '1d1a01234a475' - }; + describe('banner request validity', function () { + let bid = { + 'bidder': 'emx_digital', + 'params': { + 'tagid': '25251' + }, + 'mediaTypes': { + 'banner': { + 'sizes': [[300, 250]] + } + }, + 'adUnitCode': 'adunit-code', + 'sizes': [ + [300, 250], + [300, 600] + ], + 'bidId': '30b31c2501de1e', + 'bidderRequestId': '22edbae3120bf6', + 'auctionId': '1d1a01234a475' + }; + let badBid = { + 'bidder': 'emx_digital', + 'params': { + 'tagid': '25251' + }, + 'mediaTypes': { + 'banner': { + } + }, + 'adUnitCode': 'adunit-code', + 'bidId': '30b31c2501de1e', + 'bidderRequestId': '22edbae3120bf6', + 'auctionId': '1d1a01234a475' + }; + let noBid = {}; + let otherBid = { + 'bidder': 'emxdigital', + 'params': { + 'tagid': '25251' + }, + 'mediaTypes': { + 'banner': { + 'sizes': [[300, 250]] + } + }, + 'adUnitCode': 'adunit-code', + 'sizes': [ + [300, 250], + [300, 600] + ], + 'bidId': '30b31c2501de1e', + 'bidderRequestId': '22edbae3120bf6', + 'auctionId': '1d1a01234a475' + }; + let noMediaSizeBid = { + 'bidder': 'emxdigital', + 'params': { + 'tagid': '25251' + }, + 'mediaTypes': { + 'banner': {} + }, + 'adUnitCode': 'adunit-code', + 'sizes': [ + [300, 250], + [300, 600] + ], + 'bidId': '30b31c2501de1e', + 'bidderRequestId': '22edbae3120bf6', + 'auctionId': '1d1a01234a475' + }; - it('should return true when required params found', function () { - expect(spec.isBidRequestValid(bid)).to.equal(true); + it('should return true when required params found', function () { + expect(spec.isBidRequestValid(bid)).to.equal(true); + expect(spec.isBidRequestValid(badBid)).to.equal(false); + expect(spec.isBidRequestValid(noBid)).to.equal(false); + expect(spec.isBidRequestValid(otherBid)).to.equal(false); + expect(spec.isBidRequestValid(noMediaSizeBid)).to.equal(false); + }); }); - it('should contain tagid param', function () { - expect(spec.isBidRequestValid({ - bidder: 'emx_digital', - params: {}, - mediaTypes: { - banner: { - sizes: [ - [300, 250], - [300, 600] - ] + describe('video request validity', function () { + let bid = { + 'bidder': 'emx_digital', + 'params': { + 'tagid': '25251', + 'video': {} + }, + 'mediaTypes': { + 'video': { + 'context': 'instream', + 'playerSize': [640, 480] } - } - })).to.equal(false); - expect(spec.isBidRequestValid({ - bidder: 'emx_digital', - params: { - tagid: '' }, - mediaTypes: { - banner: { - sizes: [ - [300, 250], - [300, 600] - ] + 'adUnitCode': 'adunit-code', + 'sizes': [ + [300, 250], + [300, 600] + ], + 'bidId': '30b31c2501de1e', + 'bidderRequestId': '22edbae3120bf6', + 'auctionId': '1d1a01234a475' + }; + let noInstreamBid = { + 'bidder': 'emx_digital', + 'params': { + 'tagid': '25251', + 'video': { + 'protocols': [1, 7] } - } - })).to.equal(false); - expect(spec.isBidRequestValid({ - bidder: 'emx_digital', - params: { - tagid: '123' }, - mediaTypes: { - banner: { - sizes: [ - ] + 'mediaTypes': { + 'video': { + 'context': 'something_random' } - } - })).to.equal(false); - expect(spec.isBidRequestValid({ - bidder: 'emxdigital', - params: { - tagid: '123' }, - mediaTypes: { - banner: { - sizes: [ - [300, 250], - [300, 600] - ] + 'adUnitCode': 'adunit-code', + 'sizes': [ + [300, 250], + [300, 600] + ], + 'bidId': '30b31c2501de1e', + 'bidderRequestId': '22edbae3120bf6', + 'auctionId': '1d1a01234a475' + }; + + let outstreamBid = { + 'bidder': 'emx_digital', + 'params': { + 'tagid': '25251', + 'video': {} + }, + 'mediaTypes': { + 'video': { + 'context': 'outstream', + 'playerSize': [640, 480] } - } - })).to.equal(false); - expect(spec.isBidRequestValid({ - bidder: 'emx_digital', - params: { - tagid: '123' }, - mediaTypes: { - banner: { - sizes: [ - [300, 250], - [300, 600] - ] + 'adUnitCode': 'adunit-code', + 'sizes': [ + [300, 250], + [300, 600] + ], + 'bidId': '30b31c2501de1e', + 'bidderRequestId': '22edbae3120bf6', + 'auctionId': '1d1a01234a475' + }; + + it('should return true when required params found', function () { + expect(spec.isBidRequestValid(bid)).to.equal(true); + expect(spec.isBidRequestValid(noInstreamBid)).to.equal(false); + expect(spec.isBidRequestValid(outstreamBid)).to.equal(true); + }); + + it('should contain tagid param', function () { + expect(spec.isBidRequestValid({ + bidder: 'emx_digital', + params: {}, + mediaTypes: { + banner: { + sizes: [[300, 250]] + } } - } - })).to.equal(true); + })).to.equal(false); + expect(spec.isBidRequestValid({ + bidder: 'emx_digital', + params: { + tagid: '' + }, + mediaTypes: { + banner: { + sizes: [[300, 250]] + } + } + })).to.equal(false); + expect(spec.isBidRequestValid({ + bidder: 'emx_digital', + params: { + tagid: '123' + }, + mediaTypes: { + banner: { + sizes: [[300, 250]] + } + } + })).to.equal(true); + }); }); }); describe('buildRequests', function () { - const bidRequests = [{ - 'bidder': 'emx_digital', - 'params': { - 'tagid': '25251' - }, - 'adUnitCode': 'adunit-code', - 'mediaTypes': { - 'banner': { - 'sizes': [ - [300, 250], - [300, 600] - ] - } - }, - 'sizes': [ - [300, 250], - [300, 600] - ], - 'bidId': '30b31c2501de1e', - 'bidderRequestId': '22edbae3120bf6', - 'auctionId': 'e19f1eff-8b27-42a6-888d-9674e5a6130c', - 'transactionId': 'd7b773de-ceaa-484d-89ca-d9f51b8d61ec' - }, { - 'bidder': 'emx_digital', - 'params': { - 'tagid': '25251' - }, - 'adUnitCode': 'adunit-code', - 'mediaTypes': { - 'banner': { - 'sizes': [ - [300, 250], - [300, 600] - ] - } - }, - 'sizes': [ - [300, 250], - [300, 600] - ], - 'bidId': '30b31c2501de1e', - 'bidderRequestId': '22edbae3120bf6', - 'auctionId': 'e19f1eff-8b27-42a6-888d-9674e5a6130c', - 'transactionId': 'd7b773de-ceaa-484d-89ca-d9f51b8d61ec' - }]; let bidderRequest = { 'bidderCode': 'emx_digital', 'auctionId': 'e19f1eff-8b27-42a6-888d-9674e5a6130c', 'bidderRequestId': '22edbae3120bf6', 'timeout': 1500, + 'refererInfo': { + 'numIframes': 0, + 'reachedTop': true, + 'referer': 'https://example.com/index.html?pbjs_debug=true' + }, + 'bids': [{ + 'bidder': 'emx_digital', + 'params': { + 'tagid': '25251' + }, + 'adUnitCode': 'adunit-code', + 'mediaTypes': { + 'banner': { + 'sizes': [ + [300, 250], + [300, 600] + ] + } + }, + 'sizes': [ + [300, 250], + [300, 600] + ], + 'bidId': '30b31c2501de1e', + 'auctionId': 'e19f1eff-8b27-42a6-888d-9674e5a6130c', + 'transactionId': 'd7b773de-ceaa-484d-89ca-d9f51b8d61ec', + }] }; - bidderRequest.bids = bidRequests - - let request = spec.buildRequests(bidRequests, bidderRequest); + let request = spec.buildRequests(bidderRequest.bids, bidderRequest); it('sends bid request to ENDPOINT via POST', function () { expect(request.method).to.equal('POST'); @@ -174,107 +246,111 @@ describe('emx_digital Adapter', function () { expect(request.options.withCredentials).to.equal(true); }); - it('sends contains a properly formatted endpoint url', function () { + it('contains a properly formatted endpoint url', function () { const url = request.url.split('?'); const queryParams = url[1].split('&'); expect(queryParams[0]).to.match(new RegExp('^t=\d*', 'g')); expect(queryParams[1]).to.match(new RegExp('^ts=\d*', 'g')); }); + it('builds with bid floor', function () { + const bidRequestWithBidFloor = utils.deepClone(bidderRequest.bids); + bidRequestWithBidFloor[0].params.bidfloor = 1; + const requestWithFloor = spec.buildRequests(bidRequestWithBidFloor, bidderRequest); + const data = JSON.parse(requestWithFloor.data); + expect(data.imp[0].bidfloor).to.equal(bidRequestWithBidFloor[0].params.bidfloor); + }); + it('builds request properly', function () { const data = JSON.parse(request.data); - expect(Array.isArray(data.imp)).to.equal(true); expect(data.id).to.equal(bidderRequest.auctionId); - expect(data.imp.length).to.equal(2); + expect(data.imp.length).to.equal(1); expect(data.imp[0].id).to.equal('30b31c2501de1e'); expect(data.imp[0].tid).to.equal('d7b773de-ceaa-484d-89ca-d9f51b8d61ec'); expect(data.imp[0].tagid).to.equal('25251'); expect(data.imp[0].secure).to.equal(0); + expect(data.imp[0].vastXml).to.equal(undefined); }); - it('builds with bid floor', function() { - const bidRequestWithBidFloor = utils.deepClone(bidRequests); - bidRequestWithBidFloor[0].params.bidfloor = 1; - const requestWithFloor = spec.buildRequests(bidRequestWithBidFloor, bidderRequest); - const data = JSON.parse(requestWithFloor.data); - expect(data.imp[0].bidfloor).to.equal(bidRequestWithBidFloor[0].params.bidfloor); - }) - it('properly sends site information and protocol', function () { - let mock = sinon.stub(utils, 'getTopWindowLocation').callsFake(() => { - return { - protocol: 'https:', - host: 'example.com', - href: 'https://example.com/index.html' - }; - }); - - let request; - - request = spec.buildRequests(bidRequests, bidderRequest); + request = spec.buildRequests(bidderRequest.bids, bidderRequest); request = JSON.parse(request.data); - expect(request.site.domain).to.equal('example.com'); - expect(request.site.page).to.equal('https://example.com/index.html'); - expect(request.imp[0].secure).to.equal(1); - - mock.restore(); - }) + expect(request.site.domain).to.equal(utils.getTopWindowLocation().hostname); + expect(decodeURIComponent(request.site.page)).to.equal(bidderRequest.refererInfo.referer); + expect(request.site.ref).to.equal(window.top.document.referrer); + }); it('builds correctly formatted request banner object', function () { - let request; - - let bidRequestWithBanner = utils.deepClone(bidRequests); - - request = spec.buildRequests(bidRequestWithBanner, bidderRequest); + let bidRequestWithBanner = utils.deepClone(bidderRequest.bids); + let request = spec.buildRequests(bidRequestWithBanner, bidderRequest); const data = JSON.parse(request.data); + expect(data.imp[0].video).to.equal(undefined); + expect(data.imp[0].banner).to.exist.and.to.be.a('object'); expect(data.imp[0].banner.w).to.equal(bidRequestWithBanner[0].mediaTypes.banner.sizes[0][0]); expect(data.imp[0].banner.h).to.equal(bidRequestWithBanner[0].mediaTypes.banner.sizes[0][1]); expect(data.imp[0].banner.format[0].w).to.equal(bidRequestWithBanner[0].mediaTypes.banner.sizes[0][0]); expect(data.imp[0].banner.format[0].h).to.equal(bidRequestWithBanner[0].mediaTypes.banner.sizes[0][1]); expect(data.imp[0].banner.format[1].w).to.equal(bidRequestWithBanner[0].mediaTypes.banner.sizes[1][0]); expect(data.imp[0].banner.format[1].h).to.equal(bidRequestWithBanner[0].mediaTypes.banner.sizes[1][1]); - }) + }); + + it('builds correctly formatted request video object for instream', function () { + let bidRequestWithVideo = utils.deepClone(bidderRequest.bids); + bidRequestWithVideo[0].mediaTypes = { + video: { + context: 'instream', + playerSize: [[640, 480]] + }, + }; + bidRequestWithVideo[0].params.video = {}; + let request = spec.buildRequests(bidRequestWithVideo, bidderRequest); + const data = JSON.parse(request.data); + expect(data.imp[0].video).to.exist.and.to.be.a('object'); + expect(data.imp[0].video.w).to.equal(bidRequestWithVideo[0].mediaTypes.video.playerSize[0][0]); + expect(data.imp[0].video.h).to.equal(bidRequestWithVideo[0].mediaTypes.video.playerSize[0][1]); + }); + + it('builds correctly formatted request video object for outstream', function () { + let bidRequestWithOutstreamVideo = utils.deepClone(bidderRequest.bids); + bidRequestWithOutstreamVideo[0].mediaTypes = { + video: { + context: 'outstream', + playerSize: [[640, 480]] + }, + }; + bidRequestWithOutstreamVideo[0].params.video = {}; + let request = spec.buildRequests(bidRequestWithOutstreamVideo, bidderRequest); + const data = JSON.parse(request.data); + expect(data.imp[0].video).to.exist.and.to.be.a('object'); + expect(data.imp[0].video.w).to.equal(bidRequestWithOutstreamVideo[0].mediaTypes.video.playerSize[0][0]); + expect(data.imp[0].video.h).to.equal(bidRequestWithOutstreamVideo[0].mediaTypes.video.playerSize[0][1]); + }); it('shouldn\'t contain a user obj without GDPR information', function () { - let request = spec.buildRequests(bidRequests, bidderRequest) + let request = spec.buildRequests(bidderRequest.bids, bidderRequest) request = JSON.parse(request.data) expect(request).to.not.have.property('user'); }); it('should have the right gdpr info when enabled', function () { let consentString = 'OIJSZsOAFsABAB8EMXZZZZZ+A=='; - let bidderRequest = { - 'bidderCode': 'emx_digital', - 'auctionId': 'e19f1eff-8b27-42a6-888d-9674e5a6130c', - 'bidderRequestId': '22edbae3120bf6', - 'timeout': 1500, - 'gdprConsent': { - 'consentString': consentString, - 'gdprApplies': true - } + bidderRequest.gdprConsent = { + 'consentString': consentString, + 'gdprApplies': true }; - bidderRequest.bids = bidRequests - let request = spec.buildRequests(bidRequests, bidderRequest); + let request = spec.buildRequests(bidderRequest.bids, bidderRequest); request = JSON.parse(request.data) expect(request.regs.ext).to.have.property('gdpr', 1); - expect(request.user.ext).to.have.property('consent', 'OIJSZsOAFsABAB8EMXZZZZZ+A=='); + expect(request.user.ext).to.have.property('consent', consentString); }); it('should\'t contain consent string if gdpr isn\'t applied', function () { - let bidderRequest = { - 'bidderCode': 'emx_digital', - 'auctionId': 'e19f1eff-8b27-42a6-888d-9674e5a6130c', - 'bidderRequestId': '22edbae3120bf6', - 'timeout': 1500, - 'gdprConsent': { - 'gdprApplies': false - } + bidderRequest.gdprConsent = { + 'gdprApplies': false }; - bidderRequest.bids = bidRequests - let request = spec.buildRequests(bidRequests, bidderRequest); - + let request = spec.buildRequests(bidderRequest.bids, bidderRequest); request = JSON.parse(request.data) expect(request.regs.ext).to.have.property('gdpr', 0); expect(request).to.not.have.property('user'); @@ -282,6 +358,28 @@ describe('emx_digital Adapter', function () { }); describe('interpretResponse', function () { + let bid = { + 'bidder': 'emx_digital', + 'params': { + 'tagid': '25251', + 'video': {} + }, + 'mediaTypes': { + 'video': { + 'context': 'instream', + 'playerSize': [640, 480] + } + }, + 'adUnitCode': 'adunit-code', + 'sizes': [ + [300, 250], + [300, 600] + ], + 'bidId': '30b31c2501de1e', + 'bidderRequestId': '22edbae3120bf6', + 'auctionId': '1d1a01234a475' + }; + const serverResponse = { 'id': '12819a18-56e1-4256-b836-b69a10202668', 'seatbid': [{ @@ -366,23 +464,57 @@ describe('emx_digital Adapter', function () { expect(ad0.cpm).to.equal(serverResponse.seatbid[0].bid[0].price); expect(ad0.creativeId).to.equal(serverResponse.seatbid[0].bid[0].crid); expect(ad0.currency).to.equal('USD'); - expect(ad0.height).to.equal(serverResponse.seatbid[0].bid[0].h); - expect(ad0.mediaType).to.equal('banner'); expect(ad0.netRevenue).to.equal(true); expect(ad0.requestId).to.equal(serverResponse.seatbid[0].bid[0].id); expect(ad0.ttl).to.equal(300); - expect(ad0.width).to.equal(serverResponse.seatbid[0].bid[0].w); expect(ad1.ad).to.equal(serverResponse.seatbid[1].bid[0].adm); expect(ad1.cpm).to.equal(serverResponse.seatbid[1].bid[0].price); expect(ad1.creativeId).to.equal(serverResponse.seatbid[1].bid[0].crid); expect(ad1.currency).to.equal('USD'); - expect(ad1.height).to.equal(serverResponse.seatbid[1].bid[0].h); - expect(ad1.mediaType).to.equal('banner'); expect(ad1.netRevenue).to.equal(true); expect(ad1.requestId).to.equal(serverResponse.seatbid[1].bid[0].id); expect(ad1.ttl).to.equal(300); + }); + + it('returns a banner bid for non-xml creatives', function () { + let result = spec.interpretResponse({ + body: serverResponse + }, { bidRequest: bid } + ); + const ad0 = result[0]; + const ad1 = result[1]; + expect(ad0.mediaType).to.equal('banner'); + expect(ad0.ad.indexOf(''; + serverResponse.seatbid[1].bid[0].adm = ''; + + let result = spec.interpretResponse({ + body: serverResponse + }, { bidRequest: bid } + ); + const ad0 = result[0]; + const ad1 = result[1]; + expect(ad0.mediaType).to.equal('video'); + expect(ad0.ad.indexOf(' -1).to.equal(true); + expect(ad0.vastXml).to.equal(serverResponse.seatbid[0].bid[0].adm); + expect(ad0.ad).to.exist.and.to.be.a('string'); + expect(ad1.mediaType).to.equal('video'); + expect(ad1.ad.indexOf(' -1).to.equal(true); + expect(ad1.vastXml).to.equal(serverResponse.seatbid[1].bid[0].adm); + expect(ad1.ad).to.exist.and.to.be.a('string'); }); it('handles nobid responses', function () { @@ -396,4 +528,14 @@ describe('emx_digital Adapter', function () { expect(result.length).to.equal(0); }); }); + + describe('getUserSyncs', function () { + let syncOptionsIframe = { iframeEnabled: true }; + let syncOptionsPixel = { pixelEnabled: true }; + it('Should push the correct sync type depending on the config', function () { + let iframeSync = spec.getUserSyncs(syncOptionsIframe); + expect(iframeSync.length).to.equal(1); + expect(iframeSync[0].type).to.equal('iframe'); + }); + }); }); diff --git a/test/spec/modules/eywamediaBidAdapter_spec.js b/test/spec/modules/eywamediaBidAdapter_spec.js new file mode 100644 index 00000000000..945c0dd0d01 --- /dev/null +++ b/test/spec/modules/eywamediaBidAdapter_spec.js @@ -0,0 +1,253 @@ +import { expect } from 'chai'; +import { spec } from 'modules/eywamediaBidAdapter'; + +describe('EywamediaAdapter', function () { + let serverResponse, bidRequests, bidRequest, bidResponses; + const ENDPOINT = 'https://adtarbostg.eywamedia.com/auctions/prebidjs/3000'; + + bidRequests = [ + { + 'auctionId': 'fc917230-a5e1-4a42-b7d9-8fb776124e43', + 'sizes': [[300, 250]], + 'bidRequestsCount': 1, + 'params': { + 'publisherId': '1234_abcd' + }, + 'mediaTypes': { + 'banner': { + 'sizes': [[300, 250]] + } + }, + 'crumbs': { + 'pubcid': '8b640d4e-1f6d-4fd3-b63f-2570572d8100' + }, + 'bidId': '28b09d0543d671', + 'adUnitCode': 'div-gpt-ad-1460505748561-0', + 'transactionId': 'd909c39c-ecc9-41a4-897c-2d2fdfdf41b1', + 'src': 'client', + 'bidder': 'eywamedia', + 'bidderRequestId': '14d8cbc769114b' + }, + { + 'auctionId': 'fc917230-a5e1-4a42-b7d9-8fb776124e43', + 'sizes': [[728, 90]], + 'bidRequestsCount': 1, + 'params': { + 'publisherId': '1234_abcd' + }, + 'mediaTypes': { + 'banner': { + 'sizes': [[728, 90]] + } + }, + 'crumbs': { + 'pubcid': '8b640d4e-1f6d-4fd3-b63f-2570572d8100' + }, + 'bidId': '28b09d0543d672', + 'adUnitCode': 'div-gpt-ad-1460505748561-0', + 'transactionId': 'd909c39c-ecc9-41a4-897c-2d2fdfdf41b2', + 'src': 'client', + 'bidder': 'eywamedia', + 'bidderRequestId': '14d8cbc769114b' + } + ]; + + bidRequest = { + 'auctionId': 'c88115a4-7e71-43d0-9c96-a9b43ebd143d', + 'auctionStart': 1564725164517, + 'bidderCode': 'eywamedia', + 'bidderRequestId': '191afa18994fdd', + 'bids': [], + 'refererInfo': { + 'canonicalUrl': '', + 'numIframes': 0, + 'reachedTop': true, + 'referer': '' + }, + 'stack': [ + '' + ], + 'start': 1564725164520, + 'timeout': 3000 + }; + + let testBid = { + 'bidder': 'eywamedia', + 'params': { + 'publisherId': '1234_abcd' + } + }; + + describe('isBidRequestValid', function () { + it('should return true when required params found', function () { + assert(spec.isBidRequestValid(testBid)); + }); + + it('should return false when required params are missing', function () { + testBid.params = { + test: '231212312' + }; + assert.isFalse(spec.isBidRequestValid(testBid)); + }); + }); + + describe('buildRequests', function () { + it('should attempt to send bid requests to the endpoint via POST', function () { + const requests = spec.buildRequests(bidRequests, bidRequest); + expect(requests.method).to.equal('POST'); + expect(requests.url).to.be.equal(ENDPOINT); + }); + + it('should not blow up if crumbs is undefined', function () { + let bidArray = [ + { ...testBid, crumbs: undefined } + ] + expect(function () { spec.buildRequests(bidArray, bidRequest) }).not.to.throw() + }) + + it('should return true when required params found', function () { + testBid.params.publisherId = '1234_abcd'; + assert(spec.isBidRequestValid(testBid)); + }); + }); + + describe('interpretResponse', function () { + beforeEach(function () { + serverResponse = { + 'body': + [ + { + 'ad': '', + 'adSlot': '', + 'adUnitCode': 'div-gpt-ad-1460505748561-0', + 'adUrl': 'http://eywamedia.com', + 'bidId': '28b09d0543d671', + 'bidder': 'eywamedia', + 'bidderCode': 'eywamedia', + 'cpm': 1, + 'height': 250, + 'requestTimestamp': 1564725162, + 'respType': 'banner', + 'size': '300X250', + 'statusMessage': 'Bid available', + 'transactionId': 'd909c39c-ecc9-41a4-897c-2d2fdfdf41b1', + 'usesGenericKeys': true, + 'width': 300 + }, + { + 'ad': '', + 'adSlot': '', + 'adUnitCode': 'div-gpt-ad-1460505748561-1', + 'adUrl': 'http://eywamedia.com', + 'bidId': '28b09d0543d672', + 'bidder': 'eywamedia', + 'bidderCode': 'eywamedia', + 'cpm': 1, + 'height': 90, + 'requestTimestamp': 1564725164, + 'respType': 'banner', + 'size': '728X90', + 'statusMessage': 'Bid available', + 'transactionId': 'd909c39c-ecc9-41a4-897c-2d2fdfdf41b2', + 'usesGenericKeys': true, + 'width': 728 + } + ], + 'headers': 'header?' + }; + + bidRequest = { + 'data': + { + 'bidPayload': + [ + { + 'auctionId': 'fc917230-a5e1-4a42-b7d9-8fb776124e43', + 'sizes': [[300, 250]], + 'bidRequestsCount': 1, + 'params': { + 'publisherId': '1234_abcd' + }, + 'mediaTypes': { + 'banner': { + 'sizes': [[300, 250]] + } + }, + 'crumbs': { + 'pubcid': '8b640d4e-1f6d-4fd3-b63f-2570572d8100' + }, + 'bidId': '28b09d0543d671', + 'adUnitCode': 'div-gpt-ad-1460505748561-0', + 'transactionId': 'd909c39c-ecc9-41a4-897c-2d2fdfdf41b1', + 'src': 'client', + 'bidder': 'eywamedia', + 'bidderRequestId': '14d8cbc769114b' + }, + { + 'auctionId': 'fc917230-a5e1-4a42-b7d9-8fb776124e43', + 'sizes': [[728, 90]], + 'bidRequestsCount': 1, + 'params': { + 'publisherId': '1234_abcd' + }, + 'mediaTypes': { + 'banner': { + 'sizes': [[728, 90]] + } + }, + 'crumbs': { + 'pubcid': '8b640d4e-1f6d-4fd3-b63f-2570572d8100' + }, + 'bidId': '28b09d0543d672', + 'adUnitCode': 'div-gpt-ad-1460505748561-0', + 'transactionId': 'd909c39c-ecc9-41a4-897c-2d2fdfdf41b2', + 'src': 'client', + 'bidder': 'eywamedia', + 'bidderRequestId': '14d8cbc769114b' + } + ] + } + }; + bidResponses = [ + { + 'ad': '', + 'bidderCode': 'eywamedia', + 'cpm': 1, + 'creativeId': '28b09d0543d671', + 'currency': 'USD', + 'height': 250, + 'mediaType': 'banner', + 'netRevenue': true, + 'requestId': '28b09d0543d671', + 'transactionId': 'd909c39c-ecc9-41a4-897c-2d2fdfdf41b1', + 'ttl': 360, + 'width': 300 + }, + { + 'ad': '', + 'bidderCode': 'eywamedia', + 'cpm': 1, + 'creativeId': '28b09d0543d672', + 'currency': 'USD', + 'height': 90, + 'mediaType': 'banner', + 'netRevenue': true, + 'requestId': '28b09d0543d672', + 'transactionId': 'd909c39c-ecc9-41a4-897c-2d2fdfdf41b2', + 'ttl': 360, + 'width': 728 + } + ] + }); + + it('should respond with empty response when there is empty serverResponse', function () { + let result = spec.interpretResponse({ body: {} }, bidRequest); + assert.deepEqual(result, []); + }); + + it('should respond with multile response when there is multiple serverResponse', function () { + let result = spec.interpretResponse(serverResponse, bidRequest); + assert.deepEqual(result, bidResponses); + }); + }); +}); diff --git a/test/spec/modules/feedadBidAdapter_spec.js b/test/spec/modules/feedadBidAdapter_spec.js new file mode 100644 index 00000000000..3432a40eca4 --- /dev/null +++ b/test/spec/modules/feedadBidAdapter_spec.js @@ -0,0 +1,433 @@ +import {expect} from 'chai'; +import {spec} from 'modules/feedadBidAdapter'; +import {BANNER, NATIVE, VIDEO} from '../../../src/mediaTypes'; +import * as sinon from 'sinon'; + +const CODE = 'feedad'; + +describe('FeedAdAdapter', function () { + describe('Public API', function () { + it('should have the FeedAd bidder code', function () { + expect(spec.code).to.equal(CODE); + }); + it('should only support video and banner ads', function () { + expect(spec.supportedMediaTypes).to.be.a('array'); + expect(spec.supportedMediaTypes).to.include(BANNER); + expect(spec.supportedMediaTypes).to.include(VIDEO); + expect(spec.supportedMediaTypes).not.to.include(NATIVE); + }); + it('should export the BidderSpec functions', function () { + expect(spec.isBidRequestValid).to.be.a('function'); + expect(spec.buildRequests).to.be.a('function'); + expect(spec.interpretResponse).to.be.a('function'); + expect(spec.onTimeout).to.be.a('function'); + expect(spec.onBidWon).to.be.a('function'); + }); + }); + + describe('isBidRequestValid', function () { + it('should detect missing params', function () { + let result = spec.isBidRequestValid({ + bidder: 'feedad', + sizes: [] + }); + expect(result).to.equal(false); + }); + it('should detect missing client token', function () { + let result = spec.isBidRequestValid({ + bidder: 'feedad', + sizes: [], + params: {placementId: 'placement'} + }); + expect(result).to.equal(false); + }); + it('should detect zero length client token', function () { + let result = spec.isBidRequestValid({ + bidder: 'feedad', + sizes: [], + params: {clientToken: '', placementId: 'placement'} + }); + expect(result).to.equal(false); + }); + it('should detect missing placement id', function () { + let result = spec.isBidRequestValid({ + bidder: 'feedad', + sizes: [], + params: {clientToken: 'clientToken'} + }); + expect(result).to.equal(false); + }); + it('should detect zero length placement id', function () { + let result = spec.isBidRequestValid({ + bidder: 'feedad', + sizes: [], + params: {clientToken: 'clientToken', placementId: ''} + }); + expect(result).to.equal(false); + }); + it('should detect too long placement id', function () { + var placementId = ''; + for (var i = 0; i < 300; i++) { + placementId += 'a'; + } + let result = spec.isBidRequestValid({ + bidder: 'feedad', + sizes: [], + params: {clientToken: 'clientToken', placementId} + }); + expect(result).to.equal(false); + }); + it('should detect invalid placement id', function () { + [ + 'placement id with spaces', + 'some|id', + 'PLACEMENTID', + 'placeme:ntId' + ].forEach(id => { + let result = spec.isBidRequestValid({ + bidder: 'feedad', + sizes: [], + params: {clientToken: 'clientToken', placementId: id} + }); + expect(result).to.equal(false); + }); + }); + it('should accept valid parameters', function () { + let result = spec.isBidRequestValid({ + bidder: 'feedad', + sizes: [], + params: {clientToken: 'clientToken', placementId: 'placement-id'} + }); + expect(result).to.equal(true); + }); + }); + + describe('buildRequests', function () { + const bidderRequest = { + refererInfo: { + referer: 'the referer' + }, + some: 'thing' + }; + + it('should accept empty lists', function () { + let result = spec.buildRequests([], bidderRequest); + expect(result).to.be.empty; + }); + it('should filter native media types', function () { + let bid = { + code: 'feedad', + mediaTypes: { + native: { + sizes: [[300, 250], [300, 600]], + } + }, + params: {clientToken: 'clientToken', placementId: 'placement-id'} + }; + let result = spec.buildRequests([bid], bidderRequest); + expect(result).to.be.empty; + }); + it('should filter video media types without outstream context', function () { + let bid = { + code: 'feedad', + mediaTypes: { + video: { + context: 'instream' + } + }, + params: {clientToken: 'clientToken', placementId: 'placement-id'} + }; + let result = spec.buildRequests([bid], bidderRequest); + expect(result).to.be.empty; + }); + it('should pass through outstream video media', function () { + let bid = { + code: 'feedad', + mediaTypes: { + video: { + context: 'outstream' + } + }, + params: {clientToken: 'clientToken', placementId: 'placement-id'} + }; + let result = spec.buildRequests([bid], bidderRequest); + expect(result.data.bids).to.be.lengthOf(1); + expect(result.data.bids[0]).to.deep.equal(bid); + }); + it('should pass through banner media', function () { + let bid = { + code: 'feedad', + mediaTypes: { + banner: { + sizes: [[320, 250]] + } + }, + params: {clientToken: 'clientToken', placementId: 'placement-id'} + }; + let result = spec.buildRequests([bid], bidderRequest); + expect(result.data.bids).to.be.lengthOf(1); + expect(result.data.bids[0]).to.deep.equal(bid); + }); + it('should detect empty media types', function () { + let bid = { + code: 'feedad', + mediaTypes: { + banner: undefined, + video: undefined, + native: undefined + }, + params: {clientToken: 'clientToken', placementId: 'placement-id'} + }; + let result = spec.buildRequests([bid], bidderRequest); + expect(result).to.be.empty; + }); + it('should use POST', function () { + let bid = { + code: 'feedad', + mediaTypes: { + banner: { + sizes: [[320, 250]] + } + }, + params: {clientToken: 'clientToken', placementId: 'placement-id'} + }; + let result = spec.buildRequests([bid], bidderRequest); + expect(result.method).to.equal('POST'); + }); + it('should use the correct URL', function () { + let bid = { + code: 'feedad', + mediaTypes: { + banner: { + sizes: [[320, 250]] + } + }, + params: {clientToken: 'clientToken', placementId: 'placement-id'} + }; + let result = spec.buildRequests([bid], bidderRequest); + expect(result.url).to.equal('https://api.feedad.com/1/prebid/web/bids'); + }); + it('should specify the content type explicitly', function () { + let bid = { + code: 'feedad', + mediaTypes: { + banner: { + sizes: [[320, 250]] + } + }, + params: {clientToken: 'clientToken', placementId: 'placement-id'} + }; + let result = spec.buildRequests([bid], bidderRequest); + expect(result.options).to.deep.equal({ + contentType: 'application/json' + }) + }); + it('should include the bidder request', function () { + let bid = { + code: 'feedad', + mediaTypes: { + banner: { + sizes: [[320, 250]] + } + }, + params: {clientToken: 'clientToken', placementId: 'placement-id'} + }; + let result = spec.buildRequests([bid, bid, bid], bidderRequest); + expect(result.data).to.deep.include(bidderRequest); + }); + it('should detect missing bidder request parameter', function () { + let bid = { + code: 'feedad', + mediaTypes: { + banner: { + sizes: [[320, 250]] + } + }, + params: {clientToken: 'clientToken', placementId: 'placement-id'} + }; + let result = spec.buildRequests([bid, bid, bid]); + expect(result).to.be.empty; + }); + }); + + describe('interpretResponse', function () { + const body = [{ + foo: 'bar', + sub: { + obj: 5 + } + }, { + bar: 'foo' + }]; + + it('should convert string bodies to JSON', function () { + let result = spec.interpretResponse({body: JSON.stringify(body)}); + expect(result).to.deep.equal(body); + }); + + it('should pass through body objects', function () { + let result = spec.interpretResponse({body}); + expect(result).to.deep.equal(body); + }); + }); + + describe('event tracking calls', function () { + const clientToken = 'clientToken'; + const placementId = 'placement id'; + const auctionId = 'the auction id'; + const bidId = 'the bid id'; + const transactionId = 'the transaction id'; + const referer = 'the referer'; + const bidderRequest = { + refererInfo: { + referer: referer + }, + some: 'thing' + }; + const bid = { + 'bidder': 'feedad', + 'params': { + 'clientToken': 'fupp', + 'placementId': 'prebid-test' + }, + 'crumbs': { + 'pubcid': '6254a85f-bded-489a-9736-83c45d45ef1d' + }, + 'mediaTypes': { + 'banner': { + 'sizes': [ + [ + 300, + 250 + ] + ] + } + }, + 'adUnitCode': 'div-gpt-ad-1460505748561-0', + 'transactionId': transactionId, + 'sizes': [ + [ + 300, + 250 + ] + ], + 'bidId': bidId, + 'bidderRequestId': '10739fe6fe2127', + 'auctionId': '5ac67dff-d971-4b56-84a3-345a87a1f786', + 'src': 'client', + 'bidRequestsCount': 1 + }; + const timeoutData = { + 'bidId': bidId, + 'bidder': 'feedad', + 'adUnitCode': 'div-gpt-ad-1460505748561-0', + 'auctionId': auctionId, + 'params': [ + { + 'clientToken': clientToken, + 'placementId': placementId + } + ], + 'timeout': 3000 + }; + const bidWonData = { + 'bidderCode': 'feedad', + 'width': 300, + 'height': 250, + 'statusMessage': 'Bid available', + 'adId': '3a4529aa05114d', + 'requestId': bidId, + 'mediaType': 'banner', + 'source': 'client', + 'cpm': 0.5, + 'ad': 'ad content', + 'ttl': 60, + 'creativeId': 'feedad-21-0', + 'netRevenue': true, + 'currency': 'EUR', + 'auctionId': auctionId, + 'responseTimestamp': 1558365914596, + 'requestTimestamp': 1558365914506, + 'bidder': 'feedad', + 'adUnitCode': 'div-gpt-ad-1460505748561-0', + 'timeToRespond': 90, + 'pbLg': '0.50', + 'pbMg': '0.50', + 'pbHg': '0.50', + 'pbAg': '0.50', + 'pbDg': '0.50', + 'pbCg': '', + 'size': '300x250', + 'adserverTargeting': { + 'hb_bidder': 'feedad', + 'hb_adid': '3a4529aa05114d', + 'hb_pb': '0.50', + 'hb_size': '300x250', + 'hb_source': 'client', + 'hb_format': 'banner' + }, + 'status': 'rendered', + 'params': [ + { + 'clientToken': clientToken, + 'placementId': placementId + } + ] + }; + const cases = [ + ['onTimeout', timeoutData, 'prebid_bidTimeout'], + ['onBidWon', bidWonData, 'prebid_bidWon'], + ]; + + cases.forEach(([name, data, eventKlass]) => { + let subject = spec[name]; + describe(name + ' handler', function () { + let xhr; + let requests; + + beforeEach(function () { + xhr = sinon.useFakeXMLHttpRequest(); + requests = []; + xhr.onCreate = xhr => requests.push(xhr); + }); + + afterEach(function () { + xhr.restore(); + }); + + it('should do nothing on empty data', function () { + subject(undefined); + subject(null); + expect(requests.length).to.equal(0); + }); + + it('should do nothing when bid metadata is not set', function () { + subject(data); + expect(requests.length).to.equal(0); + }); + + it('should send tracking params when correct metadata was set', function () { + spec.buildRequests([bid], bidderRequest); + let expectedData = { + app_hybrid: false, + client_token: clientToken, + placement_id: placementId, + klass: eventKlass, + prebid_auction_id: auctionId, + prebid_bid_id: bidId, + prebid_transaction_id: transactionId, + referer, + sdk_version: '1.0.0' + }; + subject(data); + expect(requests.length).to.equal(1); + let call = requests[0]; + expect(call.url).to.equal('https://api.feedad.com/1/prebid/web/events'); + expect(JSON.parse(call.requestBody)).to.deep.equal(expectedData); + expect(call.method).to.equal('POST'); + expect(call.requestHeaders).to.include({'Content-Type': 'application/json;charset=utf-8'}); + }) + }); + }); + }); +}); diff --git a/test/spec/modules/freeWheelAdserverVideo_spec.js b/test/spec/modules/freeWheelAdserverVideo_spec.js index 5846774c8b1..f958a2733db 100644 --- a/test/spec/modules/freeWheelAdserverVideo_spec.js +++ b/test/spec/modules/freeWheelAdserverVideo_spec.js @@ -1,13 +1,13 @@ import { expect } from 'chai'; -import { getTargeting } from 'modules/freeWheelAdserverVideo'; +import { adpodUtils } from 'modules/freeWheelAdserverVideo'; import { auctionManager } from 'src/auctionManager'; import { config } from 'src/config'; -import * as adpod from 'modules/adpod'; describe('freeWheel adserver module', function() { let amStub; let amGetAdUnitsStub; - let pbcStub; + let xhr; + let requests; before(function () { let adUnits = [{ @@ -53,12 +53,13 @@ describe('freeWheel adserver module', function() { amGetAdUnitsStub = sinon.stub(auctionManager, 'getAdUnits'); amGetAdUnitsStub.returns(adUnits); amStub = sinon.stub(auctionManager, 'getBidsReceived'); - pbcStub = sinon.stub(adpod, 'callPrebidCacheAfterAuction').callsFake(function (...args) { - args[1](null, getBidsReceived()); - }); }); beforeEach(function () { + xhr = sinon.useFakeXMLHttpRequest(); + requests = []; + xhr.onCreate = request => requests.push(request); + config.setConfig({ adpod: { brandCategoryExclusion: false, @@ -69,6 +70,7 @@ describe('freeWheel adserver module', function() { afterEach(function() { config.resetConfig(); + xhr.restore(); }); after(function () { @@ -79,7 +81,7 @@ describe('freeWheel adserver module', function() { it('should return targeting for all adunits', function() { amStub.returns(getBidsReceived()); let targeting; - getTargeting({ + adpodUtils.getTargeting({ callback: function(errorMsg, targetingResult) { targeting = targetingResult; } @@ -92,7 +94,7 @@ describe('freeWheel adserver module', function() { it('should return targeting for passed adunit code', function() { amStub.returns(getBidsReceived()); let targeting; - getTargeting({ + adpodUtils.getTargeting({ codes: ['preroll_1'], callback: function(errorMsg, targetingResult) { targeting = targetingResult; @@ -121,7 +123,7 @@ describe('freeWheel adserver module', function() { }]; amStub.returns(getBidsReceived().concat(bannerBid)); let targeting; - getTargeting({ + adpodUtils.getTargeting({ callback: function(errorMsg, targetingResult) { targeting = targetingResult; } @@ -145,7 +147,7 @@ describe('freeWheel adserver module', function() { createBid(10, 'preroll_1', 30, '10.00_395_30s', '123', '395') ]); let targeting; - getTargeting({ + adpodUtils.getTargeting({ callback: function(errorMsg, targetingResult) { targeting = targetingResult; } @@ -162,7 +164,7 @@ describe('freeWheel adserver module', function() { createBid(15, 'midroll_1', 90, '15.00_406_90s', '123', '406') ]); let targeting; - getTargeting({ + adpodUtils.getTargeting({ callback: function(errorMsg, targetingResult) { targeting = targetingResult; } @@ -180,15 +182,20 @@ describe('freeWheel adserver module', function() { }); amStub.returns(getBidsReceived()); let targeting; - getTargeting({ + adpodUtils.getTargeting({ callback: function(errorMsg, targetingResult) { targeting = targetingResult; } }); - expect(pbcStub.called).to.equal(true); + requests[0].respond( + 200, + { 'Content-Type': 'text/plain' }, + JSON.stringify({'responses': getBidsReceived().slice(0, 4)}) + ); + expect(targeting['preroll_1'].length).to.equal(3); - expect(targeting['midroll_1'].length).to.equal(4); + expect(targeting['midroll_1'].length).to.equal(3); }); }); diff --git a/test/spec/modules/gamoshiBidAdapter_spec.js b/test/spec/modules/gamoshiBidAdapter_spec.js index 896271be4d3..a2c4eebc213 100644 --- a/test/spec/modules/gamoshiBidAdapter_spec.js +++ b/test/spec/modules/gamoshiBidAdapter_spec.js @@ -166,12 +166,12 @@ describe('GamoshiAdapter', function () { const bidRequestWithVideo = utils.deepClone(bidRequest); bidRequestWithVideo.mediaTypes = { video: { - sizes: [[300, 250], [120, 600]] + playerSize: [302, 252] } }; response = spec.buildRequests([bidRequestWithVideo], bidRequest)[0]; - expect(response.data.imp[0].video.w).to.equal(bidRequestWithVideo.mediaTypes.video.sizes[0][0]); - expect(response.data.imp[0].video.h).to.equal(bidRequestWithVideo.mediaTypes.video.sizes[0][1]); + expect(response.data.imp[0].video.w).to.equal(bidRequestWithVideo.mediaTypes.video.playerSize[0][0]); + expect(response.data.imp[0].video.h).to.equal(bidRequestWithVideo.mediaTypes.video.playerSize[0][1]); expect(response.data.imp[0].video.pos).to.equal(0); const bidRequestWithPosEquals1 = utils.deepClone(bidRequestWithVideo); bidRequestWithPosEquals1.params.pos = 1; @@ -202,6 +202,29 @@ describe('GamoshiAdapter', function () { expect(response.data.imp[0].video.ext.context).to.equal(null); }); + it('builds request video object correctly with multi-dimensions size array', function () { + let response; + const bidRequestWithVideo = utils.deepClone(bidRequest); + bidRequestWithVideo.mediaTypes.video = { + playerSize: [[304, 254], [305, 255]], + context: 'instream' + }; + + response = spec.buildRequests([bidRequestWithVideo], bidRequest)[0]; + expect(response.data.imp[1].video.ext.context).to.equal('instream'); + bidRequestWithVideo.mediaTypes.video.context = 'outstream'; + + const bidRequestWithPosEquals1 = utils.deepClone(bidRequestWithVideo); + bidRequestWithPosEquals1.mediaTypes.video.context = 'outstream'; + response = spec.buildRequests([bidRequestWithPosEquals1], bidRequest)[0]; + expect(response.data.imp[1].video.ext.context).to.equal('outstream'); + + const bidRequestWithPosEquals2 = utils.deepClone(bidRequestWithVideo); + bidRequestWithPosEquals2.mediaTypes.video.context = null; + response = spec.buildRequests([bidRequestWithPosEquals2], bidRequest)[0]; + expect(response.data.imp[1].video.ext.context).to.equal(null); + }); + it('builds request with gdpr consent', function () { let response = spec.buildRequests([bidRequest], bidRequest)[0]; expect(response.data.ext).to.have.property('gdpr_consent'); @@ -306,6 +329,8 @@ describe('GamoshiAdapter', function () { ] }; + const TTL = 360; + it('returns an empty array on missing response', function () { let response; @@ -322,13 +347,12 @@ describe('GamoshiAdapter', function () { const response = spec.interpretResponse({body: rtbResponse}, {bidRequest: bannerBidRequest}); expect(Array.isArray(response)).to.equal(true); expect(response.length).to.equal(1); - const ad0 = response[0]; expect(ad0.requestId).to.equal(bannerBidRequest.bidId); expect(ad0.cpm).to.equal(rtbResponse.seatbid[1].bid[0].price); expect(ad0.width).to.equal(rtbResponse.seatbid[1].bid[0].w); expect(ad0.height).to.equal(rtbResponse.seatbid[1].bid[0].h); - expect(ad0.ttl).to.equal(60 * 10); + expect(ad0.ttl).to.equal(TTL); expect(ad0.creativeId).to.equal(rtbResponse.seatbid[1].bid[0].crid); expect(ad0.netRevenue).to.equal(true); expect(ad0.currency).to.equal(rtbResponse.seatbid[1].bid[0].cur || rtbResponse.cur || 'USD'); @@ -341,13 +365,12 @@ describe('GamoshiAdapter', function () { const response = spec.interpretResponse({body: rtbResponse}, {bidRequest: videoBidRequest}); expect(Array.isArray(response)).to.equal(true); expect(response.length).to.equal(1); - const ad0 = response[0]; expect(ad0.requestId).to.equal(videoBidRequest.bidId); expect(ad0.cpm).to.equal(rtbResponse.seatbid[0].bid[0].price); expect(ad0.width).to.equal(rtbResponse.seatbid[0].bid[0].w); expect(ad0.height).to.equal(rtbResponse.seatbid[0].bid[0].h); - expect(ad0.ttl).to.equal(60 * 10); + expect(ad0.ttl).to.equal(TTL); expect(ad0.creativeId).to.equal(rtbResponse.seatbid[0].bid[0].crid); expect(ad0.netRevenue).to.equal(true); expect(ad0.currency).to.equal(rtbResponse.seatbid[0].bid[0].cur || rtbResponse.cur || 'USD'); diff --git a/test/spec/modules/gridBidAdapter_spec.js b/test/spec/modules/gridBidAdapter_spec.js index 9be195b4bd2..a191d2211f5 100644 --- a/test/spec/modules/gridBidAdapter_spec.js +++ b/test/spec/modules/gridBidAdapter_spec.js @@ -47,6 +47,8 @@ describe('TheMediaGrid Adapter', function () { }); return res; } + const bidderRequest = {refererInfo: {referer: 'http://example.com'}}; + const referrer = bidderRequest.refererInfo.referer; let bidRequests = [ { 'bidder': 'grid', @@ -84,27 +86,30 @@ describe('TheMediaGrid Adapter', function () { ]; it('should attach valid params to the tag', function () { - const request = spec.buildRequests([bidRequests[0]]); + const request = spec.buildRequests([bidRequests[0]], bidderRequest); expect(request.data).to.be.an('string'); const payload = parseRequest(request.data); - expect(payload).to.have.property('u').that.is.a('string'); + expect(payload).to.have.property('u', referrer); expect(payload).to.have.property('auids', '1'); + expect(payload).to.have.property('sizes', '300x250,300x600'); expect(payload).to.have.property('r', '22edbae2733bf6'); }); it('auids must not be duplicated', function () { - const request = spec.buildRequests(bidRequests); + const request = spec.buildRequests(bidRequests, bidderRequest); expect(request.data).to.be.an('string'); const payload = parseRequest(request.data); - expect(payload).to.have.property('u').that.is.a('string'); - expect(payload).to.have.property('auids', '1,2'); + expect(payload).to.have.property('u', referrer); + expect(payload).to.have.property('auids', '1,1,2'); + expect(payload).to.have.property('sizes', '300x250,300x600,728x90'); expect(payload).to.have.property('r', '22edbae2733bf6'); }); it('if gdprConsent is present payload must have gdpr params', function () { - const request = spec.buildRequests(bidRequests, {gdprConsent: {consentString: 'AAA', gdprApplies: true}}); + const request = spec.buildRequests(bidRequests, {gdprConsent: {consentString: 'AAA', gdprApplies: true}, refererInfo: bidderRequest.refererInfo}); expect(request.data).to.be.an('string'); const payload = parseRequest(request.data); + expect(payload).to.have.property('u', referrer); expect(payload).to.have.property('gdpr_consent', 'AAA'); expect(payload).to.have.property('gdpr_applies', '1'); }); @@ -129,9 +134,10 @@ describe('TheMediaGrid Adapter', function () { describe('interpretResponse', function () { const responses = [ {'bid': [{'price': 1.15, 'adm': '
    test content 1
    ', 'auid': 1, 'h': 250, 'w': 300, dealid: 11}], 'seat': '1'}, - {'bid': [{'price': 0.5, 'adm': '
    test content 2
    ', 'auid': 2, 'h': 90, 'w': 728}], 'seat': '1'}, + {'bid': [{'price': 0.5, 'adm': '
    test content 2
    ', 'auid': 2, 'h': 600, 'w': 300}], 'seat': '1'}, + {'bid': [{'price': 0.15, 'adm': '
    test content 3
    ', 'auid': 1, 'h': 90, 'w': 728}], 'seat': '1'}, {'bid': [{'price': 0, 'auid': 3, 'h': 250, 'w': 300}], 'seat': '1'}, - {'bid': [{'price': 0, 'adm': '
    test content 4
    ', 'h': 250, 'w': 300}], 'seat': '1'}, + {'bid': [{'price': 0, 'adm': '
    test content 5
    ', 'h': 250, 'w': 300}], 'seat': '1'}, undefined, {'bid': [], 'seat': '1'}, {'seat': '1'}, @@ -226,13 +232,13 @@ describe('TheMediaGrid Adapter', function () { 'ttl': 360, }, { - 'requestId': '5703af74d0472a', - 'cpm': 1.15, - 'creativeId': 1, - 'dealId': 11, + 'requestId': '4dff80cc4ee346', + 'cpm': 0.5, + 'creativeId': 2, + 'dealId': undefined, 'width': 300, - 'height': 250, - 'ad': '
    test content 1
    ', + 'height': 600, + 'ad': '
    test content 2
    ', 'bidderCode': 'grid', 'currency': 'USD', 'mediaType': 'banner', @@ -240,13 +246,13 @@ describe('TheMediaGrid Adapter', function () { 'ttl': 360, }, { - 'requestId': '4dff80cc4ee346', - 'cpm': 0.5, - 'creativeId': 2, + 'requestId': '5703af74d0472a', + 'cpm': 0.15, + 'creativeId': 1, 'dealId': undefined, 'width': 728, 'height': 90, - 'ad': '
    test content 2
    ', + 'ad': '
    test content 3
    ', 'bidderCode': 'grid', 'currency': 'USD', 'mediaType': 'banner', @@ -255,7 +261,7 @@ describe('TheMediaGrid Adapter', function () { } ]; - const result = spec.interpretResponse({'body': {'seatbid': [responses[0], responses[1]]}}, request); + const result = spec.interpretResponse({'body': {'seatbid': responses.slice(0, 3)}}, request); expect(result).to.deep.equal(expectedResponse); }); @@ -264,7 +270,7 @@ describe('TheMediaGrid Adapter', function () { { 'bidder': 'grid', 'params': { - 'uid': '1' + 'uid': '11' }, 'adUnitCode': 'adunit-code-1', 'sizes': [[300, 250], [300, 600]], @@ -280,7 +286,7 @@ describe('TheMediaGrid Adapter', function () { { 'bidder': 'grid', 'params': { - 'uid': '2' + 'uid': '12' }, 'adUnitCode': 'adunit-code-1', 'sizes': [[300, 250], [300, 600]], @@ -295,15 +301,15 @@ describe('TheMediaGrid Adapter', function () { } ]; const response = [ - {'bid': [{'price': 1.15, 'adm': '\n<\/Ad>\n<\/VAST>', 'auid': 1, content_type: 'video', w: 300, h: 600}], 'seat': '2'}, - {'bid': [{'price': 1.00, 'adm': '\n<\/Ad>\n<\/VAST>', 'auid': 2, content_type: 'video'}], 'seat': '2'} + {'bid': [{'price': 1.15, 'adm': '\n<\/Ad>\n<\/VAST>', 'auid': 11, content_type: 'video', w: 300, h: 600}], 'seat': '2'}, + {'bid': [{'price': 1.00, 'adm': '\n<\/Ad>\n<\/VAST>', 'auid': 12, content_type: 'video'}], 'seat': '2'} ]; const request = spec.buildRequests(bidRequests); const expectedResponse = [ { 'requestId': '659423fff799cb', 'cpm': 1.15, - 'creativeId': 1, + 'creativeId': 11, 'dealId': undefined, 'width': 300, 'height': 600, @@ -316,23 +322,6 @@ describe('TheMediaGrid Adapter', function () { 'adResponse': { 'content': '\n<\/Ad>\n<\/VAST>' } - }, - { - 'requestId': '2bc598e42b6a', - 'cpm': 1.00, - 'creativeId': 2, - 'dealId': undefined, - 'width': 300, - 'height': 250, - 'bidderCode': 'grid', - 'currency': 'USD', - 'mediaType': 'video', - 'netRevenue': false, - 'ttl': 360, - 'vastXml': '\n<\/Ad>\n<\/VAST>', - 'adResponse': { - 'content': '\n<\/Ad>\n<\/VAST>' - } } ]; @@ -380,5 +369,210 @@ describe('TheMediaGrid Adapter', function () { const result = spec.interpretResponse({'body': {'seatbid': responses.slice(2)}}, request); expect(result.length).to.equal(0); }); + + it('complicated case', function () { + const fullResponse = [ + {'bid': [{'price': 1.15, 'adm': '
    test content 1
    ', 'auid': 1, 'h': 250, 'w': 300, dealid: 11}], 'seat': '1'}, + {'bid': [{'price': 0.5, 'adm': '
    test content 2
    ', 'auid': 2, 'h': 600, 'w': 300, dealid: 12}], 'seat': '1'}, + {'bid': [{'price': 0.15, 'adm': '
    test content 3
    ', 'auid': 1, 'h': 90, 'w': 728}], 'seat': '1'}, + {'bid': [{'price': 0.15, 'adm': '
    test content 4
    ', 'auid': 1, 'h': 600, 'w': 300}], 'seat': '1'}, + {'bid': [{'price': 0.5, 'adm': '
    test content 5
    ', 'auid': 2, 'h': 600, 'w': 350}], 'seat': '1'}, + ]; + const bidRequests = [ + { + 'bidder': 'grid', + 'params': { + 'uid': '1' + }, + 'adUnitCode': 'adunit-code-1', + 'sizes': [[300, 250], [300, 600]], + 'bidId': '2164be6358b9', + 'bidderRequestId': '106efe3247', + 'auctionId': '32a1f276cb87cb8', + }, + { + 'bidder': 'grid', + 'params': { + 'uid': '1' + }, + 'adUnitCode': 'adunit-code-1', + 'sizes': [[300, 250], [300, 600]], + 'bidId': '326bde7fbf69', + 'bidderRequestId': '106efe3247', + 'auctionId': '32a1f276cb87cb8', + }, + { + 'bidder': 'grid', + 'params': { + 'uid': '2' + }, + 'adUnitCode': 'adunit-code-1', + 'sizes': [[300, 250], [300, 600]], + 'bidId': '4e111f1b66e4', + 'bidderRequestId': '106efe3247', + 'auctionId': '32a1f276cb87cb8', + }, + { + 'bidder': 'grid', + 'params': { + 'uid': '1' + }, + 'adUnitCode': 'adunit-code-2', + 'sizes': [[728, 90]], + 'bidId': '26d6f897b516', + 'bidderRequestId': '106efe3247', + 'auctionId': '32a1f276cb87cb8', + }, + { + 'bidder': 'grid', + 'params': { + 'uid': '2' + }, + 'adUnitCode': 'adunit-code-2', + 'sizes': [[728, 90]], + 'bidId': '1751cd90161', + 'bidderRequestId': '106efe3247', + 'auctionId': '32a1f276cb87cb8', + } + ]; + const request = spec.buildRequests(bidRequests); + const expectedResponse = [ + { + 'requestId': '2164be6358b9', + 'cpm': 1.15, + 'creativeId': 1, + 'dealId': 11, + 'width': 300, + 'height': 250, + 'ad': '
    test content 1
    ', + 'bidderCode': 'grid', + 'currency': 'USD', + 'mediaType': 'banner', + 'netRevenue': false, + 'ttl': 360, + }, + { + 'requestId': '4e111f1b66e4', + 'cpm': 0.5, + 'creativeId': 2, + 'dealId': 12, + 'width': 300, + 'height': 600, + 'ad': '
    test content 2
    ', + 'bidderCode': 'grid', + 'currency': 'USD', + 'mediaType': 'banner', + 'netRevenue': false, + 'ttl': 360, + }, + { + 'requestId': '26d6f897b516', + 'cpm': 0.15, + 'creativeId': 1, + 'dealId': undefined, + 'width': 728, + 'height': 90, + 'ad': '
    test content 3
    ', + 'bidderCode': 'grid', + 'currency': 'USD', + 'mediaType': 'banner', + 'netRevenue': false, + 'ttl': 360, + }, + { + 'requestId': '326bde7fbf69', + 'cpm': 0.15, + 'creativeId': 1, + 'dealId': undefined, + 'width': 300, + 'height': 600, + 'ad': '
    test content 4
    ', + 'bidderCode': 'grid', + 'currency': 'USD', + 'mediaType': 'banner', + 'netRevenue': false, + 'ttl': 360, + } + ]; + + const result = spec.interpretResponse({'body': {'seatbid': fullResponse}}, request); + expect(result).to.deep.equal(expectedResponse); + }); + + it('dublicate uids and sizes in one slot', function () { + const fullResponse = [ + {'bid': [{'price': 1.15, 'adm': '
    test content 1
    ', 'auid': 1, 'h': 250, 'w': 300}], 'seat': '1'}, + {'bid': [{'price': 0.5, 'adm': '
    test content 2
    ', 'auid': 1, 'h': 250, 'w': 300}], 'seat': '1'}, + ]; + const bidRequests = [ + { + 'bidder': 'grid', + 'params': { + 'uid': '1' + }, + 'adUnitCode': 'adunit-code-1', + 'sizes': [[300, 250], [300, 600]], + 'bidId': '5126e301f4be', + 'bidderRequestId': '171c5405a390', + 'auctionId': '35bcbc0f7e79c', + }, + { + 'bidder': 'grid', + 'params': { + 'uid': '1' + }, + 'adUnitCode': 'adunit-code-1', + 'sizes': [[300, 250], [300, 600]], + 'bidId': '57b2ebe70e16', + 'bidderRequestId': '171c5405a390', + 'auctionId': '35bcbc0f7e79c', + }, + { + 'bidder': 'grid', + 'params': { + 'uid': '1' + }, + 'adUnitCode': 'adunit-code-1', + 'sizes': [[300, 250], [300, 600]], + 'bidId': '225fcd44b18c', + 'bidderRequestId': '171c5405a390', + 'auctionId': '35bcbc0f7e79c', + } + ]; + const request = spec.buildRequests(bidRequests); + const expectedResponse = [ + { + 'requestId': '5126e301f4be', + 'cpm': 1.15, + 'creativeId': 1, + 'dealId': undefined, + 'width': 300, + 'height': 250, + 'ad': '
    test content 1
    ', + 'bidderCode': 'grid', + 'currency': 'USD', + 'mediaType': 'banner', + 'netRevenue': false, + 'ttl': 360, + }, + { + 'requestId': '57b2ebe70e16', + 'cpm': 0.5, + 'creativeId': 1, + 'dealId': undefined, + 'width': 300, + 'height': 250, + 'ad': '
    test content 2
    ', + 'bidderCode': 'grid', + 'currency': 'USD', + 'mediaType': 'banner', + 'netRevenue': false, + 'ttl': 360, + } + ]; + + const result = spec.interpretResponse({'body': {'seatbid': fullResponse}}, request); + expect(result).to.deep.equal(expectedResponse); + }); }); }); diff --git a/test/spec/modules/gumgumBidAdapter_spec.js b/test/spec/modules/gumgumBidAdapter_spec.js index c067f50fa56..cedef568d56 100644 --- a/test/spec/modules/gumgumBidAdapter_spec.js +++ b/test/spec/modules/gumgumBidAdapter_spec.js @@ -80,11 +80,40 @@ describe('gumgumAdapter', function () { expect(request.method).to.equal('GET'); expect(request.id).to.equal('30b31c1838de1e'); }); + it('should correctly set the request paramters depending on params field', function () { + const request = Object.assign({}, bidRequests[0]); + delete request.params; + request.params = { + 'inScreen': '10433394', + 'bidfloor': 0.05 + }; + const bidRequest = spec.buildRequests([request])[0]; + expect(bidRequest.data.pi).to.equal(2); + expect(bidRequest.data).to.include.any.keys('t'); + expect(bidRequest.data).to.include.any.keys('fp'); + }); + it('should correctly set the request paramters depending on params field', function () { + const request = Object.assign({}, bidRequests[0]); + delete request.params; + request.params = { + 'ICV': '10433395' + }; + const bidRequest = spec.buildRequests([request])[0]; + expect(bidRequest.data.pi).to.equal(5); + expect(bidRequest.data).to.include.any.keys('ni'); + }); + it('should not add additional parameters depending on params field', function () { + const request = spec.buildRequests(bidRequests)[0]; + expect(request.data).to.not.include.any.keys('ni'); + expect(request.data).to.not.include.any.keys('t'); + expect(request.data).to.not.include.any.keys('eAdBuyId'); + expect(request.data).to.not.include.any.keys('adBuyId'); + }); it('should add consent parameters if gdprConsent is present', function () { const gdprConsent = { consentString: 'BOJ/P2HOJ/P2HABABMAAAAAZ+A==', gdprApplies: true }; const fakeBidRequest = { gdprConsent: gdprConsent }; const bidRequest = spec.buildRequests(bidRequests, fakeBidRequest)[0]; - expect(bidRequest.data.gdprApplies).to.eq(true); + expect(bidRequest.data.gdprApplies).to.eq(1); expect(bidRequest.data.gdprConsent).to.eq('BOJ/P2HOJ/P2HABABMAAAAAZ+A=='); }); it('should handle gdprConsent is present but values are undefined case', function () { @@ -93,6 +122,31 @@ describe('gumgumAdapter', function () { const bidRequest = spec.buildRequests(bidRequests, fakeBidRequest)[0]; expect(bidRequest.data).to.not.include.any.keys('gdprConsent') }); + it('should add a tdid parameter if request contains unified id from TradeDesk', function () { + const unifiedId = { + 'userId': { + 'tdid': 'tradedesk-id' + } + } + const request = Object.assign(unifiedId, bidRequests[0]); + const bidRequest = spec.buildRequests([request])[0]; + expect(bidRequest.data.tdid).to.eq(unifiedId.userId.tdid); + }); + it('should not add a tdid parameter if unified id is not found', function () { + const request = spec.buildRequests(bidRequests)[0]; + expect(request.data).to.not.include.any.keys('tdid'); + }); + it('should send ns parameter if browser contains navigator.connection property', function () { + const bidRequest = spec.buildRequests(bidRequests)[0]; + const connection = window.navigator && window.navigator.connection; + if (connection) { + const downlink = connection.downlink || connection.bandwidth; + expect(bidRequest.data).to.include.any.keys('ns'); + expect(bidRequest.data.ns).to.eq(Math.round(downlink * 1024)); + } else { + expect(bidRequest.data).to.not.include.any.keys('ns'); + } + }); }) describe('interpretResponse', function () { @@ -191,8 +245,8 @@ describe('gumgumAdapter', function () { 'thms': 10000 } let result = spec.interpretResponse({ body: inscreenServerResponse }, inscreenBidRequest); - expect(result[0].width).to.equal('1'); - expect(result[0].height).to.equal('1'); + expect(result[0].width).to.equal(inscreenBidRequest.sizes[0][0].toString()); + expect(result[0].height).to.equal(inscreenBidRequest.sizes[0][1].toString()); }) }) describe('getUserSyncs', function () { diff --git a/test/spec/modules/hpmdnetworkBidAdapter_spec.js b/test/spec/modules/hpmdnetworkBidAdapter_spec.js new file mode 100644 index 00000000000..37ec44f07c4 --- /dev/null +++ b/test/spec/modules/hpmdnetworkBidAdapter_spec.js @@ -0,0 +1,148 @@ +import { expect } from 'chai'; +import { spec } from 'modules/hpmdnetworkBidAdapter'; + +describe('HPMDNetwork Adapter', function() { + describe('isBidRequestValid', function () { + it('should return true when required params found', function () { + const validBid = { + bidder: 'hpmdnetwork', + params: { + placementId: '1' + } + }; + + expect(spec.isBidRequestValid(validBid)).to.equal(true); + }); + + it('should return false for when required params are not passed', function () { + const invalidBid = { + bidder: 'hpmdnetwork', + params: {} + }; + + expect(spec.isBidRequestValid(invalidBid)).to.equal(false); + }); + }); + + describe('buildRequests', function () { + const bidRequests = [ + { + bidId: 'bid1', + bidder: 'hpmdnetwork', + params: { + placementId: '1' + } + }, + { + bidId: 'bid2', + bidder: 'hpmdnetwork', + params: { + placementId: '2', + } + } + ]; + const bidderRequest = { + refererInfo: { + referer: 'https://example.com?foo=bar' + } + }; + + const bidRequest = spec.buildRequests(bidRequests, bidderRequest); + + it('should build single POST request for multiple bids', function() { + expect(bidRequest.method).to.equal('POST'); + expect(bidRequest.url).to.equal('//banner.hpmdnetwork.ru/bidder/request'); + expect(bidRequest.data).to.be.an('object'); + expect(bidRequest.data.places).to.be.an('array'); + expect(bidRequest.data.places).to.have.lengthOf(2); + }); + + it('should pass bid parameters', function() { + const place1 = bidRequest.data.places[0]; + const place2 = bidRequest.data.places[1]; + + expect(place1.placementId).to.equal('1'); + expect(place2.placementId).to.equal('2'); + expect(place1.id).to.equal('bid1'); + expect(place2.id).to.equal('bid2'); + }); + + it('should pass site parameters', function() { + const url = bidRequest.data.url; + + expect(url).to.be.an('String'); + expect(url).to.equal('https://example.com?foo=bar'); + }); + + it('should pass settings', function() { + const settings = bidRequest.data.settings; + + expect(settings).to.be.an('object'); + expect(settings.currency).to.equal('RUB'); + }); + }); + + describe('interpretResponse', function () { + const serverResponse = { + body: { + 'bids': + [ + { + 'cpm': 20, + 'currency': 'RUB', + 'displayUrl': '//banner.hpmdnetwork.ru/bidder/display?dbid=0&vbid=168', + 'id': '1', + 'creativeId': '11111', + }, + { + 'cpm': 30, + 'currency': 'RUB', + 'displayUrl': '//banner.hpmdnetwork.ru/bidder/display?dbid=0&vbid=170', + 'id': '2', + 'creativeId': '22222', + 'width': 300, + 'height': 250, + }, + ] + } + }; + + const bids = spec.interpretResponse(serverResponse); + + it('should return empty array for response with no bids', function() { + const emptyBids = spec.interpretResponse({ body: {} }); + + expect(emptyBids).to.have.lengthOf(0); + }); + + it('should parse all bids from response', function() { + expect(bids).to.have.lengthOf(2); + }); + + it('should parse bid without sizes', function() { + expect(bids[0].requestId).to.equal('1'); + expect(bids[0].cpm).to.equal(20); + expect(bids[0].width).to.equal(1); + expect(bids[0].height).to.equal(1); + expect(bids[0].ttl).to.equal(300); + expect(bids[0].currency).to.equal('RUB'); + expect(bids[0]).to.have.property('creativeId'); + expect(bids[0].creativeId).to.equal('11111'); + expect(bids[0].netRevenue).to.equal(true); + expect(bids[0].ad).to.include(''); + }); + + it('should parse bid with sizes', function() { + expect(bids[1].requestId).to.equal('2'); + expect(bids[1].cpm).to.equal(30); + expect(bids[1].width).to.equal(300); + expect(bids[1].height).to.equal(250); + expect(bids[1].ttl).to.equal(300); + expect(bids[1].currency).to.equal('RUB'); + expect(bids[1]).to.have.property('creativeId'); + expect(bids[1].creativeId).to.equal('22222'); + expect(bids[1].netRevenue).to.equal(true); + expect(bids[1].ad).to.include(''); + }); + }); +}); diff --git a/test/spec/modules/iasBidAdapter_spec.js b/test/spec/modules/iasBidAdapter_spec.js index 21ef9f8e15a..8197ee25856 100644 --- a/test/spec/modules/iasBidAdapter_spec.js +++ b/test/spec/modules/iasBidAdapter_spec.js @@ -116,6 +116,9 @@ describe('iasBidAdapter is an adapter that', function () { it('screen size', function () { expect(val).to.match(/.*sr=[0-9]*\.[0-9]*/); }); + it('url value', function () { + expect(val).to.match(/.*url=https?%3A%2F%2F[^\s$.?#].[^\s]*/); + }); }); it('has property `bidRequest` that is the first passed in bid request', function () { expect(spec.buildRequests(bidRequests)).to.deep.include({ @@ -229,5 +232,112 @@ describe('iasBidAdapter is an adapter that', function () { expect(adapter.interpretResponse(serverResponse, requests)).to.length(2); }); }); + describe('returns a list of bid response that with custom value', function () { + let bidRequests, bidResponse, slots, custom, serverResponse; + beforeEach(function () { + bidRequests = [ + { + adUnitCode: 'one-div-id', + auctionId: 'someAuctionId', + bidId: 'someBidId1', + bidder: 'ias', + bidderRequestId: 'someBidderRequestId', + params: { + pubId: '1234', + adUnitPath: '/a/b/c' + }, + sizes: [ + [10, 20], + [300, 400] + ], + transactionId: 'someTransactionId' + }, + { + adUnitCode: 'two-div-id', + auctionId: 'someAuctionId', + bidId: 'someBidId2', + bidder: 'ias', + bidderRequestId: 'someBidderRequestId', + params: { + pubId: '1234', + adUnitPath: '/d/e/f' + }, + sizes: [ + [50, 60] + ], + transactionId: 'someTransactionId' + } + ]; + const request = { + bidRequest: { + bidId: '102938' + } + }; + slots = {}; + slots['test-div-id'] = { + id: '1234', + vw: ['60', '70'] + }; + slots['test-div-id-two'] = { + id: '5678', + vw: ['80', '90'] + }; + custom = {}; + custom['ias-kw'] = ['IAS_1_KW', 'IAS_2_KW']; + serverResponse = { + body: { + brandSafety: { + adt: 'adtVal', + alc: 'alcVal', + dlm: 'dlmVal', + drg: 'drgVal', + hat: 'hatVal', + off: 'offVal', + vio: 'vioVal' + }, + fr: 'false', + slots: slots, + custom: custom + }, + headers: {} + }; + bidResponse = spec.interpretResponse(serverResponse, request); + }); + it('has IAS keyword `adt` as property', function () { + expect(bidResponse[0]).to.deep.include({ adt: 'adtVal' }); + }); + it('has IAS keyword `alc` as property', function () { + expect(bidResponse[0]).to.deep.include({ alc: 'alcVal' }); + }); + it('has IAS keyword `dlm` as property', function () { + expect(bidResponse[0]).to.deep.include({ dlm: 'dlmVal' }); + }); + it('has IAS keyword `drg` as property', function () { + expect(bidResponse[0]).to.deep.include({ drg: 'drgVal' }); + }); + it('has IAS keyword `hat` as property', function () { + expect(bidResponse[0]).to.deep.include({ hat: 'hatVal' }); + }); + it('has IAS keyword `off` as property', function () { + expect(bidResponse[0]).to.deep.include({ off: 'offVal' }); + }); + it('has IAS keyword `vio` as property', function () { + expect(bidResponse[0]).to.deep.include({ vio: 'vioVal' }); + }); + it('has IAS keyword `fr` as property', function () { + expect(bidResponse[0]).to.deep.include({ fr: 'false' }); + }); + it('has property `slots`', function () { + expect(bidResponse[0]).to.deep.include({ slots: slots }); + }); + it('has property `custom`', function () { + expect(bidResponse[0]).to.deep.include({ custom: custom }); + }); + it('response is the same for multiple slots', function () { + var adapter = spec; + var requests = adapter.buildRequests(bidRequests); + expect(adapter.interpretResponse(serverResponse, requests)).to.length(3); + }); + }); }); }); diff --git a/test/spec/modules/imonomyBidAdapter_spec.js b/test/spec/modules/imonomyBidAdapter_spec.js new file mode 100644 index 00000000000..206e227a3b1 --- /dev/null +++ b/test/spec/modules/imonomyBidAdapter_spec.js @@ -0,0 +1,164 @@ +import { expect } from 'chai'; +import { spec } from 'modules/imonomyBidAdapter'; + +describe('Imonomy Adapter Tests', function () { + const bidsRequest = [ + { + bidder: 'imonomy', + params: { + placementId: '170577', + hbid: '14567718624', + }, + placementCode: 'div-gpt-ad-1460505748561-0', + transactionId: '9f801c02-bbe8-4683-8ed4-bc816ea186bb', + sizes: [ + [300, 250] + ], + bidId: '2faedf1095f815', + bidderRequestId: '18065867f8ae39', + auctionId: '529e1518-b872-45cf-807c-2d41dfa5bcd3' + }, + { + bidder: 'imonomy', + params: { + placementId: '281277', + hbid: '14567718624', + floorPrice: 0.5 + }, + placementCode: 'div-gpt-ad-1460505748561-0', + transactionId: '9f801c02-bbe8-4683-8ed4-bc816ea186bb', + sizes: [ + [728, 90] + ], + bidId: '3c34e2367a3f59', + bidderRequestId: '18065867f8ae39', + auctionId: '529e1518-b872-45cf-807c-2d41dfa5bcd3' + }]; + + const bidsResponse = { + body: { + bids: [ + { + placementid: '170577', + uuid: '2faedf1095f815', + width: 300, + height: 250, + cpm: 0.51, + creative: '', + ttl: 360, + currency: 'USD', + netRevenue: true, + creativeId: 'd30b58c2ba' + } + ] + } + }; + + it('Verifies imonomyAdapter bidder code', function () { + expect(spec.code).to.equal('imonomy'); + }); + + it('Verifies imonomyAdapter bid request validation', function () { + expect(spec.isBidRequestValid(bidsRequest[0])).to.equal(true); + expect(spec.isBidRequestValid(bidsRequest[1])).to.equal(true); + expect(spec.isBidRequestValid({})).to.equal(false); + expect(spec.isBidRequestValid({ params: {} })).to.equal(false); + expect(spec.isBidRequestValid({ params: { hbid: 12345 } })).to.equal(false); + expect(spec.isBidRequestValid({ params: { placementid: 12345 } })).to.equal(false); + expect(spec.isBidRequestValid({ params: { hbid: 12345, placementId: 67890 } })).to.equal(true); + expect(spec.isBidRequestValid({ params: { hbid: 12345, placementId: 67890, floorPrice: 0.8 } })).to.equal(true); + }); + + it('Verify imonomyAdapter build request', function () { + var startTime = new Date().getTime(); + + const request = spec.buildRequests(bidsRequest); + expect(request.url).to.equal('//b.imonomy.com/openrtb/hb/14567718624'); + expect(request.method).to.equal('POST'); + const requestData = JSON.parse(request.data); + + // bids object + let bids = requestData.bids; + expect(bids).to.have.lengthOf(2); + + // first bid request: no floor price + expect(bids[0].uuid).to.equal('2faedf1095f815'); + expect(bids[0].floorprice).to.be.undefined; + expect(bids[0].placementid).to.equal('170577'); + expect(bids[0].hbid).to.equal('14567718624'); + expect(bids[0].trid).to.equal('9f801c02-bbe8-4683-8ed4-bc816ea186bb'); + expect(bids[0].sizes).to.have.lengthOf(1); + expect(bids[0].sizes[0][0]).to.equal(300); + expect(bids[0].sizes[0][1]).to.equal(250); + + // second bid request: with floor price + expect(bids[1].uuid).to.equal('3c34e2367a3f59'); + expect(bids[1].floorprice).to.equal(0.5); + expect(bids[1].placementid).to.equal('281277'); + expect(bids[1].hbid).to.equal('14567718624'); + expect(bids[1].trid).to.equal('9f801c02-bbe8-4683-8ed4-bc816ea186bb'); + expect(bids[1]).to.have.property('sizes') + .that.is.an('array') + .of.length(1) + .that.deep.equals([[728, 90]]); + + // kbConf object + let kbConf = requestData.kbConf; + expect(kbConf.hdbdid).to.equal(bids[0].hbid); + expect(kbConf.hdbdid).to.equal(bids[1].hbid); + expect(kbConf.encode_bid).to.be.undefined; + // kbConf timezone and cb + expect(kbConf.cb).not.to.be.undefined; + expect(kbConf.ts_as).to.be.above(startTime - 1); + expect(kbConf.tz).to.equal(new Date().getTimezoneOffset()); + // kbConf bid ids + expect(kbConf.hb_placement_bidids) + .to.have.property(bids[0].placementid) + .that.equal(bids[0].uuid); + expect(kbConf.hb_placement_bidids) + .to.have.property(bids[1].placementid) + .that.equal(bids[1].uuid); + // kbConf floor price + expect(kbConf.hb_floors).not.to.have.property(bids[0].placementid) + expect(kbConf.hb_floors).to.have.property(bids[1].placementid).that.equal(bids[1].floorprice); + // kbConf placement ids + expect(kbConf.hb_placements).to.have.lengthOf(2); + expect(kbConf.hb_placements[0]).to.equal(bids[0].placementid); + expect(kbConf.hb_placements[1]).to.equal(bids[1].placementid); + }); + + it('Verify imonomyAdapter build response', function () { + const request = spec.buildRequests(bidsRequest); + const bids = spec.interpretResponse(bidsResponse, request); + + // 'server' return single bid + expect(bids).to.have.lengthOf(1); + + // verify bid object + const bid = bids[0]; + const responseBids = bidsResponse.body.bids; + + expect(bid.cpm).to.equal(responseBids[0].cpm); + expect(bid.ad).to.equal(responseBids[0].creative); + expect(bid.requestId).equal(responseBids[0].uuid); + expect(bid.uuid).equal(responseBids[0].uuid); + expect(bid.width).to.equal(responseBids[0].width); + expect(bid.height).to.equal(responseBids[0].height); + expect(bid.ttl).to.equal(responseBids[0].ttl); + expect(bid.currency).to.equal('USD'); + expect(bid.netRevenue).to.equal(true); + expect(bid.creativeId).to.equal(responseBids[0].creativeId); + }); + + it('Verifies imonomyAdapter sync options', function () { + // user sync disabled + expect(spec.getUserSyncs({})).to.be.undefined; + expect(spec.getUserSyncs({ iframeEnabled: false })).to.be.undefined; + // user sync enabled + const options = spec.getUserSyncs({ iframeEnabled: true }); + expect(options).to.not.be.undefined; + expect(options).to.have.lengthOf(1); + expect(options[0].type).to.equal('iframe'); + expect(options[0].url).to.equal('//b.imonomy.com/UserMatching/b/'); + }); +}); diff --git a/test/spec/modules/improvedigitalBidAdapter_spec.js b/test/spec/modules/improvedigitalBidAdapter_spec.js index 61ba56ab822..8b8f6c4bf4c 100644 --- a/test/spec/modules/improvedigitalBidAdapter_spec.js +++ b/test/spec/modules/improvedigitalBidAdapter_spec.js @@ -7,7 +7,7 @@ describe('Improve Digital Adapter Tests', function () { let idClient = new ImproveDigitalAdServerJSClient('hb'); const METHOD = 'GET'; - const URL = '//ad.360yield.com/hb'; + const URL = 'https://ice.360yield.com/hb'; const PARAM_PREFIX = 'jsonp='; const simpleBidRequest = { @@ -33,11 +33,17 @@ describe('Improve Digital Adapter Tests', function () { } }; - const bidderRequest = { - 'gdprConsent': { - 'consentString': 'BOJ/P2HOJ/P2HABABMAAAAAZ+A==', - 'vendorData': {}, - 'gdprApplies': true + const bidderRequestGdpr = { + gdprConsent: { + consentString: 'BOJ/P2HOJ/P2HABABMAAAAAZ+A==', + vendorData: {}, + gdprApplies: true + }, + }; + + const bidderRequestReferrer = { + refererInfo: { + referer: 'https://blah.com/test.html', }, }; @@ -151,13 +157,42 @@ describe('Improve Digital Adapter Tests', function () { getConfigStub.restore(); }); + it('should add bid floor', function () { + const bidRequest = Object.assign({}, simpleBidRequest); + let request = spec.buildRequests([bidRequest])[0]; + let params = JSON.parse(decodeURIComponent(request.data.substring(PARAM_PREFIX.length))); + // Floor price currency shouldn't be populated without a floor price + expect(params.bid_request.imp[0].bidfloorcur).to.not.exist; + + // Default floor price currency + bidRequest.params.bidFloor = 0.05; + request = spec.buildRequests([bidRequest])[0]; + params = JSON.parse(decodeURIComponent(request.data.substring(PARAM_PREFIX.length))); + expect(params.bid_request.imp[0].bidfloor).to.equal(0.05); + expect(params.bid_request.imp[0].bidfloorcur).to.equal('USD'); + + // Floor price currency + bidRequest.params.bidFloorCur = 'eUR'; + request = spec.buildRequests([bidRequest])[0]; + params = JSON.parse(decodeURIComponent(request.data.substring(PARAM_PREFIX.length))); + expect(params.bid_request.imp[0].bidfloor).to.equal(0.05); + expect(params.bid_request.imp[0].bidfloorcur).to.equal('EUR'); + }); + it('should add GDPR consent string', function () { const bidRequest = Object.assign({}, simpleBidRequest); - const request = spec.buildRequests([bidRequest], bidderRequest)[0]; + const request = spec.buildRequests([bidRequest], bidderRequestGdpr)[0]; const params = JSON.parse(decodeURIComponent(request.data.substring(PARAM_PREFIX.length))); expect(params.bid_request.gdpr).to.equal('BOJ/P2HOJ/P2HABABMAAAAAZ+A=='); }); + it('should add referrer', function () { + const bidRequest = Object.assign({}, simpleBidRequest); + const request = spec.buildRequests([bidRequest], bidderRequestReferrer)[0]; + const params = JSON.parse(decodeURIComponent(request.data.substring(PARAM_PREFIX.length))); + expect(params.bid_request.referrer).to.equal('https://blah.com/test.html'); + }); + it('should return 2 requests', function () { const requests = spec.buildRequests([ simpleBidRequest, @@ -224,7 +259,7 @@ describe('Improve Digital Adapter Tests', function () { 'id': '33e9500b21129f', 'advid': '5279', 'price': 1.45888594164456, - 'nurl': 'http://ad.360yield.com/imp_pixel?ic=wVmhKI07hCVyGC1sNdFp.6buOSiGYOw8jPyZLlcMY2RCwD4ek3Fy6.xUI7U002skGBs3objMBoNU-Frpvmb9js3NKIG0YZJgWaNdcpXY9gOXE9hY4-wxybCjVSNzhOQB-zic73hzcnJnKeoGgcfvt8fMy18-yD0aVdYWt4zbqdoITOkKNCPBEgbPFu1rcje-o7a64yZ7H3dKvtnIixXQYc1Ep86xGSBGXY6xW2KfUOMT6vnkemxO72divMkMdhR8cAuqIubbx-ZID8-xf5c9k7p6DseeBW0I8ionrlTHx.rGosgxhiFaMqtr7HiA7PBzKvPdeEYN0hQ8RYo8JzYL82hA91A3V2m9Ij6y0DfIJnnrKN8YORffhxmJ6DzwEl1zjrVFbD01bqB3Vdww8w8PQJSkKQkd313tr-atU8LS26fnBmOngEkVHwAr2WCKxuUvxHmuVBTA-Lgz7wKwMoOJCA3hFxMavVb0ZFB7CK0BUTVU6z0De92Q.FJKNCHLMbjX3vcAQ90=', + 'nurl': 'http://ice.360yield.com/imp_pixel?ic=wVmhKI07hCVyGC1sNdFp.6buOSiGYOw8jPyZLlcMY2RCwD4ek3Fy6.xUI7U002skGBs3objMBoNU-Frpvmb9js3NKIG0YZJgWaNdcpXY9gOXE9hY4-wxybCjVSNzhOQB-zic73hzcnJnKeoGgcfvt8fMy18-yD0aVdYWt4zbqdoITOkKNCPBEgbPFu1rcje-o7a64yZ7H3dKvtnIixXQYc1Ep86xGSBGXY6xW2KfUOMT6vnkemxO72divMkMdhR8cAuqIubbx-ZID8-xf5c9k7p6DseeBW0I8ionrlTHx.rGosgxhiFaMqtr7HiA7PBzKvPdeEYN0hQ8RYo8JzYL82hA91A3V2m9Ij6y0DfIJnnrKN8YORffhxmJ6DzwEl1zjrVFbD01bqB3Vdww8w8PQJSkKQkd313tr-atU8LS26fnBmOngEkVHwAr2WCKxuUvxHmuVBTA-Lgz7wKwMoOJCA3hFxMavVb0ZFB7CK0BUTVU6z0De92Q.FJKNCHLMbjX3vcAQ90=', 'h': 290, 'pid': 1053688, 'sync': [ @@ -234,7 +269,7 @@ describe('Improve Digital Adapter Tests', function () { 'crid': '422031', 'w': 600, 'cid': '99006', - 'adm': 'document.writeln(\"\\\"\\\"\\/<\\/a>\");document.writeln(\"<\\/improvedigital_ad_output_information>\");' + 'adm': 'document.writeln(\"\\\"\\\"\\/<\\/a>\");document.writeln(\"<\\/improvedigital_ad_output_information>\");' } ], 'debug': '' @@ -261,7 +296,7 @@ describe('Improve Digital Adapter Tests', function () { 'crid': '422033', 'w': 700, 'cid': '99006', - 'adm': 'document.writeln(\"\\\"\\\"\\/<\\/a>\");document.writeln(\"<\\/improvedigital_ad_output_information>\");' + 'adm': 'document.writeln(\"\\\"\\\"\\/<\\/a>\");document.writeln(\"<\\/improvedigital_ad_output_information>\");' } ], 'debug': '' @@ -278,7 +313,7 @@ describe('Improve Digital Adapter Tests', function () { id: '33e9500b21129f', advid: '5279', price: 1.45888594164456, - nurl: 'http://ad.360yield.com/imp_pixel?ic=wVm', + nurl: 'http://ice.360yield.com/imp_pixel?ic=wVm', h: 290, pid: 1053688, sync: [ @@ -310,13 +345,61 @@ describe('Improve Digital Adapter Tests', function () { { data: { type: 3, - value: 'Should get ignored' + value: '4' // rating + } + }, + { + data: { + type: 4, + value: '10105' // likes + } + }, + { + data: { + type: 5, + value: '150000' // downloads + } + }, + { + data: { + type: 6, + value: '3.99' // price + } + }, + { + data: { + type: 7, + value: '4.49' // salePrice + } + }, + { + data: { + type: 8, + value: '(123) 456-7890' // phone + } + }, + { + data: { + type: 9, + value: '123 Main Street, Anywhere USA' // address + } + }, + { + data: { + type: 10, + value: 'body2' + } + }, + { + data: { + type: 11, + value: 'https://myurl.com' // displayUrl } }, { data: { type: 12, - value: 'Do it' + value: 'Do it' // cta } }, { @@ -334,6 +417,7 @@ describe('Improve Digital Adapter Tests', function () { h: 30, w: 40 } + }, { img: { @@ -354,7 +438,8 @@ describe('Improve Digital Adapter Tests', function () { 'http://imptrack1.com', 'http://imptrack2.com' ], - jstracker: '' + jstracker: '', + privacy: 'https://www.myprivacyurl.com' } } ], @@ -362,10 +447,23 @@ describe('Improve Digital Adapter Tests', function () { } }; + const nativeEventtrackers = [ + { + event: 1, + method: 1, + url: 'http://www.mytracker.com/imptracker' + }, + { + event: 1, + method: 2, + url: 'http://www.mytracker.com/tracker.js' + } + ]; + describe('interpretResponse', function () { let expectedBid = [ { - 'ad': '', + 'ad': '', 'adId': '33e9500b21129f', 'creativeId': '422031', 'cpm': 1.45888594164456, @@ -382,7 +480,7 @@ describe('Improve Digital Adapter Tests', function () { let expectedTwoBids = [ expectedBid[0], { - 'ad': '', + 'ad': '', 'adId': '1234', 'creativeId': '422033', 'cpm': 1.23, @@ -411,8 +509,17 @@ describe('Improve Digital Adapter Tests', function () { native: { title: 'Native title', body: 'Native body', + body2: 'body2', cta: 'Do it', sponsoredBy: 'Improve Digital', + rating: '4', + likes: '10105', + downloads: '150000', + price: '3.99', + salePrice: '4.49', + phone: '(123) 456-7890', + address: '123 Main Street, Anywhere USA', + displayUrl: 'https://myurl.com', icon: { url: 'http://blah.com/icon.jpg', height: 30, @@ -426,11 +533,12 @@ describe('Improve Digital Adapter Tests', function () { clickUrl: 'http://advertiser.com', clickTrackers: ['http://click.tracker.com/click?impid=123'], impressionTrackers: [ - 'http://ad.360yield.com/imp_pixel?ic=wVm', + 'http://ice.360yield.com/imp_pixel?ic=wVm', 'http://imptrack1.com', 'http://imptrack2.com' ], - javascriptTrackers: '' + javascriptTrackers: '', + privacyLink: 'https://www.myprivacyurl.com' } } ]; @@ -532,8 +640,23 @@ describe('Improve Digital Adapter Tests', function () { // Native ads it('should return a well-formed native ad bid', function () { - const bids = spec.interpretResponse(serverResponseNative); + let bids = spec.interpretResponse(serverResponseNative); + expect(bids[0].ortbNative).to.deep.equal(serverResponseNative.body.bid[0].native); + delete bids[0].ortbNative; expect(bids).to.deep.equal(expectedBidNative); + + // eventtrackers + const response = JSON.parse(JSON.stringify(serverResponseNative)); + const expectedBids = JSON.parse(JSON.stringify(expectedBidNative)); + response.body.bid[0].native.eventtrackers = nativeEventtrackers; + expectedBids[0].native.impressionTrackers = [ + 'http://ice.360yield.com/imp_pixel?ic=wVm', + 'http://www.mytracker.com/imptracker' + ]; + expectedBids[0].native.javascriptTrackers = ''; + bids = spec.interpretResponse(response); + delete bids[0].ortbNative; + expect(bids).to.deep.equal(expectedBids); }); }); diff --git a/test/spec/modules/inskinBidAdapter_spec.js b/test/spec/modules/inskinBidAdapter_spec.js index 8a62a465a5b..896fe36d443 100644 --- a/test/spec/modules/inskinBidAdapter_spec.js +++ b/test/spec/modules/inskinBidAdapter_spec.js @@ -82,6 +82,9 @@ const RESPONSE = { 'type': 'html', 'body': '', 'data': { + 'customData': { + 'pubCPM': 1 + }, 'height': 90, 'width': 728, 'imageUrl': 'https://static.adzerk.net/Advertisers/b0ab77db8a7848c8b78931aed022a5ef.gif', @@ -241,6 +244,13 @@ describe('InSkin BidAdapter', function () { }); }); + it('cpm is correctly set', function () { + let bids = spec.interpretResponse(RESPONSE, REQUEST); + + expect(bids[0].cpm).to.equal(0.5); + expect(bids[1].cpm).to.equal(1); + }); + it('handles nobid responses', function () { let EMPTY_RESP = Object.assign({}, RESPONSE, {'body': {'decisions': null}}) let bids = spec.interpretResponse(EMPTY_RESP, REQUEST); diff --git a/test/spec/modules/ixBidAdapter_spec.js b/test/spec/modules/ixBidAdapter_spec.js index d88b783a785..38e64e8d338 100644 --- a/test/spec/modules/ixBidAdapter_spec.js +++ b/test/spec/modules/ixBidAdapter_spec.js @@ -69,6 +69,19 @@ describe('IndexexchangeAdapter', function () { } ] }; + const DEFAULT_IDENTITY_RESPONSE = { + IdentityIp: { + responsePending: false, + data: { + source: 'identityinc.com', + uids: [ + { + id: 'identityid' + } + ] + } + } + }; describe('inherited functions', function () { it('should exists and is a function', function () { @@ -209,6 +222,171 @@ describe('IndexexchangeAdapter', function () { }); }); + describe('buildRequestsIdentity', function () { + let request; + let query; + let testCopy; + + beforeEach(function() { + window.headertag = {}; + window.headertag.getIdentityInfo = function() { + return testCopy; + }; + request = spec.buildRequests(DEFAULT_BANNER_VALID_BID, DEFAULT_BANNER_OPTION); + query = request.data; + }); + afterEach(function() { + delete window.headertag; + }); + describe('buildRequestSingleRTI', function() { + before(function() { + testCopy = JSON.parse(JSON.stringify(DEFAULT_IDENTITY_RESPONSE)); + }); + it('payload should have correct format and value (single identity partner)', function () { + const payload = JSON.parse(query.r); + + expect(payload.user).to.exist; + expect(payload.user.eids).to.exist; + expect(payload.user.eids).to.be.an('array'); + expect(payload.user.eids).to.have.lengthOf(1); + }); + + it('identity data in impression should have correct format and value (single identity partner)', function () { + const impression = JSON.parse(query.r).user.eids; + expect(impression[0].source).to.equal(testCopy.IdentityIp.data.source); + expect(impression[0].uids[0].id).to.equal(testCopy.IdentityIp.data.uids[0].id); + }); + }); + + describe('buildRequestMultipleIds', function() { + before(function() { + testCopy = JSON.parse(JSON.stringify(DEFAULT_IDENTITY_RESPONSE)); + testCopy.IdentityIp.data.uids.push({ + id: '1234567' + }, + { + id: '2019-04-01TF2:34:41' + }); + }); + it('payload should have correct format and value (single identity w/ multi ids)', function () { + const payload = JSON.parse(query.r); + + expect(payload.user).to.exist; + expect(payload.user.eids).to.exist; + expect(payload.user.eids).to.be.an('array'); + expect(payload.user.eids).to.have.lengthOf(1); + }); + + it('identity data in impression should have correct format and value (single identity w/ multi ids)', function () { + const impression = JSON.parse(query.r).user.eids; + + expect(impression[0].source).to.equal(testCopy.IdentityIp.data.source); + expect(impression[0].uids).to.have.lengthOf(3); + }); + }); + + describe('buildRequestMultipleRTI', function() { + before(function() { + testCopy = JSON.parse(JSON.stringify(DEFAULT_IDENTITY_RESPONSE)); + testCopy.JackIp = { + responsePending: false, + data: { + source: 'jackinc.com', + uids: [ + { + id: 'jackid' + } + ] + } + } + testCopy.GenericIp = { + responsePending: false, + data: { + source: 'genericip.com', + uids: [ + { + id: 'genericipenvelope' + } + ] + } + } + }); + it('payload should have correct format and value (multiple identity partners)', function () { + const payload = JSON.parse(query.r); + + expect(payload.user).to.exist; + expect(payload.user.eids).to.exist; + expect(payload.user.eids).to.be.an('array'); + expect(payload.user.eids).to.have.lengthOf(3); + }); + + it('identity data in impression should have correct format and value (multiple identity partners)', function () { + const impression = JSON.parse(query.r).user.eids; + + expect(impression[0].source).to.equal(testCopy.IdentityIp.data.source); + expect(impression[0].uids).to.have.lengthOf(1); + + expect(impression[1].source).to.equal(testCopy.JackIp.data.source); + expect(impression[1].uids).to.have.lengthOf(1); + + expect(impression[2].source).to.equal(testCopy.GenericIp.data.source); + expect(impression[2].uids).to.have.lengthOf(1); + }); + }); + + describe('buildRequestNoData', function() { + beforeEach(function() { + testCopy = JSON.parse(JSON.stringify(DEFAULT_IDENTITY_RESPONSE)); + }); + + it('payload should not have any user eids with an undefined identity data response', function () { + window.headertag.getIdentityInfo = function() { + return undefined; + }; + request = spec.buildRequests(DEFAULT_BANNER_VALID_BID, DEFAULT_BANNER_OPTION); + query = request.data; + const payload = JSON.parse(query.r); + + expect(payload.user).to.exist; + expect(payload.user.eids).to.not.exist; + }); + + it('payload should have user eids if least one partner data is available', function () { + testCopy.GenericIp = { + responsePending: true, + data: {} + } + request = spec.buildRequests(DEFAULT_BANNER_VALID_BID, DEFAULT_BANNER_OPTION); + query = request.data; + const payload = JSON.parse(query.r); + + expect(payload.user).to.exist; + expect(payload.user.eids).to.exist; + }); + + it('payload should not have any user eids if identity data is pending for all partners', function () { + testCopy.IdentityIp.responsePending = true; + request = spec.buildRequests(DEFAULT_BANNER_VALID_BID, DEFAULT_BANNER_OPTION); + query = request.data; + const payload = JSON.parse(query.r); + + expect(payload.user).to.exist; + expect(payload.user.eids).to.not.exist; + }); + + it('payload should not have any user eids if identity data is pending or not available for all partners', function () { + testCopy.IdentityIp.responsePending = false; + testCopy.IdentityIp.data = {}; + request = spec.buildRequests(DEFAULT_BANNER_VALID_BID, DEFAULT_BANNER_OPTION); + query = request.data; + const payload = JSON.parse(query.r); + + expect(payload.user).to.exist; + expect(payload.user.eids).to.not.exist; + }); + }); + }); + describe('buildRequestsBanner', function () { const request = spec.buildRequests(DEFAULT_BANNER_VALID_BID, DEFAULT_BANNER_OPTION); const requestUrl = request.url; diff --git a/test/spec/modules/justpremiumBidAdapter_spec.js b/test/spec/modules/justpremiumBidAdapter_spec.js index 8167c29e5c2..c3cd015b6e3 100644 --- a/test/spec/modules/justpremiumBidAdapter_spec.js +++ b/test/spec/modules/justpremiumBidAdapter_spec.js @@ -18,6 +18,18 @@ describe('justpremium adapter', function () { { adUnitCode: 'div-gpt-ad-1471513102552-1', bidder: 'justpremium', + crumbs: { + pubcid: '0000000' + }, + userId: { + tdid: '1111111', + id5id: '2222222', + digitrustid: { + data: { + id: '3333333' + } + } + }, params: { zone: 28313, allow: ['lb', 'wp'] @@ -33,6 +45,12 @@ describe('justpremium adapter', function () { }, ] + let bidderRequest = { + refererInfo: { + referer: 'http://justpremium.com' + } + } + describe('isBidRequestValid', function () { it('Verifies bidder code', function () { expect(spec.code).to.equal('justpremium') @@ -48,15 +66,14 @@ describe('justpremium adapter', function () { describe('buildRequests', function () { it('Verify build request and parameters', function () { - const request = spec.buildRequests(adUnits) + const request = spec.buildRequests(adUnits, bidderRequest) expect(request.method).to.equal('POST') expect(request.url).to.match(/pre.ads.justpremium.com\/v\/2.0\/t\/xhr/) const jpxRequest = JSON.parse(request.data) expect(jpxRequest).to.not.equal(null) expect(jpxRequest.zone).to.not.equal('undefined') - expect(jpxRequest.hostname).to.equal(top.document.location.hostname) - expect(jpxRequest.protocol).to.equal(top.document.location.protocol.replace(':', '')) + expect(bidderRequest.refererInfo.referer).to.equal('http://justpremium.com') expect(jpxRequest.sw).to.equal(window.top.screen.width) expect(jpxRequest.sh).to.equal(window.top.screen.height) expect(jpxRequest.ww).to.equal(window.top.innerWidth) @@ -65,12 +82,16 @@ describe('justpremium adapter', function () { expect(jpxRequest.id).to.equal(adUnits[0].params.zone) expect(jpxRequest.sizes).to.not.equal('undefined') expect(jpxRequest.version.prebid).to.equal('$prebid.version$') - expect(jpxRequest.version.jp_adapter).to.equal('1.3') + expect(jpxRequest.version.jp_adapter).to.equal('1.4') + expect(jpxRequest.pubcid).to.equal('0000000') + expect(jpxRequest.uids.tdid).to.equal('1111111') + expect(jpxRequest.uids.id5id).to.equal('2222222') + expect(jpxRequest.uids.digitrustid.data.id).to.equal('3333333') }) }) describe('interpretResponse', function () { - const request = spec.buildRequests(adUnits) + const request = spec.buildRequests(adUnits, bidderRequest) it('Verify server response', function () { let response = { 'bid': { diff --git a/test/spec/modules/kargoBidAdapter_spec.js b/test/spec/modules/kargoBidAdapter_spec.js index 28cb386242f..fd0e22b91b9 100644 --- a/test/spec/modules/kargoBidAdapter_spec.js +++ b/test/spec/modules/kargoBidAdapter_spec.js @@ -34,7 +34,7 @@ describe('kargo adapter tests', function () { }); describe('build request', function() { - var bids, undefinedCurrency, noAdServerCurrency, cookies = [], localStorageItems = []; + var bids, undefinedCurrency, noAdServerCurrency, cookies = [], localStorageItems = [], sessionIds = [], requestCount = 0; beforeEach(function () { undefinedCurrency = false; @@ -57,19 +57,25 @@ describe('kargo adapter tests', function () { params: { placementId: 'foo' }, - bidId: 1 + bidId: 1, + userId: { + tdid: 'fake-tdid' + }, + sizes: [[320, 50], [300, 250], [300, 600]] }, { params: { placementId: 'bar' }, - bidId: 2 + bidId: 2, + sizes: [[320, 50], [300, 250], [300, 600]] }, { params: { placementId: 'bar' }, - bidId: 3 + bidId: 3, + sizes: [[320, 50], [300, 250], [300, 600]] } ]; }); @@ -185,6 +191,14 @@ describe('kargo adapter tests', function () { setCookie('krg_crb', getInvalidKrgCrbType3OldStyle()); } + function getInvalidKrgCrbType4OldStyle() { + return '%7B%22v%22%3A%22bnVsbA%3D%3D%22%7D'; + } + + function initializeInvalidKrgCrbType4Cookie() { + setCookie('krg_crb', getInvalidKrgCrbType4OldStyle()); + } + function getEmptyKrgCrb() { return 'eyJleHBpcmVUaW1lIjoxNDk3NDQ5MzgyNjY4LCJsYXN0U3luY2VkQXQiOjE0OTczNjI5NzkwMTJ9'; } @@ -201,9 +215,14 @@ describe('kargo adapter tests', function () { setCookie('krg_crb', getEmptyKrgCrbOldStyle()); } + function getSessionId() { + return spec._getSessionId(); + } + function getExpectedKrakenParams(excludeUserIds, excludeKrux, expectedRawCRB, expectedRawCRBCookie) { var base = { timeout: 200, + requestCount: requestCount++, currency: 'USD', cpmGranularity: 1, timestamp: frozenNow.getTime(), @@ -216,9 +235,15 @@ describe('kargo adapter tests', function () { 2: 'bar', 3: 'bar' }, + bidSizes: { + 1: [[320, 50], [300, 250], [300, 600]], + 2: [[320, 50], [300, 250], [300, 600]], + 3: [[320, 50], [300, 250], [300, 600]] + }, userIDs: { kargoID: '5f108831-302d-11e7-bf6b-4595acd3bf6c', clientID: '2410d8f2-c111-4811-88a5-7b5e190e475f', + tdID: 'fake-tdid', crbIDs: { 2: '82fa2555-5969-4614-b4ce-4dcf1080e9f9', 16: 'VoxIk8AoJz0AAEdCeyAAAAC2&502', @@ -241,6 +266,32 @@ describe('kargo adapter tests', function () { ] }, pageURL: window.location.href, + prebidRawBidRequests: [ + { + bidId: 1, + params: { + placementId: 'foo' + }, + userId: { + tdid: 'fake-tdid' + }, + sizes: [[320, 50], [300, 250], [300, 600]] + }, + { + bidId: 2, + params: { + placementId: 'bar' + }, + sizes: [[320, 50], [300, 250], [300, 600]] + }, + { + bidId: 3, + params: { + placementId: 'bar' + }, + sizes: [[320, 50], [300, 250], [300, 600]] + } + ], rawCRB: expectedRawCRBCookie, rawCRBLocalStorage: expectedRawCRB }; @@ -249,6 +300,7 @@ describe('kargo adapter tests', function () { base.userIDs = { crbIDs: {} }; + delete base.prebidRawBidRequests[0].userId.tdid; } if (excludeKrux) { @@ -261,8 +313,14 @@ describe('kargo adapter tests', function () { return base; } - function testBuildRequests(expected) { - var request = spec.buildRequests(bids, {timeout: 200, foo: 'bar'}); + function testBuildRequests(excludeTdid, expected) { + var clonedBids = JSON.parse(JSON.stringify(bids)); + if (excludeTdid) { + delete clonedBids[0].userId.tdid; + } + var request = spec.buildRequests(clonedBids, {timeout: 200, foo: 'bar'}); + expected.sessionId = getSessionId(); + sessionIds.push(expected.sessionId); var krakenParams = JSON.parse(decodeURIComponent(request.data.slice(5))); expect(request.data.slice(0, 5)).to.equal('json='); expect(request.url).to.equal('https://krk.kargo.com/api/v2/bid'); @@ -271,29 +329,37 @@ describe('kargo adapter tests', function () { expect(request.timeout).to.equal(200); expect(request.foo).to.equal('bar'); expect(krakenParams).to.deep.equal(expected); + // Make sure session ID stays the same across requests simulating multiple auctions on one page load + for (let i in sessionIds) { + if (i == 0) { + continue; + } + let sessionId = sessionIds[i]; + expect(sessionIds[0]).to.equal(sessionId); + } } it('works when all params and localstorage and cookies are correctly set', function() { initializeKruxUser(); initializeKruxSegments(); initializeKrgCrb(); - testBuildRequests(getExpectedKrakenParams(undefined, undefined, getKrgCrb(), getKrgCrbOldStyle())); + testBuildRequests(false, getExpectedKrakenParams(undefined, undefined, getKrgCrb(), getKrgCrbOldStyle())); }); it('works when all params and cookies are correctly set but no localstorage', function() { initializeKruxUser(); initializeKruxSegments(); initializeKrgCrb(true); - testBuildRequests(getExpectedKrakenParams(undefined, undefined, null, getKrgCrbOldStyle())); + testBuildRequests(false, getExpectedKrakenParams(undefined, undefined, null, getKrgCrbOldStyle())); }); it('gracefully handles nothing being set', function() { - testBuildRequests(getExpectedKrakenParams(true, true, null, null)); + testBuildRequests(true, getExpectedKrakenParams(true, true, null, null)); }); it('gracefully handles browsers without localStorage', function() { simulateNoLocalStorage(); - testBuildRequests(getExpectedKrakenParams(true, true, null, null)); + testBuildRequests(true, getExpectedKrakenParams(true, true, null, null)); }); it('handles empty yet valid Kargo CRB', function() { @@ -301,42 +367,49 @@ describe('kargo adapter tests', function () { initializeKruxSegments(); initializeEmptyKrgCrb(); initializeEmptyKrgCrbCookie(); - testBuildRequests(getExpectedKrakenParams(true, undefined, getEmptyKrgCrb(), getEmptyKrgCrbOldStyle())); + testBuildRequests(true, getExpectedKrakenParams(true, undefined, getEmptyKrgCrb(), getEmptyKrgCrbOldStyle())); }); it('handles broken Kargo CRBs where base64 encoding is invalid', function() { initializeKruxUser(); initializeKruxSegments(); initializeInvalidKrgCrbType1(); - testBuildRequests(getExpectedKrakenParams(true, undefined, getInvalidKrgCrbType1(), null)); + testBuildRequests(true, getExpectedKrakenParams(true, undefined, getInvalidKrgCrbType1(), null)); }); it('handles broken Kargo CRBs where top level JSON is invalid on cookie', function() { initializeKruxUser(); initializeKruxSegments(); initializeInvalidKrgCrbType1Cookie(); - testBuildRequests(getExpectedKrakenParams(true, undefined, null, getInvalidKrgCrbType1())); + testBuildRequests(true, getExpectedKrakenParams(true, undefined, null, getInvalidKrgCrbType1())); }); it('handles broken Kargo CRBs where decoded JSON is invalid', function() { initializeKruxUser(); initializeKruxSegments(); initializeInvalidKrgCrbType2(); - testBuildRequests(getExpectedKrakenParams(true, undefined, getInvalidKrgCrbType2(), null)); + testBuildRequests(true, getExpectedKrakenParams(true, undefined, getInvalidKrgCrbType2(), null)); }); it('handles broken Kargo CRBs where inner base 64 is invalid on cookie', function() { initializeKruxUser(); initializeKruxSegments(); initializeInvalidKrgCrbType2Cookie(); - testBuildRequests(getExpectedKrakenParams(true, undefined, null, getInvalidKrgCrbType2OldStyle())); + testBuildRequests(true, getExpectedKrakenParams(true, undefined, null, getInvalidKrgCrbType2OldStyle())); }); it('handles broken Kargo CRBs where inner JSON is invalid on cookie', function() { initializeKruxUser(); initializeKruxSegments(); initializeInvalidKrgCrbType3Cookie(); - testBuildRequests(getExpectedKrakenParams(true, undefined, null, getInvalidKrgCrbType3OldStyle())); + testBuildRequests(true, getExpectedKrakenParams(true, undefined, null, getInvalidKrgCrbType3OldStyle())); + }); + + it('handles broken Kargo CRBs where inner JSON is falsey', function() { + initializeKruxUser(); + initializeKruxSegments(); + initializeInvalidKrgCrbType4Cookie(); + testBuildRequests(true, getExpectedKrakenParams(true, undefined, null, getInvalidKrgCrbType4OldStyle())); }); it('handles a non-existant currency object on the config', function() { @@ -344,7 +417,7 @@ describe('kargo adapter tests', function () { initializeKruxUser(); initializeKruxSegments(); initializeKrgCrb(); - testBuildRequests(getExpectedKrakenParams(undefined, undefined, getKrgCrb(), getKrgCrbOldStyle())); + testBuildRequests(false, getExpectedKrakenParams(undefined, undefined, getKrgCrb(), getKrgCrbOldStyle())); }); it('handles no ad server currency being set on the currency object in the config', function() { @@ -352,7 +425,7 @@ describe('kargo adapter tests', function () { initializeKruxUser(); initializeKruxSegments(); initializeKrgCrb(); - testBuildRequests(getExpectedKrakenParams(undefined, undefined, getKrgCrb(), getKrgCrbOldStyle())); + testBuildRequests(false, getExpectedKrakenParams(undefined, undefined, getKrgCrb(), getKrgCrbOldStyle())); }); }); diff --git a/test/spec/modules/kummaBidAdapter_spec.js b/test/spec/modules/kummaBidAdapter_spec.js index 82076717dcc..7d33bd085b5 100644 --- a/test/spec/modules/kummaBidAdapter_spec.js +++ b/test/spec/modules/kummaBidAdapter_spec.js @@ -192,8 +192,8 @@ describe('Kumma Adapter Tests', function () { { id: 1, title: { text: 'Ad Title' } }, { id: 2, data: { value: 'Test description' } }, { id: 3, data: { value: 'Brand' } }, - { id: 4, img: { url: 'https://s3.amazonaws.com/adx1public/creatives_icon.png', w: 100, h: 100 } }, - { id: 5, img: { url: 'https://s3.amazonaws.com/adx1public/creatives_image.png', w: 300, h: 300 } } + { id: 4, img: { url: 'https://adx1public.s3.amazonaws.com/creatives_icon.png', w: 100, h: 100 } }, + { id: 5, img: { url: 'https://adx1public.s3.amazonaws.com/creatives_image.png', w: 300, h: 300 } } ], link: { url: 'http://brand.com/' } } @@ -220,8 +220,8 @@ describe('Kumma Adapter Tests', function () { expect(nativeBid).to.not.equal(null); expect(nativeBid.title).to.equal('Ad Title'); expect(nativeBid.sponsoredBy).to.equal('Brand'); - expect(nativeBid.icon.url).to.equal('https://s3.amazonaws.com/adx1public/creatives_icon.png'); - expect(nativeBid.image.url).to.equal('https://s3.amazonaws.com/adx1public/creatives_image.png'); + expect(nativeBid.icon.url).to.equal('https://adx1public.s3.amazonaws.com/creatives_icon.png'); + expect(nativeBid.image.url).to.equal('https://adx1public.s3.amazonaws.com/creatives_image.png'); expect(nativeBid.image.width).to.equal(300); expect(nativeBid.image.height).to.equal(300); expect(nativeBid.icon.width).to.equal(100); diff --git a/test/spec/modules/livewrappedAnalyticsAdapter_spec.js b/test/spec/modules/livewrappedAnalyticsAdapter_spec.js index 60fc9bdc1ec..611ff95a036 100644 --- a/test/spec/modules/livewrappedAnalyticsAdapter_spec.js +++ b/test/spec/modules/livewrappedAnalyticsAdapter_spec.js @@ -3,6 +3,7 @@ import CONSTANTS from 'src/constants.json'; import { config } from 'src/config'; let events = require('src/events'); +let utils = require('src/utils'); let adapterManager = require('src/adapterManager').default; const { @@ -27,6 +28,7 @@ const BID1 = { cpm: 1.1, timeToRespond: 200, bidId: '2ecff0db240757', + requestId: '2ecff0db240757', adId: '2ecff0db240757', auctionId: '25c6d7f5-699a-4bfc-87c9-996f915341fa', getStatusCode() { @@ -40,9 +42,20 @@ const BID2 = Object.assign({}, BID1, { cpm: 2.2, timeToRespond: 300, bidId: '3ecff0db240757', + requestId: '3ecff0db240757', adId: '3ecff0db240757', }); +const BID3 = { + bidId: '4ecff0db240757', + requestId: '4ecff0db240757', + adId: '4ecff0db240757', + auctionId: '25c6d7f5-699a-4bfc-87c9-996f915341fa', + getStatusCode() { + return CONSTANTS.STATUS.NO_BID; + } +}; + const MOCK = { AUCTION_INIT: { 'auctionId': '25c6d7f5-699a-4bfc-87c9-996f915341fa', @@ -61,6 +74,11 @@ const MOCK = { 'bidder': 'livewrapped', 'adUnitCode': 'box_d_1', 'bidId': '3ecff0db240757', + }, + { + 'bidder': 'livewrapped', + 'adUnitCode': 'box_d_2', + 'bidId': '4ecff0db240757', } ], 'start': 1519149562216 @@ -73,17 +91,20 @@ const MOCK = { }, BID_WON: [ Object.assign({}, BID1, { - 'status': 'rendered' + 'status': 'rendered', + 'requestId': '2ecff0db240757' }), Object.assign({}, BID2, { - 'status': 'rendered' + 'status': 'rendered', + 'requestId': '3ecff0db240757' }) ], BIDDER_DONE: { 'bidderCode': 'livewrapped', 'bids': [ BID1, - BID2 + BID2, + BID3 ] }, BID_TIMEOUT: [ @@ -96,6 +117,16 @@ const MOCK = { const ANALYTICS_MESSAGE = { publisherId: 'CC411485-42BC-4F92-8389-42C503EE38D7', + bidAdUnits: [ + { + adUnit: 'panorama_d_1', + timeStamp: 1519149562216 + }, + { + adUnit: 'box_d_1', + timeStamp: 1519149562216 + } + ], requests: [ { adUnit: 'panorama_d_1', @@ -106,6 +137,11 @@ const ANALYTICS_MESSAGE = { adUnit: 'box_d_1', bidder: 'livewrapped', timeStamp: 1519149562216 + }, + { + adUnit: 'box_d_2', + bidder: 'livewrapped', + timeStamp: 1519149562216 } ], responses: [ @@ -128,6 +164,13 @@ const ANALYTICS_MESSAGE = { cpm: 2.2, ttr: 300, IsBid: true + }, + { + timeStamp: 1519149562216, + adUnit: 'box_d_2', + bidder: 'livewrapped', + ttr: 200, + IsBid: false } ], timeouts: [], @@ -177,6 +220,7 @@ describe('Livewrapped analytics adapter', function () { xhr.onCreate = request => requests.push(request); sandbox.stub(events, 'getEvents').returns([]); + sandbox.stub(utils, 'timestamp').returns(1519149562416); clock = sandbox.useFakeTimers(1519767013781); }); @@ -206,6 +250,7 @@ describe('Livewrapped analytics adapter', function () { }); it('should build a batched message from prebid events', function () { + sandbox.stub(utils, 'getWindowTop').returns({}); performStandardAuction(); clock.tick(BID_WON_TIMEOUT + 1000); @@ -261,5 +306,19 @@ describe('Livewrapped analytics adapter', function () { expect(message.timeouts[0].bidder).to.equal('livewrapped'); expect(message.timeouts[0].adUnit).to.equal('panorama_d_1'); }); + + it('should detect adblocker recovered request', function () { + sandbox.stub(utils, 'getWindowTop').returns({ I12C: { Morph: 1 } }); + performStandardAuction(); + + clock.tick(BID_WON_TIMEOUT + 1000); + + expect(requests.length).to.equal(1); + let request = requests[0]; + + let message = JSON.parse(request.requestBody); + + expect(message.rcv).to.equal(true); + }); }); }); diff --git a/test/spec/modules/livewrappedBidAdapter_spec.js b/test/spec/modules/livewrappedBidAdapter_spec.js index b12ff56c075..855eb2ee3f9 100644 --- a/test/spec/modules/livewrappedBidAdapter_spec.js +++ b/test/spec/modules/livewrappedBidAdapter_spec.js @@ -303,6 +303,64 @@ describe('Livewrapped adapter tests', function () { expect(data).to.deep.equal(expectedQuery); }); + it('should make a well-formed single request object with optional parameters', function() { + sandbox.stub(utils, 'isSafariBrowser').callsFake(() => false); + sandbox.stub(utils, 'cookiesAreEnabled').callsFake(() => true); + let testbidRequest = clone(bidderRequest); + delete testbidRequest.bids[0].params.userId; + delete testbidRequest.bids[0].params.seats; + delete testbidRequest.bids[0].params.adUnitId; + testbidRequest.bids[0].params.options = {keyvalues: [{key: 'key', value: 'value'}]}; + let result = spec.buildRequests(testbidRequest.bids, testbidRequest); + let data = JSON.parse(result.data); + + let expectedQuery = { + auctionId: 'F7557995-65F5-4682-8782-7D5D34D82A8C', + publisherId: '26947112-2289-405D-88C1-A7340C57E63E', + url: 'http://www.domain.com', + version: '1.1', + cookieSupport: true, + adRequests: [{ + callerAdUnitId: 'panorama_d_1', + bidId: '2ffb201a808da7', + transactionId: '3D1C8CF7-D288-4D7F-8ADD-97C553056C3D', + formats: [{width: 980, height: 240}, {width: 980, height: 120}], + options: {keyvalues: [{key: 'key', value: 'value'}]} + }] + }; + + expect(data).to.deep.equal(expectedQuery); + }); + + it('should make a well-formed single request object with ad blocker revovered parameter', function() { + sandbox.stub(utils, 'getWindowTop').returns({ I12C: { Morph: 1 } }); + sandbox.stub(utils, 'isSafariBrowser').callsFake(() => false); + sandbox.stub(utils, 'cookiesAreEnabled').callsFake(() => true); + let testbidRequest = clone(bidderRequest); + delete testbidRequest.bids[0].params.userId; + delete testbidRequest.bids[0].params.seats; + delete testbidRequest.bids[0].params.adUnitId; + let result = spec.buildRequests(testbidRequest.bids, testbidRequest); + let data = JSON.parse(result.data); + + let expectedQuery = { + auctionId: 'F7557995-65F5-4682-8782-7D5D34D82A8C', + publisherId: '26947112-2289-405D-88C1-A7340C57E63E', + url: 'http://www.domain.com', + version: '1.1', + cookieSupport: true, + rcv: true, + adRequests: [{ + callerAdUnitId: 'panorama_d_1', + bidId: '2ffb201a808da7', + transactionId: '3D1C8CF7-D288-4D7F-8ADD-97C553056C3D', + formats: [{width: 980, height: 240}, {width: 980, height: 120}] + }] + }; + + expect(data).to.deep.equal(expectedQuery); + }); + it('should pass gdpr true parameters', function() { sandbox.stub(utils, 'isSafariBrowser').callsFake(() => false); sandbox.stub(utils, 'cookiesAreEnabled').callsFake(() => true); diff --git a/test/spec/modules/lkqdBidAdapter_spec.js b/test/spec/modules/lkqdBidAdapter_spec.js index 0cebb2651a9..73a4824f0ef 100644 --- a/test/spec/modules/lkqdBidAdapter_spec.js +++ b/test/spec/modules/lkqdBidAdapter_spec.js @@ -40,7 +40,7 @@ describe('LKQD Bid Adapter Test', function () { }); }); - describe('buildRequests', function () { + describe('buildRequests', () => { const ENDPOINT = 'https://v.lkqd.net/ad'; let bidRequests = [ { @@ -101,14 +101,12 @@ describe('LKQD Bid Adapter Test', function () { expect(requests.length).to.equal(2); const r1 = requests[0].data; expect(r1).to.not.have.property('dnt'); - expect(r1).to.not.have.property('pageurl'); expect(r1).to.not.have.property('contentid'); expect(r1).to.not.have.property('contenttitle'); expect(r1).to.not.have.property('contentlength'); expect(r1).to.not.have.property('contenturl'); const r2 = requests[1].data; expect(r2).to.not.have.property('dnt'); - expect(r2).to.not.have.property('pageurl'); expect(r2).to.not.have.property('contentid'); expect(r2).to.not.have.property('contenttitle'); expect(r2).to.not.have.property('contentlength'); diff --git a/test/spec/modules/lockerdomeBidAdapter_spec.js b/test/spec/modules/lockerdomeBidAdapter_spec.js index 1cd6778b01f..6a3fd814030 100644 --- a/test/spec/modules/lockerdomeBidAdapter_spec.js +++ b/test/spec/modules/lockerdomeBidAdapter_spec.js @@ -6,7 +6,7 @@ describe('LockerDomeAdapter', function () { const bidRequests = [{ bidder: 'lockerdome', params: { - adUnitId: 10809467961050726 + adUnitId: 'LD10809467961050726' }, mediaTypes: { banner: { @@ -22,7 +22,7 @@ describe('LockerDomeAdapter', function () { }, { bidder: 'lockerdome', params: { - adUnitId: 9434769725128806 + adUnitId: 'LD9434769725128806' }, mediaTypes: { banner: { @@ -66,14 +66,14 @@ describe('LockerDomeAdapter', function () { expect(bids[0].requestId).to.equal('2652ca954bce9'); expect(bids[0].adUnitCode).to.equal('ad-1'); - expect(bids[0].adUnitId).to.equal(10809467961050726); + expect(bids[0].adUnitId).to.equal('LD10809467961050726'); expect(bids[0].sizes).to.have.lengthOf(1); expect(bids[0].sizes[0][0]).to.equal(300); expect(bids[0].sizes[0][1]).to.equal(250); expect(bids[1].requestId).to.equal('4510f2834773ce'); expect(bids[1].adUnitCode).to.equal('ad-2'); - expect(bids[1].adUnitId).to.equal(9434769725128806); + expect(bids[1].adUnitId).to.equal('LD9434769725128806'); expect(bids[1].sizes).to.have.lengthOf(1); expect(bids[1].sizes[0][0]).to.equal(300); expect(bids[1].sizes[0][1]).to.equal(600); diff --git a/test/spec/modules/logicadBidAdapter_spec.js b/test/spec/modules/logicadBidAdapter_spec.js new file mode 100644 index 00000000000..effb7334b69 --- /dev/null +++ b/test/spec/modules/logicadBidAdapter_spec.js @@ -0,0 +1,119 @@ +import {expect} from 'chai'; +import {spec} from '../../../modules/logicadBidAdapter'; +import * as utils from 'src/utils'; + +describe('LogicadAdapter', function () { + const bidRequests = [{ + bidder: 'logicad', + bidId: '51ef8751f9aead', + params: { + tid: 'PJ2P', + page: 'http://www.logicad.com/' + }, + adUnitCode: 'div-gpt-ad-1460505748561-0', + transactionId: 'd7b773de-ceaa-484d-89ca-d9f51b8d61ec', + sizes: [[300, 250], [300, 600]], + bidderRequestId: '418b37f85e772c', + auctionId: '18fd8b8b0bd757', + mediaTypes: { + banner: { + sizes: [[300, 250], [300, 600]] + } + } + }]; + const bidderRequest = { + refererInfo: { + referer: 'fakeReferer', + reachedTop: true, + numIframes: 1, + stack: [] + }, + auctionStart: 1563337198010 + }; + const serverResponse = { + body: { + seatbid: + [{ + bid: { + requestId: '51ef8751f9aead', + cpm: 101.0234, + width: 300, + height: 250, + creativeId: '2019', + currency: 'JPY', + netRevenue: true, + ttl: 60, + ad: '
    TEST
    ' + } + }], + userSync: { + type: 'image', + url: 'https://cr-p31.ladsp.jp/cookiesender/31' + } + } + }; + + describe('isBidRequestValid', function () { + it('should return true if the tid parameter is present', function () { + expect(spec.isBidRequestValid(bidRequests[0])).to.be.true; + }); + + it('should return false if the tid parameter is not present', function () { + let bidRequest = utils.deepClone(bidRequests[0]); + delete bidRequest.params.tid; + expect(spec.isBidRequestValid(bidRequest)).to.be.false; + }); + + it('should return false if the params object is not present', function () { + let bidRequest = utils.deepClone(bidRequests); + delete bidRequest[0].params; + expect(spec.isBidRequestValid(bidRequest)).to.be.false; + }); + }); + + describe('buildRequests', function () { + it('should generate a valid single POST request for multiple bid requests', function () { + const request = spec.buildRequests(bidRequests, bidderRequest)[0]; + expect(request.method).to.equal('POST'); + expect(request.url).to.equal('https://pb.ladsp.com/adrequest/prebid'); + expect(request.data).to.exist; + }); + }); + + describe('interpretResponse', function () { + it('should return an empty array if an invalid response is passed', function () { + const interpretedResponse = spec.interpretResponse({}, {}); + expect(interpretedResponse).to.be.an('array').that.is.empty; + }); + + it('should return valid response when passed valid server response', function () { + const request = spec.buildRequests(bidRequests, bidderRequest)[0]; + const interpretedResponse = spec.interpretResponse(serverResponse, request); + + expect(interpretedResponse).to.have.lengthOf(1); + + expect(interpretedResponse[0].requestId).to.equal(serverResponse.body.seatbid[0].bid.requestId); + expect(interpretedResponse[0].cpm).to.equal(serverResponse.body.seatbid[0].bid.cpm); + expect(interpretedResponse[0].width).to.equal(serverResponse.body.seatbid[0].bid.width); + expect(interpretedResponse[0].height).to.equal(serverResponse.body.seatbid[0].bid.height); + expect(interpretedResponse[0].creativeId).to.equal(serverResponse.body.seatbid[0].bid.creativeId); + expect(interpretedResponse[0].currency).to.equal(serverResponse.body.seatbid[0].bid.currency); + expect(interpretedResponse[0].netRevenue).to.equal(serverResponse.body.seatbid[0].bid.netRevenue); + expect(interpretedResponse[0].ad).to.equal(serverResponse.body.seatbid[0].bid.ad); + expect(interpretedResponse[0].ttl).to.equal(serverResponse.body.seatbid[0].bid.ttl); + }); + }); + + describe('getUserSyncs', function () { + it('should perform usersync', function () { + let syncs = spec.getUserSyncs({pixelEnabled: false}, [serverResponse]); + expect(syncs).to.have.length(0); + + syncs = spec.getUserSyncs({pixelEnabled: true}, [serverResponse]); + expect(syncs).to.have.length(1); + + expect(syncs[0]).to.have.property('type', 'image'); + expect(syncs[0]).to.have.property('url', 'https://cr-p31.ladsp.jp/cookiesender/31'); + }); + }); +}); diff --git a/test/spec/modules/loopmeBidAdapter_spec.js b/test/spec/modules/loopmeBidAdapter_spec.js index 6d612746299..0d7e71c22db 100644 --- a/test/spec/modules/loopmeBidAdapter_spec.js +++ b/test/spec/modules/loopmeBidAdapter_spec.js @@ -15,37 +15,71 @@ describe('LoopMeAdapter', function () { }, adUnitCode: 'ad-1', bidId: '2652ca954bce9' - }]; + }, { + bidder: 'loopme', + params: { + ak: 'b510d5bcda' + }, + mediaTypes: { + video: { + playerSize: [[640, 480]], + context: 'outstream' + } + }, + adUnitCode: 'ad-1', + bidId: '2652ca954bce9' + } + ]; describe('isBidRequestValid', function () { it('should return true if the ak parameter is present', function () { expect(spec.isBidRequestValid(bidRequests[0])).to.be.true; + expect(spec.isBidRequestValid(bidRequests[1])).to.be.true; }); it('should return false if the ak parameter is not present', function () { - let bidRequest = utils.deepClone(bidRequests[0]); - delete bidRequest.params.ak; - expect(spec.isBidRequestValid(bidRequest)).to.be.false; + let bannerBidRequest = utils.deepClone(bidRequests[0]); + delete bannerBidRequest.params.ak; + expect(spec.isBidRequestValid(bannerBidRequest)).to.be.false; + + let videoBidRequest = utils.deepClone(bidRequests[1]); + delete videoBidRequest.params.ak; + expect(spec.isBidRequestValid(videoBidRequest)).to.be.false; }); it('should return false if the params object is not present', function () { - let bidRequest = utils.deepClone(bidRequests); - delete bidRequest[0].params; - expect(spec.isBidRequestValid(bidRequest)).to.be.false; + let bannerBidRequest = utils.deepClone(bidRequests)[0]; + delete bannerBidRequest.params; + expect(spec.isBidRequestValid(bannerBidRequest)).to.be.false; + + let videoBidRequest = utils.deepClone(bidRequests)[1]; + delete videoBidRequest.params; + expect(spec.isBidRequestValid(videoBidRequest)).to.be.false; }); }); describe('buildRequests', function () { it('should generate a valid single GET request for multiple bid requests', function () { - const request = spec.buildRequests(bidRequests)[0]; - expect(request.method).to.equal('GET'); - expect(request.url).to.equal('https://loopme.me/api/hb'); - expect(request.bidId).to.equal('2652ca954bce9'); - expect(request.data).to.exist; + const bannerRequest = spec.buildRequests(bidRequests)[0]; + expect(bannerRequest.method).to.equal('GET'); + expect(bannerRequest.url).to.equal('https://loopme.me/api/hb'); + expect(bannerRequest.bidId).to.equal('2652ca954bce9'); + expect(bannerRequest.data).to.exist; - const requestData = request.data; - expect(requestData).to.contain('ak=b510d5bcda'); - expect(requestData).to.contain('sizes=300x250'); + const bannerRequestData = bannerRequest.data; + expect(bannerRequestData).to.contain('ak=b510d5bcda'); + expect(bannerRequestData).to.contain('sizes=300x250'); + + const videoRequest = spec.buildRequests(bidRequests)[1]; + expect(videoRequest.method).to.equal('GET'); + expect(videoRequest.url).to.equal('https://loopme.me/api/hb'); + expect(videoRequest.bidId).to.equal('2652ca954bce9'); + expect(videoRequest.data).to.exist; + + const videoRquestData = videoRequest.data; + expect(videoRquestData).to.contain('ak=b510d5bcda'); + expect(videoRquestData).to.contain('sizes=640x480'); + expect(videoRquestData).to.contain('media_type=video'); }); it('should add GDPR data to request if available', function () { @@ -67,7 +101,7 @@ describe('LoopMeAdapter', function () { expect(interpretedResponse).to.be.an('array').that.is.empty; }); - it('should return valid response when passed valid server response', function () { + xit('should return valid response when passed valid server response', function () { const serverResponse = { body: { 'requestId': '2652ca954bce9', @@ -97,5 +131,37 @@ describe('LoopMeAdapter', function () { expect(interpretedResponse[0].ad).to.equal(serverResponse.body.ad); expect(interpretedResponse[0].ttl).to.equal(serverResponse.body.ttl); }); + + it('should return valid VAST response when passed valid server response', function () { + const serverResponse = { + body: { + 'requestId': '2652ca954bce9', + 'cpm': 1, + 'width': 640, + 'height': 480, + 'creativeId': '20154', + 'currency': 'USD', + 'netRevenue': false, + 'ttl': 360, + 'vastUrl': 'https://loopme.me/ads/vast?ak=cc885e3acc' + } + }; + + const request = spec.buildRequests(bidRequests)[1]; + const interpretedResponse = spec.interpretResponse(serverResponse, request); + + expect(interpretedResponse).to.have.lengthOf(1); + + expect(interpretedResponse[0].requestId).to.equal(serverResponse.body.requestId); + expect(interpretedResponse[0].cpm).to.equal(serverResponse.body.cpm); + expect(interpretedResponse[0].width).to.equal(serverResponse.body.width); + expect(interpretedResponse[0].height).to.equal(serverResponse.body.height); + expect(interpretedResponse[0].creativeId).to.equal(serverResponse.body.creativeId); + expect(interpretedResponse[0].currency).to.equal(serverResponse.body.currency); + expect(interpretedResponse[0].netRevenue).to.equal(serverResponse.body.netRevenue); + expect(interpretedResponse[0].vastUrl).to.equal(serverResponse.body.vastUrl); + expect(interpretedResponse[0].ttl).to.equal(serverResponse.body.ttl); + expect(interpretedResponse[0].renderer).to.have.property('render'); + }); }); }); diff --git a/test/spec/modules/marsmediaBidAdapter_spec.js b/test/spec/modules/marsmediaBidAdapter_spec.js new file mode 100644 index 00000000000..a58857e0f3f --- /dev/null +++ b/test/spec/modules/marsmediaBidAdapter_spec.js @@ -0,0 +1,122 @@ +import { expect } from 'chai' +import { spec, _getPlatform } from 'modules/marsmediaBidAdapter' +import { newBidder } from 'src/adapters/bidderFactory' + +describe('marsmediaBidAdapter', function () { + const adapter = newBidder(spec) + + let bidRequest = { + 'bidId': '123', + 'sizes': [[ 300, 250 ]], + 'params': { + 'publisherID': 9999, + 'floor': 0.1 + } + } + + describe('codes', function () { + it('should return a bidder code of marsmedia', function () { + expect(spec.code).to.equal('marsmedia') + }) + it('should alias mars', function () { + expect(spec.aliases.length > 0 && spec.aliases[0] === 'mars').to.be.true + }) + }) + + describe('isBidRequestValid', function () { + it('should return true if all params present', function () { + expect(spec.isBidRequestValid(bidRequest)).to.be.true + }) + + it('should return false if any parameter missing', function () { + expect(spec.isBidRequestValid(Object.assign(bidRequest, { params: { publisherID: null } }))).to.be.false + }) + }) + + describe('buildRequests', function () { + let req = spec.buildRequests([ bidRequest ], { refererInfo: { } }) + let rdata + + it('should return request object', function () { + expect(req).to.not.be.null + }) + + it('should build request data', function () { + expect(req.data).to.not.be.null + }) + + it('should include one request', function () { + rdata = JSON.parse(req.data) + expect(rdata.imp.length).to.equal(1) + }) + + it('should include all publisher params', function () { + let r = rdata.imp[0] + expect(r.publisherID !== null).to.be.true + }) + }) + + describe('interpretResponse', function () { + let response; + beforeEach(function () { + response = { + body: { + 'id': '37386aade21a71', + 'seatbid': [{ + 'bid': [{ + 'id': '1', + 'impid': '1', + 'cid': '1', + 'price': 0.1, + 'nurl': '', + 'adm': '', + 'w': 320, + 'h': 250 + }] + }] + } + }; + }); + + it('should get the correct bid response', function () { + let expectedResponse = [{ + 'requestId': '37386aade21a71', + 'cpm': 0.1, + 'width': 320, + 'height': 250, + 'creativeId': '1', + 'currency': 'USD', + 'netRevenue': true, + 'ad': ``, + 'ttl': 60 + }]; + + let result = spec.interpretResponse(response); + expect(result[0]).to.deep.equal(expectedResponse[0]); + }); + + it('handles empty bid response', function () { + let response = { + body: '' + }; + let result = spec.interpretResponse(response); + expect(result.length).to.equal(0); + }); + }); + + describe('getUserSyncs', function () { + /* it('should return iframe sync', function () { + let sync = spec.getUserSyncs({ iframeEnabled: true }) + expect(sync.length).to.equal(1) + expect(sync[0].type === 'iframe') + expect(typeof sync[0].url === 'string') + }) + + it('should return pixel sync', function () { + let sync = spec.getUserSyncs({ pixelEnabled: true }) + expect(sync.length).to.equal(1) + expect(sync[0].type === 'image') + expect(typeof sync[0].url === 'string') + }) */ + }) +}) diff --git a/test/spec/modules/meazyBidAdapter_spec.js b/test/spec/modules/meazyBidAdapter_spec.js new file mode 100644 index 00000000000..9abe37ece62 --- /dev/null +++ b/test/spec/modules/meazyBidAdapter_spec.js @@ -0,0 +1,177 @@ +import * as utils from 'src/utils'; +import { expect } from 'chai'; +import { spec } from 'modules/meazyBidAdapter'; +import { newBidder } from 'src/adapters/bidderFactory'; + +const MEAZY_PID = '6910b7344ae566a1' +const VALID_ENDPOINT = `//rtb-filter.meazy.co/pbjs?host=${utils.getOrigin()}&api_key=${MEAZY_PID}`; + +const bidderRequest = { + refererInfo: { + referer: 'page', + stack: ['page', 'page1'] + } +}; + +const bidRequest = { + bidder: 'meazy', + adUnitCode: 'test-div', + sizes: [[300, 250], [300, 600]], + params: { + pid: MEAZY_PID + }, + bidId: '30b31c1838de1e', + bidderRequestId: '22edbae2733bf6', + auctionId: '1d1a030790a475', +}; + +const bidContent = { + 'id': '30b31c1838de1e', + 'bidid': '9780a52ff05c0e92780f5baf9cf3f4e8', + 'cur': 'USD', + 'seatbid': [{ + 'bid': [{ + 'id': 'ccf05fb8effb3d02', + 'impid': 'B19C34BBD69DAF9F', + 'burl': 'https://track.meazy.co/imp?bidid=9780a52ff05c0e92780f5baf9cf3f4e8&user=fdc401a2-92f1-42bd-ac22-d570520ad0ec&burl=1&ssp=5&project=2&cost=${AUCTION_PRICE}', + 'adm': '', + 'adid': 'ad-2.6.75.300x250', + 'price': 1.5, + 'w': 300, + 'h': 250, + 'cid': '2.6.75', + 'crid': '2.6.75.300x250', + 'dealid': 'default' + }], + 'seat': '2' + }] +}; + +const bidContentExt = { + ...bidContent, + ext: { + 'syncUrl': '//sync.meazy.co/sync/img?api_key=6910b7344ae566a1' + } +}; + +const bidResponse = { + body: bidContent +}; + +const noBidResponse = { body: {'nbr': 2} }; + +describe('meazyBidAdapter', function () { + const adapter = newBidder(spec); + + describe('inherited functions', function () { + it('exists and is a function', function () { + expect(adapter.callBids).to.exist.and.to.be.a('function'); + }); + }); + + describe('isBidRequestValid', function () { + it('should return false', function () { + let bid = Object.assign({}, bidRequest); + bid.params = {}; + expect(spec.isBidRequestValid(bid)).to.equal(false); + }); + + it('should return true', function () { + expect(spec.isBidRequestValid(bidRequest)).to.equal(true); + }); + }); + + describe('buildRequests', function () { + it('should format valid url', function () { + const request = spec.buildRequests([bidRequest], bidderRequest); + expect(request.url).to.equal(VALID_ENDPOINT); + }); + + it('should format valid url', function () { + const request = spec.buildRequests([bidRequest], bidderRequest); + expect(request.url).to.equal(VALID_ENDPOINT); + }); + + it('should format valid request body', function () { + const request = spec.buildRequests([bidRequest], bidderRequest); + const payload = JSON.parse(request.data); + expect(payload.id).to.exist; + expect(payload.imp).to.exist; + expect(payload.imp[0]).to.exist; + expect(payload.imp[0].banner).to.exist; + expect(payload.imp[0].banner.format).to.exist; + expect(payload.device).to.exist; + expect(payload.site).to.exist; + expect(payload.site.domain).to.exist; + expect(payload.cur).to.exist; + }); + + it('should format valid url', function () { + const request = spec.buildRequests([bidRequest], bidderRequest); + expect(request.url).to.equal(VALID_ENDPOINT); + }); + + it('should not fill user.ext object', function () { + const request = spec.buildRequests([bidRequest], bidderRequest); + const payload = JSON.parse(request.data); + expect(payload.user.ext).to.equal(undefined); + }); + + it('should fill user.ext object', function () { + const consentString = 'hellogdpr'; + const request = spec.buildRequests([bidRequest], { ...bidderRequest, gdprConsent: { gdprApplies: true, consentString } }); + const payload = JSON.parse(request.data); + expect(payload.user.ext).to.exist.and.to.be.a('object'); + expect(payload.user.ext.consent).to.equal(consentString); + expect(payload.user.ext.gdpr).to.equal(1); + }); + }); + + describe('interpretResponse', function () { + it('should get correct bid response', function () { + const result = spec.interpretResponse(bidResponse); + const validResponse = [{ + requestId: '30b31c1838de1e', + cpm: 1.5, + width: 300, + height: 250, + creativeId: '2.6.75.300x250', + netRevenue: true, + dealId: 'default', + currency: 'USD', + ttl: 900, + ad: '' + }]; + + expect(result).to.deep.equal(validResponse); + }); + + it('handles nobid responses', function () { + let result = spec.interpretResponse(noBidResponse); + expect(result.length).to.equal(0); + }); + }); + + describe('getUserSyncs', function () { + const syncOptionsFF = { iframeEnabled: false }; + const syncOptionsEF = { iframeEnabled: true }; + const syncOptionsEE = { pixelEnabled: true, iframeEnabled: true }; + const syncOptionsFE = { pixelEnabled: true, iframeEnabled: false }; + + const successIFrame = { type: 'iframe', url: '//sync.meazy.co/sync/iframe' }; + const successPixel = { type: 'image', url: '//sync.meazy.co/sync/img?api_key=6910b7344ae566a1' }; + + it('should return an empty array', function () { + expect(spec.getUserSyncs(syncOptionsFF, [])).to.be.empty; + expect(spec.getUserSyncs(syncOptionsFF, [ bidResponse ])).to.be.empty; + expect(spec.getUserSyncs(syncOptionsFE, [ bidResponse ])).to.be.empty; + }); + + it('should be equal to the expected result', function () { + expect(spec.getUserSyncs(syncOptionsEF, [ bidResponse ])).to.deep.equal([successIFrame]); + expect(spec.getUserSyncs(syncOptionsFE, [ { body: bidContentExt } ])).to.deep.equal([successPixel]); + expect(spec.getUserSyncs(syncOptionsEE, [ { body: bidContentExt } ])).to.deep.equal([successPixel, successIFrame]); + expect(spec.getUserSyncs(syncOptionsEE, [])).to.deep.equal([successIFrame]); + }) + }); +}); diff --git a/test/spec/modules/mgidBidAdapter_spec.js b/test/spec/modules/mgidBidAdapter_spec.js index 4c67447489d..4a9f25a29a7 100644 --- a/test/spec/modules/mgidBidAdapter_spec.js +++ b/test/spec/modules/mgidBidAdapter_spec.js @@ -1,16 +1,22 @@ -import {expect} from 'chai'; +import {assert, expect} from 'chai'; import {spec} from 'modules/mgidBidAdapter'; import * as utils from '../../../src/utils'; import * as urlUtils from '../../../src/url'; describe('Mgid bid adapter', function () { let sandbox; + let logErrorSpy; + let logWarnSpy; beforeEach(function () { sandbox = sinon.sandbox.create(); + logErrorSpy = sinon.spy(utils, 'logError'); + logWarnSpy = sinon.spy(utils, 'logWarn'); }); afterEach(function () { sandbox.restore(); + utils.logError.restore(); + utils.logWarn.restore(); }); const ua = navigator.userAgent; const screenHeight = screen.height; @@ -24,9 +30,11 @@ describe('Mgid bid adapter', function () { const secure = window.location.protocol === 'https:' ? 1 : 0; const mgid_ver = spec.VERSION; const prebid_ver = $$PREBID_GLOBAL$$.version; + const utcOffset = (new Date()).getTimezoneOffset().toString(); describe('isBidRequestValid', function () { let bid = { + 'adUnitCode': 'div', 'bidder': 'mgid', 'params': { 'property': '10433394', @@ -53,6 +61,57 @@ describe('Mgid bid adapter', function () { expect(spec.isBidRequestValid(bid)).to.equal(false); }); + it('should return false when valid params are not passed', function () { + let bid = Object.assign({}, bid); + delete bid.params; + bid.adUnitCode = ''; + bid.mediaTypes = { + banner: { + sizes: [[300, 250]] + } + }; + bid.params = {accountId: 2, placementId: 1}; + expect(spec.isBidRequestValid(bid)).to.equal(false); + }); + + it('should return false when adUnitCode not passed', function () { + let bid = Object.assign({}, bid); + delete bid.params; + bid.adUnitCode = ''; + bid.mediaTypes = { + banner: { + sizes: [[300, 250]] + } + }; + bid.params = {accountId: 2, placementId: 1}; + expect(spec.isBidRequestValid(bid)).to.equal(false); + }); + + it('should return true when valid params are passed as nums', function () { + let bid = Object.assign({}, bid); + delete bid.params; + bid.adUnitCode = 'div'; + bid.mediaTypes = { + banner: { + sizes: [[300, 250]] + } + }; + bid.params = {accountId: 2, placementId: 1}; + expect(spec.isBidRequestValid(bid)).to.equal(true); + }); + + it('should return false when valid params are not passed', function () { + let bid = Object.assign({}, bid); + delete bid.params; + bid.mediaTypes = { + native: { + sizes: [[300, 250]] + } + }; + bid.params = {accountId: '0', placementId: '00'}; + expect(spec.isBidRequestValid(bid)).to.equal(false); + }); + it('should return false when valid mediaTypes are not passed', function () { let bid = Object.assign({}, bid); delete bid.params; @@ -89,9 +148,10 @@ describe('Mgid bid adapter', function () { expect(spec.isBidRequestValid(bid)).to.equal(false); }); - it('should return true when valid params are passed', function () { + it('should return true when valid params are passed as strings', function () { let bid = Object.assign({}, bid); delete bid.params; + bid.adUnitCode = 'div'; bid.params = {accountId: '1', placementId: '1'}; bid.mediaTypes = { banner: { @@ -100,6 +160,77 @@ describe('Mgid bid adapter', function () { }; expect(spec.isBidRequestValid(bid)).to.equal(true); }); + + it('should return false when valid mediaTypes.native is not object', function () { + let bid = Object.assign({}, bid); + bid.params = {accountId: '1', placementId: '1'}; + bid.mediaTypes = { + native: [] + }; + expect(spec.isBidRequestValid(bid)).to.equal(false); + }); + + it('should return false when mediaTypes.native is empty object', function () { + let bid = Object.assign({}, bid); + delete bid.params; + bid.params = {accountId: '1', placementId: '1'}; + bid.mediaTypes = { + native: {} + }; + expect(spec.isBidRequestValid(bid)).to.equal(false); + }); + + it('should return false when mediaTypes.native is invalid object', function () { + let bid = Object.assign({}, bid); + delete bid.params; + bid.params = {accountId: '1', placementId: '1'}; + bid.mediaTypes = { + native: { + image: { + sizes: [80, 80] + }, + } + }; + expect(spec.isBidRequestValid(bid)).to.equal(false); + }); + + it('should return false when mediaTypes.native has unsupported required asset', function () { + let bid = Object.assign({}, bid); + bid.params = {accountId: '2', placementId: '1'}; + bid.mediaTypes = { + native: { + title: {required: true}, + image: {required: false, sizes: [80, 80]}, + sponsored: {required: false}, + }, + }; + bid.nativeParams = { + title: {required: true}, + image: {required: false, sizes: [80, 80]}, + sponsored: {required: false}, + unsupported: {required: true}, + }; + expect(spec.isBidRequestValid(bid)).to.equal(false); + }); + + it('should return true when mediaTypes.native all assets needed', function () { + let bid = Object.assign({}, bid); + bid.adUnitCode = 'div'; + bid.params = {accountId: '2', placementId: '1'}; + bid.mediaTypes = { + native: { + title: {required: true}, + image: {required: false, sizes: [80, 80]}, + sponsored: {required: false}, + }, + }; + bid.nativeParams = { + title: {required: true}, + image: {required: false, sizes: [80, 80]}, + sponsored: {required: false}, + }; + expect(spec.isBidRequestValid(bid)).to.equal(true); + }); }); describe('override defaults', function () { @@ -138,17 +269,63 @@ describe('Mgid bid adapter', function () { const request = spec.buildRequests(bidRequests); expect(request.url).to.include('//newbidurl.com/1'); }); + it('should return overwrite default bidFloor', function () { + let bid = Object.assign({}, bid); + bid.params = { + bidFloor: 1.1, + accountId: '1', + placementId: '2', + }; + bid.mediaTypes = { + banner: { + sizes: [[300, 250]] + } + }; + let bidRequests = [bid]; + const request = spec.buildRequests(bidRequests); + expect(request.data).to.be.a('string'); + const data = JSON.parse(request.data); + expect(data).to.be.a('object'); + expect(data.imp).to.be.a('array'); + expect(data.imp).to.have.lengthOf(1); + expect(data.imp[0].bidfloor).to.deep.equal(1.1); + }); + it('should return overwrite default currency', function () { + let bid = Object.assign({}, bid); + bid.params = { + cur: 'GBP', + accountId: '1', + placementId: '2', + }; + bid.mediaTypes = { + banner: { + sizes: [[300, 250]] + } + }; + let bidRequests = [bid]; + const request = spec.buildRequests(bidRequests); + expect(request.data).to.be.a('string'); + const data = JSON.parse(request.data); + expect(data).to.be.a('object'); + expect(data.cur).to.deep.equal(['GBP']); + }); }); describe('buildRequests', function () { + it('should return undefined if no validBidRequests passed', function () { + expect(spec.buildRequests([])).to.be.undefined; + }); + let abid = { + adUnitCode: 'div', bidder: 'mgid', params: { accountId: '1', placementId: '2', }, }; - it('should return proper imp', function () { + it('should return proper request url', function () { + localStorage.setItem('mgMuidn', 'xxx'); let bid = Object.assign({}, abid); bid.mediaTypes = { banner: { @@ -156,29 +333,179 @@ describe('Mgid bid adapter', function () { } }; let bidRequests = [bid]; - const referer = utils.deepAccess(bidRequests, 'refererInfo.referer'); - const domain = urlUtils.parse(referer).hostname; const request = spec.buildRequests(bidRequests); - expect(request.url).deep.equal('//dsp.mgid.com/prebid/1'); + expect(request.url).deep.equal('https://prebid.mgid.com/prebid/1?muid=xxx'); + localStorage.removeItem('mgMuidn') + }); + it('should proper handle gdpr', function () { + let bid = Object.assign({}, abid); + bid.mediaTypes = { + banner: { + sizes: [[300, 250]] + } + }; + let bidRequests = [bid]; + const request = spec.buildRequests(bidRequests, {gdprConsent: {consentString: 'gdpr', gdprApplies: true}}); + expect(request.url).deep.equal('https://prebid.mgid.com/prebid/1'); + expect(request.method).deep.equal('POST'); + const data = JSON.parse(request.data); + expect(data.user).deep.equal({ext: {consent: 'gdpr'}}); + expect(data.regs).deep.equal({ext: {gdpr: 1}}); + }); + it('should return proper banner imp', function () { + let bid = Object.assign({}, abid); + bid.mediaTypes = { + banner: { + sizes: [[300, 250]] + } + }; + let bidRequests = [bid]; + const page = top.location.href; + const domain = urlUtils.parse(page).hostname; + const request = spec.buildRequests(bidRequests); + expect(request.url).deep.equal('https://prebid.mgid.com/prebid/1'); + expect(request.method).deep.equal('POST'); + const data = JSON.parse(request.data); + expect(data.site.domain).to.deep.equal(domain); + expect(data.site.page).to.deep.equal(page); + expect(data.cur).to.deep.equal(['USD']); + expect(data.device.ua).to.deep.equal(ua); + expect(data.device.dnt).equal(dnt); + expect(data.device.h).equal(screenHeight); + expect(data.device.w).equal(screenWidth); + expect(data.device.language).to.deep.equal(lang); + expect(data.imp[0].tagid).to.deep.equal('2/div'); + expect(data.imp[0].banner).to.deep.equal({w: 300, h: 250}); + expect(data.imp[0].secure).to.deep.equal(secure); + expect(request).to.deep.equal({ + 'method': 'POST', + 'url': 'https://prebid.mgid.com/prebid/1', + 'data': '{\"site\":{\"domain\":\"' + domain + '\",\"page\":\"' + page + '\"},\"cur\":[\"USD\"],\"geo\":{\"utcoffset\":' + utcOffset + '},\"device\":{\"ua\":\"' + ua + '\",\"js\":1,\"dnt\":' + dnt + ',\"h\":' + screenHeight + ',\"w\":' + screenWidth + ',\"language\":\"' + lang + '\"},\"ext\":{\"mgid_ver\":\"' + mgid_ver + '\",\"prebid_ver\":\"' + prebid_ver + '\"},\"imp\":[{\"tagid\":\"2/div\",\"secure\":' + secure + ',\"banner\":{\"w\":300,\"h\":250}}]}', + }); + }); + it('should not return native imp if minimum asset list not requested', function () { + let bid = Object.assign({}, abid); + bid.mediaTypes = { + native: '', + }; + bid.nativeParams = { + title: {required: true}, + image: {sizes: [80, 80]}, + }; + let bidRequests = [bid]; + const request = spec.buildRequests(bidRequests); + expect(request).to.be.undefined; + }); + it('should return proper native imp', function () { + let bid = Object.assign({}, abid); + bid.mediaTypes = { + native: '', + }; + bid.nativeParams = { + title: {required: true}, + image: {sizes: [80, 80]}, + sponsored: { }, + }; + + let bidRequests = [bid]; + const page = top.location.href; + const domain = urlUtils.parse(page).hostname; + const request = spec.buildRequests(bidRequests); + expect(request).to.be.a('object'); + expect(request.url).deep.equal('https://prebid.mgid.com/prebid/1'); + expect(request.method).deep.equal('POST'); + const data = JSON.parse(request.data); + expect(data.site.domain).to.deep.equal(domain); + expect(data.site.page).to.deep.equal(page); + expect(data.cur).to.deep.equal(['USD']); + expect(data.device.ua).to.deep.equal(ua); + expect(data.device.dnt).equal(dnt); + expect(data.device.h).equal(screenHeight); + expect(data.device.w).equal(screenWidth); + expect(data.device.language).to.deep.equal(lang); + expect(data.imp[0].tagid).to.deep.equal('2/div'); + expect(data.imp[0].native).is.a('object').and.to.deep.equal({'request': {'assets': [{'id': 1, 'required': 1, 'title': {'len': 80}}, {'id': 2, 'img': {'h': 80, 'type': 3, 'w': 80}, 'required': 0}, {'data': {'type': 1}, 'id': 11, 'required': 0}], 'plcmtcnt': 1}}); + expect(data.imp[0].secure).to.deep.equal(secure); + expect(request).to.deep.equal({ + 'method': 'POST', + 'url': 'https://prebid.mgid.com/prebid/1', + 'data': '{\"site\":{\"domain\":\"' + domain + '\",\"page\":\"' + page + '\"},\"cur\":[\"USD\"],\"geo\":{\"utcoffset\":' + utcOffset + '},\"device\":{\"ua\":\"' + ua + '\",\"js\":1,\"dnt\":' + dnt + ',\"h\":' + screenHeight + ',\"w\":' + screenWidth + ',\"language\":\"' + lang + '\"},\"ext\":{\"mgid_ver\":\"' + mgid_ver + '\",\"prebid_ver\":\"' + prebid_ver + '\"},\"imp\":[{\"tagid\":\"2/div\",\"secure\":' + secure + ',\"native\":{\"request\":{\"plcmtcnt\":1,\"assets\":[{\"id\":1,\"required\":1,\"title\":{\"len\":80}},{\"id\":2,\"required\":0,\"img\":{\"type\":3,\"w\":80,\"h\":80}},{\"id\":11,\"required\":0,\"data\":{\"type\":1}}]}}}]}', + }); + }); + it('should return proper native imp', function () { + let bid = Object.assign({}, abid); + bid.mediaTypes = { + native: '', + }; + bid.nativeParams = { + title: {required: true}, + image: {wmin: 50, hmin: 50, required: true}, + icon: {}, + sponsored: { }, + }; + + let bidRequests = [bid]; + const page = top.location.href; + const domain = urlUtils.parse(page).hostname; + const request = spec.buildRequests(bidRequests); + expect(request).to.be.a('object'); + expect(request.url).deep.equal('https://prebid.mgid.com/prebid/1'); expect(request.method).deep.equal('POST'); const data = JSON.parse(request.data); expect(data.site.domain).to.deep.equal(domain); + expect(data.site.page).to.deep.equal(page); expect(data.cur).to.deep.equal(['USD']); expect(data.device.ua).to.deep.equal(ua); expect(data.device.dnt).equal(dnt); expect(data.device.h).equal(screenHeight); expect(data.device.w).equal(screenWidth); expect(data.device.language).to.deep.equal(lang); - expect(data.imp[0].tagid).to.deep.equal('2'); - expect(data.imp[0].banner).to.deep.equal({w: 300, h: 250, format: []}); + expect(data.imp[0].tagid).to.deep.equal('2/div'); + expect(data.imp[0].native).is.a('object').and.to.deep.equal({'request': {'assets': [{'id': 1, 'required': 1, 'title': {'len': 80}}, {'id': 2, 'img': {'h': 328, hmin: 50, 'type': 3, 'w': 492, wmin: 50}, 'required': 1}, {'id': 3, 'img': {'h': 50, 'type': 1, 'w': 50}, 'required': 0}, {'data': {'type': 1}, 'id': 11, 'required': 0}], 'plcmtcnt': 1}}); expect(data.imp[0].secure).to.deep.equal(secure); expect(request).to.deep.equal({ 'method': 'POST', - 'url': '//dsp.mgid.com/prebid/1', - 'data': '{\"site\":{\"domain\":\"' + domain + '\"},\"cur\":[\"USD\"],\"device\":{\"ua\":\"' + ua + '\",\"js\":1,\"dnt\":' + dnt + ',\"h\":' + screenHeight + ',\"w\":' + screenWidth + ',\"language\":\"' + lang + '\"},\"user\":{},\"regs\":{},\"ext\":{\"mgid_ver\":\"' + mgid_ver + '\",\"prebid_ver\":\"' + prebid_ver + '\"},\"imp\":[{\"tagid\":\"2\",\"banner\":{\"w\":300,\"h\":250,\"format\":[]},\"secure\":' + secure + '}]}', + 'url': 'https://prebid.mgid.com/prebid/1', + 'data': '{\"site\":{\"domain\":\"' + domain + '\",\"page\":\"' + page + '\"},\"cur\":[\"USD\"],\"geo\":{\"utcoffset\":' + utcOffset + '},\"device\":{\"ua\":\"' + ua + '\",\"js\":1,\"dnt\":' + dnt + ',\"h\":' + screenHeight + ',\"w\":' + screenWidth + ',\"language\":\"' + lang + '\"},\"ext\":{\"mgid_ver\":\"' + mgid_ver + '\",\"prebid_ver\":\"' + prebid_ver + '\"},\"imp\":[{\"tagid\":\"2/div\",\"secure\":' + secure + ',\"native\":{\"request\":{\"plcmtcnt\":1,\"assets\":[{\"id\":1,\"required\":1,\"title\":{\"len\":80}},{\"id\":2,\"required\":1,\"img\":{\"type\":3,\"w\":492,\"h\":328,\"wmin\":50,\"hmin\":50}},{\"id\":3,\"required\":0,\"img\":{\"type\":1,\"w\":50,\"h\":50}},{\"id\":11,\"required\":0,\"data\":{\"type\":1}}]}}}]}', }); }); - it('should return proper request', function () { + it('should return proper native imp with sponsoredBy', function () { + let bid = Object.assign({}, abid); + bid.mediaTypes = { + native: '', + }; + bid.nativeParams = { + title: {required: true}, + image: {sizes: [80, 80]}, + sponsoredBy: { }, + }; + + let bidRequests = [bid]; + const page = top.location.href; + const domain = urlUtils.parse(page).hostname; + const request = spec.buildRequests(bidRequests); + expect(request).to.be.a('object'); + expect(request.url).deep.equal('https://prebid.mgid.com/prebid/1'); + expect(request.method).deep.equal('POST'); + const data = JSON.parse(request.data); + expect(data.site.domain).to.deep.equal(domain); + expect(data.site.page).to.deep.equal(page); + expect(data.cur).to.deep.equal(['USD']); + expect(data.device.ua).to.deep.equal(ua); + expect(data.device.dnt).equal(dnt); + expect(data.device.h).equal(screenHeight); + expect(data.device.w).equal(screenWidth); + expect(data.device.language).to.deep.equal(lang); + expect(data.imp[0].tagid).to.deep.equal('2/div'); + expect(data.imp[0].native).is.a('object').and.to.deep.equal({'request': {'assets': [{'id': 1, 'required': 1, 'title': {'len': 80}}, {'id': 2, 'img': {'h': 80, 'type': 3, 'w': 80}, 'required': 0}, {'data': {'type': 1}, 'id': 4, 'required': 0}], 'plcmtcnt': 1}}); + expect(data.imp[0].secure).to.deep.equal(secure); + expect(request).to.deep.equal({ + 'method': 'POST', + 'url': 'https://prebid.mgid.com/prebid/1', + 'data': '{\"site\":{\"domain\":\"' + domain + '\",\"page\":\"' + page + '\"},\"cur\":[\"USD\"],\"geo\":{\"utcoffset\":' + utcOffset + '},\"device\":{\"ua\":\"' + ua + '\",\"js\":1,\"dnt\":' + dnt + ',\"h\":' + screenHeight + ',\"w\":' + screenWidth + ',\"language\":\"' + lang + '\"},\"ext\":{\"mgid_ver\":\"' + mgid_ver + '\",\"prebid_ver\":\"' + prebid_ver + '\"},\"imp\":[{\"tagid\":\"2/div\",\"secure\":' + secure + ',\"native\":{\"request\":{\"plcmtcnt\":1,\"assets\":[{\"id\":1,\"required\":1,\"title\":{\"len\":80}},{\"id\":2,\"required\":0,\"img\":{\"type\":3,\"w\":80,\"h\":80}},{\"id\":4,\"required\":0,\"data\":{\"type\":1}}]}}}]}', + }); + }); + it('should return proper banner request', function () { let bid = Object.assign({}, abid); bid.mediaTypes = { banner: { @@ -188,37 +515,38 @@ describe('Mgid bid adapter', function () { let bidRequests = [bid]; const request = spec.buildRequests(bidRequests); - const referer = utils.deepAccess(bidRequests, 'refererInfo.referer'); - const domain = urlUtils.parse(referer).hostname; - expect(request.url).deep.equal('//dsp.mgid.com/prebid/1'); + const page = top.location.href; + const domain = urlUtils.parse(page).hostname; + expect(request.url).deep.equal('https://prebid.mgid.com/prebid/1'); expect(request.method).deep.equal('POST'); const data = JSON.parse(request.data); expect(data.site.domain).to.deep.equal(domain); + expect(data.site.page).to.deep.equal(page); expect(data.cur).to.deep.equal(['USD']); expect(data.device.ua).to.deep.equal(ua); expect(data.device.dnt).equal(dnt); expect(data.device.h).equal(screenHeight); expect(data.device.w).equal(screenWidth); expect(data.device.language).to.deep.equal(lang); - expect(data.imp[0].tagid).to.deep.equal('2'); + expect(data.imp[0].tagid).to.deep.equal('2/div'); expect(data.imp[0].banner).to.deep.equal({w: 300, h: 600, format: [{w: 300, h: 600}, {w: 300, h: 250}]}); expect(data.imp[0].secure).to.deep.equal(secure); expect(request).to.deep.equal({ 'method': 'POST', - 'url': '//dsp.mgid.com/prebid/1', - 'data': '{\"site\":{\"domain\":\"' + domain + '\"},\"cur\":[\"USD\"],\"device\":{\"ua\":\"' + ua + '\",\"js\":1,\"dnt\":' + dnt + ',\"h\":' + screenHeight + ',\"w\":' + screenWidth + ',\"language\":\"' + lang + '\"},\"user\":{},\"regs\":{},\"ext\":{\"mgid_ver\":\"' + mgid_ver + '\",\"prebid_ver\":\"' + prebid_ver + '\"},\"imp\":[{\"tagid\":\"2\",\"banner\":{\"w\":300,\"h\":600,\"format\":[{\"w\":300,\"h\":600},{\"w\":300,\"h\":250}]},\"secure\":' + secure + '}]}', + 'url': 'https://prebid.mgid.com/prebid/1', + 'data': '{\"site\":{\"domain\":\"' + domain + '\",\"page\":\"' + page + '\"},\"cur\":[\"USD\"],\"geo\":{\"utcoffset\":' + utcOffset + '},\"device\":{\"ua\":\"' + ua + '\",\"js\":1,\"dnt\":' + dnt + ',\"h\":' + screenHeight + ',\"w\":' + screenWidth + ',\"language\":\"' + lang + '\"},\"ext\":{\"mgid_ver\":\"' + mgid_ver + '\",\"prebid_ver\":\"' + prebid_ver + '\"},\"imp\":[{\"tagid\":\"2/div\",\"secure\":' + secure + ',\"banner\":{\"w\":300,\"h\":600,\"format\":[{\"w\":300,\"h\":600},{\"w\":300,\"h\":250}]}}]}', }); }); }); - describe('interpretResponse', function () { + describe('interpretResponse banner', function () { it('should not push bid response', function () { let bids = spec.interpretResponse(); - expect(bids).to.deep.equal([]); + expect(bids).to.be.undefined; }); - it('should push proper bid response', function () { + it('should push proper banner bid response', function () { let resp = { - body: {'id': '57c0c2b1b732ca', 'bidid': '57c0c2b1b732ca', 'cur': 'USD', 'seatbid': [{'bid': [{'price': 1.5, 'h': 600, 'w': 300, 'id': '1', 'impid': '61e40632c53fc2', 'adid': '2898532/2419121/2592854/2499195', 'nurl': 'http: nurl', 'burl': 'http: nurl', 'adm': 'html: adm', 'cid': '44082', 'crid': '2898532/2419121/2592854/2499195', 'cat': ['IAB7', 'IAB14', 'IAB18-3', 'IAB1-2']}], 'seat': '44082'}]} + body: {'id': '57c0c2b1b732ca', 'bidid': '57c0c2b1b732ca', 'cur': '', 'seatbid': [{'bid': [{'price': 1.5, 'h': 600, 'w': 300, 'id': '1', 'impid': '61e40632c53fc2', 'adid': '2898532/2419121/2592854/2499195', 'nurl': 'http: nurl', 'burl': 'http: burl', 'adm': 'html: adm', 'cid': '44082', 'crid': '2898532/2419121/2592854/2499195', 'cat': ['IAB7', 'IAB14', 'IAB18-3', 'IAB1-2']}], 'seat': '44082'}]} }; let bids = spec.interpretResponse(resp); expect(bids).to.deep.equal([ @@ -233,6 +561,7 @@ describe('Mgid bid adapter', function () { 'mediaType': 'banner', 'netRevenue': true, 'nurl': 'http: nurl', + 'burl': 'http: burl', 'requestId': '61e40632c53fc2', 'ttl': 300, 'width': 300, @@ -240,4 +569,129 @@ describe('Mgid bid adapter', function () { ]); }); }); + describe('interpretResponse native', function () { + it('should not push proper native bid response if adm is missing', function () { + let resp = { + body: {'id': '57c0c2b1b732ca', 'bidid': '57c0c2b1b732ca', 'cur': 'GBP', 'seatbid': [{'bid': [{'price': 1.5, 'h': 600, 'w': 300, 'id': '1', 'impid': '61e40632c53fc2', 'adid': '2898532/2419121/2592854/2499195', 'nurl': 'http: nurl', 'burl': 'http: burl', 'cid': '44082', 'crid': '2898532/2419121/2592854/2499195', 'cat': ['IAB7', 'IAB14', 'IAB18-3', 'IAB1-2'], 'ext': {'place': 0, 'crtype': 'native'}}], 'seat': '44082'}]} + }; + let bids = spec.interpretResponse(resp); + expect(bids).to.deep.equal([]) + }); + it('should not push proper native bid response if assets is empty', function () { + let resp = { + body: {'id': '57c0c2b1b732ca', 'bidid': '57c0c2b1b732ca', 'cur': 'GBP', 'seatbid': [{'bid': [{'price': 1.5, 'h': 600, 'w': 300, 'id': '1', 'impid': '61e40632c53fc2', 'adid': '2898532/2419121/2592854/2499195', 'nurl': 'http: nurl', 'burl': 'http: burl', 'adm': '{\"native\":{\"ver\":\"1.1\",\"link\":{\"url\":\"link_url\"},\"assets\":[],\"imptrackers\":[\"imptrackers1\"]}}', 'cid': '44082', 'crid': '2898532/2419121/2592854/2499195', 'cat': ['IAB7', 'IAB14', 'IAB18-3', 'IAB1-2'], 'ext': {'place': 0, 'crtype': 'native'}}], 'seat': '44082'}]} + }; + let bids = spec.interpretResponse(resp); + expect(bids).to.deep.equal([]) + }); + it('should push proper native bid response', function () { + let resp = { + body: {'id': '57c0c2b1b732ca', 'bidid': '57c0c2b1b732ca', 'cur': 'GBP', 'seatbid': [{'bid': [{'price': 1.5, 'h': 600, 'w': 300, 'id': '1', 'impid': '61e40632c53fc2', 'adid': '2898532/2419121/2592854/2499195', 'nurl': 'http: nurl', 'burl': 'http: burl', 'adm': '{\"native\":{\"ver\":\"1.1\",\"link\":{\"url\":\"link_url\"},\"assets\":[{\"id\":1,\"required\":0,\"title\":{\"text\":\"title1\"}},{\"id\":2,\"required\":0,\"img\":{\"w\":80,\"h\":80,\"type\":3,\"url\":\"image_src\"}},{\"id\":3,\"required\":0,\"img\":{\"w\":50,\"h\":50,\"type\":1,\"url\":\"icon_src\"}},{\"id\":4,\"required\":0,\"data\":{\"type\":4,\"value\":\"sponsored\"}},{\"id\":5,\"required\":0,\"data\":{\"type\":6,\"value\":\"price1\"}},{\"id\":6,\"required\":0,\"data\":{\"type\":7,\"value\":\"price2\"}}],\"imptrackers\":[\"imptrackers1\"]}}', 'cid': '44082', 'crid': '2898532/2419121/2592854/2499195', 'cat': ['IAB7', 'IAB14', 'IAB18-3', 'IAB1-2'], 'ext': {'place': 0, 'crtype': 'native'}}], 'seat': '44082'}], ext: {'muidn': 'userid'}} + }; + let bids = spec.interpretResponse(resp); + expect(bids).to.deep.equal([{ + 'ad': '{\"native\":{\"ver\":\"1.1\",\"link\":{\"url\":\"link_url\"},\"assets\":[{\"id\":1,\"required\":0,\"title\":{\"text\":\"title1\"}},{\"id\":2,\"required\":0,\"img\":{\"w\":80,\"h\":80,\"type\":3,\"url\":\"image_src\"}},{\"id\":3,\"required\":0,\"img\":{\"w\":50,\"h\":50,\"type\":1,\"url\":\"icon_src\"}},{\"id\":4,\"required\":0,\"data\":{\"type\":4,\"value\":\"sponsored\"}},{\"id\":5,\"required\":0,\"data\":{\"type\":6,\"value\":\"price1\"}},{\"id\":6,\"required\":0,\"data\":{\"type\":7,\"value\":\"price2\"}}],\"imptrackers\":[\"imptrackers1\"]}}', + 'burl': 'http: burl', + 'cpm': 1.5, + 'creativeId': '2898532/2419121/2592854/2499195', + 'currency': 'GBP', + 'dealId': '', + 'height': 0, + 'isBurl': true, + 'mediaType': 'native', + 'native': { + 'clickTrackers': [], + 'clickUrl': 'link_url', + 'data': 'price1', + 'icon': { + 'height': 50, + 'url': 'icon_src', + 'width': 50 + }, + 'image': { + 'height': 80, + 'url': 'image_src', + 'width': 80 + }, + 'impressionTrackers': [ + 'imptrackers1' + ], + 'jstracker': [], + 'sponsoredBy': 'sponsored', + 'title': 'title1' + }, + 'netRevenue': true, + 'nurl': 'http: nurl', + 'requestId': '61e40632c53fc2', + 'ttl': 300, + 'width': 0 + }]) + }); + it('should push proper native bid response', function () { + let resp = { + body: {'id': '57c0c2b1b732ca', 'bidid': '57c0c2b1b732ca', 'cur': 'GBP', 'seatbid': [{'bid': [{'price': 1.5, 'h': 600, 'w': 300, 'id': '1', 'impid': '61e40632c53fc2', 'adid': '2898532/2419121/2592854/2499195', 'nurl': 'http: nurl', 'burl': 'http: burl', 'adm': '{\"native\":{\"ver\":\"1.1\",\"link\":{\"url\":\"link_url\"},\"assets\":[{\"id\":1,\"required\":0,\"title\":{\"text\":\"title1\"}},{\"id\":2,\"required\":0,\"img\":{\"w\":80,\"h\":80,\"type\":3,\"url\":\"image_src\"}},{\"id\":3,\"required\":0,\"img\":{\"w\":50,\"h\":50,\"type\":1,\"url\":\"icon_src\"}}],\"imptrackers\":[\"imptrackers1\"]}}', 'cid': '44082', 'crid': '2898532/2419121/2592854/2499195', 'cat': ['IAB7', 'IAB14', 'IAB18-3', 'IAB1-2'], 'ext': {'place': 0, 'crtype': 'native'}}], 'seat': '44082'}]} + }; + let bids = spec.interpretResponse(resp); + expect(bids).to.deep.equal([ + { + 'ad': '{\"native\":{\"ver\":\"1.1\",\"link\":{\"url\":\"link_url\"},\"assets\":[{\"id\":1,\"required\":0,\"title\":{\"text\":\"title1\"}},{\"id\":2,\"required\":0,\"img\":{\"w\":80,\"h\":80,\"type\":3,\"url\":\"image_src\"}},{\"id\":3,\"required\":0,\"img\":{\"w\":50,\"h\":50,\"type\":1,\"url\":\"icon_src\"}}],\"imptrackers\":[\"imptrackers1\"]}}', + 'cpm': 1.5, + 'creativeId': '2898532/2419121/2592854/2499195', + 'currency': 'GBP', + 'dealId': '', + 'height': 0, + 'isBurl': true, + 'mediaType': 'native', + 'netRevenue': true, + 'nurl': 'http: nurl', + 'burl': 'http: burl', + 'requestId': '61e40632c53fc2', + 'ttl': 300, + 'width': 0, + 'native': { + clickTrackers: [], + title: 'title1', + image: { + url: 'image_src', + width: 80, + height: 80, + }, + icon: { + url: 'icon_src', + width: 50, + height: 50, + }, + impressionTrackers: ['imptrackers1'], + jstracker: [], + clickUrl: 'link_url', + } + } + ]); + }); + }); + + describe('getUserSyncs', function () { + it('should do nothing on getUserSyncs', function () { + spec.getUserSyncs() + }); + }); + describe('on bidWon', function () { + it('should replace nurl and burl for native', function () { + const burl = 'burl&s=${' + 'AUCTION_PRICE}'; + const nurl = 'nurl&s=${' + 'AUCTION_PRICE}'; + const bid = {'bidderCode': 'mgid', 'width': 0, 'height': 0, 'statusMessage': 'Bid available', 'adId': '3d0b6ff1dda89', 'requestId': '2a423489e058a1', 'mediaType': 'native', 'source': 'client', 'ad': '{\"native\":{\"ver\":\"1.1\",\"link\":{\"url\":\"LinkURL\"},\"assets\":[{\"id\":1,\"required\":0,\"title\":{\"text\":\"TITLE\"}},{\"id\":2,\"required\":0,\"img\":{\"w\":80,\"h\":80,\"type\":3,\"url\":\"ImageURL\"}},{\"id\":3,\"required\":0,\"img\":{\"w\":50,\"h\":50,\"type\":1,\"url\":\"IconURL\"}},{\"id\":11,\"required\":0,\"data\":{\"type\":1,\"value\":\"sponsored\"}}],\"imptrackers\":[\"ImpTrackerURL\"]}}', 'cpm': 0.66, 'creativeId': '353538_591471', 'currency': 'USD', 'dealId': '', 'netRevenue': true, 'ttl': 300, 'nurl': nurl, 'burl': burl, 'isBurl': true, 'native': {'title': 'TITLE', 'image': {'url': 'ImageURL', 'height': 80, 'width': 80}, 'icon': {'url': 'IconURL', 'height': 50, 'width': 50}, 'sponsored': 'sponsored', 'clickUrl': 'LinkURL', 'clickTrackers': [], 'impressionTrackers': ['ImpTrackerURL'], 'jstracker': []}, 'auctionId': 'a92bffce-14d2-4f8f-a78a-7b9b5e4d28fa', 'responseTimestamp': 1556867386065, 'requestTimestamp': 1556867385916, 'bidder': 'mgid', 'adUnitCode': 'div-gpt-ad-1555415275793-0', 'timeToRespond': 149, 'pbLg': '0.50', 'pbMg': '0.60', 'pbHg': '0.66', 'pbAg': '0.65', 'pbDg': '0.66', 'pbCg': '', 'size': '0x0', 'adserverTargeting': {'hb_bidder': 'mgid', 'hb_adid': '3d0b6ff1dda89', 'hb_pb': '0.66', 'hb_size': '0x0', 'hb_source': 'client', 'hb_format': 'native', 'hb_native_title': 'TITLE', 'hb_native_image': 'hb_native_image:3d0b6ff1dda89', 'hb_native_icon': 'IconURL', 'hb_native_linkurl': 'hb_native_linkurl:3d0b6ff1dda89'}, 'status': 'targetingSet', 'params': [{'accountId': '184', 'placementId': '353538'}]}; + spec.onBidWon(bid); + expect(bid.nurl).to.deep.equal('nurl&s=0.66'); + expect(bid.burl).to.deep.equal('burl&s=0.66'); + }); + it('should replace nurl and burl for banner', function () { + const burl = 'burl&s=${' + 'AUCTION_PRICE}'; + const nurl = 'nurl&s=${' + 'AUCTION_PRICE}'; + const bid = {'bidderCode': 'mgid', 'width': 0, 'height': 0, 'statusMessage': 'Bid available', 'adId': '3d0b6ff1dda89', 'requestId': '2a423489e058a1', 'mediaType': 'banner', 'source': 'client', 'ad': burl, 'cpm': 0.66, 'creativeId': '353538_591471', 'currency': 'USD', 'dealId': '', 'netRevenue': true, 'ttl': 300, 'nurl': nurl, 'burl': burl, 'isBurl': true, 'auctionId': 'a92bffce-14d2-4f8f-a78a-7b9b5e4d28fa', 'responseTimestamp': 1556867386065, 'requestTimestamp': 1556867385916, 'bidder': 'mgid', 'adUnitCode': 'div-gpt-ad-1555415275793-0', 'timeToRespond': 149, 'pbLg': '0.50', 'pbMg': '0.60', 'pbHg': '0.66', 'pbAg': '0.65', 'pbDg': '0.66', 'pbCg': '', 'size': '0x0', 'adserverTargeting': {'hb_bidder': 'mgid', 'hb_adid': '3d0b6ff1dda89', 'hb_pb': '0.66', 'hb_size': '0x0', 'hb_source': 'client', 'hb_format': 'banner', 'hb_banner_title': 'TITLE', 'hb_banner_image': 'hb_banner_image:3d0b6ff1dda89', 'hb_banner_icon': 'IconURL', 'hb_banner_linkurl': 'hb_banner_linkurl:3d0b6ff1dda89'}, 'status': 'targetingSet', 'params': [{'accountId': '184', 'placementId': '353538'}]}; + spec.onBidWon(bid); + expect(bid.nurl).to.deep.equal('nurl&s=0.66'); + expect(bid.burl).to.deep.equal(burl); + expect(bid.ad).to.deep.equal('burl&s=0.66'); + }); + }); }); diff --git a/test/spec/modules/mytargetBidAdapter_spec.js b/test/spec/modules/mytargetBidAdapter_spec.js index 211d1df79a7..4e478fee1f0 100644 --- a/test/spec/modules/mytargetBidAdapter_spec.js +++ b/test/spec/modules/mytargetBidAdapter_spec.js @@ -1,4 +1,5 @@ import { expect } from 'chai'; +import { config } from 'src/config'; import { spec } from 'modules/mytargetBidAdapter'; describe('MyTarget Adapter', function() { @@ -114,6 +115,35 @@ describe('MyTarget Adapter', function() { expect(settings.windowSize.width).to.equal(window.screen.width); expect(settings.windowSize.height).to.equal(window.screen.height); }); + + it('should pass currency from currency.adServerCurrency', function() { + const configStub = sinon.stub(config, 'getConfig').callsFake( + key => key === 'currency.adServerCurrency' ? 'USD' : ''); + + let bidRequest = spec.buildRequests(bidRequests, bidderRequest); + let settings = bidRequest.data.settings; + + expect(settings).to.be.an('object'); + expect(settings.currency).to.equal('USD'); + expect(settings.windowSize).to.be.an('object'); + expect(settings.windowSize.width).to.equal(window.screen.width); + expect(settings.windowSize.height).to.equal(window.screen.height); + + configStub.restore(); + }); + + it('should ignore currency other than "RUB" or "USD"', function() { + const configStub = sinon.stub(config, 'getConfig').callsFake( + key => key === 'currency.adServerCurrency' ? 'EUR' : ''); + + let bidRequest = spec.buildRequests(bidRequests, bidderRequest); + let settings = bidRequest.data.settings; + + expect(settings).to.be.an('object'); + expect(settings.currency).to.equal('RUB'); + + configStub.restore(); + }); }); describe('interpretResponse', function () { diff --git a/test/spec/modules/nafdigitalBidAdapter_spec.js b/test/spec/modules/nafdigitalBidAdapter_spec.js new file mode 100644 index 00000000000..ca486c632c7 --- /dev/null +++ b/test/spec/modules/nafdigitalBidAdapter_spec.js @@ -0,0 +1,283 @@ +import { expect } from 'chai'; +import * as utils from 'src/utils'; +import { spec } from 'modules/nafdigitalBidAdapter'; +import { newBidder } from 'src/adapters/bidderFactory'; + +const URL = 'https://nafdigitalbidder.com/hb'; + +describe('nafdigitalBidAdapter', function() { + const adapter = newBidder(spec); + let element, win; + let bidRequests; + let sandbox; + + beforeEach(function() { + element = { + x: 0, + y: 0, + + width: 0, + height: 0, + + getBoundingClientRect: () => { + return { + width: element.width, + height: element.height, + + left: element.x, + top: element.y, + right: element.x + element.width, + bottom: element.y + element.height + }; + } + }; + win = { + document: { + visibilityState: 'visible' + }, + + innerWidth: 800, + innerHeight: 600 + }; + bidRequests = [{ + 'bidder': 'nafdigital', + 'params': { + 'publisherId': 1234567 + }, + 'adUnitCode': 'adunit-code', + 'sizes': [ + [300, 250], + [300, 600] + ], + 'bidId': '5fb26ac22bde4', + 'bidderRequestId': '4bf93aeb730cb9', + 'auctionId': 'ffe9a1f7-7b67-4bda-a8e0-9ee5dc9f442e' + }]; + + sandbox = sinon.sandbox.create(); + sandbox.stub(document, 'getElementById').withArgs('adunit-code').returns(element); + sandbox.stub(utils, 'getWindowTop').returns(win); + sandbox.stub(utils, 'getWindowSelf').returns(win); + }); + + afterEach(function() { + sandbox.restore(); + }); + + describe('isBidRequestValid', function () { + let bid = { + 'bidder': 'nafdigital', + 'params': { + 'publisherId': 1234567 + }, + 'adUnitCode': 'adunit-code', + 'sizes': [ + [300, 250], + [300, 600] + ], + 'bidId': '5fb26ac22bde4', + 'bidderRequestId': '4bf93aeb730cb9', + 'auctionId': 'ffe9a1f7-7b67-4bda-a8e0-9ee5dc9f442e', + }; + + it('should return true when required params found', function () { + expect(spec.isBidRequestValid(bid)).to.equal(true); + }); + + it('should return false when tagid not passed correctly', function () { + bid.params.publisherId = undefined; + expect(spec.isBidRequestValid(bid)).to.equal(false); + }); + + it('should return false when require params are not passed', function () { + let bid = Object.assign({}, bid); + bid.params = {}; + expect(spec.isBidRequestValid(bid)).to.equal(false); + }); + }); + + describe('buildRequests', function () { + it('sends bid request to our endpoint via POST', function () { + const request = spec.buildRequests(bidRequests); + expect(request.method).to.equal('POST'); + }); + + it('request url should match our endpoint url', function () { + const request = spec.buildRequests(bidRequests); + expect(request.url).to.equal(URL); + }); + + it('sets the proper banner object', function() { + const request = spec.buildRequests(bidRequests); + const payload = JSON.parse(request.data); + expect(payload.imp[0].banner.format).to.deep.equal([{w: 300, h: 250}, {w: 300, h: 600}]); + }); + + it('accepts a single array as a size', function() { + bidRequests[0].sizes = [300, 250]; + const request = spec.buildRequests(bidRequests); + const payload = JSON.parse(request.data); + expect(payload.imp[0].banner.format).to.deep.equal([{w: 300, h: 250}]); + }); + + it('sends bidfloor param if present', function () { + bidRequests[0].params.bidFloor = 0.05; + const request = spec.buildRequests(bidRequests); + const payload = JSON.parse(request.data); + expect(payload.imp[0].bidfloor).to.equal(0.05); + }); + + it('sends tagid', function () { + const request = spec.buildRequests(bidRequests); + const payload = JSON.parse(request.data); + expect(payload.imp[0].tagid).to.equal('adunit-code'); + }); + + it('sends publisher id', function () { + const request = spec.buildRequests(bidRequests); + const payload = JSON.parse(request.data); + expect(payload.site.publisher.id).to.equal(1234567); + }); + + context('when element is fully in view', function() { + it('returns 100', function() { + Object.assign(element, { width: 600, height: 400 }); + const request = spec.buildRequests(bidRequests); + const payload = JSON.parse(request.data); + expect(payload.imp[0].banner.ext.viewability).to.equal(100); + }); + }); + + context('when element is out of view', function() { + it('returns 0', function() { + Object.assign(element, { x: -300, y: 0, width: 207, height: 320 }); + const request = spec.buildRequests(bidRequests); + const payload = JSON.parse(request.data); + expect(payload.imp[0].banner.ext.viewability).to.equal(0); + }); + }); + + context('when element is partially in view', function() { + it('returns percentage', function() { + Object.assign(element, { width: 800, height: 800 }); + const request = spec.buildRequests(bidRequests); + const payload = JSON.parse(request.data); + expect(payload.imp[0].banner.ext.viewability).to.equal(75); + }); + }); + + context('when width or height of the element is zero', function() { + it('try to use alternative values', function() { + Object.assign(element, { width: 0, height: 0 }); + bidRequests[0].sizes = [[800, 2400]]; + const request = spec.buildRequests(bidRequests); + const payload = JSON.parse(request.data); + expect(payload.imp[0].banner.ext.viewability).to.equal(25); + }); + }); + + context('when nested iframes', function() { + it('returns \'na\'', function() { + Object.assign(element, { width: 600, height: 400 }); + + utils.getWindowTop.restore(); + utils.getWindowSelf.restore(); + sandbox.stub(utils, 'getWindowTop').returns(win); + sandbox.stub(utils, 'getWindowSelf').returns({}); + + const request = spec.buildRequests(bidRequests); + const payload = JSON.parse(request.data); + expect(payload.imp[0].banner.ext.viewability).to.equal('na'); + }); + }); + + context('when tab is inactive', function() { + it('returns 0', function() { + Object.assign(element, { width: 600, height: 400 }); + + utils.getWindowTop.restore(); + win.document.visibilityState = 'hidden'; + sandbox.stub(utils, 'getWindowTop').returns(win); + + const request = spec.buildRequests(bidRequests); + const payload = JSON.parse(request.data); + expect(payload.imp[0].banner.ext.viewability).to.equal(0); + }); + }); + }); + + describe('interpretResponse', function () { + let response; + beforeEach(function () { + response = { + body: { + 'id': '37386aade21a71', + 'seatbid': [{ + 'bid': [{ + 'id': '376874781', + 'impid': '283a9f4cd2415d', + 'price': 0.35743275, + 'nurl': '', + 'adm': '', + 'w': 300, + 'h': 250 + }] + }] + } + }; + }); + + it('should get the correct bid response', function () { + let expectedResponse = [{ + 'requestId': '283a9f4cd2415d', + 'cpm': 0.35743275, + 'width': 300, + 'height': 250, + 'creativeId': '376874781', + 'currency': 'USD', + 'netRevenue': true, + 'mediaType': 'banner', + 'ad': `
    `, + 'ttl': 60 + }]; + + let result = spec.interpretResponse(response); + expect(result[0]).to.deep.equal(expectedResponse[0]); + }); + + it('crid should default to the bid id if not on the response', function () { + let expectedResponse = [{ + 'requestId': '283a9f4cd2415d', + 'cpm': 0.35743275, + 'width': 300, + 'height': 250, + 'creativeId': response.body.seatbid[0].bid[0].id, + 'currency': 'USD', + 'netRevenue': true, + 'mediaType': 'banner', + 'ad': `
    `, + 'ttl': 60 + }]; + + let result = spec.interpretResponse(response); + expect(result[0]).to.deep.equal(expectedResponse[0]); + }); + + it('handles empty bid response', function () { + let response = { + body: '' + }; + let result = spec.interpretResponse(response); + expect(result.length).to.equal(0); + }); + }); + + describe('getUserSyncs ', () => { + let syncOptions = {iframeEnabled: true, pixelEnabled: true}; + + it('should not return', () => { + let returnStatement = spec.getUserSyncs(syncOptions, []); + expect(returnStatement).to.be.empty; + }); + }); +}); diff --git a/test/spec/modules/nanointeractiveBidAdapter_spec.js b/test/spec/modules/nanointeractiveBidAdapter_spec.js index 3731535b88a..a357327fe96 100644 --- a/test/spec/modules/nanointeractiveBidAdapter_spec.js +++ b/test/spec/modules/nanointeractiveBidAdapter_spec.js @@ -1,4 +1,4 @@ -import { expect } from 'chai'; +import {expect} from 'chai'; import * as utils from 'src/utils'; import * as sinon from 'sinon'; @@ -6,8 +6,8 @@ import { BIDDER_CODE, CATEGORY, CATEGORY_NAME, - DATA_PARTNER_PIXEL_ID, - ENGINE_BASE_URL, + SSP_PLACEMENT_ID, + END_POINT_URL, NQ, NQ_NAME, REF, @@ -19,8 +19,6 @@ describe('nanointeractive adapter tests', function () { const SIZES_PARAM = 'sizes'; const BID_ID_PARAM = 'bidId'; const BID_ID_VALUE = '24a1c9ec270973'; - const CORS_PARAM = 'cors'; - const LOC_PARAM = 'loc'; const DATA_PARTNER_PIXEL_ID_VALUE = 'testPID'; const NQ_VALUE = 'rumpelstiltskin'; const NQ_NAME_QUERY_PARAM = 'nqName'; @@ -37,21 +35,7 @@ describe('nanointeractive adapter tests', function () { const AD = '
    '; const CPM = 1; - function getBidResponse (pid, nq, category, subId, cors, ref, loc) { - return { - [DATA_PARTNER_PIXEL_ID]: pid, - [NQ]: nq, - [CATEGORY]: category, - [SUB_ID]: subId, - [REF]: ref, - [SIZES_PARAM]: [WIDTH1 + 'x' + HEIGHT1, WIDTH2 + 'x' + HEIGHT2], - [BID_ID_PARAM]: BID_ID_VALUE, - [CORS_PARAM]: cors, - [LOC_PARAM]: loc, - }; - } - - function getBidRequest (params) { + function getBidRequest(params) { return { bidder: BIDDER_CODE, params: params, @@ -70,85 +54,85 @@ describe('nanointeractive adapter tests', function () { describe('Methods', function () { it('Test isBidRequestValid() with valid param(s): pid', function () { expect(nanoBidAdapter.isBidRequestValid(getBidRequest({ - [DATA_PARTNER_PIXEL_ID]: DATA_PARTNER_PIXEL_ID_VALUE, + [SSP_PLACEMENT_ID]: DATA_PARTNER_PIXEL_ID_VALUE, }))).to.equal(true); }); it('Test isBidRequestValid() with valid param(s): pid, nq', function () { expect(nanoBidAdapter.isBidRequestValid(getBidRequest({ - [DATA_PARTNER_PIXEL_ID]: DATA_PARTNER_PIXEL_ID_VALUE, + [SSP_PLACEMENT_ID]: DATA_PARTNER_PIXEL_ID_VALUE, [NQ]: NQ, }))).to.equal(true); }); it('Test isBidRequestValid() with valid param(s): pid, nq, category', function () { expect(nanoBidAdapter.isBidRequestValid(getBidRequest({ - [DATA_PARTNER_PIXEL_ID]: DATA_PARTNER_PIXEL_ID_VALUE, + [SSP_PLACEMENT_ID]: DATA_PARTNER_PIXEL_ID_VALUE, [NQ]: NQ, [CATEGORY]: CATEGORY_VALUE, }))).to.equal(true); }); it('Test isBidRequestValid() with valid param(s): pid, nq, categoryName', function () { expect(nanoBidAdapter.isBidRequestValid(getBidRequest({ - [DATA_PARTNER_PIXEL_ID]: DATA_PARTNER_PIXEL_ID_VALUE, + [SSP_PLACEMENT_ID]: DATA_PARTNER_PIXEL_ID_VALUE, [NQ]: NQ, [CATEGORY_NAME_QUERY_PARAM]: CATEGORY_NAME_QUERY_PARAM, }))).to.equal(true); }); it('Test isBidRequestValid() with valid param(s): pid, nq, subId', function () { expect(nanoBidAdapter.isBidRequestValid(getBidRequest({ - [DATA_PARTNER_PIXEL_ID]: DATA_PARTNER_PIXEL_ID_VALUE, + [SSP_PLACEMENT_ID]: DATA_PARTNER_PIXEL_ID_VALUE, [NQ]: NQ, [SUB_ID]: SUB_ID_VALUE, }))).to.equal(true); }); it('Test isBidRequestValid() with valid param(s): pid, nqName', function () { expect(nanoBidAdapter.isBidRequestValid(getBidRequest({ - [DATA_PARTNER_PIXEL_ID]: DATA_PARTNER_PIXEL_ID_VALUE, + [SSP_PLACEMENT_ID]: DATA_PARTNER_PIXEL_ID_VALUE, [NQ_NAME]: NQ_NAME_QUERY_PARAM, }))).to.equal(true); }); it('Test isBidRequestValid() with valid param(s): pid, nqName, category', function () { expect(nanoBidAdapter.isBidRequestValid(getBidRequest({ - [DATA_PARTNER_PIXEL_ID]: DATA_PARTNER_PIXEL_ID_VALUE, + [SSP_PLACEMENT_ID]: DATA_PARTNER_PIXEL_ID_VALUE, [NQ_NAME]: NQ_NAME_QUERY_PARAM, [CATEGORY]: CATEGORY_VALUE, }))).to.equal(true); }); it('Test isBidRequestValid() with valid param(s): pid, nqName, categoryName', function () { expect(nanoBidAdapter.isBidRequestValid(getBidRequest({ - [DATA_PARTNER_PIXEL_ID]: DATA_PARTNER_PIXEL_ID_VALUE, + [SSP_PLACEMENT_ID]: DATA_PARTNER_PIXEL_ID_VALUE, [NQ_NAME]: NQ_NAME_QUERY_PARAM, [CATEGORY_NAME_QUERY_PARAM]: CATEGORY_NAME_QUERY_PARAM, }))).to.equal(true); }); it('Test isBidRequestValid() with valid param(s): pid, nqName, subId', function () { expect(nanoBidAdapter.isBidRequestValid(getBidRequest({ - [DATA_PARTNER_PIXEL_ID]: DATA_PARTNER_PIXEL_ID_VALUE, + [SSP_PLACEMENT_ID]: DATA_PARTNER_PIXEL_ID_VALUE, [NQ_NAME]: NQ_NAME_QUERY_PARAM, [SUB_ID]: SUB_ID_VALUE, }))).to.equal(true); }); it('Test isBidRequestValid() with valid param(s): pid, category', function () { expect(nanoBidAdapter.isBidRequestValid(getBidRequest({ - [DATA_PARTNER_PIXEL_ID]: DATA_PARTNER_PIXEL_ID_VALUE, + [SSP_PLACEMENT_ID]: DATA_PARTNER_PIXEL_ID_VALUE, [CATEGORY]: CATEGORY_VALUE, }))).to.equal(true); }); it('Test isBidRequestValid() with valid param(s): pid, category, subId', function () { expect(nanoBidAdapter.isBidRequestValid(getBidRequest({ - [DATA_PARTNER_PIXEL_ID]: DATA_PARTNER_PIXEL_ID_VALUE, + [SSP_PLACEMENT_ID]: DATA_PARTNER_PIXEL_ID_VALUE, [CATEGORY]: CATEGORY_VALUE, [SUB_ID]: SUB_ID_VALUE, }))).to.equal(true); }); it('Test isBidRequestValid() with valid param(s): pid, subId', function () { expect(nanoBidAdapter.isBidRequestValid(getBidRequest({ - [DATA_PARTNER_PIXEL_ID]: DATA_PARTNER_PIXEL_ID_VALUE, + [SSP_PLACEMENT_ID]: DATA_PARTNER_PIXEL_ID_VALUE, [SUB_ID]: SUB_ID_VALUE, }))).to.equal(true); }); it('Test isBidRequestValid() with valid param(s): pid, nq, category, subId', function () { expect(nanoBidAdapter.isBidRequestValid(getBidRequest({ - [DATA_PARTNER_PIXEL_ID]: DATA_PARTNER_PIXEL_ID_VALUE, + [SSP_PLACEMENT_ID]: DATA_PARTNER_PIXEL_ID_VALUE, [NQ]: NQ_VALUE, [CATEGORY]: CATEGORY_VALUE, [SUB_ID]: SUB_ID_VALUE, @@ -156,7 +140,7 @@ describe('nanointeractive adapter tests', function () { }); it('Test isBidRequestValid() with valid param(s): pid, nqName, categoryName, subId', function () { expect(nanoBidAdapter.isBidRequestValid(getBidRequest({ - [DATA_PARTNER_PIXEL_ID]: DATA_PARTNER_PIXEL_ID_VALUE, + [SSP_PLACEMENT_ID]: DATA_PARTNER_PIXEL_ID_VALUE, [NQ_NAME]: NQ_NAME_QUERY_PARAM, [CATEGORY_NAME]: CATEGORY_NAME_QUERY_PARAM, [SUB_ID]: SUB_ID_VALUE, @@ -164,7 +148,7 @@ describe('nanointeractive adapter tests', function () { }); it('Test isBidRequestValid() with valid param(s): pid, nq, category, subId, ref (value none)', function () { expect(nanoBidAdapter.isBidRequestValid(getBidRequest({ - [DATA_PARTNER_PIXEL_ID]: DATA_PARTNER_PIXEL_ID_VALUE, + [SSP_PLACEMENT_ID]: DATA_PARTNER_PIXEL_ID_VALUE, [NQ]: NQ_VALUE, [CATEGORY]: CATEGORY_VALUE, [SUB_ID]: SUB_ID_VALUE, @@ -173,7 +157,7 @@ describe('nanointeractive adapter tests', function () { }); it('Test isBidRequestValid() with valid param(s): pid, nq, category, subId, ref (value other)', function () { expect(nanoBidAdapter.isBidRequestValid(getBidRequest({ - [DATA_PARTNER_PIXEL_ID]: DATA_PARTNER_PIXEL_ID_VALUE, + [SSP_PLACEMENT_ID]: DATA_PARTNER_PIXEL_ID_VALUE, [NQ]: NQ_VALUE, [CATEGORY]: CATEGORY_VALUE, [SUB_ID]: SUB_ID_VALUE, @@ -193,30 +177,22 @@ describe('nanointeractive adapter tests', function () { let sandbox; - function getMocks () { - let mockWindowLocationAddress = 'http://some-location.test'; + function getMocks() { let mockOriginAddress = 'http://localhost'; let mockRefAddress = 'http://some-ref.test'; return { - 'windowLocationAddress': mockWindowLocationAddress, + 'windowLocationAddress': mockRefAddress, 'originAddress': mockOriginAddress, - 'refAddress': mockRefAddress, + 'refAddress': '', }; } - function setUpMocks (mockRefAddress = null) { + function setUpMocks() { + sinon.sandbox.restore(); sandbox = sinon.sandbox.create(); sandbox.stub(utils, 'getOrigin').callsFake(() => getMocks()['originAddress']); - sandbox.stub(utils, 'getTopWindowLocation').callsFake(() => { - return { - 'href': getMocks()['windowLocationAddress'] - }; - }); - if (mockRefAddress == null) { - sandbox.stub(utils, 'getTopWindowReferrer').callsFake(() => getMocks()['refAddress']); - } else { - sandbox.stub(utils, 'getTopWindowReferrer').callsFake(() => mockRefAddress); - } + sandbox.stub(utils, 'deepAccess').callsFake(() => getMocks()['windowLocationAddress']); + sandbox.stub(utils, 'getParameterByName').callsFake((arg) => { switch (arg) { case CATEGORY_NAME_QUERY_PARAM: @@ -227,39 +203,31 @@ describe('nanointeractive adapter tests', function () { }); } - function assert ( + function assert( request, expectedPid, expectedNq, expectedCategory, - expectedSubId, - expectedRef = getMocks()['refAddress'], - expectedOrigin = getMocks()['originAddress'], - expectedLocation = getMocks()['windowLocationAddress'] + expectedSubId ) { + const requestData = JSON.parse(request.data); + expect(request.method).to.equal('POST'); - expect(request.url).to.equal(ENGINE_BASE_URL); - expect(request.data).to.equal(JSON.stringify([ - getBidResponse( - expectedPid, - expectedNq, - expectedCategory, - expectedSubId, - expectedOrigin, - expectedRef, - expectedLocation, - ), - ])); + expect(request.url).to.equal(END_POINT_URL + '/hb'); + expect(requestData[0].pid).to.equal(expectedPid); + expect(requestData[0].nq.toString()).to.equal(expectedNq.toString()); + expect(requestData[0].category.toString()).to.equal(expectedCategory.toString()); + expect(requestData[0].subId).to.equal(expectedSubId); } - function tearDownMocks () { + function tearDownMocks() { sandbox.restore(); } it('Test buildRequest() - pid', function () { setUpMocks(); let requestParams = { - [DATA_PARTNER_PIXEL_ID]: DATA_PARTNER_PIXEL_ID_VALUE, + [SSP_PLACEMENT_ID]: DATA_PARTNER_PIXEL_ID_VALUE, }; let expectedPid = DATA_PARTNER_PIXEL_ID_VALUE; let expectedNq = [null]; @@ -274,7 +242,7 @@ describe('nanointeractive adapter tests', function () { it('Test buildRequest() - pid, nq', function () { setUpMocks(); let requestParams = { - [DATA_PARTNER_PIXEL_ID]: DATA_PARTNER_PIXEL_ID_VALUE, + [SSP_PLACEMENT_ID]: DATA_PARTNER_PIXEL_ID_VALUE, [NQ]: NQ_VALUE, }; let expectedPid = DATA_PARTNER_PIXEL_ID_VALUE; @@ -290,7 +258,7 @@ describe('nanointeractive adapter tests', function () { it('Test buildRequest() - pid, nq, category', function () { setUpMocks(); let requestParams = { - [DATA_PARTNER_PIXEL_ID]: DATA_PARTNER_PIXEL_ID_VALUE, + [SSP_PLACEMENT_ID]: DATA_PARTNER_PIXEL_ID_VALUE, [NQ]: NQ_VALUE, [CATEGORY]: CATEGORY_VALUE, }; @@ -308,7 +276,7 @@ describe('nanointeractive adapter tests', function () { setUpMocks(); let requestParams = { - [DATA_PARTNER_PIXEL_ID]: DATA_PARTNER_PIXEL_ID_VALUE, + [SSP_PLACEMENT_ID]: DATA_PARTNER_PIXEL_ID_VALUE, [NQ]: NQ_VALUE, [CATEGORY_NAME]: CATEGORY_NAME_QUERY_PARAM, }; @@ -325,7 +293,7 @@ describe('nanointeractive adapter tests', function () { it('Test buildRequest() - pid, nq, subId', function () { setUpMocks(); let requestParams = { - [DATA_PARTNER_PIXEL_ID]: DATA_PARTNER_PIXEL_ID_VALUE, + [SSP_PLACEMENT_ID]: DATA_PARTNER_PIXEL_ID_VALUE, [NQ]: NQ_VALUE, [SUB_ID]: SUB_ID_VALUE, }; @@ -342,7 +310,7 @@ describe('nanointeractive adapter tests', function () { it('Test buildRequest() - pid, category', function () { setUpMocks(); let requestParams = { - [DATA_PARTNER_PIXEL_ID]: DATA_PARTNER_PIXEL_ID_VALUE, + [SSP_PLACEMENT_ID]: DATA_PARTNER_PIXEL_ID_VALUE, [CATEGORY]: CATEGORY_VALUE, }; let expectedPid = DATA_PARTNER_PIXEL_ID_VALUE; @@ -358,7 +326,7 @@ describe('nanointeractive adapter tests', function () { it('Test buildRequest() - pid, category, subId', function () { setUpMocks(); let requestParams = { - [DATA_PARTNER_PIXEL_ID]: DATA_PARTNER_PIXEL_ID_VALUE, + [SSP_PLACEMENT_ID]: DATA_PARTNER_PIXEL_ID_VALUE, [CATEGORY]: CATEGORY_VALUE, [SUB_ID]: SUB_ID_VALUE, }; @@ -375,7 +343,7 @@ describe('nanointeractive adapter tests', function () { it('Test buildRequest() - pid, subId', function () { setUpMocks(); let requestParams = { - [DATA_PARTNER_PIXEL_ID]: DATA_PARTNER_PIXEL_ID_VALUE, + [SSP_PLACEMENT_ID]: DATA_PARTNER_PIXEL_ID_VALUE, [SUB_ID]: SUB_ID_VALUE, }; let expectedPid = DATA_PARTNER_PIXEL_ID_VALUE; @@ -391,7 +359,7 @@ describe('nanointeractive adapter tests', function () { it('Test buildRequest() - pid, nq, category, subId', function () { setUpMocks(); let requestParams = { - [DATA_PARTNER_PIXEL_ID]: DATA_PARTNER_PIXEL_ID_VALUE, + [SSP_PLACEMENT_ID]: DATA_PARTNER_PIXEL_ID_VALUE, [NQ]: NQ_VALUE, [CATEGORY]: CATEGORY_VALUE, [SUB_ID]: SUB_ID_VALUE, @@ -409,7 +377,7 @@ describe('nanointeractive adapter tests', function () { it('Test buildRequest() - pid, nqName, categoryName, subId', function () { setUpMocks(); let requestParams = { - [DATA_PARTNER_PIXEL_ID]: DATA_PARTNER_PIXEL_ID_VALUE, + [SSP_PLACEMENT_ID]: DATA_PARTNER_PIXEL_ID_VALUE, [NQ_NAME]: NQ_NAME_QUERY_PARAM, [CATEGORY_NAME]: CATEGORY_NAME_QUERY_PARAM, [SUB_ID]: SUB_ID_VALUE, @@ -424,44 +392,6 @@ describe('nanointeractive adapter tests', function () { assert(request, expectedPid, expectedNq, expectedCategory, expectedSubId); tearDownMocks(); }); - it('Test buildRequest() - pid, nq, category, subId, ref (value none)', function () { - setUpMocks(null); - let requestParams = { - [DATA_PARTNER_PIXEL_ID]: DATA_PARTNER_PIXEL_ID_VALUE, - [NQ]: NQ_VALUE, - [CATEGORY]: CATEGORY_VALUE, - [SUB_ID]: SUB_ID_VALUE, - [REF]: REF_NO_VALUE, - }; - let expectedPid = DATA_PARTNER_PIXEL_ID_VALUE; - let expectedNq = [NQ_VALUE]; - let expectedCategory = [CATEGORY_VALUE]; - let expectedSubId = SUB_ID_VALUE; - - let request = nanoBidAdapter.buildRequests([getBidRequest(requestParams)]); - - assert(request, expectedPid, expectedNq, expectedCategory, expectedSubId, null); - tearDownMocks(); - }); - it('Test buildRequest() - pid, nq, category, subId, ref (value other)', function () { - setUpMocks(null); - let requestParams = { - [DATA_PARTNER_PIXEL_ID]: DATA_PARTNER_PIXEL_ID_VALUE, - [NQ]: NQ_VALUE, - [CATEGORY]: CATEGORY_VALUE, - [SUB_ID]: SUB_ID_VALUE, - [REF]: REF_OTHER_VALUE, - }; - let expectedPid = DATA_PARTNER_PIXEL_ID_VALUE; - let expectedNq = [NQ_VALUE]; - let expectedCategory = [CATEGORY_VALUE]; - let expectedSubId = SUB_ID_VALUE; - - let request = nanoBidAdapter.buildRequests([getBidRequest(requestParams)]); - - assert(request, expectedPid, expectedNq, expectedCategory, expectedSubId, null); - tearDownMocks(); - }); it('Test interpretResponse() length', function () { let bids = nanoBidAdapter.interpretResponse({ body: [ diff --git a/test/spec/modules/nextMilleniumBidAdapter_spec.js b/test/spec/modules/nextMillenniumBidAdapter_spec.js similarity index 91% rename from test/spec/modules/nextMilleniumBidAdapter_spec.js rename to test/spec/modules/nextMillenniumBidAdapter_spec.js index 74c8ff5dfd9..087f06d7e8e 100644 --- a/test/spec/modules/nextMilleniumBidAdapter_spec.js +++ b/test/spec/modules/nextMillenniumBidAdapter_spec.js @@ -1,12 +1,12 @@ import { expect } from 'chai'; -import { spec } from 'modules/nextMilleniumBidAdapter'; +import { spec } from 'modules/nextMillenniumBidAdapter'; -describe('nextMilleniumBidAdapterTests', function() { +describe('nextMillenniumBidAdapterTests', function() { let bidRequestData = { bids: [ { bidId: 'transaction_1234', - bidder: 'nextMillenium', + bidder: 'nextMillennium', params: { placement_id: 12345 }, @@ -19,7 +19,7 @@ describe('nextMilleniumBidAdapterTests', function() { it('validate_pub_params', function() { expect( spec.isBidRequestValid({ - bidder: 'nextMillenium', + bidder: 'nextMillennium', params: { placement_id: 12345 } @@ -31,7 +31,7 @@ describe('nextMilleniumBidAdapterTests', function() { let bidRequestData = [ { bidId: 'bid1234', - bidder: 'nextMillenium', + bidder: 'nextMillennium', params: { placement_id: -1 }, sizes: [[300, 250]] } diff --git a/test/spec/modules/nobidBidAdapter_spec.js b/test/spec/modules/nobidBidAdapter_spec.js new file mode 100644 index 00000000000..5134958d218 --- /dev/null +++ b/test/spec/modules/nobidBidAdapter_spec.js @@ -0,0 +1,256 @@ +import { expect } from 'chai'; +import { spec } from 'modules/nobidBidAdapter'; +import { newBidder } from 'src/adapters/bidderFactory'; +import { deepClone } from 'src/utils'; + +describe('Nobid Adapter', function () { + const adapter = newBidder(spec); + + describe('inherited functions', function () { + it('exists and is a function', function () { + expect(adapter.callBids).to.exist.and.to.be.a('function'); + }); + }); + + describe('isBidRequestValid', function () { + let bid = { + 'bidder': 'nobid', + 'params': { + 'siteId': 2 + }, + 'adUnitCode': 'adunit-code', + 'sizes': [[300, 250]], + 'bidId': '30b31c1838de1e', + 'bidderRequestId': '22edbae2733bf6', + 'auctionId': '1d1a030790a475', + }; + + it('should return true when required params found', function () { + expect(spec.isBidRequestValid(bid)).to.equal(true); + }); + + it('should return true when required params found', function () { + let bid = Object.assign({}, bid); + delete bid.params; + bid.params = { + 'siteId': 2 + }; + + expect(spec.isBidRequestValid(bid)).to.equal(true); + }); + + it('should return false when required params are not passed', function () { + let bid = Object.assign({}, bid); + delete bid.params; + bid.params = { + 'siteId': 0 + }; + expect(spec.isBidRequestValid(bid)).to.equal(false); + }); + }); + + describe('buildRequests', function () { + const SITE_ID = 2; + const REFERER = 'https://www.examplereferer.com'; + let bidRequests = [ + { + 'bidder': 'nobid', + 'params': { + 'siteId': SITE_ID + }, + 'adUnitCode': 'adunit-code', + 'sizes': [[300, 250]], + 'bidId': '30b31c1838de1e', + 'bidderRequestId': '22edbae2733bf6', + 'auctionId': '1d1a030790a475', + } + ]; + + let bidderRequest = { + refererInfo: {referer: REFERER} + } + + it('should add source and verison to the tag', function () { + const request = spec.buildRequests(bidRequests, bidderRequest); + const payload = JSON.parse(request.data); + expect(payload.sid).to.equal(SITE_ID); + expect(payload.l).to.exist.and.to.equal(encodeURIComponent(REFERER)); + expect(payload.tt).to.exist; + expect(payload.a).to.exist; + expect(payload.t).to.exist; + expect(payload.tz).to.exist; + expect(payload.r).to.exist; + expect(payload.lang).to.exist; + expect(payload.ref).to.exist; + expect(payload.gdpr).to.exist; + }); + + it('sends bid request to ENDPOINT via POST', function () { + const request = spec.buildRequests(bidRequests); + expect(request.url).to.contain('ads.servenobid.com/adreq'); + expect(request.method).to.equal('POST'); + }); + + it('should add gdpr consent information to the request', function () { + let consentString = 'BOJ8RZsOJ8RZsABAB8AAAAAZ+A=='; + let bidderRequest = { + 'bidderCode': 'nobid', + 'auctionId': '1d1a030790a475', + 'bidderRequestId': '22edbae2733bf6', + 'timeout': 3000, + 'gdprConsent': { + consentString: consentString, + gdprApplies: true + } + }; + bidderRequest.bids = bidRequests; + + const request = spec.buildRequests(bidRequests, bidderRequest); + const payload = JSON.parse(request.data); + + expect(payload.gdpr).to.exist; + expect(payload.gdpr.consentString).to.exist.and.to.equal(consentString); + expect(payload.gdpr.consentRequired).to.exist.and.to.be.true; + }); + }); + + describe('interpretResponse', function () { + const CREATIVE_ID_300x250 = 'CREATIVE-100'; + const ADUNIT_300x250 = 'ADUNIT-1'; + const ADMARKUP_300x250 = 'ADMARKUP-300x250'; + const PRICE_300x250 = 0.51; + const REQUEST_ID = '3db3773286ee59'; + const DEAL_ID = 'deal123'; + let response = { + country: 'US', + ip: '68.83.15.75', + device: 'COMPUTER', + site: 2, + bids: [ + {id: 1, + bdrid: 101, + divid: ADUNIT_300x250, + dealid: DEAL_ID, + creativeid: CREATIVE_ID_300x250, + size: {'w': 300, 'h': 250}, + adm: ADMARKUP_300x250, + price: '' + PRICE_300x250 + } + ] + }; + + it('should get correct bid response', function () { + let expectedResponse = [ + { + requestId: REQUEST_ID, + cpm: PRICE_300x250, + width: 300, + height: 250, + creativeId: CREATIVE_ID_300x250, + dealId: DEAL_ID, + currency: 'USD', + netRevenue: true, + ttl: 300, + ad: ADMARKUP_300x250, + mediaType: 'banner' + } + ]; + + let bidderRequest = { + bids: [{ + bidId: REQUEST_ID, + adUnitCode: ADUNIT_300x250 + }] + } + let result = spec.interpretResponse({ body: response }, {bidderRequest: bidderRequest}); + expect(result.length).to.equal(expectedResponse.length); + expect(Object.keys(result[0])).to.have.members(Object.keys(expectedResponse[0])); + expect(result[0].requestId).to.equal(expectedResponse[0].requestId); + expect(result[0].cpm).to.equal(expectedResponse[0].cpm); + }); + + it('should get correct empty response', function () { + let bidderRequest = { + bids: [{ + bidId: REQUEST_ID, + adUnitCode: ADUNIT_300x250 + '1' + }] + } + let result = spec.interpretResponse({ body: response }, {bidderRequest: bidderRequest}); + expect(result.length).to.equal(0); + }); + + it('should get correct deal id', function () { + let expectedResponse = [ + { + requestId: REQUEST_ID, + cpm: PRICE_300x250, + width: 300, + height: 250, + creativeId: CREATIVE_ID_300x250, + dealId: DEAL_ID, + currency: 'USD', + netRevenue: true, + ttl: 300, + ad: ADMARKUP_300x250, + mediaType: 'banner' + } + ]; + + let bidderRequest = { + bids: [{ + bidId: REQUEST_ID, + adUnitCode: ADUNIT_300x250 + }] + } + let result = spec.interpretResponse({ body: response }, {bidderRequest: bidderRequest}); + expect(result.length).to.equal(expectedResponse.length); + expect(result[0].dealId).to.equal(expectedResponse[0].dealId); + }); + }); + + describe('getUserSyncs', function () { + const GDPR_CONSENT_STRING = 'GDPR_CONSENT_STRING'; + it('should get correct user sync when iframeEnabled', function () { + let pixel = spec.getUserSyncs({iframeEnabled: true}) + expect(pixel[0].type).to.equal('iframe'); + expect(pixel[0].url).to.equal('https://s3.amazonaws.com/nobid-public/sync.html'); + }); + + it('should get correct user sync when iframeEnabled and pixelEnabled', function () { + let pixel = spec.getUserSyncs({iframeEnabled: true, pixelEnabled: true}) + expect(pixel[0].type).to.equal('iframe'); + expect(pixel[0].url).to.equal('https://s3.amazonaws.com/nobid-public/sync.html'); + }); + + it('should get correct user sync when iframeEnabled', function () { + let pixel = spec.getUserSyncs({iframeEnabled: true}, {}, {gdprApplies: true, consentString: GDPR_CONSENT_STRING}) + expect(pixel[0].type).to.equal('iframe'); + expect(pixel[0].url).to.equal('https://s3.amazonaws.com/nobid-public/sync.html?gdpr=1&gdpr_consent=' + GDPR_CONSENT_STRING); + }); + + it('should get correct user sync when !iframeEnabled', function () { + let pixel = spec.getUserSyncs({iframeEnabled: false}) + expect(pixel.length).to.equal(0); + }); + + it('should get correct user sync when !iframeEnabled', function () { + let pixel = spec.getUserSyncs({}) + expect(pixel.length).to.equal(0); + }); + }); + + describe('onTimeout', function (syncOptions) { + it('should increment timeoutTotal', function () { + let timeoutTotal = spec.onTimeout() + expect(timeoutTotal).to.equal(1); + }); + }); + + describe('onBidWon', function (syncOptions) { + it('should increment bidWonTotal', function () { + let bidWonTotal = spec.onBidWon() + expect(bidWonTotal).to.equal(1); + }); + }); +}); diff --git a/test/spec/modules/oneVideoBidAdapter_spec.js b/test/spec/modules/oneVideoBidAdapter_spec.js index 331a52c1ea0..58b90b0a017 100644 --- a/test/spec/modules/oneVideoBidAdapter_spec.js +++ b/test/spec/modules/oneVideoBidAdapter_spec.js @@ -10,9 +10,16 @@ describe('OneVideoBidAdapter', function () { beforeEach(function () { bidRequest = { + mediaTypes: { + video: { + context: 'instream', + playerSize: [640, 480] + } + }, bidder: 'oneVideo', sizes: [640, 480], bidId: '30b3efwfwe1e', + adUnitCode: 'video1', params: { video: { playerWidth: 640, @@ -23,7 +30,9 @@ describe('OneVideoBidAdapter', function () { position: 1, delivery: [2], playbackmethod: [1, 5], - placement: 123 + placement: 123, + sid: 134, + rewarded: 1 }, site: { id: 1, @@ -58,7 +67,9 @@ describe('OneVideoBidAdapter', function () { position: 1, delivery: [2], playbackmethod: [1, 5], - placement: 123 + placement: 123, + sid: 134, + rewarded: 1 } }; expect(spec.isBidRequestValid(bidRequest)).to.equal(false); @@ -74,7 +85,9 @@ describe('OneVideoBidAdapter', function () { position: 1, delivery: [2], playbackmethod: [1, 5], - placement: 123 + placement: 123, + sid: 134, + rewarded: 1 }, pubId: 'brxd' }; @@ -104,10 +117,12 @@ describe('OneVideoBidAdapter', function () { const data = requests[0].data; const [ width, height ] = bidRequest.sizes; const placement = bidRequest.params.video.placement; + const rewarded = bidRequest.params.video.rewarded; expect(data.imp[0].video.w).to.equal(width); expect(data.imp[0].video.h).to.equal(height); expect(data.imp[0].ext.placement).to.equal(placement); expect(data.imp[0].bidfloor).to.equal(bidRequest.params.bidfloor); + expect(data.imp[0].ext.rewarded).to.equal(rewarded); }); it('must parse bid size from a nested array', function () { @@ -140,20 +155,23 @@ describe('OneVideoBidAdapter', function () { }); it('should return a valid bid response with just "adm"', function () { - const serverResponse = {seatbid: [{bid: [{id: 1, price: 6.01, adm: ''}]}], cur: 'USD'}; + const serverResponse = {seatbid: [{bid: [{id: 1, adid: 123, crid: 2, price: 6.01, adm: ''}]}], cur: 'USD'}; const bidResponse = spec.interpretResponse({ body: serverResponse }, { bidRequest }); let o = { requestId: bidRequest.bidId, bidderCode: spec.code, cpm: serverResponse.seatbid[0].bid[0].price, - creativeId: serverResponse.seatbid[0].bid[0].id, + adId: serverResponse.seatbid[0].bid[0].adid, + creativeId: serverResponse.seatbid[0].bid[0].crid, vastXml: serverResponse.seatbid[0].bid[0].adm, width: 640, height: 480, mediaType: 'video', currency: 'USD', ttl: 100, - netRevenue: true + netRevenue: true, + adUnitCode: bidRequest.adUnitCode, + renderer: (bidRequest.mediaTypes.video.context === 'outstream') ? newRenderer(bidRequest, bidResponse) : undefined, }; expect(bidResponse).to.deep.equal(o); }); @@ -186,5 +204,12 @@ describe('OneVideoBidAdapter', function () { const request = spec.buildRequests([ bidRequest ], bidderRequest); expect(request[0].data.user.ext.consent).to.equal(bidderRequest.gdprConsent.consentString); }); + + it('should send schain object', function () { + const requests = spec.buildRequests([ bidRequest ]); + const data = requests[0].data; + expect(data.source.ext.schain.nodes[0].sid).to.equal(bidRequest.params.video.sid); + expect(data.source.ext.schain.nodes[0].rid).to.equal(data.id); + }); }); }); diff --git a/test/spec/modules/openxBidAdapter_spec.js b/test/spec/modules/openxBidAdapter_spec.js index 468d9cc33a7..7476d06cf9a 100644 --- a/test/spec/modules/openxBidAdapter_spec.js +++ b/test/spec/modules/openxBidAdapter_spec.js @@ -178,6 +178,41 @@ describe('OpenxAdapter', function () { }); }); + describe('when request is for a multiformat ad', function () { + describe('and request config uses mediaTypes video and banner', () => { + const multiformatBid = { + bidder: 'openx', + params: { + unit: '12345678', + delDomain: 'test-del-domain' + }, + adUnitCode: 'adunit-code', + mediaTypes: { + banner: { + sizes: [[300, 250]] + }, + video: { + playerSize: [300, 250] + } + }, + bidId: '30b31c1838de1e', + bidderRequestId: '22edbae2733bf6', + auctionId: '1d1a030790a475', + transactionId: '4008d88a-8137-410b-aa35-fbfdabcb478e' + }; + it('should return true multisize when required params found', function () { + expect(spec.isBidRequestValid(multiformatBid)).to.equal(true); + }); + + it('should send bid request to openx url via GET, with mediaType specified as banner', function () { + const request = spec.buildRequests([multiformatBid]); + expect(request[0].url).to.equal(`//${multiformatBid.params.delDomain}${URLBASE}`); + expect(request[0].data.ph).to.be.undefined; + expect(request[0].method).to.equal('GET'); + }); + }); + }); + describe('when request is for a video ad', function () { describe('and request config uses mediaTypes', () => { const videoBidWithMediaTypes = { @@ -359,39 +394,6 @@ describe('OpenxAdapter', function () { 'bidderRequestId': 'test-bid-request-1', 'auctionId': 'test-auction-1' }]; - const bidRequestsWithPlatformAndDelDomain = [{ - 'bidder': 'openx', - 'params': { - 'unit': '11', - 'delDomain': 'test-del-domain', - 'platform': '1cabba9e-cafe-3665-beef-f00f00f00f00', - }, - 'adUnitCode': '/adunit-code/test-path', - mediaTypes: { - banner: { - sizes: [[300, 250], [300, 600]] - } - }, - 'bidId': 'test-bid-id-1', - 'bidderRequestId': 'test-bid-request-1', - 'auctionId': 'test-auction-1' - }, { - 'bidder': 'openx', - 'params': { - 'unit': '11', - 'delDomain': 'test-del-domain', - 'platform': '1cabba9e-cafe-3665-beef-f00f00f00f00', - }, - 'adUnitCode': '/adunit-code/test-path', - mediaTypes: { - banner: { - sizes: [[300, 250], [300, 600]] - } - }, - 'bidId': 'test-bid-id-1', - 'bidderRequestId': 'test-bid-request-1', - 'auctionId': 'test-auction-1' - }]; it('should send bid request to openx url via GET, with mediaType specified as banner', function () { const request = spec.buildRequests(bidRequestsWithMediaType); @@ -415,6 +417,40 @@ describe('OpenxAdapter', function () { }); it('should send bid request to openx platform url via GET, if both params present', function () { + const bidRequestsWithPlatformAndDelDomain = [{ + 'bidder': 'openx', + 'params': { + 'unit': '11', + 'delDomain': 'test-del-domain', + 'platform': '1cabba9e-cafe-3665-beef-f00f00f00f00', + }, + 'adUnitCode': '/adunit-code/test-path', + mediaTypes: { + banner: { + sizes: [[300, 250], [300, 600]] + } + }, + 'bidId': 'test-bid-id-1', + 'bidderRequestId': 'test-bid-request-1', + 'auctionId': 'test-auction-1' + }, { + 'bidder': 'openx', + 'params': { + 'unit': '11', + 'delDomain': 'test-del-domain', + 'platform': '1cabba9e-cafe-3665-beef-f00f00f00f00', + }, + 'adUnitCode': '/adunit-code/test-path', + mediaTypes: { + banner: { + sizes: [[300, 250], [300, 600]] + } + }, + 'bidId': 'test-bid-id-1', + 'bidderRequestId': 'test-bid-request-1', + 'auctionId': 'test-auction-1' + }]; + const request = spec.buildRequests(bidRequestsWithPlatformAndDelDomain); expect(request[0].url).to.equal(`//u.openx.net${URLBASE}`); expect(request[0].data.ph).to.equal(bidRequestsWithPlatform[0].params.platform); @@ -940,7 +976,139 @@ describe('OpenxAdapter', function () { const request = spec.buildRequests(bidRequestsWithPubcid); expect(request[0].data.pubcid).to.equal('c4a4c843-2368-4b5e-b3b1-6ee4702b9ad6'); }); + + it('should send a pubcid query param when userId.pubcid is defined in the bid requests', function () { + const bidRequestsWithPubcid = [{ + bidder: 'openx', + params: { + unit: '11', + delDomain: 'test-del-domain' + }, + userId: { + pubcid: 'c1a4c843-2368-4b5e-b3b1-6ee4702b9ad6' + }, + adUnitCode: 'adunit-code', + mediaTypes: { + banner: { + sizes: [[300, 250], [300, 600]] + } + }, + bidId: 'test-bid-id-1', + bidderRequestId: 'test-bid-request-1', + auctionId: 'test-auction-1' + }]; + const request = spec.buildRequests(bidRequestsWithPubcid); + expect(request[0].data.pubcid).to.equal('c1a4c843-2368-4b5e-b3b1-6ee4702b9ad6'); + }); }) + + describe('when schain is provided', function () { + let bidRequests; + let schainConfig; + const supplyChainNodePropertyOrder = ['asi', 'sid', 'hp', 'rid', 'name', 'domain']; + + beforeEach(function () { + schainConfig = { + 'ver': '1.0', + 'complete': 1, + 'nodes': [ + { + 'asi': 'exchange1.com', + 'sid': '1234', + 'hp': 1, + 'rid': 'bid-request-1', + 'name': 'publisher', + 'domain': 'publisher.com' + // omitted ext + }, + { + 'asi': 'exchange2.com', + 'sid': 'abcd', + 'hp': 1, + 'rid': 'bid-request-2', + // name field missing + 'domain': 'intermediary.com' + }, + { + 'asi': 'exchange3.com', + 'sid': '4321', + 'hp': 1, + // request id + // name field missing + 'domain': 'intermediary-2.com' + } + ] + }; + + bidRequests = [{ + 'bidder': 'openx', + 'params': { + 'unit': '11', + 'delDomain': 'test-del-domain' + }, + 'adUnitCode': '/adunit-code/test-path', + mediaTypes: { + banner: { + sizes: [[300, 250], [300, 600]] + } + }, + 'bidId': 'test-bid-id-1', + 'bidderRequestId': 'test-bid-request-1', + 'auctionId': 'test-auction-1', + 'schain': schainConfig + }]; + }); + + it('should send a schain parameter with the proper delimiter symbols', function () { + const request = spec.buildRequests(bidRequests); + const dataParams = request[0].data; + const numNodes = schainConfig.nodes.length; + + // each node will have a ! to denote beginning of a new node + expect(dataParams.schain.match(/!/g).length).to.equal(numNodes); + + // 1 comma in the front for version + // 5 commas per node + expect(dataParams.schain.match(/,/g).length).to.equal(numNodes * 5 + 1); + }); + + it('should send a schain with the right version', function () { + const request = spec.buildRequests(bidRequests); + const dataParams = request[0].data; + let serializedSupplyChain = dataParams.schain.split('!'); + let version = serializedSupplyChain.shift().split(',')[0]; + + expect(version).to.equal(bidRequests[0].schain.ver); + }); + + it('should send a schain with the right complete value', function () { + const request = spec.buildRequests(bidRequests); + const dataParams = request[0].data; + let serializedSupplyChain = dataParams.schain.split('!'); + let isComplete = serializedSupplyChain.shift().split(',')[1]; + + expect(isComplete).to.equal(String(bidRequests[0].schain.complete)); + }); + + it('should send all available params in the right order', function () { + const request = spec.buildRequests(bidRequests); + const dataParams = request[0].data; + let serializedSupplyChain = dataParams.schain.split('!'); + serializedSupplyChain.shift(); + + serializedSupplyChain.forEach((serializedNode, nodeIndex) => { + let nodeProperties = serializedNode.split(','); + + nodeProperties.forEach((nodeProperty, propertyIndex) => { + let node = schainConfig.nodes[nodeIndex]; + let key = supplyChainNodePropertyOrder[propertyIndex]; + + expect(nodeProperty).to.equal(node[key] ? String(node[key]) : '', + `expected node '${nodeIndex}' property '${nodeProperty}' to key '${key}' to be the same value`) + }); + }); + }); + }); }); describe('buildRequests for video', function () { @@ -1194,6 +1362,10 @@ describe('OpenxAdapter', function () { expect(bid.meta.brandId).to.equal(DEFAULT_TEST_ARJ_AD_UNIT.brand_id); }); + it('should return a brand ID', function () { + expect(bid.meta.dspid).to.equal(DEFAULT_TEST_ARJ_AD_UNIT.adv_id); + }); + it('should register a beacon', function () { resetBoPixel(); spec.interpretResponse({body: bidResponse}, bidRequest); diff --git a/test/spec/modules/optimeraBidAdapter_spec.js b/test/spec/modules/optimeraBidAdapter_spec.js index d164c4dbb30..a0111ca9944 100644 --- a/test/spec/modules/optimeraBidAdapter_spec.js +++ b/test/spec/modules/optimeraBidAdapter_spec.js @@ -52,7 +52,7 @@ describe('OptimeraAdapter', function () { describe('interpretResponse', function () { let serverResponse = {}; - serverResponse.body = JSON.parse('{"div-0":["RB_K","728x90K"], "timestamp":["RB_K","1507565666"]}'); + serverResponse.body = JSON.parse('{"div-0":["RB_K","728x90K"], "timestamp":["RB_K","1507565666"], "device": { "de": { "div-0":["A1","728x90K"] }, "mo": { "div-0":["RB_K","728x90K"] }, "tb": { "div-0":["RB_K","728x90K"] } } }'); var bidRequest = { 'method': 'get', 'payload': [ @@ -72,4 +72,28 @@ describe('OptimeraAdapter', function () { expect(bidResponses[0].dealId[1]).to.equal('728x90K'); }); }); + + describe('interpretResponse with optional device param', function () { + let serverResponse = {}; + serverResponse.body = JSON.parse('{"div-0":["RB_K","728x90K"], "timestamp":["RB_K","1507565666"], "device": { "de": { "div-0":["A1","728x90K"] }, "mo": { "div-0":["RB_K","728x90K"] }, "tb": { "div-0":["RB_K","728x90K"] } } }'); + var bidRequest = { + 'method': 'get', + 'payload': [ + { + 'bidder': 'optimera', + 'params': { + 'clientID': '0', + 'device': 'de' + }, + 'adUnitCode': 'div-0', + 'bidId': '307440db8538ab' + } + ] + } + it('interpresResponse fires', function () { + let bidResponses = spec.interpretResponse(serverResponse, bidRequest); + expect(bidResponses[0].dealId[0]).to.equal('A1'); + expect(bidResponses[0].dealId[1]).to.equal('728x90K'); + }); + }); }); diff --git a/test/spec/modules/orbidderBidAdapter_spec.js b/test/spec/modules/orbidderBidAdapter_spec.js index 0761ed8d31e..aeaa5f30446 100644 --- a/test/spec/modules/orbidderBidAdapter_spec.js +++ b/test/spec/modules/orbidderBidAdapter_spec.js @@ -1,6 +1,8 @@ import {expect} from 'chai'; import {spec} from 'modules/orbidderBidAdapter'; import {newBidder} from 'src/adapters/bidderFactory'; +import openxAdapter from '../../../modules/openxAnalyticsAdapter'; +import {detectReferer} from 'src/refererDetection'; describe('orbidderBidAdapter', () => { const adapter = newBidder(spec); @@ -20,14 +22,17 @@ describe('orbidderBidAdapter', () => { return JSON.parse(JSON.stringify(val)); }; - const buildRequest = function (buildRequest) { - return spec.buildRequests( - [buildRequest], - { - refererInfo: { - referer: 'http://localhost:9876/' - } - })[0]; + const buildRequest = (buildRequest, bidderRequest) => { + if (!Array.isArray(buildRequest)) { + buildRequest = [buildRequest]; + } + + return spec.buildRequests(buildRequest, { + ...bidderRequest || {}, + refererInfo: { + referer: 'http://localhost:9876/' + } + })[0]; }; describe('inherited functions', () => { @@ -47,6 +52,12 @@ describe('orbidderBidAdapter', () => { expect(spec.isBidRequestValid(bidRequest)).to.equal(true); }); + it('accepts optional profile object', () => { + const bidRequest = deepClone(defaultBidRequest); + bidRequest.params.profile = {'key': 'value'}; + expect(spec.isBidRequestValid(bidRequest)).to.equal(true); + }); + it('performs type checking', () => { const bidRequest = deepClone(defaultBidRequest); bidRequest.params.accountId = 1; // supposed to be a string @@ -59,6 +70,12 @@ describe('orbidderBidAdapter', () => { expect(spec.isBidRequestValid(bidRequest)).to.equal(false); }); + it('doesn\'t accept malformed profile', () => { + const bidRequest = deepClone(defaultBidRequest); + bidRequest.params.profile = 'another not usable string'; + expect(spec.isBidRequestValid(bidRequest)).to.equal(false); + }); + it('should return false when required params are not passed', () => { const bidRequest = deepClone(defaultBidRequest); delete bidRequest.params; @@ -101,30 +118,28 @@ describe('orbidderBidAdapter', () => { }); it('handles empty gdpr object', () => { - const bidRequest = deepClone(defaultBidRequest); - bidRequest.gdprConsent = {}; - - const request = buildRequest(bidRequest); - expect(request.data.gdprConsent.consentRequired).to.be.equal(true); + const request = buildRequest(defaultBidRequest, { + gdprConsent: {} + }); + expect(request.data.gdprConsent.consentRequired).to.be.equal(false); }); it('handles non-existent gdpr object', () => { - const bidRequest = deepClone(defaultBidRequest); - bidRequest.gdprConsent = null; - - const request = buildRequest(bidRequest); + const request = buildRequest(defaultBidRequest, { + gdprConsent: null + }); expect(request.data.gdprConsent).to.be.undefined; }); it('handles properly filled gdpr object where gdpr applies', () => { const consentString = 'someWeirdString'; - const bidRequest = deepClone(defaultBidRequest); - bidRequest.gdprConsent = { - gdprApplies: true, - consentString: 'someWeirdString' - }; + const request = buildRequest(defaultBidRequest, { + gdprConsent: { + gdprApplies: true, + consentString: consentString + } + }); - const request = buildRequest(bidRequest); const gdprConsent = request.data.gdprConsent; expect(gdprConsent.consentRequired).to.be.equal(true); expect(gdprConsent.consentString).to.be.equal(consentString); @@ -132,28 +147,35 @@ describe('orbidderBidAdapter', () => { it('handles properly filled gdpr object where gdpr does not apply', () => { const consentString = 'someWeirdString'; - const bidRequest = deepClone(defaultBidRequest); - bidRequest.gdprConsent = { - gdprApplies: false, - consentString: 'someWeirdString' - }; + const request = buildRequest(defaultBidRequest, { + gdprConsent: { + gdprApplies: false, + consentString: consentString + } + }); - const request = buildRequest(bidRequest); const gdprConsent = request.data.gdprConsent; expect(gdprConsent.consentRequired).to.be.equal(false); expect(gdprConsent.consentString).to.be.equal(consentString); }); }); - describe('onBidWon', () => { + describe('onCallbackHandler', () => { let ajaxStub; - const winObj = { + const bidObj = { adId: 'testId', test: 1, pageUrl: 'www.someurl.de', - referrer: 'www.somereferrer.de' + referrer: 'www.somereferrer.de', + requestId: '123req456' }; + spec.bidParams['123req456'] = {'accountId': '123acc456'}; + + let bidObjClone = deepClone(bidObj); + bidObjClone.pageUrl = detectReferer(window)().referer; + bidObjClone.params = [{'accountId': '123acc456'}]; + beforeEach(() => { ajaxStub = sinon.stub(spec, 'ajaxCall'); }); @@ -162,12 +184,12 @@ describe('orbidderBidAdapter', () => { ajaxStub.restore(); }); - it('calls orbidder\'s win endpoint', () => { - spec.onBidWon(winObj); + it('calls orbidder\'s callback endpoint', () => { + spec.onBidWon(bidObj); expect(ajaxStub.calledOnce).to.equal(true); expect(ajaxStub.firstCall.args[0].indexOf('https://')).to.equal(0); expect(ajaxStub.firstCall.args[0]).to.equal(`${spec.orbidderHost}/win`); - expect(ajaxStub.firstCall.args[1]).to.equal(JSON.stringify(winObj)); + expect(ajaxStub.firstCall.args[1]).to.equal(JSON.stringify(bidObjClone)); }); }); diff --git a/test/spec/modules/ozoneBidAdapter_spec.js b/test/spec/modules/ozoneBidAdapter_spec.js index a910ef391b0..a0b51ff7a9f 100644 --- a/test/spec/modules/ozoneBidAdapter_spec.js +++ b/test/spec/modules/ozoneBidAdapter_spec.js @@ -1,6 +1,7 @@ import { expect } from 'chai'; -import { spec } from 'modules/ozoneBidAdapter'; +import { spec, getWidthAndHeightFromVideoObject, playerSizeIsNestedArray, defaultSize } from 'modules/ozoneBidAdapter'; import { config } from 'src/config'; +import {Renderer} from '../../../src/Renderer'; const OZONEURI = 'https://elb.the-ozone-project.com/openrtb2/auction'; const BIDDER_CODE = 'ozone'; /* @@ -17,7 +18,7 @@ var validBidRequests = [ bidder: 'ozone', bidderRequestId: '1c1586b27a1b5c8', crumbs: {pubcid: '203a0692-f728-4856-87f6-9a25a6b63715'}, - params: { publisherId: '9876abcd12-3', customData: {'gender': 'bart', 'age': 'low'}, ozoneData: {'networkID': '3048', 'dfpSiteID': 'd.thesun', 'sectionID': 'homepage', 'path': '/', 'sec_id': 'null', 'sec': 'sec', 'topics': 'null', 'kw': 'null', 'aid': 'null', 'search': 'null', 'article_type': 'null', 'hide_ads': '', 'article_slug': 'null'}, lotameData: {'Profile': {'tpid': 'c8ef27a0d4ba771a81159f0d2e792db4', 'Audiences': {'Audience': [{'id': '99999', 'abbr': 'sports'}, {'id': '88888', 'abbr': 'movie'}, {'id': '77777', 'abbr': 'blogger'}], 'ThirdPartyAudience': [{'id': '123', 'name': 'Automobiles'}, {'id': '456', 'name': 'Ages: 30-39'}]}}}, placementId: '1310000099', siteId: '1234567890', id: 'fea37168-78f1-4a23-a40e-88437a99377e', auctionId: '27dcb421-95c6-4024-a624-3c03816c5f99', imp: [ { id: '2899ec066a91ff8', tagid: 'undefined', secure: 1, banner: { format: [{ w: 300, h: 250 }, { w: 300, h: 600 }], h: 250, topframe: 1, w: 300 } } ] }, + params: { publisherId: '9876abcd12-3', customData: {'gender': 'bart', 'age': 'low'}, lotameData: {'Profile': {'tpid': 'c8ef27a0d4ba771a81159f0d2e792db4', 'Audiences': {'Audience': [{'id': '99999', 'abbr': 'sports'}, {'id': '88888', 'abbr': 'movie'}, {'id': '77777', 'abbr': 'blogger'}], 'ThirdPartyAudience': [{'id': '123', 'name': 'Automobiles'}, {'id': '456', 'name': 'Ages: 30-39'}]}}}, placementId: '1310000099', siteId: '1234567890', id: 'fea37168-78f1-4a23-a40e-88437a99377e', auctionId: '27dcb421-95c6-4024-a624-3c03816c5f99', imp: [ { id: '2899ec066a91ff8', tagid: 'undefined', secure: 1, banner: { format: [{ w: 300, h: 250 }, { w: 300, h: 600 }], h: 250, topframe: 1, w: 300 } } ] }, sizes: [[300, 250], [300, 600]], transactionId: '2e63c0ed-b10c-4008-aed5-84582cecfe87' } @@ -44,7 +45,7 @@ var validBidRequestsNoSizes = [ bidder: 'ozone', bidderRequestId: '1c1586b27a1b5c8', crumbs: {pubcid: '203a0692-f728-4856-87f6-9a25a6b63715'}, - params: { publisherId: '9876abcd12-3', customData: {'gender': 'bart', 'age': 'low'}, ozoneData: {'networkID': '3048', 'dfpSiteID': 'd.thesun', 'sectionID': 'homepage', 'path': '/', 'sec_id': 'null', 'sec': 'sec', 'topics': 'null', 'kw': 'null', 'aid': 'null', 'search': 'null', 'article_type': 'null', 'hide_ads': '', 'article_slug': 'null'}, lotameData: {'Profile': {'tpid': 'c8ef27a0d4ba771a81159f0d2e792db4', 'Audiences': {'Audience': [{'id': '99999', 'abbr': 'sports'}, {'id': '88888', 'abbr': 'movie'}, {'id': '77777', 'abbr': 'blogger'}], 'ThirdPartyAudience': [{'id': '123', 'name': 'Automobiles'}, {'id': '456', 'name': 'Ages: 30-39'}]}}}, placementId: '1310000099', siteId: '1234567890', id: 'fea37168-78f1-4a23-a40e-88437a99377e', auctionId: '27dcb421-95c6-4024-a624-3c03816c5f99', imp: [ { id: '2899ec066a91ff8', tagid: 'undefined', secure: 1, banner: { format: [{ w: 300, h: 250 }, { w: 300, h: 600 }], h: 250, topframe: 1, w: 300 } } ] }, + params: { publisherId: '9876abcd12-3', customData: {'gender': 'bart', 'age': 'low'}, lotameData: {'Profile': {'tpid': 'c8ef27a0d4ba771a81159f0d2e792db4', 'Audiences': {'Audience': [{'id': '99999', 'abbr': 'sports'}, {'id': '88888', 'abbr': 'movie'}, {'id': '77777', 'abbr': 'blogger'}], 'ThirdPartyAudience': [{'id': '123', 'name': 'Automobiles'}, {'id': '456', 'name': 'Ages: 30-39'}]}}}, placementId: '1310000099', siteId: '1234567890', id: 'fea37168-78f1-4a23-a40e-88437a99377e', auctionId: '27dcb421-95c6-4024-a624-3c03816c5f99', imp: [ { id: '2899ec066a91ff8', tagid: 'undefined', secure: 1, banner: { format: [{ w: 300, h: 250 }, { w: 300, h: 600 }], h: 250, topframe: 1, w: 300 } } ] }, transactionId: '2e63c0ed-b10c-4008-aed5-84582cecfe87' } ]; @@ -58,12 +59,12 @@ var validBidRequestsWithBannerMediaType = [ bidder: 'ozone', bidderRequestId: '1c1586b27a1b5c8', crumbs: {pubcid: '203a0692-f728-4856-87f6-9a25a6b63715'}, - params: { publisherId: '9876abcd12-3', customData: {'gender': 'bart', 'age': 'low'}, ozoneData: {'networkID': '3048', 'dfpSiteID': 'd.thesun', 'sectionID': 'homepage', 'path': '/', 'sec_id': 'null', 'sec': 'sec', 'topics': 'null', 'kw': 'null', 'aid': 'null', 'search': 'null', 'article_type': 'null', 'hide_ads': '', 'article_slug': 'null'}, lotameData: {'Profile': {'tpid': 'c8ef27a0d4ba771a81159f0d2e792db4', 'Audiences': {'Audience': [{'id': '99999', 'abbr': 'sports'}, {'id': '88888', 'abbr': 'movie'}, {'id': '77777', 'abbr': 'blogger'}], 'ThirdPartyAudience': [{'id': '123', 'name': 'Automobiles'}, {'id': '456', 'name': 'Ages: 30-39'}]}}}, placementId: '1310000099', siteId: '1234567890', id: 'fea37168-78f1-4a23-a40e-88437a99377e', auctionId: '27dcb421-95c6-4024-a624-3c03816c5f99', imp: [ { id: '2899ec066a91ff8', tagid: 'undefined', secure: 1, banner: { format: [{ w: 300, h: 250 }, { w: 300, h: 600 }], h: 250, topframe: 1, w: 300 } } ] }, + params: { publisherId: '9876abcd12-3', customData: {'gender': 'bart', 'age': 'low'}, lotameData: {'Profile': {'tpid': 'c8ef27a0d4ba771a81159f0d2e792db4', 'Audiences': {'Audience': [{'id': '99999', 'abbr': 'sports'}, {'id': '88888', 'abbr': 'movie'}, {'id': '77777', 'abbr': 'blogger'}], 'ThirdPartyAudience': [{'id': '123', 'name': 'Automobiles'}, {'id': '456', 'name': 'Ages: 30-39'}]}}}, placementId: '1310000099', siteId: '1234567890', id: 'fea37168-78f1-4a23-a40e-88437a99377e', auctionId: '27dcb421-95c6-4024-a624-3c03816c5f99', imp: [ { id: '2899ec066a91ff8', tagid: 'undefined', secure: 1, banner: { format: [{ w: 300, h: 250 }, { w: 300, h: 600 }], h: 250, topframe: 1, w: 300 } } ] }, mediaTypes: {banner: {sizes: [[300, 250], [300, 600]]}}, transactionId: '2e63c0ed-b10c-4008-aed5-84582cecfe87' } ]; -var validBidRequestsWithNonBannerMediaTypes = [ +var validBidRequestsWithNonBannerMediaTypesAndValidOutstreamVideo = [ { adUnitCode: 'div-gpt-ad-1460505748561-0', auctionId: '27dcb421-95c6-4024-a624-3c03816c5f99', @@ -72,8 +73,8 @@ var validBidRequestsWithNonBannerMediaTypes = [ bidder: 'ozone', bidderRequestId: '1c1586b27a1b5c8', crumbs: {pubcid: '203a0692-f728-4856-87f6-9a25a6b63715'}, - params: { publisherId: '9876abcd12-3', customData: {'gender': 'bart', 'age': 'low'}, ozoneData: {'networkID': '3048', 'dfpSiteID': 'd.thesun', 'sectionID': 'homepage', 'path': '/', 'sec_id': 'null', 'sec': 'sec', 'topics': 'null', 'kw': 'null', 'aid': 'null', 'search': 'null', 'article_type': 'null', 'hide_ads': '', 'article_slug': 'null'}, lotameData: {'Profile': {'tpid': 'c8ef27a0d4ba771a81159f0d2e792db4', 'Audiences': {'Audience': [{'id': '99999', 'abbr': 'sports'}, {'id': '88888', 'abbr': 'movie'}, {'id': '77777', 'abbr': 'blogger'}], 'ThirdPartyAudience': [{'id': '123', 'name': 'Automobiles'}, {'id': '456', 'name': 'Ages: 30-39'}]}}}, placementId: '1310000099', siteId: '1234567890', id: 'fea37168-78f1-4a23-a40e-88437a99377e', auctionId: '27dcb421-95c6-4024-a624-3c03816c5f99', imp: [ { id: '2899ec066a91ff8', tagid: 'undefined', secure: 1, banner: { format: [{ w: 300, h: 250 }, { w: 300, h: 600 }], h: 250, topframe: 1, w: 300 } } ] }, - mediaTypes: {video: {info: 'dummy data'}, native: {info: 'dummy data'}}, + params: { publisherId: '9876abcd12-3', customData: {'gender': 'bart', 'age': 'low'}, lotameData: {'Profile': {'tpid': 'c8ef27a0d4ba771a81159f0d2e792db4', 'Audiences': {'Audience': [{'id': '99999', 'abbr': 'sports'}, {'id': '88888', 'abbr': 'movie'}, {'id': '77777', 'abbr': 'blogger'}], 'ThirdPartyAudience': [{'id': '123', 'name': 'Automobiles'}, {'id': '456', 'name': 'Ages: 30-39'}]}}}, placementId: '1310000099', siteId: '1234567890', id: 'fea37168-78f1-4a23-a40e-88437a99377e', auctionId: '27dcb421-95c6-4024-a624-3c03816c5f99', imp: [ { id: '2899ec066a91ff8', tagid: 'undefined', secure: 1, video: {skippable: true, playback_method: ['auto_play_sound_off'], targetDiv: 'some-different-div-id-to-my-adunitcode'} } ] }, + mediaTypes: {video: {mimes: ['video/mp4'], 'context': 'outstream', 'sizes': [640, 480]}, native: {info: 'dummy data'}}, transactionId: '2e63c0ed-b10c-4008-aed5-84582cecfe87' } ]; @@ -91,7 +92,7 @@ var validBidderRequest = { bidder: 'ozone', bidderRequestId: '1c1586b27a1b5c8', crumbs: {pubcid: '203a0692-f728-4856-87f6-9a25a6b63715'}, - params: { publisherId: '9876abcd12-3', customData: {'gender': 'bart', 'age': 'low'}, ozoneData: {'networkID': '3048', 'dfpSiteID': 'd.thesun', 'sectionID': 'homepage', 'path': '/', 'sec_id': 'null', 'sec': 'sec', 'topics': 'null', 'kw': 'null', 'aid': 'null', 'search': 'null', 'article_type': 'null', 'hide_ads': '', 'article_slug': 'null'}, lotameData: {'Profile': {'tpid': 'c8ef27a0d4ba771a81159f0d2e792db4', 'Audiences': {'Audience': [{'id': '99999', 'abbr': 'sports'}, {'id': '88888', 'abbr': 'movie'}, {'id': '77777', 'abbr': 'blogger'}], 'ThirdPartyAudience': [{'id': '123', 'name': 'Automobiles'}, {'id': '456', 'name': 'Ages: 30-39'}]}}}, placementId: '1310000099', siteId: '1234567890', id: 'fea37168-78f1-4a23-a40e-88437a99377e', auctionId: '27dcb421-95c6-4024-a624-3c03816c5f99', imp: [ { banner: { topframe: 1, w: 300, h: 250, format: [{ w: 300, h: 250 }, { w: 300, h: 600 }] }, id: '2899ec066a91ff8', secure: 1, tagid: 'undefined' } ] }, + params: { publisherId: '9876abcd12-3', customData: {'gender': 'bart', 'age': 'low'}, lotameData: {'Profile': {'tpid': 'c8ef27a0d4ba771a81159f0d2e792db4', 'Audiences': {'Audience': [{'id': '99999', 'abbr': 'sports'}, {'id': '88888', 'abbr': 'movie'}, {'id': '77777', 'abbr': 'blogger'}], 'ThirdPartyAudience': [{'id': '123', 'name': 'Automobiles'}, {'id': '456', 'name': 'Ages: 30-39'}]}}}, placementId: '1310000099', siteId: '1234567890', id: 'fea37168-78f1-4a23-a40e-88437a99377e', auctionId: '27dcb421-95c6-4024-a624-3c03816c5f99', imp: [ { banner: { topframe: 1, w: 300, h: 250, format: [{ w: 300, h: 250 }, { w: 300, h: 600 }] }, id: '2899ec066a91ff8', secure: 1, tagid: 'undefined' } ] }, sizes: [[300, 250], [300, 600]], transactionId: '2e63c0ed-b10c-4008-aed5-84582cecfe87' }], @@ -99,6 +100,65 @@ var validBidderRequest = { start: 1536838908987, timeout: 3000 }; + +// bidder request with GDPR - change the values for testing: +// gdprConsent.gdprApplies (true/false) +// gdprConsent.vendorData.purposeConsents (make empty, make null, remove it) +// gdprConsent.vendorData.vendorConsents (remove 524, remove all, make the element null, remove it) +var bidderRequestWithFullGdpr = { + auctionId: '27dcb421-95c6-4024-a624-3c03816c5f99', + auctionStart: 1536838908986, + bidderCode: 'ozone', + bidderRequestId: '1c1586b27a1b5c8', + bids: [{ + adUnitCode: 'div-gpt-ad-1460505748561-0', + auctionId: '27dcb421-95c6-4024-a624-3c03816c5f99', + bidId: '2899ec066a91ff8', + bidRequestsCount: 1, + bidder: 'ozone', + bidderRequestId: '1c1586b27a1b5c8', + crumbs: {pubcid: '203a0692-f728-4856-87f6-9a25a6b63715'}, + params: { publisherId: '9876abcd12-3', customData: {'gender': 'bart', 'age': 'low'}, lotameData: {'Profile': {'tpid': 'c8ef27a0d4ba771a81159f0d2e792db4', 'Audiences': {'Audience': [{'id': '99999', 'abbr': 'sports'}, {'id': '88888', 'abbr': 'movie'}, {'id': '77777', 'abbr': 'blogger'}], 'ThirdPartyAudience': [{'id': '123', 'name': 'Automobiles'}, {'id': '456', 'name': 'Ages: 30-39'}]}}}, placementId: '1310000099', siteId: '1234567890', id: 'fea37168-78f1-4a23-a40e-88437a99377e', auctionId: '27dcb421-95c6-4024-a624-3c03816c5f99', imp: [ { banner: { topframe: 1, w: 300, h: 250, format: [{ w: 300, h: 250 }, { w: 300, h: 600 }] }, id: '2899ec066a91ff8', secure: 1, tagid: 'undefined' } ] }, + sizes: [[300, 250], [300, 600]], + transactionId: '2e63c0ed-b10c-4008-aed5-84582cecfe87' + }], + doneCbCallCount: 1, + start: 1536838908987, + timeout: 3000, + gdprConsent: { + 'consentString': 'BOh7mtYOh7mtYAcABBENCU-AAAAncgPIXJiiAoao0PxBFkgCAC8ACIAAQAQQAAIAAAIAAAhBGAAAQAQAEQgAAAAAAABAAAAAAAAAAAAAAACAAAAAAAACgAAAAABAAAAQAAAAAAA', + 'vendorData': { + 'metadata': 'BOh7mtYOh7mtYAcABBENCU-AAAAncgPIXJiiAoao0PxBFkgCAC8ACIAAQAQQAAIAAAIAAAhBGAAAQAQAEQgAAAAAAABAAAAAAAAAAAAAAACAAAAAAAACgAAAAABAAAAQAAAAAAA', + 'gdprApplies': true, + 'hasGlobalScope': false, + 'cookieVersion': '1', + 'created': '2019-05-31T12:46:48.825', + 'lastUpdated': '2019-05-31T12:46:48.825', + 'cmpId': '28', + 'cmpVersion': '1', + 'consentLanguage': 'en', + 'consentScreen': '1', + 'vendorListVersion': 148, + 'maxVendorId': 631, + 'purposeConsents': { + '1': true, + '2': true, + '3': true, + '4': true, + '5': true + }, + 'vendorConsents': { + '468': true, + '522': true, + '524': true, /* 524 is ozone */ + '565': true, + '591': true + } + }, + 'gdprApplies': true + }, +}; + // make sure the impid matches the request bidId var validResponse = { 'body': { @@ -154,7 +214,158 @@ var validResponse = { } }, 'headers': {} -} +}; +var validOutstreamResponse = { + 'body': { + 'id': 'd6198807-7a53-4141-b2db-d2cb754d68ba', + 'seatbid': [ + { + 'bid': [ + { + 'id': '677903815252395017', + 'impid': '2899ec066a91ff8', + 'price': 0.5, + 'adm': '', + 'adid': '98493581', + 'adomain': [ + 'http://prebid.org' + ], + 'iurl': 'https://fra1-ib.adnxs.com/cr?id=98493581', + 'cid': '9325', + 'crid': '98493581', + 'cat': [ + 'IAB3-1' + ], + 'w': 300, + 'h': 600, + 'ext': { + 'prebid': { + 'type': 'video' + }, + 'bidder': { + 'unruly': { + 'renderer': { + 'config': { + 'targetingUUID': 'aafd3388-afaf-41f4-b271-0ac8e0325a7f', + 'siteId': 1052815, + 'featureOverrides': {} + }, + 'url': 'https://video.unrulymedia.com/native/native-loader.js#supplyMode=prebid?cb=6284685353877994', + 'id': 'unruly_inarticle' + }, + 'vast_url': 'data:text/xml;base64,PD94bWwgdmVyc2lvbj0i' + } + } + } + } + ], + 'seat': 'unruly' + } + ], + 'ext': { + 'responsetimemillis': { + 'appnexus': 47, + 'openx': 30 + } + }, + 'timing': { + 'start': 1536848078.089177, + 'end': 1536848078.142203, + 'TimeTaken': 0.05302619934082031 + } + }, + 'headers': {} +}; +var validBidResponse1adWith2Bidders = { + 'body': { + 'id': '91221f96-b931-4acc-8f05-c2a1186fa5ac', + 'seatbid': [ + { + 'bid': [ + { + 'id': 'd6198807-7a53-4141-b2db-d2cb754d68ba', + 'impid': '2899ec066a91ff8', + 'price': 0.36754, + 'adm': '', + 'adid': '134928661', + 'adomain': [ + 'somecompany.com' + ], + 'iurl': 'https:\/\/ams1-ib.adnxs.com\/cr?id=134928661', + 'cid': '8825', + 'crid': '134928661', + 'cat': [ + 'IAB8-15', + 'IAB8-16', + 'IAB8-4', + 'IAB8-1', + 'IAB8-14', + 'IAB8-6', + 'IAB8-13', + 'IAB8-3', + 'IAB8-17', + 'IAB8-12', + 'IAB8-8', + 'IAB8-7', + 'IAB8-2', + 'IAB8-9', + 'IAB8', + 'IAB8-11' + ], + 'w': 300, + 'h': 250, + 'ext': { + 'prebid': { + 'type': 'banner' + }, + 'bidder': { + 'appnexus': { + 'brand_id': 14640, + 'auction_id': 1.8369641905139e+18, + 'bidder_id': 2, + 'bid_ad_type': 0 + } + } + } + } + ], + 'seat': 'appnexus' + }, + { + 'bid': [ + { + 'id': '75665207-a1ca-49db-ba0e-a5e9c7d26f32', + 'impid': '37fff511779365a', + 'price': 1.046, + 'adm': '
    removed
    ', + 'adomain': [ + 'kx.com' + ], + 'crid': '13005', + 'w': 300, + 'h': 250, + 'ext': { + 'prebid': { + 'type': 'banner' + } + } + } + ], + 'seat': 'openx' + } + ], + 'ext': { + 'responsetimemillis': { + 'appnexus': 91, + 'openx': 109, + 'ozappnexus': 46, + 'ozbeeswax': 2, + 'pangaea': 91 + } + } + }, + 'headers': {} +}; describe('ozone Adapter', function () { describe('isBidRequestValid', function () { @@ -180,7 +391,6 @@ describe('ozone Adapter', function () { publisherId: '9876abcd12-3', siteId: '1234567890', customData: {'gender': 'bart', 'age': 'low'}, - ozoneData: {'networkID': '3048', 'dfpSiteID': 'd.thesun', 'sectionID': 'homepage', 'path': '/', 'sec_id': 'null', 'sec': 'sec', 'topics': 'null', 'kw': 'null', 'aid': 'null', 'search': 'null', 'article_type': 'null', 'hide_ads': '', 'article_slug': 'null'}, lotameData: {'Profile': {'tpid': 'c8ef27a0d4ba771a81159f0d2e792db4', 'Audiences': {'Audience': [{'id': '99999', 'abbr': 'sports'}, {'id': '88888', 'abbr': 'movie'}, {'id': '77777', 'abbr': 'blogger'}], 'ThirdPartyAudience': [{'id': '123', 'name': 'Automobiles'}, {'id': '456', 'name': 'Ages: 30-39'}]}}}, }, siteId: 1234567890 @@ -423,45 +633,85 @@ describe('ozone Adapter', function () { expect(spec.isBidRequestValid(xCustomParams)).to.equal(false); }); - var xBadOzoneData = { + var xBadCustomData = { bidder: BIDDER_CODE, params: { 'placementId': '1234567890', 'publisherId': '9876abcd12-3', - 'ozoneData': 'this should be an object', + 'customData': 'this should be an object', siteId: '1234567890' } }; - it('should not validate ozoneData being sent', function () { - expect(spec.isBidRequestValid(xBadOzoneData)).to.equal(false); + expect(spec.isBidRequestValid(xBadCustomData)).to.equal(false); }); - var xBadCustomData = { + var xBadLotame = { bidder: BIDDER_CODE, params: { 'placementId': '1234567890', 'publisherId': '9876abcd12-3', - 'customData': 'this should be an object', + 'lotameData': 'this should be an object', + siteId: '1234567890' + } + }; + it('should not validate lotameData being sent', function () { + expect(spec.isBidRequestValid(xBadLotame)).to.equal(false); + }); + + var xBadVideoContext = { + bidder: BIDDER_CODE, + params: { + 'placementId': '1234567890', + 'publisherId': '9876abcd12-3', + 'lotameData': {}, siteId: '1234567890' + }, + mediaTypes: { + video: { + mimes: ['video/mp4'], + 'context': 'instream'}, } }; - it('should not validate ozoneData being sent', function () { - expect(spec.isBidRequestValid(xBadCustomData)).to.equal(false); + it('should not validate video instream being sent', function () { + expect(spec.isBidRequestValid(xBadVideoContext)).to.equal(false); }); - var xBadLotame = { + + var xBadVideoContext2 = { bidder: BIDDER_CODE, params: { 'placementId': '1234567890', 'publisherId': '9876abcd12-3', - 'lotameData': 'this should be an object', + 'lotameData': {}, siteId: '1234567890' + }, + mediaTypes: { + video: { + mimes: ['video/mp4']} } }; - it('should not validate lotameData being sent', function () { - expect(spec.isBidRequestValid(xBadLotame)).to.equal(false); + it('should not validate video without context attribute', function () { + expect(spec.isBidRequestValid(xBadVideoContext2)).to.equal(false); + }); + + let validVideoBidReq = { + bidder: BIDDER_CODE, + params: { + placementId: '1310000099', + publisherId: '9876abcd12-3', + siteId: '1234567890' + }, + mediaTypes: { + video: { + mimes: ['video/mp4'], + 'context': 'outstream'}, + } + }; + + it('should validate video outstream being sent', function () { + expect(spec.isBidRequestValid(validVideoBidReq)).to.equal(true); }); }); @@ -486,10 +736,21 @@ describe('ozone Adapter', function () { const request = spec.buildRequests(validBidRequests, validBidderRequest); expect(request.data).to.be.a('string'); var data = JSON.parse(request.data); - expect(data.imp[0].ext.ozone.ozoneData).to.be.an('object'); expect(data.imp[0].ext.ozone.lotameData).to.be.an('object'); expect(data.imp[0].ext.ozone.customData).to.be.an('object'); - expect(request).not.to.have.key('ozoneData'); + expect(request).not.to.have.key('lotameData'); + expect(request).not.to.have.key('customData'); + }); + + it('ignores ozoneData in & after version 2.1.1', function () { + let validBidRequestsWithOzoneData = validBidRequests; + validBidRequestsWithOzoneData[0].params.ozoneData = {'networkID': '3048', 'dfpSiteID': 'd.thesun', 'sectionID': 'homepage', 'path': '/', 'sec_id': 'null', 'sec': 'sec', 'topics': 'null', 'kw': 'null', 'aid': 'null', 'search': 'null', 'article_type': 'null', 'hide_ads': '', 'article_slug': 'null'}; + const request = spec.buildRequests(validBidRequests, validBidderRequest); + expect(request.data).to.be.a('string'); + var data = JSON.parse(request.data); + expect(data.imp[0].ext.ozone.lotameData).to.be.an('object'); + expect(data.imp[0].ext.ozone.customData).to.be.an('object'); + expect(data.imp[0].ext.ozone.ozoneData).to.be.undefined; expect(request).not.to.have.key('lotameData'); expect(request).not.to.have.key('customData'); }); @@ -509,8 +770,8 @@ describe('ozone Adapter', function () { expect(request).to.have.all.keys(['bidderRequest', 'data', 'method', 'url']); }); - it('handles missing banner mediaType element correctly', function () { - const request = spec.buildRequests(validBidRequestsWithNonBannerMediaTypes, validBidderRequest); + it('handles video mediaType element correctly, with outstream video', function () { + const request = spec.buildRequests(validBidRequestsWithNonBannerMediaTypesAndValidOutstreamVideo, validBidderRequest); expect(request).to.have.all.keys(['bidderRequest', 'data', 'method', 'url']); }); @@ -519,28 +780,6 @@ describe('ozone Adapter', function () { expect(request).to.have.all.keys(['bidderRequest', 'data', 'method', 'url']); }); - it('should add gdpr consent information to the request', function () { - let consentString = 'BOJ8RZsOJ8RZsABAB8AAAAAZ+A=='; - let bidderRequest = { - 'bidderCode': 'ozone', - 'auctionId': '1d1a030790a475', - 'bidderRequestId': '22edbae2733bf6', - 'timeout': 3000, - 'gdprConsent': { - consentString: consentString, - gdprApplies: true - } - }; - bidderRequest.bids = validBidRequests; - - const request = spec.buildRequests(validBidRequests, bidderRequest); - const payload = JSON.parse(request.data); - - expect(payload.user.ext).to.exist; - expect(payload.user.ext.consent).to.exist.and.to.equal(consentString); - expect(payload.regs.ext.gdpr).to.exist.and.to.equal(1); - }); - it('should be able to handle non-single requests', function () { config.setConfig({'ozone': {'singleRequest': false}}); const request = spec.buildRequests(validBidRequestsNoSizes, validBidderRequest); @@ -549,6 +788,82 @@ describe('ozone Adapter', function () { // need to reset the singleRequest config flag: config.setConfig({'ozone': {'singleRequest': true}}); }); + + it('should add gdpr consent information to the request when ozone is true', function () { + let consentString = 'BOcocyaOcocyaAfEYDENCD-AAAAjx7_______9______9uz_Ov_v_f__33e8__9v_l_7_-___u_-33d4-_1vf99yfm1-7ftr3tp_87ues2_Xur__59__3z3_NphLgA=='; + let bidderRequest = validBidderRequest; + bidderRequest.gdprConsent = { + consentString: consentString, + gdprApplies: true, + vendorData: { + vendorConsents: {524: true}, + purposeConsents: {1: true, 2: true, 3: true, 4: true, 5: true} + } + } + + const request = spec.buildRequests(validBidRequestsNoSizes, bidderRequest); + const payload = JSON.parse(request.data); + expect(payload.regs.ext.gdpr).to.equal(1); + expect(payload.regs.ext.oz_con).to.exist.and.to.equal(1); + expect(payload.regs.ext.gap).to.exist.and.to.be.an('array').and.to.eql([1, 2, 3, 4, 5]); + }); + + it('should add correct gdpr consent information to the request when user has accepted only some purpose consents', function () { + let consentString = 'BOcocyaOcocyaAfEYDENCD-AAAAjx7_______9______9uz_Ov_v_f__33e8__9v_l_7_-___u_-33d4-_1vf99yfm1-7ftr3tp_87ues2_Xur__59__3z3_NphLgA=='; + let bidderRequest = validBidderRequest; + bidderRequest.gdprConsent = { + consentString: consentString, + gdprApplies: true, + vendorData: { + vendorConsents: {524: true}, + purposeConsents: {1: true, 4: true, 5: true} + } + } + + const request = spec.buildRequests(validBidRequestsNoSizes, bidderRequest); + const payload = JSON.parse(request.data); + expect(payload.regs.ext.gdpr).to.equal(1); + expect(payload.regs.ext.oz_con).to.exist.and.to.equal(1); + expect(payload.regs.ext.gap).to.exist.and.to.be.an('array').and.to.eql([1, 4, 5]); + }); + + it('should add gdpr consent information to the request when ozone is false', function () { + let consentString = 'BOcocyaOcocyaAfEYDENCD-AAAAjx7_______9______9uz_Ov_v_f__33e8__9v_l_7_-___u_-33d4-_1vf99yfm1-7ftr3tp_87ues2_Xur__59__3z3_NphLgA=='; + let bidderRequest = validBidderRequest; + bidderRequest.gdprConsent = { + consentString: consentString, + gdprApplies: true, + vendorData: { + vendorConsents: {}, /* 524 is not present */ + purposeConsents: {1: true, 2: true, 3: true, 4: true, 5: true} + } + }; + + const request = spec.buildRequests(validBidRequestsNoSizes, bidderRequest); + const payload = JSON.parse(request.data); + expect(payload.regs.ext.gdpr).to.equal(1); + expect(payload.regs.ext.oz_con).to.exist.and.to.equal(0); + expect(payload.regs.ext.gap).to.exist.and.to.be.an('array').and.to.eql([1, 2, 3, 4, 5]); + }); + + it('should set regs.ext.gdpr flag to 0 when gdprApplies is false', function () { + let consentString = 'BOcocyaOcocyaAfEYDENCD-AAAAjx7_______9______9uz_Ov_v_f__33e8__9v_l_7_-___u_-33d4-_1vf99yfm1-7ftr3tp_87ues2_Xur__59__3z3_NphLgA=='; + let bidderRequest = validBidderRequest; + bidderRequest.gdprConsent = { + consentString: consentString, + gdprApplies: false, + vendorData: { + vendorConsents: {}, /* 524 is not present */ + purposeConsents: {1: true, 2: true, 3: true, 4: true, 5: true} + } + }; + + const request = spec.buildRequests(validBidRequestsNoSizes, bidderRequest); + const payload = JSON.parse(request.data); + expect(payload.regs.ext.gdpr).to.equal(0); + expect(payload.regs.ext.oz_con).to.be.undefined; + expect(payload.regs.ext.gap).to.be.undefined; + }); }); describe('interpretResponse', function () { @@ -574,16 +889,31 @@ describe('ozone Adapter', function () { const result = spec.interpretResponse(validResponse, request); expect(result.length).to.equal(1); }); + it('should fail ok if no seatbid in server response', function () { const result = spec.interpretResponse({}, {}); expect(result).to.be.an('array'); expect(result).to.be.empty; }); + it('should fail ok if seatbid is not an array', function () { const result = spec.interpretResponse({'body': {'seatbid': 'nothing_here'}}, {}); expect(result).to.be.an('array'); expect(result).to.be.empty; }); + + it('should have video renderer', function () { + const request = spec.buildRequests(validBidRequestsWithNonBannerMediaTypesAndValidOutstreamVideo, validBidderRequest); + const result = spec.interpretResponse(validOutstreamResponse, request); + const bid = result[0]; + expect(bid.renderer).to.be.an.instanceOf(Renderer); + }); + + it('should correctly parse response where there are more bidders than ad slots', function () { + const request = spec.buildRequests(validBidRequests, validBidderRequest); + const result = spec.interpretResponse(validBidResponse1adWith2Bidders, request); + expect(result.length).to.equal(2); + }); }); describe('userSyncs', function () { @@ -596,4 +926,67 @@ describe('ozone Adapter', function () { expect(result).to.be.empty; }); }); + + describe('video object utils', function () { + it('should find width & height from video object', function () { + let obj = {'playerSize': [640, 480], 'mimes': ['video/mp4'], 'context': 'outstream'}; + const result = getWidthAndHeightFromVideoObject(obj); + expect(result.w).to.equal(640); + expect(result.h).to.equal(480); + }); + it('should find null from bad video object', function () { + let obj = {'playerSize': [], 'mimes': ['video/mp4'], 'context': 'outstream'}; + const result = getWidthAndHeightFromVideoObject(obj); + expect(result).to.be.null; + }); + it('should find null from bad video object2', function () { + let obj = {'mimes': ['video/mp4'], 'context': 'outstream'}; + const result = getWidthAndHeightFromVideoObject(obj); + expect(result).to.be.null; + }); + it('should find null from bad video object3', function () { + let obj = {'playerSize': 'should be an array', 'mimes': ['video/mp4'], 'context': 'outstream'}; + const result = getWidthAndHeightFromVideoObject(obj); + expect(result).to.be.null; + }); + it('should find that player size is nested', function () { + let obj = {'playerSize': [[640, 480]], 'mimes': ['video/mp4'], 'context': 'outstream'}; + const result = getWidthAndHeightFromVideoObject(obj); + expect(result.w).to.equal(640); + expect(result.h).to.equal(480); + }); + it('should fail if player size is 2 x nested', function () { + let obj = {'playerSize': [[[640, 480]]], 'mimes': ['video/mp4'], 'context': 'outstream'}; + const result = getWidthAndHeightFromVideoObject(obj); + expect(result).to.be.null; + }); + it('should find that player size is nested', function () { + let obj = {'playerSize': [[640, 480]], 'mimes': ['video/mp4'], 'context': 'outstream'}; + const result = playerSizeIsNestedArray(obj); + expect(result).to.be.true; + }); + it('should find null from bad video object', function () { + let obj = {'playerSize': [], 'mimes': ['video/mp4'], 'context': 'outstream'}; + const result = playerSizeIsNestedArray(obj); + expect(result).to.be.null; + }); + it('should find null from bad video object2', function () { + let obj = {'mimes': ['video/mp4'], 'context': 'outstream'}; + const result = playerSizeIsNestedArray(obj); + expect(result).to.be.null; + }); + it('should find null from bad video object3', function () { + let obj = {'playerSize': 'should be an array', 'mimes': ['video/mp4'], 'context': 'outstream'}; + const result = playerSizeIsNestedArray(obj); + expect(result).to.be.null; + }); + }); + describe('default size', function () { + it('should should return default sizes if no obj is sent', function () { + let obj = ''; + const result = defaultSize(obj); + expect(result.defaultHeight).to.equal(250); + expect(result.defaultWidth).to.equal(300); + }); + }); }); diff --git a/test/spec/modules/padsquadBidAdapter_spec.js b/test/spec/modules/padsquadBidAdapter_spec.js new file mode 100644 index 00000000000..aba1efea32f --- /dev/null +++ b/test/spec/modules/padsquadBidAdapter_spec.js @@ -0,0 +1,261 @@ +import {expect} from 'chai'; +import {spec} from 'modules/padsquadBidAdapter'; + +const REQUEST = { + 'bidderCode': 'padsquad', + 'auctionId': 'auctionId-56a2-4f71-9098-720a68f2f708', + 'bidderRequestId': 'requestId', + 'bidRequest': [{ + 'bidder': 'padsquad', + 'params': { + 'unitId': 123456, + }, + 'placementCode': 'div-gpt-dummy-placement-code', + 'sizes': [ + [300, 250] + ], + 'bidId': 'bidId1', + 'bidderRequestId': 'bidderRequestId', + 'auctionId': 'auctionId-56a2-4f71-9098-720a68f2f708' + }, + { + 'bidder': 'padsquad', + 'params': { + 'unitId': 123456, + }, + 'placementCode': 'div-gpt-dummy-placement-code', + 'sizes': [ + [300, 250] + ], + 'bidId': 'bidId2', + 'bidderRequestId': 'bidderRequestId', + 'auctionId': 'auctionId-56a2-4f71-9098-720a68f2f708' + }], + 'start': 1487883186070, + 'auctionStart': 1487883186069, + 'timeout': 3000 +}; + +const RESPONSE = { + 'headers': null, + 'body': { + 'id': 'responseId', + 'seatbid': [ + { + 'bid': [ + { + 'id': 'bidId1', + 'impid': 'bidId1', + 'price': 0.18, + 'adm': '', + 'adid': '144762342', + 'adomain': [ + 'http://dummydomain.com' + ], + 'iurl': 'iurl', + 'cid': '109', + 'crid': 'creativeId', + 'cat': [], + 'w': 300, + 'h': 250, + 'ext': { + 'prebid': { + 'type': 'banner' + }, + 'bidder': { + 'appnexus': { + 'brand_id': 334553, + 'auction_id': 514667951122925701, + 'bidder_id': 2, + 'bid_ad_type': 0 + } + } + } + }, + { + 'id': 'bidId2', + 'impid': 'bidId2', + 'price': 0.1, + 'adm': '', + 'adid': '144762342', + 'adomain': [ + 'http://dummydomain.com' + ], + 'iurl': 'iurl', + 'cid': '109', + 'crid': 'creativeId', + 'cat': [], + 'w': 300, + 'h': 250, + 'ext': { + 'prebid': { + 'type': 'banner' + }, + 'bidder': { + 'appnexus': { + 'brand_id': 386046, + 'auction_id': 517067951122925501, + 'bidder_id': 2, + 'bid_ad_type': 0 + } + } + } + } + ], + 'seat': 'seat' + } + ], + 'ext': { + 'usersync': { + 'sovrn': { + 'status': 'none', + 'syncs': [ + { + 'url': 'urlsovrn', + 'type': 'iframe' + } + ] + }, + 'appnexus': { + 'status': 'none', + 'syncs': [ + { + 'url': 'urlappnexus', + 'type': 'pixel' + } + ] + } + }, + 'responsetimemillis': { + 'appnexus': 127 + } + } + } +}; + +describe('Padsquad bid adapter', function () { + describe('isBidRequestValid', function () { + it('should accept request if only unitId is passed', function () { + let bid = { + bidder: 'padsquad', + params: { + unitId: 'unitId', + } + }; + expect(spec.isBidRequestValid(bid)).to.equal(true); + }); + it('should accept request if only networkId is passed', function () { + let bid = { + bidder: 'padsquad', + params: { + networkId: 'networkId', + } + }; + expect(spec.isBidRequestValid(bid)).to.equal(true); + }); + it('should accept request if only publisherId is passed', function () { + let bid = { + bidder: 'padsquad', + params: { + publisherId: 'publisherId', + } + }; + expect(spec.isBidRequestValid(bid)).to.equal(true); + }); + + it('reject requests without params', function () { + let bid = { + bidder: 'padsquad', + params: {} + }; + expect(spec.isBidRequestValid(bid)).to.equal(false); + }); + }); + + describe('buildRequests', function () { + it('creates request data', function () { + let request = spec.buildRequests(REQUEST.bidRequest, REQUEST); + + expect(request).to.exist.and.to.be.a('object'); + const payload = JSON.parse(request.data); + expect(payload.imp[0]).to.have.property('id', REQUEST.bidRequest[0].bidId); + expect(payload.imp[1]).to.have.property('id', REQUEST.bidRequest[1].bidId); + }); + + it('has gdpr data if applicable', function () { + const req = Object.assign({}, REQUEST, { + gdprConsent: { + consentString: 'consentString', + gdprApplies: true, + } + }); + let request = spec.buildRequests(REQUEST.bidRequest, req); + + const payload = JSON.parse(request.data); + expect(payload.user.ext).to.have.property('consent', req.gdprConsent.consentString); + expect(payload.regs.ext).to.have.property('gdpr', 1); + }); + }); + + describe('interpretResponse', function () { + it('have bids', function () { + let bids = spec.interpretResponse(RESPONSE, REQUEST); + expect(bids).to.be.an('array').that.is.not.empty; + validateBidOnIndex(0); + validateBidOnIndex(1); + + function validateBidOnIndex(index) { + expect(bids[index]).to.have.property('currency', 'USD'); + expect(bids[index]).to.have.property('requestId', RESPONSE.body.seatbid[0].bid[index].impid); + expect(bids[index]).to.have.property('cpm', RESPONSE.body.seatbid[0].bid[index].price); + expect(bids[index]).to.have.property('width', RESPONSE.body.seatbid[0].bid[index].w); + expect(bids[index]).to.have.property('height', RESPONSE.body.seatbid[0].bid[index].h); + expect(bids[index]).to.have.property('ad', RESPONSE.body.seatbid[0].bid[index].adm); + expect(bids[index]).to.have.property('creativeId', RESPONSE.body.seatbid[0].bid[index].crid); + expect(bids[index]).to.have.property('ttl', 30); + expect(bids[index]).to.have.property('netRevenue', true); + } + }); + + it('handles empty response', function () { + const EMPTY_RESP = Object.assign({}, RESPONSE, {'body': {}}); + const bids = spec.interpretResponse(EMPTY_RESP, REQUEST); + + expect(bids).to.be.empty; + }); + }); + + describe('getUserSyncs', function () { + it('handles no parameters', function () { + let opts = spec.getUserSyncs({}); + expect(opts).to.be.an('array').that.is.empty; + }); + it('returns non if sync is not allowed', function () { + let opts = spec.getUserSyncs({iframeEnabled: false, pixelEnabled: false}); + + expect(opts).to.be.an('array').that.is.empty; + }); + + it('iframe sync enabled should return results', function () { + let opts = spec.getUserSyncs({iframeEnabled: true, pixelEnabled: false}, [RESPONSE]); + + expect(opts.length).to.equal(1); + expect(opts[0].type).to.equal('iframe'); + expect(opts[0].url).to.equal(RESPONSE.body.ext.usersync['sovrn'].syncs[0].url); + }); + + it('pixel sync enabled should return results', function () { + let opts = spec.getUserSyncs({iframeEnabled: false, pixelEnabled: true}, [RESPONSE]); + + expect(opts.length).to.equal(1); + expect(opts[0].type).to.equal('image'); + expect(opts[0].url).to.equal(RESPONSE.body.ext.usersync['appnexus'].syncs[0].url); + }); + + it('all sync enabled should return all results', function () { + let opts = spec.getUserSyncs({iframeEnabled: true, pixelEnabled: true}, [RESPONSE]); + + expect(opts.length).to.equal(2); + }); + }); +}); diff --git a/test/spec/modules/piximediaBidAdapter_spec.js b/test/spec/modules/piximediaBidAdapter_spec.js index 02cf80c614f..95e03734345 100644 --- a/test/spec/modules/piximediaBidAdapter_spec.js +++ b/test/spec/modules/piximediaBidAdapter_spec.js @@ -47,6 +47,7 @@ describe('piximediaAdapterTest', function() { it('bidRequest data', function() { const requests = spec.buildRequests(bidRequests); expect(typeof requests[0].data.timestamp).to.equal('number'); + expect(requests[0].data.pbsizes).to.equal('["300x250"]'); expect(requests[0].data.pver).to.equal('1.0'); expect(requests[0].data.pbparams).to.equal(JSON.stringify(bidRequests[0].params)); expect(requests[0].data.pbwidth).to.equal('300'); diff --git a/test/spec/modules/platformioBidAdapter_spec.js b/test/spec/modules/platformioBidAdapter_spec.js index f3754654cf1..4ef2dc1bba0 100644 --- a/test/spec/modules/platformioBidAdapter_spec.js +++ b/test/spec/modules/platformioBidAdapter_spec.js @@ -192,8 +192,8 @@ describe('Platform.io Adapter Tests', function () { { id: 1, title: { text: 'Ad Title' } }, { id: 2, data: { value: 'Test description' } }, { id: 3, data: { value: 'Brand' } }, - { id: 4, img: { url: 'https://s3.amazonaws.com/adx1public/creatives_icon.png', w: 100, h: 100 } }, - { id: 5, img: { url: 'https://s3.amazonaws.com/adx1public/creatives_image.png', w: 300, h: 300 } } + { id: 4, img: { url: 'https://adx1public.s3.amazonaws.com/creatives_icon.png', w: 100, h: 100 } }, + { id: 5, img: { url: 'https://adx1public.s3.amazonaws.com/creatives_image.png', w: 300, h: 300 } } ], link: { url: 'http://brand.com/' } } @@ -220,8 +220,8 @@ describe('Platform.io Adapter Tests', function () { expect(nativeBid).to.not.equal(null); expect(nativeBid.title).to.equal('Ad Title'); expect(nativeBid.sponsoredBy).to.equal('Brand'); - expect(nativeBid.icon.url).to.equal('https://s3.amazonaws.com/adx1public/creatives_icon.png'); - expect(nativeBid.image.url).to.equal('https://s3.amazonaws.com/adx1public/creatives_image.png'); + expect(nativeBid.icon.url).to.equal('https://adx1public.s3.amazonaws.com/creatives_icon.png'); + expect(nativeBid.image.url).to.equal('https://adx1public.s3.amazonaws.com/creatives_image.png'); expect(nativeBid.image.width).to.equal(300); expect(nativeBid.image.height).to.equal(300); expect(nativeBid.icon.width).to.equal(100); diff --git a/test/spec/modules/playgroundxyzBidAdapter_spec.js b/test/spec/modules/playgroundxyzBidAdapter_spec.js index fc430bfb31b..a90564003f4 100644 --- a/test/spec/modules/playgroundxyzBidAdapter_spec.js +++ b/test/spec/modules/playgroundxyzBidAdapter_spec.js @@ -182,4 +182,32 @@ describe('playgroundxyzBidAdapter', function () { expect(data.user.ext.consent).to.equal('XYZ-CONSENT'); }); }); + + describe('getUserSyncs', function () { + const syncUrl = '//ib.adnxs.com/getuidnb?https://ads.playground.xyz/usersync?partner=appnexus&uid=$UID'; + + describe('when iframeEnabled is true', function () { + const syncOptions = { + 'iframeEnabled': true + } + it('should return one image type user sync pixel', function () { + let result = spec.getUserSyncs(syncOptions); + expect(result.length).to.equal(1); + expect(result[0].type).to.equal('image') + expect(result[0].url).to.equal(syncUrl); + }); + }); + + describe('when iframeEnabled is false', function () { + const syncOptions = { + 'iframeEnabled': false + } + it('should return one image type user sync pixel', function () { + let result = spec.getUserSyncs(syncOptions); + expect(result.length).to.equal(1); + expect(result[0].type).to.equal('image') + expect(result[0].url).to.equal(syncUrl); + }); + }); + }) }); diff --git a/test/spec/modules/prebidServerBidAdapter_spec.js b/test/spec/modules/prebidServerBidAdapter_spec.js index 47d0084d86a..c823e5aa370 100644 --- a/test/spec/modules/prebidServerBidAdapter_spec.js +++ b/test/spec/modules/prebidServerBidAdapter_spec.js @@ -33,6 +33,19 @@ const REQUEST = { 'mediaTypes': { 'banner': { 'sizes': [[ 300, 250 ], [ 300, 300 ]] + }, + 'native': { + 'title': { + 'required': true, + 'len': 800 + }, + 'image': { + 'required': true, + 'sizes': [989, 742], + }, + 'sponsoredBy': { + 'required': true + } } }, 'transactionId': '4ef956ad-fd83-406d-bd35-e4bb786ab86c', @@ -80,6 +93,69 @@ const VIDEO_REQUEST = { ] }; +const OUTSTREAM_VIDEO_REQUEST = { + 'account_id': '1', + 'tid': '437fbbf5-33f5-487a-8e16-a7112903cfe5', + 'max_bids': 1, + 'timeout_millis': 1000, + 'secure': 0, + 'url': '', + 'prebid_version': '1.4.0-pre', + 'ad_units': [ + { + 'code': 'div-gpt-ad-1460505748561-0', + 'sizes': [640, 480], + 'mediaTypes': { + 'video': { + playerSize: [[ 640, 480 ]], + context: 'outstream', + mimes: ['video/mp4'] + }, + banner: { sizes: [[300, 250]] } + }, + 'transactionId': '4ef956ad-fd83-406d-bd35-e4bb786ab86c', + 'bids': [ + { + 'bid_id': '123', + 'bidder': 'appnexus', + 'params': { 'placementId': '12349520' } + } + ] + }, + { + code: 'video1', + mediaTypes: { + video: { + playerSize: [640, 480], + context: 'outstream', + mimes: ['video/mp4'] + } + }, + bids: [ + { + bidder: 'appnexus', + params: { + placementId: 13232385, + video: { + skippable: true, + playback_method: ['auto_play_sound_off'] + } + } + } + ], + renderer: { + url: 'http://acdn.adnxs.com/video/outstream/ANOutstreamVideo.js', + render: function (bid) { + ANOutstreamVideo.renderAd({ + targetId: bid.adUnitCode, + adResponse: bid.adResponse, + }); + } + } + } + ] +}; + let BID_REQUESTS; const RESPONSE = { @@ -319,6 +395,93 @@ const RESPONSE_OPENRTB_VIDEO = { }, }; +const RESPONSE_OPENRTB_NATIVE = { + 'id': 'c7dcf14f', + 'seatbid': [ + { + 'bid': [ + { + 'id': '6451317310275562039', + 'impid': 'div-gpt-ad-1460505748561-0', + 'price': 10, + 'adm': { + 'ver': '1.2', + 'assets': [ + { + 'id': 1, + 'img': { + 'url': 'https://vcdn.adnxs.com/p/creative-image/f8/7f/0f/13/f87f0f13-230c-4f05-8087-db9216e393de.jpg', + 'w': 989, + 'h': 742, + 'ext': { + 'appnexus': { + 'prevent_crop': 0 + } + } + } + }, + { + 'id': 0, + 'title': { + 'text': 'This is a Prebid Native Creative' + } + }, + { + 'id': 2, + 'data': { + 'value': 'Prebid.org' + } + } + ], + 'link': { + 'url': 'https://lax1-ib.adnxs.com/click?AAAAAAAAJEAAAAAAAAAkQAAAAAAAACRAAAAAAAAAJEAAAAAAAAAkQGdce2vBWudAJZpFu1er1zA7ZzddAAAAAOLoyQBtJAAAbSQAAAIAAAC8pM8FnPgWAAAAAABVU0QAVVNEAAEAAQBNXQAAAAABAgMCAAAAALsAuhVqdgAAAAA./cpcpm=AAAAAAAAAAA=/bcr=AAAAAAAA8D8=/pp=${AUCTION_PRICE}/cnd=%213Q5HCQj8-LwKELzJvi4YnPFbIAQoADEAAAAAAAAkQDoJTEFYMTo0MDc3QKcPSQAAAAAAAPA_UQAAAAAAAAAAWQAAAAAAAAAAYQAAAAAAAAAAaQAAAAAAAAAAcQAAAAAAAAAA/cca=OTMyNSNMQVgxOjQwNzc=/bn=84305/test=1/clickenc=http%3A%2F%2Fprebid.org%2Fdev-docs%2Fshow-native-ads.html' + }, + 'eventtrackers': [ + { + 'event': 1, + 'method': 1, + 'url': 'https://lax1-ib.adnxs.com/it?an_audit=0&test=1&referrer=http%3A%2F%2Flocalhost%3A9999%2FintegrationExamples%2Fgpt%2Fdemo_native.html&e=wqT_3QKCCKACBAAAAwDWAAUBCLvO3ekFEOe47duW2NbzQBiltJba--rq6zAqNgkAAAECCCRAEQEHEAAAJEAZEQkAIREJACkRCQAxEQmoMOLRpwY47UhA7UhIAlC8yb4uWJzxW2AAaM26dXjRkgWAAQGKAQNVU0SSAQEG8FKYAQGgAQGoAQGwAQC4AQLAAQPIAQLQAQnYAQDgAQHwAQCKAjt1ZignYScsIDI1Mjk4ODUsIDE1NjM5MTE5OTUpO3VmKCdyJywgOTc0OTQyMDQsIC4eAPQ0AZICnQIhb2pkaWlnajgtTHdLRUx6SnZpNFlBQ0NjOFZzd0FEZ0FRQVJJN1VoUTR0R25CbGdBWVAwQmFBQndBSGdBZ0FFQWlBRUFrQUVCbUFFQm9BRUJxQUVEc0FFQXVRSHpyV3FrQUFBa1FNRUI4NjFxcEFBQUpFREpBVVZpYmxDaFpRQkEyUUVBQUFBQUFBRHdQLUFCQVBVQkFBQUFBUGdCQUpnQ0FLQUNBTFVDQUFBQUFMMENBQUFBQU1BQ0FNZ0NBT0FDQU9nQ0FQZ0NBSUFEQVpBREFKZ0RBYWdEX1BpOENyb0RDVXhCV0RFNk5EQTNOLUFEcHctUUJBQ1lCQUhCQkFBQUFBQUFBQUFBeVFRQUFBQUFBQUFBQU5nRUFBLi6aAoUBITNRNUhDUWo4LUx3S0VMeiUhJG5QRmJJQVFvQUQRvVhBa1FEb0pURUZZTVRvME1EYzNRS2NQUxFUDFBBX1URDAxBQUFXHQwAWR0MAGEdDABjHQz0FwHYAgDgAq2YSOoCPmh0dHA6Ly9sb2NhbGhvc3Q6OTk5OS9pbnRlZ3JhdGlvbkV4YW1wbGVzL2dwdC9kZW1vX25hdGl2ZS5odG1sgAMAiAMBkAMAmAMUoAMBqgMAwAPgqAHIAwDYAwDgAwDoAwD4AwOABACSBAkvb3BlbnJ0YjKYBACiBA0xNzMuMjQ0LjM2LjQwqATtoySyBAwIABAAGAAgADAAOAC4BADABADIBADSBA45MzI1I0xBWDE6NDA3N9oEAggB4AQA8AS8yb4uiAUBmAUAoAX___________8BqgUkZTU5YzNlYjYtNmRkNi00MmQ5LWExMWEtM2FhMTFjOTc5MGUwwAUAyQUAAAAAAADwP9IFCQkAaVh0ANgFAeAFAfAFmfQh-gUECAAQAJAGAZgGALgGAMEGCSQk8D_IBgDaBhYKEAkQGQEBwTTgBgzyBgIIAIAHAYgHAA..&s=11ababa390e9f7983de260493fc5b91ec5b1b3d4&pp=${AUCTION_PRICE}' + } + ] + }, + 'adid': '97494204', + 'adomain': [ + 'http://prebid.org' + ], + 'iurl': 'https://lax1-ib.adnxs.com/cr?id=97494204', + 'cid': '9325', + 'crid': '97494204', + 'cat': [ + 'IAB3-1' + ], + 'ext': { + 'prebid': { + 'targeting': { + 'hb_bidder': 'appnexus', + 'hb_pb': '10.00' + }, + 'type': 'native', + 'video': { + 'duration': 0, + 'primary_category': '' + } + }, + 'bidder': { + 'appnexus': { + 'brand_id': 555545, + 'auction_id': 4676806524825984103, + 'bidder_id': 2, + 'bid_ad_type': 3 + } + } + } + } + ], + 'seat': 'appnexus' + } + ] +}; + const RESPONSE_UNSUPPORTED_BIDDER = { 'tid': '437fbbf5-33f5-487a-8e16-a7112903cfe5', 'status': 'OK', @@ -390,6 +553,18 @@ describe('S2S Adapter', function () { xhr.restore(); }); + it('should not add outstrean without renderer', function() { + let ortb2Config = utils.deepClone(CONFIG); + ortb2Config.endpoint = 'https://prebid.adnxs.com/pbs/v1/openrtb2/auction' + + config.setConfig({s2sConfig: ortb2Config}); + adapter.callBids(OUTSTREAM_VIDEO_REQUEST, BID_REQUESTS, addBidResponse, done, ajax); + + const requestBid = JSON.parse(requests[0].requestBody); + expect(requestBid.imp[0].banner).to.exist; + expect(requestBid.imp[0].video).to.not.exist; + }); + it('exists and is a function', function () { expect(adapter.callBids).to.exist.and.to.be.a('function'); }); @@ -513,38 +688,37 @@ describe('S2S Adapter', function () { }); it('adds digitrust id is present and user is not optout', function () { + let ortb2Config = utils.deepClone(CONFIG); + ortb2Config.endpoint = 'https://prebid.adnxs.com/pbs/v1/openrtb2/auction'; + + let consentConfig = { s2sConfig: ortb2Config }; + config.setConfig(consentConfig); + let digiTrustObj = { - success: true, - identity: { - privacy: { - optout: false - }, - id: 'testId', - keyv: 'testKeyV' - } + privacy: { + optout: false + }, + id: 'testId', + keyv: 'testKeyV' }; - window.DigiTrust = { - getUser: () => digiTrustObj - }; + let digiTrustBidRequest = utils.deepClone(BID_REQUESTS); + digiTrustBidRequest[0].bids[0].userId = { digitrustid: { data: digiTrustObj } }; - adapter.callBids(REQUEST, BID_REQUESTS, addBidResponse, done, ajax); + adapter.callBids(REQUEST, digiTrustBidRequest, addBidResponse, done, ajax); let requestBid = JSON.parse(requests[0].requestBody); - expect(requestBid.digiTrust).to.deep.equal({ - id: digiTrustObj.identity.id, - keyv: digiTrustObj.identity.keyv, - pref: 0 + expect(requestBid.user.ext.digitrust).to.deep.equal({ + id: digiTrustObj.id, + keyv: digiTrustObj.keyv }); - digiTrustObj.identity.privacy.optout = true; + digiTrustObj.privacy.optout = true; - adapter.callBids(REQUEST, BID_REQUESTS, addBidResponse, done, ajax); + adapter.callBids(REQUEST, digiTrustBidRequest, addBidResponse, done, ajax); requestBid = JSON.parse(requests[1].requestBody); - expect(requestBid.digiTrust).to.not.exist; - - delete window.DigiTrust; + expect(requestBid.user && request.user.ext && requestBid.user.ext.digitrust).to.not.exist; }); it('adds device and app objects to request', function () { @@ -567,7 +741,7 @@ describe('S2S Adapter', function () { }); }); - it('adds device and app objects to request for ORTB', function () { + it('adds device and app objects to request for OpenRTB', function () { const s2sConfig = Object.assign({}, CONFIG, { endpoint: 'https://prebid.adnxs.com/pbs/v1/openrtb2/auction' }); @@ -615,6 +789,54 @@ describe('S2S Adapter', function () { }); }); + it('adds native request for OpenRTB', function () { + const s2sConfig = Object.assign({}, CONFIG, { + endpoint: 'https://prebid.adnxs.com/pbs/v1/openrtb2/auction' + }); + + const _config = { + s2sConfig: s2sConfig + }; + + config.setConfig(_config); + adapter.callBids(REQUEST, BID_REQUESTS, addBidResponse, done, ajax); + const requestBid = JSON.parse(requests[0].requestBody); + + expect(requestBid.imp[0].native).to.deep.equal({ + request: JSON.stringify({ + 'context': 1, + 'plcmttype': 1, + 'eventtrackers': [{ + event: 1, + methods: [1] + }], + 'assets': [ + { + 'required': 1, + 'title': { + 'len': 800 + } + }, + { + 'required': 1, + 'img': { + 'type': 3, + 'w': 989, + 'h': 742 + } + }, + { + 'required': 1, + 'data': { + 'type': 1 + } + } + ] + }), + ver: '1.2' + }); + }); + it('adds site if app is not present', function () { const s2sConfig = Object.assign({}, CONFIG, { endpoint: 'https://prebid.adnxs.com/pbs/v1/openrtb2/auction' @@ -813,23 +1035,68 @@ describe('S2S Adapter', function () { it('when userId is defined on bids, it\'s properties should be copied to user.ext.tpid properties', function () { let ortb2Config = utils.deepClone(CONFIG); - ortb2Config.endpoint = 'https://prebid.adnxs.com/pbs/v1/openrtb2/auction' + ortb2Config.endpoint = 'https://prebid.adnxs.com/pbs/v1/openrtb2/auction'; let consentConfig = { s2sConfig: ortb2Config }; config.setConfig(consentConfig); let userIdBidRequest = utils.deepClone(BID_REQUESTS); - userIdBidRequest[0].userId = { - foo: 'abc123', - unifiedid: '1234' + userIdBidRequest[0].bids[0].userId = { + tdid: 'abc123', + pubcid: '1234' }; adapter.callBids(REQUEST, userIdBidRequest, addBidResponse, done, ajax); let requestBid = JSON.parse(requests[0].requestBody); - expect(typeof requestBid.user.ext.tpid).is.equal('object'); - expect(requestBid.user.ext.tpid.foo).is.equal('abc123'); - expect(requestBid.user.ext.tpid.unifiedid).is.equal('1234'); - }) + expect(typeof requestBid.user.ext.eids).is.equal('object'); + expect(Array.isArray(requestBid.user.ext.eids)).to.be.true; + expect(requestBid.user.ext.eids.filter(eid => eid.source === 'adserver.org')).is.not.empty; + expect(requestBid.user.ext.eids.filter(eid => eid.source === 'adserver.org')[0].uids[0].id).is.equal('abc123'); + expect(requestBid.user.ext.eids.filter(eid => eid.source === 'pubcommon')).is.not.empty; + expect(requestBid.user.ext.eids.filter(eid => eid.source === 'pubcommon')[0].uids[0].id).is.equal('1234'); + }); + + it('when config \'currency.adServerCurrency\' value is an array: ORTB has property \'cur\' value set to a single item array', function () { + let s2sConfig = utils.deepClone(CONFIG); + s2sConfig.endpoint = 'https://prebid.adnxs.com/pbs/v1/openrtb2/auction'; + config.setConfig({ + currency: {adServerCurrency: ['USD', 'GB', 'UK', 'AU']}, + s2sConfig: s2sConfig + }); + + const bidRequests = utils.deepClone(BID_REQUESTS); + adapter.callBids(REQUEST, bidRequests, addBidResponse, done, ajax); + + const parsedRequestBody = JSON.parse(requests[0].requestBody); + expect(parsedRequestBody.cur).to.deep.equal(['USD']); + }); + + it('when config \'currency.adServerCurrency\' value is a string: ORTB has property \'cur\' value set to a single item array', function () { + let s2sConfig = utils.deepClone(CONFIG); + s2sConfig.endpoint = 'https://prebid.adnxs.com/pbs/v1/openrtb2/auction'; + config.setConfig({ + currency: {adServerCurrency: 'NZ'}, + s2sConfig: s2sConfig + }); + + const bidRequests = utils.deepClone(BID_REQUESTS); + adapter.callBids(REQUEST, bidRequests, addBidResponse, done, ajax); + + const parsedRequestBody = JSON.parse(requests[1].requestBody); + expect(parsedRequestBody.cur).to.deep.equal(['NZ']); + }); + + it('when config \'currency.adServerCurrency\' is unset: ORTB should not define a \'cur\' property', function () { + let s2sConfig = utils.deepClone(CONFIG); + s2sConfig.endpoint = 'https://prebid.adnxs.com/pbs/v1/openrtb2/auction'; + config.setConfig({s2sConfig: s2sConfig}); + + const bidRequests = utils.deepClone(BID_REQUESTS); + adapter.callBids(REQUEST, bidRequests, addBidResponse, done, ajax); + + const parsedRequestBody = JSON.parse(requests[0].requestBody); + expect(typeof parsedRequestBody.cur).to.equal('undefined'); + }); it('always add ext.prebid.targeting.includebidderkeys: false for ORTB', function () { const s2sConfig = Object.assign({}, CONFIG, { @@ -970,6 +1237,31 @@ describe('S2S Adapter', function () { } }); }); + + it('passes schain object in request', function() { + const bidRequests = utils.deepClone(BID_REQUESTS); + const schainObject = { + 'ver': '1.0', + 'complete': 1, + 'nodes': [ + { + 'asi': 'indirectseller.com', + 'sid': '00001', + 'hp': 1 + }, + + { + 'asi': 'indirectseller-2.com', + 'sid': '00002', + 'hp': 2 + } + ] + }; + bidRequests[0].bids[0].schain = schainObject; + adapter.callBids(REQUEST, bidRequests, addBidResponse, done, ajax); + const parsedRequestBody = JSON.parse(requests[0].requestBody); + expect(parsedRequestBody.source.ext.schain).to.deep.equal(schainObject); + }) }); describe('response handler', function () { @@ -1285,6 +1577,33 @@ describe('S2S Adapter', function () { expect(response).to.have.property('vastUrl', 'https://prebid-cache.net/cache?uuid=a5ad3993'); }); + it('handles OpenRTB native responses', function () { + sinon.stub(utils, 'getBidRequest').returns({ + adUnitCode: 'div-gpt-ad-1460505748561-0', + bidder: 'appnexus', + bidId: '123' + }); + const s2sConfig = Object.assign({}, CONFIG, { + endpoint: 'https://prebidserverurl/openrtb2/auction?querystring=param' + }); + config.setConfig({s2sConfig}); + + server.respondWith(JSON.stringify(RESPONSE_OPENRTB_NATIVE)); + adapter.callBids(REQUEST, BID_REQUESTS, addBidResponse, done, ajax); + server.respond(); + + sinon.assert.calledOnce(addBidResponse); + const response = addBidResponse.firstCall.args[1]; + expect(response).to.have.property('statusMessage', 'Bid available'); + expect(response).to.have.property('adm').deep.equal(RESPONSE_OPENRTB_NATIVE.seatbid[0].bid[0].adm); + expect(response).to.have.property('mediaType', 'native'); + expect(response).to.have.property('bidderCode', 'appnexus'); + expect(response).to.have.property('requestId', '123'); + expect(response).to.have.property('cpm', 10); + + utils.getBidRequest.restore(); + }); + it('should log warning for unsupported bidder', function () { server.respondWith(JSON.stringify(RESPONSE_UNSUPPORTED_BIDDER)); diff --git a/test/spec/modules/prebidmanagerAnalyticsAdapter_spec.js b/test/spec/modules/prebidmanagerAnalyticsAdapter_spec.js new file mode 100644 index 00000000000..cd414a70236 --- /dev/null +++ b/test/spec/modules/prebidmanagerAnalyticsAdapter_spec.js @@ -0,0 +1,117 @@ +import prebidmanagerAnalytics from 'modules/prebidmanagerAnalyticsAdapter'; +import {expect} from 'chai'; +let events = require('src/events'); +let constants = require('src/constants.json'); + +describe('Prebid Manager Analytics Adapter', function () { + let xhr; + let requests; + + let bidWonEvent = { + 'bidderCode': 'appnexus', + 'width': 300, + 'height': 250, + 'adId': '1ebb82ec35375e', + 'mediaType': 'banner', + 'cpm': 0.5, + 'requestId': '1582271863760569973', + 'creative_id': '96846035', + 'creativeId': '96846035', + 'ttl': 60, + 'currency': 'USD', + 'netRevenue': true, + 'auctionId': '9c7b70b9-b6ab-4439-9e71-b7b382797c18', + 'responseTimestamp': 1537521629657, + 'requestTimestamp': 1537521629331, + 'bidder': 'appnexus', + 'adUnitCode': 'div-gpt-ad-1460505748561-0', + 'timeToRespond': 326, + 'size': '300x250', + 'status': 'rendered', + 'eventType': 'bidWon', + 'ad': 'some ad', + 'adUrl': 'ad url' + }; + + before(function () { + xhr = sinon.useFakeXMLHttpRequest(); + xhr.onCreate = request => requests.push(request); + }); + + after(function () { + xhr.restore(); + }); + + describe('Prebid Manager Analytic tests', function () { + beforeEach(function () { + requests = []; + sinon.stub(events, 'getEvents').returns([]); + }); + + afterEach(function () { + prebidmanagerAnalytics.disableAnalytics(); + events.getEvents.restore(); + }); + + it('support custom endpoint', function () { + let custom_url = 'custom url'; + prebidmanagerAnalytics.enableAnalytics({ + provider: 'prebidmanager', + options: { + url: custom_url, + bundleId: 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx' + } + }); + + expect(prebidmanagerAnalytics.getOptions().url).to.equal(custom_url); + }); + + it('bid won event', function() { + xhr.onCreate = request => requests.push(request); + let bundleId = 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'; + prebidmanagerAnalytics.enableAnalytics({ + provider: 'prebidmanager', + options: { + bundleId: bundleId + } + }); + + events.emit(constants.EVENTS.BID_WON, bidWonEvent); + prebidmanagerAnalytics.flush(); + + expect(requests.length).to.equal(1); + expect(requests[0].url).to.equal('https://endpoint.prebidmanager.com/endpoint'); + expect(requests[0].requestBody.substring(0, 2)).to.equal('1:'); + + const pmEvents = JSON.parse(requests[0].requestBody.substring(2)); + expect(pmEvents.pageViewId).to.exist; + expect(pmEvents.bundleId).to.equal(bundleId); + expect(pmEvents.ver).to.equal(1); + expect(pmEvents.events.length).to.equal(2); + expect(pmEvents.events[0].eventType).to.equal('pageView'); + expect(pmEvents.events[1].eventType).to.equal('bidWon'); + expect(pmEvents.events[1].ad).to.be.undefined; + expect(pmEvents.events[1].adUrl).to.be.undefined; + }); + + it('track event without errors', function () { + sinon.spy(prebidmanagerAnalytics, 'track'); + + prebidmanagerAnalytics.enableAnalytics({ + provider: 'prebidmanager', + options: { + bundleId: 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx' + } + }); + + events.emit(constants.EVENTS.AUCTION_INIT, {}); + events.emit(constants.EVENTS.BID_REQUESTED, {}); + events.emit(constants.EVENTS.BID_RESPONSE, {}); + events.emit(constants.EVENTS.BID_WON, {}); + events.emit(constants.EVENTS.AUCTION_END, {}); + events.emit(constants.EVENTS.BID_TIMEOUT, {}); + + sinon.assert.callCount(prebidmanagerAnalytics.track, 6); + }); + }); +}); diff --git a/test/spec/modules/projectLimeLightBidAdapter_spec.js b/test/spec/modules/projectLimeLightBidAdapter_spec.js new file mode 100644 index 00000000000..434b3fbccb5 --- /dev/null +++ b/test/spec/modules/projectLimeLightBidAdapter_spec.js @@ -0,0 +1,170 @@ +import {expect} from 'chai'; +import {spec} from '../../../modules/projectLimeLightBidAdapter'; + +describe('ProjectLimeLightAdapter', function () { + let bid = { + bidId: '2dd581a2b6281d', + bidder: 'project-limelight', + bidderRequestId: '145e1d6a7837c9', + params: { + adUnitId: 123, + adUnitType: 'banner' + }, + placementCode: 'placement_0', + auctionId: '74f78609-a92d-4cf1-869f-1b244bbfb5d2', + sizes: [[300, 250]], + transactionId: '3bb2f6da-87a6-4029-aeb0-bfe951372e62' + }; + + describe('buildRequests', function () { + let serverRequest = spec.buildRequests([bid]); + it('Creates a ServerRequest object with method, URL and data', function () { + expect(serverRequest).to.exist; + expect(serverRequest.method).to.exist; + expect(serverRequest.url).to.exist; + expect(serverRequest.data).to.exist; + }); + it('Returns POST method', function () { + expect(serverRequest.method).to.equal('POST'); + }); + it('Returns valid URL', function () { + expect(serverRequest.url).to.equal('//ads.project-limelight.com/hb'); + }); + it('Returns valid data if array of bids is valid', function () { + let data = serverRequest.data; + expect(data).to.be.an('object'); + expect(data).to.have.all.keys('deviceWidth', 'deviceHeight', 'secure', 'adUnits'); + expect(data.deviceWidth).to.be.a('number'); + expect(data.deviceHeight).to.be.a('number'); + expect(data.secure).to.be.a('boolean'); + let adUnits = data['adUnits']; + for (let i = 0; i < adUnits.length; i++) { + let adUnit = adUnits[i]; + expect(adUnit).to.have.all.keys('id', 'bidId', 'type', 'sizes', 'transactionId'); + expect(adUnit.id).to.be.a('number'); + expect(adUnit.bidId).to.be.a('string'); + expect(adUnit.type).to.be.a('string'); + expect(adUnit.transactionId).to.be.a('string'); + expect(adUnit.sizes).to.be.an('array'); + } + }); + it('Returns empty data if no valid requests are passed', function () { + serverRequest = spec.buildRequests([]); + let data = serverRequest.data; + expect(data.adUnits).to.be.an('array').that.is.empty; + }); + }); + describe('interpretBannerResponse', function () { + let resObject = { + body: [ { + requestId: '123', + mediaType: 'banner', + cpm: 0.3, + width: 320, + height: 50, + ad: '

    Hello ad

    ', + ttl: 1000, + creativeId: '123asd', + netRevenue: true, + currency: 'USD' + } ] + }; + let serverResponses = spec.interpretResponse(resObject); + it('Returns an array of valid server responses if response object is valid', function () { + expect(serverResponses).to.be.an('array').that.is.not.empty; + for (let i = 0; i < serverResponses.length; i++) { + let dataItem = serverResponses[i]; + expect(dataItem).to.have.all.keys('requestId', 'cpm', 'width', 'height', 'ad', 'ttl', 'creativeId', + 'netRevenue', 'currency', 'mediaType'); + expect(dataItem.requestId).to.be.a('string'); + expect(dataItem.cpm).to.be.a('number'); + expect(dataItem.width).to.be.a('number'); + expect(dataItem.height).to.be.a('number'); + expect(dataItem.ad).to.be.a('string'); + expect(dataItem.ttl).to.be.a('number'); + expect(dataItem.creativeId).to.be.a('string'); + expect(dataItem.netRevenue).to.be.a('boolean'); + expect(dataItem.currency).to.be.a('string'); + expect(dataItem.mediaType).to.be.a('string'); + } + it('Returns an empty array if invalid response is passed', function () { + serverResponses = spec.interpretResponse('invalid_response'); + expect(serverResponses).to.be.an('array').that.is.empty; + }); + }); + }); + describe('interpretVideoResponse', function () { + let resObject = { + body: [ { + requestId: '123', + mediaType: 'video', + cpm: 0.3, + width: 320, + height: 50, + vastXml: '', + ttl: 1000, + creativeId: '123asd', + netRevenue: true, + currency: 'USD' + } ] + }; + let serverResponses = spec.interpretResponse(resObject); + it('Returns an array of valid server responses if response object is valid', function () { + expect(serverResponses).to.be.an('array').that.is.not.empty; + for (let i = 0; i < serverResponses.length; i++) { + let dataItem = serverResponses[i]; + expect(dataItem).to.have.all.keys('requestId', 'cpm', 'width', 'height', 'vastXml', 'ttl', 'creativeId', + 'netRevenue', 'currency', 'mediaType'); + expect(dataItem.requestId).to.be.a('string'); + expect(dataItem.cpm).to.be.a('number'); + expect(dataItem.width).to.be.a('number'); + expect(dataItem.height).to.be.a('number'); + expect(dataItem.vastXml).to.be.a('string'); + expect(dataItem.ttl).to.be.a('number'); + expect(dataItem.creativeId).to.be.a('string'); + expect(dataItem.netRevenue).to.be.a('boolean'); + expect(dataItem.currency).to.be.a('string'); + expect(dataItem.mediaType).to.be.a('string'); + } + it('Returns an empty array if invalid response is passed', function () { + serverResponses = spec.interpretResponse('invalid_response'); + expect(serverResponses).to.be.an('array').that.is.empty; + }); + }); + }); + describe('isBidRequestValid', function() { + let bid = { + bidId: '2dd581a2b6281d', + bidder: 'project-limelight', + bidderRequestId: '145e1d6a7837c9', + params: { + adUnitId: 123, + adUnitType: 'banner' + }, + placementCode: 'placement_0', + auctionId: '74f78609-a92d-4cf1-869f-1b244bbfb5d2', + sizes: [[300, 250]], + transactionId: '3bb2f6da-87a6-4029-aeb0-bfe951372e62' + }; + + it('should return true when required params found', function() { + expect(spec.isBidRequestValid(bid)).to.equal(true); + }); + + it('should return false when required params are not passed', function() { + let bidFailed = { + bidder: 'project-limelight', + bidderRequestId: '145e1d6a7837c9', + params: { + adUnitId: 123, + adUnitType: 'banner' + }, + placementCode: 'placement_0', + auctionId: '74f78609-a92d-4cf1-869f-1b244bbfb5d2', + sizes: [[300, 250]], + transactionId: '3bb2f6da-87a6-4029-aeb0-bfe951372e62' + }; + expect(spec.isBidRequestValid(bidFailed)).to.equal(false); + }); + }); +}); diff --git a/test/spec/modules/pubCommonId_spec.js b/test/spec/modules/pubCommonId_spec.js index f648e165c93..fb4a58377c3 100644 --- a/test/spec/modules/pubCommonId_spec.js +++ b/test/spec/modules/pubCommonId_spec.js @@ -5,7 +5,11 @@ import { setConfig, isPubcidEnabled, getExpInterval, - initPubcid } from 'modules/pubCommonId'; + initPubcid, + setStorageItem, + getStorageItem, + removeStorageItem, + getPubcidConfig } from 'modules/pubCommonId'; import { getAdUnits } from 'test/fixtures/fixtures'; import * as auctionModule from 'src/auction'; import { registerBidder } from 'src/adapters/bidderFactory'; @@ -14,16 +18,28 @@ import * as utils from 'src/utils'; var assert = require('chai').assert; var expect = require('chai').expect; -const COOKIE_NAME = '_pubcid'; +const ID_NAME = '_pubcid'; +const EXP = '_exp'; const TIMEOUT = 2000; +const uuidPattern = /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89a-f][0-9a-f]{3}-[0-9a-f]{12}$/; + +function cleanUp() { + window.document.cookie = ID_NAME + '=; expires=Thu, 01 Jan 1970 00:00:01 GMT;'; + localStorage.removeItem(ID_NAME); + localStorage.removeItem(ID_NAME + EXP); +} + describe('Publisher Common ID', function () { afterEach(function () { $$PREBID_GLOBAL$$.requestBids.removeAll(); }); describe('Decorate adUnits', function () { - before(function() { - window.document.cookie = COOKIE_NAME + '=; expires=Thu, 01 Jan 1970 00:00:01 GMT;'; + beforeEach(function() { + cleanUp(); + }); + afterEach(function() { + cleanUp(); }); it('Check same cookie', function () { @@ -31,12 +47,13 @@ describe('Publisher Common ID', function () { let adUnits2 = getAdUnits(); let innerAdUnits1; let innerAdUnits2; - let pubcid = getCookie(COOKIE_NAME); + let pubcid; - expect(pubcid).to.be.null; // there should be no cookie initially + expect(getCookie(ID_NAME)).to.be.null; // there should be no cookie initially + expect(localStorage.getItem(ID_NAME)).to.be.null; // there should be no local storage item either requestBidHook((config) => { innerAdUnits1 = config.adUnits }, {adUnits: adUnits1}); - pubcid = getCookie(COOKIE_NAME); // cookies is created after requestbidHook + pubcid = localStorage.getItem(ID_NAME); // local storage item is created after requestbidHook innerAdUnits1.forEach((unit) => { unit.bids.forEach((bid) => { @@ -44,6 +61,11 @@ describe('Publisher Common ID', function () { expect(bid.crumbs.pubcid).to.equal(pubcid); }); }); + + // verify cookie is null + expect(getCookie(ID_NAME)).to.be.null; + + // verify same pubcid is preserved requestBidHook((config) => { innerAdUnits2 = config.adUnits }, {adUnits: adUnits2}); assert.deepEqual(innerAdUnits1, innerAdUnits2); }); @@ -57,8 +79,10 @@ describe('Publisher Common ID', function () { let pubcid2; requestBidHook((config) => { innerAdUnits1 = config.adUnits }, {adUnits: adUnits1}); - pubcid1 = getCookie(COOKIE_NAME); // get first cookie - setCookie(COOKIE_NAME, '', -1); // erase cookie + pubcid1 = localStorage.getItem(ID_NAME); // get first pubcid + removeStorageItem(ID_NAME); // remove storage + + expect(pubcid1).to.not.be.null; innerAdUnits1.forEach((unit) => { unit.bids.forEach((bid) => { @@ -68,7 +92,7 @@ describe('Publisher Common ID', function () { }); requestBidHook((config) => { innerAdUnits2 = config.adUnits }, {adUnits: adUnits2}); - pubcid2 = getCookie(COOKIE_NAME); // get second cookie + pubcid2 = localStorage.getItem(ID_NAME); // get second pubcid innerAdUnits2.forEach((unit) => { unit.bids.forEach((bid) => { @@ -77,6 +101,7 @@ describe('Publisher Common ID', function () { }); }); + expect(pubcid2).to.not.be.null; expect(pubcid1).to.not.equal(pubcid2); }); @@ -85,7 +110,7 @@ describe('Publisher Common ID', function () { let innerAdUnits; let pubcid = utils.generateUUID(); - setCookie(COOKIE_NAME, pubcid, 600); + setCookie(ID_NAME, pubcid, 600); requestBidHook((config) => { innerAdUnits = config.adUnits }, {adUnits}); innerAdUnits.forEach((unit) => { unit.bids.forEach((bid) => { @@ -94,16 +119,79 @@ describe('Publisher Common ID', function () { }); }); }); + + it('Replicate cookie to storage', function() { + let adUnits = getAdUnits(); + let innerAdUnits; + let pubcid = utils.generateUUID(); + + setCookie(ID_NAME, pubcid, 600); + requestBidHook((config) => { innerAdUnits = config.adUnits }, {adUnits}); + + expect(getStorageItem(ID_NAME)).to.equal(pubcid); + }); + + it('Does not replicate storage to cookie', function() { + let adUnits = getAdUnits(); + let innerAdUnits; + let pubcid = utils.generateUUID(); + + setStorageItem(ID_NAME, pubcid, 600); + requestBidHook((config) => { innerAdUnits = config.adUnits }, {adUnits}); + + expect(getCookie(ID_NAME)).to.be.null; + }); + + it('Cookie only', function() { + setConfig({type: 'cookie'}); + let adUnits = getAdUnits(); + let innerAdUnits; + + requestBidHook((config) => { innerAdUnits = config.adUnits }, {adUnits}); + + expect(getCookie(ID_NAME)).to.match(uuidPattern); + expect(getStorageItem(ID_NAME)).to.be.null; + }); + + it('Storage only', function() { + setConfig({type: 'html5'}); + let adUnits = getAdUnits(); + let innerAdUnits; + + requestBidHook((config) => { innerAdUnits = config.adUnits }, {adUnits}); + + expect(getCookie(ID_NAME)).to.be.null; + expect(getStorageItem(ID_NAME)).to.match(uuidPattern); + }); + + it('Bad id recovery', function() { + let adUnits = getAdUnits(); + let innerAdUnits; + + setStorageItem(ID_NAME, 'undefined', 600); + requestBidHook((config) => { innerAdUnits = config.adUnits }, {adUnits}); + + expect(getStorageItem(ID_NAME)).to.match(uuidPattern); + }); }); describe('Configuration', function () { + beforeEach(() => { + setConfig(); + cleanUp(); + }); + afterEach(() => { + setConfig(); + cleanUp(); + }); + it('empty config', function () { // this should work as usual setConfig({}); let adUnits = getAdUnits(); let innerAdUnits; requestBidHook((config) => { innerAdUnits = config.adUnits }, {adUnits}); - let pubcid = getCookie(COOKIE_NAME); + let pubcid = localStorage.getItem(ID_NAME); innerAdUnits.forEach((unit) => { unit.bids.forEach((bid) => { expect(bid).to.have.deep.nested.property('crumbs.pubcid'); @@ -114,13 +202,12 @@ describe('Publisher Common ID', function () { it('disable', function () { setConfig({enable: false}); - setCookie(COOKIE_NAME, '', -1); // erase cookie let adUnits = getAdUnits(); let unmodified = getAdUnits(); let innerAdUnits; expect(isPubcidEnabled()).to.be.false; requestBidHook((config) => { innerAdUnits = config.adUnits }, {adUnits}); - expect(getCookie(COOKIE_NAME)).to.be.null; + expect(getCookie(ID_NAME)).to.be.null; assert.deepEqual(innerAdUnits, unmodified); setConfig({enable: true}); // reset requestBidHook((config) => { innerAdUnits = config.adUnits }, {adUnits}); @@ -133,7 +220,6 @@ describe('Publisher Common ID', function () { it('change expiration time', function () { setConfig({expInterval: 100}); - setCookie(COOKIE_NAME, '', -1); // erase cookie expect(getExpInterval()).to.equal(100); let adUnits = getAdUnits(); let innerAdUnits; @@ -142,7 +228,24 @@ describe('Publisher Common ID', function () { unit.bids.forEach((bid) => { expect(bid).to.have.deep.nested.property('crumbs.pubcid'); }); - }) + }); + }); + + it('read only', function() { + setConfig({ + readOnly: true + }); + + const config = getPubcidConfig(); + expect(config.readOnly).to.be.true; + expect(config.typeEnabled).to.equal('html5'); + + let adUnits = getAdUnits(); + let innerAdUnits; + requestBidHook((config) => { innerAdUnits = config.adUnits }, {adUnits}); + + const pubcid = localStorage.getItem(ID_NAME); + expect(pubcid).to.be.null; }); }); @@ -192,4 +295,44 @@ describe('Publisher Common ID', function () { }); }); }); + + describe('Storage item functions', () => { + beforeEach(() => { cleanUp(); }); + afterEach(() => { cleanUp(); }); + + it('Test set', () => { + const key = ID_NAME; + const val = 'test-set-value'; + // Set item in localStorage + const now = Date.now(); + setStorageItem(key, val, 100); + // Check both item and expiry time are stored + const expVal = localStorage.getItem(key + EXP); + const storedVal = localStorage.getItem(key); + // Verify expiry + expect(expVal).to.not.be.null; + const expDate = new Date(expVal); + expect((expDate.getTime() - now) / 1000).to.be.closeTo(100 * 60, 5); + // Verify value + expect(storedVal).to.equal(val); + }); + + it('Test get and remove', () => { + const key = ID_NAME; + const val = 'test-get-remove'; + setStorageItem(key, val, 10); + expect(getStorageItem(key)).to.equal(val); + removeStorageItem(key); + expect(getStorageItem(key)).to.be.null; + }); + + it('Test expiry', () => { + const key = ID_NAME; + const val = 'test-expiry'; + setStorageItem(key, val, -1); + expect(localStorage.getItem(key)).to.equal(val); + expect(getStorageItem(key)).to.be.null; + expect(localStorage.getItem(key)).to.be.null; + }); + }); }); diff --git a/test/spec/modules/pubmaticBidAdapter_spec.js b/test/spec/modules/pubmaticBidAdapter_spec.js index bf008574027..3de83c56213 100644 --- a/test/spec/modules/pubmaticBidAdapter_spec.js +++ b/test/spec/modules/pubmaticBidAdapter_spec.js @@ -24,8 +24,27 @@ describe('PubMatic adapter', function () { let bannerVideoAndNativeBidRequests; let bannerBidResponse; let videoBidResponse; + let schainConfig; beforeEach(function () { + schainConfig = { + 'ver': '1.0', + 'complete': 1, + 'nodes': [ + { + 'asi': 'indirectseller.com', + 'sid': '00001', + 'hp': 1 + }, + + { + 'asi': 'indirectseller-2.com', + 'sid': '00002', + 'hp': 2 + } + ] + }; + bidRequests = [ { bidder: 'pubmatic', @@ -55,7 +74,8 @@ describe('PubMatic adapter', function () { bidId: '23acc48ad47af5', requestId: '0fb4905b-9456-4152-86be-c6f6d259ba99', bidderRequestId: '1c56ad30b9b8ca8', - transactionId: '92489f71-1bf2-49a0-adf9-000cea934729' + transactionId: '92489f71-1bf2-49a0-adf9-000cea934729', + schain: schainConfig } ]; @@ -668,27 +688,15 @@ describe('PubMatic adapter', function () { expect(isValid).to.equal(false); }); - it('invalid bid case: adSlot not passed', function () { - let validBid = { - bidder: 'pubmatic', - params: { - publisherId: '301' - } - }, - isValid = spec.isBidRequestValid(validBid); - expect(isValid).to.equal(false); - }); - - it('invalid bid case: adSlot is not string', function () { + it('valid bid case: adSlot is not passed', function () { let validBid = { bidder: 'pubmatic', params: { - publisherId: '301', - adSlot: 15671365 + publisherId: '301' } }, isValid = spec.isBidRequestValid(validBid); - expect(isValid).to.equal(false); + expect(isValid).to.equal(true); }); }); @@ -707,7 +715,7 @@ describe('PubMatic adapter', function () { it('Endpoint checking', function () { let request = spec.buildRequests(bidRequests); - expect(request.url).to.equal('//hbopenbid.pubmatic.com/translator?source=prebid-client'); + expect(request.url).to.equal('https://hbopenbid.pubmatic.com/translator?source=prebid-client'); expect(request.method).to.equal('POST'); }); @@ -740,8 +748,42 @@ describe('PubMatic adapter', function () { expect(data.imp[0].banner.h).to.equal(250); // height expect(data.imp[0].ext.pmZoneId).to.equal(bidRequests[0].params.pmzoneid.split(',').slice(0, 50).map(id => id.trim()).join()); // pmzoneid expect(data.imp[0].bidfloorcur).to.equal(bidRequests[0].params.currency); + expect(data.source.ext.schain).to.deep.equal(bidRequests[0].schain); }); + it('Request params check: without adSlot', function () { + delete bidRequests[0].params.adSlot; + let request = spec.buildRequests(bidRequests); + let data = JSON.parse(request.data); + expect(data.at).to.equal(1); // auction type + expect(data.cur[0]).to.equal('USD'); // currency + expect(data.site.domain).to.be.a('string'); // domain should be set + expect(data.site.page).to.equal(bidRequests[0].params.kadpageurl); // forced pageURL + expect(data.site.publisher.id).to.equal(bidRequests[0].params.publisherId); // publisher Id + expect(data.site.ext).to.exist.and.to.be.an('object'); // dctr parameter + expect(data.site.ext.key_val).to.exist.and.to.equal(bidRequests[0].params.dctr); + expect(data.user.yob).to.equal(parseInt(bidRequests[0].params.yob)); // YOB + expect(data.user.gender).to.equal(bidRequests[0].params.gender); // Gender + expect(data.device.geo.lat).to.equal(parseFloat(bidRequests[0].params.lat)); // Latitude + expect(data.device.geo.lon).to.equal(parseFloat(bidRequests[0].params.lon)); // Lognitude + expect(data.user.geo.lat).to.equal(parseFloat(bidRequests[0].params.lat)); // Latitude + expect(data.user.geo.lon).to.equal(parseFloat(bidRequests[0].params.lon)); // Lognitude + expect(data.ext.wrapper.wv).to.equal($$REPO_AND_VERSION$$); // Wrapper Version + expect(data.ext.wrapper.transactionId).to.equal(bidRequests[0].transactionId); // Prebid TransactionId + expect(data.ext.wrapper.wiid).to.equal(bidRequests[0].params.wiid); // OpenWrap: Wrapper Impression ID + expect(data.ext.wrapper.profile).to.equal(parseInt(bidRequests[0].params.profId)); // OpenWrap: Wrapper Profile ID + expect(data.ext.wrapper.version).to.equal(parseInt(bidRequests[0].params.verId)); // OpenWrap: Wrapper Profile Version ID + + expect(data.imp[0].id).to.equal(bidRequests[0].bidId); // Prebid bid id is passed as id + expect(data.imp[0].bidfloor).to.equal(parseFloat(bidRequests[0].params.kadfloor)); // kadfloor + expect(data.imp[0].tagid).to.deep.equal(undefined); // tagid + expect(data.imp[0].banner.w).to.equal(728); // width + expect(data.imp[0].banner.h).to.equal(90); // height + expect(data.imp[0].banner.format).to.deep.equal([{w: 160, h: 600}]); + expect(data.imp[0].ext.pmZoneId).to.equal(bidRequests[0].params.pmzoneid.split(',').slice(0, 50).map(id => id.trim()).join()); // pmzoneid + expect(data.imp[0].bidfloorcur).to.equal(bidRequests[0].params.currency); + }); + it('Request params multi size format object check', function () { let bidRequests = [ { @@ -1214,6 +1256,76 @@ describe('PubMatic adapter', function () { }); }); + describe('AdsrvrOrgId from userId module', function() { + let sandbox; + beforeEach(() => { + sandbox = sinon.sandbox.create(); + }); + + afterEach(() => { + sandbox.restore(); + }); + + it('Request should have AdsrvrOrgId config params', function() { + bidRequests[0].userId = {}; + bidRequests[0].userId.tdid = 'TTD_ID_FROM_USER_ID_MODULE'; + let request = spec.buildRequests(bidRequests, {}); + let data = JSON.parse(request.data); + expect(data.user.eids).to.deep.equal([{ + 'source': 'adserver.org', + 'uids': [{ + 'id': 'TTD_ID_FROM_USER_ID_MODULE', + 'atype': 1, + 'ext': { + 'rtiPartner': 'TDID' + } + }] + }]); + }); + + it('Request should have adsrvrOrgId from UserId Module if config and userId module both have TTD ID', function() { + sandbox.stub(config, 'getConfig').callsFake((key) => { + var config = { + adsrvrOrgId: { + 'TDID': 'TTD_ID_FROM_CONFIG', + 'TDID_LOOKUP': 'TRUE', + 'TDID_CREATED_AT': '2018-10-01T07:05:40' + } + }; + return config[key]; + }); + bidRequests[0].userId = {}; + bidRequests[0].userId.tdid = 'TTD_ID_FROM_USER_ID_MODULE'; + let request = spec.buildRequests(bidRequests, {}); + let data = JSON.parse(request.data); + expect(data.user.eids).to.deep.equal([{ + 'source': 'adserver.org', + 'uids': [{ + 'id': 'TTD_ID_FROM_USER_ID_MODULE', + 'atype': 1, + 'ext': { + 'rtiPartner': 'TDID' + } + }] + }]); + }); + + it('Request should NOT have adsrvrOrgId params if userId is NOT object', function() { + let request = spec.buildRequests(bidRequests, {}); + let data = JSON.parse(request.data); + expect(data.user.eids).to.deep.equal(undefined); + }); + + it('Request should NOT have adsrvrOrgId params if userId.tdid is NOT string', function() { + bidRequests[0].userId = { + tdid: 1234 + }; + let request = spec.buildRequests(bidRequests, {}); + let data = JSON.parse(request.data); + expect(data.user.eids).to.deep.equal(undefined); + }); + }); + describe('AdsrvrOrgId and Digitrust', function() { // here we are considering cases only of accepting DigiTrustId from config let sandbox; diff --git a/test/spec/modules/pulsepointBidAdapter_spec.js b/test/spec/modules/pulsepointBidAdapter_spec.js index f40a270af11..1d22ca6eadc 100644 --- a/test/spec/modules/pulsepointBidAdapter_spec.js +++ b/test/spec/modules/pulsepointBidAdapter_spec.js @@ -1,8 +1,7 @@ /* eslint dot-notation:0, quote-props:0 */ import {expect} from 'chai'; import {spec} from 'modules/pulsepointBidAdapter'; -import {getTopWindowLocation} from 'src/utils'; -import {newBidder} from 'src/adapters/bidderFactory'; +import {deepClone, getTopWindowLocation} from 'src/utils'; describe('PulsePoint Adapter Tests', function () { const slotConfigs = [{ @@ -48,12 +47,103 @@ describe('PulsePoint Adapter Tests', function () { } } }]; + const videoSlotConfig = [{ + placementCode: '/DfpAccount1/slotVideo', + bidId: 'bid12345', + params: { + cp: 'p10000', + ct: 't10000', + video: { + w: 400, + h: 300, + minduration: 5, + maxduration: 10, + startdelay: 0, + skip: 1, + minbitrate: 200, + protocols: [1, 2, 4] + } + } + }]; + const additionalParamsConfig = [{ + placementCode: '/DfpAccount1/slot1', + bidId: 'bid12345', + params: { + cp: 'p10000', + ct: 't10000', + cf: '1x1', + extra_key1: 'extra_val1', + extra_key2: 12345, + extra_key3: { + key1: 'val1', + key2: 23456, + }, + extra_key4: [1, 2, 3] + } + }]; + + const ortbParamsSlotConfig = [{ + placementCode: '/DfpAccount1/slot1', + bidId: 'bid12345', + params: { + cp: 'p10000', + ct: 't10000', + cf: '1x1', + bcat: ['IAB-1', 'IAB-20'], + battr: [1, 2, 3], + bidfloor: 1.5, + badv: ['cocacola.com', 'lays.com'] + } + }, { + placementCode: '/DfpAccount1/slotVideo', + bidId: 'bid12345', + params: { + cp: 'p10000', + ct: 't10000', + video: { + w: 400, + h: 300, + minduration: 5, + maxduration: 10, + }, + battr: [2, 3, 4], + bidfloor: 2.5, + } + }]; + + const outstreamSlotConfig = [{ + placementCode: '/DfpAccount1/slot1', + mediaTypes: { + video: { + playerSize: [640, 480], + context: 'outstream' + } + }, + bidId: 'bid12345', + params: { + cp: 'p10000', + ct: 't10000', + cf: '1x1', + video: { + h: 300, + w: 400, + minduration: 1, + maxduration: 210, + linearity: 1, + } + }, + renderer: { + options: { + text: 'PulsePoint Outstream' + } + } + }]; it('Verify build request', function () { const request = spec.buildRequests(slotConfigs); - expect(request.url).to.equal('//bid.contextweb.com/header/ortb'); + expect(request.url).to.equal('https://bid.contextweb.com/header/ortb?src=prebid'); expect(request.method).to.equal('POST'); - const ortbRequest = JSON.parse(request.data); + const ortbRequest = request.data; // site object expect(ortbRequest.site).to.not.equal(null); expect(ortbRequest.site.publisher).to.not.equal(null); @@ -78,7 +168,7 @@ describe('PulsePoint Adapter Tests', function () { it('Verify parse response', function () { const request = spec.buildRequests(slotConfigs); - const ortbRequest = JSON.parse(request.data); + const ortbRequest = request.data; const ortbResponse = { seatbid: [{ bid: [{ @@ -107,7 +197,7 @@ describe('PulsePoint Adapter Tests', function () { it('Verify use ttl in ext', function () { const request = spec.buildRequests(slotConfigs); - const ortbRequest = JSON.parse(request.data); + const ortbRequest = request.data; const ortbResponse = { seatbid: [{ bid: [{ @@ -139,9 +229,9 @@ describe('PulsePoint Adapter Tests', function () { it('Verify Native request', function () { const request = spec.buildRequests(nativeSlotConfig); - expect(request.url).to.equal('//bid.contextweb.com/header/ortb'); + expect(request.url).to.equal('https://bid.contextweb.com/header/ortb?src=prebid'); expect(request.method).to.equal('POST'); - const ortbRequest = JSON.parse(request.data); + const ortbRequest = request.data; // native impression expect(ortbRequest.imp[0].tagid).to.equal('t10000'); expect(ortbRequest.imp[0].banner).to.equal(null); @@ -177,9 +267,9 @@ describe('PulsePoint Adapter Tests', function () { it('Verify Native response', function () { const request = spec.buildRequests(nativeSlotConfig); - expect(request.url).to.equal('//bid.contextweb.com/header/ortb'); + expect(request.url).to.equal('https://bid.contextweb.com/header/ortb?src=prebid'); expect(request.method).to.equal('POST'); - const ortbRequest = JSON.parse(request.data); + const ortbRequest = request.data; const nativeResponse = { 'native': { assets: [ @@ -229,8 +319,10 @@ describe('PulsePoint Adapter Tests', function () { }); it('Verifies supported media types', function () { - expect(spec.supportedMediaTypes).to.have.lengthOf(2); + expect(spec.supportedMediaTypes).to.have.lengthOf(3); + expect(spec.supportedMediaTypes[0]).to.equal('banner'); expect(spec.supportedMediaTypes[1]).to.equal('native'); + expect(spec.supportedMediaTypes[2]).to.equal('video'); }); it('Verifies if bid request valid', function () { @@ -251,7 +343,7 @@ describe('PulsePoint Adapter Tests', function () { expect(options).to.not.be.undefined; expect(options).to.have.lengthOf(1); expect(options[0].type).to.equal('iframe'); - expect(options[0].url).to.equal('//bh.contextweb.com/visitormatch'); + expect(options[0].url).to.equal('https://bh.contextweb.com/visitormatch'); }); it('Verifies image pixel sync', function () { @@ -259,12 +351,12 @@ describe('PulsePoint Adapter Tests', function () { expect(options).to.not.be.undefined; expect(options).to.have.lengthOf(1); expect(options[0].type).to.equal('image'); - expect(options[0].url).to.equal('//bh.contextweb.com/visitormatch/prebid'); + expect(options[0].url).to.equal('https://bh.contextweb.com/visitormatch/prebid'); }); it('Verify app requests', function () { const request = spec.buildRequests(appSlotConfig); - const ortbRequest = JSON.parse(request.data); + const ortbRequest = request.data; // site object expect(ortbRequest.site).to.equal(null); expect(ortbRequest.app).to.not.be.null; @@ -283,9 +375,9 @@ describe('PulsePoint Adapter Tests', function () { } }; const request = spec.buildRequests(slotConfigs, bidderRequest); - expect(request.url).to.equal('//bid.contextweb.com/header/ortb'); + expect(request.url).to.equal('https://bid.contextweb.com/header/ortb?src=prebid'); expect(request.method).to.equal('POST'); - const ortbRequest = JSON.parse(request.data); + const ortbRequest = request.data; // user object expect(ortbRequest.user).to.not.equal(null); expect(ortbRequest.user.ext).to.not.equal(null); @@ -295,4 +387,157 @@ describe('PulsePoint Adapter Tests', function () { expect(ortbRequest.regs.ext).to.not.equal(null); expect(ortbRequest.regs.ext.gdpr).to.equal(1); }); + + it('Verify Video request', function () { + const request = spec.buildRequests(videoSlotConfig); + expect(request.url).to.equal('https://bid.contextweb.com/header/ortb?src=prebid'); + expect(request.method).to.equal('POST'); + const ortbRequest = request.data; + expect(ortbRequest).to.not.equal(null); + expect(ortbRequest.imp).to.have.lengthOf(1); + expect(ortbRequest.imp[0].video).to.not.be.null; + expect(ortbRequest.imp[0].native).to.be.null; + expect(ortbRequest.imp[0].banner).to.be.null; + expect(ortbRequest.imp[0].video.w).to.equal(400); + expect(ortbRequest.imp[0].video.h).to.equal(300); + expect(ortbRequest.imp[0].video.minduration).to.equal(5); + expect(ortbRequest.imp[0].video.maxduration).to.equal(10); + expect(ortbRequest.imp[0].video.startdelay).to.equal(0); + expect(ortbRequest.imp[0].video.skip).to.equal(1); + expect(ortbRequest.imp[0].video.minbitrate).to.equal(200); + expect(ortbRequest.imp[0].video.protocols).to.eql([1, 2, 4]); + }); + + it('Verify Video response', function () { + const request = spec.buildRequests(videoSlotConfig); + expect(request.url).to.equal('https://bid.contextweb.com/header/ortb?src=prebid'); + expect(request.method).to.equal('POST'); + const ortbRequest = request.data; + const ortbResponse = { + seatbid: [{ + bid: [{ + impid: ortbRequest.imp[0].id, + price: 1.25, + adm: 'http://pulsepoint.video.mp4' + }] + }] + }; + const bids = spec.interpretResponse({ body: ortbResponse }, request); + const bid = bids[0]; + expect(bid.cpm).to.equal(1.25); + expect(bid.adId).to.equal('bid12345'); + expect(bid.ad).to.be.undefined; + expect(bid['native']).to.be.undefined; + expect(bid.mediaType).to.equal('video'); + expect(bid.vastXml).to.equal(ortbResponse.seatbid[0].bid[0].adm); + }); + + it('Verify extra parameters', function () { + let request = spec.buildRequests(additionalParamsConfig); + let ortbRequest = request.data; + expect(ortbRequest).to.not.equal(null); + expect(ortbRequest.imp).to.have.lengthOf(1); + expect(ortbRequest.imp[0].ext).to.not.equal(null); + expect(ortbRequest.imp[0].ext.prebid).to.not.equal(null); + expect(ortbRequest.imp[0].ext.prebid).to.not.be.null; + expect(ortbRequest.imp[0].ext.prebid.extra_key1).to.equal('extra_val1'); + expect(ortbRequest.imp[0].ext.prebid.extra_key2).to.equal(12345); + expect(ortbRequest.imp[0].ext.prebid.extra_key3).to.not.be.null; + expect(ortbRequest.imp[0].ext.prebid.extra_key3.key1).to.equal('val1'); + expect(ortbRequest.imp[0].ext.prebid.extra_key3.key2).to.equal(23456); + expect(ortbRequest.imp[0].ext.prebid.extra_key4).to.eql([1, 2, 3]); + expect(Object.keys(ortbRequest.imp[0].ext.prebid)).to.eql(['extra_key1', 'extra_key2', 'extra_key3', 'extra_key4']); + // attempting with a configuration with no unknown params. + request = spec.buildRequests(outstreamSlotConfig); + ortbRequest = request.data; + expect(ortbRequest).to.not.equal(null); + expect(ortbRequest.imp).to.have.lengthOf(1); + expect(ortbRequest.imp[0].ext).to.equal(null); + }); + + it('Verify ortb parameters', function () { + const request = spec.buildRequests(ortbParamsSlotConfig); + const ortbRequest = request.data; + expect(ortbRequest).to.not.equal(null); + expect(ortbRequest.bcat).to.eql(['IAB-1', 'IAB-20']); + expect(ortbRequest.badv).to.eql(['cocacola.com', 'lays.com']); + expect(ortbRequest.imp).to.have.lengthOf(2); + expect(ortbRequest.imp[0].bidfloor).to.equal(1.5); + expect(ortbRequest.imp[0].banner.battr).to.eql([1, 2, 3]); + expect(ortbRequest.imp[0].ext).to.be.null; + // slot 2 + expect(ortbRequest.imp[1].bidfloor).to.equal(2.5); + expect(ortbRequest.imp[1].video.battr).to.eql([2, 3, 4]); + expect(ortbRequest.imp[1].ext).to.be.null; + }); + + it('Verify outstream renderer', function () { + const request = spec.buildRequests(outstreamSlotConfig, {bids: [outstreamSlotConfig[0]]}); + const ortbRequest = request.data; + expect(ortbRequest).to.not.be.null; + expect(ortbRequest.imp[0]).to.not.be.null; + expect(ortbRequest.imp[0].video).to.not.be.null; + const ortbResponse = { + seatbid: [{ + bid: [{ + impid: ortbRequest.imp[0].id, + price: 1.25, + adm: 'http://pulsepoint.video.mp4', + ext: { + outstream: { + type: 'Inline', + config: { + text: 'ADVERTISEMENT', + skipaftersec: 5 + }, + rendererUrl: 'http://tag.contextweb.com/hb-outstr-renderer.js' + } + } + }] + }] + }; + const bids = spec.interpretResponse({ body: ortbResponse }, request); + const bid = bids[0]; + expect(bid.cpm).to.equal(1.25); + expect(bid.renderer).to.not.be.null; + expect(bid.renderer.url).to.equal('http://tag.contextweb.com/hb-outstr-renderer.js'); + expect(bid.renderer.getConfig()).to.not.be.null; + expect(bid.renderer.getConfig().defaultOptions).to.eql(ortbResponse.seatbid[0].bid[0].ext.outstream.config); + expect(bid.renderer.getConfig().rendererOptions).to.eql(outstreamSlotConfig[0].renderer.options); + expect(bid.renderer.getConfig().type).to.equal('Inline'); + }); + it('Verify common id parameters', function () { + const bidRequests = deepClone(slotConfigs); + bidRequests[0].userId = { + pubcid: 'userid_pubcid', + tdid: 'userid_ttd', + digitrustid: { + data: { + id: 'userid_digitrust', + keyv: 4, + privacy: {optout: false}, + producer: 'ABC', + version: 2 + } + } + }; + const request = spec.buildRequests(bidRequests); + expect(request).to.be.not.null; + const ortbRequest = request.data; + expect(request.data).to.be.not.null; + // user object + expect(ortbRequest.user).to.not.be.undefined; + expect(ortbRequest.user.ext).to.not.be.undefined; + expect(ortbRequest.user.ext.eids).to.not.be.undefined; + expect(ortbRequest.user.ext.eids).to.have.lengthOf(3); + expect(ortbRequest.user.ext.eids[0].source).to.equal('pubcommon'); + expect(ortbRequest.user.ext.eids[0].uids).to.have.lengthOf(1); + expect(ortbRequest.user.ext.eids[0].uids[0].id).to.equal('userid_pubcid'); + expect(ortbRequest.user.ext.eids[1].source).to.equal('ttdid'); + expect(ortbRequest.user.ext.eids[1].uids).to.have.lengthOf(1); + expect(ortbRequest.user.ext.eids[1].uids[0].id).to.equal('userid_ttd'); + expect(ortbRequest.user.ext.eids[2].source).to.equal('digitrust'); + expect(ortbRequest.user.ext.eids[2].uids).to.have.lengthOf(1); + expect(ortbRequest.user.ext.eids[2].uids[0].id).to.equal('userid_digitrust'); + }); }); diff --git a/test/spec/modules/quantcastBidAdapter_spec.js b/test/spec/modules/quantcastBidAdapter_spec.js index 5a1a905f843..b553cf5d37e 100644 --- a/test/spec/modules/quantcastBidAdapter_spec.js +++ b/test/spec/modules/quantcastBidAdapter_spec.js @@ -1,6 +1,4 @@ -import * as utils from 'src/utils'; import { expect } from 'chai'; -import { stub, sandbox } from 'sinon'; import { QUANTCAST_DOMAIN, QUANTCAST_TEST_DOMAIN, @@ -13,11 +11,11 @@ import { } from '../../../modules/quantcastBidAdapter'; import { newBidder } from '../../../src/adapters/bidderFactory'; import { parse } from 'src/url'; -import * as ajax from 'src/ajax'; describe('Quantcast adapter', function () { const quantcastAdapter = newBidder(qcSpec); let bidRequest; + let bidderRequest; beforeEach(function () { bidRequest = { @@ -32,26 +30,20 @@ describe('Quantcast adapter', function () { }, sizes: [[300, 250]] }; + + bidderRequest = { + refererInfo: { + referer: 'http://example.com/hello.html', + canonicalUrl: 'http://example.com/hello.html' + } + }; }); - function setupVideoBidRequest() { + function setupVideoBidRequest(videoParams) { bidRequest.params = { publisherId: 'test-publisher', // REQUIRED - Publisher ID provided by Quantcast // Video object as specified in OpenRTB 2.5 - video: { - mimes: ['video/mp4'], // required - minduration: 3, // optional - maxduration: 5, // optional - protocols: [3], // optional - startdelay: 1, // optional - linearity: 1, // optinal - battr: [1, 2], // optional - maxbitrate: 10, // optional - playbackmethod: [1], // optional - delivery: [1], // optional - placement: 1, // optional - api: [2, 3] // optional - } + video: videoParams }; bidRequest['mediaTypes'] = { video: { @@ -68,27 +60,25 @@ describe('Quantcast adapter', function () { }); describe('`isBidRequestValid`', function () { - it('should return `false` when bid is not passed', function () { - expect(qcSpec.isBidRequestValid()).to.equal(false); - }); - - it('should return `false` when bid is for outstream video', function () { + it('should return `true` when bid has publisherId', function () { const bidRequest = { - mediaType: 'video', - mediaTypes: { - video: { - context: 'outstream' - } + bidder: 'quantcast', + params: { + publisherId: 'my_publisher_id' } }; - expect(qcSpec.isBidRequestValid(bidRequest)).to.equal(false); + expect(qcSpec.isBidRequestValid(bidRequest)).to.equal(true); }); - it('should return `true` when bid contains required params', function () { - const bidRequest = { mediaType: 'banner' }; + it('should return `false` when bid has no publisherId', function () { + const bidRequest = { + bidder: 'quantcast', + params: { + } + }; - expect(qcSpec.isBidRequestValid(bidRequest)).to.equal(true); + expect(qcSpec.isBidRequestValid(bidRequest)).to.equal(false); }); }); @@ -131,13 +121,6 @@ describe('Quantcast adapter', function () { }); it('sends banner bid requests contains all the required parameters', function () { - const bidderRequest = { - refererInfo: { - referer: 'http://example.com/hello.html', - canonicalUrl: 'http://example.com/hello.html' - } - }; - const requests = qcSpec.buildRequests([bidRequest], bidderRequest); const expectedBannerBidRequest = { publisherId: QUANTCAST_TEST_PUBLISHER, @@ -166,14 +149,20 @@ describe('Quantcast adapter', function () { }); it('sends video bid requests containing all the required parameters', function () { - setupVideoBidRequest(); - - const bidderRequest = { - refererInfo: { - referer: 'http://example.com/hello.html', - canonicalUrl: 'http://example.com/hello.html' - } - }; + setupVideoBidRequest({ + mimes: ['video/mp4'], // required + minduration: 3, // optional + maxduration: 5, // optional + protocols: [3], // optional + startdelay: 1, // optional + linearity: 1, // optinal + battr: [1, 2], // optional + maxbitrate: 10, // optional + playbackmethod: [1], // optional + delivery: [1], // optional + placement: 1, // optional + api: [2, 3] // optional + }); const requests = qcSpec.buildRequests([bidRequest], bidderRequest); const expectedVideoBidRequest = { @@ -213,6 +202,133 @@ describe('Quantcast adapter', function () { expect(requests[0].data).to.equal(JSON.stringify(expectedVideoBidRequest)); }); + + it('overrides video parameters with parameters from adunit', function() { + setupVideoBidRequest({ + mimes: ['video/mp4'] + }); + bidRequest.mediaTypes.video.mimes = ['video/webm']; + + const requests = qcSpec.buildRequests([bidRequest], bidderRequest); + const expectedVideoBidRequest = { + publisherId: QUANTCAST_TEST_PUBLISHER, + requestId: '2f7b179d443f14', + imp: [ + { + video: { + mimes: ['video/webm'], + w: 600, + h: 300 + }, + placementCode: 'div-gpt-ad-1438287399331-0', + bidFloor: 1e-10 + } + ], + site: { + page: 'http://example.com/hello.html', + referrer: 'http://example.com/hello.html', + domain: 'example.com' + }, + bidId: '2f7b179d443f14', + gdprSignal: 0, + prebidJsVersion: '$prebid.version$' + }; + + expect(requests[0].data).to.equal(JSON.stringify(expectedVideoBidRequest)); + }); + + it('sends video bid request when no video parameters are given', function () { + setupVideoBidRequest(null); + + const requests = qcSpec.buildRequests([bidRequest], bidderRequest); + const expectedVideoBidRequest = { + publisherId: QUANTCAST_TEST_PUBLISHER, + requestId: '2f7b179d443f14', + imp: [ + { + video: { + w: 600, + h: 300 + }, + placementCode: 'div-gpt-ad-1438287399331-0', + bidFloor: 1e-10 + } + ], + site: { + page: 'http://example.com/hello.html', + referrer: 'http://example.com/hello.html', + domain: 'example.com' + }, + bidId: '2f7b179d443f14', + gdprSignal: 0, + prebidJsVersion: '$prebid.version$' + }; + + expect(requests[0].data).to.equal(JSON.stringify(expectedVideoBidRequest)); + }); + + it('ignores unsupported video bid requests', function () { + bidRequest.mediaTypes = { + video: { + context: 'outstream', + playerSize: [[550, 310]] + } + }; + + const requests = qcSpec.buildRequests([bidRequest], bidderRequest); + + expect(requests).to.be.empty; + }); + + it('parses multi-format bid request', function () { + bidRequest.mediaTypes = { + banner: {sizes: [[300, 250], [728, 90], [250, 250], [468, 60], [320, 50]]}, + native: { + image: {required: true, sizes: [150, 50]}, + title: {required: true, len: 80}, + sponsoredBy: {required: true}, + clickUrl: {required: true}, + privacyLink: {required: false}, + body: {required: true}, + icon: {required: true, sizes: [50, 50]} + }, + video: { + context: 'outstream', + playerSize: [[550, 310]] + } + }; + bidRequest.sizes = [[300, 250], [728, 90], [250, 250], [468, 60], [320, 50]]; + + const requests = qcSpec.buildRequests([bidRequest], bidderRequest); + const expectedBidRequest = { + publisherId: QUANTCAST_TEST_PUBLISHER, + requestId: '2f7b179d443f14', + imp: [{ + banner: { + battr: [1, 2], + sizes: [ + {width: 300, height: 250}, + {width: 728, height: 90}, + {width: 250, height: 250}, + {width: 468, height: 60}, + {width: 320, height: 50} + ] + }, + placementCode: 'div-gpt-ad-1438287399331-0', + bidFloor: 1e-10 + }], + site: { + page: 'http://example.com/hello.html', + referrer: 'http://example.com/hello.html', + domain: 'example.com' + }, + bidId: '2f7b179d443f14', + gdprSignal: 0, + prebidJsVersion: '$prebid.version$' + }; + + expect(requests[0].data).to.equal(JSON.stringify(expectedBidRequest)); + }); }); it('propagates GDPR consent string and signal', function () { @@ -305,6 +421,26 @@ describe('Quantcast adapter', function () { expect(interpretedResponse[0]).to.deep.equal(expectedResponse); }); + it('should include dealId in bid response', function () { + response.body.bids[0].dealId = 'test-dealid'; + const expectedResponse = { + requestId: 'erlangcluster@qa-rtb002.us-ec.adtech.com-11417780270886458', + cpm: 4.5, + width: 300, + height: 250, + ad: + '
    Quantcast
    ', + ttl: QUANTCAST_TTL, + creativeId: 1001, + netRevenue: QUANTCAST_NET_REVENUE, + currency: 'USD', + dealId: 'test-dealid' + }; + const interpretedResponse = qcSpec.interpretResponse(response); + + expect(interpretedResponse[0]).to.deep.equal(expectedResponse); + }); + it('should get correct bid response for instream video', function() { const expectedResponse = { requestId: 'erlangcluster@qa-rtb002.us-ec.adtech.com-11417780270886458', @@ -334,26 +470,9 @@ describe('Quantcast adapter', function () { body, headers: {} }; - const expectedResponse = []; const interpretedResponse = qcSpec.interpretResponse(response); expect(interpretedResponse.length).to.equal(0); }); }); - - // can't stub ajax with es6 anymore, need to fix this - // describe('`onTimeout`', function() { - // it('makes a request to the notify endpoint', function() { - // const sinonSandbox = sandbox.create(); - // const ajaxStub = sinonSandbox.stub(ajax, 'ajax').callsFake(function() {}); - // const timeoutData = { - // bidder: 'quantcast' - // }; - // qcSpec.onTimeout(timeoutData); - // const expectedUrl = `${QUANTCAST_PROTOCOL}://${QUANTCAST_DOMAIN}:${QUANTCAST_PORT}/qchb_notify?type=timeout`; - // ajaxStub.withArgs(expectedUrl, null, null).calledOnce.should.be.true; - // ajaxStub.restore(); - // sinonSandbox.restore(); - // }); - // }); }); diff --git a/test/spec/modules/rdnBidAdapter_spec.js b/test/spec/modules/rdnBidAdapter_spec.js index 1c5958c8065..8f53502bc44 100644 --- a/test/spec/modules/rdnBidAdapter_spec.js +++ b/test/spec/modules/rdnBidAdapter_spec.js @@ -2,10 +2,20 @@ import { expect } from 'chai' import * as utils from 'src/utils' import { spec } from 'modules/rdnBidAdapter' import { newBidder } from 'src/adapters/bidderFactory' +import {config} from '../../../src/config'; describe('rdnBidAdapter', function() { const adapter = newBidder(spec); const ENDPOINT = 'https://s-bid.rmp.rakuten.co.jp/h'; + let sandbox; + + beforeEach(function() { + config.resetConfig(); + }); + + afterEach(function () { + config.resetConfig(); + }); describe('inherited functions', () => { it('exists and is a function', () => { @@ -53,6 +63,16 @@ describe('rdnBidAdapter', function() { expect(request.url).to.equal(ENDPOINT); expect(request.method).to.equal('GET') }) + + it('allows url override', () => { + config.setConfig({ + rdn: { + endpoint: '//test.rakuten.com' + } + }); + const request = spec.buildRequests(bidRequests)[0]; + expect(request.url).to.equal('//test.rakuten.com'); + }) }); describe('interpretResponse', () => { @@ -75,6 +95,9 @@ describe('rdnBidAdapter', function() { const serverResponse = { noAd: [], + noAd2: { + requestId: 'biequa9oaph4we' + }, banner: { requestId: 'biequa9oaph4we', cpm: 37.66, @@ -93,10 +116,15 @@ describe('rdnBidAdapter', function() { it('handles nobid responses', () => { const result = spec.interpretResponse( { body: serverResponse.noAd }, + bidRequests.banner + ); + expect(result.length).to.equal(0); + const result2 = spec.interpretResponse( + { body: serverResponse.noAd2 }, bidRequests.banner ); - expect(result.length).to.equal(1) + expect(result2.length).to.equal(0); }) }); describe('spec.getUserSyncs', function () { diff --git a/test/spec/modules/realvuAnalyticsAdapter_spec.js b/test/spec/modules/realvuAnalyticsAdapter_spec.js index 1aa1c4be8a5..359fb329359 100644 --- a/test/spec/modules/realvuAnalyticsAdapter_spec.js +++ b/test/spec/modules/realvuAnalyticsAdapter_spec.js @@ -164,5 +164,28 @@ describe('RealVu', function() { let r = boost.readPos(a); expect(r).to.equal(true); }); + + it('send_track', function () { + const a = boost.ads[boost.len - 1]; + boost.track(a, 'show', ''); + boost.sr = 'a'; + boost.send_track(); + expect(boost.beacons.length).to.equal(0); + }); + + it('questA text', function () { + let p = document.createElement('p'); + p.innerHTML = 'ABC'; + document.body.appendChild(p); + let r = boost.questA(p.firstChild); + document.body.removeChild(p); + expect(r).to.not.equal(null); + }); + + it('_f=conf', function () { + const a = boost.ads[boost.len - 1]; + let r = boost.tru(a, 'conf'); + expect(r).to.not.include('_ps='); + }); }); }); diff --git a/test/spec/modules/reloadBidAdapter_spec.js b/test/spec/modules/reloadBidAdapter_spec.js new file mode 100644 index 00000000000..674c810d48a --- /dev/null +++ b/test/spec/modules/reloadBidAdapter_spec.js @@ -0,0 +1,295 @@ +import { expect } from 'chai'; +import { spec } from 'modules/reloadBidAdapter'; + +let getParams = () => { + return JSON.parse(JSON.stringify({ + 'plcmID': 'placement_01', + 'partID': 'part00', + 'opdomID': 1, + 'bsrvID': 1, + 'type': 'pcm' + })); +}; + +let getBidderRequest = () => { + return JSON.parse(JSON.stringify({ + bidderCode: 'reload', + auctionId: 'd3e07445-ab06-44c8-a9dd-5ef9af06d2a6', + bidderRequestId: '7101db09af0db2', + start: new Date().getTime(), + bids: [{ + bidder: 'reload', + bidId: '84ab500420319d', + bidderRequestId: '7101db09af0db2', + auctionId: 'd3e07445-ab06-44c8-a9dd-5ef9af06d2a6', + params: getParams() + }] + })); +}; + +let getValidBidRequests = () => { + return JSON.parse(JSON.stringify([ + { + 'bidder': 'reload', + 'params': getParams(), + 'mediaTypes': { + 'banner': { + 'sizes': [[160, 600]] + } + }, + 'adUnitCode': '1b243858-3c53-43dc-9fdf-89f839ea4a0f', + 'transactionId': '8cbafa10-123d-4673-a1a5-04a1c7d62ded', + 'sizes': [[160, 600]], + 'bidId': '2236e11dc09931', + 'bidderRequestId': '1266bb886c2267', + 'auctionId': '4fb72c4d-94dc-4db1-8fac-3c2090ceeec0', + 'src': 'client', + 'bidRequestsCount': 1 + } + ])); +} + +let getExt1ServerResponse = () => { + return JSON.parse(JSON.stringify({ + 'pcmdata': { + 'thisVer': '100', + 'plcmSett': { + 'name': 'zz_test_mariano_adapter', + 'Version': '210', + 'lifeSpan': '100', + 'versionFolder': 'v4.14q', + 'versionFolderA': 'v4.14q', + 'versionFolderB': '', + 'stage': 'zz_test_mariano_adapter', + 'synchro': 1556916507000, + 'localCache': 'true', + 'testCase': 'A:00_B:100', + 'opdomain': '1', + 'checksum': '6378', + 'cpm': '0', + 'bstfct': '100', + 'totstop': 'false', + 'pcmurl': 'bidsrv01.reload.net' + }, + 'srvUrl': 'bidsrv01.reload.net', + 'instr': {'go': true, 'prc': 32, 'cur': 'USD'}, + 'statStr': 'eyN4aHYnQCk5OTotOC', + 'status': 'ok', + 'message': '', + 'log': '---- LOG ----' + }, + 'plcmID': 'zz_test_mariano_adapter', + 'partID': 'prx_part', + 'opdomID': '0', + 'bsrvID': 1, + 'adUnitCode': '1b243858-3c53-43dc-9fdf-89f839ea4a0f', + 'banner': {'w': 300, 'h': 250} + })); +} + +let getExt2ServerResponse = () => { + return JSON.parse(JSON.stringify({ + 'pcmdata': { + 'thisVer': '100', + 'plcmSett': { + 'name': 'placement_01', + 'Version': '210', + 'lifeSpan': '100', + 'versionFolder': 'v4.14q', + 'versionFolderA': 'v4.14q', + 'versionFolderB': '', + 'stage': 'placement_01', + 'synchro': 1556574760000, + 'localCache': 'true', + 'testCase': 'A:00_B:100', + 'opdomain': '1', + 'checksum': '6378', + 'cpm': '0', + 'bstfct': '100', + 'totstop': 'false', + 'pcmurl': 'bidsrv00.reload.net' + }, + 'srvUrl': 'bidsrv00.reload.net', + 'log': 'incomp_input_obj_version', + 'message': 'incomp_input_obj_version', + 'status': 'error' + }, + 'plcmID': 'placement_01', + 'partID': 'prx_part', + 'opdomID': '0', + 'bsrvID': 1, + 'adUnitCode': '1b243858-3c53-43dc-9fdf-89f839ea4a0f', + 'banner': {'w': 160, 'h': 600} + })); +} + +let getServerResponse = (pExt) => { + return JSON.parse(JSON.stringify({ + 'body': { + 'id': '2759340f70210d', + 'bidid': 'fbs-br-3mzdbycetjv8f8079', + 'seatbid': [ + { + 'bid': [ + { + 'id': 'fbs-br-stbd-bd-3mzdbycetjv8f807b', + 'price': 0, + 'nurl': '', + 'adm': '', + 'ext': pExt + } + ], + 'seat': 'fbs-br-stbd-3mzdbycetjv8f807a', + 'group': 0 + } + ] + }, + 'headers': {} + })); +} + +describe('ReloadAdapter', function () { + describe('isBidRequestValid', function () { + var bid = { + 'bidder': 'reload', + 'params': { + 'plcmID': 'placement_01', + 'partID': 'part00', + 'opdomID': 1, + 'bsrvID': 23, + 'type': 'pcm' + }, + 'adUnitCode': 'adunit-code', + 'sizes': [[300, 250], [300, 600]], + 'bidId': '30b31c1838de1e', + 'bidderRequestId': '22edbae2733bf6', + 'auctionId': '1d1a030790a475', + }; + + it('should return true when required params found', function () { + expect(spec.isBidRequestValid(bid)).to.equal(true); + }); + + it('should return false when bsrvID is not number', function () { + let bid = Object.assign({}, bid); + delete bid.params; + bid.params = { + 'plcmID': 'placement_01', + 'partID': 'part00', + 'opdomID': 1, + 'bsrvID': 'abc' + }; + expect(spec.isBidRequestValid(bid)).to.equal(false); + }); + + it('should return false when bsrvID > 99', function () { + let bid = Object.assign({}, bid); + delete bid.params; + bid.params = { + 'plcmID': 'placement_01', + 'partID': 'part00', + 'opdomID': 1, + 'bsrvID': 230 + }; + expect(spec.isBidRequestValid(bid)).to.equal(false); + }); + + it('should return false when bsrvID < 0', function () { + let bid = Object.assign({}, bid); + delete bid.params; + bid.params = { + 'plcmID': 'placement_01', + 'partID': 'part00', + 'opdomID': 1, + 'bsrvID': -3, + 'type': 'pcm' + }; + expect(spec.isBidRequestValid(bid)).to.equal(false); + }); + + it('should return false when required params are not passed', function () { + let bid = Object.assign({}, bid); + delete bid.params; + bid.params = { + 'plcmID': 'placement_01' + }; + expect(spec.isBidRequestValid(bid)).to.equal(false); + }); + }); + + describe('buildRequests()', function () { + let vRequests = spec.buildRequests(getValidBidRequests(), {}); + let vData = JSON.parse(vRequests[0].data); + + it('should send one requests', () => { + expect(vRequests.length).to.equal(1); + }); + + it('should send one requests, one impression', () => { + expect(vData.imp.length).to.equal(1); + }); + + it('should exists ext.type and ext.pcmdata', () => { + expect(vData.imp[0].banner).to.exist; + expect(vData.imp[0].banner.ext).to.exist; + expect(vData.imp[0].banner.ext.type).to.exist; + expect(vData.imp[0].banner.ext.pcmdata).to.exist; + expect(vData.imp[0].banner.ext.type).to.equal('pcm'); + }); + }); + + describe('interpretResponse()', function () { + it('Returns an empty array', () => { + let vData = spec.interpretResponse(getServerResponse(getExt2ServerResponse()), {}); + + expect(vData.length).to.equal(0); + }); + + it('Returns an array with one response', () => { + let vData = spec.interpretResponse(getServerResponse(getExt1ServerResponse()), {}); + expect(vData.length).to.equal(1); + }); + + it('required fileds', () => { + let vData = spec.interpretResponse(getServerResponse(getExt1ServerResponse()), {}); + expect(vData.length).to.equal(1); + expect(vData[0]).to.have.all.keys(['requestId', 'ad', 'cpm', 'width', 'height', 'creativeId', 'currency', 'ttl', 'netRevenue']); + }); + + it('CPM great than 0', () => { + let vData = spec.interpretResponse(getServerResponse(getExt1ServerResponse()), {}); + expect(vData[0].cpm).to.greaterThan(0); + }); + + it('instruction empty', () => { + let vResponse = Object.assign({}, getServerResponse(getExt1ServerResponse())); + vResponse.body.seatbid[0].bid[0].ext.pcmdata.instr = null; + let vData = spec.interpretResponse(vResponse, {}); + expect(vData.length).to.equal(0); + + vResponse = Object.assign({}, getServerResponse(getExt1ServerResponse())); + vResponse.body.seatbid[0].bid[0].ext.pcmdata.instr = undefined; + vData = spec.interpretResponse(vResponse, {}); + expect(vData.length).to.equal(0); + + vResponse = Object.assign({}, getServerResponse(getExt1ServerResponse())); + vResponse.body.seatbid[0].bid[0].ext.pcmdata.instr.go = undefined; + vData = spec.interpretResponse(vResponse, {}); + expect(vData.length).to.equal(0); + }); + + it('instruction with go = false', () => { + let vResponse = getServerResponse(getExt1ServerResponse()); + vResponse.body.seatbid[0].bid[0].ext.pcmdata.instr.go = false; + let vData = spec.interpretResponse(vResponse, {}); + expect(vData.length).to.equal(0); + }); + + it('incompatibility output object version (thisVer)', () => { + let vResponse = getServerResponse(getExt1ServerResponse()); + vResponse.body.seatbid[0].bid[0].ext.pcmdata.thisVer = '200'; + let vData = spec.interpretResponse(vResponse, {}); + expect(vData.length).to.equal(0); + }); + }); +}); diff --git a/test/spec/modules/rhythmoneBidAdapter_spec.js b/test/spec/modules/rhythmoneBidAdapter_spec.js index 98a7731c324..b6ac09a6207 100644 --- a/test/spec/modules/rhythmoneBidAdapter_spec.js +++ b/test/spec/modules/rhythmoneBidAdapter_spec.js @@ -1,64 +1,77 @@ import {spec} from '../../../modules/rhythmoneBidAdapter'; -var assert = require('assert'); +import * as utils from '../../../src/utils'; +import * as sinon from 'sinon'; + +var r1adapter = spec; describe('rhythmone adapter tests', function () { - describe('rhythmoneResponse', function () { - var z = spec; + beforeEach(function() { + this.defaultBidderRequest = { + 'refererInfo': { + 'referer': 'Reference Page', + 'stack': [ + 'aodomain.dvl', + 'page.dvl' + ] + } + }; + }); - var rmpBannerRequest = z.buildRequests( - [ + describe('Verify 1.0 POST Banner Bid Request', function () { + it('buildRequests works', function () { + var bidRequestList = [ { 'bidder': 'rhythmone', 'params': { - 'placementId': 'abc', - 'keywords': '', - 'categories': [], - 'trace': true, - 'zone': '2345', - 'path': 'mvo', - 'method': 'POST' + 'placementId': 'myplacement', + 'zone': 'myzone', + 'path': 'mypath' }, 'mediaType': 'banner', 'adUnitCode': 'div-gpt-ad-1438287399331-0', - 'sizes': [[300, 250]] + 'sizes': [[300, 250]], + 'transactionId': 'd7b773de-ceaa-484d-89ca-d9f51b8d61ec', + 'bidderRequestId': '418b37f85e772c', + 'auctionId': '18fd8b8b0bd757', + 'bidRequestsCount': 1, + 'bidId': '51ef8751f9aead' } - ], { 'refererInfo': { 'referer': 'Reference Page' } } - ); - - it('Verify POST Banner Bid Request', function () { - expect(rmpBannerRequest.url).to.have.string('//tag.1rx.io/rmp/abc/0/mvo?z=2345&hbv='); - expect(rmpBannerRequest.method).to.equal('POST'); - const bidRequest = JSON.parse(rmpBannerRequest.data); - expect(bidRequest.site).to.not.equal(null); - expect(bidRequest.site.ref).to.equal('Reference Page'); - expect(bidRequest.device).to.not.equal(null); - expect(bidRequest.device.ua).to.equal(navigator.userAgent); - expect(bidRequest.device).to.have.property('dnt'); - expect(bidRequest.imp[0].banner).to.not.equal(null); - expect(bidRequest.imp[0].banner.w).to.equal(300); - expect(bidRequest.imp[0].banner.h).to.equal(250); - expect(bidRequest.imp[0].ext.bidder.zone).to.equal('2345'); - expect(bidRequest.imp[0].ext.bidder.path).to.equal('mvo'); - }); + ]; - var bannerBids = z.interpretResponse({ - body: [ - { - 'impid': 'div-gpt-ad-1438287399331-0', - 'w': 300, - 'h': 250, - 'adm': '
    My ad4 with cpm of a4ab3485f434f74f
    ', - 'price': 1, - 'crid': 'cr-cfy24' - } - ] - }); + var bidRequest = r1adapter.buildRequests(bidRequestList, this.defaultBidderRequest); - it('should register one bid', function() { - assert.equal(bannerBids.length, 1); + expect(bidRequest.url).to.have.string('//tag.1rx.io/rmp/myplacement/0/mypath?z=myzone&hbv='); + expect(bidRequest.method).to.equal('POST'); + const openrtbRequest = JSON.parse(bidRequest.data); + expect(openrtbRequest.site).to.not.equal(null); + expect(openrtbRequest.site.ref).to.equal('Reference Page'); + expect(openrtbRequest.device).to.not.equal(null); + expect(openrtbRequest.device.ua).to.equal(navigator.userAgent); + expect(openrtbRequest.device.dnt).to.equal(0); + expect(openrtbRequest.imp[0].banner).to.not.equal(null); + expect(openrtbRequest.imp[0].banner.format[0].w).to.equal(300); + expect(openrtbRequest.imp[0].banner.format[0].h).to.equal(250); + expect(openrtbRequest.imp[0].ext.bidder.zone).to.equal('myzone'); + expect(openrtbRequest.imp[0].ext.bidder.path).to.equal('mypath'); }); - it('Verify parse banner response', function() { + it('interpretResponse works', function() { + var bidList = { + 'body': [ + { + 'impid': 'div-gpt-ad-1438287399331-0', + 'w': 300, + 'h': 250, + 'adm': '
    My Compelling Ad
    ', + 'price': 1, + 'crid': 'cr-cfy24' + } + ] + }; + + var bannerBids = r1adapter.interpretResponse(bidList); + + expect(bannerBids.length).to.equal(1); const bid = bannerBids[0]; expect(bid.width).to.equal(300); expect(bid.height).to.equal(250); @@ -68,70 +81,78 @@ describe('rhythmone adapter tests', function () { expect(bid.cpm).to.equal(1.0); expect(bid.ttl).to.equal(350); }); + }); - var rmpVideoRequest = z.buildRequests( - [ + describe('Verify POST Video Bid Request', function() { + it('buildRequests works', function () { + var bidRequestList = [ { 'bidder': 'rhythmone', 'params': { - 'placementId': 'xyz', - 'keywords': '', - 'categories': [], - 'trace': true, - 'method': 'POST' + 'placementId': 'myplacement', + 'zone': 'myzone', + 'path': 'mypath' }, 'mediaTypes': { 'video': { - 'playerSize': [[640, 480]], + 'playerSize': [640, 480], 'context': 'instream' } }, - 'placementCode': 'div-gpt-ad-1438287399331-1', - 'sizes': [[300, 250]] + 'adUnitCode': 'div-gpt-ad-1438287399331-1', + 'sizes': [ + [300, 250] + ], + 'transactionId': 'd7b773de-ceaa-484d-89ca-d9f51b8d61ec', + 'bidderRequestId': '418b37f85e772c', + 'auctionId': '18fd8b8b0bd757', + 'bidRequestsCount': 1, + 'bidId': '51ef8751f9aead' } - ], { 'refererInfo': { 'referer': 'Reference Page' } } - ); - - it('Verify POST Video Bid Request', function () { - expect(rmpVideoRequest.url).to.have.string('//tag.1rx.io/rmp/xyz/0/mvo?z=1r&hbv='); - expect(rmpVideoRequest.method).to.equal('POST'); - const bidRequest = JSON.parse(rmpVideoRequest.data); - expect(bidRequest.site).to.not.equal(null); - expect(bidRequest.device).to.not.equal(null); - expect(bidRequest.device.ua).to.equal(navigator.userAgent); - expect(bidRequest.device).to.have.property('dnt'); - expect(bidRequest.imp[0].video).to.not.equal(null); - expect(bidRequest.imp[0].video.w).to.equal(640); - expect(bidRequest.imp[0].video.h).to.equal(480); - expect(bidRequest.imp[0].video.mimes[0]).to.equal('video/mp4'); - expect(bidRequest.imp[0].video.protocols).to.eql([2, 3, 5, 6]); - expect(bidRequest.imp[0].video.startdelay).to.equal(0); - expect(bidRequest.imp[0].video.skip).to.equal(0); - expect(bidRequest.imp[0].video.playbackmethod).to.eql([1, 2, 3, 4]); - expect(bidRequest.imp[0].video.delivery[0]).to.equal(1); - expect(bidRequest.imp[0].video.api).to.eql([1, 2, 5]); - }); + ]; - var videoBids = z.interpretResponse({ - body: [ - { - 'impid': 'div-gpt-ad-1438287399331-1', - 'price': 1, - 'nurl': 'http://testdomain/rmp/placementid/0/path?reqId=1636037', - 'adomain': ['test.com'], - 'cid': '467415', - 'crid': 'cr-vid', - 'w': 800, - 'h': 600 - } - ] - }); + var bidRequest = r1adapter.buildRequests(bidRequestList, this.defaultBidderRequest); - it('should register one bid', function() { - assert.equal(videoBids.length, 1); + expect(bidRequest.url).to.have.string('//tag.1rx.io/rmp/myplacement/0/mypath?z=myzone&hbv='); + expect(bidRequest.method).to.equal('POST'); + const openrtbRequest = JSON.parse(bidRequest.data); + expect(openrtbRequest.site).to.not.equal(null); + expect(openrtbRequest.device).to.not.equal(null); + expect(openrtbRequest.device.ua).to.equal(navigator.userAgent); + expect(openrtbRequest.device).to.have.property('dnt'); + expect(openrtbRequest.imp[0].video).to.not.equal(null); + expect(openrtbRequest.imp[0].video.w).to.equal(640); + expect(openrtbRequest.imp[0].video.h).to.equal(480); + expect(openrtbRequest.imp[0].video.mimes[0]).to.equal('video/mp4'); + expect(openrtbRequest.imp[0].video.protocols).to.eql([2, 3, 5, 6]); + expect(openrtbRequest.imp[0].video.startdelay).to.equal(0); + expect(openrtbRequest.imp[0].video.skip).to.equal(0); + expect(openrtbRequest.imp[0].video.playbackmethod).to.eql([1, 2, 3, 4]); + expect(openrtbRequest.imp[0].video.delivery[0]).to.equal(1); + expect(openrtbRequest.imp[0].video.api).to.eql([1, 2, 5]); }); - it('Verify parse video response', function() { + it('interpretResponse works', function() { + var bidList = { + 'body': [ + { + 'impid': 'div-gpt-ad-1438287399331-1', + 'price': 1, + 'nurl': 'http://testdomain/rmp/placementid/0/path?reqId=1636037', + 'adomain': [ + 'test.com' + ], + 'cid': '467415', + 'crid': 'cr-vid', + 'w': 800, + 'h': 600 + } + ] + }; + + var videoBids = r1adapter.interpretResponse(bidList); + + expect(videoBids.length).to.equal(1); const bid = videoBids[0]; expect(bid.width).to.equal(800); expect(bid.height).to.equal(600); @@ -143,47 +164,23 @@ describe('rhythmone adapter tests', function () { expect(bid.cpm).to.equal(1.0); expect(bid.ttl).to.equal(600); }); + }); - it('should send GDPR Consent data to RhythmOne tag', function () { - let _consentString = 'testConsentString'; - var request = z.buildRequests( - [ - { - 'bidder': 'rhythmone', - 'params': { - 'placementId': 'xyz', - 'keywords': '', - 'categories': [], - 'trace': true, - 'method': 'POST' - }, - 'adUnitCode': 'div-gpt-ad-1438287399331-3', - 'sizes': [[300, 250]] - } - ], {'gdprConsent': {'gdprApplies': true, 'consentString': _consentString}, 'refererInfo': { 'referer': 'Reference Page' }} - ); - const bidRequest = JSON.parse(request.data); - expect(bidRequest.user.ext.consent).to.equal(_consentString); - expect(bidRequest.regs.ext.gdpr).to.equal(true); - }); - - var rmpMultiFormatRequest = z.buildRequests( - [ + describe('Verify Multi-Format ads and Multiple Size Bid Request', function() { + it('buildRequests works', function () { + var bidRequestList = [ { 'bidder': 'rhythmone', 'params': { - 'placementId': 'xyz', - 'keywords': '', - 'categories': [], - 'trace': true, - 'zone': '2345', - 'path': 'mvo', - 'method': 'POST' + 'placementId': 'myplacement', + 'zone': 'myzone', + 'path': 'mypath', }, 'mediaTypes': { 'banner': { 'sizes': [ - [300, 250] + [300, 250], + [300, 600] ] }, 'video': { @@ -192,58 +189,69 @@ describe('rhythmone adapter tests', function () { } }, 'adUnitCode': 'div-gpt-ad-1438287399331-5', - 'sizes': [[300, 250]] + 'transactionId': 'd7b773de-ceaa-484d-89ca-d9f51b8d61ec', + 'bidderRequestId': '418b37f85e772c', + 'auctionId': '18fd8b8b0bd757', + 'bidRequestsCount': 1, + 'bidId': '51ef8751f9aead' } - ], { 'refererInfo': { 'referer': 'Reference Page' } } - ); - - it('Verify Multi-Format ads Bid Request', function () { - const bidRequest = JSON.parse(rmpMultiFormatRequest.data); - expect(bidRequest.site).to.not.equal(null); - expect(bidRequest.site.ref).to.equal('Reference Page'); - expect(bidRequest.device).to.not.equal(null); - expect(bidRequest.device.ua).to.equal(navigator.userAgent); - expect(bidRequest.device).to.have.property('dnt'); - expect(bidRequest.imp[0].video).to.not.equal(null); - expect(bidRequest.imp[0].video.w).to.equal(640); - expect(bidRequest.imp[0].video.h).to.equal(480); - expect(bidRequest.imp[0].video.mimes[0]).to.equal('video/mp4'); - expect(bidRequest.imp[0].video.protocols).to.eql([2, 3, 5, 6]); - expect(bidRequest.imp[0].video.startdelay).to.equal(0); - expect(bidRequest.imp[0].video.skip).to.equal(0); - expect(bidRequest.imp[0].video.playbackmethod).to.eql([1, 2, 3, 4]); - expect(bidRequest.imp[0].video.delivery[0]).to.equal(1); - expect(bidRequest.imp[0].video.api).to.eql([1, 2, 5]); - expect(bidRequest.imp[0].banner).to.not.equal(null); - expect(bidRequest.imp[0].banner.w).to.equal(300); - expect(bidRequest.imp[0].banner.h).to.equal(250); - expect(bidRequest.imp[0].ext.bidder.zone).to.equal('2345'); - expect(bidRequest.imp[0].ext.bidder.path).to.equal('mvo'); - }); + ]; - var forRMPMultiFormatResponse = z.interpretResponse({ - body: { - 'id': '1e810245dd1779', - 'seatbid': [ { - 'bid': [ { - 'impid': 'div-gpt-ad-1438287399331-5', - 'price': 1, - 'nurl': 'http://testdomain/rmp/placementid/0/path?reqId=1636037', - 'adomain': ['test.com'], - 'cid': '467415', - 'crid': 'cr-vid', - 'w': 800, - 'h': 600 - } ] - } ] - } - }); + var bidRequest = r1adapter.buildRequests(bidRequestList, this.defaultBidderRequest); - it('should register one bid', function() { - assert.equal(forRMPMultiFormatResponse.length, 1); + const openrtbRequest = JSON.parse(bidRequest.data); + expect(openrtbRequest.site).to.not.equal(null); + expect(openrtbRequest.site.ref).to.equal('Reference Page'); + expect(openrtbRequest.device).to.not.equal(null); + expect(openrtbRequest.device.ua).to.equal(navigator.userAgent); + expect(openrtbRequest.device).to.have.property('dnt'); + expect(openrtbRequest.imp[0].video).to.not.equal(null); + expect(openrtbRequest.imp[0].video.w).to.equal(640); + expect(openrtbRequest.imp[0].video.h).to.equal(480); + expect(openrtbRequest.imp[0].video.mimes[0]).to.equal('video/mp4'); + expect(openrtbRequest.imp[0].video.protocols).to.eql([2, 3, 5, 6]); + expect(openrtbRequest.imp[0].video.startdelay).to.equal(0); + expect(openrtbRequest.imp[0].video.skip).to.equal(0); + expect(openrtbRequest.imp[0].video.playbackmethod).to.eql([1, 2, 3, 4]); + expect(openrtbRequest.imp[0].video.delivery[0]).to.equal(1); + expect(openrtbRequest.imp[0].video.api).to.eql([1, 2, 5]); + expect(openrtbRequest.imp[0].banner).to.not.equal(null); + expect(openrtbRequest.imp[0].banner.format[0].w).to.equal(300); + expect(openrtbRequest.imp[0].banner.format[0].h).to.equal(250); + expect(openrtbRequest.imp[0].banner.format[1].w).to.equal(300); + expect(openrtbRequest.imp[0].banner.format[1].h).to.equal(600); + expect(openrtbRequest.imp[0].ext.bidder.zone).to.equal('myzone'); + expect(openrtbRequest.imp[0].ext.bidder.path).to.equal('mypath'); }); - it('Verify parse for multi format ad response', function() { + it('interpretResponse works', function() { + var bidList = { + 'body': { + 'id': '1e810245dd1779', + 'seatbid': [ + { + 'bid': [ + { + 'impid': 'div-gpt-ad-1438287399331-5', + 'price': 1, + 'nurl': 'http://testdomain/rmp/placementid/0/path?reqId=1636037', + 'adomain': [ + 'test.com' + ], + 'cid': '467415', + 'crid': 'cr-vid', + 'w': 800, + 'h': 600 + } + ] + } + ] + } + }; + + var forRMPMultiFormatResponse = r1adapter.interpretResponse(bidList); + + expect(forRMPMultiFormatResponse.length).to.equal(1); const bid = forRMPMultiFormatResponse[0]; expect(bid.width).to.equal(800); expect(bid.height).to.equal(600); @@ -255,65 +263,483 @@ describe('rhythmone adapter tests', function () { expect(bid.cpm).to.equal(1.0); expect(bid.ttl).to.equal(600); }); + }); + + describe('misc buildRequests', function() { + it('should send GDPR Consent data to RhythmOne tag', function () { + var bidRequestList = [ + { + 'bidder': 'rhythmone', + 'params': { + 'placementId': 'myplacement', + 'zone': 'myzone', + 'path': 'mypath' + }, + 'mediaTypes': { + 'banner': { + 'sizes': [[300, 250]] + } + }, + 'adUnitCode': 'div-gpt-ad-1438287399331-3', + 'transactionId': 'd7b773de-ceaa-484d-89ca-d9f51b8d61ec', + 'bidderRequestId': '418b37f85e772c', + 'auctionId': '18fd8b8b0bd757', + 'bidRequestsCount': 1, + 'bidId': '51ef8751f9aead' + } + ]; + + var consentString = 'testConsentString'; + var gdprBidderRequest = this.defaultBidderRequest; + gdprBidderRequest.gdprConsent = { + 'gdprApplies': true, + 'consentString': consentString + }; + + var bidRequest = r1adapter.buildRequests(bidRequestList, gdprBidderRequest); + + const openrtbRequest = JSON.parse(bidRequest.data); + expect(openrtbRequest.user.ext.consent).to.equal(consentString); + expect(openrtbRequest.regs.ext.gdpr).to.equal(true); + }); - var noBidResponse = z.interpretResponse({ - body: '' + it('prefer 2.0 sizes', function () { + var bidRequestList = [ + { + 'bidder': 'rhythmone', + 'params': { + 'placementId': 'myplacement', + 'zone': 'myzone', + 'path': 'mypath' + }, + 'mediaTypes': { + 'banner': { + 'sizes': [[300, 600]] + } + }, + 'adUnitCode': 'div-gpt-ad-1438287399331-0', + 'sizes': [[300, 250]], + 'transactionId': 'd7b773de-ceaa-484d-89ca-d9f51b8d61ec', + 'bidderRequestId': '418b37f85e772c', + 'auctionId': '18fd8b8b0bd757', + 'bidRequestsCount': 1, + 'bidId': '51ef8751f9aead' + } + ]; + + var bidRequest = r1adapter.buildRequests(bidRequestList, this.defaultBidderRequest); + + const openrtbRequest = JSON.parse(bidRequest.data); + expect(openrtbRequest.imp[0].banner.format[0].w).to.equal(300); + expect(openrtbRequest.imp[0].banner.format[0].h).to.equal(600); }); - it('No bid response', function() { - assert.equal(noBidResponse.length, 0); + it('does not return request for invalid banner size configuration', function () { + var bidRequestList = [ + { + 'bidder': 'rhythmone', + 'params': { + 'placementId': 'myplacement', + 'zone': 'myzone', + 'path': 'mypath' + }, + 'mediaTypes': { + 'banner': { + 'sizes': [[300]] + } + }, + 'adUnitCode': 'div-gpt-ad-1438287399331-0', + 'transactionId': 'd7b773de-ceaa-484d-89ca-d9f51b8d61ec', + 'bidderRequestId': '418b37f85e772c', + 'auctionId': '18fd8b8b0bd757', + 'bidRequestsCount': 1, + 'bidId': '51ef8751f9aead' + } + ]; + + var bidRequest = r1adapter.buildRequests(bidRequestList, this.defaultBidderRequest); + expect(bidRequest.method).to.be.undefined; }); - describe('isRequiredParamPresent', function () { - var rmpBannerRequest = z.buildRequests( - [ - { - 'bidder': 'rhythmone', - 'params': { - 'keywords': '', - 'categories': [], - 'trace': true, - 'zone': '2345', - 'path': 'mvo', - 'method': 'POST' - }, - 'mediaType': 'banner', - 'adUnitCode': 'div-gpt-ad-1438287399331-0', - 'sizes': [[300, 250]] - } - ], { 'refererInfo': { 'referer': 'Reference Page' } } - ); - it('should return empty when required params not found', function () { - expect(rmpBannerRequest).to.be.empty; - }); + it('does not return request for missing banner size configuration', function () { + var bidRequestList = [ + { + 'bidder': 'rhythmone', + 'params': { + 'placementId': 'myplacement', + 'zone': 'myzone', + 'path': 'mypath' + }, + 'mediaTypes': { + 'banner': {} + }, + 'adUnitCode': 'div-gpt-ad-1438287399331-0', + 'transactionId': 'd7b773de-ceaa-484d-89ca-d9f51b8d61ec', + 'bidderRequestId': '418b37f85e772c', + 'auctionId': '18fd8b8b0bd757', + 'bidRequestsCount': 1, + 'bidId': '51ef8751f9aead' + } + ]; + + var bidRequest = r1adapter.buildRequests(bidRequestList, this.defaultBidderRequest); + expect(bidRequest.method).to.be.undefined; }); - }); - describe('auditBeacon', function() { - var z = spec; - var beaconURL = z.getUserSyncs({pixelEnabled: true})[0]; - it('should contain the correct path', function() { - var u = '//hbevents.1rx.io/audit?'; - assert.equal(beaconURL.url.substring(0, u.length), u); + it('reject bad sizes', function () { + var bidRequestList = [ + { + 'bidder': 'rhythmone', + 'params': { + 'placementId': 'myplacement', + 'zone': 'myzone', + 'path': 'mypath' + }, + 'mediaTypes': { + 'banner': {'sizes': [['400', '500'], ['4n0', '5g0']]} + }, + 'adUnitCode': 'div-gpt-ad-1438287399331-0', + 'transactionId': 'd7b773de-ceaa-484d-89ca-d9f51b8d61ec', + 'bidderRequestId': '418b37f85e772c', + 'auctionId': '18fd8b8b0bd757', + 'bidRequestsCount': 1, + 'bidId': '51ef8751f9aead' + } + ]; + + var bidRequest = r1adapter.buildRequests(bidRequestList, this.defaultBidderRequest); + const openrtbRequest = JSON.parse(bidRequest.data); + expect(openrtbRequest.imp[0].banner.format.length).to.equal(1); + }); + + it('dnt is correctly set to 1', function () { + var bidRequestList = [ + { + 'bidder': 'rhythmone', + 'params': { + 'placementId': 'myplacement', + }, + 'mediaTypes': { + 'banner': { + 'sizes': [[300, 600]] + } + }, + 'adUnitCode': 'div-gpt-ad-1438287399331-0', + 'transactionId': 'd7b773de-ceaa-484d-89ca-d9f51b8d61ec', + 'bidderRequestId': '418b37f85e772c', + 'auctionId': '18fd8b8b0bd757', + 'bidRequestsCount': 1, + 'bidId': '51ef8751f9aead' + } + ]; + + var dntStub = sinon.stub(utils, 'getDNT').returns(1); + + var bidRequest = r1adapter.buildRequests(bidRequestList, this.defaultBidderRequest); + + dntStub.restore(); + + const openrtbRequest = JSON.parse(bidRequest.data); + expect(openrtbRequest.device.dnt).to.equal(1); + }); + + it('sets floor', function () { + var bidRequestList = [ + { + 'bidder': 'rhythmone', + 'params': { + 'placementId': 'myplacement', + 'floor': 100.0 + }, + 'mediaTypes': { + 'banner': { + 'sizes': [[300, 600]] + } + }, + 'adUnitCode': 'div-gpt-ad-1438287399331-0', + 'transactionId': 'd7b773de-ceaa-484d-89ca-d9f51b8d61ec', + 'bidderRequestId': '418b37f85e772c', + 'auctionId': '18fd8b8b0bd757', + 'bidRequestsCount': 1, + 'bidId': '51ef8751f9aead' + } + ]; + + var bidRequest = r1adapter.buildRequests(bidRequestList, this.defaultBidderRequest); + + const openrtbRequest = JSON.parse(bidRequest.data); + expect(openrtbRequest.imp[0].bidfloor).to.equal(100.0); + }); + + it('supports string video sizes', function () { + var bidRequestList = [ + { + 'bidder': 'rhythmone', + 'params': { + 'placementId': 'myplacement', + }, + 'mediaTypes': { + 'video': { + 'context': 'instream', + 'playerSize': ['600', '300'] + } + }, + 'adUnitCode': 'div-gpt-ad-1438287399331-1', + 'transactionId': 'd7b773de-ceaa-484d-89ca-d9f51b8d61ec', + 'bidderRequestId': '418b37f85e772c', + 'auctionId': '18fd8b8b0bd757', + 'bidRequestsCount': 1, + 'bidId': '51ef8751f9aead' + } + ]; + + var bidRequest = r1adapter.buildRequests(bidRequestList, this.defaultBidderRequest); + + const openrtbRequest = JSON.parse(bidRequest.data); + expect(openrtbRequest.imp[0].video.w).to.equal(600); + expect(openrtbRequest.imp[0].video.h).to.equal(300); + }); + + it('rejects bad video sizes', function () { + var bidRequestList = [ + { + 'bidder': 'rhythmone', + 'params': { + 'placementId': 'myplacement', + }, + 'mediaTypes': { + 'video': { + 'context': 'instream', + 'playerSize': ['badWidth', 'badHeight'] + } + }, + 'adUnitCode': 'div-gpt-ad-1438287399331-1', + 'transactionId': 'd7b773de-ceaa-484d-89ca-d9f51b8d61ec', + 'bidderRequestId': '418b37f85e772c', + 'auctionId': '18fd8b8b0bd757', + 'bidRequestsCount': 1, + 'bidId': '51ef8751f9aead' + } + ]; + + var bidRequest = r1adapter.buildRequests(bidRequestList, this.defaultBidderRequest); + + const openrtbRequest = JSON.parse(bidRequest.data); + expect(openrtbRequest.imp[0].video.w).to.be.undefined; + expect(openrtbRequest.imp[0].video.h).to.be.undefined; + }); + + it('supports missing video size', function () { + var bidRequestList = [ + { + 'bidder': 'rhythmone', + 'params': { + 'placementId': 'myplacement', + }, + 'mediaTypes': { + 'video': { + 'context': 'instream' + } + }, + 'adUnitCode': 'div-gpt-ad-1438287399331-1', + 'transactionId': 'd7b773de-ceaa-484d-89ca-d9f51b8d61ec', + 'bidderRequestId': '418b37f85e772c', + 'auctionId': '18fd8b8b0bd757', + 'bidRequestsCount': 1, + 'bidId': '51ef8751f9aead' + } + ]; + + var bidRequest = r1adapter.buildRequests(bidRequestList, this.defaultBidderRequest); + + const openrtbRequest = JSON.parse(bidRequest.data); + expect(openrtbRequest.imp[0].video.w).to.be.undefined; + expect(openrtbRequest.imp[0].video.h).to.be.undefined; + }); + + it('uses default zone and path', function () { + var bidRequestList = [ + { + 'bidder': 'rhythmone', + 'params': { + 'placementId': 'myplacement' + }, + 'mediaTypes': { + 'banner': { + 'sizes': [ + [300, 600] + ] + } + }, + 'adUnitCode': 'div-gpt-ad-1438287399331-0', + 'transactionId': 'd7b773de-ceaa-484d-89ca-d9f51b8d61ec', + 'bidderRequestId': '418b37f85e772c', + 'auctionId': '18fd8b8b0bd757', + 'bidRequestsCount': 1, + 'bidId': '51ef8751f9aead' + } + ]; + + var bidRequest = r1adapter.buildRequests(bidRequestList, this.defaultBidderRequest); + + const openrtbRequest = JSON.parse(bidRequest.data); + expect(openrtbRequest.imp[0].ext.bidder.zone).to.equal('1r'); + expect(openrtbRequest.imp[0].ext.bidder.path).to.equal('mvo'); + }); + + it('should return empty when required params not found', function () { + var bidRequestList = [ + { + 'bidder': 'rhythmone', + 'params': { + 'zone': 'myzone', + 'path': 'mypath' + }, + 'mediaTypes': { + 'banner': { + 'sizes': [ + [300, 250] + ] + } + }, + 'adUnitCode': 'div-gpt-ad-1438287399331-3', + 'transactionId': 'd7b773de-ceaa-484d-89ca-d9f51b8d61ec', + 'bidderRequestId': '418b37f85e772c', + 'auctionId': '18fd8b8b0bd757', + 'bidRequestsCount': 1, + 'bidId': '51ef8751f9aead' + } + ]; + + var bidRequest = r1adapter.buildRequests(bidRequestList, this.defaultBidderRequest); + + expect(bidRequest).to.be.empty; }); - beaconURL = z.getUserSyncs({pixelEnabled: true}, null, {'gdprApplies': true, 'consentString': 'testConsentString'})[0]; - it('should send GDPR Consent data to Sync pixel', function () { - expect(beaconURL.url).to.have.string('&gdpr=true&gdpr_consent=testConsentString'); + it('should return empty site data when refererInfo is missing', function() { + delete this.defaultBidderRequest.refererInfo; + var bidRequestList = [ + { + 'bidder': 'rhythmone', + 'params': { + 'placementId': 'myplacement', + 'zone': 'myzone', + 'path': 'mypath' + }, + 'mediaType': 'banner', + 'adUnitCode': 'div-gpt-ad-1438287399331-0', + 'sizes': [[300, 250]], + 'transactionId': 'd7b773de-ceaa-484d-89ca-d9f51b8d61ec', + 'bidderRequestId': '418b37f85e772c', + 'auctionId': '18fd8b8b0bd757', + 'bidRequestsCount': 1, + 'bidId': '51ef8751f9aead' + } + ]; + + var bidRequest = r1adapter.buildRequests(bidRequestList, this.defaultBidderRequest); + const openrtbRequest = JSON.parse(bidRequest.data); + + expect(openrtbRequest.site.domain).to.equal(''); + expect(openrtbRequest.site.page).to.equal(''); + expect(openrtbRequest.site.ref).to.equal(''); }); }); + + it('should return empty site.domain and site.page when refererInfo.stack is empty', function() { + this.defaultBidderRequest.refererInfo.stack = []; + var bidRequestList = [ + { + 'bidder': 'rhythmone', + 'params': { + 'placementId': 'myplacement', + 'zone': 'myzone', + 'path': 'mypath' + }, + 'mediaType': 'banner', + 'adUnitCode': 'div-gpt-ad-1438287399331-0', + 'sizes': [[300, 250]], + 'transactionId': 'd7b773de-ceaa-484d-89ca-d9f51b8d61ec', + 'bidderRequestId': '418b37f85e772c', + 'auctionId': '18fd8b8b0bd757', + 'bidRequestsCount': 1, + 'bidId': '51ef8751f9aead' + } + ]; + + var bidRequest = r1adapter.buildRequests(bidRequestList, this.defaultBidderRequest); + const openrtbRequest = JSON.parse(bidRequest.data); + + expect(openrtbRequest.site.domain).to.equal(''); + expect(openrtbRequest.site.page).to.equal(''); + expect(openrtbRequest.site.ref).to.equal('Reference Page'); + }); + + it('should secure correctly', function() { + this.defaultBidderRequest.refererInfo.stack[0] = ['https://securesite.dvl']; + var bidRequestList = [ + { + 'bidder': 'rhythmone', + 'params': { + 'placementId': 'myplacement', + 'zone': 'myzone', + 'path': 'mypath' + }, + 'mediaType': 'banner', + 'adUnitCode': 'div-gpt-ad-1438287399331-0', + 'sizes': [[300, 250]], + 'transactionId': 'd7b773de-ceaa-484d-89ca-d9f51b8d61ec', + 'bidderRequestId': '418b37f85e772c', + 'auctionId': '18fd8b8b0bd757', + 'bidRequestsCount': 1, + 'bidId': '51ef8751f9aead' + } + ]; + + var bidRequest = r1adapter.buildRequests(bidRequestList, this.defaultBidderRequest); + const openrtbRequest = JSON.parse(bidRequest.data); + + expect(openrtbRequest.imp[0].secure).to.equal(1); + }); + + describe('misc interpretResponse', function () { + it('No bid response', function() { + var noBidResponse = r1adapter.interpretResponse({ + 'body': '' + }); + expect(noBidResponse.length).to.equal(0); + }); + }); + describe('isBidRequestValid', function () { - let bid = { + var bid = { 'bidder': 'rhythmone', 'params': { - 'placementId': '469127' + 'placementId': 'myplacement', + 'path': 'mypath', + 'zone': 'myzone' }, - 'adUnitCode': 'bannerDiv', - 'sizes': [[300, 250]] + 'mediaTypes': { + 'banner': { + 'sizes': [[300, 250]] + } + }, + 'adUnitCode': 'bannerDiv' }; it('should return true when required params found', function () { - expect(spec.isBidRequestValid(bid)).to.equal(true); + expect(r1adapter.isBidRequestValid(bid)).to.equal(true); + }); + + it('should return false when placementId missing', function () { + delete bid.params.placementId; + expect(r1adapter.isBidRequestValid(bid)).to.equal(false); + }); + }); + + describe('getUserSyncs', function () { + it('returns an empty string', function () { + expect(r1adapter.getUserSyncs()).to.deep.equal([]); }); }); }); diff --git a/test/spec/modules/richAudienceBidAdapter_spec.js b/test/spec/modules/richaudienceBidAdapter_spec.js similarity index 97% rename from test/spec/modules/richAudienceBidAdapter_spec.js rename to test/spec/modules/richaudienceBidAdapter_spec.js index 689c29a2646..16d67ce7ceb 100644 --- a/test/spec/modules/richAudienceBidAdapter_spec.js +++ b/test/spec/modules/richaudienceBidAdapter_spec.js @@ -1,13 +1,12 @@ // import or require modules necessary for the test, e.g.: import {expect} from 'chai'; // may prefer 'assert' in place of 'expect' -// import spec from 'modules/richAudienceBidAdapter'; import { spec -} from 'modules/richAudienceBidAdapter'; +} from 'modules/richaudienceBidAdapter'; import {config} from 'src/config'; import * as utils from 'src/utils'; -describe('Rich Audience adapter tests', function () { +describe('Richaudience adapter tests', function () { var DEFAULT_PARAMS = [{ adUnitCode: 'test-div', bidId: '2c7c8e9c900244', @@ -81,7 +80,9 @@ describe('Rich Audience adapter tests', function () { creative_id: '189198063', netRevenue: true, currency: 'USD', - ttl: 300 + ttl: 300, + dealId: 'dealId' + } }; @@ -95,7 +96,8 @@ describe('Rich Audience adapter tests', function () { netRevenue: true, currency: 'USD', ttl: 300, - vastXML: '' + vastXML: '', + dealId: 'dealId' } }; @@ -228,6 +230,7 @@ describe('Rich Audience adapter tests', function () { expect(bid.netRevenue).to.equal(true); expect(bid.currency).to.equal('USD'); expect(bid.ttl).to.equal(300); + expect(bid.dealId).to.equal('dealId'); }); it('no banner media response', function () { diff --git a/test/spec/modules/rubiconAnalyticsAdapter_spec.js b/test/spec/modules/rubiconAnalyticsAdapter_spec.js index efb7a1725e7..9c005c3394f 100644 --- a/test/spec/modules/rubiconAnalyticsAdapter_spec.js +++ b/test/spec/modules/rubiconAnalyticsAdapter_spec.js @@ -1,7 +1,12 @@ -import rubiconAnalyticsAdapter, { SEND_TIMEOUT } from 'modules/rubiconAnalyticsAdapter'; +import rubiconAnalyticsAdapter, { SEND_TIMEOUT, parseBidResponse } from 'modules/rubiconAnalyticsAdapter'; import CONSTANTS from 'src/constants.json'; import { config } from 'src/config'; +import { + setConfig, + addBidResponseHook, +} from 'modules/currency'; + let Ajv = require('ajv'); let schema = require('./rubiconAnalyticsSchema.json'); let ajv = new Ajv({ @@ -448,7 +453,8 @@ const ANALYTICS_MESSAGE = { }, 'bidwonStatus': 'success' } - ] + ], + 'wrapperName': '10000_fakewrapper_test' }; function performStandardAuction() { @@ -487,6 +493,9 @@ describe('rubicon analytics adapter', function () { s2sConfig: { timeout: 1000, accountId: 10000, + }, + rubicon: { + wrapperName: '10000_fakewrapper_test' } }) }); @@ -694,5 +703,60 @@ describe('rubicon analytics adapter', function () { expect(timedOutBid.error.code).to.equal('timeout-error'); expect(timedOutBid).to.not.have.property('bidResponse'); }); + + it('should successfully convert bid price to USD in parseBidResponse', function () { + // Set the rates + setConfig({ + adServerCurrency: 'JPY', + rates: { + USD: { + JPY: 100 + } + } + }); + + // set our bid response to JPY + const bidCopy = utils.deepClone(BID2); + bidCopy.currency = 'JPY'; + bidCopy.cpm = 100; + + // Now add the bidResponse hook which hooks on the currenct conversion function onto the bid response + let innerBid; + addBidResponseHook(function(adCodeId, bid) { + innerBid = bid; + }, 'elementId', bidCopy); + + // Use the rubi analytics parseBidResponse Function to get the resulting cpm from the bid response! + const bidResponseObj = parseBidResponse(innerBid); + expect(bidResponseObj).to.have.property('bidPriceUSD'); + expect(bidResponseObj.bidPriceUSD).to.equal(1.0); + }); + }); + + describe('config with integration type', () => { + it('should use the integration type provided in the config instead of the default', () => { + sandbox.stub(config, 'getConfig').callsFake(function (key) { + const config = { + 'rubicon.int_type': 'testType' + }; + return config[key]; + }); + + rubiconAnalyticsAdapter.enableAnalytics({ + options: { + endpoint: '//localhost:9999/event', + accountId: 1001 + } + }); + + performStandardAuction(); + + expect(requests.length).to.equal(1); + const request = requests[0]; + const message = JSON.parse(request.requestBody); + expect(message.integration).to.equal('testType'); + + rubiconAnalyticsAdapter.disableAnalytics(); + }); }); }); diff --git a/test/spec/modules/rubiconAnalyticsSchema.json b/test/spec/modules/rubiconAnalyticsSchema.json index b856bf584e9..686aced840f 100644 --- a/test/spec/modules/rubiconAnalyticsSchema.json +++ b/test/spec/modules/rubiconAnalyticsSchema.json @@ -191,6 +191,9 @@ } ] } + }, + "wrapperName": { + "type": "string" } }, "definitions": { diff --git a/test/spec/modules/rubiconBidAdapter_spec.js b/test/spec/modules/rubiconBidAdapter_spec.js index f3b244b1bc1..8d65e1e97b4 100644 --- a/test/spec/modules/rubiconBidAdapter_spec.js +++ b/test/spec/modules/rubiconBidAdapter_spec.js @@ -353,6 +353,28 @@ describe('the rubicon adapter', function () { }); }); + it('should not send p_pos to AE if not params.position specified', function() { + var noposRequest = utils.deepClone(bidderRequest); + delete noposRequest.bids[0].params.position; + + let [request] = spec.buildRequests(noposRequest.bids, noposRequest); + let data = parseQuery(request.data); + + expect(data['site_id']).to.equal('70608'); + expect(data['p_pos']).to.equal(undefined); + }); + + it('should not send p_pos to AE if not params.position is invalid', function() { + var badposRequest = utils.deepClone(bidderRequest); + badposRequest.bids[0].params.position = 'bad'; + + let [request] = spec.buildRequests(badposRequest.bids, badposRequest); + let data = parseQuery(request.data); + + expect(data['site_id']).to.equal('70608'); + expect(data['p_pos']).to.equal(undefined); + }); + it('ad engine query params should be ordered correctly', function () { sandbox.stub(Math, 'random').callsFake(() => 0.1); let [request] = spec.buildRequests(bidderRequest.bids, bidderRequest); @@ -470,7 +492,7 @@ describe('the rubicon adapter', function () { }); it('should use rubicon sizes if present (including non-mappable sizes)', function () { - var sizesBidderRequest = clone(bidderRequest); + var sizesBidderRequest = utils.deepClone(bidderRequest); sizesBidderRequest.bids[0].params.sizes = [55, 57, 59, 801]; let [request] = spec.buildRequests(sizesBidderRequest.bids, sizesBidderRequest); @@ -481,7 +503,7 @@ describe('the rubicon adapter', function () { }); it('should not validate bid request if no valid sizes', function () { - var sizesBidderRequest = clone(bidderRequest); + var sizesBidderRequest = utils.deepClone(bidderRequest); sizesBidderRequest.bids[0].sizes = [[621, 250], [300, 251]]; let result = spec.isBidRequestValid(sizesBidderRequest.bids[0]); @@ -490,7 +512,7 @@ describe('the rubicon adapter', function () { }); it('should not validate bid request if no account id is present', function () { - var noAccountBidderRequest = clone(bidderRequest); + var noAccountBidderRequest = utils.deepClone(bidderRequest); delete noAccountBidderRequest.bids[0].params.accountId; let result = spec.isBidRequestValid(noAccountBidderRequest.bids[0]); @@ -499,7 +521,7 @@ describe('the rubicon adapter', function () { }); it('should allow a floor override', function () { - var floorBidderRequest = clone(bidderRequest); + var floorBidderRequest = utils.deepClone(bidderRequest); floorBidderRequest.bids[0].params.floor = 2; let [request] = spec.buildRequests(floorBidderRequest.bids, floorBidderRequest); @@ -876,17 +898,17 @@ describe('the rubicon adapter', function () { 'rf': 'localhost' }; - const bidCopy = clone(bidderRequest.bids[0]); + const bidCopy = utils.deepClone(bidderRequest.bids[0]); bidCopy.params.siteId = '70608'; bidCopy.params.zoneId = '1111'; bidderRequest.bids.push(bidCopy); - const bidCopy2 = clone(bidderRequest.bids[0]); + const bidCopy2 = utils.deepClone(bidderRequest.bids[0]); bidCopy2.params.siteId = '99999'; bidCopy2.params.zoneId = '2222'; bidderRequest.bids.push(bidCopy2); - const bidCopy3 = clone(bidderRequest.bids[0]); + const bidCopy3 = utils.deepClone(bidderRequest.bids[0]); bidCopy3.params.siteId = '99999'; bidCopy3.params.zoneId = '3333'; bidderRequest.bids.push(bidCopy3); @@ -957,7 +979,7 @@ describe('the rubicon adapter', function () { }); }); - it('should not send more than 10 bids in a request', function () { + it('should not send more than 10 bids in a request (split into separate requests with <= 10 bids each)', function () { sandbox.stub(config, 'getConfig').callsFake((key) => { const config = { 'rubicon.singleRequest': true @@ -965,27 +987,44 @@ describe('the rubicon adapter', function () { return config[key]; }); - for (let i = 0; i < 20; i++) { - let bidCopy = clone(bidderRequest.bids[0]); + let serverRequests; + let data; + + // TEST '10' BIDS, add 9 to 1 existing bid + for (let i = 0; i < 9; i++) { + let bidCopy = utils.deepClone(bidderRequest.bids[0]); bidCopy.params.zoneId = `${i}0000`; bidderRequest.bids.push(bidCopy); } - - const serverRequests = spec.buildRequests(bidderRequest.bids, bidderRequest); - - // if bids are greater than 10, additional bids are dropped + serverRequests = spec.buildRequests(bidderRequest.bids, bidderRequest); + // '10' bids per SRA request: so there should be 1 request + expect(serverRequests.length).to.equal(1); + // and that one request should have data from 10 bids expect(serverRequests[0].bidRequest).to.have.lengthOf(10); - // check that slots param value matches - const foundSlotsCount = serverRequests[0].data.indexOf('&slots=10&'); - expect(foundSlotsCount !== -1).to.equal(true); - + expect(serverRequests[0].data.indexOf('&slots=10&') !== -1).to.equal(true); // check that zone_id has 10 values (since all zone_ids are unique all should exist in get param) - const data = parseQuery(serverRequests[0].data); - + data = parseQuery(serverRequests[0].data); expect(data).to.be.a('object'); expect(data).to.have.property('zone_id'); expect(data.zone_id.split(';')).to.have.lengthOf(10); + + // TEST '100' BIDS, add 90 to the previously added 10 + for (let i = 0; i < 90; i++) { + let bidCopy = utils.deepClone(bidderRequest.bids[0]); + bidCopy.params.zoneId = `${(i + 10)}0000`; + bidderRequest.bids.push(bidCopy); + } + serverRequests = spec.buildRequests(bidderRequest.bids, bidderRequest); + // '100' bids: should be '10' SRA requests + expect(serverRequests.length).to.equal(10); + // check that each request has 10 items + serverRequests.forEach((serverRequest) => { + // and that one request should have data from 10 bids + expect(serverRequest.bidRequest).to.have.lengthOf(10); + // check that slots param value matches + expect(serverRequest.data.indexOf('&slots=10&') !== -1).to.equal(true); + }); }); it('should not group bid requests if singleRequest does not equal true', function () { @@ -996,14 +1035,14 @@ describe('the rubicon adapter', function () { return config[key]; }); - const bidCopy = clone(bidderRequest.bids[0]); + const bidCopy = utils.deepClone(bidderRequest.bids[0]); bidderRequest.bids.push(bidCopy); - const bidCopy2 = clone(bidderRequest.bids[0]); + const bidCopy2 = utils.deepClone(bidderRequest.bids[0]); bidCopy2.params.siteId = '32001'; bidderRequest.bids.push(bidCopy2); - const bidCopy3 = clone(bidderRequest.bids[0]); + const bidCopy3 = utils.deepClone(bidderRequest.bids[0]); bidCopy3.params.siteId = '32001'; bidderRequest.bids.push(bidCopy3); @@ -1019,18 +1058,18 @@ describe('the rubicon adapter', function () { return config[key]; }); - const bidCopy = clone(bidderRequest.bids[0]); + const bidCopy = utils.deepClone(bidderRequest.bids[0]); bidderRequest.bids.push(bidCopy); - const bidCopy2 = clone(bidderRequest.bids[0]); + const bidCopy2 = utils.deepClone(bidderRequest.bids[0]); bidCopy2.params.siteId = '32001'; bidderRequest.bids.push(bidCopy2); - const bidCopy3 = clone(bidderRequest.bids[0]); + const bidCopy3 = utils.deepClone(bidderRequest.bids[0]); bidCopy3.params.siteId = '32001'; bidderRequest.bids.push(bidCopy3); - const bidCopy4 = clone(bidderRequest.bids[0]); + const bidCopy4 = utils.deepClone(bidderRequest.bids[0]); bidCopy4.mediaTypes = { video: { context: 'instream', @@ -1063,7 +1102,7 @@ describe('the rubicon adapter', function () { describe('user id config', function() { it('should send tpid_tdid when userId defines tdid', function () { - const clonedBid = clone(bidderRequest.bids[0]); + const clonedBid = utils.deepClone(bidderRequest.bids[0]); clonedBid.userId = { tdid: 'abcd-efgh-ijkl-mnop-1234' }; @@ -1118,39 +1157,64 @@ describe('the rubicon adapter', function () { expect(post.ext.prebid.cache.vastxml.returnCreative).to.equal(false) }); + it('should send correct bidfloor to PBS', function() { + createVideoBidderRequest(); + + bidderRequest.bids[0].params.floor = 0.1; + let [request] = spec.buildRequests(bidderRequest.bids, bidderRequest); + expect(request.data.imp[0].bidfloor).to.equal(0.1); + + bidderRequest.bids[0].params.floor = 5.5; + [request] = spec.buildRequests(bidderRequest.bids, bidderRequest); + expect(request.data.imp[0].bidfloor).to.equal(5.5); + + bidderRequest.bids[0].params.floor = '1.7'; + [request] = spec.buildRequests(bidderRequest.bids, bidderRequest); + expect(request.data.imp[0].bidfloor).to.equal(1.7); + + bidderRequest.bids[0].params.floor = 0; + [request] = spec.buildRequests(bidderRequest.bids, bidderRequest); + expect(request.data.imp[0].bidfloor).to.equal(0); + + bidderRequest.bids[0].params.floor = undefined; + [request] = spec.buildRequests(bidderRequest.bids, bidderRequest); + expect(request.data.imp[0]).to.not.haveOwnProperty('bidfloor'); + + bidderRequest.bids[0].params.floor = null; + [request] = spec.buildRequests(bidderRequest.bids, bidderRequest); + expect(request.data.imp[0]).to.not.haveOwnProperty('bidfloor'); + }); + it('should send request with proper ad position', function () { createVideoBidderRequest(); - let positionBidderRequest = clone(bidderRequest); + let positionBidderRequest = utils.deepClone(bidderRequest); positionBidderRequest.bids[0].mediaTypes.video.pos = 1; let [request] = spec.buildRequests(positionBidderRequest.bids, positionBidderRequest); expect(request.data.imp[0].video.pos).to.equal(1); - }); - it('should send request with proper ad position when mediaTypes.video.pos is not defined', function () { - createVideoBidderRequest(); - let positionBidderRequest = clone(bidderRequest); + positionBidderRequest = utils.deepClone(bidderRequest); positionBidderRequest.bids[0].params.position = undefined; positionBidderRequest.bids[0].mediaTypes.video.pos = undefined; - let [request] = spec.buildRequests(positionBidderRequest.bids, positionBidderRequest); - expect(request.data.imp[0].video.pos).to.equal(0); + [request] = spec.buildRequests(positionBidderRequest.bids, positionBidderRequest); + expect(request.data.imp[0].video.pos).to.equal(undefined); - positionBidderRequest = clone(bidderRequest); + positionBidderRequest = utils.deepClone(bidderRequest); positionBidderRequest.bids[0].params.position = 'atf' positionBidderRequest.bids[0].mediaTypes.video.pos = undefined; [request] = spec.buildRequests(positionBidderRequest.bids, positionBidderRequest); expect(request.data.imp[0].video.pos).to.equal(1); - positionBidderRequest = clone(bidderRequest); + positionBidderRequest = utils.deepClone(bidderRequest); positionBidderRequest.bids[0].params.position = 'btf'; positionBidderRequest.bids[0].mediaTypes.video.pos = undefined; [request] = spec.buildRequests(positionBidderRequest.bids, positionBidderRequest); expect(request.data.imp[0].video.pos).to.equal(3); - positionBidderRequest = clone(bidderRequest); + positionBidderRequest = utils.deepClone(bidderRequest); positionBidderRequest.bids[0].params.position = 'foobar'; positionBidderRequest.bids[0].mediaTypes.video.pos = undefined; [request] = spec.buildRequests(positionBidderRequest.bids, positionBidderRequest); - expect(request.data.imp[0].video.pos).to.equal(0); + expect(request.data.imp[0].video.pos).to.equal(undefined); }); it('should properly enforce video.context to be either instream or outstream', function () { @@ -1171,7 +1235,7 @@ describe('the rubicon adapter', function () { bidderRequest.auctionStart + 100 ); - const bidRequestCopy = clone(bidderRequest.bids[0]); + const bidRequestCopy = utils.deepClone(bidderRequest.bids[0]); expect(spec.isBidRequestValid(bidRequestCopy)).to.equal(true); // change context to outstream, still true @@ -1257,7 +1321,7 @@ describe('the rubicon adapter', function () { bidderRequest.auctionStart + 100 ); - const bidRequestCopy = clone(bidderRequest); + const bidRequestCopy = utils.deepClone(bidderRequest); let [request] = spec.buildRequests(bidRequestCopy.bids, bidRequestCopy); expect(spec.isBidRequestValid(bidderRequest.bids[0])).to.equal(true); @@ -1305,12 +1369,30 @@ describe('the rubicon adapter', function () { bidderRequest.auctionStart + 100 ); - const bidRequestCopy = clone(bidderRequest); + const bidRequestCopy = utils.deepClone(bidderRequest); let requests = spec.buildRequests(bidRequestCopy.bids, bidRequestCopy); expect(requests.length).to.equal(1); expect(requests[0].url).to.equal(FASTLANE_ENDPOINT); }); + + it('should include coppa flag in video bid request', () => { + createVideoBidderRequest(); + + sandbox.stub(Date, 'now').callsFake(() => + bidderRequest.auctionStart + 100 + ); + + sandbox.stub(config, 'getConfig').callsFake(key => { + const config = { + 'coppa': true + }; + return config[key]; + }); + + const [request] = spec.buildRequests(bidderRequest.bids, bidderRequest); + expect(request.data.regs.coppa).to.equal(1); + }); }); describe('combineSlotUrlParams', function () { @@ -1756,7 +1838,7 @@ describe('the rubicon adapter', function () { }; let bids = spec.interpretResponse({ body: response }, { - bidRequest: [clone(bidderRequest.bids[0])] + bidRequest: [utils.deepClone(bidderRequest.bids[0])] }); expect(bids).to.be.lengthOf(1); @@ -1966,6 +2048,19 @@ describe('the rubicon adapter', function () { expect(bids[0].height).to.equal(480); }); }); + + describe('config with integration type', () => { + it('should use the integration type provided in the config instead of the default', () => { + sandbox.stub(config, 'getConfig').callsFake(function (key) { + const config = { + 'rubicon.int_type': 'testType' + }; + return config[key]; + }); + const [request] = spec.buildRequests(bidderRequest.bids, bidderRequest); + expect(parseQuery(request.data).tk_flint).to.equal('testType_v$prebid.version$'); + }); + }); }); }); @@ -2090,7 +2185,3 @@ describe('the rubicon adapter', function () { }); }); }); - -function clone(obj) { - return JSON.parse(JSON.stringify(obj)); -} diff --git a/test/spec/modules/s2sTesting_spec.js b/test/spec/modules/s2sTesting_spec.js index 34de6d9ec38..52377dcabf2 100644 --- a/test/spec/modules/s2sTesting_spec.js +++ b/test/spec/modules/s2sTesting_spec.js @@ -1,30 +1,14 @@ import s2sTesting from 'modules/s2sTesting'; import { config } from 'src/config'; -import find from 'core-js/library/fn/array/find'; - -var events = require('src/events'); -var CONSTANTS = require('src/constants.json'); -const BID_ADJUSTMENT = CONSTANTS.EVENTS.BID_ADJUSTMENT; var expect = require('chai').expect; describe('s2sTesting', function () { - let mathRandomStub; - let randomNumber = 0; - - beforeEach(function () { - mathRandomStub = sinon.stub(Math, 'random').callsFake(() => { return randomNumber; }); - }); - - afterEach(function () { - mathRandomStub.restore(); - }); - describe('s2sTesting.getSource', function () { // helper function to set random number and get the source function getExpectedSource(randNumber, sourceWeights, sources) { // set random number for testing - randomNumber = randNumber; + s2sTesting.globalRand = randNumber; return s2sTesting.getSource(sourceWeights, sources); } @@ -93,7 +77,7 @@ describe('s2sTesting', function () { describe('setting source through s2sConfig', function () { beforeEach(function () { // set random number for testing - randomNumber = 0.7; + s2sTesting.globalRand = 0.7; }); it('does not work if testing is "false"', function () { @@ -155,6 +139,50 @@ describe('s2sTesting', function () { expect(serverClientBidders.server).to.eql(['rubicon']); expect(serverClientBidders.client).to.have.members(['appnexus']); }); + + it('sends both bidders to same source when weights are the same', function () { + s2sTesting.globalRand = 0.01; + + config.setConfig({s2sConfig: { + bidders: ['rubicon', 'appnexus'], + testing: true, + bidderControl: { + rubicon: {bidSource: {server: 1, client: 99}}, + appnexus: {bidSource: {server: 1, client: 99}} + }}}); + expect(s2sTesting.getSourceBidderMap()).to.eql({ + client: ['rubicon', 'appnexus'], + server: [] + }); + expect(s2sTesting.getSourceBidderMap()).to.eql({ + client: ['rubicon', 'appnexus'], + server: [] + }); + expect(s2sTesting.getSourceBidderMap()).to.eql({ + client: ['rubicon', 'appnexus'], + server: [] + }); + + config.setConfig({s2sConfig: { + bidders: ['rubicon', 'appnexus'], + testing: true, + bidderControl: { + rubicon: {bidSource: {server: 99, client: 1}}, + appnexus: {bidSource: {server: 99, client: 1}} + }}}); + expect(s2sTesting.getSourceBidderMap()).to.eql({ + server: ['rubicon', 'appnexus'], + client: [] + }); + expect(s2sTesting.getSourceBidderMap()).to.eql({ + server: ['rubicon', 'appnexus'], + client: [] + }); + expect(s2sTesting.getSourceBidderMap()).to.eql({ + server: ['rubicon', 'appnexus'], + client: [] + }); + }); }); describe('setting source through adUnits', function () { @@ -162,7 +190,7 @@ describe('s2sTesting', function () { // reset s2sconfig bid sources config.setConfig({s2sConfig: {testing: true}}); // set random number for testing - randomNumber = 0.7; + s2sTesting.globalRand = 0.7; }); it('sets one bidder source from one adUnit', function () { @@ -280,7 +308,7 @@ describe('s2sTesting', function () { // reset s2sconfig bid sources config.setConfig({s2sConfig: {testing: true}}); // set random number for testing - randomNumber = 0.7; + s2sTesting.globalRand = 0.7; }); it('should get sources from both', function () { diff --git a/test/spec/modules/scaleableAnalyticsAdapter_spec.js b/test/spec/modules/scaleableAnalyticsAdapter_spec.js new file mode 100644 index 00000000000..300f72751a4 --- /dev/null +++ b/test/spec/modules/scaleableAnalyticsAdapter_spec.js @@ -0,0 +1,136 @@ +import scaleableAnalytics from 'modules/scaleableAnalyticsAdapter'; +import { expect } from 'chai'; +import events from 'src/events'; +import CONSTANTS from 'src/constants.json'; +import adapterManager from 'src/adapterManager'; + +const BID_TIMEOUT = CONSTANTS.EVENTS.BID_TIMEOUT; +const AUCTION_INIT = CONSTANTS.EVENTS.AUCTION_INIT; +const BID_RESPONSE = CONSTANTS.EVENTS.BID_RESPONSE; +const BID_WON = CONSTANTS.EVENTS.BID_WON; +const AUCTION_END = CONSTANTS.EVENTS.AUCTION_END; + +describe('Scaleable Analytics Adapter', function() { + const MOCK_DATA = { + adUnitCode: '12345', + site: '5c4fab7a829e955d6c265e72', + bidResponse: { + adUnitCode: '12345', + bidderCode: 'test-code', + cpm: 3.14, + timeToRespond: 285 + }, + bidTimeout: [ + { + adUnitCode: '67890', + bidder: 'test-code' + } + ] + }; + + MOCK_DATA.expectedBidResponse = { + event: 'bids', + bids: [{ + code: MOCK_DATA.bidResponse.bidderCode, + cpm: MOCK_DATA.bidResponse.cpm, + ttr: MOCK_DATA.bidResponse.timeToRespond + }], + adunit: MOCK_DATA.adUnitCode, + site: MOCK_DATA.site + }; + + MOCK_DATA.expectedBidTimeout = { + event: 'bids', + bids: [], + timeouts: [MOCK_DATA.bidTimeout[0].bidder], + adunit: MOCK_DATA.bidTimeout[0].adUnitCode, + site: MOCK_DATA.site + }; + + let xhr; + let requests; + + before(function() { + xhr = sinon.useFakeXMLHttpRequest(); + xhr.onCreate = request => requests.push(request); + }); + + after(function() { + xhr.restore(); + }); + + describe('Event Handling', function() { + beforeEach(function() { + requests = []; + sinon.stub(events, 'getEvents').returns([]); + + scaleableAnalytics.enableAnalytics({ + provider: 'scaleable', + options: { + site: MOCK_DATA.site + } + }); + }); + + afterEach(function() { + events.getEvents.restore(); + scaleableAnalytics.disableAnalytics(); + }); + + it('should handle the auction init event', function(done) { + events.emit(AUCTION_INIT, { + adUnitCodes: [MOCK_DATA.adUnitCode] + }); + + const result = JSON.parse(requests[0].requestBody); + expect(result).to.deep.equal({ + event: 'request', + site: MOCK_DATA.site, + adunit: MOCK_DATA.adUnitCode + }); + + done(); + }); + + it('should handle the bid response event', function() { + events.emit(BID_RESPONSE, MOCK_DATA.bidResponse); + + const actual = scaleableAnalytics.getAuctionData(); + + expect(actual[MOCK_DATA.adUnitCode]).to.deep.equal(MOCK_DATA.expectedBidResponse); + }); + + it('should handle the bid timeout event', function() { + events.emit(BID_TIMEOUT, MOCK_DATA.bidTimeout); + + const actual = scaleableAnalytics.getAuctionData(); + + expect(actual[MOCK_DATA.bidTimeout[0].adUnitCode]).to.deep.equal(MOCK_DATA.expectedBidTimeout); + }); + + it('should handle the bid won event', function(done) { + events.emit(BID_WON, MOCK_DATA.bidResponse); + + const result = JSON.parse(requests[0].requestBody); + expect(result).to.deep.equal({ + adunit: MOCK_DATA.adUnitCode, + code: MOCK_DATA.bidResponse.bidderCode, + cpm: MOCK_DATA.bidResponse.cpm, + ttr: MOCK_DATA.bidResponse.timeToRespond, + event: 'win', + site: MOCK_DATA.site + }); + + done(); + }); + + it('should handle the auction end event', function(done) { + events.emit(AUCTION_END, {}); + + const result = JSON.parse(requests[0].requestBody); + expect(result).to.deep.equal(MOCK_DATA.expectedBidResponse); + + done(); + }); + }); +}); diff --git a/test/spec/modules/schain_spec.js b/test/spec/modules/schain_spec.js new file mode 100644 index 00000000000..8f5104f1822 --- /dev/null +++ b/test/spec/modules/schain_spec.js @@ -0,0 +1,286 @@ +import {isValidSchainConfig, isSchainObjectValid, copySchainObjectInAdunits} from '../../../modules/schain'; +import { expect } from 'chai'; + +describe('#isValidSchainConfig: module config validation', function() { + it('if config is undefined or not an objct then return false', function() { + expect(isValidSchainConfig()).to.false; + expect(isValidSchainConfig('')).to.false; + expect(isValidSchainConfig([])).to.false; + expect(isValidSchainConfig(12)).to.false; + expect(isValidSchainConfig(3.14)).to.false; + }) + + it('if config is an object then return true', function() { + expect(isValidSchainConfig({})).to.true; + }) +}); + +describe('#isSchainObjectValid: schain object validation', function() { + let schainConfig; + + beforeEach(function() { + schainConfig = { + 'ver': '1.0', + 'complete': 1, + 'nodes': [ + { + 'asi': 'indirectseller.com', + 'sid': '00001', + 'hp': 1 + }, + + { + 'asi': 'indirectseller-2.com', + 'sid': '00002', + 'hp': 2 + } + ] + }; + }); + + it('Return true for correct config', function() { + expect(isSchainObjectValid(schainConfig, true)).to.true; + }); + + it('Return false for string config', function() { + schainConfig = JSON.stringify(schainConfig); + expect(isSchainObjectValid(schainConfig, true)).to.false; + }); + + it('Returns false if complete param is not an Integer', function() { + schainConfig.complete = 1; // integer + expect(isSchainObjectValid(schainConfig, true)).to.true; + schainConfig.complete = '1'; // string + expect(isSchainObjectValid(schainConfig, true)).to.false; + schainConfig.complete = 1.1; // float + expect(isSchainObjectValid(schainConfig, true)).to.false; + schainConfig.complete = {}; // object + expect(isSchainObjectValid(schainConfig, true)).to.false; + delete schainConfig.complete; // undefined + expect(isSchainObjectValid(schainConfig, true)).to.false; + schainConfig.complete = true; // boolean + expect(isSchainObjectValid(schainConfig, true)).to.false; + schainConfig.complete = []; // array + expect(isSchainObjectValid(schainConfig, true)).to.false; + }); + + it('Returns false if version param is not a String', function() { + schainConfig.ver = 1; // Integer + expect(isSchainObjectValid(schainConfig, true)).to.false; + schainConfig.ver = 1.1; // float + expect(isSchainObjectValid(schainConfig, true)).to.false; + schainConfig.ver = {}; // object + expect(isSchainObjectValid(schainConfig, true)).to.false; + delete schainConfig.ver; // undefined + expect(isSchainObjectValid(schainConfig, true)).to.false; + schainConfig.ver = true; // boolean + expect(isSchainObjectValid(schainConfig, true)).to.false; + schainConfig.ver = []; // array + expect(isSchainObjectValid(schainConfig, true)).to.false; + }); + + it('Returns false if ext param is not an Object', function() { + schainConfig.ext = 1; // Integer + expect(isSchainObjectValid(schainConfig, true)).to.false; + schainConfig.ext = 1.1; // float + expect(isSchainObjectValid(schainConfig, true)).to.false; + schainConfig.ext = {}; // object + expect(isSchainObjectValid(schainConfig, true)).to.true; + delete schainConfig.ext; // undefined // param is optional thus this will result true + expect(isSchainObjectValid(schainConfig, true)).to.true; + schainConfig.ext = true; // boolean + expect(isSchainObjectValid(schainConfig, true)).to.false; + schainConfig.ext = []; // array + expect(isSchainObjectValid(schainConfig, true)).to.false; + }); + + it('Returns false if nodes param is not an Array', function() { + // by default schainConfig.nodes is array + expect(isSchainObjectValid(schainConfig, true)).to.true; + schainConfig.nodes = 1; // Integer + expect(isSchainObjectValid(schainConfig, true)).to.false; + schainConfig.nodes = 1.1; // float + expect(isSchainObjectValid(schainConfig, true)).to.false; + schainConfig.nodes = {}; // object + expect(isSchainObjectValid(schainConfig, true)).to.false; + delete schainConfig.nodes; // undefined + expect(isSchainObjectValid(schainConfig, true)).to.false; + schainConfig.nodes = true; // boolean + expect(isSchainObjectValid(schainConfig, true)).to.false; + }); + + it('Returns false if nodes[].asi is not a String', function() { + schainConfig.nodes[0].asi = 1; // Integer + expect(isSchainObjectValid(schainConfig, true)).to.false; + schainConfig.nodes[0].asi = 1.1; // float + expect(isSchainObjectValid(schainConfig, true)).to.false; + schainConfig.nodes[0].asi = {}; // object + expect(isSchainObjectValid(schainConfig, true)).to.false; + delete schainConfig.nodes[0].asi; // undefined + expect(isSchainObjectValid(schainConfig, true)).to.false; + schainConfig.nodes[0].asi = true; // boolean + expect(isSchainObjectValid(schainConfig, true)).to.false; + schainConfig.nodes[0].asi = []; // array + expect(isSchainObjectValid(schainConfig, true)).to.false; + }); + + it('Returns false if nodes[].sid is not a String', function() { + schainConfig.nodes[1].sid = 1; // Integer + expect(isSchainObjectValid(schainConfig, true)).to.false; + schainConfig.nodes[1].sid = 1.1; // float + expect(isSchainObjectValid(schainConfig, true)).to.false; + schainConfig.nodes[1].sid = {}; // object + expect(isSchainObjectValid(schainConfig, true)).to.false; + delete schainConfig.nodes[0].sid; // undefined + expect(isSchainObjectValid(schainConfig, true)).to.false; + schainConfig.nodes[1].sid = true; // boolean + expect(isSchainObjectValid(schainConfig, true)).to.false; + schainConfig.nodes[1].sid = []; // array + expect(isSchainObjectValid(schainConfig, true)).to.false; + }); + + it('Returns false if nodes[].hp is not an Integer', function() { + schainConfig.nodes[0].hp = '1'; // string + expect(isSchainObjectValid(schainConfig, true)).to.false; + schainConfig.nodes[0].hp = 1.1; // float + expect(isSchainObjectValid(schainConfig, true)).to.false; + schainConfig.nodes[0].hp = {}; // object + expect(isSchainObjectValid(schainConfig, true)).to.false; + delete schainConfig.nodes[0].hp; // undefined + expect(isSchainObjectValid(schainConfig, true)).to.false; + schainConfig.nodes[0].hp = true; // boolean + expect(isSchainObjectValid(schainConfig, true)).to.false; + schainConfig.nodes[0].hp = []; // array + expect(isSchainObjectValid(schainConfig, true)).to.false; + }); + + it('Returns false if nodes[].rid is not a String', function() { + schainConfig.nodes[1].rid = 'rid value'; // string + expect(isSchainObjectValid(schainConfig, true)).to.true; + schainConfig.nodes[1].rid = 1; // Integer + expect(isSchainObjectValid(schainConfig, true)).to.false; + schainConfig.nodes[1].rid = 1.1; // float + expect(isSchainObjectValid(schainConfig, true)).to.false; + schainConfig.nodes[1].rid = {}; // object + expect(isSchainObjectValid(schainConfig, true)).to.false; + delete schainConfig.nodes[1].rid; // undefined // param is optional thus this will result true + expect(isSchainObjectValid(schainConfig, true)).to.true; + schainConfig.nodes[1].rid = true; // boolean + expect(isSchainObjectValid(schainConfig, true)).to.false; + schainConfig.nodes[1].rid = []; // array + expect(isSchainObjectValid(schainConfig, true)).to.false; + }); + + it('Returns false if nodes[].name is not a String', function() { + schainConfig.nodes[0].name = 'name value'; // string + expect(isSchainObjectValid(schainConfig, true)).to.true; + schainConfig.nodes[0].name = 1; // Integer + expect(isSchainObjectValid(schainConfig, true)).to.false; + schainConfig.nodes[0].name = 1.1; // float + expect(isSchainObjectValid(schainConfig, true)).to.false; + schainConfig.nodes[0].name = {}; // object + expect(isSchainObjectValid(schainConfig, true)).to.false; + delete schainConfig.nodes[0].name; // undefined // param is optional thus this will result true + expect(isSchainObjectValid(schainConfig, true)).to.true; + schainConfig.nodes[0].name = true; // boolean + expect(isSchainObjectValid(schainConfig, true)).to.false; + schainConfig.nodes[0].name = []; // array + expect(isSchainObjectValid(schainConfig, true)).to.false; + }); + + it('Returns false if nodes[].domain is not a String', function() { + schainConfig.nodes[1].domain = 'domain value'; // string + expect(isSchainObjectValid(schainConfig, true)).to.true; + schainConfig.nodes[1].domain = 1; // Integer + expect(isSchainObjectValid(schainConfig, true)).to.false; + schainConfig.nodes[1].domain = 1.1; // float + expect(isSchainObjectValid(schainConfig, true)).to.false; + schainConfig.nodes[1].domain = {}; // object + expect(isSchainObjectValid(schainConfig, true)).to.false; + delete schainConfig.nodes[1].domain; // undefined // param is optional thus this will result true + expect(isSchainObjectValid(schainConfig, true)).to.true; + schainConfig.nodes[1].domain = true; // boolean + expect(isSchainObjectValid(schainConfig, true)).to.false; + schainConfig.nodes[1].domain = []; // array + expect(isSchainObjectValid(schainConfig, true)).to.false; + }); + + it('Returns false if nodes[].ext param is not an Object', function() { + schainConfig.nodes[0].ext = 1; // Integer + expect(isSchainObjectValid(schainConfig, true)).to.false; + schainConfig.nodes[0].ext = 1.1; // float + expect(isSchainObjectValid(schainConfig, true)).to.false; + schainConfig.nodes[0].ext = {}; // object + expect(isSchainObjectValid(schainConfig, true)).to.true; + delete schainConfig.nodes[0].ext; // undefined // param is optional thus this will result true + expect(isSchainObjectValid(schainConfig, true)).to.true; + schainConfig.nodes[0].ext = true; // boolean + expect(isSchainObjectValid(schainConfig, true)).to.false; + schainConfig.nodes[0].ext = []; // array + expect(isSchainObjectValid(schainConfig, true)).to.false; + }); + + it('Relaxed mode: Returns true even for invalid config if second argument is set to false', function() { + schainConfig = { + 'ver': 1.0, // invalid + 'complete': '1', // invalid + 'nodes': [ + { + 'asi': 'indirectseller.com', + 'sid': 1, // invalid + 'hp': '1' // invalid + }, + + { + 'asi': 'indirectseller-2.com', + 'sid': '00002', + 'hp': 2 + } + ] + }; + expect(isSchainObjectValid(schainConfig, false)).to.true; + + schainConfig = {}; + expect(isSchainObjectValid(schainConfig, false)).to.true; + }) +}); + +describe('Passing schain object to adUnits', function() { + let schainConfig; + + beforeEach(function() { + schainConfig = { + 'ver': '1.0', + 'complete': 1, + 'nodes': [ + { + 'asi': 'indirectseller.com', + 'sid': '00001', + 'hp': 1 + }, + + { + 'asi': 'indirectseller-2.com', + 'sid': '00002', + 'hp': 2 + } + ] + }; + }); + + it('schain object should be applied to all adUnits', function() { + let adUnits = [ + { + bids: [{}, {}] + }, + { + bids: [{}, {}] + } + ]; + copySchainObjectInAdunits(adUnits, schainConfig); + expect(adUnits[0].bids[0].schain).to.equal(schainConfig); + expect(adUnits[0].bids[1].schain).to.equal(schainConfig); + expect(adUnits[1].bids[0].schain).to.equal(schainConfig); + expect(adUnits[1].bids[1].schain).to.equal(schainConfig); + }); +}); diff --git a/test/spec/modules/seedtagBidAdapter_spec.js b/test/spec/modules/seedtagBidAdapter_spec.js new file mode 100644 index 00000000000..4bd4b599c55 --- /dev/null +++ b/test/spec/modules/seedtagBidAdapter_spec.js @@ -0,0 +1,396 @@ +import { expect } from 'chai' +import { spec, getTimeoutUrl } from 'modules/seedtagBidAdapter' + +function getSlotConfigs(mediaTypes, params) { + return { + params: params, + sizes: [[300, 250], [300, 600]], + bidId: '30b31c1838de1e', + bidderRequestId: '22edbae2733bf6', + auctionId: '1d1a030790a475', + bidRequestsCount: 1, + bidder: 'seedtag', + mediaTypes: mediaTypes, + src: 'client', + transactionId: 'd704d006-0d6e-4a09-ad6c-179e7e758096' + } +} + +describe('Seedtag Adapter', function() { + describe('isBidRequestValid method', function() { + const PUBLISHER_ID = '0000-0000-01' + const ADUNIT_ID = '000000' + describe('returns true', function() { + describe('when banner slot config has all mandatory params', () => { + describe('and placement has the correct value', function() { + const createBannerSlotConfig = placement => { + return getSlotConfigs( + { banner: {} }, + { + publisherId: PUBLISHER_ID, + adUnitId: ADUNIT_ID, + placement + } + ) + } + const placements = ['banner', 'video', 'inImage', 'inScreen'] + placements.forEach(placement => { + it('should be ' + placement, function() { + const isBidRequestValid = spec.isBidRequestValid( + createBannerSlotConfig(placement) + ) + expect(isBidRequestValid).to.equal(true) + }) + }) + }) + }) + describe('when video slot has all mandatory params.', function() { + it('should return true, when video mediatype object are correct.', function() { + const slotConfig = getSlotConfigs( + { + video: { + context: 'instream', + playerSize: [[600, 200]] + } + }, + { + publisherId: PUBLISHER_ID, + adUnitId: ADUNIT_ID, + placement: 'video' + } + ) + const isBidRequestValid = spec.isBidRequestValid(slotConfig) + expect(isBidRequestValid).to.equal(true) + }) + }) + }) + describe('returns false', function() { + describe('when params are not correct', function() { + function createSlotconfig(params) { + return getSlotConfigs({ banner: {} }, params) + } + it('does not have the PublisherToken.', function() { + const isBidRequestValid = spec.isBidRequestValid( + createSlotconfig({ + adUnitId: '000000', + placement: 'banner' + }) + ) + expect(isBidRequestValid).to.equal(false) + }) + it('does not have the AdUnitId.', function() { + const isBidRequestValid = spec.isBidRequestValid( + createSlotconfig({ + publisherId: '0000-0000-01', + placement: 'banner' + }) + ) + expect(isBidRequestValid).to.equal(false) + }) + it('does not have the placement.', function() { + const isBidRequestValid = spec.isBidRequestValid( + createSlotconfig({ + publisherId: '0000-0000-01', + adUnitId: '000000' + }) + ) + expect(isBidRequestValid).to.equal(false) + }) + it('does not have a the correct placement.', function() { + const isBidRequestValid = spec.isBidRequestValid( + createSlotconfig({ + publisherId: '0000-0000-01', + adUnitId: '000000', + placement: 'another_thing' + }) + ) + expect(isBidRequestValid).to.equal(false) + }) + }) + describe('when video mediaType object is not correct.', function() { + function createVideoSlotconfig(mediaType) { + return getSlotConfigs(mediaType, { + publisherId: PUBLISHER_ID, + adUnitId: ADUNIT_ID, + placement: 'video' + }) + } + it('is a void object', function() { + const isBidRequestValid = spec.isBidRequestValid( + createVideoSlotconfig({ video: {} }) + ) + expect(isBidRequestValid).to.equal(false) + }) + it('does not have playerSize.', function() { + const isBidRequestValid = spec.isBidRequestValid( + createVideoSlotconfig({ video: { context: 'instream' } }) + ) + expect(isBidRequestValid).to.equal(false) + }) + it('is not instream ', function() { + const isBidRequestValid = spec.isBidRequestValid( + createVideoSlotconfig({ + video: { + context: 'outstream', + playerSize: [[600, 200]] + } + }) + ) + expect(isBidRequestValid).to.equal(false) + }) + }) + }) + }) + + describe('buildRequests method', function() { + const bidderRequest = { + refererInfo: { referer: 'referer' }, + timeout: 1000 + } + const mandatoryParams = { + publisherId: '0000-0000-01', + adUnitId: '000000', + placement: 'banner' + } + const inStreamParams = Object.assign({}, mandatoryParams, { + video: { + mimes: 'mp4' + } + }) + const validBidRequests = [ + getSlotConfigs({ banner: {} }, mandatoryParams), + getSlotConfigs( + { video: { context: 'instream', playerSize: [[300, 200]] } }, + inStreamParams + ) + ] + it('Url params should be correct ', function() { + const request = spec.buildRequests(validBidRequests, bidderRequest) + expect(request.method).to.equal('POST') + expect(request.url).to.equal('https://s.seedtag.com/c/hb/bid') + }) + + it('Common data request should be correct', function() { + const request = spec.buildRequests(validBidRequests, bidderRequest) + const data = JSON.parse(request.data) + expect(data.url).to.equal('referer') + expect(data.publisherToken).to.equal('0000-0000-01') + expect(typeof data.version).to.equal('string') + }) + + describe('adPosition param', function() { + it('should sended when publisher set adPosition param', function() { + const params = Object.assign({}, mandatoryParams, { + adPosition: 1 + }) + const validBidRequests = [getSlotConfigs({ banner: {} }, params)] + const request = spec.buildRequests(validBidRequests, bidderRequest) + const data = JSON.parse(request.data) + expect(data.bidRequests[0].adPosition).to.equal(1) + }) + it('should not sended when publisher has not set adPosition param', function() { + const validBidRequests = [ + getSlotConfigs({ banner: {} }, mandatoryParams) + ] + const request = spec.buildRequests(validBidRequests, bidderRequest) + const data = JSON.parse(request.data) + expect(data.bidRequests[0].adPosition).to.equal(undefined) + }) + }) + + describe('GDPR params', function() { + describe('when there arent consent management platform', function() { + it('cmp should be false', function() { + const request = spec.buildRequests(validBidRequests, bidderRequest) + const data = JSON.parse(request.data) + expect(data.cmp).to.equal(false) + }) + }) + describe('when there are consent management platform', function() { + it('cmps should be true and ga should not sended, when gdprApplies is undefined', function() { + bidderRequest['gdprConsent'] = { + gdprApplies: undefined, + consentString: 'consentString' + } + const request = spec.buildRequests(validBidRequests, bidderRequest) + const data = JSON.parse(request.data) + expect(data.cmp).to.equal(true) + expect(Object.keys(data).indexOf('data')).to.equal(-1) + expect(data.cd).to.equal('consentString') + }) + it('cmps should be true and all gdpr parameters should be sended, when there are gdprApplies', function() { + bidderRequest['gdprConsent'] = { + gdprApplies: true, + consentString: 'consentString' + } + const request = spec.buildRequests(validBidRequests, bidderRequest) + const data = JSON.parse(request.data) + expect(data.cmp).to.equal(true) + expect(data.ga).to.equal(true) + expect(data.cd).to.equal('consentString') + }) + }) + }) + + describe('BidRequests params', function() { + const request = spec.buildRequests(validBidRequests, bidderRequest) + const data = JSON.parse(request.data) + const bidRequests = data.bidRequests + it('should request a Banner', function() { + const bannerBid = bidRequests[0] + expect(bannerBid.id).to.equal('30b31c1838de1e') + expect(bannerBid.transactionId).to.equal( + 'd704d006-0d6e-4a09-ad6c-179e7e758096' + ) + expect(bannerBid.supplyTypes[0]).to.equal('display') + expect(bannerBid.adUnitId).to.equal('000000') + expect(bannerBid.sizes[0][0]).to.equal(300) + expect(bannerBid.sizes[0][1]).to.equal(250) + expect(bannerBid.sizes[1][0]).to.equal(300) + expect(bannerBid.sizes[1][1]).to.equal(600) + }) + it('should request an InStream Video', function() { + const videoBid = bidRequests[1] + expect(videoBid.id).to.equal('30b31c1838de1e') + expect(videoBid.transactionId).to.equal( + 'd704d006-0d6e-4a09-ad6c-179e7e758096' + ) + expect(videoBid.supplyTypes[0]).to.equal('video') + expect(videoBid.adUnitId).to.equal('000000') + expect(videoBid.videoParams.mimes).to.equal('mp4') + expect(videoBid.videoParams.w).to.equal(300) + expect(videoBid.videoParams.h).to.equal(200) + expect(videoBid.sizes[0][0]).to.equal(300) + expect(videoBid.sizes[0][1]).to.equal(250) + expect(videoBid.sizes[1][0]).to.equal(300) + expect(videoBid.sizes[1][1]).to.equal(600) + }) + }) + }) + + describe('interpret response method', function() { + it('should return a void array, when the server response are not correct.', function() { + const request = { data: JSON.stringify({}) } + const serverResponse = { + body: {} + } + const bids = spec.interpretResponse(serverResponse, request) + expect(typeof bids).to.equal('object') + expect(bids.length).to.equal(0) + }) + it('should return a void array, when the server response have not got bids.', function() { + const request = { data: JSON.stringify({}) } + const serverResponse = { body: { bids: [] } } + const bids = spec.interpretResponse(serverResponse, request) + expect(typeof bids).to.equal('object') + expect(bids.length).to.equal(0) + }) + describe('when the server response return a bid', function() { + describe('the bid is a banner', function() { + it('should return a banner bid', function() { + const request = { data: JSON.stringify({}) } + const serverResponse = { + body: { + bids: [ + { + bidId: '2159a54dc2566f', + price: 0.5, + currency: 'USD', + content: 'content', + width: 728, + height: 90, + mediaType: 'display', + ttl: 360 + } + ], + cookieSync: { url: '' } + } + } + const bids = spec.interpretResponse(serverResponse, request) + expect(bids.length).to.equal(1) + expect(bids[0].requestId).to.equal('2159a54dc2566f') + expect(bids[0].cpm).to.equal(0.5) + expect(bids[0].width).to.equal(728) + expect(bids[0].height).to.equal(90) + expect(bids[0].currency).to.equal('USD') + expect(bids[0].netRevenue).to.equal(true) + expect(bids[0].ad).to.equal('content') + }) + }) + describe('the bid is a video', function() { + it('should return a instream bid', function() { + const request = { data: JSON.stringify({}) } + const serverResponse = { + body: { + bids: [ + { + bidId: '2159a54dc2566f', + price: 0.5, + currency: 'USD', + content: 'content', + width: 728, + height: 90, + mediaType: 'video', + ttl: 360 + } + ], + cookieSync: { url: '' } + } + } + const bids = spec.interpretResponse(serverResponse, request) + expect(bids.length).to.equal(1) + expect(bids[0].requestId).to.equal('2159a54dc2566f') + expect(bids[0].cpm).to.equal(0.5) + expect(bids[0].width).to.equal(728) + expect(bids[0].height).to.equal(90) + expect(bids[0].currency).to.equal('USD') + expect(bids[0].netRevenue).to.equal(true) + expect(bids[0].vastXml).to.equal('content') + }) + }) + }) + }) + + describe('user syncs method', function() { + it('should return empty array, when iframe sync option are disabled.', function() { + const syncOption = { iframeEnabled: false } + const serverResponses = [{ body: { cookieSync: 'someUrl' } }] + const cookieSyncArray = spec.getUserSyncs(syncOption, serverResponses) + expect(cookieSyncArray.length).to.equal(0) + }) + it('should return empty array, when the server response are wrong.', function() { + const syncOption = { iframeEnabled: true } + const serverResponses = [{ body: {} }] + const cookieSyncArray = spec.getUserSyncs(syncOption, serverResponses) + expect(cookieSyncArray.length).to.equal(0) + }) + it('should return empty array, when the server response are void.', function() { + const syncOption = { iframeEnabled: true } + const serverResponses = [{ body: { cookieSync: '' } }] + const cookieSyncArray = spec.getUserSyncs(syncOption, serverResponses) + expect(cookieSyncArray.length).to.equal(0) + }) + it('should return a array with the cookie sync, when the server response with a cookie sync.', function() { + const syncOption = { iframeEnabled: true } + const serverResponses = [{ body: { cookieSync: 'someUrl' } }] + const cookieSyncArray = spec.getUserSyncs(syncOption, serverResponses) + expect(cookieSyncArray.length).to.equal(1) + expect(cookieSyncArray[0].type).to.equal('iframe') + expect(cookieSyncArray[0].url).to.equal('someUrl') + }) + }) + + describe('onTimeout', function () { + it('should return the correct endpoint', function () { + const params = { publisherId: '0000', adUnitId: '11111' } + const timeoutData = [{ params: [ params ] }]; + const timeoutUrl = getTimeoutUrl(timeoutData); + expect(timeoutUrl).to.equal( + 'https://s.seedtag.com/se/hb/timeout?publisherToken=' + + params.publisherId + + '&adUnitId=' + + params.adUnitId + ) + }) + }) +}) diff --git a/test/spec/modules/shareUserIds_spec.js b/test/spec/modules/shareUserIds_spec.js new file mode 100644 index 00000000000..4ae5f93a1a6 --- /dev/null +++ b/test/spec/modules/shareUserIds_spec.js @@ -0,0 +1,53 @@ +import {userIdTargeting} from '../../../modules/userIdTargeting'; +import { expect } from 'chai'; + +describe('#userIdTargeting', function() { + let userIds; + let config; + + beforeEach(function() { + userIds = { + tdid: 'my-tdid' + }; + config = { + 'GAM': true, + 'GAM_KEYS': { + 'tdid': 'TD_ID' + } + }; + }); + + it('Do nothing if config is invaild', function() { + let pubads = window.googletag.pubads(); + pubads.clearTargeting(); + pubads.setTargeting('test', ['TEST']); + userIdTargeting(userIds, JSON.stringify(config)); + expect(pubads.getTargeting()).to.deep.equal({test: ['TEST']}); + }); + + it('all UserIds are passed as is with GAM: true', function() { + let pubads = window.googletag.pubads(); + pubads.clearTargeting(); + pubads.setTargeting('test', ['TEST']); + delete config.GAM_KEYS; + userIdTargeting(userIds, config); + expect(pubads.getTargeting()).to.deep.equal({test: ['TEST'], tdid: ['my-tdid']}); + }) + + it('Publisher prefered key-names are used', function() { + let pubads = window.googletag.pubads(); + pubads.clearTargeting(); + pubads.setTargeting('test', ['TEST']); + userIdTargeting(userIds, config); + expect(pubads.getTargeting()).to.deep.equal({test: ['TEST'], 'TD_ID': ['my-tdid']}); + }); + + it('Publisher does not want to pass an id', function() { + let pubads = window.googletag.pubads(); + pubads.clearTargeting(); + pubads.setTargeting('test', ['TEST']); + config.GAM_KEYS.tdid = ''; + userIdTargeting(userIds, config); + expect(pubads.getTargeting()).to.deep.equal({test: ['TEST']}); + }); +}); diff --git a/test/spec/modules/sharethroughBidAdapter_spec.js b/test/spec/modules/sharethroughBidAdapter_spec.js index 6a4ab016fdc..afa5f44959c 100644 --- a/test/spec/modules/sharethroughBidAdapter_spec.js +++ b/test/spec/modules/sharethroughBidAdapter_spec.js @@ -1,9 +1,9 @@ import { expect } from 'chai'; -import { sharethroughAdapterSpec } from 'modules/sharethroughBidAdapter'; +import { sharethroughAdapterSpec, sharethroughInternal } from 'modules/sharethroughBidAdapter'; import { newBidder } from 'src/adapters/bidderFactory'; const spec = newBidder(sharethroughAdapterSpec).getSpec(); -const bidderRequest = [ +const bidRequests = [ { bidder: 'sharethrough', bidId: 'bidId1', @@ -11,7 +11,8 @@ const bidderRequest = [ placementCode: 'foo', params: { pkey: 'aaaa1111' - } + }, + userId: { tdid: 'fake-tdid' } }, { bidder: 'sharethrough', @@ -39,41 +40,65 @@ const bidderRequest = [ const prebidRequests = [ { method: 'GET', - url: document.location.protocol + '//btlr.sharethrough.com' + '/header-bid/v1', + url: document.location.protocol + '//btlr.sharethrough.com' + '/WYu2BXv1/v1', data: { bidId: 'bidId', placement_key: 'pKey' }, strData: { - stayInIframe: false, + skipIframeBusting: false, sizes: [] } }, { method: 'GET', - url: document.location.protocol + '//btlr.sharethrough.com' + '/header-bid/v1', + url: document.location.protocol + '//btlr.sharethrough.com' + '/WYu2BXv1/v1', data: { bidId: 'bidId', placement_key: 'pKey' }, strData: { - stayInIframe: true, + skipIframeBusting: true, sizes: [[300, 250], [300, 300], [250, 250], [600, 50]] } }, { method: 'GET', - url: document.location.protocol + '//btlr.sharethrough.com' + '/header-bid/v1', + url: document.location.protocol + '//btlr.sharethrough.com' + '/WYu2BXv1/v1', data: { bidId: 'bidId', placement_key: 'pKey' }, strData: { - stayInIframe: true, + skipIframeBusting: true, iframeSize: [500, 500], sizes: [[300, 250], [300, 300], [250, 250], [600, 50]] } }, + { + method: 'GET', + url: document.location.protocol + '//btlr.sharethrough.com' + '/WYu2BXv1/v1', + data: { + bidId: 'bidId', + placement_key: 'pKey' + }, + strData: { + skipIframeBusting: false, + sizes: [[0, 0]] + } + }, + { + method: 'GET', + url: document.location.protocol + '//btlr.sharethrough.com' + '/WYu2BXv1/v1', + data: { + bidId: 'bidId', + placement_key: 'pKey' + }, + strData: { + skipIframeBusting: false, + sizes: [[300, 250], [300, 300], [250, 250], [600, 50]] + } + }, ]; const bidderResponse = { @@ -95,21 +120,71 @@ const bidderResponse = { header: { get: (header) => header } }; -// Mirrors the one in modules/sharethroughBidAdapter.js as the function is unexported -const b64EncodeUnicode = (str) => { - return btoa( - encodeURIComponent(str).replace(/%([0-9A-F]{2})/g, - function toSolidBytes(match, p1) { - return String.fromCharCode('0x' + p1); - })); -} +const setUserAgent = (str) => { + window.navigator['__defineGetter__']('userAgent', function () { + return str; + }); +}; + +describe('sharethrough internal spec', function () { + let windowSpy, windowTopSpy; + + beforeEach(function() { + windowSpy = sinon.spy(window.document, 'getElementsByTagName'); + windowTopSpy = sinon.spy(window.top.document, 'getElementsByTagName'); + }); + + afterEach(function() { + windowSpy.restore(); + windowTopSpy.restore(); + window.STR = undefined; + window.top.STR = undefined; + }); + + describe('we cannot access top level document', function () { + beforeEach(function() { + window.lockedInFrame = true; + }); + + afterEach(function() { + window.lockedInFrame = false; + }); + + it('appends sfp.js to the safeframe', function () { + sharethroughInternal.handleIframe(); + expect(windowSpy.calledOnce).to.be.true; + }); + + it('does not append anything if sfp.js is already loaded in the safeframe', function () { + window.STR = { Tag: true }; + sharethroughInternal.handleIframe(); + expect(windowSpy.notCalled).to.be.true; + expect(windowTopSpy.notCalled).to.be.true; + }); + }); + + describe('we are able to bust out of the iframe', function () { + it('appends sfp.js to window.top', function () { + sharethroughInternal.handleIframe(); + expect(windowSpy.calledOnce).to.be.true; + expect(windowTopSpy.calledOnce).to.be.true; + }); + + it('only appends sfp-set-targeting.js if sfp.js is already loaded on the page', function () { + window.top.STR = { Tag: true }; + sharethroughInternal.handleIframe(); + expect(windowSpy.calledOnce).to.be.true; + expect(windowTopSpy.notCalled).to.be.true; + }); + }); +}); describe('sharethrough adapter spec', function () { describe('.code', function () { it('should return a bidder code of sharethrough', function () { expect(spec.code).to.eql('sharethrough'); }); - }) + }); describe('.isBidRequestValid', function () { it('should return false if req has no pkey', function () { @@ -133,44 +208,86 @@ describe('sharethrough adapter spec', function () { }); it('should return true if req is correct', function () { - expect(spec.isBidRequestValid(bidderRequest[0])).to.eq(true); - expect(spec.isBidRequestValid(bidderRequest[1])).to.eq(true); + expect(spec.isBidRequestValid(bidRequests[0])).to.eq(true); + expect(spec.isBidRequestValid(bidRequests[1])).to.eq(true); }) }); describe('.buildRequests', function () { it('should return an array of requests', function () { - const bidRequests = spec.buildRequests(bidderRequest); + const builtBidRequests = spec.buildRequests(bidRequests); - expect(bidRequests[0].url).to.eq( - 'http://btlr.sharethrough.com/header-bid/v1'); - expect(bidRequests[1].url).to.eq( - 'http://btlr.sharethrough.com/header-bid/v1') - expect(bidRequests[0].method).to.eq('GET'); + expect(builtBidRequests[0].url).to.eq( + 'http://btlr.sharethrough.com/WYu2BXv1/v1'); + expect(builtBidRequests[1].url).to.eq( + 'http://btlr.sharethrough.com/WYu2BXv1/v1'); + expect(builtBidRequests[0].method).to.eq('GET'); + }); + + it('should set the instant_play_capable parameter correctly based on browser userAgent string', function () { + setUserAgent('Android Chrome/60'); + let builtBidRequests = spec.buildRequests(bidRequests); + expect(builtBidRequests[0].data.instant_play_capable).to.be.true; + + setUserAgent('iPhone Version/11'); + builtBidRequests = spec.buildRequests(bidRequests); + expect(builtBidRequests[0].data.instant_play_capable).to.be.true; + + setUserAgent('iPhone CriOS/60'); + builtBidRequests = spec.buildRequests(bidRequests); + expect(builtBidRequests[0].data.instant_play_capable).to.be.true; + + setUserAgent('Android Chrome/50'); + builtBidRequests = spec.buildRequests(bidRequests); + expect(builtBidRequests[0].data.instant_play_capable).to.be.false; + + setUserAgent('Android Chrome'); + builtBidRequests = spec.buildRequests(bidRequests); + expect(builtBidRequests[0].data.instant_play_capable).to.be.false; + + setUserAgent(undefined); + builtBidRequests = spec.buildRequests(bidRequests); + expect(builtBidRequests[0].data.instant_play_capable).to.be.false; }); it('should add consent parameters if gdprConsent is present', function () { const gdprConsent = { consentString: 'consent_string123', gdprApplies: true }; - const fakeBidRequest = { gdprConsent: gdprConsent }; - const bidRequest = spec.buildRequests(bidderRequest, fakeBidRequest)[0]; + const bidderRequest = { gdprConsent: gdprConsent }; + const bidRequest = spec.buildRequests(bidRequests, bidderRequest)[0]; expect(bidRequest.data.consent_required).to.eq(true); expect(bidRequest.data.consent_string).to.eq('consent_string123'); }); it('should handle gdprConsent is present but values are undefined case', function () { const gdprConsent = { consent_string: undefined, gdprApplies: undefined }; - const fakeBidRequest = { gdprConsent: gdprConsent }; - const bidRequest = spec.buildRequests(bidderRequest, fakeBidRequest)[0]; + const bidderRequest = { gdprConsent: gdprConsent }; + const bidRequest = spec.buildRequests(bidRequests, bidderRequest)[0]; expect(bidRequest.data).to.not.include.any.keys('consent_string') }); + + it('should add the ttduid parameter if a bid request contains a value for Unified ID from The Trade Desk', function () { + const bidRequest = spec.buildRequests(bidRequests)[0]; + expect(bidRequest.data.ttduid).to.eq('fake-tdid'); + }); + + it('should add Sharethrough specific parameters', function () { + const builtBidRequests = spec.buildRequests(bidRequests); + expect(builtBidRequests[0]).to.deep.include({ + strData: { + skipIframeBusting: undefined, + iframeSize: undefined, + sizes: [[600, 300]] + } + }); + }); }); describe('.interpretResponse', function () { it('returns a correctly parsed out response', function () { expect(spec.interpretResponse(bidderResponse, prebidRequests[0])[0]).to.include( { - width: 0, - height: 0, + width: 1, + height: 1, cpm: 12.34, creativeId: 'aCreativeId', dealId: 'aDealId', @@ -180,7 +297,7 @@ describe('sharethrough adapter spec', function () { }); }); - it('returns a correctly parsed out response with largest size when strData.stayInIframe is true', function () { + it('returns a correctly parsed out response with largest size when strData.skipIframeBusting is true', function () { expect(spec.interpretResponse(bidderResponse, prebidRequests[1])[0]).to.include( { width: 300, @@ -194,7 +311,7 @@ describe('sharethrough adapter spec', function () { }); }); - it('returns a correctly parsed out response with explicitly defined size when strData.stayInIframe is true and strData.iframeSize is provided', function () { + it('returns a correctly parsed out response with explicitly defined size when strData.skipIframeBusting is true and strData.iframeSize is provided', function () { expect(spec.interpretResponse(bidderResponse, prebidRequests[2])[0]).to.include( { width: 500, @@ -208,6 +325,34 @@ describe('sharethrough adapter spec', function () { }); }); + it('returns a correctly parsed out response with explicitly defined size when strData.skipIframeBusting is false and strData.sizes contains [0, 0] only', function () { + expect(spec.interpretResponse(bidderResponse, prebidRequests[3])[0]).to.include( + { + width: 0, + height: 0, + cpm: 12.34, + creativeId: 'aCreativeId', + dealId: 'aDealId', + currency: 'USD', + netRevenue: true, + ttl: 360, + }); + }); + + it('returns a correctly parsed out response with explicitly defined size when strData.skipIframeBusting is false and strData.sizes contains multiple sizes', function () { + expect(spec.interpretResponse(bidderResponse, prebidRequests[4])[0]).to.include( + { + width: 300, + height: 300, + cpm: 12.34, + creativeId: 'aCreativeId', + dealId: 'aDealId', + currency: 'USD', + netRevenue: true, + ttl: 360, + }); + }); + it('returns a blank array if there are no creatives', function () { const bidResponse = { body: { creatives: [] } }; expect(spec.interpretResponse(bidResponse, prebidRequests[0])).to.be.an('array').that.is.empty; @@ -223,29 +368,27 @@ describe('sharethrough adapter spec', function () { expect(spec.interpretResponse(bidResponse, prebidRequests[0])).to.be.an('array').that.is.empty; }); - it('correctly generates ad markup', function () { + it('correctly generates ad markup when skipIframeBusting is false', function () { const adMarkup = spec.interpretResponse(bidderResponse, prebidRequests[0])[0].ad; let resp = null; expect(() => btoa(JSON.stringify(bidderResponse))).to.throw(); - expect(() => resp = b64EncodeUnicode(JSON.stringify(bidderResponse))).not.to.throw(); + expect(() => resp = sharethroughInternal.b64EncodeUnicode(JSON.stringify(bidderResponse))).not.to.throw(); expect(adMarkup).to.match( /data-str-native-key="pKey" data-stx-response-name=\"str_response_bidId\"/); expect(!!adMarkup.indexOf(resp)).to.eql(true); - expect(adMarkup).to.match( - /"'; + +describe('slimcutBidAdapter', function() { + const adapter = newBidder(spec); + + describe('inherited functions', function() { + it('exists and is a function', function() { + expect(adapter.callBids).to.exist.and.to.be.a('function'); + }); + }); + + describe('isBidRequestValid', function() { + let bid = { + 'bidder': 'slimcut', + 'params': { + 'placementId': 83 + }, + 'adUnitCode': 'adunit-code', + 'sizes': [[300, 250], [300, 600]], + 'bidId': '3c871ffa8ef14c', + 'bidderRequestId': 'b41642f1aee381', + 'auctionId': '4e156668c977d7' + }; + + it('should return true when required params found', function() { + expect(spec.isBidRequestValid(bid)).to.equal(true); + }); + + it('should return false when placementId is not valid (letters)', function() { + let bid = Object.assign({}, bid); + delete bid.params; + bid.params = { + 'placementId': 'ABCD' + }; + + expect(spec.isBidRequestValid(bid)).to.equal(false); + }); + + it('should return false when placementId < 0', function() { + let bid = Object.assign({}, bid); + delete bid.params; + bid.params = { + 'placementId': -1 + }; + + expect(spec.isBidRequestValid(bid)).to.equal(false); + }); + + it('should return false when required params are not passed', function() { + let bid = Object.assign({}, bid); + delete bid.params; + + bid.params = {}; + + expect(spec.isBidRequestValid(bid)).to.equal(false); + }); + }); + + describe('buildRequests', function() { + let bidRequests = [ + { + 'bidder': 'teads', + 'params': { + 'placementId': 10433394 + }, + 'adUnitCode': 'adunit-code', + 'sizes': [[300, 250], [300, 600]], + 'bidId': '3c871ffa8ef14c', + 'bidderRequestId': 'b41642f1aee381', + 'auctionId': '4e156668c977d7', + 'deviceWidth': 1680 + } + ]; + + let bidderResquestDefault = { + 'auctionId': '4e156668c977d7', + 'bidderRequestId': 'b41642f1aee381', + 'timeout': 3000 + }; + + it('sends bid request to ENDPOINT via POST', function() { + const request = spec.buildRequests(bidRequests, bidderResquestDefault); + + expect(request.url).to.equal(ENDPOINT); + expect(request.method).to.equal('POST'); + }); + + it('should send GDPR to endpoint', function() { + let consentString = 'JRJ8RKfDeBNsERRDCSAAZ+A=='; + let bidderRequest = { + 'auctionId': '4e156668c977d7', + 'bidderRequestId': 'b41642f1aee381', + 'timeout': 3000, + 'gdprConsent': { + 'consentString': consentString, + 'gdprApplies': true, + 'vendorData': { + 'hasGlobalConsent': false + } + } + }; + + const request = spec.buildRequests(bidRequests, bidderRequest); + const payload = JSON.parse(request.data); + + expect(payload.gdpr_iab).to.exist; + expect(payload.gdpr_iab.consent).to.equal(consentString); + }); + + it('should add referer info to payload', function () { + const bidRequest = Object.assign({}, bidRequests[0]) + const bidderRequest = { + refererInfo: { + referer: 'http://example.com/page.html', + reachedTop: true, + numIframes: 2 + } + } + const request = spec.buildRequests([bidRequest], bidderRequest); + const payload = JSON.parse(request.data); + + expect(payload.referrer).to.exist; + expect(payload.referrer).to.deep.equal('http://example.com/page.html') + }); + }); + + describe('getUserSyncs', () => { + let bids = { + 'body': { + 'responses': [{ + 'ad': AD_SCRIPT, + 'cpm': 0.5, + 'currency': 'USD', + 'height': 250, + 'netRevenue': true, + 'requestId': '3ede2a3fa0db94', + 'ttl': 360, + 'width': 300, + 'creativeId': 'er2ee', + 'transactionId': 'deadb33f', + 'winUrl': 'https://sb.freeskreen.com/win' + }] + } + }; + + it('should get the correct number of sync urls', () => { + let urls = spec.getUserSyncs({iframeEnabled: true}, bids); + expect(urls.length).to.equal(1); + expect(urls[0].url).to.equal('//sb.freeskreen.com/async_usersync.html'); + }); + + it('should return no url if not iframe enabled', () => { + let urls = spec.getUserSyncs({iframeEnabled: false}, bids); + expect(urls.length).to.equal(0); + }); + }); + + describe('interpretResponse', function() { + let bids = { + 'body': { + 'responses': [{ + 'ad': AD_SCRIPT, + 'cpm': 0.5, + 'currency': 'USD', + 'height': 250, + 'netRevenue': true, + 'requestId': '3ede2a3fa0db94', + 'ttl': 360, + 'width': 300, + 'creativeId': 'er2ee', + 'transactionId': 'deadb33f', + 'winUrl': 'https://sb.freeskreen.com/win' + }] + } + }; + + it('should get correct bid response', function() { + let expectedResponse = [{ + 'cpm': 0.5, + 'width': 300, + 'height': 250, + 'currency': 'USD', + 'netRevenue': true, + 'ttl': 360, + 'ad': AD_SCRIPT, + 'requestId': '3ede2a3fa0db94', + 'creativeId': 'er2ee', + 'transactionId': 'deadb33f', + 'winUrl': 'https://sb.freeskreen.com/win' + }]; + + let result = spec.interpretResponse(bids); + expect(Object.keys(result[0])).to.deep.equal(Object.keys(expectedResponse[0])); + }); + + it('handles nobid responses', function() { + let bids = { + 'body': { + 'responses': [] + } + }; + + let result = spec.interpretResponse(bids); + expect(result.length).to.equal(0); + }); + }); +}); diff --git a/test/spec/modules/smilewantedBidAdapter_spec.js b/test/spec/modules/smilewantedBidAdapter_spec.js index 489f393523a..144c7ca60f6 100644 --- a/test/spec/modules/smilewantedBidAdapter_spec.js +++ b/test/spec/modules/smilewantedBidAdapter_spec.js @@ -5,62 +5,151 @@ import { config } from 'src/config'; import * as utils from 'src/utils'; import { requestBidsHook } from 'modules/consentManagement'; +const DISPLAY_REQUEST = [{ + adUnitCode: 'sw_300x250', + bidId: '12345', + sizes: [ + [300, 250], + [300, 200] + ], + bidder: 'smilewanted', + params: { + zoneId: 1, + bidfloor: 2.50 + }, + requestId: 'request_abcd1234', + transactionId: 'trans_abcd1234' +}]; + +const BID_RESPONSE_DISPLAY = { + body: { + cpm: 3, + width: 300, + height: 250, + creativeId: 'crea_sw_1', + currency: 'EUR', + isNetCpm: true, + ttl: 300, + ad: '< --- sw script --- >', + cSyncUrl: 'https://csync.smilewanted.com' + } +}; + +const VIDEO_INSTREAM_REQUEST = [{ + code: 'video1', + mediaTypes: { + video: {} + }, + sizes: [ + [640, 480] + ], + bidder: 'smilewanted', + params: { + zoneId: 2, + bidfloor: 2.50 + }, + requestId: 'request_abcd1234', + transactionId: 'trans_abcd1234' +}]; + +const BID_RESPONSE_VIDEO_INSTREAM = { + body: { + cpm: 3, + width: 640, + height: 480, + creativeId: 'crea_sw_2', + currency: 'EUR', + isNetCpm: true, + ttl: 300, + ad: 'https://vast.smilewanted.com', + cSyncUrl: 'https://csync.smilewanted.com', + formatTypeSw: 'video_instream' + } +}; + +const VIDEO_OUTSTREAM_REQUEST = [{ + code: 'video1', + mediaTypes: { + video: {} + }, + sizes: [ + [640, 480] + ], + bidder: 'smilewanted', + params: { + zoneId: 3, + bidfloor: 2.50 + }, + requestId: 'request_abcd1234', + transactionId: 'trans_abcd1234' +}]; + +const BID_RESPONSE_VIDEO_OUTSTREAM = { + body: { + cpm: 3, + width: 640, + height: 480, + creativeId: 'crea_sw_3', + currency: 'EUR', + isNetCpm: true, + ttl: 300, + ad: 'https://vast.smilewanted.com', + cSyncUrl: 'https://csync.smilewanted.com', + OustreamTemplateUrl: 'https://prebid.smilewanted.com/scripts_outstream/infeed.js', + formatTypeSw: 'video_outstream' + } +}; + // Default params with optional ones describe('smilewantedBidAdapterTests', function () { - var DEFAULT_PARAMS = [{ - adUnitCode: 'sw_300x250', - bidId: '12345', - sizes: [ - [300, 250], - [300, 200] - ], - bidder: 'smilewanted', - params: { - zoneId: '1234', - bidfloor: 2.50 - }, - requestId: 'request_abcd1234', - transactionId: 'trans_abcd1234' - }]; - - var BID_RESPONSE = { - body: { - cpm: 3, - width: 300, - height: 250, - creativeId: 'crea_sw_1', - currency: 'EUR', - isNetCpm: true, - ttl: 300, - adUrl: 'https://www.smilewanted.com', - ad: '< --- sw script --- >', - cSyncUrl: 'https://csync.smilewanted.com' - } - }; - it('SmileWanted - Verify build request', function () { config.setConfig({ 'currency': { 'adServerCurrency': 'EUR' } }); - const request = spec.buildRequests(DEFAULT_PARAMS); - expect(request[0]).to.have.property('url').and.to.equal('https://prebid.smilewanted.com'); - expect(request[0]).to.have.property('method').and.to.equal('POST'); - const requestContent = JSON.parse(request[0].data); - expect(requestContent).to.have.property('zoneId').and.to.equal('1234'); - expect(requestContent).to.have.property('currencyCode').and.to.equal('EUR'); - expect(requestContent).to.have.property('bidfloor').and.to.equal(2.50); - expect(requestContent).to.have.property('sizes'); - expect(requestContent.sizes[0]).to.have.property('w').and.to.equal(300); - expect(requestContent.sizes[0]).to.have.property('h').and.to.equal(250); - expect(requestContent.sizes[1]).to.have.property('w').and.to.equal(300); - expect(requestContent.sizes[1]).to.have.property('h').and.to.equal(200); - expect(requestContent).to.have.property('transactionId').and.to.not.equal(null).and.to.not.be.undefined; + + const requestDisplay = spec.buildRequests(DISPLAY_REQUEST); + expect(requestDisplay[0]).to.have.property('url').and.to.equal('https://prebid.smilewanted.com'); + expect(requestDisplay[0]).to.have.property('method').and.to.equal('POST'); + const requestDisplayContent = JSON.parse(requestDisplay[0].data); + expect(requestDisplayContent).to.have.property('zoneId').and.to.equal(1); + expect(requestDisplayContent).to.have.property('currencyCode').and.to.equal('EUR'); + expect(requestDisplayContent).to.have.property('bidfloor').and.to.equal(2.50); + expect(requestDisplayContent).to.have.property('sizes'); + expect(requestDisplayContent.sizes[0]).to.have.property('w').and.to.equal(300); + expect(requestDisplayContent.sizes[0]).to.have.property('h').and.to.equal(250); + expect(requestDisplayContent.sizes[1]).to.have.property('w').and.to.equal(300); + expect(requestDisplayContent.sizes[1]).to.have.property('h').and.to.equal(200); + expect(requestDisplayContent).to.have.property('transactionId').and.to.not.equal(null).and.to.not.be.undefined; + + const requestVideoInstream = spec.buildRequests(VIDEO_INSTREAM_REQUEST); + expect(requestVideoInstream[0]).to.have.property('url').and.to.equal('https://prebid.smilewanted.com'); + expect(requestVideoInstream[0]).to.have.property('method').and.to.equal('POST'); + const requestVideoInstreamContent = JSON.parse(requestVideoInstream[0].data); + expect(requestVideoInstreamContent).to.have.property('zoneId').and.to.equal(2); + expect(requestVideoInstreamContent).to.have.property('currencyCode').and.to.equal('EUR'); + expect(requestVideoInstreamContent).to.have.property('bidfloor').and.to.equal(2.50); + expect(requestVideoInstreamContent).to.have.property('sizes'); + expect(requestVideoInstreamContent.sizes[0]).to.have.property('w').and.to.equal(640); + expect(requestVideoInstreamContent.sizes[0]).to.have.property('h').and.to.equal(480); + expect(requestVideoInstreamContent).to.have.property('transactionId').and.to.not.equal(null).and.to.not.be.undefined; + + const requestVideoOutstream = spec.buildRequests(VIDEO_OUTSTREAM_REQUEST); + expect(requestVideoOutstream[0]).to.have.property('url').and.to.equal('https://prebid.smilewanted.com'); + expect(requestVideoOutstream[0]).to.have.property('method').and.to.equal('POST'); + const requestVideoOutstreamContent = JSON.parse(requestVideoOutstream[0].data); + expect(requestVideoOutstreamContent).to.have.property('zoneId').and.to.equal(3); + expect(requestVideoOutstreamContent).to.have.property('currencyCode').and.to.equal('EUR'); + expect(requestVideoOutstreamContent).to.have.property('bidfloor').and.to.equal(2.50); + expect(requestVideoOutstreamContent).to.have.property('sizes'); + expect(requestVideoOutstreamContent.sizes[0]).to.have.property('w').and.to.equal(640); + expect(requestVideoOutstreamContent.sizes[0]).to.have.property('h').and.to.equal(480); + expect(requestVideoOutstreamContent).to.have.property('transactionId').and.to.not.equal(null).and.to.not.be.undefined; }); it('SmileWanted - Verify build request with referrer', function () { - const request = spec.buildRequests(DEFAULT_PARAMS, { + const request = spec.buildRequests(DISPLAY_REQUEST, { refererInfo: { referer: 'http://localhost/Prebid.js/integrationExamples/gpt/hello_world.html' } @@ -87,7 +176,7 @@ describe('smilewantedBidAdapterTests', function () { allowAuctionWithoutConsent: true } }); - const request = spec.buildRequests(DEFAULT_PARAMS, { + const request = spec.buildRequests(DISPLAY_REQUEST, { gdprConsent: { consentString: 'BOO_ch7OO_ch7AKABBENA2-AAAAZ97_______9______9uz_Gv_r_f__33e8_39v_h_7_u___m_-zzV4-_lvQV1yPA1OrfArgFA', gdprApplies: true @@ -110,7 +199,7 @@ describe('smilewantedBidAdapterTests', function () { allowAuctionWithoutConsent: true } }); - const request = spec.buildRequests(DEFAULT_PARAMS, { + const request = spec.buildRequests(DISPLAY_REQUEST, { gdprConsent: { consentString: 'BOO_ch7OO_ch7AKABBENA2-AAAAZ97_______9______9uz_Gv_r_f__33e8_39v_h_7_u___m_-zzV4-_lvQV1yPA1OrfArgFA' } @@ -121,13 +210,12 @@ describe('smilewantedBidAdapterTests', function () { }); }); - it('SmileWanted - Verify parse response', function () { - const request = spec.buildRequests(DEFAULT_PARAMS); - const bids = spec.interpretResponse(BID_RESPONSE, request[0]); + it('SmileWanted - Verify parse response - Display', function () { + const request = spec.buildRequests(DISPLAY_REQUEST); + const bids = spec.interpretResponse(BID_RESPONSE_DISPLAY, request[0]); expect(bids).to.have.lengthOf(1); const bid = bids[0]; expect(bid.cpm).to.equal(3); - expect(bid.adUrl).to.equal('https://www.smilewanted.com'); expect(bid.ad).to.equal('< --- sw script --- >'); expect(bid.width).to.equal(300); expect(bid.height).to.equal(250); @@ -135,10 +223,56 @@ describe('smilewantedBidAdapterTests', function () { expect(bid.currency).to.equal('EUR'); expect(bid.netRevenue).to.equal(true); expect(bid.ttl).to.equal(300); - expect(bid.requestId).to.equal(DEFAULT_PARAMS[0].bidId); + expect(bid.requestId).to.equal(DISPLAY_REQUEST[0].bidId); + + expect(function () { + spec.interpretResponse(BID_RESPONSE_DISPLAY, { + data: 'invalid Json' + }) + }).to.not.throw(); + }); + + it('SmileWanted - Verify parse response - Video Instream', function () { + const request = spec.buildRequests(VIDEO_INSTREAM_REQUEST); + const bids = spec.interpretResponse(BID_RESPONSE_VIDEO_INSTREAM, request[0]); + expect(bids).to.have.lengthOf(1); + const bid = bids[0]; + expect(bid.cpm).to.equal(3); + expect(bid.ad).to.equal(null); + expect(bid.vastUrl).to.equal('https://vast.smilewanted.com'); + expect(bid.width).to.equal(640); + expect(bid.height).to.equal(480); + expect(bid.creativeId).to.equal('crea_sw_2'); + expect(bid.currency).to.equal('EUR'); + expect(bid.netRevenue).to.equal(true); + expect(bid.ttl).to.equal(300); + expect(bid.requestId).to.equal(VIDEO_INSTREAM_REQUEST[0].bidId); + + expect(function () { + spec.interpretResponse(BID_RESPONSE_VIDEO_INSTREAM, { + data: 'invalid Json' + }) + }).to.not.throw(); + }); + + it('SmileWanted - Verify parse response - Video Oustream', function () { + const request = spec.buildRequests(VIDEO_OUTSTREAM_REQUEST); + const bids = spec.interpretResponse(BID_RESPONSE_VIDEO_OUTSTREAM, request[0]); + expect(bids).to.have.lengthOf(1); + const bid = bids[0]; + expect(bid.cpm).to.equal(3); + expect(bid.vastUrl).to.equal('https://vast.smilewanted.com'); + expect(bid.renderer.url).to.equal('https://prebid.smilewanted.com/scripts_outstream/infeed.js'); + expect(bid.width).to.equal(640); + expect(bid.height).to.equal(480); + expect(bid.creativeId).to.equal('crea_sw_3'); + expect(bid.currency).to.equal('EUR'); + expect(bid.netRevenue).to.equal(true); + expect(bid.ttl).to.equal(300); + expect(bid.requestId).to.equal(VIDEO_OUTSTREAM_REQUEST[0].bidId); expect(function () { - spec.interpretResponse(BID_RESPONSE, { + spec.interpretResponse(BID_RESPONSE_VIDEO_OUTSTREAM, { data: 'invalid Json' }) }).to.not.throw(); @@ -155,7 +289,7 @@ describe('smilewantedBidAdapterTests', function () { }); it('SmileWanted - Verify if bid request valid', function () { - expect(spec.isBidRequestValid(DEFAULT_PARAMS[0])).to.equal(true); + expect(spec.isBidRequestValid(DISPLAY_REQUEST[0])).to.equal(true); expect(spec.isBidRequestValid({ params: { zoneId: 1234 @@ -173,14 +307,14 @@ describe('smilewantedBidAdapterTests', function () { it('SmileWanted - Verify user sync', function () { var syncs = spec.getUserSyncs({ iframeEnabled: true - }, [BID_RESPONSE]); + }, [BID_RESPONSE_DISPLAY]); expect(syncs).to.have.lengthOf(1); expect(syncs[0].type).to.equal('iframe'); expect(syncs[0].url).to.equal('https://csync.smilewanted.com'); syncs = spec.getUserSyncs({ iframeEnabled: false - }, [BID_RESPONSE]); + }, [BID_RESPONSE_DISPLAY]); expect(syncs).to.have.lengthOf(0); syncs = spec.getUserSyncs({ diff --git a/test/spec/modules/somoaudienceBidAdapter_spec.js b/test/spec/modules/somoBidAdapter_spec.js similarity index 96% rename from test/spec/modules/somoaudienceBidAdapter_spec.js rename to test/spec/modules/somoBidAdapter_spec.js index bdd2dade96f..16fd43841b7 100644 --- a/test/spec/modules/somoaudienceBidAdapter_spec.js +++ b/test/spec/modules/somoBidAdapter_spec.js @@ -1,19 +1,19 @@ import {expect} from 'chai'; -import {spec} from 'modules/somoaudienceBidAdapter'; +import {spec} from 'modules/somoBidAdapter'; import * as utils from 'src/utils'; describe('Somo Audience Adapter Tests', function () { describe('isBidRequestValid', function () { it('should return false when given an invalid bid', function () { const bid = { - bidder: 'somoaudience', + bidder: 'somo', }; const isValid = spec.isBidRequestValid(bid); expect(isValid).to.equal(false); }); it('should return true when given a placementId bid', function () { const bid = { - bidder: 'somoaudience', + bidder: 'somo', params: { placementId: 'test' } @@ -27,7 +27,7 @@ describe('Somo Audience Adapter Tests', function () { describe('buildBannerRequests', function () { it('should properly build a banner request with type not defined and sizes not defined', function () { const bidRequests = [{ - bidder: 'somoaudience', + bidder: 'somo', params: { placementId: 'test' } @@ -49,7 +49,7 @@ describe('Somo Audience Adapter Tests', function () { it('should properly build a banner request with sizes defined in 2d array', function () { const bidRequests = [{ - bidder: 'somoaudience', + bidder: 'somo', sizes: [[300, 250]], params: { placementId: 'test' @@ -71,7 +71,7 @@ describe('Somo Audience Adapter Tests', function () { }); it('should properly build a banner request with sizes defined in 1d array', function () { const bidRequests = [{ - bidder: 'somoaudience', + bidder: 'somo', sizes: [300, 250], params: { placementId: 'test' @@ -99,7 +99,7 @@ describe('Somo Audience Adapter Tests', function () { it('should populate optional banner parameters', function () { const bidRequests = [ { - bidder: 'somoaudience', + bidder: 'somo', sizes: [[300, 200]], mediaType: 'banner', params: { @@ -128,7 +128,7 @@ describe('Somo Audience Adapter Tests', function () { describe('buildVideoRequests', function () { it('should properly build a video request with sizes defined', function () { const bidRequests = [{ - bidder: 'somoaudience', + bidder: 'somo', mediaTypes: { video: {} }, @@ -151,7 +151,7 @@ describe('Somo Audience Adapter Tests', function () { it('should properly build a video request with sizes defined in 2d array', function () { const bidRequests = [{ - bidder: 'somoaudience', + bidder: 'somo', mediaTypes: { video: {} }, @@ -173,7 +173,7 @@ describe('Somo Audience Adapter Tests', function () { }); it('should properly build a video request with sizes not defined', function () { const bidRequests = [{ - bidder: 'somoaudience', + bidder: 'somo', mediaType: 'video', params: { placementId: 'test' @@ -199,7 +199,7 @@ describe('Somo Audience Adapter Tests', function () { it('should populate optional video parameters', function () { const bidRequests = [ { - bidder: 'somoaudience', + bidder: 'somo', sizes: [[200, 300]], mediaType: 'video', params: { @@ -242,7 +242,7 @@ describe('Somo Audience Adapter Tests', function () { describe('buildSiteRequests', function () { it('should fill in basic site parameters', function () { const bidRequests = [{ - bidder: 'somoaudience', + bidder: 'somo', params: { placementId: 'test' } @@ -258,7 +258,7 @@ describe('Somo Audience Adapter Tests', function () { it('should fill in optional site parameters', function () { const bidRequests = [{ - bidder: 'somoaudience', + bidder: 'somo', params: { placementId: 'test', site: { @@ -285,7 +285,7 @@ describe('Somo Audience Adapter Tests', function () { describe('buildAppRequests', function () { it('should fill in app parameters', function () { const bidRequests = [{ - bidder: 'somoaudience', + bidder: 'somo', params: { placementId: 'test', app: { @@ -325,7 +325,7 @@ describe('Somo Audience Adapter Tests', function () { it('should properly build request with gdpr consent', function () { const bidRequests = [{ - bidder: 'somoaudience', + bidder: 'somo', params: { placementId: 'test' } @@ -342,7 +342,7 @@ describe('Somo Audience Adapter Tests', function () { it('should properly build request with gdpr not applies', function () { bidderRequest.gdprConsent.gdprApplies = false; const bidRequests = [{ - bidder: 'somoaudience', + bidder: 'somo', params: { placementId: 'test' } @@ -362,7 +362,7 @@ describe('Somo Audience Adapter Tests', function () { it('should populate optional parameters', function () { const bidRequests = [ { - bidder: 'somoaudience', + bidder: 'somo', params: { placementId: 'test', bcat: ['IAB-2', 'IAB-7'], @@ -389,7 +389,7 @@ describe('Somo Audience Adapter Tests', function () { it('Verify banner parse response', function () { const bidRequests = [ { - bidder: 'somoaudience', + bidder: 'somo', params: { placementId: 'test', }, @@ -417,7 +417,7 @@ describe('Somo Audience Adapter Tests', function () { it('Verify video parse response', function () { const bidRequests = [ { - bidder: 'somoaudience', + bidder: 'somo', mediaTypes: { video: { } diff --git a/test/spec/modules/sonobiBidAdapter_spec.js b/test/spec/modules/sonobiBidAdapter_spec.js index 010d07f1c37..dc536846ae2 100644 --- a/test/spec/modules/sonobiBidAdapter_spec.js +++ b/test/spec/modules/sonobiBidAdapter_spec.js @@ -1,6 +1,7 @@ import { expect } from 'chai' import { spec, _getPlatform } from 'modules/sonobiBidAdapter' import { newBidder } from 'src/adapters/bidderFactory' +import {userSync} from '../../../src/userSync'; describe('SonobiBidAdapter', function () { const adapter = newBidder(spec) @@ -101,7 +102,29 @@ describe('SonobiBidAdapter', function () { }) describe('.buildRequests', function () { + beforeEach(function() { + sinon.stub(userSync, 'canBidderRegisterSync'); + }); + afterEach(function() { + userSync.canBidderRegisterSync.restore(); + }); let bidRequest = [{ + 'schain': { + 'ver': '1.0', + 'complete': 1, + 'nodes': [ + { + 'asi': 'indirectseller.com', + 'sid': '00001', + 'hp': 1 + }, + { + 'asi': 'indirectseller-2.com', + 'sid': '00002', + 'hp': 0 + }, + ] + }, 'bidder': 'sonobi', 'params': { 'placement_id': '1a2b3c4d5e6f1a2b3c4d', @@ -283,29 +306,42 @@ describe('SonobiBidAdapter', function () { delete bidRequest[1].params.hfa; bidRequest[0].crumbs = {'pubcid': 'abcd-efg-0101'}; bidRequest[1].crumbs = {'pubcid': 'abcd-efg-0101'}; - const bidRequests = spec.buildRequests(bidRequest, bidderRequests) - expect(bidRequests.url).to.equal('https://apex.go.sonobi.com/trinity.json') - expect(bidRequests.method).to.equal('GET') - expect(bidRequests.data.ref).not.to.be.empty - expect(bidRequests.data.s).not.to.be.empty + const bidRequests = spec.buildRequests(bidRequest, bidderRequests); + expect(bidRequests.url).to.equal('https://apex.go.sonobi.com/trinity.json'); + expect(bidRequests.method).to.equal('GET'); + expect(bidRequests.data.ref).not.to.be.empty; + expect(bidRequests.data.s).not.to.be.empty; expect(bidRequests.data.hfa).to.equal('PRE-abcd-efg-0101'); - }) + }); it('should return a properly formatted request with commonid from User ID as hfa', function () { delete bidRequest[0].params.hfa; delete bidRequest[1].params.hfa; bidRequest[0].userId = {'pubcid': 'abcd-efg-0101'}; bidRequest[1].userId = {'pubcid': 'abcd-efg-0101'}; - const bidRequests = spec.buildRequests(bidRequest, bidderRequests) - expect(bidRequests.url).to.equal('https://apex.go.sonobi.com/trinity.json') - expect(bidRequests.method).to.equal('GET') - expect(bidRequests.data.ref).not.to.be.empty - expect(bidRequests.data.s).not.to.be.empty + const bidRequests = spec.buildRequests(bidRequest, bidderRequests); + expect(bidRequests.url).to.equal('https://apex.go.sonobi.com/trinity.json'); + expect(bidRequests.method).to.equal('GET'); + expect(bidRequests.data.ref).not.to.be.empty; + expect(bidRequests.data.s).not.to.be.empty; expect(bidRequests.data.hfa).to.equal('PRE-abcd-efg-0101'); delete bidRequest[0].userId; delete bidRequest[1].userId; }) + it('should return a properly formatted request with unified id from User ID as tdid', function () { + delete bidRequest[0].params.tdid; + delete bidRequest[1].params.tdid; + bidRequest[0].userId = {'tdid': 'td-abcd-efg-0101'}; + bidRequest[1].userId = {'tdid': 'td-abcd-efg-0101'}; + const bidRequests = spec.buildRequests(bidRequest, bidderRequests); + expect(bidRequests.url).to.equal('https://apex.go.sonobi.com/trinity.json'); + expect(bidRequests.method).to.equal('GET'); + expect(bidRequests.data.ref).not.to.be.empty; + expect(bidRequests.data.s).not.to.be.empty; + expect(bidRequests.data.tdid).to.equal('td-abcd-efg-0101'); + }) + it('should return a properly formatted request with hfa preferred over commonid', function () { bidRequest[0].params.hfa = 'hfakey'; bidRequest[1].params.hfa = 'hfakey'; @@ -318,6 +354,56 @@ describe('SonobiBidAdapter', function () { expect(bidRequests.data.s).not.to.be.empty expect(bidRequests.data.hfa).to.equal('hfakey') }) + + it('should set ius as 0 if Sonobi cannot drop iframe pixels', function () { + userSync.canBidderRegisterSync.returns(false); + const bidRequests = spec.buildRequests(bidRequest, bidderRequests); + expect(bidRequests.data.ius).to.equal(0); + }); + + it('should set ius as 1 if Sonobi can drop iframe pixels', function() { + userSync.canBidderRegisterSync.returns(true); + const bidRequests = spec.buildRequests(bidRequest, bidderRequests); + expect(bidRequests.data.ius).to.equal(1); + }); + + it('should return a properly formatted request with schain defined', function () { + const bidRequests = spec.buildRequests(bidRequest, bidderRequests); + expect(JSON.parse(bidRequests.data.schain)).to.deep.equal(bidRequest[0].schain) + }); + + it('should return a properly formatted request with userid as a JSON-encoded set of User ID results', function () { + bidRequest[0].userId = {'pubcid': 'abcd-efg-0101', 'tdid': 'td-abcd-efg-0101'}; + bidRequest[1].userId = {'pubcid': 'abcd-efg-0101', 'tdid': 'td-abcd-efg-0101'}; + const bidRequests = spec.buildRequests(bidRequest, bidderRequests); + expect(bidRequests.url).to.equal('https://apex.go.sonobi.com/trinity.json'); + expect(bidRequests.method).to.equal('GET'); + expect(bidRequests.data.ref).not.to.be.empty; + expect(bidRequests.data.s).not.to.be.empty; + expect(JSON.parse(bidRequests.data.userid)).to.eql({'pubcid': 'abcd-efg-0101', 'tdid': 'td-abcd-efg-0101'}); + }); + + it('should return a properly formatted request with userid omitted if there are no userIds', function () { + bidRequest[0].userId = {}; + bidRequest[1].userId = {}; + const bidRequests = spec.buildRequests(bidRequest, bidderRequests); + expect(bidRequests.url).to.equal('https://apex.go.sonobi.com/trinity.json'); + expect(bidRequests.method).to.equal('GET'); + expect(bidRequests.data.ref).not.to.be.empty; + expect(bidRequests.data.s).not.to.be.empty; + expect(bidRequests.data.userid).to.equal(undefined); + }); + + it('should return a properly formatted request with userid omitted', function () { + bidRequest[0].userId = undefined; + bidRequest[1].userId = undefined; + const bidRequests = spec.buildRequests(bidRequest, bidderRequests); + expect(bidRequests.url).to.equal('https://apex.go.sonobi.com/trinity.json'); + expect(bidRequests.method).to.equal('GET'); + expect(bidRequests.data.ref).not.to.be.empty; + expect(bidRequests.data.s).not.to.be.empty; + expect(bidRequests.data.userid).to.equal(undefined); + }); }) describe('.interpretResponse', function () { diff --git a/test/spec/modules/sortableAnalyticsAdapter_spec.js b/test/spec/modules/sortableAnalyticsAdapter_spec.js new file mode 100644 index 00000000000..90bd5fcdf22 --- /dev/null +++ b/test/spec/modules/sortableAnalyticsAdapter_spec.js @@ -0,0 +1,307 @@ +import {expect} from 'chai'; +import sortableAnalyticsAdapter, {TIMEOUT_FOR_REGISTRY, DEFAULT_PBID_TIMEOUT} from 'modules/sortableAnalyticsAdapter'; +import events from 'src/events'; +import CONSTANTS from 'src/constants.json'; +import * as prebidGlobal from 'src/prebidGlobal'; + +describe('Sortable Analytics Adapter', function() { + let requests; + let sandbox; + let xhr; + let clock; + + const initialConfig = { + provider: 'sortable', + options: { + siteId: 'testkey' + } + }; + + const TEST_DATA = { + AUCTION_INIT: { + auctionId: 'fb8d579a-5c3f-4705-ab94-3cff39005d9e', + timeout: 3000 + }, + BID_REQUESTED: { + refererInfo: { + referer: 'test.com', + reachedTop: true, + numIframes: 1 + }, + bidderCode: 'sortable', + auctionId: 'fb8d579a-5c3f-4705-ab94-3cff39005d9e', + bids: [{ + bidder: 'sortable', + params: { + tagId: 'medrec_1' + }, + adUnitCode: '300x250', + transactionId: 'aa02b498-8a99-418e-bc59-6b6fd45f32de', + sizes: [ + [300, 250] + ], + bidId: '26721042674416', + bidderRequestId: '10141593b1d84a', + auctionId: 'fb8d579a-5c3f-4705-ab94-3cff39005d9e', + bidRequestsCount: 1 + }, { + bidder: 'sortable', + params: { + tagId: 'lead_1' + }, + adUnitCode: '728x90', + transactionId: 'b7e9e957-af4f-4c47-8ca7-41f01cb4f105', + sizes: [ + [728, 90] + ], + bidId: '50fa575b41e596', + bidderRequestId: '37a8760be6db23', + auctionId: 'fb8d579a-5c3f-4705-ab94-3cff39005d9e', + bidRequestsCount: 1 + }], + start: 1553529405788 + }, + BID_ADJUSTMENT_1: { + bidderCode: 'sortable', + adId: '88221d316425f7', + mediaType: 'banner', + cpm: 0.70, + dealId: null, + currency: 'USD', + netRevenue: true, + ttl: 60, + auctionId: 'fb8d579a-5c3f-4705-ab94-3cff39005d9e', + responseTimestamp: 1553534161763, + bidder: 'sortable', + adUnitCode: '300x250', + timeToRespond: 331, + width: '300', + height: '250' + }, + AUCTION_END: { + auctionId: 'fb8d579a-5c3f-4705-ab94-3cff39005d9e' + }, + BID_ADJUSTMENT_2: { + bidderCode: 'sortable', + adId: '88221d316425f8', + mediaType: 'banner', + cpm: 0.50, + dealId: null, + currency: 'USD', + netRevenue: true, + ttl: 60, + auctionId: 'fb8d579a-5c3f-4705-ab94-3cff39005d9e', + responseTimestamp: 1553534161770, + bidder: 'sortable', + adUnitCode: '728x90', + timeToRespond: 338, + width: '728', + height: '90' + }, + BID_WON_1: { + bidderCode: 'sortable', + adId: '88221d316425f7', + mediaType: 'banner', + cpm: 0.70, + dealId: null, + currency: 'USD', + netRevenue: true, + ttl: 60, + auctionId: 'fb8d579a-5c3f-4705-ab94-3cff39005d9e', + responseTimestamp: 1553534161763, + bidder: 'sortable', + adUnitCode: '300x250', + timeToRespond: 331 + }, + BID_WON_2: { + bidderCode: 'sortable', + adId: '88221d316425f8', + mediaType: 'banner', + cpm: 0.50, + dealId: null, + currency: 'USD', + netRevenue: true, + ttl: 60, + auctionId: 'fb8d579a-5c3f-4705-ab94-3cff39005d9e', + responseTimestamp: 1553534161770, + bidder: 'sortable', + adUnitCode: '728x90', + timeToRespond: 338 + }, + BID_TIMEOUT: [{ + auctionId: 'fb8d579a-5c3f-4705-ab94-3cff39005d9e', + adUnitCode: '300x250', + bidder: 'sortable' + }] + }; + + beforeEach(function() { + sandbox = sinon.sandbox.create(); + xhr = sandbox.useFakeXMLHttpRequest(); + xhr.onCreate = (request) => requests.push(request); + clock = sandbox.useFakeTimers(); + sandbox.stub(events, 'getEvents').returns([]); + sandbox.stub(prebidGlobal, 'getGlobal').returns({ + version: '1.0', + bidderSettings: { + 'sortable': { + bidCpmAdjustment: function (number) { + return number * 0.95; + } + } + } + }); + + requests = []; + sortableAnalyticsAdapter.enableAnalytics(initialConfig); + }); + + afterEach(function() { + sandbox.restore(); + sortableAnalyticsAdapter.disableAnalytics(); + }); + + describe('initialize adapter', function() { + const settings = sortableAnalyticsAdapter.getOptions(); + + it('should init settings correctly and apply defaults', function() { + expect(settings).to.include({ + 'disableSessionTracking': false, + 'key': initialConfig.options.siteId, + 'protocol': 'https', + 'url': `https://pa.deployads.com/pae/${initialConfig.options.siteId}`, + 'timeoutForPbid': DEFAULT_PBID_TIMEOUT + }); + }); + it('should assign a pageview ID', function() { + expect(settings).to.have.own.property('pageviewId'); + }); + }); + + describe('events tracking', function() { + it('should send the PBID event', function() { + events.emit(CONSTANTS.EVENTS.AUCTION_INIT, TEST_DATA.AUCTION_INIT); + events.emit(CONSTANTS.EVENTS.BID_REQUESTED, TEST_DATA.BID_REQUESTED); + events.emit(CONSTANTS.EVENTS.BID_ADJUSTMENT, TEST_DATA.BID_ADJUSTMENT_1); + events.emit(CONSTANTS.EVENTS.BID_ADJUSTMENT, TEST_DATA.BID_ADJUSTMENT_2); + events.emit(CONSTANTS.EVENTS.AUCTION_END, TEST_DATA.AUCTION_END); + events.emit(CONSTANTS.EVENTS.BID_WON, TEST_DATA.BID_WON_1); + events.emit(CONSTANTS.EVENTS.BID_WON, TEST_DATA.BID_WON_2); + + clock.tick(DEFAULT_PBID_TIMEOUT); + + expect(requests.length).to.equal(1); + let result = JSON.parse(requests[0].requestBody); + expect(result).to.have.own.property('pbid'); + expect(result.pbid).to.deep.include({ + ai: 'fb8d579a-5c3f-4705-ab94-3cff39005d9e', + ac: ['300x250', '728x90'], + adi: ['88221d316425f7', '88221d316425f8'], + bs: 'sortable', + bid: ['26721042674416', '50fa575b41e596'], + bif: 0.95, + brc: 1, + brid: ['10141593b1d84a', '37a8760be6db23'], + rs: ['300x250', '728x90'], + btcp: [0.70, 0.50], + btcc: 'USD', + btin: true, + btsrc: 'sortable', + c: [0.70, 0.50], + cc: 'USD', + did: null, + inr: true, + it: true, + iw: true, + ito: false, + mt: 'banner', + rtp: true, + nif: 1, + pbv: '1.0', + siz: ['300x250', '728x90'], + st: 1553529405788, + tgid: ['medrec_1', 'lead_1'], + to: 3000, + trid: ['aa02b498-8a99-418e-bc59-6b6fd45f32de', 'b7e9e957-af4f-4c47-8ca7-41f01cb4f105'], + ttl: 60, + ttr: [331, 338], + u: 'test.com', + _count: 2 + }); + }); + + it('should track a late bidWon event', function() { + events.emit(CONSTANTS.EVENTS.AUCTION_INIT, TEST_DATA.AUCTION_INIT); + events.emit(CONSTANTS.EVENTS.BID_REQUESTED, TEST_DATA.BID_REQUESTED); + events.emit(CONSTANTS.EVENTS.BID_ADJUSTMENT, TEST_DATA.BID_ADJUSTMENT_1); + events.emit(CONSTANTS.EVENTS.AUCTION_END, TEST_DATA.AUCTION_END); + + clock.tick(DEFAULT_PBID_TIMEOUT); + + events.emit(CONSTANTS.EVENTS.BID_WON, TEST_DATA.BID_WON_1); + + clock.tick(TIMEOUT_FOR_REGISTRY); + + expect(requests.length).to.equal(2); + const pbid_req = JSON.parse(requests[0].requestBody); + expect(pbid_req).to.have.own.property('pbid'); + const pbwon_req = JSON.parse(requests[1].requestBody); + expect(pbwon_req).to.have.own.property('pbrw'); + expect(pbwon_req.pbrw).to.deep.equal({ + ac: '300x250', + ai: 'fb8d579a-5c3f-4705-ab94-3cff39005d9e', + bif: 0.95, + bs: 'sortable', + s: initialConfig.options.siteId, + cc: 'USD', + c: 0.70, + inr: true, + _count: 1, + _type: 'pbrw' + }); + }); + + it('should track late bidder timeouts', function() { + events.emit(CONSTANTS.EVENTS.AUCTION_INIT, TEST_DATA.AUCTION_INIT); + events.emit(CONSTANTS.EVENTS.BID_REQUESTED, TEST_DATA.BID_REQUESTED); + events.emit(CONSTANTS.EVENTS.AUCTION_END, TEST_DATA.AUCTION_END); + clock.tick(DEFAULT_PBID_TIMEOUT); + events.emit(CONSTANTS.EVENTS.BID_TIMEOUT, TEST_DATA.BID_TIMEOUT); + + clock.tick(TIMEOUT_FOR_REGISTRY); + + expect(requests.length).to.equal(2); + const pbid_req = JSON.parse(requests[0].requestBody); + expect(pbid_req).to.have.own.property('pbid'); + const pbto_req = JSON.parse(requests[1].requestBody); + expect(pbto_req).to.have.own.property('pbto'); + expect(pbto_req.pbto).to.deep.equal({ + ai: 'fb8d579a-5c3f-4705-ab94-3cff39005d9e', + s: initialConfig.options.siteId, + ac: '300x250', + bs: 'sortable', + _type: 'pbto', + _count: 1 + }); + }); + + it('should track errors', function() { + events.emit(CONSTANTS.EVENTS.AUCTION_INIT, TEST_DATA.AUCTION_INIT); + events.emit(CONSTANTS.EVENTS.BID_REQUESTED, {}); + + clock.tick(TIMEOUT_FOR_REGISTRY); + + expect(requests.length).to.equal(1); + const err_req = JSON.parse(requests[0].requestBody); + expect(err_req).to.have.own.property('pber'); + expect(err_req.pber).to.include({ + args: '{}', + s: initialConfig.options.siteId, + _count: 1, + ti: 'bidRequested', + _type: 'pber' + }); + expect(err_req.pber.msg).to.be.a('string'); + }); + }); +}); diff --git a/test/spec/modules/sovrnAnalyticsAdapter_spec.js b/test/spec/modules/sovrnAnalyticsAdapter_spec.js new file mode 100644 index 00000000000..299e22ca790 --- /dev/null +++ b/test/spec/modules/sovrnAnalyticsAdapter_spec.js @@ -0,0 +1,546 @@ +import sovrnAnalyticsAdapter from '../../../modules/sovrnAnalyticsAdapter' +import { expect } from 'chai' +import {config} from 'src/config' +import adaptermanager from 'src/adapterManager' +var assert = require('assert'); + +let events = require('src/events'); +let constants = require('src/constants.json'); + +/** + * Emit analytics events + * @param {array} eventArr - array of objects to define the events that will fire + * @param {object} eventObj - key is eventType, value is event + * @param {string} auctionId - the auction id to attached to the events + */ +function emitEvent(eventType, event, auctionId) { + event.auctionId = auctionId; + events.emit(constants.EVENTS[eventType], event); +} + +let auctionStartTimestamp = Date.now(); +let timeout = 3000; +let auctionInit = { + timestamp: auctionStartTimestamp, + timeout: timeout +}; +let bidderCode = 'sovrn'; +let bidderRequestId = '123bri'; +let adUnitCode = 'div'; +let adUnitCode2 = 'div2'; +let bidId = 'bidid'; +let bidId2 = 'bidid2'; +let tId = '7aafa3ee-a80a-46d7-a4a0-cbcba463d97a'; +let tId2 = '99dca3ee-a80a-46d7-a4a0-cbcba463d97e'; +let bidRequested = { + auctionStart: auctionStartTimestamp, + bidderCode: bidderCode, + bidderRequestId: bidderRequestId, + bids: [ + { + adUnitCode: adUnitCode, + bidId: bidId, + bidder: bidderCode, + bidderRequestId: '10340af0c7dc72', + sizes: [[300, 250]], + startTime: auctionStartTimestamp + 100, + transactionId: tId + }, + { + adUnitCode: adUnitCode2, + bidId: bidId2, + bidder: bidderCode, + bidderRequestId: '10340af0c7dc72', + sizes: [[300, 250]], + startTime: auctionStartTimestamp + 100, + transactionId: tId2 + } + ], + doneCbCallCount: 1, + start: auctionStartTimestamp, + timeout: timeout +}; +let bidResponse = { + bidderCode: bidderCode, + width: 300, + height: 250, + statusMessage: 'Bid available', + adId: '3870e27a5752fb', + mediaType: 'banner', + source: 'client', + requestId: bidId, + cpm: 0.8584999918937682, + creativeId: 'cridprebidrtb', + dealId: null, + currency: 'USD', + netRevenue: true, + ad: '
    divvy mcdiv
    ', + ttl: 60000, + responseTimestamp: auctionStartTimestamp + 150, + requestTimestamp: auctionStartTimestamp + 100, + bidder: bidderCode, + adUnitCode: adUnitCode, + timeToRespond: 50, + pbLg: '0.50', + pbMg: '0.80', + pbHg: '0.85', + pbAg: '0.85', + pbDg: '0.85', + pbCg: '', + size: '300x250', + adserverTargeting: { + hb_bidder: bidderCode, + hb_adid: '3870e27a5752fb', + hb_pb: '0.85' + }, + status: 'rendered' +}; + +let bidResponse2 = { + bidderCode: bidderCode, + width: 300, + height: 250, + statusMessage: 'Bid available', + adId: '9999e27a5752fb', + mediaType: 'banner', + source: 'client', + requestId: bidId2, + cpm: 0.12, + creativeId: 'cridprebidrtb', + dealId: null, + currency: 'USD', + netRevenue: true, + ad: '
    divvy mcdiv
    ', + ttl: 60000, + responseTimestamp: auctionStartTimestamp + 150, + requestTimestamp: auctionStartTimestamp + 100, + bidder: bidderCode, + adUnitCode: adUnitCode2, + timeToRespond: 50, + pbLg: '0.10', + pbMg: '0.10', + pbHg: '0.10', + pbAg: '0.10', + pbDg: '0.10', + pbCg: '', + size: '300x250', + adserverTargeting: { + hb_bidder: bidderCode, + hb_adid: '9999e27a5752fb', + hb_pb: '0.10' + }, + status: 'rendered' +}; +let bidAdjustment = {}; +for (var k in bidResponse) bidAdjustment[k] = bidResponse[k]; +bidAdjustment.cpm = 0.8; +let bidAdjustmentNoMatchingRequest = { + bidderCode: 'not-sovrn', + width: 300, + height: 250, + statusMessage: 'Bid available', + adId: '1', + mediaType: 'banner', + source: 'client', + requestId: '1', + cpm: 0.10, + creativeId: '', + dealId: null, + currency: 'USD', + netRevenue: true, + ad: '
    divvy mcdiv
    ', + ttl: 60000, + responseTimestamp: auctionStartTimestamp + 150, + requestTimestamp: auctionStartTimestamp + 100, + bidder: 'not-sovrn', + adUnitCode: '', + timeToRespond: 50, + pbLg: '0.00', + pbMg: '0.10', + pbHg: '0.10', + pbAg: '0.10', + pbDg: '0.10', + pbCg: '', + size: '300x250', + adserverTargeting: { + hb_bidder: 'not-sovrn', + hb_adid: '1', + hb_pb: '0.10' + }, +}; +let bidResponseNoMatchingRequest = bidAdjustmentNoMatchingRequest; + +describe('Sovrn Analytics Adapter', function () { + let xhr; + let requests; + beforeEach(() => { + xhr = sinon.useFakeXMLHttpRequest(); + xhr.onCreate = request => requests.push(request); + requests = []; + sinon.stub(events, 'getEvents').returns([]); + }); + afterEach(() => { + xhr.restore(); + events.getEvents.restore(); + }); + + describe('enableAnalytics ', function () { + beforeEach(() => { + sinon.spy(sovrnAnalyticsAdapter, 'track'); + }); + afterEach(() => { + sovrnAnalyticsAdapter.disableAnalytics(); + sovrnAnalyticsAdapter.track.restore(); + }); + + it('should catch all events if affiliate id present', function () { + adaptermanager.enableAnalytics({ + provider: 'sovrn', + options: { + sovrnId: 123 + } + }); + + events.emit(constants.EVENTS.AUCTION_INIT, {}); + events.emit(constants.EVENTS.AUCTION_END, {}); + events.emit(constants.EVENTS.BID_REQUESTED, {}); + events.emit(constants.EVENTS.BID_RESPONSE, {}); + events.emit(constants.EVENTS.BID_WON, {}); + + sinon.assert.callCount(sovrnAnalyticsAdapter.track, 5); + }); + + it('should catch no events if no affiliate id', function () { + adaptermanager.enableAnalytics({ + provider: 'sovrn', + options: { + } + }); + + events.emit(constants.EVENTS.AUCTION_INIT, {}); + events.emit(constants.EVENTS.AUCTION_END, {}); + events.emit(constants.EVENTS.BID_REQUESTED, {}); + events.emit(constants.EVENTS.BID_RESPONSE, {}); + events.emit(constants.EVENTS.BID_WON, {}); + + sinon.assert.callCount(sovrnAnalyticsAdapter.track, 0); + }); + }); + + describe('sovrnAnalyticsAdapter ', function() { + beforeEach(() => { + sovrnAnalyticsAdapter.enableAnalytics({ + provider: 'sovrn', + options: { + sovrnId: 123 + } + }); + sinon.spy(sovrnAnalyticsAdapter, 'track'); + }); + afterEach(() => { + sovrnAnalyticsAdapter.disableAnalytics(); + sovrnAnalyticsAdapter.track.restore(); + }); + it('should have correct type', function () { + assert.equal(sovrnAnalyticsAdapter.getAdapterType(), 'endpoint') + }) + }); + + describe('auction data collector ', function() { + beforeEach(() => { + sovrnAnalyticsAdapter.enableAnalytics({ + provider: 'sovrn', + options: { + sovrnId: 123 + } + }); + sinon.spy(sovrnAnalyticsAdapter, 'track'); + }); + afterEach(() => { + sovrnAnalyticsAdapter.disableAnalytics(); + sovrnAnalyticsAdapter.track.restore(); + }); + it('should create auctiondata record from init ', function () { + let auctionId = '123.123.123.123'; + emitEvent('AUCTION_INIT', auctionInit, auctionId); + + let auctionData = sovrnAnalyticsAdapter.getAuctions(); + let currentAuction = auctionData[auctionId]; + assert(currentAuction); + let expectedTimeOutData = { + buffer: config.getConfig('timeoutBuffer'), + bidder: config.getConfig('bidderTimeout'), + }; + expect(currentAuction.auction.timeouts).to.deep.equal(expectedTimeOutData); + assert.equal(currentAuction.auction.payload, 'auction'); + assert.equal(currentAuction.auction.priceGranularity, config.getConfig('priceGranularity')) + assert.equal(currentAuction.auction.auctionId, auctionId); + assert.equal(currentAuction.auction.sovrnId, 123); + }); + it('should create a bidrequest object ', function() { + let auctionId = '234.234.234.234'; + emitEvent('AUCTION_INIT', auctionInit, auctionId); + emitEvent('BID_REQUESTED', bidRequested, auctionId); + + let auctionData = sovrnAnalyticsAdapter.getAuctions(); + let currentAuction = auctionData[auctionId]; + assert(currentAuction); + let requests = currentAuction.auction.requests; + assert(requests); + assert.equal(requests.length, 1); + assert.equal(requests[0].bidderCode, bidderCode); + assert.equal(requests[0].bidderRequestId, bidderRequestId); + assert.equal(requests[0].timeout, timeout); + let bids = requests[0].bids; + assert(bids); + assert.equal(bids.length, 2); + assert.equal(bids[0].bidId, bidId); + assert.equal(bids[0].bidder, bidderCode); + assert.equal(bids[0].transactionId, tId); + assert.equal(bids[0].sizes.length, 1); + assert.equal(bids[0].sizes[0][0], 300); + assert.equal(bids[0].sizes[0][1], 250); + expect(requests[0]).to.not.have.property('doneCbCallCount'); + expect(requests[0]).to.not.have.property('auctionId'); + }); + it('should add results to the bid with response ', function () { + let auctionId = '345.345.345.345'; + emitEvent('AUCTION_INIT', auctionInit, auctionId); + emitEvent('BID_REQUESTED', bidRequested, auctionId); + emitEvent('BID_RESPONSE', bidResponse, auctionId); + + let auctionData = sovrnAnalyticsAdapter.getAuctions(); + let currentAuction = auctionData[auctionId]; + let returnedBid = currentAuction.auction.requests[0].bids[0]; + assert.equal(returnedBid.bidId, bidId); + assert.equal(returnedBid.bidder, bidderCode); + assert.equal(returnedBid.transactionId, tId); + assert.equal(returnedBid.sizes.length, 1); + assert.equal(returnedBid.sizes[0][0], 300); + assert.equal(returnedBid.sizes[0][1], 250); + assert.equal(returnedBid.adserverTargeting.hb_adid, '3870e27a5752fb'); + assert.equal(returnedBid.adserverTargeting.hb_bidder, bidderCode); + assert.equal(returnedBid.adserverTargeting.hb_pb, '0.85'); + assert.equal(returnedBid.cpm, 0.8584999918937682); + }); + it('should add new unsynced bid if no request exists for response ', function () { + let auctionId = '456.456.456.456'; + emitEvent('AUCTION_INIT', auctionInit, auctionId); + emitEvent('BID_REQUESTED', bidRequested, auctionId); + emitEvent('BID_RESPONSE', bidResponseNoMatchingRequest, auctionId); + + let auctionData = sovrnAnalyticsAdapter.getAuctions(); + let currentAuction = auctionData[auctionId]; + let requests = currentAuction.auction.requests; + assert(requests); + assert.equal(requests.length, 1); + let bidRequest = requests[0].bids[0]; + expect(bidRequest).to.not.have.property('adserverTargeting'); + expect(bidRequest).to.not.have.property('cpm'); + expect(currentAuction.auction.unsynced[0]).to.deep.equal(bidResponseNoMatchingRequest); + }); + it('should adjust the bid ', function () { + let auctionId = '567.567.567.567'; + emitEvent('AUCTION_INIT', auctionInit, auctionId); + emitEvent('BID_REQUESTED', bidRequested, auctionId); + emitEvent('BID_ADJUSTMENT', bidResponse, auctionId); + emitEvent('BID_RESPONSE', bidAdjustment, auctionId); + + let auctionData = sovrnAnalyticsAdapter.getAuctions(); + let currentAuction = auctionData[auctionId]; + let returnedBid = currentAuction.auction.requests[0].bids[0]; + assert.equal(returnedBid.cpm, 0.8); + assert.equal(returnedBid.originalValues.cpm, 0.8584999918937682); + }); + }); + describe('auction data send ', function() { + let expectedPostBody = { + sovrnId: 123, + auctionId: '678.678.678.678', + payload: 'auction', + priceGranularity: 'medium', + }; + let expectedRequests = { + bidderCode: 'sovrn', + bidderRequestId: '123bri', + timeout: 3000 + }; + let expectedBids = { + adUnitCode: 'div', + bidId: 'bidid', + bidder: 'sovrn', + bidderRequestId: '10340af0c7dc72', + transactionId: '7aafa3ee-a80a-46d7-a4a0-cbcba463d97a', + width: 300, + height: 250, + statusMessage: 'Bid available', + adId: '3870e27a5752fb', + mediaType: 'banner', + source: 'client', + cpm: 0.8584999918937682, + creativeId: 'cridprebidrtb', + dealId: null, + currency: 'USD', + netRevenue: true, + ttl: 60000, + timeToRespond: 50, + size: '300x250', + status: 'rendered', + isAuctionWinner: true + }; + let SecondAdUnitExpectedBids = { + adUnitCode: 'div2', + bidId: 'bidid2', + bidder: 'sovrn', + bidderRequestId: '10340af0c7dc72', + transactionId: '99dca3ee-a80a-46d7-a4a0-cbcba463d97e', + width: 300, + height: 250, + statusMessage: 'Bid available', + adId: '9999e27a5752fb', + mediaType: 'banner', + source: 'client', + cpm: 0.12, + creativeId: 'cridprebidrtb', + dealId: null, + currency: 'USD', + netRevenue: true, + ttl: 60000, + timeToRespond: 50, + size: '300x250', + status: 'rendered', + isAuctionWinner: true + }; + let expectedAdServerTargeting = { + hb_bidder: 'sovrn', + hb_adid: '3870e27a5752fb', + hb_pb: '0.85' + }; + beforeEach(() => { + sovrnAnalyticsAdapter.enableAnalytics({ + provider: 'sovrn', + options: { + sovrnId: 123 + } + }); + sinon.spy(sovrnAnalyticsAdapter, 'track'); + }); + afterEach(() => { + sovrnAnalyticsAdapter.disableAnalytics(); + sovrnAnalyticsAdapter.track.restore(); + }); + it('should send auction data ', function () { + let auctionId = '678.678.678.678'; + emitEvent('AUCTION_INIT', auctionInit, auctionId); + emitEvent('BID_REQUESTED', bidRequested, auctionId); + emitEvent('BID_RESPONSE', bidResponse, auctionId); + emitEvent('BID_RESPONSE', bidResponse2, auctionId) + emitEvent('AUCTION_END', {}, auctionId); + let requestBody = JSON.parse(requests[0].requestBody); + let requestsFromRequestBody = requestBody.requests[0]; + let bidsFromRequests = requestsFromRequestBody.bids[0]; + expect(requestBody).to.deep.include(expectedPostBody); + expect(requestBody.timeouts).to.deep.equal({buffer: 400, bidder: 3000}); + expect(requestsFromRequestBody).to.deep.include(expectedRequests); + expect(bidsFromRequests).to.deep.include(expectedBids); + let bidsFromRequests2 = requestsFromRequestBody.bids[1]; + expect(bidsFromRequests2).to.deep.include(SecondAdUnitExpectedBids); + expect(bidsFromRequests.adserverTargeting).to.deep.include(expectedAdServerTargeting); + }); + }); + describe('bid won data send ', function() { + let auctionId = '789.789.789.789'; + let creativeId = 'cridprebidrtb'; + let requestId = 'requestId69'; + let bidWonEvent = { + ad: 'html', + adId: 'adId', + adUnitCode: adUnitCode, + auctionId: auctionId, + bidder: bidderCode, + bidderCode: bidderCode, + cpm: 1.01, + creativeId: creativeId, + currency: 'USD', + height: 250, + mediaType: 'banner', + requestId: requestId, + size: '300x250', + source: 'client', + status: 'rendered', + statusMessage: 'Bid available', + timeToRespond: 421, + ttl: 60, + width: 300 + }; + let expectedBidWonBody = { + sovrnId: 123, + payload: 'winner' + }; + let expectedWinningBid = { + bidderCode: bidderCode, + width: 300, + height: 250, + statusMessage: 'Bid available', + adId: 'adId', + mediaType: 'banner', + source: 'client', + requestId: requestId, + cpm: 1.01, + creativeId: creativeId, + currency: 'USD', + ttl: 60, + auctionId: auctionId, + bidder: bidderCode, + adUnitCode: adUnitCode, + timeToRespond: 421, + size: '300x250', + }; + beforeEach(() => { + sovrnAnalyticsAdapter.enableAnalytics({ + provider: 'sovrn', + options: { + sovrnId: 123 + } + }); + sinon.spy(sovrnAnalyticsAdapter, 'track'); + }); + afterEach(() => { + sovrnAnalyticsAdapter.disableAnalytics(); + sovrnAnalyticsAdapter.track.restore(); + }); + it('should send bid won data ', function () { + emitEvent('AUCTION_INIT', auctionInit, auctionId); + emitEvent('BID_WON', bidWonEvent, auctionId); + let requestBody = JSON.parse(requests[0].requestBody); + expect(requestBody).to.deep.include(expectedBidWonBody); + expect(requestBody.winningBid).to.deep.include(expectedWinningBid); + }); + }); + describe('Error Tracking', function() { + beforeEach(() => { + sovrnAnalyticsAdapter.enableAnalytics({ + provider: 'sovrn', + options: { + sovrnId: 123 + } + }); + sinon.spy(sovrnAnalyticsAdapter, 'track'); + }); + afterEach(() => { + sovrnAnalyticsAdapter.disableAnalytics() + sovrnAnalyticsAdapter.track.restore() + }); + it('should send an error message when a bid is received for a closed auction', function() { + let auctionId = '678.678.678.678'; + emitEvent('AUCTION_INIT', auctionInit, auctionId) + emitEvent('BID_REQUESTED', bidRequested, auctionId) + emitEvent('AUCTION_END', {}, auctionId) + requests[0].respond(200) + emitEvent('BID_RESPONSE', bidResponse, auctionId) + let requestBody = JSON.parse(requests[1].requestBody) + expect(requestBody.payload).to.equal('error') + expect(requestBody.message).to.include('Event Received after Auction Close Auction Id') + }) + }) +}) diff --git a/test/spec/modules/spotxBidAdapter_spec.js b/test/spec/modules/spotxBidAdapter_spec.js index ba015331b68..33cf85a855e 100644 --- a/test/spec/modules/spotxBidAdapter_spec.js +++ b/test/spec/modules/spotxBidAdapter_spec.js @@ -150,6 +150,7 @@ describe('the spotx adapter', function () { expect(request.data.imp.video.ext).to.deep.equal({ ad_volume: 1, ad_unit: 'incontent', + hide_skin: 1, outstream_options: {foo: 'bar'}, outstream_function: '987', custom: {bar: 'foo'}, diff --git a/test/spec/modules/staqAnalyticsAdapter_spec.js b/test/spec/modules/staqAnalyticsAdapter_spec.js new file mode 100644 index 00000000000..33c85d11431 --- /dev/null +++ b/test/spec/modules/staqAnalyticsAdapter_spec.js @@ -0,0 +1,301 @@ +import analyticsAdapter, {ExpiringQueue, getUmtSource, storage} from 'modules/staqAnalyticsAdapter'; +import {expect} from 'chai'; +import adapterManager from 'src/adapterManager'; +import CONSTANTS from 'src/constants.json'; + +const events = require('../../../src/events'); + +const DIRECT = { + source: '(direct)', + medium: '(direct)', + campaign: '(direct)' +}; +const REFERRER = { + source: 'lander.com', + medium: '(referral)', + campaign: '(referral)', + content: '/lander.html' +}; +const GOOGLE_ORGANIC = { + source: 'google', + medium: '(organic)', + campaign: '(organic)' +}; +const CAMPAIGN = { + source: 'adkernel', + medium: 'email', + campaign: 'new_campaign', + c1: '1', + c2: '2', + c3: '3', + c4: '4', + c5: '5' + +}; +describe('', function () { + let sandbox; + + before(function () { + sandbox = sinon.sandbox.create(); + }); + + after(function () { + sandbox.restore(); + analyticsAdapter.disableAnalytics(); + }); + + describe('UTM source parser', function () { + let stubSetItem; + let stubGetItem; + + before(function () { + stubSetItem = sandbox.stub(storage, 'setItem'); + stubGetItem = sandbox.stub(storage, 'getItem'); + }); + + afterEach(function () { + sandbox.reset(); + }); + + it('should parse first direct visit as (direct)', function () { + stubGetItem.withArgs('adk_dpt_analytics').returns(undefined); + stubSetItem.returns(undefined); + let source = getUmtSource('http://example.com'); + expect(source).to.be.eql(DIRECT); + }); + + it('should parse visit from google as organic', function () { + stubGetItem.withArgs('adk_dpt_analytics').returns(undefined); + stubSetItem.returns(undefined); + let source = getUmtSource('http://example.com', 'https://www.google.com/search?q=pikachu'); + expect(source).to.be.eql(GOOGLE_ORGANIC); + }); + + it('should parse referral visit', function () { + stubGetItem.withArgs('adk_dpt_analytics').returns(undefined); + stubSetItem.returns(undefined); + let source = getUmtSource('http://example.com', 'http://lander.com/lander.html'); + expect(source).to.be.eql(REFERRER); + }); + + it('should parse referral visit from same domain as direct', function () { + stubGetItem.withArgs('adk_dpt_analytics').returns(undefined); + stubSetItem.returns(undefined); + let source = getUmtSource('http://lander.com/news.html', 'http://lander.com/lander.html'); + expect(source).to.be.eql(DIRECT); + }); + + it('should parse campaign visit', function () { + stubGetItem.withArgs('adk_dpt_analytics').returns(undefined); + stubSetItem.returns(undefined); + let source = getUmtSource('http://lander.com/index.html?utm_campaign=new_campaign&utm_source=adkernel&utm_medium=email&utm_c1=1&utm_c2=2&utm_c3=3&utm_c4=4&utm_c5=5'); + expect(source).to.be.eql(CAMPAIGN); + }); + }); + + describe('ExpiringQueue', function () { + let timer; + before(function () { + timer = sandbox.useFakeTimers(0); + }); + after(function () { + timer.restore(); + }); + + it('should notify after timeout period', (done) => { + let queue = new ExpiringQueue(() => { + let elements = queue.popAll(); + expect(elements).to.be.eql([1, 2, 3, 4]); + elements = queue.popAll(); + expect(elements).to.have.lengthOf(0); + expect(Date.now()).to.be.equal(200); + done(); + }, 100); + + queue.push(1); + setTimeout(() => { + queue.push([2, 3]); + timer.tick(50); + }, 50); + setTimeout(() => { + queue.push([4]); + timer.tick(100); + }, 100); + timer.tick(50); + }); + }); + + const REQUEST = { + bidderCode: 'AppNexus', + bidderName: 'AppNexus', + auctionId: '5018eb39-f900-4370-b71e-3bb5b48d324f', + bidderRequestId: '1a6fc81528d0f6', + bids: [{ + bidder: 'AppNexus', + params: {}, + adUnitCode: 'container-1', + transactionId: 'de90df62-7fd0-4fbc-8787-92d133a7dc06', + sizes: [[300, 250]], + bidId: '208750227436c1', + bidderRequestId: '1a6fc81528d0f6', + auctionId: '5018eb39-f900-4370-b71e-3bb5b48d324f' + }], + auctionStart: 1509369418387, + timeout: 3000, + start: 1509369418389 + }; + + const RESPONSE = { + bidderCode: 'AppNexus', + width: 300, + height: 250, + statusMessage: 'Bid available', + adId: '208750227436c1', + mediaType: 'banner', + cpm: 0.015, + ad: '', + auctionId: '5018eb39-f900-4370-b71e-3bb5b48d324f', + responseTimestamp: 1509369418832, + requestTimestamp: 1509369418389, + bidder: 'AppNexus', + adUnitCode: 'container-1', + timeToRespond: 443, + size: '300x250' + }; + + const bidTimeoutArgsV1 = [{ + bidId: '2baa51527bd015', + bidderCode: 'AppNexus', + adUnitCode: 'container-1', + auctionId: '66529d4c-8998-47c2-ab3e-5b953490b98f' + }, + { + bidId: '6fe3b4c2c23092', + bidderCode: 'AppNexus', + adUnitCode: 'container-2', + auctionId: '66529d4c-8998-47c2-ab3e-5b953490b98f' + }]; + + describe('Analytics adapter', function () { + let ajaxStub; + let timer; + + before(function () { + ajaxStub = sandbox.stub(analyticsAdapter, 'ajaxCall'); + timer = sandbox.useFakeTimers(0); + }); + + beforeEach(function () { + sandbox.stub(events, 'getEvents').callsFake(() => { + return [] + }); + }); + + afterEach(function () { + events.getEvents.restore(); + }); + + it('should be configurable', function () { + adapterManager.registerAnalyticsAdapter({ + code: 'staq', + adapter: analyticsAdapter + }); + + adapterManager.enableAnalytics({ + provider: 'staq', + options: { + connId: 777, + queueTimeout: 1000, + url: 'http://localhost/prebid' + } + }); + + expect(analyticsAdapter.context).to.have.property('connectionId', 777); + }); + + it('should handle auction init event', function () { + events.emit(CONSTANTS.EVENTS.AUCTION_INIT, {config: {}, timeout: 3000}); + const ev = analyticsAdapter.context.queue.peekAll(); + expect(ev).to.have.length(1); + expect(ev[0]).to.be.eql({event: 'auctionInit', auctionId: undefined}); + }); + + it('should handle bid request event', function () { + events.emit(CONSTANTS.EVENTS.BID_REQUESTED, REQUEST); + const ev = analyticsAdapter.context.queue.peekAll(); + expect(ev).to.have.length(2); + expect(ev[1]).to.be.eql({ + adUnitCode: 'container-1', + auctionId: '5018eb39-f900-4370-b71e-3bb5b48d324f', + event: 'bidRequested', + adapter: 'AppNexus', + bidderName: 'AppNexus' + }); + }); + + it('should handle bid response event', function () { + events.emit(CONSTANTS.EVENTS.BID_RESPONSE, RESPONSE); + const ev = analyticsAdapter.context.queue.peekAll(); + expect(ev).to.have.length(3); + expect(ev[2]).to.be.eql({ + adId: '208750227436c1', + event: 'bidResponse', + adapter: 'AppNexus', + bidderName: 'AppNexus', + auctionId: '5018eb39-f900-4370-b71e-3bb5b48d324f', + adUnitCode: 'container-1', + cpm: 0.015, + timeToRespond: 0.443, + height: 250, + width: 300, + bidWon: false, + }); + }); + + it('should handle timeouts properly', function() { + events.emit(CONSTANTS.EVENTS.BID_TIMEOUT, bidTimeoutArgsV1); + + const ev = analyticsAdapter.context.queue.peekAll(); + expect(ev).to.have.length(5); // remember, we added 2 timeout events + expect(ev[3]).to.be.eql({ + adapter: 'AppNexus', + auctionId: '66529d4c-8998-47c2-ab3e-5b953490b98f', + bidderName: 'AppNexus', + event: 'adapterTimedOut' + }) + }); + + it('should handle winning bid', function () { + events.emit(CONSTANTS.EVENTS.BID_WON, RESPONSE); + const ev = analyticsAdapter.context.queue.peekAll(); + expect(ev).to.have.length(6); + expect(ev[5]).to.be.eql({ + auctionId: '5018eb39-f900-4370-b71e-3bb5b48d324f', + adId: '208750227436c1', + event: 'bidWon', + adapter: 'AppNexus', + bidderName: 'AppNexus', + adUnitCode: 'container-1', + cpm: 0.015, + height: 250, + width: 300, + bidWon: true, + }); + }); + + it('should handle auction end event', function () { + timer.tick(447); + events.emit(CONSTANTS.EVENTS.AUCTION_END, RESPONSE); + let ev = analyticsAdapter.context.queue.peekAll(); + expect(ev).to.have.length(0); + expect(ajaxStub.calledOnce).to.be.equal(true); + let firstCallArgs0 = ajaxStub.firstCall.args[0]; + ev = JSON.parse(firstCallArgs0); + // console.log('AUCTION END EVENT SHAPE ' + JSON.stringify(ev)); + const ev6 = ev[6]; + expect(ev6.connId).to.be.eql(777); + expect(ev6.auctionId).to.be.eql('5018eb39-f900-4370-b71e-3bb5b48d324f'); + expect(ev6.event).to.be.eql('auctionEnd'); + }); + }); +}); diff --git a/test/spec/modules/stvBidAdapter_spec.js b/test/spec/modules/stvBidAdapter_spec.js new file mode 100644 index 00000000000..72ea428304a --- /dev/null +++ b/test/spec/modules/stvBidAdapter_spec.js @@ -0,0 +1,138 @@ +import { expect } from 'chai'; +import { spec } from 'modules/stvBidAdapter'; +import { newBidder } from 'src/adapters/bidderFactory'; + +const VADS_ENDPOINT_URL = 'https://ads.smartstream.tv/r/'; + +describe('stvAdapter', function () { + const adapter = newBidder(spec); + + describe('isBidRequestValid', function () { + let bid = { + 'bidder': 'stv', + 'params': { + 'placement': '6682', + 'pfilter': { + 'floorprice': 1000000 + }, + 'bcat': 'IAB2,IAB4', + 'dvt': 'desktop' + }, + 'sizes': [ + [300, 250] + ], + 'bidId': '30b31c1838de1e', + 'bidderRequestId': '22edbae2733bf6', + 'auctionId': '1d1a030790a475' + }; + + it('should return true when required params found', function () { + expect(spec.isBidRequestValid(bid)).to.equal(true); + }); + + it('should return false when required params are not passed', function () { + let bid = Object.assign({}, bid); + delete bid.params; + bid.params = { + 'someIncorrectParam': 0 + }; + expect(spec.isBidRequestValid(bid)).to.equal(false); + }); + }); + + describe('buildRequests', function () { + let bidRequests = [{ + 'bidder': 'stv', + 'params': { + 'source': 'vads', + 'placement': 'prer0-0%3D4137', + 'pfilter': { + 'min_duration': 1, + 'max_duration': 100, + 'min_bitrate': 32, + 'max_bitrate': 128, + }, + 'noskip': 1 + }, + 'mediaTypes': { + 'video': { + 'playerSize': [640, 480], + 'context': 'instream' + } + }, + 'bidId': '30b31c1838de1e', + 'bidderRequestId': '22edbae2733bf6', + 'auctionId': '1d1a030790a475' + }]; + + let bidderRequest = { + refererInfo: { + referer: 'some_referrer.net' + } + } + + const request = spec.buildRequests(bidRequests, bidderRequest); + it('sends bid video request to our vads endpoint via GET', function () { + expect(request[0].method).to.equal('GET'); + let data = request[0].data.replace(/rnd=\d+\&/g, '').replace(/ref=.*\&bid/g, 'bid'); + expect(data).to.equal('_f=vast2&alternative=prebid_js&_ps=prer0-0%3D4137&srw=640&srh=480&idt=100&bid_id=30b31c1838de1e&pfilter%5Bmin_duration%5D=1&pfilter%5Bmax_duration%5D=100&pfilter%5Bmin_bitrate%5D=32&pfilter%5Bmax_bitrate%5D=128&noskip=1'); + }); + }); + + describe('interpretResponse', function () { + let vadsServerVideoResponse = { + 'body': { + 'cpm': 5000000, + 'crid': 100500, + 'width': '300', + 'height': '250', + 'vastXml': '{"reason":7001,"status":"accepted"}', + 'requestId': '220ed41385952a', + 'currency': 'EUR', + 'ttl': 60, + 'netRevenue': true, + 'zone': '6682' + } + }; + + let expectedResponse = [{ + requestId: '23beaa6af6cdde', + cpm: 0.5, + width: 0, + height: 0, + creativeId: 100500, + dealId: '', + currency: 'EUR', + netRevenue: true, + ttl: 300, + vastXml: '{"reason":7001,"status":"accepted"}', + mediaType: 'video' + }]; + + it('should get the correct vads video bid response by display ad', function () { + let bidRequest = [{ + 'method': 'GET', + 'url': VADS_ENDPOINT_URL, + 'mediaTypes': { + 'video': { + 'playerSize': [640, 480], + 'context': 'instream' + } + }, + 'data': { + 'bid_id': '30b31c1838de1e' + } + }]; + let result = spec.interpretResponse(vadsServerVideoResponse, bidRequest[0]); + expect(Object.keys(result[0])).to.have.members(Object.keys(expectedResponse[0])); + }); + + it('handles empty bid response', function () { + let response = { + body: {} + }; + let result = spec.interpretResponse(response); + expect(result.length).to.equal(0); + }); + }); +}); diff --git a/test/spec/modules/sublimeBidAdapter_spec.js b/test/spec/modules/sublimeBidAdapter_spec.js new file mode 100644 index 00000000000..45173b09953 --- /dev/null +++ b/test/spec/modules/sublimeBidAdapter_spec.js @@ -0,0 +1,255 @@ +import { expect } from 'chai'; +import { spec } from 'modules/sublimeBidAdapter'; +import { newBidder } from 'src/adapters/bidderFactory'; + +describe('Sublime Adapter', function() { + const adapter = newBidder(spec); + + describe('inherited functions', function() { + it('exists and is a function', function() { + expect(adapter.callBids).to.exist.and.to.be.a('function'); + }); + }); + + describe('isBidRequestValid', function() { + let bid = { + bidder: 'sublime', + params: { + zoneId: 24549, + endpoint: '', + }, + }; + + it('should return true when required params found', function() { + expect(spec.isBidRequestValid(bid)).to.equal(true); + }); + + it('should return false when required params are not passed', function() { + let bid = Object.assign({}, bid); + bid.params = {}; + expect(spec.isBidRequestValid(bid)).to.equal(false); + }); + }); + + describe('buildRequests', function() { + let bidRequests = [ + { + bidder: 'sublime', + adUnitCode: 'sublime_code', + bidId: 'abc1234', + sizes: [[1800, 1000], [640, 300]], + requestId: 'xyz654', + params: { + zoneId: 123, + callbackName: 'false' + } + }, { + bidder: 'sublime', + adUnitCode: 'sublime_code_2', + bidId: 'abc1234_2', + sizes: [[1, 1]], + requestId: 'xyz654_2', + params: { + zoneId: 456, + } + } + ]; + + let bidderRequest = { + gdprConsent: { + consentString: 'EOHEIRCOUCOUIEHZIOEIU-TEST', + gdprApplies: true + }, + refererInfo: { + referer: 'https://example.com', + numIframes: 2, + } + }; + + let request = spec.buildRequests(bidRequests, bidderRequest); + + it('should have a post method', function() { + expect(request[0].method).to.equal('POST'); + expect(request[1].method).to.equal('POST'); + }); + + it('should contains a request id equals to the bid id', function() { + expect(request[0].data.requestId).to.equal(bidRequests[0].bidId); + expect(request[1].data.requestId).to.equal(bidRequests[1].bidId); + }); + + it('should have an url that contains bid keyword', function() { + expect(request[0].url).to.match(/bid/); + expect(request[1].url).to.match(/bid/); + }); + }); + + describe('buildRequests: default arguments', function() { + let bidRequests = [{ + bidder: 'sublime', + adUnitCode: 'sublime_code', + bidId: 'abc1234', + sizes: [[1800, 1000], [640, 300]], + requestId: 'xyz654', + params: { + zoneId: 123 + } + }]; + + let request = spec.buildRequests(bidRequests); + + it('should have an url that match the default endpoint', function() { + expect(request[0].url).to.equal('https://pbjs.sskzlabs.com/bid'); + }); + }); + + describe('interpretResponse', function() { + let serverResponse = { + 'request_id': '3db3773286ee59', + 'cpm': 0.5, + 'ad': '', + }; + + it('should get correct bid response', function() { + // Mock the fire method + top.window.sublime = { + analytics: { + fire: function() {} + } + }; + + let expectedResponse = [ + { + requestId: '', + cpm: 0.5, + width: 1800, + height: 1000, + creativeId: 1, + dealId: 1, + currency: 'USD', + netRevenue: true, + ttl: 600, + ad: '', + }, + ]; + let result = spec.interpretResponse({body: serverResponse}); + expect(Object.keys(result[0])).to.have.members(Object.keys(expectedResponse[0])); + }); + + it('should get correct default size for 1x1', function() { + let serverResponse = { + 'requestId': 'xyz654_2', + 'cpm': 0.5, + 'ad': '', + }; + + let bidRequest = { + bidder: 'sublime', + adUnitCode: 'sublime_code_2', + bidId: 'abc1234_2', + data: { + w: 1, + h: 1, + }, + requestId: 'xyz654_2', + params: { + zoneId: 456, + } + }; + + let result = spec.interpretResponse({body: serverResponse}, bidRequest); + + let expectedResponse = { + requestId: 'xyz654_2', + cpm: 0.5, + width: 1, + height: 1, + creativeId: 1, + dealId: 1, + currency: 'EUR', + netRevenue: true, + ttl: 600, + ad: '', + }; + + expect(result[0]).to.deep.equal(expectedResponse); + }); + + it('should return bid empty response', function () { + let serverResponse = ''; + let bidRequest = {}; + + let result = spec.interpretResponse({ body: serverResponse }, bidRequest); + + let expectedResponse = []; + + expect(result).to.deep.equal(expectedResponse); + }); + + it('should return bid with default value in response', function () { + let serverResponse = { + 'requestId': 'xyz654_2', + 'ad': '', + }; + + let bidRequest = { + bidder: 'sublime', + adUnitCode: 'sublime_code_2', + bidId: 'abc1234_2', + data: { + w: 1, + h: 1, + }, + requestId: 'xyz654_2', + params: { + zoneId: 456, + } + }; + + let result = spec.interpretResponse({ body: serverResponse }, bidRequest); + + let expectedResponse = { + requestId: 'xyz654_2', + cpm: 0, + width: 1, + height: 1, + creativeId: 1, + dealId: 1, + currency: 'EUR', + netRevenue: true, + ttl: 600, + ad: '', + }; + + expect(result[0]).to.deep.equal(expectedResponse); + }); + + it('should return empty bid response because of timeout', function () { + let serverResponse = { + 'requestId': 'xyz654_2', + 'timeout': true, + 'ad': '', + }; + + let bidRequest = { + bidder: 'sublime', + adUnitCode: 'sublime_code_2', + bidId: 'abc1234_2', + data: { + w: 1, + h: 1, + }, + requestId: 'xyz654_2', + params: { + zoneId: 456, + } + }; + + let result = spec.interpretResponse({ body: serverResponse }, bidRequest); + + let expectedResponse = []; + + expect(result).to.deep.equal(expectedResponse); + }); + }); +}); diff --git a/test/spec/modules/synacormediaBidAdapter_spec.js b/test/spec/modules/synacormediaBidAdapter_spec.js index b91e8cc9fc1..d2f024181a4 100644 --- a/test/spec/modules/synacormediaBidAdapter_spec.js +++ b/test/spec/modules/synacormediaBidAdapter_spec.js @@ -7,6 +7,7 @@ describe('synacormediaBidAdapter ', function () { let bid; beforeEach(function () { bid = { + sizes: [300, 250], params: { seatId: 'prebid', placementId: '1234' @@ -18,21 +19,140 @@ describe('synacormediaBidAdapter ', function () { assert(spec.isBidRequestValid(bid)); }); + it('should return false when sizes are missing', function () { + delete bid.sizes; + assert.isFalse(spec.isBidRequestValid(bid)); + }); + + it('should return false when the only size is unwanted', function () { + bid.sizes = [[1, 1]]; + assert.isFalse(spec.isBidRequestValid(bid)); + }); + it('should return false when seatId param is missing', function () { delete bid.params.seatId; assert.isFalse(spec.isBidRequestValid(bid)); }); + it('should return false when placementId param is missing', function () { delete bid.params.placementId; assert.isFalse(spec.isBidRequestValid(bid)); }); + it('should return false when params is missing or null', function () { assert.isFalse(spec.isBidRequestValid({ params: null })); assert.isFalse(spec.isBidRequestValid({})); assert.isFalse(spec.isBidRequestValid(null)); }); }); + + describe('impression type', function() { + let nonVideoReq = { + bidId: '9876abcd', + sizes: [[300, 250], [300, 600]], + params: { + seatId: 'prebid', + placementId: '1234', + bidfloor: '0.50' + } + }; + + let bannerReq = { + bidId: '9876abcd', + sizes: [[300, 250], [300, 600]], + params: { + seatId: 'prebid', + placementId: '1234', + bidfloor: '0.50' + }, + mediaTypes: { + banner: { + h: 600, + pos: 0, + w: 300, + } + }, + }; + + let videoReq = { + bidId: '9876abcd', + sizes: [[640, 480]], + params: { + seatId: 'prebid', + placementId: '1234', + bidfloor: '0.50' + }, + mediaTypes: { + video: { + context: 'instream', + playerSize: [ + [ + 640, + 480 + ] + ] + } + }, + }; + it('should return correct impression type video/banner', function() { + assert.isFalse(spec.isVideoBid(nonVideoReq)); + assert.isFalse(spec.isVideoBid(bannerReq)); + assert.isTrue(spec.isVideoBid(videoReq)); + }); + }); describe('buildRequests', function () { + let validBidRequestVideo = { + bidder: 'synacormedia', + params: { + seatId: 'prebid', + placementId: '1234', + video: { + minduration: 30 + } + }, + mediaTypes: { + video: { + context: 'instream', + playerSize: [[ 640, 480 ]] + } + }, + adUnitCode: 'video1', + transactionId: '93e5def8-29aa-4fe8-bd3a-0298c39f189a', + sizes: [[ 640, 480 ]], + bidId: '2624fabbb078e8', + bidderRequestId: '117954d20d7c9c', + auctionId: 'defd525f-4f1e-4416-a4cb-ae53be90e706', + src: 'client', + bidRequestsCount: 1 + }; + + let bidderRequestVideo = { + bidderCode: 'synacormedia', + auctionId: 'VideoAuctionId124', + bidderRequestId: '117954d20d7c9c', + auctionStart: 1553624929697, + timeout: 700, + refererInfo: { + referer: 'http://localhost:9999/test/pages/video.html?pbjs_debug=true', + reachedTop: true, + numIframes: 0, + stack: [ 'http://localhost:9999/test/pages/video.html?pbjs_debug=true' ] + }, + start: 1553624929700 + }; + + bidderRequestVideo.bids = validBidRequestVideo; + let expectedDataVideo1 = { + id: 'v2624fabbb078e8-640x480', + tagid: '1234', + video: { + w: 640, + h: 480, + pos: 0, + minduration: 30 + } + }; + let validBidRequest = { bidId: '9876abcd', sizes: [[300, 250], [300, 600]], @@ -56,7 +176,7 @@ describe('synacormediaBidAdapter ', function () { pos: 0, w: 300, }, - id: '9876abcd~300x250', + id: 'b9876abcd-300x250', tagid: '1234', bidfloor: 0.5 }; @@ -66,12 +186,13 @@ describe('synacormediaBidAdapter ', function () { pos: 0, w: 300, }, - id: '9876abcd~300x600', + id: 'b9876abcd-300x600', tagid: '1234', bidfloor: 0.5 }; it('should return valid request when valid bids are used', function () { + // banner test let req = spec.buildRequests([validBidRequest], bidderRequest); expect(req).be.an('object'); expect(req).to.have.property('method', 'POST'); @@ -80,6 +201,16 @@ describe('synacormediaBidAdapter ', function () { expect(req.data).to.exist.and.to.be.an('object'); expect(req.data.id).to.equal('xyz123'); expect(req.data.imp).to.eql([expectedDataImp1, expectedDataImp2]); + + // video test + let reqVideo = spec.buildRequests([validBidRequestVideo], bidderRequestVideo); + expect(reqVideo).be.an('object'); + expect(reqVideo).to.have.property('method', 'POST'); + expect(reqVideo).to.have.property('url'); + expect(reqVideo.url).to.contain('//prebid.technoratimedia.com/openrtb/bids/prebid?'); + expect(reqVideo.data).to.exist.and.to.be.an('object'); + expect(reqVideo.data.id).to.equal('VideoAuctionId124'); + expect(reqVideo.data.imp).to.eql([expectedDataVideo1]); }); it('should return multiple bids when multiple valid requests with the same seatId are used', function () { @@ -104,7 +235,7 @@ describe('synacormediaBidAdapter ', function () { pos: 0, w: 300, }, - id: 'foobar~300x600', + id: 'bfoobar-300x600', tagid: '5678', bidfloor: 0.5 }]); @@ -132,7 +263,7 @@ describe('synacormediaBidAdapter ', function () { pos: 0, w: 300, }, - id: 'foobar~300x250', + id: 'bfoobar-300x250', tagid: '5678', bidfloor: 0.5 } @@ -161,7 +292,7 @@ describe('synacormediaBidAdapter ', function () { pos: 0, w: 300, }, - id: '9876abcd~300x250', + id: 'b9876abcd-300x250', tagid: '1234', } ]); @@ -188,7 +319,7 @@ describe('synacormediaBidAdapter ', function () { pos: 0, w: 300, }, - id: '9876abcd~300x250', + id: 'b9876abcd-300x250', tagid: '1234', } ]); @@ -216,7 +347,7 @@ describe('synacormediaBidAdapter ', function () { w: 300, pos: 1, }, - id: '9876abcd~300x250', + id: 'b9876abcd-300x250', tagid: '1234' } ]); @@ -243,7 +374,7 @@ describe('synacormediaBidAdapter ', function () { w: 300, pos: 0, }, - id: '9876abcd~300x250', + id: 'b9876abcd-300x250', tagid: '1234' } ]); @@ -252,22 +383,174 @@ describe('synacormediaBidAdapter ', function () { expect(spec.buildRequests([], bidderRequest)).to.be.undefined; expect(spec.buildRequests([validBidRequest], null)).to.be.undefined; }); + + it('should return empty impression when there is no valid sizes in bidrequest', function() { + let validBidReqWithoutSize = { + bidId: '9876abcd', + sizes: [], + params: { + seatId: 'prebid', + placementId: '1234', + bidfloor: '0.50' + } + }; + + let validBidReqInvalidSize = { + bidId: '9876abcd', + sizes: [[300]], + params: { + seatId: 'prebid', + placementId: '1234', + bidfloor: '0.50' + } + }; + + let bidderRequest = { + auctionId: 'xyz123', + refererInfo: { + referer: 'https://test.com/foo/bar' + } + }; + + let req = spec.buildRequests([validBidReqWithoutSize], bidderRequest); + assert.isUndefined(req); + req = spec.buildRequests([validBidReqInvalidSize], bidderRequest); + assert.isUndefined(req); + }); + it('should use all the video params in the impression request', function () { + let validBidRequestVideo = { + bidder: 'synacormedia', + params: { + seatId: 'prebid', + placementId: '1234', + video: { + minduration: 30, + maxduration: 45, + startdelay: 1, + linearity: 1, + placement: 1, + mimes: ['video/mp4'], + protocols: [1], + api: 1 + } + }, + mediaTypes: { + video: { + context: 'instream', + playerSize: [[ 640, 480 ]] + } + }, + adUnitCode: 'video1', + transactionId: '93e5def8-29aa-4fe8-bd3a-0298c39f189a', + sizes: [[ 640, 480 ]], + bidId: '2624fabbb078e8', + bidderRequestId: '117954d20d7c9c', + auctionId: 'defd525f-4f1e-4416-a4cb-ae53be90e706', + src: 'client', + bidRequestsCount: 1 + }; + + let req = spec.buildRequests([validBidRequestVideo], bidderRequest); + expect(req).to.have.property('method', 'POST'); + expect(req).to.have.property('url'); + expect(req.url).to.contain('//prebid.technoratimedia.com/openrtb/bids/prebid?src=$$REPO_AND_VERSION$$'); + expect(req.data.id).to.equal('xyz123'); + expect(req.data.imp).to.eql([ + { + video: { + h: 480, + pos: 0, + w: 640, + minduration: 30, + maxduration: 45, + startdelay: 1, + linearity: 1, + placement: 1, + mimes: ['video/mp4'], + protocols: [1], + api: 1 + }, + id: 'v2624fabbb078e8-640x480', + tagid: '1234', + } + ]); + }); + it('should move any video params in the mediaTypes object to params.video object', function () { + let validBidRequestVideo = { + bidder: 'synacormedia', + params: { + seatId: 'prebid', + placementId: '1234', + video: { + minduration: 30, + maxduration: 45, + protocols: [1], + api: 1 + } + }, + mediaTypes: { + video: { + context: 'instream', + playerSize: [[ 640, 480 ]], + startdelay: 1, + linearity: 1, + placement: 1, + mimes: ['video/mp4'] + } + }, + adUnitCode: 'video1', + transactionId: '93e5def8-29aa-4fe8-bd3a-0298c39f189a', + sizes: [[ 640, 480 ]], + bidId: '2624fabbb078e8', + bidderRequestId: '117954d20d7c9c', + auctionId: 'defd525f-4f1e-4416-a4cb-ae53be90e706', + src: 'client', + bidRequestsCount: 1 + }; + + let req = spec.buildRequests([validBidRequestVideo], bidderRequest); + expect(req).to.have.property('method', 'POST'); + expect(req).to.have.property('url'); + expect(req.url).to.contain('//prebid.technoratimedia.com/openrtb/bids/prebid?src=$$REPO_AND_VERSION$$'); + expect(req.data.id).to.equal('xyz123'); + expect(req.data.imp).to.eql([ + { + video: { + h: 480, + pos: 0, + w: 640, + minduration: 30, + maxduration: 45, + startdelay: 1, + linearity: 1, + placement: 1, + mimes: ['video/mp4'], + protocols: [1], + api: 1 + }, + id: 'v2624fabbb078e8-640x480', + tagid: '1234', + } + ]); + }); }); describe('interpretResponse', function () { let bidResponse = { id: '10865933907263896~9998~0', - impid: '9876abcd~300x250', + impid: 'b9876abcd-300x250', price: 0.13, crid: '1022-250', - adm: '' + adm: '', + nurl: '//uat-net.technoratimedia.com/openrtb/tags?ID=k5JkFVQ1RJT05fSU1QX0lEPXYyZjczN&AUCTION_PRICE=${AUCTION_PRICE}' }; let bidResponse2 = { id: '10865933907263800~9999~0', - impid: '9876abcd~300x600', + impid: 'b9876abcd-300x600', price: 1.99, crid: '9993-013', - adm: '' + adm: '', + nurl: '//uat-net.technoratimedia.com/openrtb/tags?ID=OTk5OX4wJkFVQ1RJT05fU0VBVF9JR&AUCTION_PRICE=${AUCTION_PRICE}' }; let serverResponse; @@ -282,6 +565,52 @@ describe('synacormediaBidAdapter ', function () { } }; }); + + it('should return 1 video bid when 1 bid is in the video response', function () { + let serverRespVideo = { + body: { + id: 'abcd1234', + seatbid: [ + { + bid: [ + { + id: '11339128001692337~9999~0', + impid: 'v2da7322b2df61f-640x480', + price: 0.45, + nurl: 'https://uat-net.technoratimedia.com/openrtb/tags?ID=QVVDVElPTl9JRD1lOTBhYWU1My1hZDkwLTRkNDEtYTQxMC1lZDY1MjIxMDc0ZGMmQVVDVElPTl9CSURfSUQ9MTEzMzkxMjgwMDE2OTIzMzd-OTk5OX4wJkFVQ1RJT05fU0VBVF9JRD05OTk5JkFVQ1RJT05fSU1QX0lEPXYyZGE3MzIyYjJkZjYxZi02NDB4NDgwJkFDVE9SX1JFRj1ha2thLnRjcDovL2F3cy1lYXN0MUBhZHMxMy5jYXAtdXNlMS5zeW5hY29yLmNvbToyNTUxL3VzZXIvJGNMYmZiIy0xOTk4NTIzNTk3JlNFQVRfSUQ9cHJlYmlk&AUCTION_PRICE=${AUCTION_PRICE}', + adm: '\n\n\n\nSynacor Media Ad Server - 9999\nhttps://uat-net.technoratimedia.com/openrtb/tags?ID=QVVDVElPTl9JRD1lOTBhYWU1My1hZDkwLTRkNDEtYTQxMC1lZDY1MjIxMDc0ZGMmQVVDVElPTl9CSURfSUQ9MTEzMzkxMjgwMDE2OTIzMzd-OTk5OX4wJkFVQ1RJT05fU0VBVF9JRD05OTk5JkFVQ1RJT05fSU1QX0lEPXYyZGE3MzIyYjJkZjYxZi02NDB4NDgwJkFDVE9SX1JFRj1ha2thLnRjcDovL2F3cy1lYXN0MUBhZHMxMy5jYXAtdXNlMS5zeW5hY29yLmNvbToyNTUxL3VzZXIvJGNMYmZiIy0xOTk4NTIzNTk3JlNFQVRfSUQ9cHJlYmlk&AUCTION_PRICE=${AUCTION_PRICE}\n\n\n', + adomain: [ 'psacentral.org' ], + cid: 'bidder-crid', + crid: 'bidder-cid', + cat: [] + } + ], + seat: '9999' + } + ] + } + }; + + // serverResponse.body.seatbid[0].bid.push(bidResponse); + let resp = spec.interpretResponse(serverRespVideo); + expect(resp).to.be.an('array').to.have.lengthOf(1); + expect(resp[0]).to.eql({ + requestId: '2da7322b2df61f', + adId: '11339128001692337-9999-0', + cpm: 0.45, + width: 640, + height: 480, + creativeId: '9999_bidder-cid', + currency: 'USD', + netRevenue: true, + mediaType: 'video', + ad: '\n\n\n\nSynacor Media Ad Server - 9999\nhttps://uat-net.technoratimedia.com/openrtb/tags?ID=QVVDVElPTl9JRD1lOTBhYWU1My1hZDkwLTRkNDEtYTQxMC1lZDY1MjIxMDc0ZGMmQVVDVElPTl9CSURfSUQ9MTEzMzkxMjgwMDE2OTIzMzd-OTk5OX4wJkFVQ1RJT05fU0VBVF9JRD05OTk5JkFVQ1RJT05fSU1QX0lEPXYyZGE3MzIyYjJkZjYxZi02NDB4NDgwJkFDVE9SX1JFRj1ha2thLnRjcDovL2F3cy1lYXN0MUBhZHMxMy5jYXAtdXNlMS5zeW5hY29yLmNvbToyNTUxL3VzZXIvJGNMYmZiIy0xOTk4NTIzNTk3JlNFQVRfSUQ9cHJlYmlk&AUCTION_PRICE=0.45\n\n\n', + ttl: 60, + videoCacheKey: 'QVVDVElPTl9JRD1lOTBhYWU1My1hZDkwLTRkNDEtYTQxMC1lZDY1MjIxMDc0ZGMmQVVDVElPTl9CSURfSUQ9MTEzMzkxMjgwMDE2OTIzMzd-OTk5OX4wJkFVQ1RJT05fU0VBVF9JRD05OTk5JkFVQ1RJT05fSU1QX0lEPXYyZGE3MzIyYjJkZjYxZi02NDB4NDgwJkFDVE9SX1JFRj1ha2thLnRjcDovL2F3cy1lYXN0MUBhZHMxMy5jYXAtdXNlMS5zeW5hY29yLmNvbToyNTUxL3VzZXIvJGNMYmZiIy0xOTk4NTIzNTk3JlNFQVRfSUQ9cHJlYmlk', + vastUrl: 'https://uat-net.technoratimedia.com/openrtb/tags?ID=QVVDVElPTl9JRD1lOTBhYWU1My1hZDkwLTRkNDEtYTQxMC1lZDY1MjIxMDc0ZGMmQVVDVElPTl9CSURfSUQ9MTEzMzkxMjgwMDE2OTIzMzd-OTk5OX4wJkFVQ1RJT05fU0VBVF9JRD05OTk5JkFVQ1RJT05fSU1QX0lEPXYyZGE3MzIyYjJkZjYxZi02NDB4NDgwJkFDVE9SX1JFRj1ha2thLnRjcDovL2F3cy1lYXN0MUBhZHMxMy5jYXAtdXNlMS5zeW5hY29yLmNvbToyNTUxL3VzZXIvJGNMYmZiIy0xOTk4NTIzNTk3JlNFQVRfSUQ9cHJlYmlk&AUCTION_PRICE=0.45' + }); + }); + it('should return 1 bid when 1 bid is in the response', function () { serverResponse.body.seatbid[0].bid.push(bidResponse); let resp = spec.interpretResponse(serverResponse); @@ -292,11 +621,11 @@ describe('synacormediaBidAdapter ', function () { cpm: 0.13, width: 300, height: 250, - creativeId: '9998~1022-250', + creativeId: '9998_1022-250', currency: 'USD', netRevenue: true, mediaType: BANNER, - ad: '', + ad: '', ttl: 60 }); }); @@ -315,31 +644,34 @@ describe('synacormediaBidAdapter ', function () { cpm: 0.13, width: 300, height: 250, - creativeId: '9998~1022-250', + creativeId: '9998_1022-250', currency: 'USD', netRevenue: true, mediaType: BANNER, - ad: '', + ad: '', ttl: 60 }); + expect(resp[1]).to.eql({ requestId: '9876abcd', adId: '10865933907263800-9999-0', cpm: 1.99, width: 300, height: 600, - creativeId: '9999~9993-013', + creativeId: '9999_9993-013', currency: 'USD', netRevenue: true, mediaType: BANNER, - ad: '', + ad: '', ttl: 60 }); }); + it('should not return a bid when no bid is in the response', function () { let resp = spec.interpretResponse(serverResponse); expect(resp).to.be.an('array').that.is.empty; }); + it('should not return a bid when there is no response body', function () { expect(spec.interpretResponse({ body: null })).to.not.exist; expect(spec.interpretResponse({ body: 'some error text' })).to.not.exist; diff --git a/test/spec/modules/teadsBidAdapter_spec.js b/test/spec/modules/teadsBidAdapter_spec.js index 20fdbe947c0..af1c7a9c01b 100644 --- a/test/spec/modules/teadsBidAdapter_spec.js +++ b/test/spec/modules/teadsBidAdapter_spec.js @@ -5,11 +5,11 @@ import {newBidder} from 'src/adapters/bidderFactory'; const ENDPOINT = '//a.teads.tv/hb/bid-request'; const AD_SCRIPT = '"'; -describe('teadsBidAdapter', function() { +describe('teadsBidAdapter', () => { const adapter = newBidder(spec); - describe('inherited functions', function() { - it('exists and is a function', function() { + describe('inherited functions', () => { + it('exists and is a function', () => { expect(adapter.callBids).to.exist.and.to.be.a('function'); }); }); @@ -132,6 +132,22 @@ describe('teadsBidAdapter', function() { expect(payload.gdpr_iab.status).to.equal(12); }); + it('should add referer info to payload', function () { + const bidRequest = Object.assign({}, bidRequests[0]) + const bidderRequest = { + refererInfo: { + referer: 'http://example.com/page.html', + reachedTop: true, + numIframes: 2 + } + } + const request = spec.buildRequests([bidRequest], bidderRequest); + const payload = JSON.parse(request.data); + + expect(payload.referrer).to.exist; + expect(payload.referrer).to.deep.equal('http://example.com/page.html') + }); + it('should send GDPR to endpoint with 11 status', function() { let consentString = 'JRJ8RKfDeBNsERRDCSAAZ+A=='; let bidderRequest = { @@ -270,16 +286,17 @@ describe('teadsBidAdapter', function() { 'currency': 'USD', 'height': 250, 'netRevenue': true, - 'requestId': '3ede2a3fa0db94', + 'bidId': '3ede2a3fa0db94', 'ttl': 360, 'width': 300, - 'creativeId': 'er2ee' + 'creativeId': 'er2ee', + 'placementId': 34 }] } }; it('should get correct bid response', function() { - let expectedResponse = [{ + let expectedResponse = { 'cpm': 0.5, 'width': 300, 'height': 250, @@ -288,11 +305,12 @@ describe('teadsBidAdapter', function() { 'ttl': 360, 'ad': AD_SCRIPT, 'requestId': '3ede2a3fa0db94', - 'creativeId': 'er2ee' - }]; + 'creativeId': 'er2ee', + 'placementId': 34 + }; let result = spec.interpretResponse(bids); - expect(Object.keys(result[0])).to.deep.equal(Object.keys(expectedResponse[0])); + expect(result[0]).to.deep.equal(expectedResponse); }); it('handles nobid responses', function() { @@ -306,4 +324,71 @@ describe('teadsBidAdapter', function() { expect(result.length).to.equal(0); }); }); + + it('should call userSync with good params', function() { + let bids = [{ + 'body': { + 'responses': [{ + 'ad': '', + 'ttl': 360, + 'creativeId': '5cb5dc9375c0e', + 'netRevenue': true, + 'currency': 'EUR', + 'sync': ['https:\/\/SYNC_URL'] + }] + } + }; + + it('should handle response', function() { + let expectedResponse = [ + { + cpm: 10.0, + width: '1', + height: '1', + currency: 'EUR', + netRevenue: true, + ttl: 360, + ad: '', + requestId: '242d506d4e4f15', + creativeId: '5cb5dc9375c0e' + } + ]; + + let result = spec.interpretResponse(serverResponse); + expect(Object.keys(result[0])).to.deep.equal(Object.keys(expectedResponse[0])); + }); + + it('should handles empty response', function() { + let serverResponse = { + 'body': { + 'responses': [] + } + }; + + let result = spec.interpretResponse(serverResponse); + expect(result.length).to.equal(0); + }); + + describe('getUserSyncs', () => { + it('should push user sync images if enabled', () => { + const syncOptions = { pixelEnabled: true }; + const syncs = spec.getUserSyncs(syncOptions, [serverResponse]); + + expect(syncs[0]).to.deep.equal({ + type: 'image', + url: 'https://SYNC_URL' + }); + }) + }); + }); +}); diff --git a/test/spec/modules/visxBidAdapter_spec.js b/test/spec/modules/visxBidAdapter_spec.js index 93dbe5626c2..09ce92479f9 100755 --- a/test/spec/modules/visxBidAdapter_spec.js +++ b/test/spec/modules/visxBidAdapter_spec.js @@ -40,6 +40,12 @@ describe('VisxAdapter', function () { }); describe('buildRequests', function () { + const bidderRequest = { + refererInfo: { + referer: 'http://example.com' + } + }; + const encodedReferrer = encodeURIComponent(bidderRequest.refererInfo.referer); let bidRequests = [ { 'bidder': 'visx', @@ -58,7 +64,7 @@ describe('VisxAdapter', function () { 'uid': '903535' }, 'adUnitCode': 'adunit-code-2', - 'sizes': [[728, 90]], + 'sizes': [[728, 90], [300, 250]], 'bidId': '3150ccb55da321', 'bidderRequestId': '22edbae2733bf6', 'auctionId': '1d1a030790a475', @@ -77,48 +83,51 @@ describe('VisxAdapter', function () { ]; it('should attach valid params to the tag', function () { - const request = spec.buildRequests([bidRequests[0]]); + const request = spec.buildRequests([bidRequests[0]], bidderRequest); const payload = request.data; expect(payload).to.be.an('object'); - expect(payload).to.have.property('u').that.is.a('string'); + expect(payload).to.have.property('u', encodedReferrer); expect(payload).to.have.property('pt', 'net'); expect(payload).to.have.property('auids', '903535'); + expect(payload).to.have.property('sizes', '300x250,300x600'); expect(payload).to.have.property('r', '22edbae2733bf6'); expect(payload).to.have.property('cur', 'EUR'); }); - it('auids must not be duplicated', function () { - const request = spec.buildRequests(bidRequests); + it('sizes must not be duplicated', function () { + const request = spec.buildRequests(bidRequests, bidderRequest); const payload = request.data; expect(payload).to.be.an('object'); - expect(payload).to.have.property('u').that.is.a('string'); + expect(payload).to.have.property('u', encodedReferrer); expect(payload).to.have.property('pt', 'net'); - expect(payload).to.have.property('auids', '903535,903536'); + expect(payload).to.have.property('auids', '903535,903535,903536'); + expect(payload).to.have.property('sizes', '300x250,300x600,728x90'); expect(payload).to.have.property('r', '22edbae2733bf6'); expect(payload).to.have.property('cur', 'EUR'); }); it('pt parameter must be "net" if params.priceType === "gross"', function () { bidRequests[1].params.priceType = 'gross'; - const request = spec.buildRequests(bidRequests); + const request = spec.buildRequests(bidRequests, bidderRequest); const payload = request.data; expect(payload).to.be.an('object'); - expect(payload).to.have.property('u').that.is.a('string'); + expect(payload).to.have.property('u', encodedReferrer); expect(payload).to.have.property('pt', 'net'); - expect(payload).to.have.property('auids', '903535,903536'); + expect(payload).to.have.property('auids', '903535,903535,903536'); + expect(payload).to.have.property('sizes', '300x250,300x600,728x90'); expect(payload).to.have.property('r', '22edbae2733bf6'); expect(payload).to.have.property('cur', 'EUR'); delete bidRequests[1].params.priceType; }); - it('pt parameter must be "net" if params.priceType === "net"', function () { bidRequests[1].params.priceType = 'net'; - const request = spec.buildRequests(bidRequests); + const request = spec.buildRequests(bidRequests, bidderRequest); const payload = request.data; expect(payload).to.be.an('object'); - expect(payload).to.have.property('u').that.is.a('string'); + expect(payload).to.have.property('u', encodedReferrer); expect(payload).to.have.property('pt', 'net'); - expect(payload).to.have.property('auids', '903535,903536'); + expect(payload).to.have.property('auids', '903535,903535,903536'); + expect(payload).to.have.property('sizes', '300x250,300x600,728x90'); expect(payload).to.have.property('r', '22edbae2733bf6'); expect(payload).to.have.property('cur', 'EUR'); delete bidRequests[1].params.priceType; @@ -126,12 +135,13 @@ describe('VisxAdapter', function () { it('pt parameter must be "net" if params.priceType === "undefined"', function () { bidRequests[1].params.priceType = 'undefined'; - const request = spec.buildRequests(bidRequests); + const request = spec.buildRequests(bidRequests, bidderRequest); const payload = request.data; expect(payload).to.be.an('object'); - expect(payload).to.have.property('u').that.is.a('string'); + expect(payload).to.have.property('u', encodedReferrer); expect(payload).to.have.property('pt', 'net'); - expect(payload).to.have.property('auids', '903535,903536'); + expect(payload).to.have.property('auids', '903535,903535,903536'); + expect(payload).to.have.property('sizes', '300x250,300x600,728x90'); expect(payload).to.have.property('r', '22edbae2733bf6'); expect(payload).to.have.property('cur', 'EUR'); delete bidRequests[1].params.priceType; @@ -140,12 +150,13 @@ describe('VisxAdapter', function () { it('should add currency from currency.bidderCurrencyDefault', function () { const getConfigStub = sinon.stub(config, 'getConfig').callsFake( arg => arg === 'currency.bidderCurrencyDefault.visx' ? 'JPY' : 'USD'); - const request = spec.buildRequests(bidRequests); + const request = spec.buildRequests(bidRequests, bidderRequest); const payload = request.data; expect(payload).to.be.an('object'); - expect(payload).to.have.property('u').that.is.a('string'); + expect(payload).to.have.property('u', encodedReferrer); expect(payload).to.have.property('pt', 'net'); - expect(payload).to.have.property('auids', '903535,903536'); + expect(payload).to.have.property('auids', '903535,903535,903536'); + expect(payload).to.have.property('sizes', '300x250,300x600,728x90'); expect(payload).to.have.property('r', '22edbae2733bf6'); expect(payload).to.have.property('cur', 'JPY'); getConfigStub.restore(); @@ -154,12 +165,13 @@ describe('VisxAdapter', function () { it('should add currency from currency.adServerCurrency', function () { const getConfigStub = sinon.stub(config, 'getConfig').callsFake( arg => arg === 'currency.bidderCurrencyDefault.visx' ? '' : 'USD'); - const request = spec.buildRequests(bidRequests); + const request = spec.buildRequests(bidRequests, bidderRequest); const payload = request.data; expect(payload).to.be.an('object'); - expect(payload).to.have.property('u').that.is.a('string'); + expect(payload).to.have.property('u', encodedReferrer); expect(payload).to.have.property('pt', 'net'); - expect(payload).to.have.property('auids', '903535,903536'); + expect(payload).to.have.property('auids', '903535,903535,903536'); + expect(payload).to.have.property('sizes', '300x250,300x600,728x90'); expect(payload).to.have.property('r', '22edbae2733bf6'); expect(payload).to.have.property('cur', 'USD'); getConfigStub.restore(); @@ -193,9 +205,10 @@ describe('VisxAdapter', function () { describe('interpretResponse', function () { const responses = [ {'bid': [{'price': 1.15, 'adm': '
    test content 1
    ', 'auid': 903535, 'h': 250, 'w': 300}], 'seat': '1'}, - {'bid': [{'price': 0.5, 'adm': '
    test content 2
    ', 'auid': 903536, 'h': 90, 'w': 728}], 'seat': '1'}, - {'bid': [{'price': 0, 'auid': 903536, 'h': 250, 'w': 300}], 'seat': '1'}, - {'bid': [{'price': 0, 'adm': '
    test content 4
    ', 'h': 250, 'w': 300}], 'seat': '1'}, + {'bid': [{'price': 0.5, 'adm': '
    test content 2
    ', 'auid': 903536, 'h': 600, 'w': 300}], 'seat': '1'}, + {'bid': [{'price': 0.15, 'adm': '
    test content 3
    ', 'auid': 903535, 'h': 90, 'w': 728}], 'seat': '1'}, + {'bid': [{'price': 0, 'auid': 903537, 'h': 250, 'w': 300}], 'seat': '1'}, + {'bid': [{'price': 0, 'adm': '
    test content 5
    ', 'h': 250, 'w': 300}], 'seat': '1'}, undefined, {'bid': [], 'seat': '1'}, {'seat': '1'}, @@ -225,6 +238,7 @@ describe('VisxAdapter', function () { 'width': 300, 'height': 250, 'ad': '
    test content 1
    ', + 'bidderCode': 'visx', 'currency': 'EUR', 'netRevenue': true, 'ttl': 360, @@ -281,37 +295,40 @@ describe('VisxAdapter', function () { 'width': 300, 'height': 250, 'ad': '
    test content 1
    ', + 'bidderCode': 'visx', 'currency': 'EUR', 'netRevenue': true, 'ttl': 360, }, { - 'requestId': '5703af74d0472a', - 'cpm': 1.15, - 'creativeId': 903535, + 'requestId': '4dff80cc4ee346', + 'cpm': 0.5, + 'creativeId': 903536, 'dealId': undefined, 'width': 300, - 'height': 250, - 'ad': '
    test content 1
    ', + 'height': 600, + 'ad': '
    test content 2
    ', + 'bidderCode': 'visx', 'currency': 'EUR', 'netRevenue': true, 'ttl': 360, }, { - 'requestId': '4dff80cc4ee346', - 'cpm': 0.5, - 'creativeId': 903536, + 'requestId': '5703af74d0472a', + 'cpm': 0.15, + 'creativeId': 903535, 'dealId': undefined, 'width': 728, 'height': 90, - 'ad': '
    test content 2
    ', + 'ad': '
    test content 3
    ', + 'bidderCode': 'visx', 'currency': 'EUR', 'netRevenue': true, 'ttl': 360, } ]; - const result = spec.interpretResponse({'body': {'seatbid': [responses[0], responses[1]]}}, request); + const result = spec.interpretResponse({'body': {'seatbid': responses.slice(0, 3)}}, request); expect(result).to.deep.equal(expectedResponse); }); @@ -340,6 +357,7 @@ describe('VisxAdapter', function () { 'width': 300, 'height': 250, 'ad': '
    test content 1
    ', + 'bidderCode': 'visx', 'currency': 'JPY', 'netRevenue': true, 'ttl': 360, @@ -356,7 +374,7 @@ describe('VisxAdapter', function () { { 'bidder': 'visx', 'params': { - 'uid': '903536' + 'uid': '903537' }, 'adUnitCode': 'adunit-code-1', 'sizes': [[300, 250], [300, 600]], @@ -388,8 +406,220 @@ describe('VisxAdapter', function () { } ]; const request = spec.buildRequests(bidRequests); - const result = spec.interpretResponse({'body': {'seatbid': responses.slice(2)}}, request); + const result = spec.interpretResponse({'body': {'seatbid': responses.slice(3)}}, request); expect(result.length).to.equal(0); }); + + it('complicated case', function () { + const fullResponse = [ + {'bid': [{'price': 1.15, 'adm': '
    test content 1
    ', 'auid': 903535, 'h': 250, 'w': 300}], 'seat': '1'}, + {'bid': [{'price': 0.5, 'adm': '
    test content 2
    ', 'auid': 903536, 'h': 600, 'w': 300}], 'seat': '1'}, + {'bid': [{'price': 0.15, 'adm': '
    test content 3
    ', 'auid': 903535, 'h': 90, 'w': 728}], 'seat': '1'}, + {'bid': [{'price': 0.15, 'adm': '
    test content 4
    ', 'auid': 903535, 'h': 600, 'w': 300}], 'seat': '1'}, + {'bid': [{'price': 0.5, 'adm': '
    test content 5
    ', 'auid': 903536, 'h': 600, 'w': 350}], 'seat': '1'}, + ]; + const bidRequests = [ + { + 'bidder': 'visx', + 'params': { + 'uid': '903535' + }, + 'adUnitCode': 'adunit-code-1', + 'sizes': [[300, 250], [300, 600]], + 'bidId': '2164be6358b9', + 'bidderRequestId': '106efe3247', + 'auctionId': '32a1f276cb87cb8', + }, + { + 'bidder': 'visx', + 'params': { + 'uid': '903535' + }, + 'adUnitCode': 'adunit-code-1', + 'sizes': [[300, 250], [300, 600]], + 'bidId': '326bde7fbf69', + 'bidderRequestId': '106efe3247', + 'auctionId': '32a1f276cb87cb8', + }, + { + 'bidder': 'visx', + 'params': { + 'uid': '903536' + }, + 'adUnitCode': 'adunit-code-1', + 'sizes': [[300, 250], [300, 600]], + 'bidId': '4e111f1b66e4', + 'bidderRequestId': '106efe3247', + 'auctionId': '32a1f276cb87cb8', + }, + { + 'bidder': 'visx', + 'params': { + 'uid': '903535' + }, + 'adUnitCode': 'adunit-code-2', + 'sizes': [[728, 90]], + 'bidId': '26d6f897b516', + 'bidderRequestId': '106efe3247', + 'auctionId': '32a1f276cb87cb8', + }, + { + 'bidder': 'visx', + 'params': { + 'uid': '903536' + }, + 'adUnitCode': 'adunit-code-2', + 'sizes': [[728, 90]], + 'bidId': '1751cd90161', + 'bidderRequestId': '106efe3247', + 'auctionId': '32a1f276cb87cb8', + } + ]; + const request = spec.buildRequests(bidRequests); + const expectedResponse = [ + { + 'requestId': '2164be6358b9', + 'cpm': 1.15, + 'creativeId': 903535, + 'dealId': undefined, + 'width': 300, + 'height': 250, + 'ad': '
    test content 1
    ', + 'bidderCode': 'visx', + 'currency': 'EUR', + 'netRevenue': true, + 'ttl': 360, + }, + { + 'requestId': '4e111f1b66e4', + 'cpm': 0.5, + 'creativeId': 903536, + 'dealId': undefined, + 'width': 300, + 'height': 600, + 'ad': '
    test content 2
    ', + 'bidderCode': 'visx', + 'currency': 'EUR', + 'netRevenue': true, + 'ttl': 360, + }, + { + 'requestId': '26d6f897b516', + 'cpm': 0.15, + 'creativeId': 903535, + 'dealId': undefined, + 'width': 728, + 'height': 90, + 'ad': '
    test content 3
    ', + 'bidderCode': 'visx', + 'currency': 'EUR', + 'netRevenue': true, + 'ttl': 360, + }, + { + 'requestId': '326bde7fbf69', + 'cpm': 0.15, + 'creativeId': 903535, + 'dealId': undefined, + 'width': 300, + 'height': 600, + 'ad': '
    test content 4
    ', + 'bidderCode': 'visx', + 'currency': 'EUR', + 'netRevenue': true, + 'ttl': 360, + }, + { + 'requestId': '1751cd90161', + 'cpm': 0.5, + 'creativeId': 903536, + 'dealId': undefined, + 'width': 350, + 'height': 600, + 'ad': '
    test content 5
    ', + 'bidderCode': 'visx', + 'currency': 'EUR', + 'netRevenue': true, + 'ttl': 360, + } + ]; + + const result = spec.interpretResponse({'body': {'seatbid': fullResponse}}, request); + expect(result).to.deep.equal(expectedResponse); + }); + + it('dublicate uids and sizes in one slot', function () { + const fullResponse = [ + {'bid': [{'price': 1.15, 'adm': '
    test content 1
    ', 'auid': 903535, 'h': 250, 'w': 300}], 'seat': '1'}, + {'bid': [{'price': 0.5, 'adm': '
    test content 2
    ', 'auid': 903535, 'h': 250, 'w': 300}], 'seat': '1'}, + ]; + const bidRequests = [ + { + 'bidder': 'visx', + 'params': { + 'uid': '903535' + }, + 'adUnitCode': 'adunit-code-1', + 'sizes': [[300, 250], [300, 600]], + 'bidId': '5126e301f4be', + 'bidderRequestId': '171c5405a390', + 'auctionId': '35bcbc0f7e79c', + }, + { + 'bidder': 'visx', + 'params': { + 'uid': '903535' + }, + 'adUnitCode': 'adunit-code-1', + 'sizes': [[300, 250], [300, 600]], + 'bidId': '57b2ebe70e16', + 'bidderRequestId': '171c5405a390', + 'auctionId': '35bcbc0f7e79c', + }, + { + 'bidder': 'visx', + 'params': { + 'uid': '903535' + }, + 'adUnitCode': 'adunit-code-1', + 'sizes': [[300, 250], [300, 600]], + 'bidId': '225fcd44b18c', + 'bidderRequestId': '171c5405a390', + 'auctionId': '35bcbc0f7e79c', + } + ]; + const request = spec.buildRequests(bidRequests); + const expectedResponse = [ + { + 'requestId': '5126e301f4be', + 'cpm': 1.15, + 'creativeId': 903535, + 'dealId': undefined, + 'width': 300, + 'height': 250, + 'ad': '
    test content 1
    ', + 'bidderCode': 'visx', + 'currency': 'EUR', + 'netRevenue': true, + 'ttl': 360, + }, + { + 'requestId': '57b2ebe70e16', + 'cpm': 0.5, + 'creativeId': 903535, + 'dealId': undefined, + 'width': 300, + 'height': 250, + 'ad': '
    test content 2
    ', + 'bidderCode': 'visx', + 'currency': 'EUR', + 'netRevenue': true, + 'ttl': 360, + } + ]; + + const result = spec.interpretResponse({'body': {'seatbid': fullResponse}}, request); + expect(result).to.deep.equal(expectedResponse); + }); }); }); diff --git a/test/spec/modules/yieldlabBidAdapter_spec.js b/test/spec/modules/yieldlabBidAdapter_spec.js index c2e12408cdd..c8709969e00 100644 --- a/test/spec/modules/yieldlabBidAdapter_spec.js +++ b/test/spec/modules/yieldlabBidAdapter_spec.js @@ -148,5 +148,22 @@ describe('yieldlabBidAdapter', function () { expect(result[0].vastUrl).to.include('https://ad.yieldlab.net/d/1111/2222/728x90?ts=') expect(result[0].vastUrl).to.include('&id=abc') }) + + it('should add renderer if outstream context', function () { + const OUTSTREAM_REQUEST = Object.assign({}, REQUEST, { + 'mediaTypes': { + 'video': { + 'playerSize': [[640, 480]], + 'context': 'outstream' + } + } + }) + const result = spec.interpretResponse({body: [RESPONSE]}, {validBidRequests: [OUTSTREAM_REQUEST]}) + + expect(result[0].renderer.id).to.equal('2d925f27f5079f') + expect(result[0].renderer.url).to.equal('https://ad2.movad.net/dynamic.ad?a=o193092&ma_loadEvent=ma-start-event') + expect(result[0].width).to.equal(640) + expect(result[0].height).to.equal(480) + }) }) }) diff --git a/test/spec/modules/yieldmoBidAdapter_spec.js b/test/spec/modules/yieldmoBidAdapter_spec.js index 80a9265a5c2..60fe25db95e 100644 --- a/test/spec/modules/yieldmoBidAdapter_spec.js +++ b/test/spec/modules/yieldmoBidAdapter_spec.js @@ -1,15 +1,19 @@ import { expect } from 'chai'; import { spec } from 'modules/yieldmoBidAdapter'; -import {newBidder} from 'src/adapters/bidderFactory'; +import { newBidder } from 'src/adapters/bidderFactory'; import * as utils from 'src/utils'; describe('YieldmoAdapter', function () { const adapter = newBidder(spec); const ENDPOINT = 'https://ads.yieldmo.com/exchange/prebid'; + let tdid = '8d146286-91d4-4958-aff4-7e489dd1abd6'; + let bid = { bidder: 'yieldmo', - params: {}, + params: { + bidFloor: 0.1 + }, adUnitCode: 'adunit-code', sizes: [[300, 250], [300, 600]], bidId: '30b31c1838de1e', @@ -17,6 +21,9 @@ describe('YieldmoAdapter', function () { auctionId: '1d1a030790a475', crumbs: { pubcid: 'c604130c-0144-4b63-9bf2-c2bd8c8d86da' + }, + userId: { + tdid, } }; let bidArray = [bid]; @@ -50,13 +57,22 @@ describe('YieldmoAdapter', function () { expect(request.url).to.be.equal(ENDPOINT); }); + it('should not blow up if crumbs is undefined', function () { + let bidArray = [ + { ...bid, crumbs: undefined } + ] + expect(function () { spec.buildRequests(bidArray) }).not.to.throw() + }) + it('should place bid information into the p parameter of data', function () { let placementInfo = spec.buildRequests(bidArray).data.p; - expect(placementInfo).to.equal('[{"placement_id":"adunit-code","callback_id":"30b31c1838de1e","sizes":[[300,250],[300,600]]}]'); + expect(placementInfo).to.equal('[{"placement_id":"adunit-code","callback_id":"30b31c1838de1e","sizes":[[300,250],[300,600]],"bidFloor":0.1}]'); bidArray.push({ bidder: 'yieldmo', - params: {}, + params: { + bidFloor: 0.2 + }, adUnitCode: 'adunit-code-1', sizes: [[300, 250], [300, 600]], bidId: '123456789', @@ -70,19 +86,19 @@ describe('YieldmoAdapter', function () { // multiple placements placementInfo = spec.buildRequests(bidArray).data.p; - expect(placementInfo).to.equal('[{"placement_id":"adunit-code","callback_id":"30b31c1838de1e","sizes":[[300,250],[300,600]]},{"placement_id":"adunit-code-1","callback_id":"123456789","sizes":[[300,250],[300,600]]}]'); + expect(placementInfo).to.equal('[{"placement_id":"adunit-code","callback_id":"30b31c1838de1e","sizes":[[300,250],[300,600]],"bidFloor":0.1},{"placement_id":"adunit-code-1","callback_id":"123456789","sizes":[[300,250],[300,600]],"bidFloor":0.2}]'); }); it('should add placement id if given', function () { bidArray[0].params.placementId = 'ym_1293871298'; let placementInfo = spec.buildRequests(bidArray).data.p; - expect(placementInfo).to.include('"ym_placement_id":"ym_1293871298"}'); - expect(placementInfo).not.to.include('"ym_placement_id":"ym_0987654321"}'); + expect(placementInfo).to.include('"ym_placement_id":"ym_1293871298"'); + expect(placementInfo).not.to.include('"ym_placement_id":"ym_0987654321"'); bidArray[1].params.placementId = 'ym_0987654321'; placementInfo = spec.buildRequests(bidArray).data.p; - expect(placementInfo).to.include('"ym_placement_id":"ym_1293871298"}'); - expect(placementInfo).to.include('"ym_placement_id":"ym_0987654321"}'); + expect(placementInfo).to.include('"ym_placement_id":"ym_1293871298"'); + expect(placementInfo).to.include('"ym_placement_id":"ym_0987654321"'); }); it('should add additional information to data parameter of request', function () { @@ -97,7 +113,8 @@ describe('YieldmoAdapter', function () { expect(data.hasOwnProperty('title')).to.be.true; expect(data.hasOwnProperty('h')).to.be.true; expect(data.hasOwnProperty('w')).to.be.true; - }) + expect(data.hasOwnProperty('pubcid')).to.be.true; + }); it('should add pubcid as parameter of request', function () { const pubcidBid = { @@ -114,7 +131,24 @@ describe('YieldmoAdapter', function () { }; const data = spec.buildRequests([pubcidBid]).data; expect(data.pubcid).to.deep.equal('c604130c-0144-4b63-9bf2-c2bd8c8d86da2'); - }) + }); + + it('should add unified id as parameter of request', function () { + const unifiedIdBid = { + bidder: 'yieldmo', + params: {}, + adUnitCode: 'adunit-code', + sizes: [[300, 250], [300, 600]], + bidId: '30b31c1838de1e', + bidderRequestId: '22edbae2733bf6', + auctionId: '1d1a030790a475', + userId: { + tdid, + } + }; + const data = spec.buildRequests([unifiedIdBid]).data; + expect(data.tdid).to.deep.equal(tdid); + }); }); describe('interpretResponse', function () { diff --git a/test/spec/modules/yieldnexusBidAdapter_spec.js b/test/spec/modules/yieldnexusBidAdapter_spec.js index 3d36291f136..8f2e40d1810 100644 --- a/test/spec/modules/yieldnexusBidAdapter_spec.js +++ b/test/spec/modules/yieldnexusBidAdapter_spec.js @@ -142,6 +142,27 @@ describe('YieldNexusAdapter', () => { response = spec.buildRequests([bidRequestWithPosEquals1])[0]; expect(response.data.imp[0].video.pos).to.equal(bidRequestWithPosEquals1.params.pos); }); + + it('builds request video object correctly with multi-dimensions size array', function () { + let bidRequestWithVideo = utils.deepClone(bidRequest); + bidRequestWithVideo.mediaTypes.video = { + playerSize: [[304, 254], [305, 255]], + context: 'instream' + }; + + let response = spec.buildRequests([bidRequestWithVideo], bidRequest)[0]; + expect(response.data.imp[0].video.w).to.equal(304); + expect(response.data.imp[0].video.h).to.equal(254); + + bidRequestWithVideo = utils.deepClone(bidRequest); + bidRequestWithVideo.mediaTypes.video = { + playerSize: [304, 254] + }; + + response = spec.buildRequests([bidRequestWithVideo], bidRequest)[0]; + expect(response.data.imp[0].video.w).to.equal(304); + expect(response.data.imp[0].video.h).to.equal(254); + }); }); describe('interpretResponse', () => { const bannerBidRequest = { diff --git a/test/spec/modules/yieldoneBidAdapter_spec.js b/test/spec/modules/yieldoneBidAdapter_spec.js index e91eeab1369..abc579514ef 100644 --- a/test/spec/modules/yieldoneBidAdapter_spec.js +++ b/test/spec/modules/yieldoneBidAdapter_spec.js @@ -2,8 +2,9 @@ import { expect } from 'chai'; import { spec } from 'modules/yieldoneBidAdapter'; import { newBidder } from 'src/adapters/bidderFactory'; -const ENDPOINT = '//y.one.impact-ad.jp/h_bid'; -const USER_SYNC_URL = '//y.one.impact-ad.jp/push_sync'; +const ENDPOINT = 'https://y.one.impact-ad.jp/h_bid'; +const USER_SYNC_URL = 'https://y.one.impact-ad.jp/push_sync'; +const VIDEO_PLAYER_URL = 'https://img.ak.impact-ad.jp/ic/pone/ivt/firstview/js/dac-video-prebid.min.js'; describe('yieldoneBidAdapter', function() { const adapter = newBidder(spec); @@ -99,7 +100,7 @@ describe('yieldoneBidAdapter', function() { let bidRequestBanner = [ { 'method': 'GET', - 'url': '//y.one.impact-ad.jp/h_bid', + 'url': 'https://y.one.impact-ad.jp/h_bid', 'data': { 'v': 'hb1', 'p': '36891', @@ -163,7 +164,7 @@ describe('yieldoneBidAdapter', function() { let bidRequestVideo = [ { 'method': 'GET', - 'url': '//y.one.impact-ad.jp/h_bid', + 'url': 'https://y.one.impact-ad.jp/h_bid', 'data': { 'v': 'hb1', 'p': '41993', @@ -190,11 +191,17 @@ describe('yieldoneBidAdapter', function() { 'ttl': 3000, 'referrer': '', 'mediaType': 'video', - 'vastXml': '' + 'vastXml': '', + 'renderer': { + id: '23beaa6af6cdde', + url: VIDEO_PLAYER_URL + } }]; let result = spec.interpretResponse(serverResponseVideo, bidRequestVideo[0]); expect(Object.keys(result[0])).to.deep.equal(Object.keys(expectedResponse[0])); expect(result[0].mediaType).to.equal(expectedResponse[0].mediaType); + expect(result[0].renderer.id).to.equal(expectedResponse[0].renderer.id); + expect(result[0].renderer.url).to.equal(expectedResponse[0].renderer.url); }); it('handles empty bid response', function () { diff --git a/test/spec/renderer_spec.js b/test/spec/renderer_spec.js index 7a7354add31..f9a670c1315 100644 --- a/test/spec/renderer_spec.js +++ b/test/spec/renderer_spec.js @@ -114,7 +114,7 @@ describe('Renderer', function () { $$PREBID_GLOBAL$$.adUnits = [{ code: 'video1', renderer: { - url: 'http://cdn.adnxs.com/renderer/video/ANOutstreamVideo.js', + url: 'http://acdn.adnxs.com/video/outstream/ANOutstreamVideo.js', render: sinon.spy() } }] diff --git a/test/spec/sizeMapping_spec.js b/test/spec/sizeMapping_spec.js index f85da4cba0b..254dcb8003e 100644 --- a/test/spec/sizeMapping_spec.js +++ b/test/spec/sizeMapping_spec.js @@ -66,13 +66,6 @@ describe('sizeMapping', function () { } return matchMediaOverride; }); - - sandbox.stub(window, 'matchMedia').callsFake((...args) => { - if (typeof matchMediaOverride === 'function') { - return matchMediaOverride.apply(window, args); - } - return matchMediaOverride; - }); }); afterEach(function () { @@ -161,15 +154,14 @@ describe('sizeMapping', function () { }); }); - it('should filter all banner sizes but not disable adUnit if multiple mediaTypes are present', function () { + it('should filter all banner sizes and should disable the adUnit even if other mediaTypes are present', function () { matchMediaOverride = (str) => str === '(min-width: 0px) and (max-width: 767px)' ? {matches: true} : {matches: false}; - let status = resolveStatus(undefined, Object.assign({}, testSizes, { native: { type: 'image' } }), undefined, sizeConfig); - expect(status.active).to.equal(true); + expect(status.active).to.equal(false); expect(status.mediaTypes).to.deep.equal({ banner: { sizes: [] @@ -210,12 +202,101 @@ describe('sizeMapping', function () { expect(status.mediaTypes).to.deep.equal(testSizes); }); + it('should activate/decactivate adUnits/bidders based on labels with multiformat ads', function () { + matchMediaOverride = (str) => str === '(min-width: 768px) and (max-width: 1199px)' ? {matches: true} : {matches: false}; + + let multiFormatSizes = { + banner: { + sizes: [[728, 90], [300, 300]] + }, + native: { + type: 'image' + }, + video: { + context: 'outstream', + playerSize: [300, 300] + } + }; + + let status = resolveStatus({ + labels: ['tablet', 'test'], + labelAll: true + }, multiFormatSizes, undefined, sizeConfigWithLabels); + + expect(status.active).to.equal(false); + expect(status.mediaTypes).to.deep.equal({ + banner: { + sizes: [[728, 90]] + }, + native: { + type: 'image' + }, + video: { + context: 'outstream', + playerSize: [300, 300] + } + }); + + status = resolveStatus({ + labels: ['tablet'] + }, multiFormatSizes, undefined, sizeConfigWithLabels); + + expect(status.active).to.equal(true); + expect(status.mediaTypes).to.deep.equal({ + banner: { + sizes: [[728, 90]] + }, + native: { + type: 'image' + }, + video: { + context: 'outstream', + playerSize: [300, 300] + } + }); + + multiFormatSizes.banner.sizes.splice(0, 1, [728, 80]); + status = resolveStatus({ + labels: ['tablet'] + }, multiFormatSizes, undefined, sizeConfigWithLabels); + + expect(status.active).to.equal(false); + expect(status.mediaTypes).to.deep.equal({ + banner: { + sizes: [] + }, + native: { + type: 'image' + }, + video: { + context: 'outstream', + playerSize: [300, 300] + } + }); + + delete multiFormatSizes.banner; + status = resolveStatus({ + labels: ['tablet'] + }, multiFormatSizes, undefined, sizeConfigWithLabels); + + expect(status.active).to.equal(true); + expect(status.mediaTypes).to.deep.equal({ + native: { + type: 'image' + }, + video: { + context: 'outstream', + playerSize: [300, 300] + } + }); + }); + it('should active/deactivate adUnits/bidders based on requestBids labels', function () { let activeLabels = ['us-visitor', 'desktop', 'smart']; let status = resolveStatus({ - labels: ['uk-visitor'], - activeLabels + labels: ['uk-visitor'], // from adunit + activeLabels // from requestBids.labels }, testSizes, undefined, sizeConfigWithLabels); expect(status.active).to.equal(false); diff --git a/test/spec/unit/core/adapterManager_spec.js b/test/spec/unit/core/adapterManager_spec.js index f52aadba647..8eb1e21b229 100644 --- a/test/spec/unit/core/adapterManager_spec.js +++ b/test/spec/unit/core/adapterManager_spec.js @@ -1,8 +1,10 @@ import { expect } from 'chai'; -import adapterManager, { - gdprDataHandler -} from 'src/adapterManager'; -import { getAdUnits } from 'test/fixtures/fixtures'; +import adapterManager, { gdprDataHandler } from 'src/adapterManager'; +import { + getAdUnits, + getServerTestingConfig, + getServerTestingsAds +} from 'test/fixtures/fixtures'; import CONSTANTS from 'src/constants.json'; import * as utils from 'src/utils'; import { config } from 'src/config'; @@ -1142,5 +1144,128 @@ describe('adapterManager tests', function () { expect(bidRequests[0].gdprConsent).to.be.undefined; }); }); + + describe('s2sTesting - testServerOnly', () => { + beforeEach(() => { + config.setConfig({ s2sConfig: getServerTestingConfig(CONFIG) }); + }); + + afterEach(() => config.resetConfig()); + + const makeBidRequests = ads => { + let bidRequests = adapterManager.makeBidRequests( + ads, 1111, 2222, 1000 + ); + + bidRequests.sort((a, b) => { + if (a.bidderCode < b.bidderCode) return -1; + if (a.bidderCode > b.bidderCode) return 1; + return 0; + }); + + return bidRequests; + }; + + const removeAdUnitsBidSource = adUnits => adUnits.map(adUnit => { + const newAdUnit = { ...adUnit }; + newAdUnit.bids = newAdUnit.bids.map(bid => { + if (bid.bidSource) delete bid.bidSource; + return bid; + }); + return newAdUnit; + }); + + it('suppresses all client bids if there are server bids resulting from bidSource at the adUnit Level', () => { + const bidRequests = makeBidRequests(getServerTestingsAds()); + + expect(bidRequests).lengthOf(2); + + expect(bidRequests[0].bids).lengthOf(1); + expect(bidRequests[0].bids[0].bidder).equals('openx'); + expect(bidRequests[0].bids[0].finalSource).equals('server'); + + expect(bidRequests[0].bids).lengthOf(1); + expect(bidRequests[1].bids[0].bidder).equals('rubicon'); + expect(bidRequests[1].bids[0].finalSource).equals('server'); + }); + + // todo: update description + it('suppresses all, and only, client bids if there are bids resulting from bidSource at the adUnit Level', () => { + const ads = getServerTestingsAds(); + + // change this adUnit to be server based + ads[1].bids[1].bidSource.client = 0; + ads[1].bids[1].bidSource.server = 100; + + const bidRequests = makeBidRequests(ads); + + expect(bidRequests).lengthOf(3); + + expect(bidRequests[0].bids).lengthOf(1); + expect(bidRequests[0].bids[0].bidder).equals('appnexus'); + expect(bidRequests[0].bids[0].finalSource).equals('server'); + + expect(bidRequests[1].bids).lengthOf(1); + expect(bidRequests[1].bids[0].bidder).equals('openx'); + expect(bidRequests[1].bids[0].finalSource).equals('server'); + + expect(bidRequests[2].bids).lengthOf(1); + expect(bidRequests[2].bids[0].bidder).equals('rubicon'); + expect(bidRequests[2].bids[0].finalSource).equals('server'); + }); + + // we have a server call now + it('does not suppress client bids if no "test case" bids result in a server bid', () => { + const ads = getServerTestingsAds(); + + // change this adUnit to be client based + ads[0].bids[0].bidSource.client = 100; + ads[0].bids[0].bidSource.server = 0; + + const bidRequests = makeBidRequests(ads); + + expect(bidRequests).lengthOf(4); + + expect(bidRequests[0].bids).lengthOf(1); + expect(bidRequests[0].bids[0].bidder).equals('adequant'); + expect(bidRequests[0].bids[0].finalSource).equals('client'); + + expect(bidRequests[1].bids).lengthOf(2); + expect(bidRequests[1].bids[0].bidder).equals('appnexus'); + expect(bidRequests[1].bids[0].finalSource).equals('client'); + expect(bidRequests[1].bids[1].bidder).equals('appnexus'); + expect(bidRequests[1].bids[1].finalSource).equals('client'); + + expect(bidRequests[2].bids).lengthOf(1); + expect(bidRequests[2].bids[0].bidder).equals('openx'); + expect(bidRequests[2].bids[0].finalSource).equals('server'); + + expect(bidRequests[3].bids).lengthOf(2); + expect(bidRequests[3].bids[0].bidder).equals('rubicon'); + expect(bidRequests[3].bids[0].finalSource).equals('client'); + expect(bidRequests[3].bids[1].bidder).equals('rubicon'); + expect(bidRequests[3].bids[1].finalSource).equals('client'); + }); + + it( + 'should surpress client side bids if no ad unit bidSources are set, ' + + 'but bidderControl resolves to server', + () => { + const ads = removeAdUnitsBidSource(getServerTestingsAds()); + + const bidRequests = makeBidRequests(ads); + + expect(bidRequests).lengthOf(2); + + expect(bidRequests[0].bids).lengthOf(1); + expect(bidRequests[0].bids[0].bidder).equals('openx'); + expect(bidRequests[0].bids[0].finalSource).equals('server'); + + expect(bidRequests[1].bids).lengthOf(2); + expect(bidRequests[1].bids[0].bidder).equals('rubicon'); + expect(bidRequests[1].bids[0].finalSource).equals('server'); + } + ); + }); }); }); diff --git a/test/spec/unit/core/bidderFactory_spec.js b/test/spec/unit/core/bidderFactory_spec.js index 9e201afbe6c..fd54d2911e1 100644 --- a/test/spec/unit/core/bidderFactory_spec.js +++ b/test/spec/unit/core/bidderFactory_spec.js @@ -29,6 +29,10 @@ const MOCK_BIDS_REQUEST = { ] } +function onTimelyResponseStub() { + +} + describe('bidders created by newBidder', function () { let spec; let bidder; @@ -67,7 +71,7 @@ describe('bidders created by newBidder', function () { spec.getUserSyncs.returns([]); bidder.callBids({}); - bidder.callBids({ bids: 'nothing useful' }, addBidResponseStub, doneStub, ajaxStub); + bidder.callBids({ bids: 'nothing useful' }, addBidResponseStub, doneStub, ajaxStub, onTimelyResponseStub); expect(ajaxStub.called).to.equal(false); expect(spec.isBidRequestValid.called).to.equal(false); @@ -81,7 +85,7 @@ describe('bidders created by newBidder', function () { spec.isBidRequestValid.returns(true); spec.buildRequests.returns([]); - bidder.callBids(MOCK_BIDS_REQUEST, addBidResponseStub, doneStub, ajaxStub); + bidder.callBids(MOCK_BIDS_REQUEST, addBidResponseStub, doneStub, ajaxStub, onTimelyResponseStub); expect(ajaxStub.called).to.equal(false); expect(spec.isBidRequestValid.calledTwice).to.equal(true); @@ -95,7 +99,7 @@ describe('bidders created by newBidder', function () { spec.isBidRequestValid.returns(false); spec.buildRequests.returns([]); - bidder.callBids(MOCK_BIDS_REQUEST, addBidResponseStub, doneStub, ajaxStub); + bidder.callBids(MOCK_BIDS_REQUEST, addBidResponseStub, doneStub, ajaxStub, onTimelyResponseStub); expect(ajaxStub.called).to.equal(false); expect(spec.isBidRequestValid.calledTwice).to.equal(true); @@ -109,7 +113,7 @@ describe('bidders created by newBidder', function () { spec.isBidRequestValid.onSecondCall().returns(false); spec.buildRequests.returns([]); - bidder.callBids(MOCK_BIDS_REQUEST, addBidResponseStub, doneStub, ajaxStub); + bidder.callBids(MOCK_BIDS_REQUEST, addBidResponseStub, doneStub, ajaxStub, onTimelyResponseStub); expect(ajaxStub.called).to.equal(false); expect(spec.isBidRequestValid.calledTwice).to.equal(true); @@ -123,7 +127,7 @@ describe('bidders created by newBidder', function () { spec.isBidRequestValid.returns(true); spec.buildRequests.returns([]); - bidder.callBids(MOCK_BIDS_REQUEST, addBidResponseStub, doneStub, ajaxStub); + bidder.callBids(MOCK_BIDS_REQUEST, addBidResponseStub, doneStub, ajaxStub, onTimelyResponseStub); expect(ajaxStub.called).to.equal(false); }); @@ -139,7 +143,7 @@ describe('bidders created by newBidder', function () { data: data }); - bidder.callBids(MOCK_BIDS_REQUEST, addBidResponseStub, doneStub, ajaxStub); + bidder.callBids(MOCK_BIDS_REQUEST, addBidResponseStub, doneStub, ajaxStub, onTimelyResponseStub); expect(ajaxStub.calledOnce).to.equal(true); expect(ajaxStub.firstCall.args[0]).to.equal(url); @@ -164,7 +168,7 @@ describe('bidders created by newBidder', function () { options: options }); - bidder.callBids(MOCK_BIDS_REQUEST, addBidResponseStub, doneStub, ajaxStub); + bidder.callBids(MOCK_BIDS_REQUEST, addBidResponseStub, doneStub, ajaxStub, onTimelyResponseStub); expect(ajaxStub.calledOnce).to.equal(true); expect(ajaxStub.firstCall.args[0]).to.equal(url); @@ -187,7 +191,7 @@ describe('bidders created by newBidder', function () { data: data }); - bidder.callBids(MOCK_BIDS_REQUEST, addBidResponseStub, doneStub, ajaxStub); + bidder.callBids(MOCK_BIDS_REQUEST, addBidResponseStub, doneStub, ajaxStub, onTimelyResponseStub); expect(ajaxStub.calledOnce).to.equal(true); expect(ajaxStub.firstCall.args[0]).to.equal(`${url}?arg=2&`); @@ -211,7 +215,7 @@ describe('bidders created by newBidder', function () { options: opt }); - bidder.callBids(MOCK_BIDS_REQUEST, addBidResponseStub, doneStub, ajaxStub); + bidder.callBids(MOCK_BIDS_REQUEST, addBidResponseStub, doneStub, ajaxStub, onTimelyResponseStub); expect(ajaxStub.calledOnce).to.equal(true); expect(ajaxStub.firstCall.args[0]).to.equal(`${url}?arg=2&`); @@ -240,7 +244,7 @@ describe('bidders created by newBidder', function () { } ]); - bidder.callBids(MOCK_BIDS_REQUEST, addBidResponseStub, doneStub, ajaxStub); + bidder.callBids(MOCK_BIDS_REQUEST, addBidResponseStub, doneStub, ajaxStub, onTimelyResponseStub); expect(ajaxStub.calledTwice).to.equal(true); }); @@ -253,7 +257,7 @@ describe('bidders created by newBidder', function () { spec.interpretResponse.returns([]); spec.getUserSyncs.returns([]); - bidder.callBids(MOCK_BIDS_REQUEST, addBidResponseStub, doneStub, ajaxStub); + bidder.callBids(MOCK_BIDS_REQUEST, addBidResponseStub, doneStub, ajaxStub, onTimelyResponseStub); expect(addBidResponseStub.callCount).to.equal(0); }); @@ -293,7 +297,7 @@ describe('bidders created by newBidder', function () { }); spec.getUserSyncs.returns([]); - bidder.callBids(MOCK_BIDS_REQUEST, addBidResponseStub, doneStub, ajaxStub); + bidder.callBids(MOCK_BIDS_REQUEST, addBidResponseStub, doneStub, ajaxStub, onTimelyResponseStub); expect(spec.interpretResponse.calledOnce).to.equal(true); const response = spec.interpretResponse.firstCall.args[0] @@ -325,7 +329,7 @@ describe('bidders created by newBidder', function () { ]); spec.getUserSyncs.returns([]); - bidder.callBids(MOCK_BIDS_REQUEST, addBidResponseStub, doneStub, ajaxStub); + bidder.callBids(MOCK_BIDS_REQUEST, addBidResponseStub, doneStub, ajaxStub, onTimelyResponseStub); expect(spec.interpretResponse.calledTwice).to.equal(true); expect(doneStub.calledOnce).to.equal(true); @@ -356,7 +360,7 @@ describe('bidders created by newBidder', function () { spec.interpretResponse.returns(bid); - bidder.callBids(MOCK_BIDS_REQUEST, addBidResponseStub, doneStub, ajaxStub); + bidder.callBids(MOCK_BIDS_REQUEST, addBidResponseStub, doneStub, ajaxStub, onTimelyResponseStub); expect(addBidResponseStub.calledOnce).to.equal(true); expect(addBidResponseStub.firstCall.args[0]).to.equal('mock/placement'); @@ -375,7 +379,7 @@ describe('bidders created by newBidder', function () { }); spec.getUserSyncs.returns([]); - bidder.callBids(MOCK_BIDS_REQUEST, addBidResponseStub, doneStub, ajaxStub); + bidder.callBids(MOCK_BIDS_REQUEST, addBidResponseStub, doneStub, ajaxStub, onTimelyResponseStub); expect(spec.getUserSyncs.calledOnce).to.equal(true); expect(spec.getUserSyncs.firstCall.args[1].length).to.equal(1); @@ -394,7 +398,7 @@ describe('bidders created by newBidder', function () { url: 'usersync.com' }]); - bidder.callBids(MOCK_BIDS_REQUEST, addBidResponseStub, doneStub, ajaxStub); + bidder.callBids(MOCK_BIDS_REQUEST, addBidResponseStub, doneStub, ajaxStub, onTimelyResponseStub); expect(userSyncStub.called).to.equal(true); expect(userSyncStub.firstCall.args[0]).to.equal('iframe'); @@ -423,7 +427,7 @@ describe('bidders created by newBidder', function () { spec.interpretResponse.returns(bid); - bidder.callBids(MOCK_BIDS_REQUEST, addBidResponseStub, doneStub, ajaxStub); + bidder.callBids(MOCK_BIDS_REQUEST, addBidResponseStub, doneStub, ajaxStub, onTimelyResponseStub); expect(logErrorSpy.calledOnce).to.equal(true); }); @@ -453,7 +457,7 @@ describe('bidders created by newBidder', function () { spec.interpretResponse.returns(bid); - bidder.callBids(MOCK_BIDS_REQUEST, addBidResponseStub, doneStub, ajaxStub); + bidder.callBids(MOCK_BIDS_REQUEST, addBidResponseStub, doneStub, ajaxStub, onTimelyResponseStub); expect(logErrorSpy.calledOnce).to.equal(true); }); @@ -485,7 +489,7 @@ describe('bidders created by newBidder', function () { }); spec.getUserSyncs.returns([]); - bidder.callBids(MOCK_BIDS_REQUEST, addBidResponseStub, doneStub, ajaxStub); + bidder.callBids(MOCK_BIDS_REQUEST, addBidResponseStub, doneStub, ajaxStub, onTimelyResponseStub); expect(spec.interpretResponse.called).to.equal(false); expect(doneStub.calledOnce).to.equal(true); @@ -503,7 +507,7 @@ describe('bidders created by newBidder', function () { spec.interpretResponse.returns([]); spec.getUserSyncs.returns([]); - bidder.callBids(MOCK_BIDS_REQUEST, addBidResponseStub, doneStub, ajaxStub); + bidder.callBids(MOCK_BIDS_REQUEST, addBidResponseStub, doneStub, ajaxStub, onTimelyResponseStub); expect(addBidResponseStub.callCount).to.equal(0); expect(doneStub.calledOnce).to.equal(true); @@ -520,7 +524,7 @@ describe('bidders created by newBidder', function () { }); spec.getUserSyncs.returns([]); - bidder.callBids(MOCK_BIDS_REQUEST, addBidResponseStub, doneStub, ajaxStub); + bidder.callBids(MOCK_BIDS_REQUEST, addBidResponseStub, doneStub, ajaxStub, onTimelyResponseStub); expect(spec.getUserSyncs.calledOnce).to.equal(true); expect(spec.getUserSyncs.firstCall.args[1]).to.deep.equal([]); @@ -666,7 +670,7 @@ describe('validate bid response: ', function () { const bidder = newBidder(spec); spec.interpretResponse.returns(bids1); - bidder.callBids(bidRequest, addBidResponseStub, doneStub, ajaxStub); + bidder.callBids(bidRequest, addBidResponseStub, doneStub, ajaxStub, onTimelyResponseStub); expect(addBidResponseStub.calledOnce).to.equal(true); expect(addBidResponseStub.firstCall.args[0]).to.equal('mock/placement'); @@ -703,7 +707,7 @@ describe('validate bid response: ', function () { const bidder = newBidder(spec); spec.interpretResponse.returns(bids1); - bidder.callBids(bidRequest, addBidResponseStub, doneStub, ajaxStub); + bidder.callBids(bidRequest, addBidResponseStub, doneStub, ajaxStub, onTimelyResponseStub); expect(addBidResponseStub.calledOnce).to.equal(false); expect(logErrorSpy.callCount).to.equal(1); @@ -736,7 +740,7 @@ describe('validate bid response: ', function () { const bidder = newBidder(spec); spec.interpretResponse.returns(bids1); - bidder.callBids(bidRequest, addBidResponseStub, doneStub, ajaxStub); + bidder.callBids(bidRequest, addBidResponseStub, doneStub, ajaxStub, onTimelyResponseStub); expect(addBidResponseStub.calledOnce).to.equal(true); expect(addBidResponseStub.firstCall.args[0]).to.equal('mock/placement'); @@ -768,7 +772,7 @@ describe('validate bid response: ', function () { const bidder = newBidder(spec); spec.interpretResponse.returns(bids1); - bidder.callBids(bidRequest, addBidResponseStub, doneStub, ajaxStub); + bidder.callBids(bidRequest, addBidResponseStub, doneStub, ajaxStub, onTimelyResponseStub); expect(addBidResponseStub.calledOnce).to.equal(true); expect(addBidResponseStub.firstCall.args[0]).to.equal('mock/placement'); diff --git a/test/spec/unit/core/targeting_spec.js b/test/spec/unit/core/targeting_spec.js index 13ebfd7dc4e..b165a2a21fb 100644 --- a/test/spec/unit/core/targeting_spec.js +++ b/test/spec/unit/core/targeting_spec.js @@ -1,5 +1,5 @@ import { expect } from 'chai'; -import { targeting as targetingInstance, filters } from 'src/targeting'; +import { targeting as targetingInstance, filters, sortByDealAndPriceBucket } from 'src/targeting'; import { config } from 'src/config'; import { getAdUnits, createBidReceived } from 'test/fixtures/fixtures'; import CONSTANTS from 'src/constants.json'; @@ -32,6 +32,7 @@ const bid1 = { [CONSTANTS.TARGETING_KEYS.PRICE_BUCKET]: '0.53', [CONSTANTS.TARGETING_KEYS.DEAL]: '1234' }, + 'dealId': '1234', 'netRevenue': true, 'currency': 'USD', 'ttl': 300 @@ -97,6 +98,131 @@ const bid3 = { 'ttl': 300 }; +const nativeBid1 = { + 'bidderCode': 'appnexus', + 'width': 0, + 'height': 0, + 'statusMessage': 'Bid available', + 'adId': '591e7c9354b633', + 'requestId': '24aae81e32d6f6', + 'mediaType': 'native', + 'source': 'client', + 'cpm': 10, + 'creativeId': 97494403, + 'currency': 'USD', + 'netRevenue': true, + 'ttl': 300, + 'adUnitCode': '/19968336/prebid_native_example_1', + 'appnexus': { + 'buyerMemberId': 9325 + }, + 'meta': { + 'advertiserId': 2529885 + }, + 'native': { + 'title': 'This is a Prebid Native Creative', + 'body': 'This is a Prebid Native Creative. There are many like it, but this one is mine.', + 'sponsoredBy': 'Prebid.org', + 'clickUrl': 'http://prebid.org/dev-docs/show-native-ads.html', + 'clickTrackers': ['http://www.clickUrl.com/404'], + 'impressionTrackers': ['http://imp.trackerUrl.com/it1'], + 'javascriptTrackers': '', + 'image': { + 'url': 'http://vcdn.adnxs.com/p/creative-image/94/22/cd/0f/9422cd0f-f400-45d3-80f5-2b92629d9257.jpg', + 'height': 2250, + 'width': 3000 + }, + 'icon': { + 'url': 'http://vcdn.adnxs.com/p/creative-image/bd/59/a6/c6/bd59a6c6-0851-411d-a16d-031475a51312.png', + 'height': 83, + 'width': 127 + } + }, + 'auctionId': '72138a4a-b747-4192-9192-dcc41d675de8', + 'responseTimestamp': 1565785219461, + 'requestTimestamp': 1565785219405, + 'bidder': 'appnexus', + 'timeToRespond': 56, + 'pbLg': '5.00', + 'pbMg': '10.00', + 'pbHg': '10.00', + 'pbAg': '10.00', + 'pbDg': '10.00', + 'pbCg': '', + 'size': '0x0', + 'adserverTargeting': { + [CONSTANTS.TARGETING_KEYS.BIDDER]: 'appnexus', + [CONSTANTS.TARGETING_KEYS.AD_ID]: '591e7c9354b633', + [CONSTANTS.TARGETING_KEYS.PRICE_BUCKET]: '10.00', + [CONSTANTS.TARGETING_KEYS.SIZE]: '0x0', + [CONSTANTS.TARGETING_KEYS.SOURCE]: 'client', + [CONSTANTS.TARGETING_KEYS.FORMAT]: 'native', + [CONSTANTS.NATIVE_KEYS.title]: 'This is a Prebid Native Creative', + [CONSTANTS.NATIVE_KEYS.body]: 'This is a Prebid Native Creative. There are many like it, but this one is mine.', + [CONSTANTS.NATIVE_KEYS.sponsoredBy]: 'Prebid.org', + [CONSTANTS.NATIVE_KEYS.clickUrl]: 'http://prebid.org/dev-docs/show-native-ads.html', + [CONSTANTS.NATIVE_KEYS.image]: 'http://vcdn.adnxs.com/p/creative-image/94/22/cd/0f/9422cd0f-f400-45d3-80f5-2b92629d9257.jpg', + [CONSTANTS.NATIVE_KEYS.icon]: 'http://vcdn.adnxs.com/p/creative-image/bd/59/a6/c6/bd59a6c6-0851-411d-a16d-031475a51312.png' + } +}; +const nativeBid2 = { + 'bidderCode': 'dgads', + 'width': 0, + 'height': 0, + 'statusMessage': 'Bid available', + 'adId': '6e0aba55ed54e5', + 'requestId': '4de26ec83d9661', + 'mediaType': 'native', + 'source': 'client', + 'cpm': 1.90909091, + 'creativeId': 'xuidx6c901261b0x2b2', + 'currency': 'JPY', + 'netRevenue': true, + 'ttl': 60, + 'referrer': 'http://test.localhost:9999/integrationExamples/gpt/demo_native.html?pbjs_debug=true', + 'native': { + 'image': { + 'url': 'https://ads-tr.bigmining.com/img/300x250.png', + 'width': 300, + 'height': 250 + }, + 'title': 'Test Title', + 'body': 'Test Description', + 'sponsoredBy': 'test.com', + 'clickUrl': 'http://prebid.org/', + 'clickTrackers': ['https://www.clickUrl.com/404'], + 'impressionTrackers': [ + 'http://imp.trackerUrl.com/it2' + ] + }, + 'auctionId': '72138a4a-b747-4192-9192-dcc41d675de8', + 'responseTimestamp': 1565785219607, + 'requestTimestamp': 1565785219409, + 'bidder': 'dgads', + 'adUnitCode': '/19968336/prebid_native_example_1', + 'timeToRespond': 198, + 'pbLg': '1.50', + 'pbMg': '1.90', + 'pbHg': '1.90', + 'pbAg': '1.90', + 'pbDg': '1.90', + 'pbCg': '', + 'size': '0x0', + 'adserverTargeting': { + [CONSTANTS.TARGETING_KEYS.BIDDER]: 'dgads', + [CONSTANTS.TARGETING_KEYS.AD_ID]: '6e0aba55ed54e5', + [CONSTANTS.TARGETING_KEYS.PRICE_BUCKET]: '1.90', + [CONSTANTS.TARGETING_KEYS.SIZE]: '0x0', + [CONSTANTS.TARGETING_KEYS.SOURCE]: 'client', + [CONSTANTS.TARGETING_KEYS.FORMAT]: 'native', + [CONSTANTS.NATIVE_KEYS.image]: 'https://ads-tr.bigmining.com/img/300x250.png', + [CONSTANTS.NATIVE_KEYS.title]: 'Test Title', + [CONSTANTS.NATIVE_KEYS.body]: 'Test Description', + [CONSTANTS.NATIVE_KEYS.sponsoredBy]: 'test.com', + [CONSTANTS.NATIVE_KEYS.clickUrl]: 'http://prebid.org/' + } +}; + describe('targeting tests', function () { let sandbox; let enableSendAllBids = false; @@ -106,7 +232,6 @@ describe('targeting tests', function () { sandbox = sinon.sandbox.create(); useBidCache = true; - // enableSendAllBids = false; let origGetConfig = config.getConfig; sandbox.stub(config, 'getConfig').callsFake(function (key) { @@ -128,6 +253,8 @@ describe('targeting tests', function () { let amBidsReceivedStub; let amGetAdUnitsStub; let bidExpiryStub; + let logWarnStub; + let logErrorStub; let bidsReceived; beforeEach(function () { @@ -140,6 +267,17 @@ describe('targeting tests', function () { return ['/123456/header-bid-tag-0']; }); bidExpiryStub = sandbox.stub(filters, 'isBidNotExpired').returns(true); + logWarnStub = sinon.stub(utils, 'logWarn'); + logErrorStub = sinon.stub(utils, 'logError'); + }); + + afterEach(function() { + config.resetConfig(); + logWarnStub.restore(); + logErrorStub.restore(); + amBidsReceivedStub.restore(); + amGetAdUnitsStub.restore(); + bidExpiryStub.restore(); }); describe('when hb_deal is present in bid.adserverTargeting', function () { @@ -165,6 +303,155 @@ describe('targeting tests', function () { }); }); + it('will enforce a limit on the number of auction keys when auctionKeyMaxChars setting is active', function () { + config.setConfig({ + targetingControls: { + auctionKeyMaxChars: 150 + } + }); + + const targeting = targetingInstance.getAllTargeting(['/123456/header-bid-tag-0', '/123456/header-bid-tag-1']); + expect(targeting['/123456/header-bid-tag-1']).to.deep.equal({}); + expect(targeting['/123456/header-bid-tag-0']).to.contain.keys('hb_pb', 'hb_adid', 'hb_bidder', 'hb_deal'); + expect(targeting['/123456/header-bid-tag-0']['hb_adid']).to.equal(bid1.adId); + expect(logWarnStub.calledOnce).to.be.true; + }); + + it('will return an error when auctionKeyMaxChars setting is set too low for any auction keys to be allowed', function () { + config.setConfig({ + targetingControls: { + auctionKeyMaxChars: 50 + } + }); + + const targeting = targetingInstance.getAllTargeting(['/123456/header-bid-tag-0', '/123456/header-bid-tag-1']); + expect(targeting['/123456/header-bid-tag-1']).to.deep.equal({}); + expect(targeting['/123456/header-bid-tag-0']).to.deep.equal({}); + expect(logWarnStub.calledTwice).to.be.true; + expect(logErrorStub.calledOnce).to.be.true; + }); + + describe('targetingControls.alwaysIncludeDeals', function () { + let bid4; + + beforeEach(function() { + bid4 = utils.deepClone(bid1); + bid4.adserverTargeting = { + hb_deal: '4321', + hb_pb: '0.1', + hb_adid: '567891011', + hb_bidder: 'appnexus', + }; + bid4.bidder = bid4.bidderCode = 'appnexus'; + bid4.cpm = 0.1; // losing bid so not included if enableSendAllBids === false + bid4.dealId = '4321'; + enableSendAllBids = false; + + bidsReceived.push(bid4); + }); + + it('does not include losing deals when alwaysIncludeDeals not set', function () { + const targeting = targetingInstance.getAllTargeting(['/123456/header-bid-tag-0']); + + // Rubicon wins bid and has deal, but alwaysIncludeDeals is false, so only top bid plus deal_id + // appnexus does not get sent since alwaysIncludeDeals is not defined + expect(targeting['/123456/header-bid-tag-0']).to.deep.equal({ + 'hb_deal_rubicon': '1234', + 'hb_deal': '1234', + 'hb_pb': '0.53', + 'hb_adid': '148018fe5e', + 'hb_bidder': 'rubicon', + 'foobar': '300x250' + }); + }); + + it('does not include losing deals when alwaysIncludeDeals set to false', function () { + config.setConfig({ + targetingControls: { + alwaysIncludeDeals: false + } + }); + + const targeting = targetingInstance.getAllTargeting(['/123456/header-bid-tag-0']); + + // Rubicon wins bid and has deal, but alwaysIncludeDeals is false, so only top bid plus deal_id + // appnexus does not get sent since alwaysIncludeDeals is false + expect(targeting['/123456/header-bid-tag-0']).to.deep.equal({ + 'hb_deal_rubicon': '1234', // This is just how it works before this PR, always added no matter what for winner if they have deal + 'hb_deal': '1234', + 'hb_pb': '0.53', + 'hb_adid': '148018fe5e', + 'hb_bidder': 'rubicon', + 'foobar': '300x250' + }); + }); + + it('includes losing deals when alwaysIncludeDeals set to true and also winning deals bidder KVPs', function () { + config.setConfig({ + targetingControls: { + alwaysIncludeDeals: true + } + }); + const targeting = targetingInstance.getAllTargeting(['/123456/header-bid-tag-0']); + + // Rubicon wins bid and has a deal, so all KVPs for them are passed (top plus bidder specific) + // Appnexus had deal so passed through + expect(targeting['/123456/header-bid-tag-0']).to.deep.equal({ + 'hb_deal_rubicon': '1234', + 'hb_deal': '1234', + 'hb_pb': '0.53', + 'hb_adid': '148018fe5e', + 'hb_bidder': 'rubicon', + 'foobar': '300x250', + 'hb_pb_rubicon': '0.53', + 'hb_adid_rubicon': '148018fe5e', + 'hb_bidder_rubicon': 'rubicon', + 'hb_deal_appnexus': '4321', + 'hb_pb_appnexus': '0.1', + 'hb_adid_appnexus': '567891011', + 'hb_bidder_appnexus': 'appnexus' + }); + }); + + it('includes winning bid even when it is not a deal, plus other deal KVPs', function () { + config.setConfig({ + targetingControls: { + alwaysIncludeDeals: true + } + }); + let bid5 = utils.deepClone(bid4); + bid5.adserverTargeting = { + hb_pb: '3.0', + hb_adid: '111111', + hb_bidder: 'pubmatic', + }; + bid5.bidder = bid5.bidderCode = 'pubmatic'; + bid5.cpm = 3.0; // winning bid! + delete bid5.dealId; // no deal with winner + bidsReceived.push(bid5); + + const targeting = targetingInstance.getAllTargeting(['/123456/header-bid-tag-0']); + + // Pubmatic wins but no deal. So only top bid KVPs for them is sent + // Rubicon has a dealId so passed through + // Appnexus has a dealId so passed through + expect(targeting['/123456/header-bid-tag-0']).to.deep.equal({ + 'hb_bidder': 'pubmatic', + 'hb_adid': '111111', + 'hb_pb': '3.0', + 'foobar': '300x250', + 'hb_deal_rubicon': '1234', + 'hb_pb_rubicon': '0.53', + 'hb_adid_rubicon': '148018fe5e', + 'hb_bidder_rubicon': 'rubicon', + 'hb_deal_appnexus': '4321', + 'hb_pb_appnexus': '0.1', + 'hb_adid_appnexus': '567891011', + 'hb_bidder_appnexus': 'appnexus' + }); + }); + }); + it('selects the top bid when enableSendAllBids true', function () { enableSendAllBids = true; let targeting = targetingInstance.getAllTargeting(['/123456/header-bid-tag-0']); @@ -180,6 +467,27 @@ describe('targeting tests', function () { expect(targeting['/123456/header-bid-tag-0'][CONSTANTS.TARGETING_KEYS.PRICE_BUCKET + '_rubicon']).to.deep.equal(targeting['/123456/header-bid-tag-0'][CONSTANTS.TARGETING_KEYS.PRICE_BUCKET]); }); + it('ensures keys are properly generated when enableSendAllBids is true and multiple bidders use native', function() { + const nativeAdUnitCode = '/19968336/prebid_native_example_1'; + enableSendAllBids = true; + + // update mocks for this test to return native bids + amBidsReceivedStub.callsFake(function() { + return [nativeBid1, nativeBid2]; + }); + amGetAdUnitsStub.callsFake(function() { + return [nativeAdUnitCode]; + }); + + let targeting = targetingInstance.getAllTargeting([nativeAdUnitCode]); + expect(targeting[nativeAdUnitCode].hb_native_image).to.equal(nativeBid1.native.image.url); + expect(targeting[nativeAdUnitCode].hb_native_linkurl).to.equal(nativeBid1.native.clickUrl); + expect(targeting[nativeAdUnitCode].hb_native_title).to.equal(nativeBid1.native.title); + expect(targeting[nativeAdUnitCode].hb_native_image_dgad).to.exist.and.to.equal(nativeBid2.native.image.url); + expect(targeting[nativeAdUnitCode].hb_pb_dgads).to.exist.and.to.equal(nativeBid2.pbMg); + expect(targeting[nativeAdUnitCode].hb_native_body_appne).to.exist.and.to.equal(nativeBid1.native.body); + }); + it('does not include adpod type bids in the getBidsReceived results', function () { let adpodBid = utils.deepClone(bid1); adpodBid.video = { context: 'adpod', durationSeconds: 15, durationBucket: 15 }; @@ -326,4 +634,164 @@ describe('targeting tests', function () { }); }); }); + + describe('sortByDealAndPriceBucket', function() { + it('will properly sort bids when some bids have deals and some do not', function () { + let bids = [{ + adUnitTargeting: { + hb_adid: 'abc', + hb_pb: '1.00', + hb_deal: '1234' + } + }, { + adUnitTargeting: { + hb_adid: 'def', + hb_pb: '0.50', + } + }, { + adUnitTargeting: { + hb_adid: 'ghi', + hb_pb: '20.00', + hb_deal: '4532' + } + }, { + adUnitTargeting: { + hb_adid: 'jkl', + hb_pb: '9.00', + hb_deal: '9864' + } + }, { + adUnitTargeting: { + hb_adid: 'mno', + hb_pb: '50.00', + } + }, { + adUnitTargeting: { + hb_adid: 'pqr', + hb_pb: '100.00', + } + }]; + bids.sort(sortByDealAndPriceBucket); + expect(bids[0].adUnitTargeting.hb_adid).to.equal('ghi'); + expect(bids[1].adUnitTargeting.hb_adid).to.equal('jkl'); + expect(bids[2].adUnitTargeting.hb_adid).to.equal('abc'); + expect(bids[3].adUnitTargeting.hb_adid).to.equal('pqr'); + expect(bids[4].adUnitTargeting.hb_adid).to.equal('mno'); + expect(bids[5].adUnitTargeting.hb_adid).to.equal('def'); + }); + + it('will properly sort bids when all bids have deals', function () { + let bids = [{ + adUnitTargeting: { + hb_adid: 'abc', + hb_pb: '1.00', + hb_deal: '1234' + } + }, { + adUnitTargeting: { + hb_adid: 'def', + hb_pb: '0.50', + hb_deal: '4321' + } + }, { + adUnitTargeting: { + hb_adid: 'ghi', + hb_pb: '2.50', + hb_deal: '4532' + } + }, { + adUnitTargeting: { + hb_adid: 'jkl', + hb_pb: '2.00', + hb_deal: '9864' + } + }]; + bids.sort(sortByDealAndPriceBucket); + expect(bids[0].adUnitTargeting.hb_adid).to.equal('ghi'); + expect(bids[1].adUnitTargeting.hb_adid).to.equal('jkl'); + expect(bids[2].adUnitTargeting.hb_adid).to.equal('abc'); + expect(bids[3].adUnitTargeting.hb_adid).to.equal('def'); + }); + + it('will properly sort bids when no bids have deals', function () { + let bids = [{ + adUnitTargeting: { + hb_adid: 'abc', + hb_pb: '1.00' + } + }, { + adUnitTargeting: { + hb_adid: 'def', + hb_pb: '0.10' + } + }, { + adUnitTargeting: { + hb_adid: 'ghi', + hb_pb: '10.00' + } + }, { + adUnitTargeting: { + hb_adid: 'jkl', + hb_pb: '10.01' + } + }, { + adUnitTargeting: { + hb_adid: 'mno', + hb_pb: '1.00' + } + }, { + adUnitTargeting: { + hb_adid: 'pqr', + hb_pb: '100.00' + } + }]; + bids.sort(sortByDealAndPriceBucket); + expect(bids[0].adUnitTargeting.hb_adid).to.equal('pqr'); + expect(bids[1].adUnitTargeting.hb_adid).to.equal('jkl'); + expect(bids[2].adUnitTargeting.hb_adid).to.equal('ghi'); + expect(bids[3].adUnitTargeting.hb_adid).to.equal('abc'); + expect(bids[4].adUnitTargeting.hb_adid).to.equal('mno'); + expect(bids[5].adUnitTargeting.hb_adid).to.equal('def'); + }); + }); + + describe('setTargetingForAst', function () { + let sandbox, + apnTagStub; + beforeEach(function() { + sandbox = sinon.createSandbox(); + sandbox.stub(targetingInstance, 'resetPresetTargetingAST'); + apnTagStub = sandbox.stub(window.apntag, 'setKeywords'); + }); + afterEach(function () { + sandbox.restore(); + }); + + it('should set single addUnit code', function() { + let adUnitCode = 'testdiv-abc-ad-123456-0'; + sandbox.stub(targetingInstance, 'getAllTargeting').returns({ + 'testdiv1-abc-ad-123456-0': {hb_bidder: 'appnexus'} + }); + targetingInstance.setTargetingForAst(adUnitCode); + expect(targetingInstance.getAllTargeting.called).to.equal(true); + expect(targetingInstance.resetPresetTargetingAST.called).to.equal(true); + expect(apnTagStub.callCount).to.equal(1); + expect(apnTagStub.getCall(0).args[0]).to.deep.equal('testdiv1-abc-ad-123456-0'); + expect(apnTagStub.getCall(0).args[1]).to.deep.equal({HB_BIDDER: 'appnexus'}); + }); + + it('should set array of addUnit codes', function() { + let adUnitCodes = ['testdiv1-abc-ad-123456-0', 'testdiv2-abc-ad-123456-0'] + sandbox.stub(targetingInstance, 'getAllTargeting').returns({ + 'testdiv1-abc-ad-123456-0': {hb_bidder: 'appnexus'}, + 'testdiv2-abc-ad-123456-0': {hb_bidder: 'appnexus'} + }); + targetingInstance.setTargetingForAst(adUnitCodes); + expect(targetingInstance.getAllTargeting.called).to.equal(true); + expect(targetingInstance.resetPresetTargetingAST.called).to.equal(true); + expect(apnTagStub.callCount).to.equal(2); + expect(apnTagStub.getCall(1).args[0]).to.deep.equal('testdiv2-abc-ad-123456-0'); + expect(apnTagStub.getCall(1).args[1]).to.deep.equal({HB_BIDDER: 'appnexus'}); + }); + }); }); diff --git a/test/spec/unit/pbjs_api_spec.js b/test/spec/unit/pbjs_api_spec.js index b734faf9dd5..485dd5cf077 100644 --- a/test/spec/unit/pbjs_api_spec.js +++ b/test/spec/unit/pbjs_api_spec.js @@ -108,6 +108,7 @@ var createSlotArrayScenario2 = function createSlotArrayScenario2() { window.googletag = { _slots: [], + _targeting: {}, pubads: function () { var self = this; return { @@ -117,6 +118,18 @@ window.googletag = { setSlots: function (slots) { self._slots = slots; + }, + + setTargeting: function(key, arrayOfValues) { + self._targeting[key] = arrayOfValues; + }, + + getTargeting: function() { + return self._targeting; + }, + + clearTargeting: function() { + self._targeting = {}; } }; } @@ -434,7 +447,9 @@ describe('Unit: Prebid Module', function () { 'trackers': [{ 'impression_urls': ['http://lax1-ib.adnxs.com/impression'] }] - } + }, + 'viewability': { + 'config': ''} }] }] }; @@ -574,7 +589,9 @@ describe('Unit: Prebid Module', function () { 'trackers': [{ 'impression_urls': ['http://lax1-ib.adnxs.com/impression'] }] - } + }, + 'viewability': { + 'config': ''} }] }] }; @@ -606,7 +623,9 @@ describe('Unit: Prebid Module', function () { 'trackers': [{ 'impression_urls': ['http://lax1-ib.adnxs.com/impression'] }] - } + }, + 'viewability': { + 'config': ''} }] }] }; @@ -990,7 +1009,6 @@ describe('Unit: Prebid Module', function () { beforeEach(function () { doc = { - open: sinon.spy(), write: sinon.spy(), close: sinon.spy(), defaultView: { @@ -1041,7 +1059,6 @@ describe('Unit: Prebid Module', function () { }); adResponse.ad = ""; $$PREBID_GLOBAL$$.renderAd(doc, bidId); - assert.ok(doc.open, 'open method called'); assert.ok(doc.write.calledWith(adResponse.ad), 'ad was written to doc'); assert.ok(doc.close.called, 'close method called'); }); diff --git a/test/spec/userSync_spec.js b/test/spec/userSync_spec.js index dfe6372288f..f55fe13c528 100644 --- a/test/spec/userSync_spec.js +++ b/test/spec/userSync_spec.js @@ -98,15 +98,18 @@ describe('user sync', function () { expect(insertUserSyncIframeStub.getCall(0).args[0]).to.equal('http://example.com/iframe'); }); - it('should only trigger syncs once per page', function () { + it('should only trigger syncs once per page per bidder', function () { const userSync = newTestUserSync({pixelEnabled: true}); userSync.registerSync('image', 'testBidder', 'http://example.com/1'); userSync.syncUsers(); userSync.registerSync('image', 'testBidder', 'http://example.com/2'); + userSync.registerSync('image', 'testBidder2', 'http://example.com/3'); userSync.syncUsers(); + expect(triggerPixelStub.callCount).to.equal(2); expect(triggerPixelStub.getCall(0)).to.not.be.null; expect(triggerPixelStub.getCall(0).args[0]).to.exist.and.to.equal('http://example.com/1'); - expect(triggerPixelStub.getCall(1)).to.be.null; + expect(triggerPixelStub.getCall(1)).to.not.be.null; + expect(triggerPixelStub.getCall(1).args[0]).to.exist.and.to.equal('http://example.com/3'); }); it('should not fire syncs if cookies are not supported', function () { @@ -355,4 +358,105 @@ describe('user sync', function () { expect(triggerPixelStub.getCall(0).args[0]).to.exist.and.to.equal('http://example.com/1'); expect(insertUserSyncIframeStub.getCall(0)).to.be.null; }); + + describe('publicAPI', function () { + describe('canBidderRegisterSync', function() { + describe('with filterSettings', function() { + it('should return false if filter settings does not allow it', function () { + const userSync = newUserSync({ + config: { + filterSettings: { + image: { + bidders: '*', + filter: 'include' + }, + iframe: { + bidders: ['testBidder'], + filter: 'include' + } + } + } + }); + expect(userSync.canBidderRegisterSync('iframe', 'otherTestBidder')).to.equal(false); + }); + it('should return true if filter settings does allow it', function () { + const userSync = newUserSync({ + config: { + filterSettings: { + image: { + bidders: '*', + filter: 'include' + }, + iframe: { + bidders: ['testBidder'], + filter: 'include' + } + } + } + }); + expect(userSync.canBidderRegisterSync('iframe', 'testBidder')).to.equal(true); + }); + }); + describe('almost deprecated - without filterSettings', function() { + describe('enabledBidders contains testBidder', function() { + it('should return false if type is iframe and iframeEnabled is false', function () { + const userSync = newUserSync({ + config: { + pixelEnabled: true, + iframeEnabled: false, + enabledBidders: ['testBidder'], + } + }); + expect(userSync.canBidderRegisterSync('iframe', 'testBidder')).to.equal(false); + }); + + it('should return true if type is iframe and iframeEnabled is true', function () { + const userSync = newUserSync({ + config: { + pixelEnabled: true, + iframeEnabled: true, + enabledBidders: ['testBidder'], + } + }); + expect(userSync.canBidderRegisterSync('iframe', 'testBidder')).to.equal(true); + }); + + it('should return false if type is image and pixelEnabled is false', function () { + const userSync = newUserSync({ + config: { + pixelEnabled: false, + iframeEnabled: true, + enabledBidders: ['testBidder'], + } + }); + expect(userSync.canBidderRegisterSync('image', 'testBidder')).to.equal(false); + }); + + it('should return true if type is image and pixelEnabled is true', function () { + const userSync = newUserSync({ + config: { + pixelEnabled: true, + iframeEnabled: true, + enabledBidders: ['testBidder'], + } + }); + expect(userSync.canBidderRegisterSync('image', 'testBidder')).to.equal(true); + }); + }); + + describe('enabledBidders does not container testBidder', function() { + it('should return false since testBidder is not in enabledBidders', function() { + const userSync = newUserSync({ + config: { + pixelEnabled: true, + iframeEnabled: true, + enabledBidders: ['otherTestBidder'], + } + }); + expect(userSync.canBidderRegisterSync('iframe', 'testBidder')).to.equal(false); + }); + }); + }); + }); + }); }); diff --git a/test/spec/utils_spec.js b/test/spec/utils_spec.js index df1c9b66b28..5bee79d39c2 100755 --- a/test/spec/utils_spec.js +++ b/test/spec/utils_spec.js @@ -232,6 +232,56 @@ describe('Utils', function () { }); }); + describe('parseGPTSingleSizeArrayToRtbSize', function () { + it('should return size string with input single size array', function () { + var size = [300, 250]; + var output = utils.parseGPTSingleSizeArrayToRtbSize(size); + assert.deepEqual(output, {w: 300, h: 250}); + }); + + it('should return size string with input single size array', function () { + var size = ['300', '250']; + var output = utils.parseGPTSingleSizeArrayToRtbSize(size); + assert.deepEqual(output, {w: 300, h: 250}); + }); + + it('return undefined using string input', function () { + var size = '1'; + var output = utils.parseGPTSingleSizeArrayToRtbSize(size); + assert.equal(output, undefined); + }); + + it('return undefined using number input', function () { + var size = 1; + var output = utils.parseGPTSingleSizeArrayToRtbSize(size); + assert.equal(output, undefined); + }); + + it('return undefined using one length single array', function () { + var size = [300]; + var output = utils.parseGPTSingleSizeArrayToRtbSize(size); + assert.equal(output, undefined); + }); + + it('return undefined if the input is empty', function () { + var size = ''; + var output = utils.parseGPTSingleSizeArrayToRtbSize(size); + assert.equal(output, undefined); + }); + + it('return undefined if the input is not a number', function () { + var size = ['foo', 'bar']; + var output = utils.parseGPTSingleSizeArrayToRtbSize(size); + assert.equal(output, undefined); + }); + + it('return undefined if the input is not a number 2', function () { + var size = [300, 'foo']; + var output = utils.parseGPTSingleSizeArrayToRtbSize(size); + assert.equal(output, undefined); + }); + }); + describe('isA', function () { it('should return true with string object', function () { var output = utils.isA(obj_string, type_string); @@ -611,7 +661,7 @@ describe('Utils', function () { var value2 = utils.deepAccess(obj, 'test.first'); assert.equal(value2, 11); - var value3 = utils.deepAccess(obj, 1); + var value3 = utils.deepAccess(obj, '1'); assert.equal(value3, 2); }); @@ -626,6 +676,29 @@ describe('Utils', function () { }); }); + describe('deepSetValue', function() { + it('should set existing properties at various depths', function() { + const testObj = { + prop: 'value', + nestedObj: { + nestedProp: 'nestedValue' + } + }; + utils.deepSetValue(testObj, 'prop', 'newValue'); + assert.equal(testObj.prop, 'newValue'); + utils.deepSetValue(testObj, 'nestedObj.nestedProp', 'newNestedValue'); + assert.equal(testObj.nestedObj.nestedProp, 'newNestedValue'); + }); + + it('should create object levels between top and bottom of given path if they do not exist', function() { + const testObj = {}; + utils.deepSetValue(testObj, 'level1.level2', 'value'); + assert.notEqual(testObj.level1, undefined); + assert.notEqual(testObj.level1.level2, undefined); + assert.equal(testObj.level1.level2, 'value'); + }); + }); + describe('createContentToExecuteExtScriptInFriendlyFrame', function () { it('should return empty string if url is not passed', function () { var output = utils.createContentToExecuteExtScriptInFriendlyFrame(); diff --git a/wdio.conf.js b/wdio.conf.js new file mode 100644 index 00000000000..9e816bef24b --- /dev/null +++ b/wdio.conf.js @@ -0,0 +1,55 @@ +const browsers = require('./browsers.json'); + +function getCapabilities() { + function getPlatform(os) { + const platformMap = { + 'Windows': 'WINDOWS', + 'OS X': 'MAC', + } + return platformMap[os]; + } + + // remove the IE11 browser from functional tests + delete browsers['bs_ie_11_windows_10']; + + let capabilities = [] + Object.keys(browsers).forEach(key => { + let browser = browsers[key]; + capabilities.push({ + browserName: browser.browser, + platform: getPlatform(browser.os), + version: browser.browser_version, + acceptSslCerts: true, + 'browserstack.networkLogs': true, + 'browserstack.console': 'verbose', + build: 'Prebidjs E2E ' + new Date().toLocaleString() + }); + }); + return capabilities; +} + +exports.config = { + specs: [ + './test/spec/e2e/**/*.spec.js' + ], + services: ['browserstack'], + user: process.env.BROWSERSTACK_USERNAME, + key: process.env.BROWSERSTACK_ACCESS_KEY, + browserstackLocal: true, + // Do not increase this, since we have only 5 parallel tests in browserstack account + maxInstances: 5, + capabilities: getCapabilities(), + logLevel: 'silent', // Level of logging verbosity: silent | verbose | command | data | result | error + coloredLogs: true, + waitforTimeout: 60000, // Default timeout for all waitFor* commands. + connectionRetryTimeout: 60000, // Default timeout in milliseconds for request if Selenium Grid doesn't send response + connectionRetryCount: 3, // Default request retries count + framework: 'mocha', + mochaOpts: { + ui: 'bdd', + timeout: 60000, + compilers: ['js:babel-register'], + }, + // if you see error, update this to spec reporter and logLevel above to get detailed report. + reporters: ['concise'] +}; diff --git a/webpack.conf.js b/webpack.conf.js index 9518b972b1b..a5c75fa8a1a 100644 --- a/webpack.conf.js +++ b/webpack.conf.js @@ -3,12 +3,43 @@ var path = require('path'); var webpack = require('webpack'); var helpers = require('./gulpHelpers'); var RequireEnsureWithoutJsonp = require('./plugins/RequireEnsureWithoutJsonp.js'); +var { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer'); +var argv = require('yargs').argv; +var allowedModules = require('./allowedModules'); // list of module names to never include in the common bundle chunk var neverBundle = [ 'AnalyticsAdapter.js' ]; +var plugins = [ + new RequireEnsureWithoutJsonp() +]; + +if (argv.analyze) { + plugins.push( + new BundleAnalyzerPlugin() + ) +} + +plugins.push( // this plugin must be last so it can be easily removed for karma unit tests + new webpack.optimize.CommonsChunkPlugin({ + name: 'prebid', + filename: 'prebid-core.js', + minChunks: function(module) { + return ( + ( + module.context && module.context.startsWith(path.resolve('./src')) && + !(module.resource && neverBundle.some(name => module.resource.includes(name))) + ) || + module.resource && (allowedModules.src.concat(['core-js'])).some( + name => module.resource.includes(path.resolve('./node_modules/' + name)) + ) + ); + } + }) +); + module.exports = { devtool: 'source-map', resolve: { @@ -43,16 +74,5 @@ module.exports = { } ] }, - plugins: [ - new RequireEnsureWithoutJsonp(), - - // this plugin must be last so it can be easily removed for karma unit tests - new webpack.optimize.CommonsChunkPlugin({ - name: 'prebid', - filename: 'prebid-core.js', - minChunks: function(module, count) { - return !(count < 2 || neverBundle.indexOf(path.basename(module.resource)) !== -1) - } - }) - ] + plugins };