Building > Quick Guides > Performance > Telemetry
Performance data of certain user actions
Introduced in 4.2.0
, CHT has supported deployment of in-app training cards to facilitate remote training.
Since interaction with training cards logs telemetry data, it is possible to view the data directly from CouchDB. However, it is more useful when you can run queries that provide useful metrics about the usage of training cards aggregated across many users, and interactions.
With this in mind, it is typically easier to query the data using SQL from an analytics database. The couchDB data can be replicated using CHT Sync to a postgresql instance where you can then run the SQL queries.
This guide includes several SQL queries that can act as a starting point for identifying useful metrics.
Creating the following index can improve the performance of running these queries
CREATE INDEX idx_couchdb_users_meta_type ON couchdb_users_meta((doc->>'type'));
In these examples the training cards set has an ID of chp_self_assessment
which you can replace to get the metrics for any training card set.
SELECT
'chp_self_assessment' AS form_name,
COUNT(DISTINCT doc#>>'{metadata,user}') AS total_users_viewed
FROM
couchdb_users_meta
WHERE
doc->>'type' = 'telemetry'
AND COALESCE((doc#>>'{metrics,enketo:training:chp_self_assessment:add:render,count}')::int, 0) > 0;
SELECT
doc#>>'{metadata,user}' AS cht_user,
SUM((doc#>>'{metrics,enketo:training:chp_self_assessment:add:render,count}')::int) AS views_without_completion
FROM
couchdb_users_meta
WHERE
doc->>'type' = 'telemetry'
AND (doc#>>'{metrics,enketo:training:chp_self_assessment:add:render,count}')::int > 0
AND NOT (doc#>'{metrics}' ? 'enketo:training:chp_self_assessment:add:save')
GROUP BY
doc#>>'{metadata,user}'
ORDER BY
views_without_completion DESC;
SELECT
doc#>>'{metadata,user}' AS cht_user,
SUM((doc#>>'{metrics,enketo:training:chp_self_assessment:add:render,count}')::int) AS times_viewed
FROM
couchdb_users_meta
WHERE
doc->>'type' = 'telemetry'
AND COALESCE((doc#>>'{metrics,enketo:training:chp_self_assessment:add:render,count}')::int, 0) > 0
GROUP BY
doc#>>'{metadata,user}'
ORDER BY
times_viewed desc;
SELECT
doc#>>'{metadata,user}' AS cht_user,
SUM((doc#>>'{metrics,enketo:training:chp_self_assessment:add:quit,count}')::int) AS times_quit
FROM
couchdb_users_meta
WHERE
doc->>'type' = 'telemetry'
AND COALESCE((doc#>>'{metrics,enketo:training:chp_self_assessment:add:quit,count}')::int, 0) > 0
GROUP BY
doc#>>'{metadata,user}'
ORDER BY
times_quit desc;
SELECT DISTINCT
doc#>>'{metadata,user}' AS cht_user
FROM
couchdb_users_meta
WHERE
doc->>'type' = 'telemetry'
AND doc#>'{metrics}' ? 'enketo:training:chp_self_assessment:add:save';
SELECT
'chp_self_assessment' AS form_name,
COUNT(DISTINCT doc#>>'{metadata,user}') AS total_users_completed
FROM
couchdb_users_meta
WHERE
doc->>'type' = 'telemetry'
AND COALESCE((doc#>>'{metrics,enketo:training:chp_self_assessment:add:save,count}')::int, 0) > 0
SELECT DISTINCT
doc#>>'{metadata,user}' AS cht_user,
COALESCE(doc#>>'{metrics,enketo:training:chp_self_assessment:add:user_edit_time,max}','0')::int/1000 AS max_seconds_on_form,
COALESCE(doc#>>'{metrics,enketo:training:chp_self_assessment:add:user_edit_time,min}','0')::int/1000 AS min_seconds_on_form
FROM
couchdb_users_meta
WHERE
doc->>'type'='telemetry'
AND doc#>'{metrics}' ? 'enketo:training:chp_self_assessment:add:save'
Such queries are instrumental in understanding the effectiveness of deploying training cards. The insights gained from such queries that identify useful metrics can inform where users are struggling with training cards.
For instance, understanding why certain users quit the training repeatedly before completing the training.
Performance data of certain user actions
An overview of data flows in the CHT for analytics, impact monitoring, and data science
Was this page helpful?
Glad to hear it! Please tell us how we can improve.
Sorry to hear that. Please tell us how we can improve.