Introduction🔗
The derived property element works out new properties from properties that other elements in the Pipeline have already produced. It follows rules written in a short script, in YAML or JSON, with one script for each property it produces.
The element holds no data file, sends no request over the network and needs no Resource Key or License Key. It reads no evidence from the request either. Everything it reads is a property another element has already written into the flow data, so it goes in the Pipeline after those elements.
A script is for a property that follows simply from properties already in the flow data, such as putting a number into bands or combining two flags into one answer. Work that needs a network call, needs to keep something between requests, or needs the raw evidence (headers, query string or cookies) belongs in an element of your own instead, as Custom flow elements describes.
See the Specification for more technical details, and the script format reference for everything a script can say.
The properties it gives🔗
Each script writes one property, named by the script, into the element data under the key derived. A script that produces HumanConfidence is read as derived.HumanConfidence, and the cloud's JSON gives it as derived.humanconfidence.
The packages carry the scripts in the derived-properties repository, which you can add by name.
| Property | Values | Engines to add | Script |
HumanConfidence | High, Medium, Low or Unknown | Device Detection and IP Intelligence | HumanConfidence.yaml |
IsGdpr | True or False | IP Intelligence | IsGdpr.yaml |
HumanConfidence is described on Human Confidence overview. IsGdpr is defined by its script as "Whether the General Data Protection Regulation, or the United Kingdom's version of it, is likely to apply to the person making the request, judged from the country of the supplied location", and its script says that it is a default for a caller that knows nothing about its own position, and not a determination.
A script below version 1.0.0 is a draft and may change. Both of these are below 1.0.0 today.
Each script names every property it reads, so the elements that supply them have to be in the Pipeline, and the properties have to be in your data files or your Resource Key. Where one is missing, the property has no value and says why, as the next section describes.
Scripts of your own🔗
You can write a script for a property of your own. The authoring guide works through one from a blank file, and the script tester runs a script in a browser against values you type, showing which rule matched.
When a property has no value🔗
Where every property a script reads is available, the script's rules run and it gives a value. Where any one of them is not available, the property has no value, and its message names every property that could not be read and what the element that supplies it said. For IsGdpr, which reads the country code ip.CountryCode, the message has this shape.
Derived property 'IsGdpr' has no value because 1 source property was not available. 'ip.CountryCode' (element 'ip' has no value for 'CountryCode': ...). Usual causes are the element that supplies the property not being in the pipeline, the property being excluded in the engine configuration, the property not being included in the resource key, or JavaScript that populates the property not having run yet.
Where more than one property is not available, the count reads <n> source properties were not available and each property is named in turn.
There is no third state. A value that cannot be read as the type the script expects counts as not available, so a value such as Unknown or N/A never turns into false or zero.
When the Pipeline is built🔗
Building the element checks every script and reports every fault in one message, rather than stopping at the first one. Each fault names the script, where it came from, the place in the document and what is wrong.
Building the Pipeline then fails, naming the property, when no element in the Pipeline supplies a property a script reads, or when two derived property elements write a property of the same name. Where the elements sit is not checked, so the Aspect Engines that supply the properties can run in a parallel group ahead of the derived property element.
Configuration🔗
A script reaches the element in one of three ways, and one element can take all three.
- By name, for a script the package carries.
- From a file in your own environment, where a path can hold a wildcard such as
derived/*.yaml. - As text held by your own code, in YAML or JSON. This one is available in code only.
In a configuration file, Scripts names the scripts the package carries and ScriptFiles gives the paths of your own. Write each as one string with commas between the entries, not as a JSON array.
In PHP the builder name is the class's full name, written in JSON as "BuilderName": "fiftyone\\pipeline\\derivedproperty\\DerivedPropertyElement", the way other PHP elements are named on Building from configuration.
In Go, register derivedproperty.NewFromConfiguration with a core.BuilderRegistry under derivedproperty.BuilderName, then build the Pipeline with the registry's BuildFromConfiguration.
Using it🔗
The feature matrix shows which languages have the element.
The cloud🔗
The 51Degrees cloud gives a derived property by running this same element in its own Pipeline, so a cloud answer and an answer from your own servers come from the same script. Choose the property for your Resource Key like any other. Where a property a script reads was not available, the cloud gives the property as null with the reason alongside it, for example humanconfidencenullreason.
Example🔗
