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

Rubicon Bid Adapter: expand fastlane EID protocol and pass p_site.mobile; Support device.ip and device.ipv6. #12471

Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
64 changes: 35 additions & 29 deletions modules/rubiconBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Copy link
Collaborator

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!

import { getGlobal } from '../src/prebidGlobal.js';
import { Renderer } from '../src/Renderer.js';
import {
Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -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) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If defined mobile is either 0 or 1

So, with this current code it would only pass it if it was 1 since 0 is falsy.

So lets add typeof here and pass along.

if (typeof bidRequest?.ortb2?.site?.mobile === 'number') {

Also add a test to confirm p_site.mobile

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);
}
});
}
Expand Down
Loading