Skip to content

Adding onTimeout function in Adapter Spec #2279

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

Merged
merged 12 commits into from
Apr 2, 2018

Conversation

vedantseta
Copy link
Contributor

@vedantseta vedantseta commented Mar 17, 2018

Type of change

  • Feature
  • Does this change affect user-facing APIs or examples documented on http://prebid.org?

Description of change

This adds a function onTimeout to bidder spec, letting bidders to subscribe to their own timeout.

Payload received to this function is same as bidTimeout event with timeout value and user configured params for this adunit and bidder combination.

However the payload contains timed out bids for subscribed bidder, unlike bidTimeout event data.

Example

export const spec = {
        code: BIDDER_CODE,
        aliases: ['ex'], // short code
        isBidRequestValid: function(bid) {
            return !!(bid.params.placementId || (bid.params.member && bid.params.invCode));
        },
        onTimeout: function(data) {
             // BIDDER SPEFIC CODE HERE

        },
}

Other information

This resolves #2254
Documentation PR : prebid.github.io/pull/678

@vedantseta vedantseta changed the title Feature/bidder timeout spec Allow bidders to subscribe to own timed out bid data Mar 17, 2018
@vedantseta vedantseta changed the title Allow bidders to subscribe to own timed out bid data Adding onTimeout function in Adapter Spec Mar 17, 2018
@matthewlane matthewlane added needs review needs 2nd review Core module updates require two approvals from the core team needs docs labels Mar 19, 2018
Copy link
Collaborator

@matthewlane matthewlane left a comment

Choose a reason for hiding this comment

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

@vedantseta Thanks a lot for the PR. We're going to need docs for the changes and an additional review since this changes core modules, but one change initially requested:

});
timedOutBidders = utils.groupBy(timedOutBidders, 'bidder');

for (const bidder of Object.keys(timedOutBidders)) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

The way for...of loops transpile have caused us errors for the browsers we support, can you change this to a forEach or different looping construct?

@vedantseta
Copy link
Contributor Author

@matthewlane , Have changed for..of to forEach and have added documentation prebid.github.io#678 here. Can you please review the same?

@mkendall07 mkendall07 self-requested a review March 26, 2018 15:39
@mkendall07 mkendall07 self-assigned this Mar 26, 2018
Copy link
Collaborator

@matthewlane matthewlane left a comment

Choose a reason for hiding this comment

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

There's a conflict that needs resolving but otherwise looks good to me

* @param {object} adunits
* @param {string} adunit code
* @param {string} bidder code
* @return {Array} user configured param for the given bidder adunit configuration
Copy link
Member

@mkendall07 mkendall07 Mar 28, 2018

Choose a reason for hiding this comment

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

it's really hard to visualize what this object looks like. Can you add it to the jsdocs typedef here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

return type is Array of Objects,

const adUnits = [{
      code: 'adUnit1',
      bids: [{
        bidder: 'bidder1',
        params: {
          key1: 'value1'
        }
      }]
    }];

In this case object is adUnits[0].params, which is defined by user

const spec = adapter.getSpec();
if (spec && spec.onTimeout && typeof spec.onTimeout === 'function') {
utils.logInfo(`Invoking ${bidder}.onTimeout`);
spec.onTimeout(timedOutBidders[bidder]);
Copy link
Member

Choose a reason for hiding this comment

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

typedef would be nice here for the passed object.

@mkendall07 mkendall07 merged commit 4bdc91c into prebid:master Apr 2, 2018
@vedantseta vedantseta mentioned this pull request Apr 17, 2018
1 task
dluxemburg pushed a commit to Genius/Prebid.js that referenced this pull request Jul 17, 2018
* timeout bidder spec init

* refactored

* refactored

* test case added for getUserConfiguredParams

* added more test cases

* timeout added as param

* minor changes

* replacing for..of with forEach

* Update utils_spec.js

* trailing spaces removed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
LGTM needs 2nd review Core module updates require two approvals from the core team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow bidders to subscribe to own timed out bid data
3 participants