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

Kargo Adapter for Prebid 1.0 #1729

Merged
merged 1 commit into from
Oct 26, 2017
Merged

Kargo Adapter for Prebid 1.0 #1729

merged 1 commit into from
Oct 26, 2017

Conversation

samuelhorwitz
Copy link
Contributor

@samuelhorwitz samuelhorwitz commented Oct 19, 2017

Description of change

Kargo Adapter migrated to Prebid 1.0

Notes

As a side note, I would like some clarification on currency support. Does the publisher always specify conversion rates? We have multiple currency support being added into our server-side code and I would like to know the best way to configure things so that our rates our used when the pub specifies a compatible non-USD currency. We will be returning our CPMs in the currency the publisher specifies already converted on our end. I'm unsure however of how I should implement this in the adapter. Thank you!

@dbemiller
Copy link
Contributor

hey @samuelhorwitz, is there any reason you made this PR against the prebid-1.0 branch? Since you're using the bidderFactory, you should be able to update in master directly.

This helps us with branch maintenance, because otherwise all the patches & bugfixes to your adapter between now and the 1.0 release will become merge conflicts.

Currency

It looks like you're doing the right thing to me. Import the config, read the currency from it in buildRequests, and respond with the bid's currency when you interpretResponse.

@snapwich may want to overrule me here, as he's more familiar with the module... but your code here looks like it should work to me.

@samuelhorwitz
Copy link
Contributor Author

I can change the base of this PR, but should I actually rebase my branch off of master? If I change the base without rebasing, this PR will become much more complicated to review, but if I rebase from master I will be working off of a branch that doesn't include any of the 1.0 updates

@dbemiller
Copy link
Contributor

You should create a branch from master, and open a PR against master.

The 1.0 branch doesn't change any adapter-facing APIs in the bidderFactory... and in fact breaking changes to bidderFactory are aimed at master too (see #1748), so if anything prebid-1.0 will be farther out of date.

currency in the config exists in master too... so I don't think your code should change very much (if at all) between the two.

const HOST = 'https://krk.kargo.com';
export const spec = {
code: BIDDER_CODE,
aliases: [],
Copy link
Contributor

Choose a reason for hiding this comment

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

No need to define this if it's an empty array.... you can just leave it out.

if (adUnit.receivedTracker) {
let el = document.createElement('img');
el.src = adUnit.receivedTracker;
document.body.appendChild(el);
Copy link
Contributor

@dbemiller dbemiller Oct 23, 2017

Choose a reason for hiding this comment

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

sync pixels need to be added using the userSync module

You can also implement getUserSyncs, in which case the bidderFactory will put them in the userSync module for you. This would probably be easier for you to test.

Either way, prebid-core will attach them to the page after the auction's over.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

When do user syncs fire? We can just leave this off if it's not an immediate thing... we use this tracker to log that an ad unit was received by the page but if it's not fired in a deterministically "soon" fashion then it's better we just leave it off.

Copy link
Contributor

Choose a reason for hiding this comment

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

Aha... ok. Not a user sync at all, then.

Yeah... there's no real good way to do that. Publishers get annoyed by libraries making extra requests because of the impact it has on page load times.

You could use the user sync module if you want... by default, we fire them 3 seconds after the auction has completed.

However, it still wouldn't be reliable. Since it affects the publishers' page performance, Prebid made this configurable... so they can limit the number that fire, opt out totally, etc.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah okay cool, I will remove it then

Copy link
Contributor

Choose a reason for hiding this comment

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

Sure thing.

If this is a feature you guys really need, I'd recommend opening an issue about it. I don't know how the Prebid.JS leadership feels about supporting this, but that's a good way to get discussion going with some more eyes on it.

Copy link
Contributor Author

@samuelhorwitz samuelhorwitz Oct 24, 2017

Choose a reason for hiding this comment

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

I've created a ticket here #1762 but it's not urgent for us to have this support and I've just removed the code

return bidResponses;
},

// PRIVATE
Copy link
Contributor

Choose a reason for hiding this comment

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

You can make these truly private if you pull them off the spec object, and just define them as helper functions in the top level of your file.

If they're not exported, they're safe.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For some reason I thought I mocked these more than I did in tests so I made them "private" as opposed to out of closure scope. I don't think I actually do, though. That being said, I don't really mind either way, I added that comment to visually separate the interface functionality from the behind the scenes functionality.

let adUnit = adUnits[adUnitId];
bidResponses.push({
requestId: bids[adUnitId].bidId,
bidderCode: spec.code,
Copy link
Contributor

Choose a reason for hiding this comment

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

Our docs are bad here, but... don't send back the bidderCode on bids. The bidderFactory adds it to you, and this won't work quite right if someone aliases your adapter (which can be done by customers at runtime)


_getCrbIds() {
try {
const crb = JSON.parse(decodeURIComponent(spec._readCookie('krg_crb')));
Copy link
Member

Choose a reason for hiding this comment

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

what's this cookie you are reading? How do you have access to it if you are in the pub domain?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

These are first party cookies our pubs are likely to already have on their page from our various other integrations.

Copy link
Member

Choose a reason for hiding this comment

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

ok that's what I thought. Thanks for clarifying.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No problem

@samuelhorwitz samuelhorwitz changed the base branch from prebid-1.0 to master October 24, 2017 15:03
@samuelhorwitz
Copy link
Contributor Author

So, I just modified this PR to be derived from master/pointing to master. However I will need to re-run some of my own tests to make sure all my changes still work.

@dbemiller
Copy link
Contributor

Sounds good, let me know when you're comfortable with it.

@samuelhorwitz
Copy link
Contributor Author

Okay everything seems good from our tests! Thank you

Copy link
Contributor

@dbemiller dbemiller left a comment

Choose a reason for hiding this comment

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

Looks good to me. I left a few non-essential suggestions I just noticed while testing things... but not a big deal.

```
var adUnits = [{
code: 'div-gpt-ad-1460505748561-1',
sizes: [[300,250][1,1]],
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like you're missing a comma here.

**Module Type**: Bidder Adapter
**Maintainer**: [email protected]

# Description
Copy link
Contributor

Choose a reason for hiding this comment

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

You might want to mention something about how this only works on mobile.

I tried this and thought I wasn't getting a bid back... but I put my browser in mobile mode and then it worked. Didn't realize that was a dependency. Others may run into the same problem.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I updated this as well but its below the line commented on so Github didnt dismiss it

@dbemiller
Copy link
Contributor

agh... sorry about this, but one more change, because #1742 got merged before we could get this in.

The first argument to interpretResponse now looks like this:

{
  body: responseBody,
  headers: {
    get: function(header) { /* returns a header from the HTTP response */ }
  }
}

You'll have to update the spec so that it looks through that object as well now.

@samuelhorwitz
Copy link
Contributor Author

Alright, done!

@samuelhorwitz
Copy link
Contributor Author

Hey, sorry about this but now I have one last thing I need to add also! It should be a very quick/small change to what we send to our bidder.

@dbemiller
Copy link
Contributor

no worries... do what you've gotta do ^^

@samuelhorwitz
Copy link
Contributor Author

Alright finished again!

@dbemiller dbemiller merged commit ebaec7a into prebid:master Oct 26, 2017
Millerrok pushed a commit to Vertamedia/Prebid.js that referenced this pull request Oct 31, 2017
* 'master' of https://github.com/prebid/Prebid.js: (22 commits)
  Update GetIntent adapter to 1.0 version (prebid#1721)
  Add `usePaymentRule` param to AN bidders (prebid#1778)
  New hooks API (replaces monkey-patching for currency) (prebid#1683)
  Change prebidServer to call client user syncs if they exist (prebid#1734)
  Fix Centro adapter to allow requests of the same units (prebid#1746)
  add vastUrl + media type for video bids Prebid Server (prebid#1739)
  Update adxcg adapter for prebid 1.0 (prebid#1741)
  Update yieldmoBid adapter request url (prebid#1771)
  Upgrade Quantcast adapter for Prebid 1.0 (prebid#1753)
  Fidelity Media Adapter update. Prebid v1.0 (prebid#1719)
  Kargo Adapter for Prebid 1.0 (prebid#1729)
  updated for prebid 1.0 api (prebid#1722)
  Add AdOcean adapter (prebid#1735)
  Update Conversant adapter to Prebid 1.0 (prebid#1711)
  Fix test-coverage bug (prebid#1765)
  Migrating TrustX adapter to 1.0 (prebid#1709)
  Update Improve Digital adapter for Prebid 1.0 (prebid#1728)
  Fixed the argument type on getUserSyncs. (prebid#1767)
  nanointeractive bid adapter (prebid#1627)
  Validating bid response params (prebid#1738)
  ...
mattpr pushed a commit to mattpr/Prebid.js that referenced this pull request Oct 31, 2017
outoftime pushed a commit to Genius/Prebid.js that referenced this pull request Nov 13, 2017
* tag '0.32.0' of https://github.com/prebid/Prebid.js: (44 commits)
  Prebid 0.32.0 Release
  Commenting out tests that are failing in IE10 (prebid#1710)
  Update dfp.buildVideoUrl to accept adserver url (prebid#1663)
  Update rubicon adapter with new properties and 1.0 changes (prebid#1776)
  Added adUnitCode for compatibility (prebid#1781)
  Remove 'supported' from analytics adapter info (prebid#1780)
  Add TTL parameter to bid (prebid#1784)
  Update GetIntent adapter to 1.0 version (prebid#1721)
  Add `usePaymentRule` param to AN bidders (prebid#1778)
  New hooks API (replaces monkey-patching for currency) (prebid#1683)
  Change prebidServer to call client user syncs if they exist (prebid#1734)
  Fix Centro adapter to allow requests of the same units (prebid#1746)
  add vastUrl + media type for video bids Prebid Server (prebid#1739)
  Update adxcg adapter for prebid 1.0 (prebid#1741)
  Update yieldmoBid adapter request url (prebid#1771)
  Upgrade Quantcast adapter for Prebid 1.0 (prebid#1753)
  Fidelity Media Adapter update. Prebid v1.0 (prebid#1719)
  Kargo Adapter for Prebid 1.0 (prebid#1729)
  updated for prebid 1.0 api (prebid#1722)
  Add AdOcean adapter (prebid#1735)
  ...
dluxemburg pushed a commit to Genius/Prebid.js that referenced this pull request Jul 17, 2018
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.

5 participants