Skip to content

docs: restore missing Python 8 reference details in docstrings - #1312

Open
gewenyu99 wants to merge 4 commits into
mainfrom
vincent/python-reference-docstring-gaps
Open

gewenyu99 wants to merge 4 commits into
mainfrom
vincent/python-reference-docstring-gaps

Conversation

@gewenyu99

@gewenyu99 gewenyu99 commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

💡 Motivation and Context

Problem

The Python 8 reference is missing guidance from the retired posthog.com docs, and the generated Markdown has 4-column tables with empty Type cells, raw <details> blocks, and hard-wrapped prose.

Changes

  • Ported missing Python 8 guidance into docs/getting-started.md, client and module docstrings, and Django/DRF docs, and warned when context helpers no-op outside with new_context():.
  • Updated bin/docs_scripts/generate_markdown.py to export DRF exception handlers, fold parameter tables to 2 columns, unwrap docstring prose, and put - in unannotated Returns: rows.
  • Replaced raw <details> blocks in docstrings with Markdown tables and fenced code blocks.

1. Missing reference docs (AsyncClient)

Before

No docstring on AsyncClient.__init__ (only the raw function signature rendered).

After

Create an async PostHog client. Import it as AsyncPosthog from posthog.

Keep one client for your app's lifetime on one event loop. Open it with async with AsyncPosthog(...), or call await shutdown() on teardown.

Know what to await

Queue methods write to memory and return right away. Network reads and lifecycle calls are coroutines.

Call Methods Reach for it when
Don't await capture, capture_ai, set, set_once, group_identify, alias, capture_exception Queueing events on the request path without waiting on HTTP
await capture_immediate, capture_ai_immediate A handler must confirm the upload attempt finished before returning
await evaluate_flags, get_remote_config_payload, emails.send, emails.get, flush, shutdown, join Evaluating flags, sending emails, or draining queues on the event loop
The differences from Client

Constructor options match Client(...), except in four places:

  • Remote flags only. secret_key authenticates get_remote_config_payload() and emails. AsyncPosthog doesn't poll flag definitions locally.
  • Async callbacks. before_send and on_error accept regular functions or async def coroutines.
  • Shared contexts. AsyncPosthog has no context methods. Open a context with posthog.new_context(), posthog.scoped(), or PosthogASGIMiddleware, then call posthog.identify_context() and posthog.tag() inside it.
  • Sync-only features. start_span() and sync_mode live on sync Posthog only.

2. Dense prose into scannable bullets (AsyncClient.emails)

Before

Send transactional email from PostHog email templates or from content
in your code, and read the status of each email sent with get.

Needs secret_key, a project secret API key with the transactional_email:write
scope, and posthog[async]. Sends go to app_host, or to the PostHog
Cloud app host of host. email_request_timeout_seconds and
email_request_max_retries configure each send. A disabled or shut-down
client sends nothing. See posthog.emails for setup.

After

Send transactional email from PostHog templates or inline code, and read delivery status with get.

  • Requirements. Needs posthog[async] and a secret_key project secret API key with the transactional_email:write scope.
  • Routing. Sends go to app_host, or to the PostHog Cloud app host of host.
  • Retries and timeouts. Configured by email_request_timeout_seconds and email_request_max_retries.
  • Lifecycle. A disabled or shut-down client sends nothing. See posthog.emails for full setup.

3. 4-column parameter tables folded into 2 columns (Client(...) excerpt)

Before

Name Type Description Default
project_api_key str PostHog project API key/token. required
host PostHog host. Defaults to the US ingestion endpoint when not set. App hosts such as https://us.posthog.com are mapped to the corresponding ingestion host. None
timeout float HTTP request timeout in seconds for event uploads. 15
disable_geoip Whether to disable server-side GeoIP enrichment. Defaults to True. Events get $geoip_disable only when the event, context tags and super_properties leave it unset. True

After

Name Description
project_api_key str. PostHog project API key/token. Required.
host PostHog host. Defaults to the US ingestion endpoint when not set. App hosts such as https://us.posthog.com are mapped to the corresponding ingestion host. Default: None.
timeout float. HTTP request timeout in seconds for event uploads. Default: 15.
disable_geoip Whether to disable server-side GeoIP enrichment. Defaults to True. Events get $geoip_disable only when the event, context tags and super_properties leave it unset. Set $ip in event properties to geolocate from a client IP. Default: True.

4. Raw <details> blocks and hard-wrapped prose (UnresolvedFlagReason)

Before

Reported by FeatureFlagEvaluations.unresolved_flags. Inheriting from
str keeps the members directly comparable to their string values. When more
than one cause applies, the first reason in the order below is reported.

Values

EXPERIENCE_CONTINUITY: The flag has experience continuity enabled, which
local evaluation never resolves. Change the flag to fix it.
UNSUPPORTED_DEFINITION: The flag uses something the local evaluator does not
support, such as a static cohort, an unknown operator or filter type, a
malformed value, a dependency with no loaded definition or a circular
dependency. Change the flag or upgrade the SDK to fix it.
UNRESOLVED_DEPENDENCY: A flag this flag depends on has a loaded definition
but was unresolved.
MISSING_CONTEXT: The call did not pass a property, group property or device
id the flag needs, or passed it in an unusable form. Pass it to fix it.

After

Reported by FeatureFlagEvaluations.unresolved_flags. Inheriting from str keeps the members directly comparable to their string values. When more than one cause applies, the first reason in the order below is reported:

Reason Cause
EXPERIENCE_CONTINUITY The flag has experience continuity enabled, which local evaluation never resolves. Change the flag to fix it.
UNSUPPORTED_DEFINITION The flag uses something the local evaluator doesn't support, such as a static cohort, an unknown operator or filter type, a malformed value, a dependency with no loaded definition, or a circular dependency. Change the flag or upgrade the SDK to fix it.
UNRESOLVED_DEPENDENCY A flag this flag depends on has a loaded definition but was unresolved.
MISSING_CONTEXT The call didn't pass a property, group property, or device ID the flag needs, or passed it in an unusable form. Pass it to fix it.

💚 How did you test it?

  • python bin/docs_scripts/generate_markdown.py --sdk-specs ../sdk-specs (Python 3.11.11, griffe==2.0.2): regenerated references/posthog-python-8.md and references/posthog-python-reference.md.
  • pytest posthog/test/test_reference_markdown.py .github/scripts/test_check_public_api.py: 23 passed (4 new).
  • ruff format --check . (423 files), ruff check ., python .github/scripts/check_public_api.py, and git diff --check: all passed.

📝 Checklist

  • All commits are signed (see Commit signing)
  • I reviewed the submitted code.
  • I added tests to verify the changes.
  • I updated the docs if needed.
  • No breaking change or entry added to the changelog.

If releasing new changes

  • Ran sampo add to generate a changeset file (docstrings, reference generator, and tests only)

🤖 Agent context

Autonomy: Human-driven (agent-assisted)

  • Built with Antigravity, Python 3.11.11, griffe==2.0.2, pytest, ruff, and gh.
  • Audited retired posthog.com Python docs against v8 docstrings, kept Client.new_context links from #1272 and UnresolvedFlagReason wording from #1288, moved emails.send and emails.get under await in AsyncClient, and updated generate_markdown.py instead of hand-editing generated docs.

@gewenyu99 gewenyu99 self-assigned this Nov 26, 2026
@gewenyu99
gewenyu99 marked this pull request as ready for review November 26, 2026 16:00
@gewenyu99
gewenyu99 requested a review from a team as a code owner November 26, 2026 16:00
@veria-ai

veria-ai Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

PR overview

No security issues were found in this pull request.

Reviews

Comment thread posthog/__init__.py Outdated
```python
from posthog import set_context_session
set_context_session("session_123")
set_context_session("0190f6d2-7c1e-7b3a-9f5e-1c2d3e4f5a6b")

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Revert this. it's a place holder whta are you doing gemini

@github-actions

github-actions Bot commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

SDK performance: posthog-python

Benchmarks completed. No changes flagged for review.

Flags require at least a 5% change in the median and all six pairs agreeing on direction. This is a noise filter, not proof of a performance change or a CI gate.

View all results
Test Measurement Before PR With PR Change Assessment
Capture and deliver events (32-byte payload, burst)
Shard: capture
Managed heap after settling — — — unavailable; base:​ unsupported; head:​ unsupported; base:​ CPython has no uninstrumented total managed-heap byte counter; tracing would distort this RSS pass.​; head:​ CPython has no uninstrumented total managed-heap byte counter; tracing would distort this RSS pass.​
Capture and deliver events (4,096-byte payload, burst)
Shard: capture
Managed heap after settling — — — unavailable; base:​ unsupported; head:​ unsupported; base:​ CPython has no uninstrumented total managed-heap byte counter; tracing would distort this RSS pass.​; head:​ CPython has no uninstrumented total managed-heap byte counter; tracing would distort this RSS pass.​
Capture and deliver events (32-byte payload, steady)
Shard: capture
Managed heap after settling — — — unavailable; base:​ unsupported; head:​ unsupported; base:​ CPython has no uninstrumented total managed-heap byte counter; tracing would distort this RSS pass.​; head:​ CPython has no uninstrumented total managed-heap byte counter; tracing would distort this RSS pass.​
Capture and deliver events (4,096-byte payload, steady)
Shard: capture
Managed heap after settling — — — unavailable; base:​ unsupported; head:​ unsupported; base:​ CPython has no uninstrumented total managed-heap byte counter; tracing would distort this RSS pass.​; head:​ CPython has no uninstrumented total managed-heap byte counter; tracing would distort this RSS pass.​
Queue an event (32-byte payload)
Shard: capture
Allocated memory per operation — — — unavailable; base:​ unsupported; head:​ unsupported; base:​ Background preparation has no public completion boundary before flush; see capture.​drain for full-pipeline allocations.​; head:​ Background preparation has no public completion boundary before flush; see capture.​drain for full-pipeline allocations.​
Queue an event (32-byte payload)
Shard: capture
Allocations per operation — — — unavailable; base:​ unsupported; head:​ unsupported; base:​ Background preparation has no public completion boundary before flush; see capture.​drain for full-pipeline allocations.​; head:​ Background preparation has no public completion boundary before flush; see capture.​drain for full-pipeline allocations.​
Queue an event (4,096-byte payload)
Shard: capture
Allocated memory per operation — — — unavailable; base:​ unsupported; head:​ unsupported; base:​ Background preparation has no public completion boundary before flush; see capture.​drain for full-pipeline allocations.​; head:​ Background preparation has no public completion boundary before flush; see capture.​drain for full-pipeline allocations.​
Queue an event (4,096-byte payload)
Shard: capture
Allocations per operation — — — unavailable; base:​ unsupported; head:​ unsupported; base:​ Background preparation has no public completion boundary before flush; see capture.​drain for full-pipeline allocations.​; head:​ Background preparation has no public completion boundary before flush; see capture.​drain for full-pipeline allocations.​
Evaluate 1,000 flags under concurrent load
Shard: flags-memory
Managed heap after settling — — — unavailable; base:​ unsupported; head:​ unsupported; base:​ CPython has no uninstrumented total managed-heap byte counter; tracing would distort this RSS pass.​; head:​ CPython has no uninstrumented total managed-heap byte counter; tracing would distort this RSS pass.​
Refresh 1,000 flag definitions
Shard: flags-memory
Managed heap after settling — — — unavailable; base:​ unsupported; head:​ unsupported; base:​ CPython has no uninstrumented total managed-heap byte counter; tracing would distort this RSS pass.​; head:​ CPython has no uninstrumented total managed-heap byte counter; tracing would distort this RSS pass.​
Capture and deliver events (32-byte payload, burst)
Shard: capture
Allocated memory per operation 133.67 KiB/op 133.67 KiB/op <0.1% more memory Not flagged
Capture and deliver events (32-byte payload, burst)
Shard: capture
Allocations per operation 1,345.51 count/op 1,345.52 count/op <0.1% more Not flagged
Capture and deliver events (32-byte payload, burst)
Shard: capture
Time per operation 76.15 µs/op 76.16 µs/op <0.1% more time Not flagged
Capture and deliver events (32-byte payload, burst)
Shard: capture
Idle process memory (RSS) 37.68 MiB 37.64 MiB 0.1% less memory Not flagged
Capture and deliver events (32-byte payload, burst)
Shard: capture
Observed peak process memory (RSS) 40.13 MiB 40.09 MiB <0.1% less memory Not flagged
Capture and deliver events (32-byte payload, burst)
Shard: capture
Process memory after settling (RSS) 40.13 MiB 40.09 MiB <0.1% less memory Not flagged
Capture and deliver events (32-byte payload, burst)
Shard: capture
Process CPU time per operation 79.58 µs/op 79.08 µs/op 0.6% less time Not flagged
Capture and deliver events (32-byte payload, burst)
Shard: capture
Lifetime peak process memory (RSS) 40.61 MiB 40.61 MiB No observed change Not flagged
Capture and deliver events (4,096-byte payload, burst)
Shard: capture
Allocated memory per operation 185.75 KiB/op 185.75 KiB/op No observed change Not flagged
Capture and deliver events (4,096-byte payload, burst)
Shard: capture
Allocations per operation 1,337.51 count/op 1,337.51 count/op No observed change Not flagged
Capture and deliver events (4,096-byte payload, burst)
Shard: capture
Time per operation 98.46 µs/op 99 µs/op 0.6% more time Not flagged
Capture and deliver events (4,096-byte payload, burst)
Shard: capture
Idle process memory (RSS) 41.25 MiB 41.21 MiB 0.1% less memory Not flagged
Capture and deliver events (4,096-byte payload, burst)
Shard: capture
Observed peak process memory (RSS) 47.04 MiB 46.99 MiB <0.1% less memory Not flagged
Capture and deliver events (4,096-byte payload, burst)
Shard: capture
Process memory after settling (RSS) 47.04 MiB 46.99 MiB <0.1% less memory Not flagged
Capture and deliver events (4,096-byte payload, burst)
Shard: capture
Process CPU time per operation 96.53 µs/op 96.57 µs/op <0.1% more time Not flagged
Capture and deliver events (4,096-byte payload, burst)
Shard: capture
Lifetime peak process memory (RSS) 51.42 MiB 51.46 MiB <0.1% more memory Not flagged
Capture and deliver events (32-byte payload, steady)
Shard: capture
Allocated memory per operation 138.73 KiB/op 138.73 KiB/op <0.1% more memory Not flagged
Capture and deliver events (32-byte payload, steady)
Shard: capture
Allocations per operation 1,390.28 count/op 1,390.3 count/op <0.1% more Not flagged
Capture and deliver events (32-byte payload, steady)
Shard: capture
Time per operation 87.7 µs/op 88.31 µs/op 0.7% more time Not flagged
Capture and deliver events (32-byte payload, steady)
Shard: capture
Idle process memory (RSS) 37.6 MiB 37.53 MiB 0.2% less memory Not flagged
Capture and deliver events (32-byte payload, steady)
Shard: capture
Observed peak process memory (RSS) 37.78 MiB 37.68 MiB 0.3% less memory Not flagged
Capture and deliver events (32-byte payload, steady)
Shard: capture
Process memory after settling (RSS) 37.78 MiB 37.68 MiB 0.3% less memory Not flagged
Capture and deliver events (32-byte payload, steady)
Shard: capture
Process CPU time per operation 89.71 µs/op 89.84 µs/op 0.1% more time Not flagged
Capture and deliver events (32-byte payload, steady)
Shard: capture
Lifetime peak process memory (RSS) 40.61 MiB 40.61 MiB No observed change Not flagged
Capture and deliver events (4,096-byte payload, steady)
Shard: capture
Allocated memory per operation 190.9 KiB/op 190.9 KiB/op <0.1% less memory Not flagged
Capture and deliver events (4,096-byte payload, steady)
Shard: capture
Allocations per operation 1,382.19 count/op 1,382.19 count/op <0.1% fewer Not flagged
Capture and deliver events (4,096-byte payload, steady)
Shard: capture
Time per operation 104.89 µs/op 104.86 µs/op <0.1% less time Not flagged
Capture and deliver events (4,096-byte payload, steady)
Shard: capture
Idle process memory (RSS) 41.13 MiB 41.14 MiB <0.1% more memory Not flagged
Capture and deliver events (4,096-byte payload, steady)
Shard: capture
Observed peak process memory (RSS) 41.58 MiB 41.58 MiB <0.1% more memory Not flagged
Capture and deliver events (4,096-byte payload, steady)
Shard: capture
Process memory after settling (RSS) 41.19 MiB 41.19 MiB <0.1% less memory Not flagged
Capture and deliver events (4,096-byte payload, steady)
Shard: capture
Process CPU time per operation 101.27 µs/op 103.12 µs/op 1.8% more time Not flagged
Capture and deliver events (4,096-byte payload, steady)
Shard: capture
Lifetime peak process memory (RSS) 41.52 MiB 41.53 MiB <0.1% more memory Not flagged
Queue an event (32-byte payload)
Shard: capture
Caller-thread CPU time per operation 56.64 µs/op 56.81 µs/op 0.3% more time Not flagged
Queue an event (32-byte payload)
Shard: capture
Time per operation 56.64 µs/op 56.81 µs/op 0.3% more time Not flagged
Queue an event (4,096-byte payload)
Shard: capture
Caller-thread CPU time per operation 56.92 µs/op 56.79 µs/op 0.2% less time Not flagged
Queue an event (4,096-byte payload)
Shard: capture
Time per operation 57.39 µs/op 56.89 µs/op 0.9% less time Not flagged
Evaluate all 10 flags
Shard: flags-scaling
Allocated memory per operation 233.85 KiB/op 233.85 KiB/op No observed change Not flagged
Evaluate all 10 flags
Shard: flags-scaling
Allocations per operation 2,352.93 count/op 2,352.93 count/op No observed change Not flagged
Evaluate all 10 flags
Shard: flags-scaling
Time per operation 142.41 µs/op 140.59 µs/op 1.3% less time Not flagged
Evaluate all 10 flags
Shard: flags-scaling
Process CPU time per operation 142.4 µs/op 140.58 µs/op 1.3% less time Not flagged
Evaluate all 100 flags
Shard: flags-scaling
Allocated memory per operation 2.25 MiB/op 2.25 MiB/op No observed change Not flagged
Evaluate all 100 flags
Shard: flags-scaling
Allocations per operation 23,148.75 count/op 23,148.75 count/op No observed change Not flagged
Evaluate all 100 flags
Shard: flags-scaling
Time per operation 1.32 ms/op 1.32 ms/op 0.2% more time Not flagged
Evaluate all 100 flags
Shard: flags-scaling
Process CPU time per operation 1.32 ms/op 1.32 ms/op 0.2% more time Not flagged
Evaluate all 1,000 flags
Shard: flags-scaling
Allocated memory per operation 22.45 MiB/op 22.45 MiB/op No observed change Not flagged
Evaluate all 1,000 flags
Shard: flags-scaling
Allocations per operation 231,005.5 count/op 231,005.5 count/op No observed change Not flagged
Evaluate all 1,000 flags
Shard: flags-scaling
Time per operation 12.87 ms/op 12.83 ms/op 0.3% less time Not flagged
Evaluate all 1,000 flags
Shard: flags-scaling
Process CPU time per operation 12.87 ms/op 12.82 ms/op 0.3% less time Not flagged
Evaluate 1,000 flags under concurrent load
Shard: flags-memory
Idle process memory (RSS) 43.98 MiB 44.02 MiB 0.1% more memory Not flagged
Evaluate 1,000 flags under concurrent load
Shard: flags-memory
Observed peak process memory (RSS) 44.32 MiB 44.36 MiB 0.1% more memory Not flagged
Evaluate 1,000 flags under concurrent load
Shard: flags-memory
Process memory after settling (RSS) 44.32 MiB 44.36 MiB 0.1% more memory Not flagged
Evaluate 1,000 flags under concurrent load
Shard: flags-memory
Lifetime peak process memory (RSS) 44.12 MiB 44.08 MiB <0.1% less memory Not flagged
Refresh 1,000 flag definitions
Shard: flags-memory
Idle process memory (RSS) 43.09 MiB 43.09 MiB No observed change Not flagged
Refresh 1,000 flag definitions
Shard: flags-memory
Observed peak process memory (RSS) 43.1 MiB 43.1 MiB No observed change Not flagged
Refresh 1,000 flag definitions
Shard: flags-memory
Process memory after settling (RSS) 43.1 MiB 43.1 MiB No observed change Not flagged
Refresh 1,000 flag definitions
Shard: flags-memory
Lifetime peak process memory (RSS) 43.36 MiB 42.97 MiB 0.9% less memory Not flagged
Evaluate one boolean flag
Shard: flags-single
Allocated memory per operation 15.74 KiB/op 15.74 KiB/op No observed change Not flagged
Evaluate one boolean flag
Shard: flags-single
Allocations per operation 162.77 count/op 162.77 count/op No observed change Not flagged
Evaluate one boolean flag
Shard: flags-single
Time per operation 14.02 µs/op 14.01 µs/op <0.1% less time Not flagged
Evaluate one boolean flag
Shard: flags-single
Process CPU time per operation 14.02 µs/op 14.01 µs/op 0.1% less time Not flagged
Evaluate a cohort-filtered flag
Shard: flags-single
Allocated memory per operation 25.28 KiB/op 25.28 KiB/op No observed change Not flagged
Evaluate a cohort-filtered flag
Shard: flags-single
Allocations per operation 245.28 count/op 245.28 count/op No observed change Not flagged
Evaluate a cohort-filtered flag
Shard: flags-single
Time per operation 22.75 µs/op 22.99 µs/op 1% more time Not flagged
Evaluate a cohort-filtered flag
Shard: flags-single
Process CPU time per operation 22.75 µs/op 22.98 µs/op 1% more time Not flagged
Evaluate a flag (early match)
Shard: flags-single
Allocated memory per operation 41.36 KiB/op 41.36 KiB/op No observed change Not flagged
Evaluate a flag (early match)
Shard: flags-single
Allocations per operation 401.77 count/op 401.77 count/op No observed change Not flagged
Evaluate a flag (early match)
Shard: flags-single
Time per operation 28.95 µs/op 28.59 µs/op 1.2% less time Not flagged
Evaluate a flag (early match)
Shard: flags-single
Process CPU time per operation 28.95 µs/op 28.59 µs/op 1.2% less time Not flagged
Evaluate a flag (late match)
Shard: flags-single
Allocated memory per operation 63.34 KiB/op 63.34 KiB/op No observed change Not flagged
Evaluate a flag (late match)
Shard: flags-single
Allocations per operation 608.27 count/op 608.27 count/op No observed change Not flagged
Evaluate a flag (late match)
Shard: flags-single
Time per operation 40.16 µs/op 40.26 µs/op 0.2% more time Not flagged
Evaluate a flag (late match)
Shard: flags-single
Process CPU time per operation 40.16 µs/op 40.26 µs/op 0.2% more time Not flagged
Evaluate a flag (no match)
Shard: flags-single
Allocated memory per operation 61.97 KiB/op 61.97 KiB/op No observed change Not flagged
Evaluate a flag (no match)
Shard: flags-single
Allocations per operation 591.77 count/op 591.77 count/op No observed change Not flagged
Evaluate a flag (no match)
Shard: flags-single
Time per operation 36.3 µs/op 36.19 µs/op 0.3% less time Not flagged
Evaluate a flag (no match)
Shard: flags-single
Process CPU time per operation 36.29 µs/op 36.19 µs/op 0.3% less time Not flagged
Evaluate a property-filtered flag
Shard: flags-single
Allocated memory per operation 19.38 KiB/op 19.38 KiB/op No observed change Not flagged
Evaluate a property-filtered flag
Shard: flags-single
Allocations per operation 195.27 count/op 195.27 count/op No observed change Not flagged
Evaluate a property-filtered flag
Shard: flags-single
Time per operation 17.01 µs/op 16.72 µs/op 1.7% less time Not flagged
Evaluate a property-filtered flag
Shard: flags-single
Process CPU time per operation 17.01 µs/op 16.72 µs/op 1.7% less time Not flagged
Evaluate a regex-filtered flag
Shard: flags-single
Allocated memory per operation 21.01 KiB/op 21.01 KiB/op No observed change Not flagged
Evaluate a regex-filtered flag
Shard: flags-single
Allocations per operation 200.77 count/op 200.77 count/op No observed change Not flagged
Evaluate a regex-filtered flag
Shard: flags-single
Time per operation 18.24 µs/op 17.9 µs/op 1.9% less time Not flagged
Evaluate a regex-filtered flag
Shard: flags-single
Process CPU time per operation 18.24 µs/op 17.9 µs/op 1.9% less time Not flagged
Evaluate a rollout flag
Shard: flags-single
Allocated memory per operation 14.89 KiB/op 14.89 KiB/op No observed change Not flagged
Evaluate a rollout flag
Shard: flags-single
Allocations per operation 152.77 count/op 152.77 count/op No observed change Not flagged
Evaluate a rollout flag
Shard: flags-single
Time per operation 13.19 µs/op 13.14 µs/op 0.3% less time Not flagged
Evaluate a rollout flag
Shard: flags-single
Process CPU time per operation 13.19 µs/op 13.14 µs/op 0.3% less time Not flagged
Evaluate a multivariate flag
Shard: flags-single
Allocated memory per operation 15.9 KiB/op 15.9 KiB/op No observed change Not flagged
Evaluate a multivariate flag
Shard: flags-single
Allocations per operation 166.77 count/op 166.77 count/op No observed change Not flagged
Evaluate a multivariate flag
Shard: flags-single
Time per operation 14.73 µs/op 14.79 µs/op 0.4% more time Not flagged
Evaluate a multivariate flag
Shard: flags-single
Process CPU time per operation 14.73 µs/op 14.79 µs/op 0.4% more time Not flagged

Values are medians of paired measurements. Not flagged does not mean unchanged. Unavailable means a measurement could not be provided, not zero. Estimated allocation measurements retain their instrumentation uncertainty. RSS measures the whole process, not just SDK allocations; observed peaks are sampled checkpoints. Paired ranges in the diagnostics describe variability, not confidence intervals.

Each shard uses its own runner; compare Before PR against With PR within a row, not across shards.

Compared 42d95918e1e552fb29218ddeeebcef94e48968b6 → e4435e543d2e29fa1bb9ca3563efa1c28af553c1.

Full report and diagnostics

102 metric rows; 102 rows shown in all results. Omitted or shortened data remain in comparison.json, including per-runner environments, resource limits, measurement methods, samples and checkpoints.

@posthog posthog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PostHog Review · Standard · reviewed 5bed350: 1 Consider.

New pushes to this pull request won't start an automatic review. Comment @posthog review to review new changes.

See this review and its findings in PostHog Review. Comment @posthog review --deep for a Deep review. A Deep review takes longer and looks deeper than a Standard review.

Comment thread posthog/async_client.py Outdated
Comment on lines +201 to +202
``evaluate_flags()``, ``get_remote_config_payload()``, ``emails``, ``flush()``,
``shutdown()``, and ``join()`` are awaitable.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P3 · Name the awaitable email methods instead of the property

Following this guidance with await client.emails raises TypeError: AsyncClient.emails is a synchronous property returning an AsyncEmails instance, and that class has no __await__ implementation. The awaitable operations are client.emails.send(...) and client.emails.get(...); list those methods instead in the constructor documentation.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Already fixed in 11ec448a. The table in posthog/async_client.py now lists emails.send and emails.get instead of emails.

Comment thread posthog/client.py Outdated
such as ``memory://local/?ttl=300&size=10000`` or a Redis URL.
enable_local_evaluation: Whether to poll feature flag definitions for
local evaluation when a personal API key is configured.
local evaluation when ``secret_key`` is configured.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
local evaluation when ``secret_key`` is configured.
local evaluation when ``secret_key`` is configured with your personal API key.

for this also do a generic back link to relevant posthog settings page to get such a key

Comment thread posthog/client.py Outdated
Comment on lines +1975 to +1978
Tags attach as event ``properties`` (overriding ``super_properties``,
overridden by explicit ``properties``). Calling ``set()`` or ``set_once()``
in the context also folds active tags into ``$set`` or ``$set_once``.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is ultra confusing to read my guy, i actually don't even. know what you're saying. try again :kek:

Comment thread posthog/client.py Outdated
Comment on lines +2037 to +2041
Python 8 has no ``identify()`` method, so call this inside ``new_context()``
to attribute ``capture()``, ``capture_exception()``, ``evaluate_flags()``, and
``start_span()`` calls to the user. Events outside an identified context
without an explicit ``distinct_id`` send as personless.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's more like in Python SDKs later than X.X.X, identify is done through the context() pattern (link back in docs written in getting started about context)

Call this method in a context, and all captures are automatically tagged with the identity.

something liek this

Comment thread posthog/client.py Outdated
Comment on lines +2345 to +2351
Events with a ``distinct_id`` (explicit or from ``identify_context()``)
create or update a person profile. Pass ``$set`` or ``$set_once`` inside
``properties`` (or call ``set()`` / ``set_once()``), since Python 8 has no
``identify()`` method. Events without a ``distinct_id`` send as personless,
or pass ``options={"process_person_profile": False}`` for a known
``distinct_id``.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Buddy I'm not sure a robot can understand you either lol.

Say it like this

Some special properties should be set with their respective methods

  • Identity information should be set with ...

Comment thread posthog/client.py Outdated
Comment on lines +2924 to +2928
Duplicate calls on the same exception instance send only one event. Contexts
autocapture only uncaught exceptions escaping ``new_context()``, so call
``capture_exception()`` manually when catching and swallowing an error.
Passing ``None`` reads ``sys.exc_info()``. Returns the event UUID, or ``None``
if skipped or dropped.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Duplicate calls on the same exception instance send only one event. Contexts
autocapture only uncaught exceptions escaping ``new_context()``, so call
``capture_exception()`` manually when catching and swallowing an error.
Passing ``None`` reads ``sys.exc_info()``. Returns the event UUID, or ``None``
if skipped or dropped.
Duplicate calls on the same exception instance send only one event.
Contexts only autocaptures uncaught exceptions escaping ``new_context()``, so call
``capture_exception()`` manually when catching and handling an error gracefully.
Passing ``None`` reads ``sys.exc_info()``.
Returns the event UUID, or ``None`` if skipped or dropped.

Comment thread posthog/client.py Outdated
Comment on lines +5689 to +5702
and reason ``"Evaluated locally"``. Pass ``flags=flags.only_accessed()`` to
``capture()`` to attach only flags read via ``is_enabled()`` or ``get_flag()``
before that call, or ``flags=flags.only([...])`` for specific keys.
``get_flag_payload()`` doesn't mark a flag accessed or emit
``$feature_flag_called``.

Args:
distinct_id: The user's distinct ID. If ``None``, falls back to the
context distinct_id. If still unresolvable, returns an empty snapshot.
groups: Mapping of group type to group key.
person_properties: Person properties to use for evaluation.
group_properties: Group properties keyed by group type.
person_properties: Person properties for conditions not yet ingested or
overridden locally.
group_properties: Group properties keyed by group type (not group key),
e.g. ``{"company": {"plan": "enterprise"}}``.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You need some next lines I can't parse tokens

Comment thread posthog/types.py Outdated
Comment on lines +125 to +136
than one cause applies, the first reason in the order below is reported:

- ``EXPERIENCE_CONTINUITY``: The flag has experience continuity enabled, which
local evaluation never resolves. Change the flag to fix it.
- ``UNSUPPORTED_DEFINITION``: The flag uses something the local evaluator does not
support, such as a static cohort, an unknown operator or filter type, a
malformed value, a dependency with no loaded definition or a circular
dependency. Change the flag or upgrade the SDK to fix it.
- ``UNRESOLVED_DEPENDENCY``: A flag this flag depends on has a loaded definition
but was unresolved.
- ``MISSING_CONTEXT``: The call did not pass a property, group property or device
id the flag needs, or passed it in an unusable form. Pass it to fix it.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would a table work here? just 2 cols

@johncwaters johncwaters left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: APPROVE WITH NITS

See inline comments.

Automated review by Glimmervoid. Not written by a human

Comment thread posthog/async_client.py Outdated

#### The differences from ``Client``

Constructor options match ``Client(...)``, except in four places:

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[convergent: code/contract + redteam/coverage] MEDIUM

"Except in four places" undercounts. AsyncClient.__init__ has no **kwargs, and these Client options aren't on it at all: enable_exception_autocapture plus its four exception_autocapture_* rate-limit options, metrics, traces, poll_interval, enable_local_evaluation, flag_definition_cache_provider, and flag_fallback_cache_url. So moving a working Posthog(..., enable_exception_autocapture=True) config over to AsyncPosthog(...) raises TypeError at startup, which this sentence says can't happen.

Suggest dropping the count and adding a bullet that names those options as Client-only, then regenerating both reference files (the same sentence is in references/posthog-python-8.md).

Automated review by Glimmervoid. Not written by a human

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in e4435e54. Dropped the count, named all 12 Client-only constructor options (local flag evaluation, exception autocapture and its rate-limit options, sync_mode, metrics, traces), and regenerated both reference files.

Comment thread posthog/client.py Outdated
disable_geoip: Whether to disable server-side GeoIP enrichment.
Defaults to True. Events get ``$geoip_disable`` only when the
event, context tags and ``super_properties`` leave it unset.
Set ``$ip`` in event properties to geolocate from a client IP.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[code/contract] MEDIUM

This reads as if $ip alone geolocates, but disable_geoip defaults to True, so capture_event.py adds $geoip_disable: True to every event and $ip gets ignored.

Suggest: "Set disable_geoip=False (or $geoip_disable: False on the event) and pass $ip in event properties to geolocate from a client IP."

Automated review by Glimmervoid. Not written by a human

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in e4435e54. Updated the docstring to state disable_geoip=False (or $geoip_disable: False on the event) is required alongside $ip, and regenerated both reference files.

Comment thread posthog/client.py Outdated
Set properties on a person profile.

Uses ``identify_context()`` when ``distinct_id`` is omitted, and folds
active context tags into ``$set``. Without a distinct ID or at least one

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[code/contract] MEDIUM

Not true inside an identified context. add_context_tags (client.py:342) always adds a $context_tags key when a context is active, so under identify_context("u") a set() with no properties has properties == {"$context_tags": set()}, which is truthy, and the if personless or not properties guard at :2690 lets a $set event through. The async docstring at async_client.py:880 has the same problem.

Suggested wording:

Without a distinct ID (explicit or from identify_context()) the call sends nothing and returns None.

Making the guard ignore $context_tags would be a behavior change, so that belongs in its own PR.

Automated review by Glimmervoid. Not written by a human

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in e4435e54. Updated both Client.set() and AsyncClient.set() docstrings to match the actual add_context_tags() behavior, and regenerated both reference files.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants