Skip to content

Commit

Permalink
beOp BidAdapter: FirstPartyData management and ingest Permutive segme…
Browse files Browse the repository at this point in the history
…nts (prebid#9947)

* Add psegs compatibility for permutive

* Add tests for FirstPartyData and Permutive

* Rearrange permutive segments ids location from ortb2

* Use permutive keywords instead of p_standard
  • Loading branch information
sebrobert authored and Michele Nasti committed Aug 25, 2023
1 parent 6b7fe6a commit f46494d
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
6 changes: 6 additions & 0 deletions modules/beopBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ export const spec = {
*/
buildRequests: function(validBidRequests, bidderRequest) {
const slots = validBidRequests.map(beOpRequestSlotsMaker);
const firstPartyData = bidderRequest.ortb2;
const psegs = (firstPartyData && firstPartyData.user && firstPartyData.user.ext && firstPartyData.user.ext.data) ? firstPartyData.user.ext.data.permutive : undefined;
const pageUrl = getPageUrl(bidderRequest.refererInfo, window);
const gdpr = bidderRequest.gdprConsent;
const firstSlot = slots[0];
Expand Down Expand Up @@ -68,6 +70,10 @@ export const spec = {
tc_string: (gdpr && gdpr.gdprApplies) ? gdpr.consentString : null,
};

if (psegs) {
Object.assign(payloadObject, {psegs: psegs});
}

const payloadString = JSON.stringify(payloadObject);
return {
method: 'POST',
Expand Down
24 changes: 24 additions & 0 deletions test/spec/modules/beopBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,30 @@ describe('BeOp Bid Adapter tests', () => {
expect(payload.url).to.exist;
// check that the protocol is added correctly
expect(payload.url).to.equal('http://test.te');
expect(payload.psegs).to.not.exist;
});

it('should call the endpoint with psegs data if any', function () {
let bidderRequest =
{
'ortb2': {
'user': {
'ext': {
'data': {
'permutive': [1234, 5678, 910]
}
}
}
}
};

const request = spec.buildRequests(bidRequests, bidderRequest);
const payload = JSON.parse(request.data);
expect(payload.psegs).to.exist;
expect(payload.psegs).to.include(1234);
expect(payload.psegs).to.include(5678);
expect(payload.psegs).to.include(910);
expect(payload.psegs).to.not.include(1);
});

it('should not prepend the protocol in page url if already present', function () {
Expand Down

0 comments on commit f46494d

Please sign in to comment.