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

AdagioBidAdapter: prebid-8: stop using auctionid and transactionid #10079

Merged
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
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