Skip to content

Commit

Permalink
feat: move duplicate code to its function [PB-1387]
Browse files Browse the repository at this point in the history
  • Loading branch information
shahin-rahbariasl committed Apr 18, 2023
1 parent 1159f22 commit c191749
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions modules/ixBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -196,10 +196,7 @@ function bidToVideoImp(bid) {
imp.ext.tid = deepAccess(bid, 'ortb2Imp.ext.tid');

// AdUnit-Specific First Party Data
const adUnitFPD = deepAccess(bid, 'ortb2Imp.ext.data');
if (adUnitFPD) {
deepSetValue(imp, 'ext.data', adUnitFPD)
}
addAdUnitFPD(imp, bid)

// copy all video properties to imp object
for (const adUnitProperty in videoAdUnitRef) {
Expand Down Expand Up @@ -275,10 +272,7 @@ function bidToNativeImp(bid) {
imp.ext.tid = deepAccess(bid, 'ortb2Imp.ext.tid');

// AdUnit-Specific First Party Data
const adUnitFPD = deepAccess(bid, 'ortb2Imp.ext.data');
if (adUnitFPD) {
deepSetValue(imp, 'ext.data', adUnitFPD)
}
addAdUnitFPD(imp, bid)

_applyFloor(bid, imp, NATIVE);

Expand Down Expand Up @@ -1028,6 +1022,19 @@ function addFPD(bidderRequest, r, fpd, site, user) {
return r;
}

/**
* Adds First-Party Data (FPD) from the bid object to the imp object.
*
* @param {Object} imp - The imp object, representing an impression in the OpenRTB format.
* @param {Object} bid - The bid object, containing information about the bid request.
*/
function addAdUnitFPD(imp, bid) {
const adUnitFPD = deepAccess(bid, 'ortb2Imp.ext.data');
if (adUnitFPD) {
deepSetValue(imp, 'ext.data', adUnitFPD)
}
}

/**
* addIdentifiersInfo adds indentifier info to ixDaig.
*
Expand Down

0 comments on commit c191749

Please sign in to comment.