brk-code

posthog-python の API リファレンス

posthog-python (posthog/posthog-python) の公開 API 138 件 —— クラス 41、関数 77、メソッド 20。実際のソースを静的解析して抽出した正確なシグネチャを掲載しています。

リポジトリ: posthog/posthog-python

種別件数
クラス41
関数77
メソッド20

API 一覧

funcbin.docs_scripts.generate_json_schemas.analyze_class(cls) -> dict
Analyze a class and return its documentation.
funcbin.docs_scripts.generate_json_schemas.analyze_function(func, name:str) -> dict
Analyze a function and return its documentation.
funcbin.docs_scripts.generate_json_schemas.extract_description_from_docstring(docstring:str) -> str
Extract main description from docstring.
funcbin.docs_scripts.generate_json_schemas.extract_details_from_docstring(docstring:str) -> str
Extract details section from docstring.
funcbin.docs_scripts.generate_json_schemas.extract_examples_from_docstring(docstring:str) -> list
Extract code examples from docstring.
funcbin.docs_scripts.generate_json_schemas.get_type_name(type_annotation) -> str
Convert type annotation to string name.
funcbin.docs_scripts.generate_json_schemas.parse_docstring_tags(docstring:str) -> dict
Parse tags from docstring Category section.
classposthog.Posthog
Public PostHog SDK client.
funcposthog.ai.anthropic.anthropic_converter.extract_anthropic_stop_reason(response:Any) -> Optional[str]
Extract stop reason from Anthropic response.
funcposthog.ai.anthropic.anthropic_converter.extract_anthropic_tools(kwargs:Dict[str, Any]) -> Optional[Any]
Extract tool definitions from Anthropic API kwargs.
funcposthog.ai.anthropic.anthropic_converter.extract_anthropic_web_search_count(response:Any) -> int
Extract web search count from Anthropic response.
funcposthog.ai.gateway.is_posthog_ai_gateway_url(base_url:Any) -> bool
Return True if base_url points at a known PostHog AI Gateway host.
funcposthog.ai.gateway.warn_if_posthog_ai_gateway(base_url:Any) -> None
Warn when an AI wrapper is pointed at the PostHog AI Gateway.
classposthog.ai.gemini.gemini_converter.GeminiPart
Represents a part in a Gemini message.
funcposthog.ai.gemini.gemini_converter.extract_gemini_stop_reason(response:Any) -> Optional[str]
Extract stop reason from Gemini response.
funcposthog.ai.gemini.gemini_converter.extract_gemini_stop_reason_from_chunk(chunk:Any) -> Optional[str]
Extract stop reason from a Gemini streaming chunk.
funcposthog.ai.gemini.gemini_converter.extract_gemini_tools(kwargs:Dict[str, Any]) -> Optional[Any]
Extract tool definitions from Gemini API kwargs.
funcposthog.ai.gemini.gemini_converter.extract_gemini_usage_from_chunk(chunk:Any) -> TokenUsage
Extract usage statistics from a Gemini streaming chunk.
funcposthog.ai.gemini.gemini_converter.extract_gemini_web_search_count(response:Any) -> int
Extract web search count from Gemini response.
funcposthog.ai.media.ensure_serializable(obj:Any) -> Any
Ensure an object is JSON-serializable, converting to str as fallback.
classposthog.ai.openai.openai.WrappedChat
Wrapper for OpenAI chat that tracks usage in PostHog.
funcposthog.ai.openai.openai_converter.extract_openai_content_from_chunk(chunk:Any, provider_type:str='chat') -> Optional[Any]
Extract content from an OpenAI streaming chunk.
funcposthog.ai.openai.openai_converter.extract_openai_stop_reason(response:Any) -> Optional[str]
Extract stop reason from OpenAI response.
funcposthog.ai.openai.openai_converter.extract_openai_tools(kwargs:Dict[str, Any]) -> Optional[Any]
Extract tool definitions from OpenAI API kwargs.
funcposthog.ai.openai.openai_converter.extract_openai_web_search_count(response:Any) -> int
Extract web search count from OpenAI response.
funcposthog.ai.openai.openai_converter.format_openai_input(messages:Optional[List[Dict[str, Any]]]=None, input_data:Optional[Any]=None) -> List[FormattedMessage]
Format OpenAI input messages.
funcposthog.ai.openai.openai_converter.format_openai_streaming_input(kwargs:Dict[str, Any], api_type:str='chat') -> Any
Format OpenAI streaming input based on API type.
classposthog.ai.prompts.CachedPrompt
Cached prompt with metadata.
classposthog.ai.prompts.PromptResult
Result of a prompt fetch with metadata about its source.
classposthog.ai.prompts.Prompts
Fetch and compile LLM prompts from PostHog.
methodposthog.ai.prompts.Prompts.clear_cache(name:Optional[str]=None, *version:Optional[int]=None) -> None
Clear cached prompts.
methodposthog.ai.prompts.Prompts.compile(prompt:str, variables:PromptVariables) -> str
Replace {{variableName}} placeholders with values.
classposthog.ai.types.FormattedFunctionCall
Formatted function/tool call content item.
classposthog.ai.types.FormattedImageContent
Formatted image content item.
classposthog.ai.types.FormattedMessage
Standardized message format for PostHog tracking.
classposthog.ai.types.FormattedTextContent
Formatted text content item.
classposthog.ai.types.ProviderResponse
Standardized provider response format.
classposthog.ai.types.TokenUsage
Token usage information for AI model responses.
funcposthog.ai.utils.extract_stop_reason(response:Any, provider:str) -> Optional[str]
Extract stop reason from response based on provider.
funcposthog.ai.utils.format_response(response, provider:str)
Format a regular (non-streaming) response.
funcposthog.ai.utils.get_model_params(kwargs:Dict[str, Any]) -> Dict[str, Any]
Extracts model parameters from the kwargs dictionary.
funcposthog.ai.utils.get_usage(response, provider:str) -> TokenUsage
Extract usage statistics from response based on provider.
classposthog.args.OptionalCaptureArgs
Optional arguments for the capture method.
classposthog.args.OptionalSetArgs
Optional arguments for the set method.
funcposthog.capture(event:str, **kwargs:Unpack[OptionalCaptureArgs]) -> Optional[str]
Capture anything a user does within your system.
funcposthog.capture_exception(exception:Optional[ExceptionArg]=None, **kwargs:Unpack[OptionalCaptureArgs]) -> Optional[str]
Capture exceptions that happen in your code.
classposthog.capture_mode.CaptureMode
Selects the capture wire protocol used for event ingestion.
classposthog.capture_v1.CaptureV1Error
Batch-level failure of a capture-v1 send.
classposthog.client.Client
This is the SDK reference for the PostHog Python SDK.
methodposthog.client.Client.capture(event:str, **kwargs:Unpack[OptionalCaptureArgs]) -> Optional[str]
Captures an event manually.
methodposthog.client.Client.capture_exception(exception:Optional[ExceptionArg], **kwargs:Unpack[OptionalCaptureArgs]) -> Optional[str]
Capture an exception for error tracking.
methodposthog.client.Client.flush(timeout_seconds:Optional[float]=10) -> None
Force a flush from the internal queue to the server.
methodposthog.client.Client.get_tags() -> Dict[str, Any]
Get all tags from the current context.
methodposthog.client.Client.identify_context(distinct_id:str) -> None
Identify the current context with a distinct ID.
methodposthog.client.Client.set(**kwargs:Unpack[OptionalSetArgs]) -> Optional[str]
Set properties on a person profile.
methodposthog.client.Client.set_context_device_id(device_id:str) -> None
Set the device ID for the current context.
methodposthog.client.Client.set_context_session(session_id:str) -> None
Set the session ID for the current context.
methodposthog.client.Client.shutdown() -> None
Flush all messages and cleanly shutdown the client.
methodposthog.client.Client.tag(name:str, value:Any) -> None
Add a tag to the current context.
classposthog.consumer.Consumer
Consumes the messages from the client's queue.
methodposthog.consumer.Consumer.next()
Return the next batch of items to upload.
methodposthog.consumer.Consumer.run()
Runs the consumer.
funcposthog.contexts.get_context_device_id() -> Optional[str]
Get the device ID for the current context.
funcposthog.contexts.get_context_distinct_id() -> Optional[str]
Get the distinct ID for the current context.
funcposthog.contexts.get_context_session_id() -> Optional[str]
Get the session ID for the current context.
funcposthog.contexts.get_tags() -> Dict[str, Any]
Get all tags from the current context.
funcposthog.contexts.set_code_variables_mask_url_credentials_context(enabled:bool) -> None
Whether to scrub credentials embedded in URLs/DSNs (e.g.
funcposthog.contexts.tag(key:str, value:Any) -> None
Add a tag to the current context.
classposthog.exception_utils.AnnotatedValue
Meta information for a data field in the event payload.
funcposthog.feature_flag_definitions()
Returns loaded feature flags.
classposthog.feature_flags.ConditionMatch
Outcome of evaluating a single condition group.
classposthog.flag_definition_cache.FlagDefinitionCacheData
Data structure for cached flag definitions.
funcposthog.flush(timeout_seconds:Optional[float]=10) -> None
Tell the client to flush all queued events.
funcposthog.get_remote_config_payload(key:str)
Get the payload for a remote config feature flag.
funcposthog.get_tags() -> Dict[str, Any]
Get all tags from the current context.
funcposthog.identify_context(distinct_id:str)
Identify the current context with a distinct ID.
classposthog.integrations.django.PosthogContextMiddleware
Middleware to automatically track Django requests.
classposthog.mcp.McpAnalytics
Handle returned by :func:`instrument`.
methodposthog.mcp.McpAnalytics.capture(event:str, properties:Optional[dict]=None) -> None
Capture a custom event for this server.
funcposthog.mcp._conversation_id.resolve_conversation_id(enabled:bool, args:Any, tool_name:Optional[str], missing_capability_tool_name:str) -> Tuple[Optional[str], bool]
Return ``(conversation_id, minted)``.
funcposthog.mcp._ids.deterministic_prefixed_id(prefix:MCPAnalyticsIDPrefix, value:str) -> str
Deterministic id derived from an arbitrary string.
funcposthog.mcp._instrument_lowlevel.instrument_low_level(server:Any, data:MCPAnalyticsData) -> None
Instrument a raw ``mcp.server.Server``.
funcposthog.mcp._instrumentation.read_tool_category(tool:Any) -> Optional[str]
Read a tool's product category from its ``_meta.category``.
classposthog.mcp._internal.MCPAnalyticsData
All per-server tracking state.
funcposthog.mcp._sanitization.sanitize_event(event:Dict[str, Any]) -> Dict[str, Any]
Sanitize an event's response, parameters, and user_intent.
funcposthog.mcp._sink.process_mcp_event(event:McpEvent, options:McpCaptureOptions) -> Optional[Tuple[Event, List[PostHogCaptureEvent]]]
Run an MCP event through the full transform.
funcposthog.mcp.asgi.autowire_stateless_mint(server:Any) -> None
Make stateless minting zero-config on the ``instrument()`` path.
classposthog.mcp.constants.PostHogMCPAnalyticsEvent
PostHog-owned event names.
classposthog.mcp.constants.PostHogMCPAnalyticsProperty
PostHog property wire-keys emitted on MCP events.
funcposthog.mcp.session.resolve_session_id(data:MCPAnalyticsData, mcp_session_id:Optional[str], *token:Optional[SessionTokenPayload]=None) -> str
Resolve the session id for a request.
classposthog.mcp.session_token.SessionTokenPayload
What a session token carries.
funcposthog.mcp.session_token.decode_session_id(value:Any) -> Optional[SessionTokenPayload]
Decode an ``Mcp-Session-Id`` value into a token payload.
funcposthog.mcp.session_token.read_mcp_session_header(headers:Any) -> Optional[str]
Read the ``mcp-session-id`` value off a headers mapping.
classposthog.mcp.types.MCPAnalyticsOptions
Configuration for ``instrument()``.
classposthog.mcp.types.PostHogCaptureEvent
A fully-built payload ready for ``Client.capture()``.
classposthog.mcp.types.UserIdentity
Resolved identity for a session.
classposthog.request.GetResponse
Response from a GET request with ETag support.
classposthog.request.HTTPAdapterWithSocketOptions
HTTPAdapter with configurable socket options.
funcposthog.request.determine_server_host(host:Optional[str]) -> str
Determines the server host to use.
funcposthog.request.disable_connection_reuse() -> None
Disable HTTP connection reuse for SDK requests.
funcposthog.request.enable_keep_alive() -> None
Enable TCP keepalive for SDK HTTP connections.
funcposthog.request.get(api_key:str, url:str, host:Optional[str]=None, timeout:Optional[int]=None, etag:Optional[str]=None) -> GetResponse
Make a GET request with optional ETag support.
funcposthog.request.normalize_host(host:Optional[str]) -> str
Normalize a configured host, defaulting blank values to DEFAULT_HOST.
funcposthog.request.post(api_key:str, host:Optional[str]=None, path:Optional[str]=None, gzip:bool=False, timeout:int=15, session:Optional[requests.Session]=None, **kwargs) -> requests.Response
Post the `kwargs` to the API
funcposthog.request.reset_sessions() -> None
Reset the global sessions.
funcposthog.request.set_socket_options(socket_options:Optional[SocketOptions]) -> None
Configure socket options for all SDK HTTP connections.
funcposthog.set(**kwargs:Unpack[OptionalSetArgs]) -> Optional[str]
Set properties on a user record.
funcposthog.set_context_session(session_id:str)
Set the session ID for the current context.
funcposthog.set_once(**kwargs:Unpack[OptionalSetArgs]) -> Optional[str]
Set properties on a user record, only if they do not yet exist.
funcposthog.shutdown() -> None
Flush all messages and cleanly shutdown the client.
funcposthog.tag(name:str, value:Any)
Add a tag to the current context.
classposthog.types.FeatureFlag
Detailed feature flag evaluation returned by the flags API.
classposthog.types.FeatureFlagError
Error type constants for the $feature_flag_error property.
methodposthog.types.FeatureFlagError.api_error(status:Union[int, str]) -> str
Generate API error string with status code.
classposthog.types.FlagMetadata
Feature flag metadata returned by the feature flag API.
classposthog.types.FlagReason
Reason metadata returned by the feature flag API.
classposthog.types.FlagsAndPayloads
Feature flag values and payloads keyed by feature flag key.
classposthog.types.FlagsResponse
Normalized response from the PostHog feature flags API.
classposthog.types.LegacyFlagMetadata
Legacy feature flag metadata containing only a payload.
funcposthog.utils.guess_timezone(dt:datetime) -> datetime
Attempts to convert a naive datetime to an aware datetime.
funcposthog.utils.is_naive(dt:datetime) -> bool
Determines if a given datetime.datetime is naive.
funcposthog.utils.total_seconds(delta:timedelta) -> float
Return the total number of seconds contained in the duration.
classsdk_compliance_adapter.adapter.RequestInfo
Information about an HTTP request made by the SDK
classsdk_compliance_adapter.adapter.SDKState
Tracks SDK internal state for test assertions
methodsdk_compliance_adapter.adapter.SDKState.get_state() -> Dict[str, Any]
Get current state as dict
methodsdk_compliance_adapter.adapter.SDKState.increment_captured()
Increment total events captured
methodsdk_compliance_adapter.adapter.SDKState.record_error(error:str)
Record an error
methodsdk_compliance_adapter.adapter.SDKState.reset()
Reset all state
funcsdk_compliance_adapter.adapter.capture()
Capture a single event
funcsdk_compliance_adapter.adapter.create_batch_id(batch:List[Dict]) -> str
Create a unique ID for a batch based on UUIDs
funcsdk_compliance_adapter.adapter.flush()
Force flush all pending events
funcsdk_compliance_adapter.adapter.get_feature_flag()
Evaluate a feature flag
funcsdk_compliance_adapter.adapter.get_state()
Get internal SDK state
funcsdk_compliance_adapter.adapter.health()
Health check endpoint
funcsdk_compliance_adapter.adapter.identify()
Identify a user
funcsdk_compliance_adapter.adapter.init()
Initialize the SDK client
funcsdk_compliance_adapter.adapter.main()
Main entry point
funcsdk_compliance_adapter.adapter.reset()
Reset SDK state

この情報について

掲載しているシグネチャは posthog/posthog-python の公開ソースコードを Python の ast モジュールで静的解析し、引数名・デフォルト値・ 型注釈・戻り値型をそのまま抽出したものです。実装コードは保存していません。 詳しくは仕組みの解説をご覧ください。

収録ライブラリ一覧(全 805 件)へ戻る