Skip to content

Commit

Permalink
Native: privacyLink is now converted to ortb.privacy (prebid#10271)
Browse files Browse the repository at this point in the history
* fix for privacyLink in native prebid#10249

* handle privacy link in response too

* privacy link should be returned in response

---------

Co-authored-by: Michele Nasti <michele@magnite.com>
  • Loading branch information
2 people authored and Santiago Carabone committed Aug 22, 2023
1 parent 266069b commit e25adc0
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 4 deletions.
1 change: 0 additions & 1 deletion src/constants.json
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,6 @@
"MAIN": 3
},
"NATIVE_KEYS_THAT_ARE_NOT_ASSETS": [
"privacyLink",
"clickUrl",
"sendTargetingKeys",
"adTemplate",
Expand Down
13 changes: 12 additions & 1 deletion src/native.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}

Expand Down
17 changes: 15 additions & 2 deletions test/spec/native_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -862,6 +862,9 @@ describe('validate native', function () {
}]
},
address: {},
privacyLink: {
required: true
}
},
},
};
Expand Down Expand Up @@ -917,6 +920,7 @@ describe('validate native', function () {
type: 9,
}
});
expect(ortb.privacy).to.equal(1);
});

['bogusKey', 'clickUrl', 'privacyLink'].forEach(nativeKey => {
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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', () => {
Expand Down

0 comments on commit e25adc0

Please sign in to comment.