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

Publish video support #34

Merged
merged 39 commits into from
Nov 27, 2024
Merged
Show file tree
Hide file tree
Changes from 36 commits
Commits
Show all changes
39 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
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
70 changes: 39 additions & 31 deletions modules/equativBidAdapter.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { BANNER } from '../src/mediaTypes.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,25 +13,43 @@ 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) => {
if (bidRequests.filter(isValid).length === 0) {
logError(`${LOG_PREFIX} No useful bid requests to process. No request will be sent.`, bidRequests);
return undefined;
}

return {
data: converter.toORTB({ bidderRequest, bidRequests }),
method: 'POST',
url: 'https://ssb-global.smartadserver.com/api/bid?callerId=169'
// url: 'https://ssb-engine-argocd-dev.internal.smartadserver.com/api/bid?callerId=169'
url: 'https://ssb-global.smartadserver.com/api/bid?callerId=169',
};
},

Expand Down Expand Up @@ -97,24 +115,13 @@ export const converter = ortbConverter({
imp.secure = 1;
imp.tagid = bidRequest.adUnitCode;

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

if (siteId) {
bidder.siteId = siteId;
}

if (pageId) {
bidder.pageId = pageId;
}

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 +131,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(env => deepAccess(bid, env)) || 'ortb2.site.publisher';
jefftmahoney marked this conversation as resolved.
Show resolved Hide resolved
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 +148,7 @@ export const converter = ortbConverter({
}

return req;
},
}
});

registerBidder(spec);
4 changes: 2 additions & 2 deletions src/ajax.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {config} from './config.js';
import {buildUrl, logError, parseUrl} from './utils.js';
import { config } from './config.js';
import { buildUrl, logError, parseUrl } from './utils.js';

export const dep = {
fetch: window.fetch.bind(window),
Expand Down
Loading