chore: track update actions per doctype
[skip ci]
This commit is contained in:
parent
69220a9a9e
commit
4f70200bd5
2 changed files with 8 additions and 5 deletions
|
|
@ -16,7 +16,7 @@ from frappe.utils.telemetry import capture_doc
|
|||
def savedocs(doc, action):
|
||||
"""save / submit / update doclist"""
|
||||
doc = frappe.get_doc(json.loads(doc))
|
||||
capture_doc(doc)
|
||||
capture_doc(doc, action)
|
||||
set_local_name(doc)
|
||||
|
||||
# action
|
||||
|
|
@ -47,6 +47,8 @@ def savedocs(doc, action):
|
|||
def cancel(doctype=None, name=None, workflow_state_fieldname=None, workflow_state=None):
|
||||
"""cancel a doclist"""
|
||||
doc = frappe.get_doc(doctype, name)
|
||||
capture_doc(doc, "Cancel")
|
||||
|
||||
if workflow_state_fieldname and workflow_state:
|
||||
doc.set(workflow_state_fieldname, workflow_state)
|
||||
doc.cancel()
|
||||
|
|
|
|||
|
|
@ -5,11 +5,10 @@ removed without any warning.
|
|||
"""
|
||||
from contextlib import suppress
|
||||
|
||||
from posthog import Posthog
|
||||
|
||||
import frappe
|
||||
from frappe.utils import getdate
|
||||
from frappe.utils.caching import site_cache
|
||||
from posthog import Posthog
|
||||
|
||||
POSTHOG_PROJECT_FIELD = "posthog_project_id"
|
||||
POSTHOG_HOST_FIELD = "posthog_host"
|
||||
|
|
@ -59,11 +58,13 @@ def capture(event, app, **kwargs):
|
|||
ph and ph.capture(distinct_id=frappe.local.site, event=f"{app}_{event}", **kwargs)
|
||||
|
||||
|
||||
def capture_doc(doc):
|
||||
def capture_doc(doc, action):
|
||||
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})
|
||||
capture("document_created", "frappe", properties={"doctype": doc.doctype, "action": "Insert"})
|
||||
else:
|
||||
capture("document_modified", "frappe", properties={"doctype": doc.doctype, "action": action})
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue