:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
import contextvars
from contextlib import contextmanager
from ee.hogai.utils.types.base import NodePath
node_path_context = contextvars.ContextVar[tuple[NodePath, ...]]("node_path_context")
@contextmanager
def set_node_path(node_path: tuple[NodePath, ...]):
token = node_path_context.set(node_path)
try:
yield
finally:
node_path_context.reset(token)
def get_node_path() -> tuple[NodePath, ...] | None:
try:
return node_path_context.get()
except LookupError:
return None