Metrics Helper¶
- class MetricsHelper()¶
A helper for common metrics tasks.
Arguments: - im (InteractionMachine) – The interaction machine that the metrics should be run on.
- MetricsHelper.add.sessions_between_states(state_from, state_to, label)¶
Adds an average metric that measures the amount of sessions between two state events. The metric will fire with a value of 1 plus the amount of new sessions between the two state events.
Arguments: - state_from (object) – The state where session counting should start.
- state_to (object) – The state where session counting should end.
- state_* (object) –
The name and action of the state, e.g.
{ state: 'states:foo', action: 'exit' }
- state_*.state (string) – The name of the state. Required.
- state_*.action (string) – The state action. Can be one of enter, exit, input, resume, and show. Defaults to enter.
- label (string) – The label for the metric. Defaults to sessions_between_$ACTIONFROM_$STATEFROM_$ACTIONTO_$STATETO where $ACTION_* is the specified action, and $STATE_* is the name of the state with all characters that are not a-zA-Z._ replaced with _.
- MetricsHelper.add.sessions_until_state(state, label)¶
Adds an average metric that counts the amount of sessions taken to reach the specified state action.
Arguments: - state (object) –
The name and action of the state to count actions for, e.g.
{ state: 'states:foo', action: 'exit' }
- state.state (string) – The name of the state to count the action for. Required.
- state.action (string) – The state action that should increment the count. Can be one of enter, exit, input, resume, and show. Defaults to enter.
- label (string) – The label for the metric. Defaults to sessions_until_$ACTION_$STATE where $ACTION is the specified action, and $STATE is the name of the state with all characters that are not a-zA-Z._ replaced with _.
- state (object) –
- MetricsHelper.add.time_between_states(state_from, state_to, label)¶
Adds an average metric that measures the amount of time taken between two state events. Metric stored as milliseconds.
Arguments: - state_from (object) – The state where timing should start.
- state_to (object) – The state where timing should end.
- state_* (object) –
The name and action of the state, e.g.
{ state: 'states:foo', action: 'exit' }
- state_*.state (string) – The name of the state. Required.
- state_*.action (string) – The state action. Can be one of enter, exit, input, resume, and show. Defaults to enter.
- label (string) – The label for the metric. Defaults to time_between_$ACTIONFROM_$STATEFROM_$ACTIONTO_$STATETO where $ACTION_* is the specified action, and $STATE_* is the name of the state with all characters that are not a-zA-Z._ replaced with _.
- MetricsHelper.add.total_sessions(label)¶
Adds inc and sum metrics that fires every time a new session is started.
Arguments: - label (string) – The label for the metric. Defaults to total_sessions
- MetricsHelper.add.total_state_actions(state, label)¶
Adds inc and sum metrics that fires every time the specified state action is triggered.
Arguments: - state (object) –
The name and action of the state to count actions for, e.g.
{ state: 'states:foo', action: 'exit' }
- state.state (string) – The name of the state to count the action for. Required.
- state.action (string) – The state action that should increment the count. Can be one of enter, exit, input, resume, and show. Defaults to enter.
- label (string) – The label for the metric. Defaults to total_action_$ACTION_$STATE where $ACTION is the specified action, and $STATE is the name of the state with all characters that are not a-zA-Z._ replaced with _.
- state (object) –
- MetricsHelper.add.total_unique_users(label)¶
Adds inc and sum metrics that fires every time a new session is started with a new user.
Arguments: - label (string) – The label for the metric. Defaults to unique_users
- MetricsHelper.add.tracker(start_trigger, end_trigger, metrics)¶
Allows the addition of multiple start/end metrics with one function.
Arguments: - start_trigger (object) – The action that should trigger the start of the metric.
- end_trigger (object) – The action that should trigger the end of the metric.
- *_trigger (object) –
The name and action of the state, e.g.
{ state: 'states:foo', action: 'exit' }
- metrics (object) –
The metrics and their labels that should be attached to the given triggers. Of the format metric_type: metric_label. metric_type can be one of time_between_states, sessions_between_states. e.g.
{ time_between_states: 'time_between_a_and_b' }
- MetricsHelper.add.trigger(trigger, metrics)¶
Allows the addition of multiple metrics on one trigger event.
Arguments: - trigger (object) –
The name and action of the state to trigger on, e.g.
{ state: 'states:foo', action: 'exit' }
- metrics (object) –
The metrics and their labels that should be attached to the given trigger. Of the format metric_type: metric_label. metric_type can be one of sessions_until_state, total_state_actions. e.g.
{ sessions_until_state: 'sessions_until_foo', total_state_actions: 'total_bar_completions' }
- trigger (object) –