-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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: support native bid requests #12566
Changes from 58 commits
2f8a35c
3120efd
9483a81
5e04eae
6acff45
55bbc9d
a0e1efe
b03579d
f618679
d5a3178
92091d4
23eac33
3a5eda0
86a7845
52752e7
b75a5c2
9ec6fe4
259cba2
9a92f9d
811932c
ae67b8a
bc4e78a
3148ed8
f08f05d
3fac9a9
e65525d
9ce2bc2
fb9b893
9f9c133
08e3c52
0bc782c
c0990eb
19b147c
3a6c723
c1a2e63
3bfac49
0f1d815
578f79f
4be5f71
4f400c3
1b74710
e95f8b4
f35f424
65905e0
28a1e74
9aae66c
e081bf3
33e2c3c
14d5e6d
1b3f249
ef71a28
f3dc7c7
78a32de
716423c
f309940
0208c9e
b3d9086
f7109f8
29161bb
4cd1038
2337165
786cfde
12f1f17
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,10 @@ | ||
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 { getBidFloor } from '../libraries/equativUtils/equativUtils.js'; | ||
import { ortbConverter } from '../libraries/ortbConverter/converter.js'; | ||
import { registerBidder } from '../src/adapters/bidderFactory.js'; | ||
import { config } from '../src/config.js'; | ||
import { BANNER, NATIVE, VIDEO } from '../src/mediaTypes.js'; | ||
import { getStorageManager } from '../src/storageManager.js'; | ||
import { deepAccess, deepSetValue, logError, logWarn, mergeDeep } from '../src/utils.js'; | ||
|
||
/** | ||
|
@@ -18,22 +19,22 @@ 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. | ||
* Evaluates impressions for validity. The entry evaluated is considered valid if NEITHER of these conditions are met: | ||
* 1) it has a `video` property defined for `mediaTypes.video` which is an empty object | ||
* 2) it has a `native` property defined for `mediatTypes.native` which is an empty object | ||
* @param {*} bidReq A bid request object to evaluate | ||
* @returns boolean | ||
*/ | ||
function isValid(bidReq) { | ||
return !(bidReq.mediaTypes.video && JSON.stringify(bidReq.mediaTypes.video) === '{}'); | ||
return !(bidReq.mediaTypes.video && JSON.stringify(bidReq.mediaTypes.video) === '{}') && !(bidReq.mediaTypes.native && JSON.stringify(bidReq.mediaTypes.native) === '{}'); | ||
} | ||
|
||
export const storage = getStorageManager({ bidderCode: BIDDER_CODE }); | ||
|
||
export const spec = { | ||
code: BIDDER_CODE, | ||
gvlid: 45, | ||
supportedMediaTypes: [BANNER, VIDEO], | ||
supportedMediaTypes: [BANNER, VIDEO, NATIVE], | ||
|
||
/** | ||
* @param bidRequests | ||
|
@@ -42,7 +43,7 @@ export const spec = { | |
*/ | ||
buildRequests: (bidRequests, bidderRequest) => { | ||
if (bidRequests.filter(isValid).length === 0) { | ||
logError(`${LOG_PREFIX} No useful bid requests to process. No request will be sent.`, bidRequests); | ||
logError(`${LOG_PREFIX} No useful bid requests to process. No requests will be sent.`, bidRequests); | ||
return undefined; | ||
} | ||
|
||
|
@@ -121,7 +122,6 @@ export const converter = ortbConverter({ | |
|
||
imp.bidfloor = imp.bidfloor || getBidFloor(bidRequest, config.getConfig('currency.adServerCurrency'), mediaType); | ||
imp.secure = 1; | ||
|
||
imp.tagid = bidRequest.adUnitCode; | ||
|
||
if (!deepAccess(bidRequest, 'ortb2Imp.rwdd') && deepAccess(bidRequest, 'mediaTypes.video.ext.rewarded')) { | ||
|
@@ -151,6 +151,17 @@ export const converter = ortbConverter({ | |
}); | ||
} | ||
|
||
// "assets" is not included as a property to check here because the | ||
// ortbConverter library checks for it already and will skip processing | ||
// the request if it is missing | ||
if (deepAccess(bid, 'mediaTypes.native')) { | ||
['privacy', 'plcmttype', 'eventtrackers'].forEach(prop => { | ||
if (!bid.mediaTypes.native.ortb[prop]) { | ||
logWarn(`${LOG_PREFIX} Property "${prop}" is missing from request`, bid); | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can you add detail, eg ${LOG_PREFIX} Property "${prop}" is missing from request, ${LOG_PREFIX} will not bid There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Our product managers want the warnings in there, but do want the bid request to be stopped if these particular properties are missing. If If not bidding if these other properties are missing is a hard requirement, I can share that back to them. Or if you would like the message further refined in another way (e.g. adding "it is strongly recommended you add ${prop}", etc.) we can do that too. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. putting myself in the shoes of someone reading this message, i dont know what the outcome is. Tell the publisher the consequence. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yep, that makes a lot of sense. I'll refine it. |
||
}); | ||
} | ||
|
||
const pid = storage.getCookie(PID_COOKIE_NAME); | ||
if (pid) { | ||
deepSetValue(req, 'user.buyeruid', pid); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
spelling
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here:
mediatTypes.native
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just spotted it - thanks!