From 714ff3f0a3fe6134056e599efa31e628373f1612 Mon Sep 17 00:00:00 2001 From: Manoel Aranda Neto Date: Tue, 19 May 2026 17:11:41 +0200 Subject: [PATCH] docs: update Python SDK examples --- contents/docs/libraries/python/_snippets/contexts.mdx | 6 +++--- contents/docs/libraries/python/index.mdx | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/contents/docs/libraries/python/_snippets/contexts.mdx b/contents/docs/libraries/python/_snippets/contexts.mdx index 65b31986c2c1..c856eb8f2f01 100644 --- a/contents/docs/libraries/python/_snippets/contexts.mdx +++ b/contents/docs/libraries/python/_snippets/contexts.mdx @@ -60,7 +60,7 @@ with new_context(): You can disable this nesting behavior by passing `fresh=True` to `new_context`: ```python -from posthog import new_context +from posthog import new_context, tag with new_context(fresh=True): tag("some-key", "value-2") @@ -98,7 +98,7 @@ You can read more about identifying users in the [user identification documentat ### Contexts and sessions -Contexts can be associated with a session ID by calling `posthog.set_context_session`. Session IDs must be UUIDv7 strings. +Contexts can be associated with a session ID by calling `posthog.set_context_session`. When linking backend events to frontend sessions, use the session ID from the frontend SDK (PostHog session IDs are UUIDv7 strings). ```python from posthog import new_context, set_context_session @@ -148,7 +148,7 @@ with new_context(capture_exceptions=False): ### Decorating functions -The SDK exposes a function decorator. It takes the same arguments as `new_context` and provides a handy way to mark a whole function as being in a new context. For example: +The SDK exposes a function decorator. It takes the same `fresh` and `capture_exceptions` arguments as `new_context` and provides a handy way to mark a whole function as being in a new context. For example: ```python from posthog import scoped, identify_context diff --git a/contents/docs/libraries/python/index.mdx b/contents/docs/libraries/python/index.mdx index 9353c1764840..237d55f8ac25 100644 --- a/contents/docs/libraries/python/index.mdx +++ b/contents/docs/libraries/python/index.mdx @@ -171,7 +171,7 @@ posthog = Posthog("", enable_exception_autocapture=True, ...) You can also manually capture exceptions using the `capture_exception` method: ```python -posthog.capture_exception(e, 'user_distinct_id', properties=additional_properties) +posthog.capture_exception(e, distinct_id='user_distinct_id', properties=additional_properties) ``` Contexts automatically capture exceptions thrown inside them, unless disable it by passing `capture_exceptions=False` to `new_context()`.