-
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
Rubicon Bid Adapter: expand fastlane EID protocol and pass p_site.mobile; Support device.ip and device.ipv6. #12471
Merged
robertrmartinez
merged 3 commits into
prebid:master
from
apukh-magnite:rubiconBidAdapter/expand-fastline-eid
Nov 19, 2024
+215
−222
Merged
Changes from 1 commit
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
ff3239a
Rubicon Bid Adapter: Remove special source handling, add eid_ for eac…
apukh-magnite ff155b5
Rubicon Bid Adapter: Change check for mobile property in bidRequest
apukh-magnite 2c21497
Rubicon Bid Adapter: Add tests for p_site.mobile property in bidRequest
apukh-magnite 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 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 |
---|---|---|
|
@@ -3,7 +3,6 @@ import { pbsExtensions } from '../libraries/pbsExtensions/pbsExtensions.js'; | |
import { registerBidder } from '../src/adapters/bidderFactory.js'; | ||
import { config } from '../src/config.js'; | ||
import { BANNER, NATIVE, VIDEO } from '../src/mediaTypes.js'; | ||
import { find } from '../src/polyfill.js'; | ||
import { getGlobal } from '../src/prebidGlobal.js'; | ||
import { Renderer } from '../src/Renderer.js'; | ||
import { | ||
|
@@ -499,6 +498,8 @@ export const spec = { | |
'x_imp.ext.tid': bidRequest.ortb2Imp?.ext?.tid, | ||
'l_pb_bid_id': bidRequest.bidId, | ||
'o_cdep': bidRequest.ortb2?.device?.ext?.cdep, | ||
'ip': bidRequest.ortb2?.device?.ip, | ||
'ipv6': bidRequest.ortb2?.device?.ipv6, | ||
'p_screen_res': _getScreenResolution(), | ||
'tk_user_key': params.userId, | ||
'p_geo.latitude': isNaN(parseFloat(latitude)) ? undefined : parseFloat(latitude).toFixed(4), | ||
|
@@ -542,42 +543,47 @@ export const spec = { | |
if (bidRequest?.ortb2Imp?.ext?.ae) { | ||
data['o_ae'] = 1; | ||
} | ||
// If the bid request contains a 'mobile' property under 'ortb2.site', add it to 'data' as 'p_site.mobile'. | ||
if (bidRequest?.ortb2?.site?.mobile) { | ||
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. If defined So, with this current code it would only pass it if it was So lets add typeof here and pass along. if (typeof bidRequest?.ortb2?.site?.mobile === 'number') { Also add a test to confirm |
||
data['p_site.mobile'] = bidRequest.ortb2.site.mobile | ||
} | ||
|
||
addDesiredSegtaxes(bidderRequest, data); | ||
// loop through userIds and add to request | ||
if (bidRequest.userIdAsEids) { | ||
bidRequest.userIdAsEids.forEach(eid => { | ||
if (bidRequest?.ortb2?.user?.ext?.eids) { | ||
bidRequest.ortb2.user.ext.eids.forEach(({ source, uids = [], inserter, matcher, mm, ext = {} }) => { | ||
try { | ||
// special cases | ||
if (eid.source === 'adserver.org') { | ||
data['tpid_tdid'] = eid.uids[0].id; | ||
data['eid_adserver.org'] = eid.uids[0].id; | ||
} else if (eid.source === 'liveintent.com') { | ||
data['tpid_liveintent.com'] = eid.uids[0].id; | ||
data['eid_liveintent.com'] = eid.uids[0].id; | ||
if (eid.ext && Array.isArray(eid.ext.segments) && eid.ext.segments.length) { | ||
data['tg_v.LIseg'] = eid.ext.segments.join(','); | ||
} | ||
} else if (eid.source === 'liveramp.com') { | ||
data['x_liverampidl'] = eid.uids[0].id; | ||
} else if (eid.source === 'id5-sync.com') { | ||
data['eid_id5-sync.com'] = `${eid.uids[0].id}^${eid.uids[0].atype}^${(eid.uids[0].ext && eid.uids[0].ext.linkType) || ''}`; | ||
} else { | ||
// add anything else with this generic format | ||
// if rubicon drop ^ | ||
const id = eid.source === 'rubiconproject.com' ? eid.uids[0].id : `${eid.uids[0].id}^${eid.uids[0].atype || ''}` | ||
data[`eid_${eid.source}`] = id; | ||
} | ||
// send AE "ppuid" signal if exists, and hasn't already been sent | ||
// Ensure there is at least one valid UID in the 'uids' array | ||
const uidData = uids[0]; | ||
if (!uidData) return; // Skip processing if no valid UID exists | ||
|
||
// Function to build the EID value in the required format | ||
const buildEidValue = (uidData) => [ | ||
uidData.id, // uid: The user ID | ||
uidData.atype || '', | ||
'', // third: Always empty, as specified in the requirement | ||
inserter || '', | ||
matcher || '', | ||
mm || '', | ||
uidData?.ext?.rtipartner || '' | ||
].join('^'); // Return a single string formatted with '^' delimiter | ||
|
||
const eidValue = buildEidValue(uidData); // Build the EID value string | ||
|
||
// Store the constructed EID value for the given source | ||
data[`eid_${source}`] = eidValue; | ||
|
||
// Handle the "ppuid" signal, ensuring it is set only once | ||
if (!data['ppuid']) { | ||
// get the first eid.uids[*].ext.stype === 'ppuid', if one exists | ||
const ppId = find(eid.uids, uid => uid.ext && uid.ext.stype === 'ppuid'); | ||
if (ppId && ppId.id) { | ||
data['ppuid'] = ppId.id; | ||
// Search for a UID with the 'stype' field equal to 'ppuid' in its extension | ||
const ppId = uids.find(uid => uid.ext?.stype === 'ppuid'); | ||
if (ppId?.id) { | ||
data['ppuid'] = ppId.id; // Store the ppuid if found | ||
} | ||
} | ||
} catch (e) { | ||
logWarn('Rubicon: error reading eid:', eid, e); | ||
// Log any errors encountered during processing | ||
logWarn('Rubicon: error reading eid:', { source, uids }, e); | ||
} | ||
}); | ||
} | ||
|
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.
This is not used anywhere? It def should not be!