Demonstrates how to use the ShareUsage element directly to send evidence data to 51Degrees for usage sharing.
Demonstrates how to use the ShareUsage element directly to send evidence data to 51Degrees for usage sharing. This example shows how to:
- Build a pipeline with only a ShareUsage element (no device detection)
- Configure batch size (minimum entries per message)
- Configure sampling rate (share percentage)
- Process evidence from a YAML file
- Add custom identifiers to track the data source
This is useful for scenarios where you want to share usage data without performing device detection, or when you want fine-grained control over the share usage settings.
Note on Client IP Address: The client IP address is included in the shared evidence solely for deduplication purposes. This allows 51Degrees' machine learning algorithms to properly weight evidence coming from different sources versus repeated evidence from the same source. Without this, the training data could be skewed by over-representing certain device configurations.
Identifying the Data Source (usage-from): To help 51Degrees identify which customer or partner is sending usage data, you can add a custom "usage-from" header to the evidence. This is done by adding evidence with key header.usage-from and your company/application name as the value. In the XML packet sent to 51Degrees, this appears as: <header Name="usage-from">YourCompanyName</header>. Replace "YourCompanyName" in the USAGE_FROM_VALUE constant with your actual identifier before running this example.
This example requires a local data file. The free 'Lite' data file can be downloaded with the
scripts in the data GitHub repository, which
this repository includes at cxx/data. Fetch the submodules by running
git submodule update --init --recursive, then run
sh cxx/data/get-data-files.sh 51Degrees-LiteV4.1.hash from the repository root,
which saves the file as cxx/data/device-detection/51Degrees-LiteV4.1.hash.
The Lite data file is only used for illustration, and has limited accuracy and capabilities. The Enterprise data file has every property. Contact us about a copy.
Required PyPi Dependencies:
