Skip to content

Commit

Permalink
convert bidders: ix
Browse files Browse the repository at this point in the history
  • Loading branch information
dgirardi committed May 20, 2022
1 parent 4486b4f commit 8ba55cd
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 32 deletions.
2 changes: 1 addition & 1 deletion modules/iqmBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ export const spec = {
bidderRequestId: bid.bidderRequestId,
uuid: bid.bidId,
// TODO: please do not send internal data structures over the network
// I am not going to attempt to accomodate this, no way this is usable on their end, it changes way too frequently
// I am not going to attempt to accommodate this, no way this is usable on their end, it changes way too frequently
bidderRequest
}
const request = {
Expand Down
2 changes: 1 addition & 1 deletion modules/iqzoneBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ export const spec = {
winLocation = window.location;
}

const refferUrl = bidderRequest.refererInfo && bidderRequest.refererInfo.referer;
const refferUrl = bidderRequest.refererInfo && bidderRequest.refererInfo.page;
let refferLocation;
try {
refferLocation = refferUrl && new URL(refferUrl);
Expand Down
16 changes: 1 addition & 15 deletions modules/ixBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,7 @@ function buildRequest(validBidRequests, bidderRequest, impressions, version) {
// Get ids from Prebid User ID Modules
let eidInfo = getEidInfo(deepAccess(validBidRequests, '0.userIdAsEids'));
let userEids = eidInfo.toSend;
const pageUrl = getPageUrl() || deepAccess(bidderRequest, 'refererInfo.referer');
const pageUrl = deepAccess(bidderRequest, 'refererInfo.page');

// RTI ids will be included in the bid request if the function getIdentityInfo() is loaded
// and if the data for the partner exist
Expand Down Expand Up @@ -934,20 +934,6 @@ function createBannerImps(validBidRequest, missingBannerSizes, bannerImps) {
}
}

/**
* Returns the `pageUrl` set by publisher on the page if it is an valid url
*/
function getPageUrl() {
const pageUrl = config.getConfig('pageUrl');
try {
const url = new URL(pageUrl);
return url.href;
} catch (_) {
logWarn(`IX Bid Adapter: invalid pageUrl config property value set: ${pageUrl}`);
return undefined;
}
}

/**
* Determines IX configuration type based on IX params
* @param {object} valid IX configured param
Expand Down
22 changes: 7 additions & 15 deletions test/spec/modules/ixBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ describe('IndexexchangeAdapter', function () {
vendorData: {}
},
refererInfo: {
referer: 'https://www.prebid.org',
page: 'https://www.prebid.org',
canonicalUrl: 'https://www.prebid.org/the/link/to/the/page'
}
};
Expand Down Expand Up @@ -1388,22 +1388,14 @@ describe('IndexexchangeAdapter', function () {
const payload = JSON.parse(query.r);
expect(payload.id).to.equal(DEFAULT_BANNER_VALID_BID[0].bidderRequestId);
expect(payload.id).to.be.a('string');
expect(payload.site.page).to.equal(DEFAULT_OPTION.refererInfo.referer);
expect(payload.site.page).to.equal(DEFAULT_OPTION.refererInfo.page);
expect(payload.site.ref).to.equal(document.referrer);
expect(payload.ext.source).to.equal('prebid');
expect(payload.source.ext.schain).to.deep.equal(SAMPLE_SCHAIN);
expect(payload.imp).to.be.an('array');
expect(payload.imp).to.have.lengthOf(1);
});

it('payload should set site.page to pageUrl when it exists in config object', function () {
const url = 'https://example.com/index.html';
config.setConfig({ pageUrl: url });
const request = spec.buildRequests(DEFAULT_BANNER_VALID_BID, DEFAULT_OPTION)[0].data;
const payload = JSON.parse(request.r);
expect(payload.site.page).to.contains(url);
});

it('payload should have correct format and value for r.id when bidderRequestId is a number ', function () {
const bidWithIntId = utils.deepClone(DEFAULT_BANNER_VALID_BID);
bidWithIntId[0].bidderRequestId = 123456;
Expand Down Expand Up @@ -1631,7 +1623,7 @@ describe('IndexexchangeAdapter', function () {

const requestWithFirstPartyData = spec.buildRequests(DEFAULT_BANNER_VALID_BID, DEFAULT_OPTION)[0];
const pageUrl = JSON.parse(requestWithFirstPartyData.data.r).site.page;
const expectedPageUrl = DEFAULT_OPTION.refererInfo.referer + '?ab=123&cd=123%23ab&e%2Ff=456&h%3Fg=456%23cd';
const expectedPageUrl = DEFAULT_OPTION.refererInfo.page + '?ab=123&cd=123%23ab&e%2Ff=456&h%3Fg=456%23cd';
expect(pageUrl).to.equal(expectedPageUrl);
});

Expand All @@ -1645,7 +1637,7 @@ describe('IndexexchangeAdapter', function () {
const requestFirstPartyDataNumber = spec.buildRequests(DEFAULT_BANNER_VALID_BID, DEFAULT_OPTION)[0];
const pageUrl = JSON.parse(requestFirstPartyDataNumber.data.r).site.page;

expect(pageUrl).to.equal(DEFAULT_OPTION.refererInfo.referer);
expect(pageUrl).to.equal(DEFAULT_OPTION.refererInfo.page);
});

it('should not set first party or timeout if it is not present', function () {
Expand All @@ -1656,15 +1648,15 @@ describe('IndexexchangeAdapter', function () {
const requestWithoutConfig = spec.buildRequests(DEFAULT_BANNER_VALID_BID, DEFAULT_OPTION)[0];
const pageUrl = JSON.parse(requestWithoutConfig.data.r).site.page;

expect(pageUrl).to.equal(DEFAULT_OPTION.refererInfo.referer);
expect(pageUrl).to.equal(DEFAULT_OPTION.refererInfo.page);
expect(requestWithoutConfig.data.t).to.be.undefined;
});

it('should not set first party or timeout if it is setConfig is not called', function () {
const requestWithoutConfig = spec.buildRequests(DEFAULT_BANNER_VALID_BID, DEFAULT_OPTION)[0];
const pageUrl = JSON.parse(requestWithoutConfig.data.r).site.page;

expect(pageUrl).to.equal(DEFAULT_OPTION.refererInfo.referer);
expect(pageUrl).to.equal(DEFAULT_OPTION.refererInfo.page);
expect(requestWithoutConfig.data.t).to.be.undefined;
});

Expand Down Expand Up @@ -2415,7 +2407,7 @@ describe('IndexexchangeAdapter', function () {
const validBidWithoutreferInfo = spec.buildRequests(DEFAULT_BANNER_VALID_BID, options);
const requestWithoutreferInfo = JSON.parse(validBidWithoutreferInfo[0].data.r);

expect(requestWithoutreferInfo.site.page).to.equal(options.refererInfo.referer);
expect(requestWithoutreferInfo.site.page).to.equal(options.refererInfo.page);
expect(validBidWithoutreferInfo[0].url).to.equal(IX_SECURE_ENDPOINT);
});

Expand Down

0 comments on commit 8ba55cd

Please sign in to comment.