Skip to content

Commit

Permalink
Ensure transaction ID is always unique (prebid#3190)
Browse files Browse the repository at this point in the history
* 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.
  • Loading branch information
naegelin authored and Pedro López Jiménez committed Mar 18, 2019
1 parent de85791 commit 2acd2b8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
4 changes: 1 addition & 3 deletions src/prebid.js
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down
5 changes: 3 additions & 2 deletions test/spec/unit/pbjs_api_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: [
{
Expand All @@ -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);
});
Expand Down

0 comments on commit 2acd2b8

Please sign in to comment.