From 263379abf379108ad31fec8afbba7ee9936ab172 Mon Sep 17 00:00:00 2001 From: mungai-njoroge Date: Wed, 27 Sep 2023 22:06:45 +0300 Subject: [PATCH] debunce posthog events to every 5 minutes --- app/api/artist.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/app/api/artist.py b/app/api/artist.py index 19f7b741..28939874 100644 --- a/app/api/artist.py +++ b/app/api/artist.py @@ -20,10 +20,16 @@ from app.utils.threading import background api = Blueprint("artist", __name__, url_prefix="/") +ARTIST_VISIT_COUNT = 0 + @background def send_event(): - Telemetry.send_artist_visited() + global ARTIST_VISIT_COUNT + ARTIST_VISIT_COUNT += 1 + + if ARTIST_VISIT_COUNT % 5 == 0: + Telemetry.send_artist_visited() @api.route("/artist/", methods=["GET"])