-
Notifications
You must be signed in to change notification settings - Fork 0
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
Showheroes update #4
Changes from 1 commit
b89e0f1
6b698ac
10cc542
b2f7974
54c6147
ec416cb
6060470
22252fa
57c724a
027e1df
875db81
9b28c8c
63793d6
bcb81f4
e6ad465
10638ed
de54544
52278df
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 |
---|---|---|
|
@@ -19,6 +19,7 @@ const converter = ortbConverter({ | |
netRevenue: true, | ||
ttl: TTL, | ||
currency: 'EUR', | ||
mediaType: VIDEO, | ||
}, | ||
imp(buildImp, bidRequest, context) { | ||
const imp = buildImp(bidRequest, context); | ||
|
@@ -55,6 +56,24 @@ const converter = ortbConverter({ | |
(req?.device?.sua) && delete req.device['sua']; | ||
return req; | ||
}, | ||
|
||
bidResponse(buildBidResponse, bid, context) { | ||
const bidResponse = buildBidResponse(bid, context); | ||
|
||
if (context.imp?.ext?.mediaType === 'outstream') { | ||
const renderConfig = { | ||
rendererUrl: bid.ext?.rendererConfig?.rendererUrl, | ||
renderFunc: bid.ext?.rendererConfig?.renderFunc, | ||
renderOptions: bid.ext?.rendererConfig?.renderOptions, | ||
}; | ||
if (renderConfig.renderFunc && renderConfig.rendererUrl) { | ||
bidResponse.renderer = createRenderer(bidResponse, renderConfig); | ||
} | ||
} | ||
bidResponse.callbacks = bid.ext.callbacks; | ||
bidResponse.extra = bid.ext?.extra; | ||
return bidResponse; | ||
}, | ||
}) | ||
|
||
const GVLID = 111; | ||
|
@@ -79,7 +98,12 @@ export const spec = { | |
}; | ||
}, | ||
interpretResponse: (response, request) => { | ||
return createBids(response.body, request.data); | ||
if (!response.body) { | ||
return []; | ||
} | ||
|
||
const bids = converter.fromORTB({response: response.body, request: request.data}).bids; | ||
return bids; | ||
}, | ||
getUserSyncs: (syncOptions, serverResponses) => { | ||
const syncs = []; | ||
|
@@ -121,68 +145,18 @@ export const spec = { | |
}, | ||
}; | ||
|
||
function createBids(bidRes, bidReq) { | ||
if (!bidRes || !bidRes.seatbid) { | ||
return []; | ||
} | ||
const bids = []; | ||
|
||
bidRes.seatbid.forEach((seatbid) => { | ||
if (!seatbid.bid?.length) { | ||
return; | ||
} | ||
seatbid.bid.forEach((bid) => { | ||
const imp = bidReq.imp.find((imp) => imp.id === bid.impid); | ||
const bidUnit = { | ||
cpm: bid.price, | ||
requestId: bid.impid, | ||
adUnitCode: imp?.ext?.adUnitCode, | ||
currency: bidRes.cur, | ||
mediaType: VIDEO, | ||
ttl: bid.exp || TTL, | ||
netRevenue: true, | ||
extra: bid.extra, | ||
width: bid.w, | ||
height: bid.h, | ||
creativeId: bid.crid, | ||
callbacks: bid?.ext?.callbacks, | ||
meta: { | ||
advertiserDomains: bid.adomain || [], | ||
}, | ||
}; | ||
if (bid.adm) { | ||
bidUnit.vastXml = bid.adm; | ||
bidUnit.adResponse = { | ||
content: bid.adm, | ||
}; | ||
} | ||
if (bid.nurl) { | ||
bidUnit.vastUrl = bid.nurl; | ||
} | ||
if (imp?.ext?.mediaType === 'outstream') { | ||
const renderConfig = { | ||
rendererUrl: bid.ext?.rendererConfig?.rendererUrl, | ||
renderFunc: bid.ext?.rendererConfig?.renderFunc, | ||
renderOptions: bid.ext?.rendererConfig?.renderOptions, | ||
}; | ||
if (renderConfig.renderFunc && renderConfig.rendererUrl) { | ||
bidUnit.renderer = createRenderer(bidUnit, renderConfig); | ||
} | ||
}; | ||
bids.push(bidUnit); | ||
}); | ||
}); | ||
|
||
return bids; | ||
} | ||
|
||
function outstreamRender(response, renderConfig) { | ||
response.renderer.push(() => { | ||
const func = deepAccess(window, renderConfig.renderFunc); | ||
if (!isFn(func)) { | ||
return; | ||
} | ||
const renderPayload = { ...response, ...renderConfig.renderOptions }; | ||
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. What type of object is Moreover it's not clear the contract between the renderer function and the argument it can receive. 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. I left like that on purpose. To be free to change/modify from the backend side whatever we want. I know it's not ideal, I know it's ugly and error-prone. But, until we don't have our renderer in place, I really don't see the other way. Then we can open a PR in pbjs and cleanup the mess that is left behind. Another option is to hardcode appnexus renderer inside pbjs, and then 2nd PR to replace it with ours. Code would be a lot cleaner. Let me know what you think? 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. I was just looking at the Maybe it's better to explicitly return the object passed to the renderer directly from the server response function outstreamRender(response, renderConfig) {
response.renderer.push(() => {
const func = deepAccess(window, renderConfig.renderFunc);
if (!isFn(func)) {
return;
}
func(renderConfig.renderOptions);
});
} This means that adserver must be changed with:
|
||
if (renderPayload.vastXml) { | ||
renderPayload.adResponse = { | ||
content: renderPayload.vastXml, | ||
}; | ||
} | ||
func(renderPayload); | ||
}); | ||
} | ||
|
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.
This line looks suspicious, maybe you wanted to write: