From 1d4e06fdf382562ef834cb843639bed01f2eb2a4 Mon Sep 17 00:00:00 2001 From: Vasilije <8619304+Vasilije1990@users.noreply.github.com> Date: Mon, 30 Sep 2024 18:30:39 +0200 Subject: [PATCH] Add tasks for segment sync and posthog sync --- tools/daily_pypi_downloads.py | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/tools/daily_pypi_downloads.py b/tools/daily_pypi_downloads.py index d57092c3b..64a0956ed 100644 --- a/tools/daily_pypi_downloads.py +++ b/tools/daily_pypi_downloads.py @@ -49,6 +49,7 @@ downloads = None for entry in data['data']: if entry['date'] == date_str: downloads = entry['downloads'] + category = entry.get('category') break if downloads is None: @@ -61,16 +62,19 @@ message_id = f"cognee_downloads_{date_str}" distinct_id = str(uuid.uuid4()) # Send an event to PostHog -posthog.capture( - distinct_id=distinct_id, - event='cognee_downloads', - properties={ - 'date': date_str, - 'downloads': downloads, - } -) +event_name = 'cognee_lib_downloads_with_mirrors' if category == 'with_mirrors' else 'cognee_lib_downloads_without_mirrors' -print(f"Data for {date_str} updated in PostHog successfully.") +if event_name == 'cognee_lib_downloads_without_mirrors': + posthog.capture( + distinct_id=str(uuid.uuid4()), + event=event_name, + properties={ + 'category': category, + 'date': date_str, + 'downloads': downloads, + } + ) +print(f"Data for {date_str} updated in PostHog successfully. Downloads is {downloads}") # Update the state file with open(state_file, 'w') as f: