Skip to content

Commit

Permalink
Add a new generated field transactionId to each adunits.
Browse files Browse the repository at this point in the history
Transaction ID that must be common across all participants in
this bid request (e.g., potentially multiple exchanges) (OpenRTB v2.5).
  • Loading branch information
rcassan committed Mar 9, 2017
1 parent 00e673c commit db7550a
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 11 deletions.
1 change: 1 addition & 0 deletions src/adaptermanager.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ function getBids({bidderCode, requestId, bidderRequestId, adUnits}) {
return Object.assign(bid, {
placementCode: adUnit.code,
mediaType: adUnit.mediaType,
transactionId : adUnit.transactionId,
sizes: sizes,
bidId: utils.getUniqueIdentifierStr(),
bidderRequestId,
Expand Down
6 changes: 5 additions & 1 deletion src/prebid.js
Original file line number Diff line number Diff line change
Expand Up @@ -429,9 +429,13 @@ $$PREBID_GLOBAL$$.requestBids = function ({ bidsBackHandler, timeout, adUnits, a
$$PREBID_GLOBAL$$.addAdUnits = function (adUnitArr) {
utils.logInfo('Invoking $$PREBID_GLOBAL$$.addAdUnits', arguments);
if (utils.isArray(adUnitArr)) {
//append array to existing
// generate transactionid for each new adUnits
// Append array to existing
adUnitArr.forEach(adUnit => adUnit.transactionId = utils.generateUUID())
$$PREBID_GLOBAL$$.adUnits.push.apply($$PREBID_GLOBAL$$.adUnits, adUnitArr);
} else if (typeof adUnitArr === objectType_object) {
// Generate the transaction id for the adunit
adUnitArr.transactionId = utils.generateUUID();
$$PREBID_GLOBAL$$.adUnits.push(adUnitArr);
}
};
Expand Down
29 changes: 19 additions & 10 deletions test/fixtures/fixtures.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ export function getBidRequests() {
"bidderRequestId": "2946b569352ef2",
"requestId": "1863e370099523",
"startTime": 1462918897462,
"status": 1
"status": 1,
"transactionId": "fsafsa"
},
{
"bidder": "appnexus",
Expand All @@ -50,7 +51,8 @@ export function getBidRequests() {
"bidderRequestId": "2946b569352ef2",
"requestId": "1863e370099523",
"startTime": 1462918897463,
"status": 1
"status": 1,
"transactionId": "fsafsa"
}
],
"start": 1462918897460
Expand Down Expand Up @@ -79,7 +81,8 @@ export function getBidRequests() {
],
"bidId": "6d11aa2d5b3659",
"bidderRequestId": "5e1525bae3eb11",
"requestId": "1863e370099523"
"requestId": "1863e370099523",
"transactionId": "fsafsa"
}
],
"start": 1462918897463
Expand Down Expand Up @@ -112,7 +115,7 @@ export function getBidRequests() {
"sizes": [
15,
10
]
],
},
"placementCode": "/19968336/header-bid-tag-0",
"sizes": [
Expand All @@ -127,7 +130,8 @@ export function getBidRequests() {
],
"bidId": "96aff279720d39",
"bidderRequestId": "8778750ee15a77",
"requestId": "1863e370099523"
"requestId": "1863e370099523",
"transactionId": "fsafsa"
}
],
"start": 1462918897474
Expand Down Expand Up @@ -156,7 +160,8 @@ export function getBidRequests() {
"bidId": "1144e2f0de84363",
"bidderRequestId": "107f5e6e98dcf09",
"requestId": "1863e370099523",
"startTime": 1462918897477
"startTime": 1462918897477,
"transactionId": "fsafsa"
}
],
"start": 1462918897475
Expand Down Expand Up @@ -185,7 +190,8 @@ export function getBidRequests() {
"bidId": "135e89c039705da",
"bidderRequestId": "12eeded736650b4",
"requestId": "1863e370099523",
"status": 1
"status": 1,
"transactionId": "fsafsa"
}
],
"start": 1462918897477
Expand Down Expand Up @@ -215,7 +221,8 @@ export function getBidRequests() {
"bidderRequestId": "167c4d79b615948",
"requestId": "1863e370099523",
"startTime": 1462918897480,
"status": 1
"status": 1,
"transactionId": "fsafsa"
}
],
"start": 1462918897479
Expand Down Expand Up @@ -245,7 +252,8 @@ export function getBidRequests() {
"bidderRequestId": "18bed198c172a69",
"requestId": "1863e370099523",
"startTime": 1462918897481,
"status": 1
"status": 1,
"transactionId": "fsafsa"
}
],
"start": 1462918897480
Expand Down Expand Up @@ -273,7 +281,8 @@ export function getBidRequests() {
],
"bidId": "21ae8131ec04f6e",
"bidderRequestId": "20d0d30333715a7",
"requestId": "1863e370099523"
"requestId": "1863e370099523",
"transactionId": "fsafsa"
}
],
"start": 1462918897482
Expand Down
7 changes: 7 additions & 0 deletions test/spec/adUnits_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,13 @@ describe('Publisher API _ AdUnits', function () {
assert.strictEqual(bids2[1].params.placementId, '827326', 'adUnit2 bids2 params.placementId');
});

it ('both add unit should contains a transactionid.'), function() {
assert.exist(adUnit1.transationId)
assert.exist(adUnit2.transationId)

assert.strictEqual(false, adUnit1.transationId === adUnit2.transationId)
}

it('the second adUnits value should be same with the adUnits that is added by $$PREBID_GLOBAL$$.addAdUnits();', function () {

assert.strictEqual(adUnit2.code, '/1996833/slot-2', 'adUnit2 code');
Expand Down

0 comments on commit db7550a

Please sign in to comment.