Skip to content

Commit

Permalink
Merge branch 'optional-chaining' of github.com:prebid/Prebid.js into …
Browse files Browse the repository at this point in the history
…optional-chaining
  • Loading branch information
dgirardi committed Dec 5, 2024
2 parents 1dc9e71 + 9b21ad1 commit 9d0cbfc
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/native.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import {
deepAccess,
deepClone, getDefinedParams,
insertHtmlIntoIframe,
isArray,
Expand Down Expand Up @@ -373,25 +372,25 @@ export function getNativeTargeting(bid, {index = auctionManager.index} = {}) {

Object.keys(flatBidNativeKeys).forEach(asset => {
const key = nativeKeys[asset];
let value = getAssetValue(bid.native[asset]) || getAssetValue(deepAccess(bid, `native.ext.${asset}`));
let value = getAssetValue(bid.native[asset]) || getAssetValue(bid?.native?.ext?.[asset]);

if (asset === 'adTemplate' || !key || !value) {
return;
}

let sendPlaceholder = deepAccess(adUnit, `nativeParams.${asset}.sendId`);
let sendPlaceholder = adUnit?.nativeParams?.[asset]?.sendId;
if (typeof sendPlaceholder !== 'boolean') {
sendPlaceholder = deepAccess(adUnit, `nativeParams.ext.${asset}.sendId`);
sendPlaceholder = adUnit?.nativeParams?.ext?.[asset]?.sendId;
}

if (sendPlaceholder) {
const placeholder = `${key}:${bid.adId}`;
value = placeholder;
}

let assetSendTargetingKeys = deepAccess(adUnit, `nativeParams.${asset}.sendTargetingKeys`);
let assetSendTargetingKeys = adUnit?.nativeParams?.[asset]?.sendTargetingKeys;
if (typeof assetSendTargetingKeys !== 'boolean') {
assetSendTargetingKeys = deepAccess(adUnit, `nativeParams.ext.${asset}.sendTargetingKeys`);
assetSendTargetingKeys = adUnit?.nativeParams?.ext?.[asset]?.sendTargetingKeys;
}

const sendTargeting = typeof assetSendTargetingKeys === 'boolean' ? assetSendTargetingKeys : globalSendTargetingKeys;
Expand Down

0 comments on commit 9d0cbfc

Please sign in to comment.