Featurevisor

Building blocks

Segments

Segments are made up of conditions against various attributes. They are the groups of users that you can target in your features via rules.

Create a segment

Let's assume we already have a country attribute.

Now we with to create a segment that targets users from The Netherlands. We can do that by creating a segment:

segments/netherlands.yml
description: Users from The Netherlands
conditions:
- attribute: country
operator: equals
value: nl

The segment will match when the context in SDK contains an attribute country with value nl.

Conditions

Targeting everyone

You can target everyone via a segment by using asterisk * as the value in conditions:

segments/everyone.yml
description: Everyone
conditions: '*'

Attribute

The attribute is the name of the attribute you want to check against in the context.

Nested path

If you are using an attribute that is of type object, you can make use of dot separated paths to access nester properties, like myAttribute.nestedProperty.

Operator

There are numerous operators that can be used to compare the attribute value against given value. Find all supported operators in below section.

Value

The value property is the value you want to operator to compare against. The type of the value depends on the attribute being used.

Operators

These operators are supported as conditions:

OperatorType of attributeDescription
existsAttribute exists in context
notExistsAttribute does not exist
equalsanyEquals to
notEqualsanyNot equals to
greaterThaninteger, doubleGreater than
greaterThanOrEqualsinteger, doubleGreater than or equal to
lessThaninteger, doubleLess than
lessThanOrEqualsinteger, doubleLess than or equal to
containsstringContains string
notContainsstringDoes not contain string
startsWithstringStarts with string
endsWithstringEnds with string
instringIn array of strings
notInstringNot in array of strings
beforestring, dateDate comparison
afterstring, dateDate comparison
matchesstringMatches regex pattern
notMatchesstringDoes not match regex pattern
semverEqualsstringSemver equals to
semverNotEqualsstringSemver not equals to
semverGreaterThanstringSemver greater than
semverGreaterThanOrEqualsstringSemver greater than or equals
semverLessThanstringSemver less than
semverLessThanOrEqualsstringSemver less than or equals
includesarrayArray includes value
notIncludesarrayArray does not include value

Examples of each operator below:

equals

# ...
conditions:
- attribute: country
operator: equals
value: us

notEquals

# ...
conditions:
- attribute: country
operator: notEquals
value: us

greaterThan

# ...
conditions:
- attribute: age
operator: greaterThan
value: 21

greaterThanOrEquals

# ...
conditions:
- attribute: age
operator: greaterThanOrEquals
value: 18

lessThan

# ...
conditions:
- attribute: age
operator: lessThan
value: 65

lessThanOrEquals

# ...
conditions:
- attribute: age
operator: lessThanOrEquals
value: 64

contains

# ...
conditions:
- attribute: name
operator: contains
value: John

notContains

# ...
conditions:
- attribute: name
operator: notContains
value: Smith

startsWith

# ...
conditions:
- attribute: name
operator: startsWith
value: John

endsWith

# ...
conditions:
- attribute: name
operator: endsWith
value: Smith

in

# ...
conditions:
- attribute: country
operator: in
value:
- be
- nl
- lu

notIn

# ...
conditions:
- attribute: country
operator: notIn
value:
- fr
- gb
- de

before

# ...
conditions:
- attribute: date
operator: before
value: 2023-12-25T00:00:00Z

after

# ...
conditions:
- attribute: date
operator: after
value: 2023-12-25T00:00:00Z

semverEquals

# ...
conditions:
- attribute: version
operator: semverEquals
value: 1.0.0

semverNotEquals

# ...
conditions:
- attribute: version
operator: semverNotEquals
value: 1.0.0

semverGreaterThan

# ...
conditions:
- attribute: version
operator: semverGreaterThan
value: 1.0.0

semverGreaterThanOrEquals

# ...
conditions:
- attribute: version
operator: semverGreaterThanOrEquals
value: 1.0.0

semverLessThan

# ...
conditions:
- attribute: version
operator: semverLessThan
value: 1.0.0

semverLessThanOrEquals

# ...
conditions:
- attribute: version
operator: semverLessThanOrEquals
value: 1.0.0

exists

# ...
conditions:
- attribute: country
operator: exists

notExists

# ...
conditions:
- attribute: country
operator: notExists

includes

# ...
conditions:
- attribute: permissions
operator: includes
value: write

notIncludes

# ...
conditions:
- attribute: permissions
operator: notIncludes
value: write

matches

# ...
conditions:
- attribute: email
operator: matches
value: ^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$
# optional regex flags
regexFlags: i # case-insensitive

notMatches

# ...
conditions:
- attribute: email
operator: notMatches
value: ^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$
# optional regex flags
regexFlags: i # case-insensitive

Advanced conditions

Conditions can also be combined using and, or, and not operators.

and

# ...
conditions:
and:
- attribute: country
operator: equals
value: us
- attribute: device
operator: equals
value: iPhone

or

# ...
conditions:
or:
- attribute: country
operator: equals
value: us
- attribute: country
operator: equals
value: ca

not

# ...
conditions:
not:
- attribute: country
operator: equals
value: us

Complex

and and or can be combined to create complex conditions:

# ...
conditions:
- and:
- attribute: device
operator: equals
value: iPhone
- or:
- attribute: country
operator: equals
value: us
- attribute: country
operator: equals
value: ca

You can also nest and, or, and not operators:

# ...
conditions:
- not:
- or:
- attribute: country
operator: equals
value: us
- attribute: country
operator: equals
value: ca

Archiving

You can archive a segment by setting archived: true:

segments/netherlands.yml
archived: true
description: Users from The Netherlands
conditions:
- attribute: country
operator: equals
value: nl
Previous
Attributes