Skip to content

Commit

Permalink
Freewheel add dealId property in bidResponse (prebid#5200)
Browse files Browse the repository at this point in the history
* freewheel-ssp fix issue on playerSize of bidRequest

* freewheel-ssp fix issue on playerSize of bidRequest

* freewheel add dealId property in bidResponse
  • Loading branch information
xwang202 authored and iggyfisk committed Jun 22, 2020
1 parent 844ab7f commit 7203907
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
22 changes: 21 additions & 1 deletion modules/freewheel-sspBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,24 @@ function getCreativeId(xmlNode) {
return creaId;
}

function getDealId(xmlNode) {
var dealId = '';
var impNodes = xmlNode.querySelectorAll('Impression'); // Nodelist.forEach is not supported in IE and Edge
// Workaround given here https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/10638731/

Array.prototype.forEach.call(impNodes, function (el) {
var queries = el.textContent.substring(el.textContent.indexOf('?') + 1).split('&');
Array.prototype.forEach.call(queries, function (item) {
var split = item.split('=');
if (split[0] == 'dealId') {
dealId = split[1];
}
});
});

return dealId;
}

/**
* returns the top most accessible window
*/
Expand Down Expand Up @@ -353,6 +371,7 @@ export const spec = {

const princingData = getPricing(xmlDoc);
const creativeId = getCreativeId(xmlDoc);
const dealId = getDealId(xmlDoc);

const topWin = getTopMostWindow();
if (!topWin.freewheelssp_cache) {
Expand All @@ -371,7 +390,8 @@ export const spec = {
creativeId: creativeId,
currency: princingData.currency,
netRevenue: true,
ttl: 360
ttl: 360,
dealId: dealId
};

if (bidrequest.mediaTypes.video) {
Expand Down
12 changes: 12 additions & 0 deletions test/spec/modules/freewheel-sspBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,8 @@ describe('freewheelSSP BidAdapter Test', () => {
'<Ad id=\'AdswizzAd28517153\'>' +
' <InLine>' +
' <AdSystem>Adswizz</AdSystem>' +
' <Impression id="dmp-1617899169-2513"></Impression>' +
' <Impression id="user-sync-1617899169-1">https://ads.stickyadstv.com/auto-user-sync?dealId=NRJ-PRO-00008</Impression>' +
' <Creatives>' +
' <Creative id=\'28517153\' sequence=\'1\'>' +
' <Linear>' +
Expand Down Expand Up @@ -323,12 +325,14 @@ describe('freewheelSSP BidAdapter Test', () => {
currency: 'EUR',
netRevenue: true,
ttl: 360,
dealId: 'NRJ-PRO-00008',
ad: ad
}
];

let result = spec.interpretResponse(response, request[0]);
expect(Object.keys(result[0])).to.deep.equal(Object.keys(expectedResponse[0]));
expect(result[0].dealId).to.equal('NRJ-PRO-00008');
});

it('should get correct bid response with formated ad', () => {
Expand All @@ -344,12 +348,14 @@ describe('freewheelSSP BidAdapter Test', () => {
currency: 'EUR',
netRevenue: true,
ttl: 360,
dealId: 'NRJ-PRO-00008',
ad: formattedAd
}
];

let result = spec.interpretResponse(response, request[0]);
expect(Object.keys(result[0])).to.deep.equal(Object.keys(expectedResponse[0]));
expect(result[0].dealId).to.equal('NRJ-PRO-00008');
});

it('handles nobid responses', () => {
Expand Down Expand Up @@ -421,6 +427,8 @@ describe('freewheelSSP BidAdapter Test', () => {
'<Ad id=\'AdswizzAd28517153\'>' +
' <InLine>' +
' <AdSystem>Adswizz</AdSystem>' +
' <Impression id="dmp-1617899169-2513"></Impression>' +
' <Impression id="user-sync-1617899169-1">https://ads.stickyadstv.com/auto-user-sync?dealId=NRJ-PRO-00008</Impression>' +
' <Creatives>' +
' <Creative id=\'28517153\' sequence=\'1\'>' +
' <Linear>' +
Expand Down Expand Up @@ -454,6 +462,7 @@ describe('freewheelSSP BidAdapter Test', () => {
currency: 'EUR',
netRevenue: true,
ttl: 360,
dealId: 'NRJ-PRO-00008',
vastXml: response,
mediaType: 'video',
ad: ad
Expand All @@ -462,6 +471,7 @@ describe('freewheelSSP BidAdapter Test', () => {

let result = spec.interpretResponse(response, request[0]);
expect(Object.keys(result[0])).to.deep.equal(Object.keys(expectedResponse[0]));
expect(result[0].dealId).to.equal('NRJ-PRO-00008');
});

it('should get correct bid response with formated ad', () => {
Expand All @@ -477,6 +487,7 @@ describe('freewheelSSP BidAdapter Test', () => {
currency: 'EUR',
netRevenue: true,
ttl: 360,
dealId: 'NRJ-PRO-00008',
vastXml: response,
mediaType: 'video',
ad: formattedAd
Expand All @@ -485,6 +496,7 @@ describe('freewheelSSP BidAdapter Test', () => {

let result = spec.interpretResponse(response, request[0]);
expect(Object.keys(result[0])).to.deep.equal(Object.keys(expectedResponse[0]));
expect(result[0].dealId).to.equal('NRJ-PRO-00008');
});

it('handles nobid responses', () => {
Expand Down

0 comments on commit 7203907

Please sign in to comment.