From 2acd2b8a5bb6a98550a0f6ffddffd73e5e107a6a Mon Sep 17 00:00:00 2001 From: naegelin Date: Fri, 2 Nov 2018 23:31:28 +0100 Subject: [PATCH] Ensure transaction ID is always unique (#3190) * Ensure transaction ID is always unique Transaction ID implicitly suggests that this is a unique identifier per transaction. However in the case of a refresh / re-use of an ad unit the transaction ID remains the same causing undesirable bidding with certain SSPs. --- src/prebid.js | 4 +--- test/spec/unit/pbjs_api_spec.js | 5 +++-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/prebid.js b/src/prebid.js index 48d08719cb1..61c5421c0d3 100644 --- a/src/prebid.js +++ b/src/prebid.js @@ -348,9 +348,7 @@ $$PREBID_GLOBAL$$.requestBids = createHook('asyncSeries', function ({ bidsBackHa return !includes(s2sBidders, bidder); }) : allBidders; - if (!adUnit.transactionId) { - adUnit.transactionId = utils.generateUUID(); - } + adUnit.transactionId = utils.generateUUID(); bidders.forEach(bidder => { const adapter = bidderRegistry[bidder]; diff --git a/test/spec/unit/pbjs_api_spec.js b/test/spec/unit/pbjs_api_spec.js index a03339c76b3..215bf2cd757 100644 --- a/test/spec/unit/pbjs_api_spec.js +++ b/test/spec/unit/pbjs_api_spec.js @@ -1281,7 +1281,7 @@ describe('Unit: Prebid Module', function () { assert.ok(logMessageSpy.calledWith('No adUnits configured. No bids requested.'), 'expected message was logged'); }); - it('should attach transactionIds to ads (or pass through transactionId if it already exists)', function () { + it('should always attach new transactionIds to adUnits passed to requestBids', function () { $$PREBID_GLOBAL$$.requestBids({ adUnits: [ { @@ -1296,7 +1296,8 @@ describe('Unit: Prebid Module', function () { }); expect(auctionArgs.adUnits[0]).to.have.property('transactionId') - .and.to.equal('d0676a3c-ff32-45a5-af65-8175a8e7ddca'); + .and.to.match(/[a-f0-9\-]{36}/i) + .and.not.to.equal('d0676a3c-ff32-45a5-af65-8175a8e7ddca'); expect(auctionArgs.adUnits[1]).to.have.property('transactionId') .and.to.match(/[a-f0-9\-]{36}/i); });