From cbbb6a7d8595cc5e74fd8f119b85bcc235228d7d Mon Sep 17 00:00:00 2001 From: Ankush Menat Date: Fri, 5 May 2023 12:54:14 +0530 Subject: [PATCH] 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. --- frappe/desk/desktop.py | 4 ++++ frappe/utils/telemetry.py | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/frappe/desk/desktop.py b/frappe/desk/desktop.py index 8a8fbb54c1..801a47ed7b 100644 --- a/frappe/desk/desktop.py +++ b/frappe/desk/desktop.py @@ -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}) diff --git a/frappe/utils/telemetry.py b/frappe/utils/telemetry.py index 4042c0b65e..b5bc13dd57 100644 --- a/frappe/utils/telemetry.py +++ b/frappe/utils/telemetry.py @@ -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)