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

PAAPI: emit addComponentAuction event #11341

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/adapters/bidderFactory.js
Original file line number Diff line number Diff line change
Expand Up @@ -549,6 +549,7 @@ export const registerSyncInner = hook('async', function(spec, responses, gdprCon
}, 'registerSyncs')

export const addComponentAuction = hook('sync', (request, fledgeAuctionConfig) => {
events.emit(CONSTANTS.EVENTS.ADD_COMPONENT_AUCTION, request, fledgeAuctionConfig);
Copy link
Collaborator

Choose a reason for hiding this comment

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

With #11277 , this is being expanded (and renamed) to also support adding single buyers.

There's also the fact that if the paapi module is not installed, this data is just dropped - I'm not sure the event makes sense here (the component auction is not really "added").

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Does the need make sense? Prebid currently will event for things like new BidRequests or BidResponses, but I can't find any event that includes the fledgeAuctionConfigs. The paapi.js module doesn't seem ideal either, since a fledgeAuctionConfig can be returned from a BidAdapter without that module included.

Namespace-wise, I just followed with the name of the hook. If one name doesn't make sense, not sure if the other does either, right?

Copy link
Collaborator

Choose a reason for hiding this comment

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

bidRequested and bidResponse are only fired when the action is "final" (if they fail validation or are rejected they may trigger other events, but not those). Without the paapi module adapters would typically not get the ae signal and presumably they wouldn't have a reason to return auction configs.
It doesn't translate perfectly, but IMO it would be more consistent to fire something like componentAuction from the paapi module at the time all processing is done (they have first party data added) and they're "locked in".

If there's a need to know when configs are dropped I would make it a separate event - maybe unusedComponentAuction?

}, 'addComponentAuction');

// check that the bid has a width and height set
Expand Down
3 changes: 2 additions & 1 deletion src/constants.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@
"BID_VIEWABLE": "bidViewable",
"STALE_RENDER": "staleRender",
"BILLABLE_EVENT": "billableEvent",
"BID_ACCEPTED": "bidAccepted"
"BID_ACCEPTED": "bidAccepted",
"ADD_COMPONENT_AUCTION": "addComponentAuction"
},
"AD_RENDER_FAILED_REASON": {
"PREVENT_WRITING_ON_MAIN_DOCUMENT": "preventWritingOnMainDocument",
Expand Down
25 changes: 25 additions & 0 deletions test/spec/unit/core/bidderFactory_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1588,4 +1588,29 @@ describe('bidderFactory', () => {
});
})
});

describe('addComponentAuction', () => {
let requestStub
let fledgeAuctionConfigStub
let eventEmitterSpy

beforeEach(() => {
eventEmitterSpy = sinon.spy(events, 'emit');
requestStub = sinon.stub();
fledgeAuctionConfigStub = sinon.stub();
})

afterEach(() => {
eventEmitterSpy.restore();
})

it(`should emit an addComponentAuction event`, () => {
addComponentAuction(requestStub, fledgeAuctionConfigStub);
const eventCall = eventEmitterSpy.withArgs(CONSTANTS.EVENTS.ADD_COMPONENT_AUCTION).getCalls()[0];
const [event, request, fledgeAuctionConfig] = eventCall.args;
assert.equal(event, CONSTANTS.EVENTS.ADD_COMPONENT_AUCTION)
assert.equal(request, requestStub);
assert.equal(fledgeAuctionConfig, fledgeAuctionConfigStub);
})
});
})