Eventvisor

Building blocks

Attributes

Attributes are contextual data about the environment your application runs in.

Examples

If you are building a web or mobile application, examples of attributes can be:

  • deviceId
  • userId
  • country
  • browser
  • os
  • ...etc

Defining attributes

If we choose to define a new attribute called deviceId, we can create a new file called deviceId.yml in the attributes directory:

attributes/deviceId.yml
description: Device ID
tags:
- web
type: string

The file name (without the extension) will be the name of the attribute.

Description

The description property is purely for documentation purposes:

attributes/deviceId.yml
# ...
description: Device ID

Tags

Tags are used to generate targeted datafiles for your applications:

attributes/deviceId.yml
# ...
tags:
- web
- mobile
- backend

Types

Based on [JSON Schema], we can chose from several different types for an attribute:

  • string
  • number (integer or float)
  • integer (whole number only)
  • boolean
  • object
  • array

string

attributes/myAttribute.yml
description: My attribute
tags:
- web
type: string

number

attributes/myAttribute.yml
description: My attribute
tags:
- web
type: number

integer

attributes/myAttribute.yml
description: My attribute
tags:
- web
type: integer

boolean

attributes/myAttribute.yml
description: My attribute
tags:
- web
type: boolean

object

attributes/myAttribute.yml
description: My attribute
tags:
- web
type: object
properties:
name:
type: string
version:
type: semver
required:
- name

array

attributes/myAttribute.yml
description: My attribute
tags:
- web
type: array
items:
type: string

Setting attribute values

In your application, you will be setting the attribute values using provided SDKs.

If we take JavaScript SDK as an example, we can set the attribute values like this:

eventvisor.setAttribute("myAttribute", "value");

If the value is not matching the schema, we will get a validation error in the console.

Deprecating

You can deprecate an attribute by adding deprecated: true to the attribute definition:

attributes/myAttribute.yml
# ...
deprecated: true

If deprecated, it will still continue to work as expected, but the SDKs will show a warning in the console notifying the developers to take action.

Archiving

You can archive an attribute by adding archived: true to the attribute definition:

attributes/myAttribute.yml
# ...
archived: true
Previous
Quick start
Next
Events