Skip to content

Commit bd3c4d0

Browse files
authored
VIS.X: fix bug with onTimeout function arguments (#8110)
Co-authored-by: Vladimir Fedoseev <[email protected]>
1 parent d8c711d commit bd3c4d0

File tree

2 files changed

+25
-6
lines changed

2 files changed

+25
-6
lines changed

modules/visxBidAdapter.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export const spec = {
4242
}
4343
}
4444
}
45-
return !!bid.params.uid;
45+
return !!bid.params.uid && !isNaN(parseInt(bid.params.uid));
4646
},
4747
buildRequests: function(validBidRequests, bidderRequest) {
4848
const auids = [];
@@ -203,6 +203,15 @@ export const spec = {
203203
},
204204
onTimeout: function(timeoutData) {
205205
// Call '/track/bid_timeout' with timeout data
206+
timeoutData.forEach(({ params }) => {
207+
if (params) {
208+
params.forEach((item) => {
209+
if (item && item.uid) {
210+
item.uid = parseInt(item.uid);
211+
}
212+
});
213+
}
214+
});
206215
triggerPixel(buildUrl(TRACK_TIMEOUT_PATH) + '//' + JSON.stringify(timeoutData));
207216
}
208217
};
@@ -249,7 +258,7 @@ function buildImpObject(bid) {
249258
...(banner && { banner }),
250259
...(video && { video }),
251260
ext: {
252-
bidder: { uid: Number(uid) },
261+
bidder: { uid: parseInt(uid) },
253262
}
254263
};
255264

test/spec/modules/visxBidAdapter_spec.js

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ describe('VisxAdapter', function () {
1818
let bid = {
1919
'bidder': 'visx',
2020
'params': {
21-
'uid': '903536'
21+
'uid': 903536
2222
},
2323
'adUnitCode': 'adunit-code',
2424
'sizes': [[300, 250], [300, 600]],
@@ -40,6 +40,15 @@ describe('VisxAdapter', function () {
4040
expect(spec.isBidRequestValid(bid)).to.equal(false);
4141
});
4242

43+
it('should return false when uid can not be parsed as number', function () {
44+
let bid = Object.assign({}, bid);
45+
delete bid.params;
46+
bid.params = {
47+
'uid': 'sdvsdv'
48+
};
49+
expect(spec.isBidRequestValid(bid)).to.equal(false);
50+
});
51+
4352
it('it should fail on invalid video bid', function () {
4453
let videoBid = Object.assign({}, bid);
4554
videoBid.mediaTypes = {
@@ -102,7 +111,7 @@ describe('VisxAdapter', function () {
102111
{
103112
'bidder': 'visx',
104113
'params': {
105-
'uid': 903535
114+
'uid': '903535'
106115
},
107116
'adUnitCode': 'adunit-code-2',
108117
'sizes': [[728, 90], [300, 250]],
@@ -1263,9 +1272,10 @@ describe('VisxAdapter', function () {
12631272
});
12641273

12651274
it('onTimeout', function () {
1266-
const data = { timeout: 3000, bidId: '23423', params: { uid: 1 } };
1275+
const data = [{ timeout: 3000, adUnitCode: 'adunit-code-1', auctionId: '1cbd2feafe5e8b', bidder: 'visx', bidId: '23423', params: [{ uid: '1' }] }];
1276+
const expectedData = [{ ...data[0], params: [{ uid: 1 }] }];
12671277
spec.onTimeout(data);
1268-
expect(utils.triggerPixel.calledOnceWith('https://t.visx.net/track/bid_timeout//' + JSON.stringify(data))).to.equal(true);
1278+
expect(utils.triggerPixel.calledOnceWith('https://t.visx.net/track/bid_timeout//' + JSON.stringify(expectedData))).to.equal(true);
12691279
});
12701280
});
12711281

0 commit comments

Comments
 (0)