Skip to content

Tracker metric

A tracker metric, should only use this as a child of tracker widget. It will render the metric that is defined.

Name Description
component tracker-metric
options see options below
child required, a widget to be rendered that would collect the tracker metrics
styles any styles

Options

Name Description
tracker required, the parent tracker
metric required, a tracker metric to be collected
title optional, can defined custom title (or set it to blank), this is useful if you want custom title widget for your metric
default optional, default value to apply to hidden metric
data a map of data to be sent to the metric, use this if you want to send specific value pairs to the metric (dropdown, radio list, etc)

Example

In the below example, meal-entry tracker has breakfast metric that is a checkbox. Below code will render the breakfast checkbox.

{
  "ux": {
    "component": "tracker",
    "options": {
      "tracker": "meal-entry"
    },
    "styles": {
      "root": {
        "padding": "10px 20px"
      }
    },
    "child": {
      "component": "grid",
      "children": [
          {
              "component": "tracker-metric",
              "options": {
                  "tracker": "meal-entry",
                  "metric": "breakfast"
              }
          },
          {
              "component": "tracker-metric",
              "options": {
                  "tracker": "meal-entry",
                  "metric": "someHiddenField",
                  "default": "123"                
              }
          }
      ]
    }
  }
}

Example with customt title

{
  "ux": {
    "component": "tracker",
    "options": {
      "tracker": "meal-entry"
    },
    "styles": {
      "root": {
        "padding": "10px 20px"
      }
    },
    "child": {
      "component": "grid",
      "children": [
          {
              "component": "text",
              "text": "Some custom title",
              "styles": {
                "color": "#767676",
                "fontSize": 24.0
              }
          },
          {
              "component": "tracker-metric",
              "options": {
                  "tracker": "meal-entry",
                  "metric": "breakfast",
                  "title": ""
              }
          },
          {
            "component": "tracker-metric",
            "options": {
              "tracker": "quiz-entry",
              "metric": "quiz",
              "data": {
                "source": {
                  "apple": 1,
                  "orange": 2
                }
              },
            }
          },
      ]
    }
  }
}