Skip to content

added new rubiconLite adapter#740

Merged
mkendall07 merged 3 commits intoprebid:masterfrom
rubicon-project:new-rubicon-adapter
Oct 27, 2016
Merged

added new rubiconLite adapter#740
mkendall07 merged 3 commits intoprebid:masterfrom
rubicon-project:new-rubicon-adapter

Conversation

@snapwich
Copy link
Collaborator

Type of change

  • New bidder adapter

Description of change

This is a lightweight Rubicon adapter that no longer includes the Fastlane library when participating in an auction. Due to the lack of Fastlane library, some APIs are unavailable (such as those on the rubicontag). For those who still require access to those APIs they can use the regular rubicon adapter; for those that don't need those APIs, there is now the option to use this rubiconLite adapter for a performance increase.

  • test parameters for validating bids
{
  bidder: 'rubiconLite',
  params: {
    // ... (same as regular Rubicon adapter)
  }
}

@mkendall07 mkendall07 self-assigned this Oct 24, 2016
@mkendall07
Copy link
Contributor

Looks like you have a unit test failure. Once it's addressed I'll review.

@snapwich snapwich force-pushed the new-rubicon-adapter branch from fb40fc1 to 8731f4e Compare October 24, 2016 20:31
@snapwich snapwich force-pushed the new-rubicon-adapter branch from 8731f4e to 6aa90a3 Compare October 24, 2016 20:39
@snapwich
Copy link
Collaborator Author

@mkendall07 should be good now. saucelabs didn't like my mocked window.screen so I just replaced that with a regexp check and it seems to be happy now.

Copy link
Contributor

@mkendall07 mkendall07 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@snapwich
Thanks for the PR. I've put some initial comments for you to review/address. I'll validate bids after updates. Thanks.

* @file Rubicon (RubiconLite) adapter
*/

var CONSTANTS = require('../constants.json');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We prefer now to use the ES6 import syntax. See https://github.com/prebid/Prebid.js/blob/master/src/adapters/appnexusAst.js for examples

var bidfactory = require('../bidfactory.js');
var ajax = require("../ajax.js").ajax;

function RubiconAdapter(mockResponse) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not clear why mockResponse is passed to the constructor function?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was my method of testing only the ajax callback in unit tests. It could be written in a way to expose the callback as an export. Do you have a preference?

}

//indicate that there is no bid for this placement
let badBid = bidfactory.createBid(2, bid);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use CONSTANTS.STATUS.NO_BID instead of 2.

}

let _renderCreative = (script, impId) =>
'<html>\n' +
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prefer ES6 template literals here.

}

//set the status
bidRequest.status = CONSTANTS.STATUS.GOOD;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this doesn't actually do anything. Please use CONSTANTS.STATUS.GOOD on line 174 instead.

'<\/body>\n' +
'<\/html>';

//expose the callback to the global object:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: this comment isn't really accurate.

@snapwich
Copy link
Collaborator Author

submitted updates

@mkendall07
Copy link
Contributor

Thanks @snapwich
Sorry to push the issue but what's the deal with mockResponse ? I'm not a fan of writing code for prod that is only for test. Maybe I'm missing something though.

@snapwich
Copy link
Collaborator Author

I can't think of any other methods to test the ajax callback in isolation without either passing in a testing dependency or exposing some private methods as exports, both of which require extra code within the module that is really only for testing. Do you have a preference?

@mkendall07
Copy link
Contributor

right that's because ES6 modules are read only which is a pain. To get around these, we used sinon.fakeServer to mock the response that the ajax function returns. Would this work? Example: https://github.com/prebid/Prebid.js/blob/master/test/spec/adapters/appnexusAst_spec.js#L163

@snapwich
Copy link
Collaborator Author

Unfortunately mocking the AJAX call is insufficient to test the callback in isolation since the only access is through callBids. Isolation is pretty important in this case I think due to the fact that we have a lot more response handling tests than request sending tests. Without isolation it requires the response handling tests to run the request handling code with each test which is both slow and prone to causing all response tests to fail from request bugs (which makes debugging difficult).

I recognize the way I have it now isn't even completely isolated since the test call is still made through callBids (although quickly directed to the callback). I think the ideal situation, and what I've done in the past, is to pass a testing flag using the Webpack DefinePlugin. This allows testing code to be present in the module if(TESTING) { which translates to if(true/false) { which uglify will then remove as dead code in production builds. I think in this case it would be easy to implement since you have a different execution path for testing vs production builds, would you like me to take a crack at it?

@mkendall07
Copy link
Contributor

@snapwich
I disagree with

mocking the AJAX call is insufficient to test the callback in isolation since the only access is through callBids.

We tend to subscribe to "test behaviors, not implementations" concept. If your in a situation where you find yourself having to test private methods, you are unit testing implementation vs public interface. Here's a link: https://teamgaslight.com/blog/testing-behavior-vs-testing-implementation

I'm not sure if writing conditionals into the code for test/prod is more desirable than the current way you are doing it.

What this means practically, is that you should be able to test what is needed by the public interface by mocking out dependencies as needed.

@snapwich
Copy link
Collaborator Author

We tend to subscribe to "test behaviors, not implementations" concept. If your in a situation where you find yourself having to test private methods, you are unit testing implementation vs public interface. Here's a link: https://teamgaslight.com/blog/testing-behavior-vs-testing-implementation

I agree with your statement and the article you've provided. Unfortunately AJAX has the side-effect of exposing an additional API which is public in the sense that an external resource has to communicate with our internal implementation. By "exposing" that hidden API in the way prescribed (fake server responses) it is requiring the unit tests to execute a lot of additional code that is not under test which has negative consequences for both testing performance and false-positives when not-under-test-code has bugs.

However, in interest of moving forward, I've made the recommendation here as suggested. I hope you'll consider allowing testing and debugging code paths in the future for builds as I have seen many positive benefits in the past.

@mkendall07
Copy link
Contributor

thanks for the update.
Regarding

allowing testing and debugging code paths in the future for builds

I'm hesitant to allow it because I think it can encourage bad behavior "it's OK because it's test code and thrown away anyway" type of attitude. Not that it cannot be done right. We'll always consider other's viewpoints on these things. Thanks for contributing.

@mkendall07 mkendall07 merged commit d145021 into prebid:master Oct 27, 2016
mp-12301 pushed a commit to aol/Prebid.js that referenced this pull request Apr 10, 2017
…ebid-0.14.0 to release/1.7.0

* commit '3eefcf043466f5457c81bfec18b032b53490b78b': (52 commits)
  New adapters ids.
  Prebid 0.14.0 Release
  add workaround to prevent IX adapter from ending auction earlier due to one request becoming many responses (prebid#763)
  Add pbjs.getHighestCpmBids for getting winning bids (prebid#755)
  Fix build
  Drop Sekindo adapter.
  Bugfix/suppress prebid request if sizeMapping undefined for device width (prebid#758)
  amp integration (prebid#756)
  Add contribution guidelines (prebid#761)
  Add api method to shuffle the order bidders are called in (prebid#760)
  build adapter from custom source path (prebid#753)
  reduce duplication and ignore ga.js in coverage (prebid#754)
  Log /ut response errors in dev console (prebid#747)
  Fix indentation (code style error when building) (prebid#751)
  Add package keywords (prebid#746)
  added new rubiconLite adapter (prebid#740)
  Show warning if bidCpmAdjustment is set for AOL bidder (closes prebid#725) (prebid#728)
  IX adapter code refactoring (prebid#711)
  Update memeglobal.js (prebid#737)
  Pulsepoint Analytics adapter for Prebid (prebid#706)
  ...
mp-12301 pushed a commit to aol/Prebid.js that referenced this pull request Apr 10, 2017
…7.0 to master

* commit '262f371a5c855419c3ef357fb1f0cf87a107749f': (52 commits)
  New adapters ids.
  Prebid 0.14.0 Release
  add workaround to prevent IX adapter from ending auction earlier due to one request becoming many responses (prebid#763)
  Add pbjs.getHighestCpmBids for getting winning bids (prebid#755)
  Fix build
  Drop Sekindo adapter.
  Bugfix/suppress prebid request if sizeMapping undefined for device width (prebid#758)
  amp integration (prebid#756)
  Add contribution guidelines (prebid#761)
  Add api method to shuffle the order bidders are called in (prebid#760)
  build adapter from custom source path (prebid#753)
  reduce duplication and ignore ga.js in coverage (prebid#754)
  Log /ut response errors in dev console (prebid#747)
  Fix indentation (code style error when building) (prebid#751)
  Add package keywords (prebid#746)
  added new rubiconLite adapter (prebid#740)
  Show warning if bidCpmAdjustment is set for AOL bidder (closes prebid#725) (prebid#728)
  IX adapter code refactoring (prebid#711)
  Update memeglobal.js (prebid#737)
  Pulsepoint Analytics adapter for Prebid (prebid#706)
  ...
@robertrmartinez robertrmartinez deleted the new-rubicon-adapter branch July 5, 2023 19:44
pm-abhinav-deshpande pushed a commit to pm-abhinav-deshpande/Prebid.js that referenced this pull request Apr 23, 2025
…ly_prebid_8_upgrade

Revert "Updated wiid with unique string instead of auction id"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Comments