From e0a7567f4fa083ee607d980cb9d7add161d8c00a Mon Sep 17 00:00:00 2001 From: David Newell Date: Fri, 6 Jun 2025 18:42:00 +0100 Subject: [PATCH 1/2] feat: add setup method --- posthog/__init__.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/posthog/__init__.py b/posthog/__init__.py index bafeb1c0..629a20f8 100644 --- a/posthog/__init__.py +++ b/posthog/__init__.py @@ -572,8 +572,7 @@ def shutdown(): _proxy("join") -def _proxy(method, *args, **kwargs): - """Create an analytics client if one doesn't exist and send to it.""" +def setup(): global default_client if not default_client: default_client = Client( @@ -602,6 +601,11 @@ def _proxy(method, *args, **kwargs): default_client.disabled = disabled default_client.debug = debug + +def _proxy(method, *args, **kwargs): + """Create an analytics client if one doesn't exist and send to it.""" + setup() + fn = getattr(default_client, method) return fn(*args, **kwargs) From b43dbfc692be34d0ea3612d779e0db7d747479a0 Mon Sep 17 00:00:00 2001 From: David Newell Date: Fri, 6 Jun 2025 18:43:45 +0100 Subject: [PATCH 2/2] changelog --- CHANGELOG.md | 15 ++++++++++----- posthog/version.py | 2 +- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5f025b18..84d59764 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,11 +1,16 @@ +## 4.3.3 - 2025-06-06 + +Add `setup()` function to initialise default client + ## 4.3.2 - 2025-06-06 Add context management: - - New context manager with `posthog.new_context()` - - Tag functions: `posthog.tag()`, `posthog.get_tags()`, `posthog.clear_tags()` - - Function decorator: - - `@posthog.scoped` - Creates context and captures exceptions thrown within the function - - Automatic deduplication of exceptions to ensure each exception is only captured once + +- New context manager with `posthog.new_context()` +- Tag functions: `posthog.tag()`, `posthog.get_tags()`, `posthog.clear_tags()` +- Function decorator: + - `@posthog.scoped` - Creates context and captures exceptions thrown within the function +- Automatic deduplication of exceptions to ensure each exception is only captured once ## 4.2.1 - 2025-6-05 diff --git a/posthog/version.py b/posthog/version.py index 223ba835..e5384a2b 100644 --- a/posthog/version.py +++ b/posthog/version.py @@ -1,4 +1,4 @@ -VERSION = "4.3.2" +VERSION = "4.3.3" if __name__ == "__main__": print(VERSION, end="") # noqa: T201