Skip to content

docs: Document async SDK usage#721

Draft
marandaneto wants to merge 3 commits into
async-sdk-02-feature-flagsfrom
async-sdk-03-docs
Draft

docs: Document async SDK usage#721
marandaneto wants to merge 3 commits into
async-sdk-02-feature-flagsfrom
async-sdk-03-docs

Conversation

@marandaneto

@marandaneto marandaneto commented Jul 1, 2026

Copy link
Copy Markdown
Member

💡 Motivation and Context

Finishes the async SDK stack for #103 with README guidance for installing posthog[async], using AsyncPosthog, closing it with async with / await shutdown(), and evaluating flags without blocking the event loop.

This PR is stacked on #720. Review feedback was addressed by removing a redundant explicit flush() from the async with example, since exiting the context shuts down and flushes automatically.

💚 How did you test it?

  • uv run --extra test pytest posthog/test/test_async_request.py posthog/test/test_async_client.py posthog/test/test_async_feature_flags.py --verbose --timeout=30
  • uv run python -W error -c "import posthog; from posthog import AsyncPosthog"

📝 Checklist

  • 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

🤖 Agent context

Autonomy: Human-driven (agent-assisted)

Implemented with pi. This PR is docs-only and is intentionally separated from the implementation PRs so the code review can happen in smaller stacked chunks.

@marandaneto marandaneto self-assigned this Jul 1, 2026
@greptile-apps

greptile-apps Bot commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Reviews (1): Last reviewed commit: "Document async SDK usage" | Re-trigger Greptile

Comment thread README.md Outdated
@github-actions

github-actions Bot commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

posthog-python Compliance Report

Date: 2026-07-02 14:19:04 UTC
Duration: 177037ms

✅ All Tests Passed!

46/46 tests passed


Capture Tests

29/29 tests passed

View Details
Test Status Duration
Format Validation.Event Has Required Fields 513ms
Format Validation.Event Has Uuid 1506ms
Format Validation.Event Has Lib Properties 1506ms
Format Validation.Distinct Id Is String 1506ms
Format Validation.Token Is Present 1505ms
Format Validation.Custom Properties Preserved 1505ms
Format Validation.Event Has Timestamp 1505ms
Retry Behavior.Retries On 503 9512ms
Retry Behavior.Does Not Retry On 400 3508ms
Retry Behavior.Does Not Retry On 401 3506ms
Retry Behavior.Respects Retry After Header 9513ms
Retry Behavior.Implements Backoff 23525ms
Retry Behavior.Retries On 500 7501ms
Retry Behavior.Retries On 502 7512ms
Retry Behavior.Retries On 504 7509ms
Retry Behavior.Max Retries Respected 23526ms
Deduplication.Generates Unique Uuids 1495ms
Deduplication.Preserves Uuid On Retry 7510ms
Deduplication.Preserves Uuid And Timestamp On Retry 14514ms
Deduplication.Preserves Uuid And Timestamp On Batch Retry 7514ms
Deduplication.No Duplicate Events In Batch 1502ms
Deduplication.Different Events Have Different Uuids 1506ms
Compression.Sends Gzip When Enabled 1506ms
Batch Format.Uses Proper Batch Structure 1506ms
Batch Format.Flush With No Events Sends Nothing 1004ms
Batch Format.Multiple Events Batched Together 1504ms
Error Handling.Does Not Retry On 403 3508ms
Error Handling.Does Not Retry On 413 3506ms
Error Handling.Retries On 408 7512ms

Feature_Flags Tests

17/17 tests passed

View Details
Test Status Duration
Request Payload.Request With Person Properties Device Id 1001ms
Request Payload.Flags Request Uses V2 Query Param 1006ms
Request Payload.Flags Request Hits Flags Path Not Decide 1005ms
Request Payload.Flags Request Omits Authorization Header 1005ms
Request Payload.Token In Flags Body Matches Init 1006ms
Request Payload.Groups Round Trip 1005ms
Request Payload.Groups Default To Empty Object 1005ms
Request Payload.Disable Geoip False Propagates As Geoip Disable False 1006ms
Request Payload.Disable Geoip Omitted Defaults To False 1005ms
Request Payload.Flag Keys To Evaluate Contains Only Requested Key 1006ms
Request Lifecycle.No Flags Request On Init Alone 502ms
Request Lifecycle.No Flags Request On Normal Capture 1506ms
Request Lifecycle.Two Flag Calls Produce Two Remote Requests 1008ms
Request Lifecycle.Mock Response Value Is Returned To Caller 1003ms
Retry Behavior.Retries Flags On 502 1005ms
Retry Behavior.Retries Flags On 504 1005ms
Side Effect Events.Get Feature Flag Captures Feature Flag Called Event 1507ms

@marandaneto marandaneto force-pushed the async-sdk-02-feature-flags branch from 5376ad0 to 218c362 Compare July 1, 2026 13:07
@marandaneto marandaneto force-pushed the async-sdk-02-feature-flags branch from 218c362 to 9e67828 Compare July 1, 2026 13:14
@marandaneto marandaneto force-pushed the async-sdk-02-feature-flags branch from 9e67828 to 6c126a1 Compare July 1, 2026 16:35
@marandaneto marandaneto force-pushed the async-sdk-02-feature-flags branch from 6c126a1 to d9e30ec Compare July 1, 2026 16:37
@marandaneto marandaneto force-pushed the async-sdk-03-docs branch 2 times, most recently from 2efcf82 to 164663f Compare July 2, 2026 10:19
@marandaneto marandaneto force-pushed the async-sdk-02-feature-flags branch from 83794b2 to ce3aa46 Compare July 2, 2026 11:15
@marandaneto marandaneto force-pushed the async-sdk-02-feature-flags branch 2 times, most recently from d1e9ab5 to a365483 Compare July 2, 2026 11:26
@marandaneto marandaneto force-pushed the async-sdk-02-feature-flags branch from a365483 to 84f6ba5 Compare July 2, 2026 11:29
Comment thread README.md
@marandaneto marandaneto force-pushed the async-sdk-02-feature-flags branch from 84f6ba5 to 7f102b9 Compare July 2, 2026 13:21
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.

1 participant