Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

create adapter adyoulike #1155

Merged
merged 4 commits into from
Jun 5, 2017
Merged

create adapter adyoulike #1155

merged 4 commits into from
Jun 5, 2017

Conversation

jbAdyoulike
Copy link
Contributor

@jbAdyoulike jbAdyoulike commented Apr 25, 2017

Type of change

  • Bugfix
  • Feature
  • New bidder adapter
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Other

Description of change

  • test parameters for validating bids
{
  bidder: 'adyoulike',
  params: {
     placement: "194f787b85c829fb8822cdaf1ae64435",
  }
}

[email protected]

  • official adapter submission

Other information

const _VERSION = "0.1";

const baseAdapter = Adapter.createNew('adyoulike');
const bidRequests = {};
Copy link
Contributor

Choose a reason for hiding this comment

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

Keeping state out here will be buggy. What would happen if callBids gets called twice before your ajax request returns? For example, suppose a page makes more than one cal to requestBids.

You can make it safe if you use newResponseHandler(requests) as your ajax callback (where newResponseHandler(requests) returns the handleResponse function, with the requests stored in the closure scope)

@dbemiller
Copy link
Contributor

You'll also want to submit a documentation PR for the bidder params page.

@dbemiller
Copy link
Contributor

I'm seeing CORS errors when testing:

XMLHttpRequest cannot load http://hb-api.omnitagjs.com/hb-api/prebid?. Response to preflight request doesn't pass access control check: The value of the 'Access-Control-Allow-Origin' header in the response must not be the wildcard '*' when the request's credentials mode is 'include'. Origin 'http://test.localhost:9999' is therefore not allowed access. The credentials mode of requests initiated by the XMLHttpRequest is controlled by the withCredentials attribute.

My test page is below:

<html>
<head>
    <!-- Prebid Config Section START -->
    <!-- Make sure this is inserted before your GPT tag -->
    <script>
      var PREBID_TIMEOUT = 700;

      var adUnits = [{
        code: 'div-gpt-ad-1460505748561-0',
        sizes: [[300, 250], [300,600]],
        bids: [{
          bidder: 'adyoulike',
          params: {
            placement: "d135a2027b1041059f06fbf8cf4ddfef",
          }
        }]
      }];

      var pbjs = pbjs || {};
      pbjs.que = pbjs.que || [];

    </script>
    <!-- Prebid Config Section END -->

    <!-- Prebid Boilerplate Section START. No Need to Edit. -->
    <script type="text/javascript" src="../build/dev/prebid.js" async></script>
    <script>
      var googletag = googletag || {};
      googletag.cmd = googletag.cmd || [];
      googletag.cmd.push(function() {
        googletag.pubads().disableInitialLoad();
      });

      pbjs.que.push(function() {
        pbjs.addAdUnits(adUnits);
        pbjs.requestBids({
          bidsBackHandler: sendAdserverRequest
        });
      });

      function sendAdserverRequest() {
        if (pbjs.adserverRequestSent) return;
        pbjs.adserverRequestSent = true;
        googletag.cmd.push(function() {
          pbjs.que.push(function() {
            pbjs.setTargetingForGPTAsync();
            googletag.pubads().refresh();
          });
        });
      }

      setTimeout(function() {
        sendAdserverRequest();
      }, PREBID_TIMEOUT);

    </script>
    <!-- Prebid Boilerplate Section END -->

    <script>
      (function () {
        var gads = document.createElement('script');
        gads.async = true;
        gads.type = 'text/javascript';
        var useSSL = 'https:' == document.location.protocol;
        gads.src = (useSSL ? 'https:' : 'http:') +
          '//www.googletagservices.com/tag/js/gpt.js';
        var node = document.getElementsByTagName('script')[0];
        node.parentNode.insertBefore(gads, node);
      })();
    </script>

    <script>
      googletag.cmd.push(function () {
        googletag.defineSlot('/19968336/header-bid-tag-0', [[300, 250], [300, 600]], 'div-gpt-ad-1460505748561-0').addService(googletag.pubads());

        googletag.pubads().enableSingleRequest();
        googletag.enableServices();
      });
    </script>
</head>

<body>
<h2>Prebid.js Test</h2>
<h5>Div-1</h5>
<div id='div-gpt-ad-1460505748561-0'>
    <script type='text/javascript'>
      googletag.cmd.push(function() { googletag.display('div-gpt-ad-1460505748561-0'); });
    </script>
</div>
</body>
</html>

@jbAdyoulike
Copy link
Contributor Author

Could you use this placement ID for your test: 194f787b85c829fb8822cdaf1ae64435 ?

@dbemiller
Copy link
Contributor

dbemiller commented May 19, 2017

@jbAdyoulike please fix the linting errors. eslint --fix might help

@jbAdyoulike
Copy link
Contributor Author

@dbemiller done

@dbemiller
Copy link
Contributor

Am seeing errors using that placement Id:
screen shot 2017-05-19 at 3 53 11 pm

Request params:

      var adUnits = [{
        code: 'div-gpt-ad-1460505748561-0',
        sizes: [[300, 250], [300,600]],
        bids: [{
          bidder: 'adyoulike',
          params: {
            placement: "194f787b85c829fb8822cdaf1ae64435",
          }
        }]
      }];

@jbAdyoulike
Copy link
Contributor Author

@dbemiller Could you give me the request body and response body of this endpoint http://hb-api.omnitagjs.com/hb-api/prebid from the network console to let me investigate on my side ?

This error looks strange, Following what I have from my side :
cap-prebid

@dbemiller
Copy link
Contributor

screen shot 2017-05-22 at 9 43 25 am
screen shot 2017-05-22 at 9 43 40 am

@jbAdyoulike
Copy link
Contributor Author

@dbemiller Ok, It was a misconfiguration on my placement, it should works now.

try {
return window.top.document.referrer;
} catch (e) { }
return document.referrer;
Copy link
Contributor

@dbemiller dbemiller May 23, 2017

Choose a reason for hiding this comment

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

Generally, it's considered bad practice to use try/catch for control flow: https://softwareengineering.stackexchange.com/a/189225

This can be written linearly by testing for undefined (the same goes for getCanonicalUrl).


/* Get current page canonical url */
function getCanonicalUrl() {
if (utils.inIframes) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This is undefined... did you mean to call utils.inIframe() here?

@dbemiller
Copy link
Contributor

Needs just a few changes as far as I can tell... but I do want to complement you especially for writing such pretty code :). Super clear and easy to read.

@jbAdyoulike
Copy link
Contributor Author

@dbemiller It's a pleasure ;)

I have created the PR for the bidder params page prebid/prebid.github.io#252

@protonate protonate added this to the Prebid 0.25.0 milestone Jun 2, 2017
Copy link
Collaborator

@jaiminpanchal27 jaiminpanchal27 left a comment

Choose a reason for hiding this comment

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

LGTM

@jaiminpanchal27 jaiminpanchal27 merged commit 6b36d64 into prebid:master Jun 5, 2017
protonate pushed a commit that referenced this pull request Jun 7, 2017
* create adapter adyoulike

* move bidRequests in callBids scope

* update adyoulike.js and adyoulike_spec.js syntax

* refactor getReferrerUrl and getCanonicalUrl
@ayl-julien
Copy link

Hi @protonate what do we have to do to have our name updated on prebid.org?

@dbemiller
Copy link
Contributor

@ayl-julien @protonate is away for a little while, but submit a PR against this repo to change it.

dluxemburg pushed a commit to Genius/Prebid.js that referenced this pull request Jul 17, 2018
* create adapter adyoulike

* move bidRequests in callBids scope

* update adyoulike.js and adyoulike_spec.js syntax

* refactor getReferrerUrl and getCanonicalUrl
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants