chore: track onboarding progress

Easy self-onboarding has been hardest to get right in complex business
apps, even though we have worked on this for long long time we have no
clear idea on how well it works, or if it's severly lacking.

We want to improve this by first understanding how efficient current
system is.

This PR adds basic telemetry for which steps are being completed, which
are skipped and what onboarding group is dismissed completely.
This commit is contained in:
Ankush Menat 2023-05-05 12:54:14 +05:30
parent fa80cfd2cf
commit cbbb6a7d85
2 changed files with 6 additions and 2 deletions

View file

@ -617,4 +617,8 @@ def update_onboarding_step(name, field, value):
value: Value to be updated
"""
from frappe.utils.telemetry import capture
frappe.db.set_value("Onboarding Step", name, field, value)
capture(frappe.scrub(name), app="frappe_onboarding", properties={field: value})

View file

@ -40,8 +40,8 @@ def init_telemetry():
frappe.local.posthog = Posthog(posthog_project_id, host=posthog_host)
def capture(event, app):
def capture(event, app, **kwargs):
init_telemetry()
ph: Posthog = getattr(frappe.local, "posthog", None)
with suppress(Exception):
ph and ph.capture(frappe.local.site, f"{app}_{event}")
ph and ph.capture(distinct_id=frappe.local.site, event=f"{app}_{event}", **kwargs)