Skip to content

Commit be26aa1

Browse files
author
Michele Nasti
committed
add non-asset properties to media type object
1 parent dabe836 commit be26aa1

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

src/constants.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,5 +150,10 @@
150150
"NATIVE_IMAGE_TYPES": {
151151
"ICON": 1,
152152
"MAIN": 3
153-
}
153+
},
154+
"NATIVE_KEYS_THAT_ARE_NOT_ASSETS": [
155+
"sendTargetingKeys",
156+
"adTemplate",
157+
"rendererUrl"
158+
]
154159
}

src/native.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@ function getNativeKeys(adUnit) {
398398
}
399399
}
400400

401-
const { NATIVE_ASSET_TYPES, NATIVE_IMAGE_TYPES, PREBID_NATIVE_DATA_KEYS_TO_ORTB } = CONSTANTS;
401+
const { NATIVE_ASSET_TYPES, NATIVE_IMAGE_TYPES, PREBID_NATIVE_DATA_KEYS_TO_ORTB, NATIVE_KEYS_THAT_ARE_NOT_ASSETS } = CONSTANTS;
402402

403403
/**
404404
* converts Prebid legacy native assets request to OpenRTB format
@@ -554,7 +554,16 @@ export function convertOrtbRequestToProprietaryNative(bidRequests) {
554554
// convert Native ORTB definition to old-style prebid native definition
555555
for (const bidRequest of bidRequests) {
556556
if (bidRequest.mediaTypes && bidRequest.mediaTypes[NATIVE] && bidRequest.mediaTypes[NATIVE].ortb) {
557-
bidRequest.mediaTypes[NATIVE] = fromOrtbNativeRequest(bidRequest.mediaTypes[NATIVE].ortb);
557+
bidRequest.mediaTypes[NATIVE] = {
558+
// to keep other keywords like sendTargetingKeys, rendererUrl...
559+
...Object.keys(bidRequest.mediaTypes[NATIVE])
560+
.filter(key => NATIVE_KEYS_THAT_ARE_NOT_ASSETS.includes(key))
561+
.reduce((obj, key) => ({
562+
...obj,
563+
[key]: bidRequest.mediaTypes[NATIVE][key]
564+
}), {}),
565+
...fromOrtbNativeRequest(bidRequest.mediaTypes[NATIVE].ortb)
566+
}
558567
bidRequest.nativeParams = bidRequest.mediaTypes[NATIVE];
559568
if (bidRequest.nativeParams) {
560569
processNativeAdUnitParams(bidRequest.nativeParams);

0 commit comments

Comments
 (0)