chore: track doc creation

This is alternate to "Activation" level that already exists, activation
level will be phased out over time.
This commit is contained in:
Ankush Menat 2023-05-29 13:27:15 +05:30
parent a2a84215b1
commit 2ed2f8747d
2 changed files with 12 additions and 0 deletions

View file

@ -9,12 +9,14 @@ from frappe.desk.form.load import run_onload
from frappe.model.docstatus import DocStatus
from frappe.monitor import add_data_to_monitor
from frappe.utils.scheduler import is_scheduler_inactive
from frappe.utils.telemetry import capture_doc
@frappe.whitelist()
def savedocs(doc, action):
"""save / submit / update doclist"""
doc = frappe.get_doc(json.loads(doc))
capture_doc(doc)
set_local_name(doc)
# action

View file

@ -57,3 +57,13 @@ def capture(event, app, **kwargs):
ph: Posthog = getattr(frappe.local, "posthog", None)
with suppress(Exception):
ph and ph.capture(distinct_id=frappe.local.site, event=f"{app}_{event}", **kwargs)
def capture_doc(doc):
with suppress(Exception):
age = site_age()
if not age or age > 15:
return
if doc.get("__islocal") or not doc.get("name"):
capture("document_created", "frappe", properties={"doctype": doc.doctype})