Skip to content

Commit

Permalink
Add 51 Degrees Device Detection Module documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
Sarana-Anna committed May 3, 2024
1 parent 19896bd commit 75018c1
Showing 1 changed file with 308 additions and 0 deletions.
308 changes: 308 additions & 0 deletions prebid-server/pbs-modules/51degrees-device-detection.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,308 @@
---
layout: page_v2
page_type: pbs-module
title: Prebid Server 51Degrees Device Detection Module
display_name : 51Degrees Device Detection Module
sidebarType : 5
---

# 51Degrees Device Detection Module
{:.no_toc}

* TOC
{:toc }

Check failure on line 13 in prebid-server/pbs-modules/51degrees-device-detection.md

View workflow job for this annotation

GitHub Actions / run markdownlint

Lists should be surrounded by blank lines

prebid-server/pbs-modules/51degrees-device-detection.md:13 MD032/blanks-around-lists Lists should be surrounded by blank lines [Context: "{:toc }"] https://github.com/DavidAnson/markdownlint/blob/v0.33.0/doc/md032.md
## Overview

51Degrees module enriches an incoming OpenRTB request [51Degrees Device Data](https://51degrees.com/documentation/_device_detection__overview.html).

51Degrees module sets the following fields of the device object: `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 the device age, chip set, codec support, and price, operating system and app/browser versions, age, and embedded features.

## Setup

The 51Degrees module operates using a data file. You can get started with a free Lite data file that can be downloaded here: [51Degrees-LiteV4.1.hash](https://github.com/51Degrees/device-detection-data/blob/main/51Degrees-LiteV4.1.hash). The Lite file is capable of detecting limited device information, so if you need in-depth device data, please contact 51Degrees to obtain a license: [https://51degrees.com/contact-us](https://51degrees.com/contact-us?ContactReason=Free%20Trial).

Put the data file in a file system location writable by the user that is running the Prebid Server module and specify that directory location in the configuration parameters. The location needs to be writable if you would like to enable [automatic data file updates](https://51degrees.com/documentation/_features__automatic_datafile_updates.html).

### Execution Plan

This module supports running at two stages:

- entrypoint: this is where incoming requests are parsed and device detection evidences are extracted.

Check failure on line 30 in prebid-server/pbs-modules/51degrees-device-detection.md

View workflow job for this annotation

GitHub Actions / run markdownlint

Unordered list style

prebid-server/pbs-modules/51degrees-device-detection.md:30:1 MD004/ul-style Unordered list style [Expected: asterisk; Actual: dash] https://github.com/DavidAnson/markdownlint/blob/v0.33.0/doc/md004.md
- raw-auction-request: this is where outgoing auction requests to each bidder are enriched with the device detection data

Check failure on line 31 in prebid-server/pbs-modules/51degrees-device-detection.md

View workflow job for this annotation

GitHub Actions / run markdownlint

Unordered list style

prebid-server/pbs-modules/51degrees-device-detection.md:31:1 MD004/ul-style Unordered list style [Expected: asterisk; Actual: dash] https://github.com/DavidAnson/markdownlint/blob/v0.33.0/doc/md004.md

We recommend defining the execution plan right in the account config
so the module is only invoked for specific accounts. See below for an example.

### Global Config

There is no host-company level config for this module.

### Account-Level Config

To start using current module in PBS-Java you have to enable module and add `fiftyone-devicedetection-entrypoint-hook` and `fiftyone-devicedetection-raw-auction-request-hook` into hooks execution plan inside your yaml file:
Here's a general template for the account config used in PBS-Java:

```yaml
hooks:
fiftyone-devicedetection:
enabled: true
host_execution_plan: >
{
"endpoints": {
"/openrtb2/auction": {
"stages": {
"entrypoint": {
"groups": [
{
"timeout": 100,
"hook-sequence": [
{
"module-code": "fiftyone-devicedetection",
"hook-impl-code": "fiftyone-devicedetection-entrypoint-hook"
}
]
}
]
},
"raw-auction-request": {
"groups": [
{
"timeout": 100,
"hook-sequence": [
{
"module-code": "fiftyone-devicedetection",
"hook-impl-code": "fiftyone-devicedetection-raw-auction-request-hook"
}
]
}
]
}
}
}
}
}
```
Minimal sample (only required):
```yaml
modules:
fiftyone-devicedetection:
data-file:
path: "51Degrees-LiteV4.1.hash" # string, REQUIRED, download the sample from https://github.com/51Degrees/device-detection-data/blob/main/51Degrees-LiteV4.1.hash or Enterprise from https://51degrees.com/pricing
```
PBS-Go version of the same config:
```json

Check failure on line 96 in prebid-server/pbs-modules/51degrees-device-detection.md

View workflow job for this annotation

GitHub Actions / run markdownlint

Fenced code blocks should be surrounded by blank lines

prebid-server/pbs-modules/51degrees-device-detection.md:96 MD031/blanks-around-fences Fenced code blocks should be surrounded by blank lines [Context: "```json"] https://github.com/DavidAnson/markdownlint/blob/v0.33.0/doc/md031.md
{
"hooks": {
"modules": {
"fiftyone_degrees": {
"device_detection": {
"enabled": true,
"data_file": {
"path": "path/to/51Degrees-LiteV4.1.hash",
"update": {
"auto": true,
"url": "https://my.datafile.com/datafile.gz",
"polling_interval": 3600,
"license_key": "your_license_key",
"product": "V4Enterprise"
}
}
}
},
"host_execution_plan": {
"endpoints": {
"/openrtb2/auction": {
"stages": {
"entrypoint": {
"groups": [
{
"timeout": 100,
"hook_sequence": [
{
"module_code": "fiftyone-devicedetection",
"hook_impl_code": "fiftyone-devicedetection-entrypoint-hook"
}
]
}
]
},
"raw_auction_request": {
"groups": [
{
"timeout": 100,
"hook_sequence": [
{
"module_code": "fiftyone-devicedetection",
"hook_impl_code": "fiftyone-devicedetection-raw-auction-request-hook"
}
]
}
]
}
}
}
}
}
}
}
}
```

## List of module configuration options (same for PBS-Java and PBS-Go)

- `account-filter`

Check failure on line 156 in prebid-server/pbs-modules/51degrees-device-detection.md

View workflow job for this annotation

GitHub Actions / run markdownlint

Unordered list style

prebid-server/pbs-modules/51degrees-device-detection.md:156:1 MD004/ul-style Unordered list style [Expected: asterisk; Actual: dash] https://github.com/DavidAnson/markdownlint/blob/v0.33.0/doc/md004.md
- `allow-list` - _(list of strings)_ - A list of account IDs that are allowed to use this module. If empty, everyone is allowed. Full-string match is performed (whitespaces and capitalization matter). Defaults to empty.

Check failure on line 157 in prebid-server/pbs-modules/51degrees-device-detection.md

View workflow job for this annotation

GitHub Actions / run markdownlint

Unordered list style

prebid-server/pbs-modules/51degrees-device-detection.md:157:1 MD004/ul-style Unordered list style [Expected: asterisk; Actual: dash] https://github.com/DavidAnson/markdownlint/blob/v0.33.0/doc/md004.md
- `data-file`

Check failure on line 158 in prebid-server/pbs-modules/51degrees-device-detection.md

View workflow job for this annotation

GitHub Actions / run markdownlint

Unordered list style

prebid-server/pbs-modules/51degrees-device-detection.md:158:1 MD004/ul-style Unordered list style [Expected: asterisk; Actual: dash] https://github.com/DavidAnson/markdownlint/blob/v0.33.0/doc/md004.md
- `path` - _(string, **REQUIRED**)_ - The full path to the device detection data file. Sample file can be downloaded from [data repo on GitHub](https://github.com/51Degrees/device-detection-data/blob/main/51Degrees-LiteV4.1.hash).

Check failure on line 159 in prebid-server/pbs-modules/51degrees-device-detection.md

View workflow job for this annotation

GitHub Actions / run markdownlint

Unordered list style

prebid-server/pbs-modules/51degrees-device-detection.md:159:1 MD004/ul-style Unordered list style [Expected: asterisk; Actual: dash] https://github.com/DavidAnson/markdownlint/blob/v0.33.0/doc/md004.md
- `make-temp-copy` - _(boolean)_ - If true, the engine will create a temporary copy of the data file rather than using the data file directly. Defaults to false.

Check failure on line 160 in prebid-server/pbs-modules/51degrees-device-detection.md

View workflow job for this annotation

GitHub Actions / run markdownlint

Unordered list style

prebid-server/pbs-modules/51degrees-device-detection.md:160:1 MD004/ul-style Unordered list style [Expected: asterisk; Actual: dash] https://github.com/DavidAnson/markdownlint/blob/v0.33.0/doc/md004.md
- `update`

Check failure on line 161 in prebid-server/pbs-modules/51degrees-device-detection.md

View workflow job for this annotation

GitHub Actions / run markdownlint

Unordered list style

prebid-server/pbs-modules/51degrees-device-detection.md:161:1 MD004/ul-style Unordered list style [Expected: asterisk; Actual: dash] https://github.com/DavidAnson/markdownlint/blob/v0.33.0/doc/md004.md
- `auto` - _(boolean)_ - Enable/Disable auto update. Defaults to enabled. If enabled, the auto update system will automatically download and apply new data files for device detection.
- `on-startup` - _(boolean)_ - Enable/Disable update on startup. Defaults to enabled. If enabled, the auto update system will be used to check for an update before the device detection engine is created. If an update is available, it will be downloaded and applied before the pipeline is built and returned for use so this may take some time.
- `url` - _(string)_ - Configure the engine to use the specified URL when looking for an updated data file. Default is the 51Degrees update URL.
- `license-key` - _(string)_ - Set the license key used when checking for new device detection data files. Defaults to null.
- `watch-file-system` - _(boolean)_ - The DataUpdateService has the ability to watch a file on disk and refresh the engine as soon as that file is updated. This setting enables/disables that feature. Defaults to true.
- `polling-interval` - _(int, seconds)_ - Set the time between checks for a new data file made by the DataUpdateService in seconds. Default = 30 minutes.
- `performance`
- `profile` - _(string)_ - Set the performance profile for the device detection engine. Must be one of: LowMemory, MaxPerformance, HighPerformance, Balanced, BalancedTemp. Defaults to balanced.
- `concurrency` - _(int)_ - Set the expected number of concurrent operations using the engine. This sets the concurrency of the internal caches to avoid excessive locking. Default: 10.
- `difference` - _(int)_ - Set the maximum difference to allow when processing HTTP headers. The meaning of difference depends on the Device Detection API being used. The difference is the difference in hash value between the hash that was found, and the hash that is being searched for. By default this is 0. For more information see [51Degrees documentation](https://51degrees.com/documentation/_device_detection__hash.html).
- `allow-unmatched` - _(boolean)_ - If set to false, a non-matching User-Agent will result in properties without set values.
If set to true, a non-matching User-Agent will cause the 'default profiles' to be returned. This means that properties will always have values (i.e. no need to check .hasValue) but some may be inaccurate. By default, this is false.
- `drift` - _(int)_ - Set the maximum drift to allow when matching hashes. If the drift is exceeded, the result is considered invalid and values will not be returned. By default this is 0. For more information see [51Degrees documentation](https://51degrees.com/documentation/_device_detection__hash.html).

### Example:
```yaml
hooks:
modules:
fiftyone-devicedetection:
account-filter:
allow-list: [] # list of strings, account ids for enabled publishers, or empty for all
data-file:
path: ~ # string, REQUIRED, download the sample from https://github.com/51Degrees/device-detection-data/blob/main/51Degrees-LiteV4.1.hash or Enterprise from https://51degrees.com/pricing
make-temp-copy: ~ # boolean
update:
auto: ~ # boolean
on-startup: ~ # boolean
url: ~ # string
license-key: ~ # string
watch-file-system: ~ # boolean
polling-interval: ~ # int, seconds
performance:
profile: ~ # string, one of [LowMemory,MaxPerformance,HighPerformance,Balanced,BalancedTemp]
concurrency: ~ # int
difference: ~ # int
allow-unmatched: ~ # boolean
drift: ~ # int
```
## Running the demo (PBS-Java)
1. Build the server bundle JAR as described in [Build Project](https://github.com/prebid/prebid-server-java/blob/master/docs/build.md#build-project), e.g.
```bash
mvn clean package --file extra/pom.xml
```

2. Download `51Degrees-LiteV4.1.hash` from [GitHub](https://github.com/51Degrees/device-detection-data/blob/main/51Degrees-LiteV4.1.hash) and put it in the project root directory.

```bash
curl -o 51Degrees-LiteV4.1.hash -L https://github.com/51Degrees/device-detection-data/raw/main/51Degrees-LiteV4.1.hash
```

3. Start server bundle JAR as described in [Running project](https://github.com/prebid/prebid-server-java/blob/master/docs/run.md#running-project), e.g.

```bash
java -jar target/prebid-server-bundle.jar --spring.config.additional-location=sample/prebid-config-with-51d-dd.yaml
```

4. Run sample request against the server as described in [requests/README](https://github.com/prebid/prebid-server-java/blob/master/sample/requests/README.txt), e.g.

```bash
curl http://localhost:8080/openrtb2/auction --data @extra/modules/fiftyone-devicedetection/sample-requests/data.json
```

5. See the `device` object be enriched

```diff
"device": {
- "ua": "Mozilla/5.0 (Linux; Android 11; SM-G998W) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.198 Mobile Safari/537.36"
+ "ua": "Mozilla/5.0 (Linux; Android 11; SM-G998W) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.198 Mobile Safari/537.36",
+ "os": "Android",
+ "osv": "11.0",
+ "h": 3200,
+ "w": 1440,
+ "ext": {
+ "fiftyonedegrees_deviceId": "110698-102757-105219-0"
+ }
},
```

[Enterprise](https://51degrees.com/pricing) files can provide even more information:

```diff
"device": {
"ua": "Mozilla/5.0 (Linux; Android 11; SM-G998W) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.198 Mobile Safari/537.36",
+ "devicetype": 1,
+ "make": "Samsung",
+ "model": "SM-G998W",
"os": "Android",
"osv": "11.0",
"h": 3200,
"w": 1440,
+ "ppi": 516,
+ "pxratio": 3.44,
"ext": {
- "fiftyonedegrees_deviceId": "110698-102757-105219-0"
+ "fiftyonedegrees_deviceId": "110698-102757-105219-18092"
}
```

## Running the demo (PBS-Go)

1. Download dependencies:
```bash
go mod download
```

2. Replace the original config file `pbs.json` (placed in the repository root or in `/etc/config`) with the sample [config file](https://github.com/51Degrees/prebid-server/blob/feature/51Degrees-device-detection-module/modules/fiftyone_degrees/device_detection/sample/pbs.json):
```
cp modules/fiftyone_degrees/device_detection/sample/pbs.json pbs.json
```

3. Download `51Degrees-LiteV4.1.hash` from [[GitHub](https://github.com/51Degrees/device-detection-data/blob/main/51Degrees-LiteV4.1.hash)] and put it in the project root directory.

```bash
curl -o 51Degrees-LiteV4.1.hash -L https://github.com/51Degrees/device-detection-data/raw/main/51Degrees-LiteV4.1.hash
```

4. Create a directory for sample stored requests (needed for the server to run):
```bash
mkdir -p sample/stored
```

5. Start the server:
```bash
go run main.go
```

6. Run sample request:
```bash
curl \
--header "Content-Type: application/json" \
http://localhost:8000/openrtb2/auction \
--data @modules/fiftyone_degrees/device_detection/sample/request_data.json
```

## Maintainer contacts

Any suggestions or questions can be directed to [[email protected]](mailto:[email protected]) e-mail.

Or just open new [issue](https://github.com/prebid/prebid-server-java/issues/new) or [pull request](https://github.com/prebid/prebid-server-java/pulls) in this repository.

## Further Reading

- [Prebid Server Module List](/prebid-server/pbs-modules/index.html)
- [Building a Prebid Server Module](/prebid-server/developers/add-a-module.html)

0 comments on commit 75018c1

Please sign in to comment.