Device detection services for 51Degrees Pipeline

fiftyone.devicedetection.examples.shared.EvidenceHelper Class Reference

Static Public Member Functions

static List< Map< String, String > > setUpEvidence ()
 Prepare evidence for use in examples.
static List< Map< String, String > > getEvidenceList (File yamlFile, int max) throws IOException
 Load a Yaml file as a list of documents (each being a Map containing evidence).
static Iterable< Map< String, String > > getEvidenceIterable (File yamlFile) throws IOException
 Create an Iterable<Map<String, String>> for reading documents from the passed yamlFile.

Member Function Documentation

◆ getEvidenceIterable()

Iterable< Map< String, String > > fiftyone.devicedetection.examples.shared.EvidenceHelper.getEvidenceIterable ( File yamlFile) throws IOException
static

Create an Iterable<Map<String, String>> for reading documents from the passed yamlFile.

Parameters
yamlFilea yamlFile
Returns
an Iterable
Exceptions
IOExceptionfor file errors

◆ getEvidenceList()

List< Map< String, String > > fiftyone.devicedetection.examples.shared.EvidenceHelper.getEvidenceList ( File yamlFile,
int max ) throws IOException
static

Load a Yaml file as a list of documents (each being a Map containing evidence).

Parameters
yamlFilea yaml file
maxmaximum entries
Returns
a List
Exceptions
IOExceptionin case of error

◆ setUpEvidence()

List< Map< String, String > > fiftyone.devicedetection.examples.shared.EvidenceHelper.setUpEvidence ( )
static

Prepare evidence for use in examples.

A note on User-Agent Client Hint representations: There are 3 common ways to represent UACH:

  • HTTP header map
  • getHighEntropyValues() JS API call result in JSON format
  • Structured User Agent Object from OpenRTB 2.6

Links:

51Degrees historically used HTTP header map to represent User-Agent Client Hints and expected the evidence to be provided as HTTP headers (or same name query parameters). The header names in question are:

  • Sec-CH-UA
  • Sec-CH-UA-Platform
  • Sec-CH-UA-Mobile
  • Sec-CH-UA-Model
  • Sec-CH-UA-Full-Version-List
  • Sec-CH-UA-Platform-Version
  • Sec-CH-UA-Arch
  • Sec-CH-UA-Bitness

However in version 4.5 we introduced the ability to perform device detection using the 2 other User-Agent Client Hints representations as evidence (internally it is done through conversion to the HTTP-header representation but it's an implementation detail). The 2 evidence parameter names in question are: 51D_gethighentropyvalues and 51D_structureduseragent - the engine consumes them as either query or cookie params.

query.51D_gethighentropyvalues or cookie.51D_gethighentropyvalues is a base64-encoded JSON-string result of calling a getHighEntropyValues() API, that normally would return a value similar to the below:

{"architecture":"arm","brands":[{"brand":"Google Chrome","version":"131"},{"brand":"Chromium","version":"131"} ,{"brand":"Not_A Brand","version":"24"}],"fullVersionList":[{"brand":"Google Chrome","version":"131.0.6778.140"} ,{"brand":"Chromium","version":"131.0.6778.140"},{"brand":"Not_A Brand","version":"24.0.0.0"}], "mobile":false,"model":"","platform":"macOS","platformVersion":"15.1.1"}

to obtain the below evidence we called this JavaScript snippet in the Chrome browser dev console: btoa(JSON.stringify(await navigator.userAgentData.getHighEntropyValues( ['bitness', 'architecture','fullVersionList','model', 'platformVersion'])))

query.51D_structureduseragent or cookie.51D_structureduseragent is a JSON-string representation of User-Agent Client Hints used in the OpenRTB 2.6