Skip to content

Commit d7e95c1

Browse files
authored
Fix plausible statistics (#3814)
1 parent 3ca72d2 commit d7e95c1

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

lego/utils/functions.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,16 @@ def request_plausible_statistics(obj: BasisModel, **kwargs) -> Response:
5555
date = f"{created_at},{now}" # Plausible wants the date on this schema: YYYY-MM-DD,YYYY-MM-DD
5656

5757
model_name = obj._meta.model_name
58+
slug = getattr(obj, "slug", None)
5859
url_root = kwargs.get("url_root", None)
5960

6061
if not (model_name or url_root):
6162
raise ValueError("Valid obj or url_root must be provided")
6263

63-
url_path = f"/{url_root or model_name + 's'}/{obj.id}*"
64+
page_url = url_root or model_name + "s"
65+
obj_url = slug or obj.id
66+
67+
url_path = f"/{page_url}/{obj_url}"
6468
filters = f"event:page=={quote(url_path)}"
6569

6670
api_url = (

0 commit comments

Comments
 (0)