Skip to content

Commit fcd1e3c

Browse files
authored
PubWise Bid Adapter: clean up and updates to adUnit parsing (prebid#9066)
* add pubwise bid adpater updates * Update pubwiseBidAdapter_spec.js * updates for feedback from review, adding imp.ext.tid and source.tid from appropriate locations
1 parent f113129 commit fcd1e3c

File tree

2 files changed

+20
-16
lines changed

2 files changed

+20
-16
lines changed

modules/pubwiseBidAdapter.js

+14-12
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@ import { _each, isStr, deepClone, isArray, deepSetValue, inIframe, logMessage, l
22
import { config } from '../src/config.js';
33
import { registerBidder } from '../src/adapters/bidderFactory.js';
44
import { BANNER, NATIVE } from '../src/mediaTypes.js';
5-
import { convertOrtbRequestToProprietaryNative } from '../src/native.js';
6-
const VERSION = '0.1.0';
5+
const VERSION = '0.2.0';
76
const GVLID = 842;
87
const NET_REVENUE = true;
98
const UNDEFINED = undefined;
@@ -117,9 +116,6 @@ export const spec = {
117116
* @return ServerRequest Info describing the request to the server.
118117
*/
119118
buildRequests: function (validBidRequests, bidderRequest) {
120-
// convert Native ORTB definition to old-style prebid native definition
121-
validBidRequests = convertOrtbRequestToProprietaryNative(validBidRequests);
122-
123119
var refererInfo;
124120
if (bidderRequest && bidderRequest.refererInfo) {
125121
refererInfo = bidderRequest.refererInfo;
@@ -170,7 +166,7 @@ export const spec = {
170166
payload.user.geo.lon = _parseSlotParam('lon', conf.lon);
171167
payload.user.yob = _parseSlotParam('yob', conf.yob);
172168
payload.device.geo = payload.user.geo;
173-
payload.site.page = payload.site.page.trim();
169+
payload.site.page = payload.site?.page?.trim();
174170
payload.site.domain = _getDomainFromURL(payload.site.page);
175171

176172
// add the content object from config in request
@@ -184,7 +180,7 @@ export const spec = {
184180
}
185181

186182
// passing transactionId in source.tid
187-
deepSetValue(payload, 'source.tid', conf.transactionId);
183+
deepSetValue(payload, 'source.tid', bidderRequest?.auctionId);
188184

189185
// schain
190186
if (validBidRequests[0].schain) {
@@ -440,7 +436,10 @@ function _createImpressionObject(bid, conf) {
440436
tagid: bid.params.adUnit || undefined,
441437
bidfloor: _parseSlotParam('bidFloor', bid.params.bidFloor), // capitalization dicated by 3.2.4 spec
442438
secure: 1,
443-
bidfloorcur: bid.params.currency ? _parseSlotParam('currency', bid.params.currency) : DEFAULT_CURRENCY // capitalization dicated by 3.2.4 spec
439+
bidfloorcur: bid.params.currency ? _parseSlotParam('currency', bid.params.currency) : DEFAULT_CURRENCY, // capitalization dicated by 3.2.4 spec
440+
ext: {
441+
tid: (bid.transactionId ? bid.transactionId : '')
442+
}
444443
};
445444

446445
if (bid.hasOwnProperty('mediaTypes')) {
@@ -494,7 +493,11 @@ function _parseSlotParam(paramName, paramValue) {
494493

495494
function _parseAdSlot(bid) {
496495
_logInfo('parseAdSlot bid', bid)
497-
bid.params.adUnit = '';
496+
if (bid.adUnitCode) {
497+
bid.params.adUnit = bid.adUnitCode;
498+
} else {
499+
bid.params.adUnit = '';
500+
}
498501
bid.params.width = 0;
499502
bid.params.height = 0;
500503
bid.params.adSlot = _cleanSlotName(bid.params.adSlot);
@@ -532,9 +535,8 @@ function _cleanSlotName(slotName) {
532535

533536
function _initConf(refererInfo) {
534537
return {
535-
// TODO: do the fallbacks make sense here?
536-
pageURL: refererInfo?.page || window.location.href,
537-
refURL: refererInfo?.ref || window.document.referrer
538+
pageURL: refererInfo?.page,
539+
refURL: refererInfo?.ref
538540
};
539541
}
540542

test/spec/modules/pubwiseBidAdapter_spec.js

+6-4
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ const sampleBidderBannerRequest = {
238238
'bidFloor': '1.00',
239239
'currency': 'USD',
240240
'adSlot': '',
241-
'adUnit': '',
241+
'adUnit': 'div-gpt-ad-1460505748561-0',
242242
'bcat': [
243243
'IAB25-3',
244244
'IAB26-1',
@@ -535,13 +535,15 @@ describe('PubWiseAdapter', function () {
535535

536536
describe('Handling Request Construction', function () {
537537
it('bid requests are not mutable', function() {
538-
let sourceBidRequest = utils.deepClone(sampleValidBidRequests)
539-
spec.buildRequests(sampleValidBidRequests, {auctinId: 'placeholder'});
538+
let sourceBidRequest = utils.deepClone(sampleValidBidRequests);
539+
spec.buildRequests(sampleValidBidRequests, {auctionId: 'placeholder'});
540540
expect(sampleValidBidRequests).to.deep.equal(sourceBidRequest, 'Should be unedited as they are used elsewhere');
541541
});
542542
it('should handle complex bidRequest', function() {
543543
let request = spec.buildRequests(sampleValidBidRequests, sampleBidderRequest);
544-
expect(request.bidderRequest).to.equal(sampleBidderRequest);
544+
expect(request.bidderRequest).to.equal(sampleBidderRequest, "Bid Request Doesn't Match Sample");
545+
expect(request.data.source.tid).to.equal(sampleBidderRequest.auctionId, 'AuctionId -> source.tid Mismatch');
546+
expect(request.data.imp[0].ext.tid).to.equal(sampleBidderRequest.bids[0].transactionId, 'TransactionId -> ext.tid Mismatch');
545547
});
546548
it('must conform to API for buildRequests', function() {
547549
let request = spec.buildRequests(sampleValidBidRequests);

0 commit comments

Comments
 (0)