From 00c69c207eb2c0eddb3bb175301a3a150427e71c Mon Sep 17 00:00:00 2001 From: Eric Nolte Date: Mon, 15 Apr 2024 12:40:40 -0400 Subject: [PATCH] PAAPI: emit addComponentAuction event Component Auction Configs appear to be entirely contained within the PAAPI + fledgeForGPT modules. This event provides a way to access those configs from outside of those 2 modules. --- src/adapters/bidderFactory.js | 1 + src/constants.json | 3 ++- test/spec/unit/core/bidderFactory_spec.js | 25 +++++++++++++++++++++++ 3 files changed, 28 insertions(+), 1 deletion(-) diff --git a/src/adapters/bidderFactory.js b/src/adapters/bidderFactory.js index 337ae47f338..956f781c1e5 100644 --- a/src/adapters/bidderFactory.js +++ b/src/adapters/bidderFactory.js @@ -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); }, 'addComponentAuction'); // check that the bid has a width and height set diff --git a/src/constants.json b/src/constants.json index ceac779a508..f923d7b695f 100644 --- a/src/constants.json +++ b/src/constants.json @@ -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", diff --git a/test/spec/unit/core/bidderFactory_spec.js b/test/spec/unit/core/bidderFactory_spec.js index 5fe5a1accfc..1993f5a4843 100644 --- a/test/spec/unit/core/bidderFactory_spec.js +++ b/test/spec/unit/core/bidderFactory_spec.js @@ -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); + }) + }); })