Skip to content

Commit

Permalink
AdagioBidAdapter: prebid-8: stop using auctionid and transactionid (#…
Browse files Browse the repository at this point in the history
…10079)

* AdagioBidAdapter: stop using Prebid.js internal auctionId and transactionId

* AdagioBidAdapter: remove transformBidParams() logic
  • Loading branch information
osazos authored Jun 8, 2023
1 parent e083290 commit 52c2ea1
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 55 deletions.
49 changes: 18 additions & 31 deletions modules/adagioBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -860,8 +860,7 @@ function storeRequestInAdagioNS(bidRequest) {
bidder: bidRequest.bidder,
params: bidRequest.params // use the updated bid.params object with auto-detected params
}],
// TODO: fix auctionId leak: https://github.com/prebid/Prebid.js/issues/9781
auctionId: bidRequest.auctionId,
auctionId: bidRequest.auctionId, // this auctionId has been generated by adagioBidAdapter
pageviewId: internal.getPageviewId(),
printNumber,
localPbjs: '$$PREBID_GLOBAL$$',
Expand All @@ -870,7 +869,7 @@ function storeRequestInAdagioNS(bidRequest) {

// (legacy) Store internal adUnit information
w.ADAGIO.adUnits[bidRequest.adUnitCode] = {
auctionId: bidRequest.auctionId,
auctionId: bidRequest.auctionId, // this auctionId has been generated by adagioBidAdapter
pageviewId: internal.getPageviewId(),
printNumber,
};
Expand Down Expand Up @@ -982,7 +981,14 @@ export const spec = {
const syncEnabled = deepAccess(config.getConfig('userSync'), 'syncEnabled')
const usIfr = syncEnabled && userSync.canBidderRegisterSync('iframe', 'adagio')

const adUnits = _map(validBidRequests, (bidRequest) => {
const aucId = generateUUID()

const adUnits = _map(validBidRequests, (rawBidRequest) => {
const bidRequest = {...rawBidRequest}

// Fix https://github.com/prebid/Prebid.js/issues/9781
bidRequest.auctionId = aucId

const globalFeatures = GlobalExchange.getOrSetGlobalFeatures();
const features = {
...globalFeatures,
Expand Down Expand Up @@ -1095,6 +1101,12 @@ export const spec = {

storeRequestInAdagioNS(bidRequest);

// Remove these fields at the very end, so we can still use them before.
delete bidRequest.transactionId;
delete bidRequest.ortb2Imp;
delete bidRequest.ortb2;
delete bidRequest.sizes;

return bidRequest;
});

Expand Down Expand Up @@ -1233,33 +1245,8 @@ export const spec = {
* @returns {object} updated params
*/
transformBidParams(params, isOrtb, adUnit, bidRequests) {
const adagioBidderRequest = find(bidRequests, bidRequest => bidRequest.bidderCode === 'adagio');
const adagioBid = find(adagioBidderRequest.bids, bid => bid.adUnitCode === adUnit.code);

if (isOrtb) {
autoFillParams(adagioBid);

adagioBid.params.auctionId = deepAccess(adagioBidderRequest, 'auctionId');

const globalFeatures = GlobalExchange.getOrSetGlobalFeatures();
adagioBid.params.features = {
...globalFeatures,
print_number: getPrintNumber(adagioBid.adUnitCode, adagioBidderRequest).toString(),
adunit_position: getSlotPosition(adagioBid.params.adUnitElementId) // adUnitElementId à déplacer ???
};

adagioBid.params.pageviewId = internal.getPageviewId();
adagioBid.params.prebidVersion = '$prebid.version$';
adagioBid.params.data = GlobalExchange.getExchangeData();

if (deepAccess(adagioBid, 'mediaTypes.video.context') === OUTSTREAM) {
adagioBid.params.playerName = setPlayerName(adagioBid);
}

storeRequestInAdagioNS(adagioBid);
}

return adagioBid.params;
// We do not have a prebid server adapter. So let's return unchanged params.
return params;
}
};

Expand Down
39 changes: 15 additions & 24 deletions test/spec/modules/adagioBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,7 @@ describe('Adagio bid adapter', () => {
sandbox.stub(adagio, 'getDevice').returns({ a: 'a' });
sandbox.stub(adagio, 'getSite').returns({ domain: 'adagio.io', 'page': 'https://adagio.io/hb' });
sandbox.stub(adagio, 'getPageviewId').returns('1234-567');
sandbox.stub(utils, 'generateUUID').returns('blabla');

const bid01 = new BidRequestBuilder().withParams().build();
const bidderRequest = new BidderRequestBuilder().build();
Expand All @@ -309,6 +310,18 @@ describe('Adagio bid adapter', () => {
expect(requests[0].data).to.have.all.keys(expectedDataKeys);
});

it('should use a custom generated auctionId and remove transactionId', function() {
const expectedAuctionId = '373bcda7-9794-4f1c-be2c-0d223d11d579'
sandbox.stub(utils, 'generateUUID').returns(expectedAuctionId);

const bid01 = new BidRequestBuilder().withParams().build();
const bidderRequest = new BidderRequestBuilder().build();

const requests = spec.buildRequests([bid01], bidderRequest);
expect(requests[0].data.adUnits[0].auctionId).eq(expectedAuctionId);
expect(requests[0].data.adUnits[0].transactionId).to.not.exist;
});

it('should enqueue computed features for collect usage', function() {
sandbox.stub(Date, 'now').returns(12345);

Expand Down Expand Up @@ -1280,14 +1293,6 @@ describe('Adagio bid adapter', () => {

describe('transformBidParams', function() {
it('Compute additional params in s2s mode', function() {
GlobalExchange.prepareExchangeData('{}');

sandbox.stub(window.top.document, 'getElementById').returns(
fixtures.getElementById()
);
sandbox.stub(window.top, 'getComputedStyle').returns({ display: 'block' });
sandbox.stub(utils, 'inIframe').returns(false);

const adUnit = {
code: 'adunit-code',
params: {
Expand All @@ -1308,22 +1313,8 @@ describe('Adagio bid adapter', () => {
}
}).withParams().build();

const params = spec.transformBidParams({ organizationId: '1000' }, true, adUnit, [{ bidderCode: 'adagio', auctionId: bid01.auctionId, bids: [bid01] }]);

expect(params.organizationId).to.exist;
expect(params.auctionId).to.exist;
expect(params.playerName).to.exist;
expect(params.playerName).to.equal('other');
expect(params.features).to.exist;
expect(params.features.page_dimensions).to.exist;
expect(params.features.adunit_position).to.exist;
expect(params.features.dom_loading).to.exist;
expect(params.features.print_number).to.exist;
expect(params.features.user_timestamp).to.exist;
expect(params.placement).to.exist;
expect(params.adUnitElementId).to.exist;
expect(params.site).to.exist;
expect(params.data.session).to.exist;
const params = spec.transformBidParams({ param01: 'test' }, true, adUnit, [{ bidderCode: 'adagio', auctionId: bid01.auctionId, bids: [bid01] }]);
expect(params.param01).eq('test');
});
});

Expand Down

0 comments on commit 52c2ea1

Please sign in to comment.