forked from prebid/Prebid.js
-
Notifications
You must be signed in to change notification settings - Fork 0
Update insticator for 2.6rtb #83
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
Open
shubhamc-ins
wants to merge
12
commits into
insticator-master
Choose a base branch
from
update-insticator-for-2.6rtb
base: insticator-master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
b60244e
enhance ORTB 2.6 support and enhance bid response handling
shubhamc-ins 4c620e7
Rubicon Bid Adapter: add support for primaryCatId and secondaryCatIds…
ourcraig 4ab7cc3
Bump lodash from 4.17.21 to 4.17.23 (#14368)
dependabot[bot] 738996e
remove onBidWon
shubhamc-ins b764b8a
Yield one bid adapter: support Interstitial (instl param) in building…
alukonin1 f46d47e
New Adapter: Panxo - AI traffic monetization SSP (#14365)
css12s e09f726
add tests for handling 204 No Content responses in InsticatorBidAdapter
shubhamc-ins f2c15cb
Bridgewell Bid Adapter: expand request data (#14320)
donnychang 86882d6
update InsticatorBidAdapter and improve TTL handling
shubhamc-ins f357dd5
Merge branch 'master' into update-insticator-for-2.6rtb
shubhamc-ins f9ce2f7
udpate media type detection in InsticatorBidAdapter to support ORTB 2…
shubhamc-ins 32a34c3
Merge branch 'update-insticator-for-2.6rtb' of github.com:Insticator/…
shubhamc-ins File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,7 +5,7 @@ import {deepAccess, generateUUID, logError, isArray, isInteger, isArrayOfNums, d | |
| import {getStorageManager} from '../src/storageManager.js'; | ||
|
|
||
| const BIDDER_CODE = 'insticator'; | ||
| const ENDPOINT = 'https://ex.ingage.tech/v1/openrtb'; // production endpoint | ||
| const ENDPOINT = 'https://ex.ingage.tech/v1/openrtb'; | ||
| const USER_ID_KEY = 'hb_insticator_uid'; | ||
| const USER_ID_COOKIE_EXP = 2592000000; // 30 days | ||
| const BID_TTL = 300; // 5 minutes | ||
|
|
@@ -29,7 +29,16 @@ export const OPTIONAL_VIDEO_PARAMS = { | |
| 'playbackend': (value) => isInteger(value) && [1, 2, 3].includes(value), | ||
| 'delivery': (value) => isArrayOfNums(value), | ||
| 'pos': (value) => isInteger(value) && [0, 1, 2, 3, 4, 5, 6, 7].includes(value), | ||
| 'api': (value) => isArrayOfNums(value)}; | ||
| 'api': (value) => isArrayOfNums(value), | ||
| // Ad Pod specific parameters (ORTB 2.6) | ||
| 'podid': (value) => typeof value === 'string' && value.length > 0, | ||
| 'podseq': (value) => isInteger(value) && value >= 0, | ||
| 'poddur': (value) => isInteger(value) && value > 0, | ||
| 'slotinpod': (value) => isInteger(value) && [-1, 0, 1, 2].includes(value), | ||
| 'mincpmpersec': (value) => typeof value === 'number' && value > 0, | ||
| 'maxseq': (value) => isInteger(value) && value > 0, | ||
| 'rqddurs': (value) => isArrayOfNums(value) && value.every(v => v > 0), | ||
| }; | ||
|
|
||
| const ORTB_SITE_FIRST_PARTY_DATA = { | ||
| 'cat': v => Array.isArray(v) && v.every(c => typeof c === 'string'), | ||
|
|
@@ -114,11 +123,11 @@ function buildVideo(bidRequest) { | |
|
|
||
| const optionalParams = {}; | ||
| for (const param in OPTIONAL_VIDEO_PARAMS) { | ||
| if (bidRequestVideo[param] && OPTIONAL_VIDEO_PARAMS[param](bidRequestVideo[param])) { | ||
| if (bidRequestVideo[param] != null && OPTIONAL_VIDEO_PARAMS[param](bidRequestVideo[param])) { | ||
| optionalParams[param] = bidRequestVideo[param]; | ||
| } | ||
| // remove invalid optional params from bidder specific overrides | ||
| if (videoBidderParams[param] && !OPTIONAL_VIDEO_PARAMS[param](videoBidderParams[param])) { | ||
| if (videoBidderParams[param] != null && !OPTIONAL_VIDEO_PARAMS[param](videoBidderParams[param])) { | ||
| delete videoBidderParams[param]; | ||
| } | ||
| } | ||
|
|
@@ -135,6 +144,20 @@ function buildVideo(bidRequest) { | |
| optionalParams['context'] = context; | ||
| } | ||
|
|
||
| // Map Prebid.js adpod fields to ORTB 2.6 video fields | ||
| const adPodDurationSec = deepAccess(bidRequest, 'mediaTypes.video.adPodDurationSec'); | ||
| if (adPodDurationSec && isInteger(adPodDurationSec) && adPodDurationSec > 0) { | ||
| optionalParams['poddur'] = adPodDurationSec; | ||
| } | ||
|
|
||
| const durationRangeSec = deepAccess(bidRequest, 'mediaTypes.video.durationRangeSec'); | ||
| if (durationRangeSec && isArrayOfNums(durationRangeSec) && durationRangeSec.length > 0) { | ||
| const validDurations = durationRangeSec.filter(v => v > 0); | ||
| if (validDurations.length > 0) { | ||
| optionalParams['rqddurs'] = validDurations; | ||
| } | ||
| } | ||
|
|
||
| const videoObj = { | ||
| mimes, | ||
| w, | ||
|
|
@@ -442,8 +465,9 @@ function buildRequest(validBidRequests, bidderRequest) { | |
| return req; | ||
| } | ||
|
|
||
| function buildBid(bid, bidderRequest) { | ||
| function buildBid(bid, bidderRequest, seatbid) { | ||
| const originalBid = ((bidderRequest.bids) || []).find((b) => b.bidId === bid.impid); | ||
|
|
||
| let meta = {} | ||
|
|
||
| if (bid.ext && bid.ext.meta) { | ||
|
|
@@ -454,27 +478,79 @@ function buildBid(bid, bidderRequest) { | |
| meta.advertiserDomains = bid.adomain | ||
| } | ||
|
|
||
| // ORTB 2.6: Add category support | ||
| if (bid.cat && Array.isArray(bid.cat) && bid.cat.length > 0) { | ||
| meta.primaryCatId = bid.cat[0]; | ||
| if (bid.cat.length > 1) { | ||
| meta.secondaryCatIds = bid.cat.slice(1); | ||
| } | ||
| } | ||
|
|
||
| // ORTB 2.6: Add seat from seatbid | ||
| if (seatbid && seatbid.seat) { | ||
| meta.seat = seatbid.seat; | ||
| } | ||
|
|
||
| // ORTB 2.6: Add creative attributes | ||
| if (bid.attr && Array.isArray(bid.attr)) { | ||
| meta.attr = bid.attr; | ||
| } | ||
|
|
||
| // Determine media type using multiple signals | ||
| let mediaType = 'banner'; | ||
| if (bid.adm && bid.adm.includes('<VAST')) { | ||
|
|
||
| // 1. Check ORTB 2.6 mtype first (most reliable) | ||
| if (bid.mtype === 2) { | ||
| mediaType = 'video'; | ||
| } else if (bid.mtype === 1) { | ||
| mediaType = 'banner'; | ||
| // 2. Fall back to content detection (case-insensitive) | ||
| } else if (bid.adm && bid.adm.toLowerCase().includes('<vast') && !bid.adm.toLowerCase().includes('<script')) { | ||
| mediaType = 'video'; | ||
| } | ||
|
|
||
| // TTL: Use bid.exp as upper bound if provided, otherwise use configTTL | ||
| const configTTL = config.getConfig('insticator.bidTTL') || BID_TTL; | ||
| const ttl = bid.exp && bid.exp > 0 ? Math.min(bid.exp, configTTL) : configTTL; | ||
|
|
||
| const bidResponse = { | ||
| requestId: bid.impid, | ||
| creativeId: bid.crid, | ||
| cpm: bid.price, | ||
| currency: 'USD', | ||
| netRevenue: true, | ||
| ttl: bid.exp || config.getConfig('insticator.bidTTL') || BID_TTL, | ||
| ttl: ttl, | ||
| width: bid.w, | ||
| height: bid.h, | ||
| mediaType: mediaType, | ||
| ad: bid.adm, | ||
| adUnitCode: originalBid.adUnitCode, | ||
| adUnitCode: originalBid?.adUnitCode, | ||
| ...(Object.keys(meta).length > 0 ? {meta} : {}) | ||
| }; | ||
|
|
||
| // ORTB 2.6: Add deal ID | ||
| if (bid.dealid) { | ||
| bidResponse.dealId = bid.dealid; | ||
| } | ||
|
|
||
| // ORTB 2.6: Add billing URL for billing notification | ||
| if (bid.burl) { | ||
|
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. lets add nurl too if prebidjs supports it. |
||
| bidResponse.burl = bid.burl; | ||
| } | ||
|
|
||
| // ORTB 2.6: Add notice URL for win notification | ||
| if (bid.nurl) { | ||
| bidResponse.nurl = bid.nurl; | ||
| } | ||
|
|
||
| if (mediaType === 'video') { | ||
| bidResponse.vastXml = bid.adm; | ||
|
|
||
| // ORTB 2.6: Add video duration for adpod support | ||
| if (bid.dur && isInteger(bid.dur) && bid.dur > 0) { | ||
| bidResponse.video = bidResponse.video || {}; | ||
| bidResponse.video.durationSeconds = bid.dur; | ||
| } | ||
| } | ||
|
|
||
| // Inticator bid adaptor only returns `vastXml` for video bids. No VastUrl or videoCache. | ||
|
|
@@ -493,7 +569,7 @@ function buildBid(bid, bidderRequest) { | |
| } | ||
|
|
||
| function buildBidSet(seatbid, bidderRequest) { | ||
| return seatbid.bid.map((bid) => buildBid(bid, bidderRequest)); | ||
| return seatbid.bid.map((bid) => buildBid(bid, bidderRequest, seatbid)); | ||
| } | ||
|
|
||
| function validateSize(size) { | ||
|
|
@@ -652,17 +728,27 @@ export const spec = { | |
| if (deepAccess(validBidRequests[0], 'params.bid_endpoint_request_url')) { | ||
| endpointUrl = deepAccess(validBidRequests[0], 'params.bid_endpoint_request_url').replace(/^http:/, 'https:'); | ||
| } | ||
|
|
||
| // Add publisherId as query parameter if present and non-empty | ||
| const publisherId = deepAccess(validBidRequests[0], 'params.publisherId'); | ||
| if (publisherId && publisherId.trim() !== '') { | ||
| const urlObj = new URL(endpointUrl); | ||
| urlObj.searchParams.set('publisherId', publisherId); | ||
| endpointUrl = urlObj.toString(); | ||
| } | ||
| } | ||
|
|
||
| if (validBidRequests.length > 0) { | ||
| const ortbRequest = buildRequest(validBidRequests, bidderRequest); | ||
|
|
||
| requests.push({ | ||
| method: 'POST', | ||
| url: endpointUrl, | ||
| options: { | ||
| contentType: 'application/json', | ||
| withCredentials: true, | ||
| }, | ||
| data: JSON.stringify(buildRequest(validBidRequests, bidderRequest)), | ||
| data: JSON.stringify(ortbRequest), | ||
| bidderRequest, | ||
| }); | ||
| } | ||
|
|
@@ -673,11 +759,22 @@ export const spec = { | |
| interpretResponse: function (serverResponse, request) { | ||
| const bidderRequest = request.bidderRequest; | ||
| const body = serverResponse.body; | ||
| if (!body || body.id !== bidderRequest.bidderRequestId) { | ||
| logError('insticator: response id does not match bidderRequestId'); | ||
|
|
||
| // Handle 204 No Content or empty response body (valid "no bid" scenario) | ||
| if (!body || !body.id) { | ||
| return []; | ||
| } | ||
|
|
||
| // Validate response ID matches request ID | ||
| if (body.id !== bidderRequest.bidderRequestId) { | ||
| logError('insticator: response id does not match bidderRequestId', { | ||
| responseId: body.id, | ||
| bidderRequestId: bidderRequest.bidderRequestId | ||
| }); | ||
| return []; | ||
| } | ||
|
|
||
| // No seatbid means no bids (valid scenario) | ||
| if (!body.seatbid) { | ||
| return []; | ||
| } | ||
|
|
@@ -686,7 +783,9 @@ export const spec = { | |
| buildBidSet(seatbid, bidderRequest) | ||
| ); | ||
|
|
||
| return bidsets.reduce((a, b) => a.concat(b), []); | ||
| const finalBids = bidsets.reduce((a, b) => a.concat(b), []); | ||
|
|
||
| return finalBids; | ||
| }, | ||
|
|
||
| getUserSyncs: function (options, responses) { | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
we won't reject requests right if this validations fail? Just wondering if something can be done to still process the requests
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.
No, requests are NOT rejected. this validation only controls whether the param is included and invalid params are skipped, and the bid request still proceeds with valid params.