From e25adc00f439512b07ea39a98f7dc9f7ee9b7322 Mon Sep 17 00:00:00 2001 From: Michele Nasti Date: Fri, 11 Aug 2023 00:14:15 +0200 Subject: [PATCH] Native: privacyLink is now converted to ortb.privacy (#10271) * fix for privacyLink in native #10249 * handle privacy link in response too * privacy link should be returned in response --------- Co-authored-by: Michele Nasti --- src/constants.json | 1 - src/native.js | 13 ++++++++++++- test/spec/native_spec.js | 17 +++++++++++++++-- 3 files changed, 27 insertions(+), 4 deletions(-) diff --git a/src/constants.json b/src/constants.json index b7593b4867e..e8cb64e575d 100644 --- a/src/constants.json +++ b/src/constants.json @@ -163,7 +163,6 @@ "MAIN": 3 }, "NATIVE_KEYS_THAT_ARE_NOT_ASSETS": [ - "privacyLink", "clickUrl", "sendTargetingKeys", "adTemplate", diff --git a/src/native.js b/src/native.js index 66d1fd4becd..1414c7a2ee7 100644 --- a/src/native.js +++ b/src/native.js @@ -480,6 +480,11 @@ export function toOrtbNativeRequest(legacyNativeAssets) { continue; } + if (key === 'privacyLink') { + ortb.privacy = 1; + continue; + } + const asset = legacyNativeAssets[key]; let required = 0; if (asset.required && isBoolean(asset.required)) { @@ -623,6 +628,9 @@ export function fromOrtbNativeRequest(openRTBRequest) { oldNativeObject[prebidAssetName].len = asset.data.len; } } + if (openRTBRequest.privacy) { + oldNativeObject.privacyLink = { required: false }; + } // video was not supported by old prebid assets } return oldNativeObject; @@ -696,8 +704,11 @@ export function legacyPropertiesToOrtbNative(legacyNative) { // in general, native trackers seem to be neglected and/or broken response.jstracker = Array.isArray(value) ? value.join('') : value; break; + case 'privacyLink': + response.privacy = value; + break; } - }) + }); return response; } diff --git a/test/spec/native_spec.js b/test/spec/native_spec.js index a1b546e00f4..9cfee6f5cd8 100644 --- a/test/spec/native_spec.js +++ b/test/spec/native_spec.js @@ -862,6 +862,9 @@ describe('validate native', function () { }] }, address: {}, + privacyLink: { + required: true + } }, }, }; @@ -917,6 +920,7 @@ describe('validate native', function () { type: 9, } }); + expect(ortb.privacy).to.equal(1); }); ['bogusKey', 'clickUrl', 'privacyLink'].forEach(nativeKey => { @@ -1024,11 +1028,14 @@ describe('validate native', function () { expect(oldNativeRequest.sponsoredBy).to.include({ required: true, len: 25 - }) + }); expect(oldNativeRequest.body).to.include({ required: true, len: 140 - }) + }); + expect(oldNativeRequest.privacyLink).to.include({ + required: false + }); }); if (FEATURES.NATIVE) { @@ -1199,6 +1206,12 @@ describe('legacyPropertiesToOrtbNative', () => { expect(native.jstracker).to.eql('some-markupsome-other-markup'); }) }); + describe('privacylink', () => { + it('should convert privacyLink to privacy', () => { + const native = legacyPropertiesToOrtbNative({privacyLink: 'https:/my-privacy-link.com'}); + expect(native.privacy).to.eql('https:/my-privacy-link.com'); + }) + }) }); describe('fireImpressionTrackers', () => {