Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Equativ Bid Adapter: add support for video media type #12514

Merged
merged 43 commits into from
Dec 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
2f8a35c
add support of dsa
eszponder Aug 19, 2024
3120efd
Merge pull request #27 from smartadserver/dsa-2
eszponder Aug 19, 2024
9483a81
restore topics
eszponder Aug 19, 2024
5e04eae
Merge pull request #28 from smartadserver/dsa-2
eszponder Aug 19, 2024
6acff45
DSA fix for UT
eszponder Aug 20, 2024
55bbc9d
Merge pull request #29 from smartadserver/dsa-2
eszponder Aug 20, 2024
a0e1efe
Merge branch 'prebid:master' into master
krzysztofequativ Sep 2, 2024
b03579d
Merge branch 'prebid:master' into master
krzysztofequativ Sep 11, 2024
f618679
Merge branch 'prebid:master' into master
krzysztofequativ Oct 14, 2024
d5a3178
drafy of adapter
krzysztofequativ Sep 11, 2024
92091d4
fixes after dev test
krzysztofequativ Sep 12, 2024
23eac33
make world simpler
krzysztofequativ Sep 12, 2024
3a5eda0
fix prev commit
krzysztofequativ Sep 12, 2024
86a7845
return empty userSyncs array by default
krzysztofequativ Sep 12, 2024
52752e7
adjustments
janzych-smart Sep 16, 2024
b75a5c2
apply prettier
janzych-smart Sep 16, 2024
9ec6fe4
unit tests for Equativ adapter
janzych-smart Sep 17, 2024
259cba2
add dsp user sync
krzysztofequativ Sep 20, 2024
9a92f9d
add readme
krzysztofequativ Sep 20, 2024
811932c
body can be undef
krzysztofequativ Sep 20, 2024
ae67b8a
support additional br params
krzysztofequativ Sep 25, 2024
bc4e78a
remove user sync
krzysztofequativ Sep 27, 2024
3148ed8
do not send dt param
krzysztofequativ Oct 8, 2024
f08f05d
handle floors and network id
krzysztofequativ Oct 9, 2024
3fac9a9
handle empty media types
krzysztofequativ Oct 10, 2024
e65525d
get min floor
krzysztofequativ Oct 15, 2024
9ce2bc2
fix desc for u.t.
krzysztofequativ Oct 16, 2024
fb9b893
better name for u.t.
krzysztofequativ Oct 16, 2024
9f9c133
add u.t. for not supported media type
krzysztofequativ Oct 16, 2024
08e3c52
improve currency u.t.
krzysztofequativ Oct 16, 2024
c0990eb
SADR-6484: initial video setup for new PBJS adapter
jefftmahoney Oct 25, 2024
19b147c
SADR-6484: Adding logging requirement missed earlier
jefftmahoney Oct 28, 2024
3a6c723
SADR-6484: handle ext.rewarded prop for video with new oRTBConverter
jefftmahoney Oct 29, 2024
c1a2e63
SADR-6484: test revision + not sending bid requests where video obj i…
jefftmahoney Oct 30, 2024
0f1d815
Merge branch 'master' into SADR-6484
krzysztofequativ Nov 13, 2024
4be5f71
refactoring and u.t.
krzysztofequativ Nov 15, 2024
4f400c3
rename variable
krzysztofequativ Nov 18, 2024
e95f8b4
revert changes rel. to test endpoint
krzysztofequativ Nov 27, 2024
f35f424
revert changes rel. to test endpoint
krzysztofequativ Nov 27, 2024
65905e0
Merge pull request #34 from smartadserver/SADR-6484
krzysztofequativ Nov 27, 2024
28a1e74
split imp[0] into seperate requests and fix u.t.
krzysztofequativ Nov 29, 2024
9aae66c
Merge pull request #37 from smartadserver/split-imp
eszponder Dec 3, 2024
e081bf3
Merge branch 'master' into master
jefftmahoney Dec 3, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
91 changes: 54 additions & 37 deletions modules/equativBidAdapter.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { BANNER } from '../src/mediaTypes.js';
import { config } from '../src/config.js';
import { BANNER, VIDEO } from '../src/mediaTypes.js';
import { getBidFloor } from '../libraries/equativUtils/equativUtils.js'
import { getStorageManager } from '../src/storageManager.js';
import { ortbConverter } from '../libraries/ortbConverter/converter.js';
import { registerBidder } from '../src/adapters/bidderFactory.js';
import { getStorageManager } from '../src/storageManager.js';
import { deepAccess, deepSetValue, mergeDeep } from '../src/utils.js';
import { deepAccess, deepSetValue, logError, logWarn, mergeDeep } from '../src/utils.js';

/**
* @typedef {import('../src/adapters/bidderFactory.js').Bid} Bid
Expand All @@ -13,26 +14,50 @@ import { deepAccess, deepSetValue, mergeDeep } from '../src/utils.js';
const BIDDER_CODE = 'equativ';
const COOKIE_SYNC_ORIGIN = 'https://apps.smartadserver.com';
const COOKIE_SYNC_URL = `${COOKIE_SYNC_ORIGIN}/diff/templates/asset/csync.html`;
const LOG_PREFIX = 'Equativ:';
const PID_COOKIE_NAME = 'eqt_pid';

/**
* Evaluates a bid request for validity. Returns false if the
* request contains a video media type with no properties, true
* otherwise.
* @param {*} bidReq A bid request object to evaluate
* @returns boolean
*/
function isValid(bidReq) {
return !(bidReq.mediaTypes.video && JSON.stringify(bidReq.mediaTypes.video) === '{}');
}

export const storage = getStorageManager({ bidderCode: BIDDER_CODE });

export const spec = {
code: BIDDER_CODE,
gvlid: 45,
supportedMediaTypes: [BANNER],
supportedMediaTypes: [BANNER, VIDEO],

/**
* @param bidRequests
* @param bidderRequest
* @returns {ServerRequest[]}
*/
buildRequests: (bidRequests, bidderRequest) => {
return {
data: converter.toORTB({ bidderRequest, bidRequests }),
method: 'POST',
url: 'https://ssb-global.smartadserver.com/api/bid?callerId=169'
};
if (bidRequests.filter(isValid).length === 0) {
logError(`${LOG_PREFIX} No useful bid requests to process. No request will be sent.`, bidRequests);
return undefined;
}

const requests = [];

bidRequests.forEach(bid => {
const data = converter.toORTB({bidRequests: [bid], bidderRequest});
requests.push({
data,
method: 'POST',
url: 'https://ssb-global.smartadserver.com/api/bid?callerId=169',
})
});

return requests;
},

/**
Expand Down Expand Up @@ -89,32 +114,23 @@ export const converter = ortbConverter({

imp(buildImp, bidRequest, context) {
const imp = buildImp(bidRequest, context);
const mediaType = deepAccess(bidRequest, 'mediaTypes.video') ? VIDEO : BANNER;
const { siteId, pageId, formatId } = bidRequest.params;

delete imp.dt;

imp.bidfloor = imp.bidfloor || getBidFloor(bidRequest);
imp.secure = bidRequest.ortb2Imp?.secure ?? 1;
imp.tagid = bidRequest.adUnitCode;

if (siteId || pageId || formatId) {
const bidder = {};

if (siteId) {
bidder.siteId = siteId;
}
imp.bidfloor = imp.bidfloor || getBidFloor(bidRequest, config.getConfig('currency.adServerCurrency'), mediaType);
imp.secure = 1;

if (pageId) {
bidder.pageId = pageId;
}
imp.tagid = bidRequest.adUnitCode;

if (formatId) {
bidder.formatId = formatId;
}
if (!deepAccess(bidRequest, 'ortb2Imp.rwdd') && deepAccess(bidRequest, 'mediaTypes.video.ext.rewarded')) {
mergeDeep(imp, { rwdd: bidRequest.mediaTypes.video.ext.rewarded });
}

mergeDeep(imp, {
ext: { bidder },
});
const bidder = { ...(siteId && { siteId }), ...(pageId && { pageId }), ...(formatId && { formatId }) };
if (Object.keys(bidder).length) {
mergeDeep(imp.ext, { bidder });
}

return imp;
Expand All @@ -124,14 +140,15 @@ export const converter = ortbConverter({
const bid = context.bidRequests[0];
const req = buildRequest(imps, bidderRequest, context);

if (deepAccess(bid, 'ortb2.site.publisher')) {
deepSetValue(req, 'site.publisher.id', bid.ortb2.site.publisher.id || bid.params.networkId);
} else if (deepAccess(bid, 'ortb2.app.publisher')) {
deepSetValue(req, 'app.publisher.id', bid.ortb2.app.publisher.id || bid.params.networkId);
} else if (deepAccess(bid, 'ortb2.dooh.publisher')) {
deepSetValue(req, 'dooh.publisher.id', bid.ortb2.dooh.publisher.id || bid.params.networkId);
} else {
deepSetValue(req, 'site.publisher.id', bid.params.networkId);
let env = ['ortb2.site.publisher', 'ortb2.app.publisher', 'ortb2.dooh.publisher'].find(propPath => deepAccess(bid, propPath)) || 'ortb2.site.publisher';
deepSetValue(req, env.replace('ortb2.', '') + '.id', deepAccess(bid, env + '.id') || bid.params.networkId);

if (deepAccess(bid, 'mediaTypes.video')) {
['mimes', 'placement'].forEach(prop => {
if (!bid.mediaTypes.video[prop]) {
logWarn(`${LOG_PREFIX} Property "${prop}" is missing from request`, bid);
}
});
}

const pid = storage.getCookie(PID_COOKIE_NAME);
Expand All @@ -140,7 +157,7 @@ export const converter = ortbConverter({
}

return req;
},
}
});

registerBidder(spec);
Loading
Loading