Skip to content

Commit

Permalink
nextMillennium Bid Adapter : added supply chain support (#12421)
Browse files Browse the repository at this point in the history
* PB-2782 - added support supply chain

* PB-2782 - added supply chain support - 2
  • Loading branch information
mhlm authored Nov 6, 2024
1 parent 655712c commit 7bca55c
Show file tree
Hide file tree
Showing 2 changed files with 124 additions and 1 deletion.
18 changes: 17 additions & 1 deletion modules/nextMillenniumBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
parseUrl,
triggerPixel,
} from '../src/utils.js';

import {getAd} from '../libraries/targetVideoUtils/bidderUtils.js';

import { EVENTS } from '../src/constants.js';
Expand All @@ -20,7 +21,7 @@ import {config} from '../src/config.js';
import {registerBidder} from '../src/adapters/bidderFactory.js';
import {getRefererInfo} from '../src/refererDetection.js';

const NM_VERSION = '4.1.0';
const NM_VERSION = '4.2.0';
const PBJS_VERSION = 'v$prebid.version$';
const GVLID = 1060;
const BIDDER_CODE = 'nextMillennium';
Expand Down Expand Up @@ -90,6 +91,7 @@ export const spec = {
window.nmmRefreshCounts = window.nmmRefreshCounts || {};
const site = getSiteObj();
const device = getDeviceObj();
const source = getSourceObj(validBidRequests, bidderRequest);
const tmax = deepAccess(bidderRequest, 'timeout') || DEFAULT_TMAX;

const postBody = {
Expand All @@ -101,6 +103,7 @@ export const spec = {

device,
site,
source,
imp: [],
};

Expand Down Expand Up @@ -495,6 +498,19 @@ function getDeviceObj() {
};
}

export function getSourceObj(validBidRequests, bidderRequest) {
const schain = validBidRequests?.[0]?.schain ||
(bidderRequest?.ortb2?.source && (bidderRequest?.ortb2?.source?.schain || bidderRequest?.ortb2?.source?.ext?.schain));

if (!schain) return;

const source = {
schain,
};

return source;
}

function getSua() {
let {brands, mobile, platform} = (window?.navigator?.userAgentData || {});
if (!(brands && platform)) return undefined;
Expand Down
107 changes: 107 additions & 0 deletions test/spec/modules/nextMillenniumBidAdapter_spec.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { expect } from 'chai';
import {
getImp,
getSourceObj,
replaceUsersyncMacros,
setConsentStrings,
setOrtb2Parameters,
Expand Down Expand Up @@ -108,6 +109,112 @@ describe('nextMillenniumBidAdapterTests', () => {
}
});

describe('function getSourceObj', () => {
const dataTests = [
{
title: 'schain is empty',
validBidRequests: [{}],
bidderRequest: {},
expected: undefined,
},

{
title: 'schain is validBidReequest',
bidderRequest: {},
validBidRequests: [{
schain: {
validation: 'strict',
config: {
ver: '1.0',
complete: 1,
nodes: [{asi: 'test.test', sid: '00001', hp: 1}],
},
},
}],

expected: {
schain: {
validation: 'strict',
config: {
ver: '1.0',
complete: 1,
nodes: [{asi: 'test.test', sid: '00001', hp: 1}],
},
},
},
},

{
title: 'schain is bidderReequest.ortb2.source.schain',
bidderRequest: {
ortb2: {
source: {
schain: {
validation: 'strict',
config: {
ver: '1.0',
complete: 1,
nodes: [{asi: 'test.test', sid: '00001', hp: 1}],
},
},
},
},
},

validBidRequests: [{}],
expected: {
schain: {
validation: 'strict',
config: {
ver: '1.0',
complete: 1,
nodes: [{asi: 'test.test', sid: '00001', hp: 1}],
},
},
},
},

{
title: 'schain is bidderReequest.ortb2.source.ext.schain',
bidderRequest: {
ortb2: {
source: {
ext: {
schain: {
validation: 'strict',
config: {
ver: '1.0',
complete: 1,
nodes: [{asi: 'test.test', sid: '00001', hp: 1}],
},
},
},
},
},
},

validBidRequests: [{}],
expected: {
schain: {
validation: 'strict',
config: {
ver: '1.0',
complete: 1,
nodes: [{asi: 'test.test', sid: '00001', hp: 1}],
},
},
},
},
];

for (let {title, validBidRequests, bidderRequest, expected} of dataTests) {
it(title, () => {
const source = getSourceObj(validBidRequests, bidderRequest);
expect(source).to.deep.equal(expected);
});
}
});

describe('function setConsentStrings', () => {
const dataTests = [
{
Expand Down

0 comments on commit 7bca55c

Please sign in to comment.