Skip to content

Commit bcb5026

Browse files
add 51degrees property thirdpartycookiesenabled (prebid#14262)
* 51Degrees RTD submodule: map new `ortb2.device.ext` param - `thirdpartycookiesenabled` * 51Degrees RTD submodule: update tests * 51Degrees RTD submodule: update tests * doc update * doc update * 51Degrees RTD submodule: rename custom key, add tests * doc update * doc update --------- Co-authored-by: Bohdan V <25197509+BohdanVV@users.noreply.github.com>
1 parent c9fb203 commit bcb5026

3 files changed

Lines changed: 36 additions & 6 deletions

File tree

modules/51DegreesRtdProvider.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,7 @@ export const convert51DegreesDataToOrtb2 = (data51) => {
227227
* @param {number} [device.screenpixelsphysicalwidth] Screen physical width in pixels
228228
* @param {number} [device.pixelratio] Pixel ratio
229229
* @param {number} [device.screeninchesheight] Screen height in inches
230+
* @param {string} [device.thirdpartycookiesenabled] Third-party cookies enabled
230231
*
231232
* @returns {Object} Enriched ORTB2 object
232233
*/
@@ -261,7 +262,12 @@ export const convert51DegreesDeviceToOrtb2 = (device) => {
261262
deepSetNotEmptyValue(ortb2Device, 'w', device.screenpixelsphysicalwidth || device.screenpixelswidth);
262263
deepSetNotEmptyValue(ortb2Device, 'pxratio', device.pixelratio);
263264
deepSetNotEmptyValue(ortb2Device, 'ppi', devicePhysicalPPI || devicePPI);
265+
// kept for backward compatibility
264266
deepSetNotEmptyValue(ortb2Device, 'ext.fiftyonedegrees_deviceId', device.deviceid);
267+
deepSetNotEmptyValue(ortb2Device, 'ext.fod.deviceId', device.deviceid);
268+
if (['True', 'False'].includes(device.thirdpartycookiesenabled)) {
269+
deepSetValue(ortb2Device, 'ext.fod.tpc', device.thirdpartycookiesenabled === 'True' ? 1 : 0);
270+
}
265271

266272
return {device: ortb2Device};
267273
}

modules/51DegreesRtdProvider.md

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,17 @@
88

99
## Description
1010

11-
The 51Degrees module enriches an OpenRTB request with [51Degrees Device Data](https://51degrees.com/documentation/index.html).
11+
51Degrees module enriches an OpenRTB request with [51Degrees Device Data](https://51degrees.com/documentation/index.html).
1212

13-
The 51Degrees module sets the following fields of the device object: `devicetype`, `make`, `model`, `os`, `osv`, `h`, `w`, `ppi`, `pxratio`. Interested bidder adapters may use these fields as needed. In addition, the module sets `device.ext.fiftyonedegrees_deviceId` to a permanent device ID, which can be rapidly looked up in on-premise data, exposing over 250 properties, including device age, chipset, codec support, price, operating system and app/browser versions, age, and embedded features.
13+
51Degrees module sets the following fields of the device object: `devicetype`, `make`, `model`, `os`, `osv`, `h`, `w`, `ppi`, `pxratio`. Interested bidder adapters may use these fields as needed.
14+
15+
The module also adds a `device.ext.fod` extension object (fod == fifty one degrees) and sets `device.ext.fod.deviceId` to a permanent device ID, which can be rapidly looked up in on-premise data, exposing over 250 properties, including device age, chipset, codec support, price, operating system and app/browser versions, age, and embedded features.
16+
17+
It also sets `device.ext.fod.tpc` key to a binary value to indicate whether third-party cookies are enabled in the browser (1 if enabled, 0 if disabled).
1418

1519
The module supports on-premise and cloud device detection services, with free options for both.
1620

17-
A free resource key for use with 51Degrees cloud service can be obtained from [51Degrees cloud configuration](https://configure.51degrees.com/HNZ75HT1). This is the simplest approach to trial the module.
21+
A free resource key for use with 51Degrees cloud service can be obtained from [51Degrees cloud configuration](https://configure.51degrees.com/7bL8jDGz). This is the simplest approach to trial the module.
1822

1923
An interface-compatible self-hosted service can be used with .NET, Java, Node, PHP, and Python. See [51Degrees examples](https://51degrees.com/documentation/_examples__device_detection__getting_started__web__on_premise.html).
2024

@@ -36,7 +40,7 @@ gulp build --modules=rtdModule,51DegreesRtdProvider,appnexusBidAdapter,...
3640

3741
#### Resource Key
3842

39-
In order to use the module, please first obtain a Resource Key using the [Configurator tool](https://configure.51degrees.com/HNZ75HT1) - choose the following properties:
43+
In order to use the module, please first obtain a Resource Key using the [Configurator tool](https://configure.51degrees.com/7bL8jDGz) - choose the following properties:
4044

4145
* DeviceId
4246
* DeviceType
@@ -52,6 +56,7 @@ In order to use the module, please first obtain a Resource Key using the [Config
5256
* ScreenInchesHeight
5357
* ScreenInchesWidth
5458
* PixelRatio
59+
* ThirdPartyCookiesEnabled
5560

5661
The Cloud API is **free** to integrate and use. To increase limits, please check [51Degrees pricing](https://51degrees.com/pricing).
5762

@@ -106,7 +111,7 @@ pbjs.setConfig({
106111
waitForIt: true, // should be true, otherwise the auctionDelay will be ignored
107112
params: {
108113
resourceKey: '<YOUR_RESOURCE_KEY>',
109-
// Get your resource key from https://configure.51degrees.com/HNZ75HT1
114+
// Get your resource key from https://configure.51degrees.com/7bL8jDGz
110115
// alternatively, you can use the on-premise version of the 51Degrees service and connect to your chosen endpoint
111116
// onPremiseJSUrl: 'https://localhost/51Degrees.core.js'
112117
},

test/spec/modules/51DegreesRtdProvider_spec.js

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ describe('51DegreesRtdProvider', function() {
3333
devicetype: 'Desktop',
3434
pixelratio: 1,
3535
deviceid: '17595-131215-132535-18092',
36+
thirdpartycookiesenabled: 'True',
3637
};
3738

3839
const fiftyOneDegreesDeviceX2scaling = {
@@ -61,6 +62,10 @@ describe('51DegreesRtdProvider', function() {
6162
pxratio: 1,
6263
ext: {
6364
fiftyonedegrees_deviceId: '17595-131215-132535-18092',
65+
fod: {
66+
deviceId: '17595-131215-132535-18092',
67+
tpc: 1,
68+
},
6469
},
6570
},
6671
};
@@ -362,7 +367,8 @@ describe('51DegreesRtdProvider', function() {
362367
it('does not set the deviceid if it is not provided', function() {
363368
const device = {...fiftyOneDegreesDevice};
364369
delete device.deviceid;
365-
expect(convert51DegreesDeviceToOrtb2(device).device).to.not.have.any.keys('ext');
370+
expect(convert51DegreesDeviceToOrtb2(device).device.ext).to.not.have.any.keys('fiftyonedegrees_deviceId');
371+
expect(convert51DegreesDeviceToOrtb2(device).device.ext.fod).to.not.have.any.keys('deviceId');
366372
});
367373

368374
it('sets the model to hardwarename if hardwaremodel is not provided', function() {
@@ -400,6 +406,19 @@ describe('51DegreesRtdProvider', function() {
400406
w: expectedORTB2DeviceResult.device.w,
401407
});
402408
});
409+
410+
it('does not set the tpc if thirdpartycookiesenabled is "Unknown"', function () {
411+
const device = { ...fiftyOneDegreesDevice };
412+
device.thirdpartycookiesenabled = 'Unknown';
413+
expect(convert51DegreesDeviceToOrtb2(device).device.ext.fod).to.not.have.any.keys('tpc');
414+
});
415+
416+
it('sets the tpc if thirdpartycookiesenabled is "True" or "False"', function () {
417+
const deviceTrue = { ...fiftyOneDegreesDevice, thirdpartycookiesenabled: 'True' };
418+
const deviceFalse = { ...fiftyOneDegreesDevice, thirdpartycookiesenabled: 'False' };
419+
expect(convert51DegreesDeviceToOrtb2(deviceTrue).device.ext.fod).to.deep.include({ tpc: 1 });
420+
expect(convert51DegreesDeviceToOrtb2(deviceFalse).device.ext.fod).to.deep.include({ tpc: 0 });
421+
});
403422
});
404423

405424
describe('getBidRequestData', function() {

0 commit comments

Comments
 (0)