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

Ensure transaction ID is always unique #3190

Merged
merged 5 commits into from
Nov 2, 2018
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
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 @@ -1248,7 +1248,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 @@ -1263,7 +1263,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