Skip to content

docs: Document async SDK usage#721

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

docs: Document async SDK usage#721
marandaneto wants to merge 5 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-22 08:01:15 UTC
Duration: 338871ms

✅ All Tests Passed!

111/111 tests passed


Capture_V1 Tests

94/94 tests passed

View Details
Test Status Duration
Endpoint And Method.Targets V1 Endpoint 518ms
Endpoint And Method.Does Not Use Legacy Endpoints 1010ms
Required Headers.Has Authorization Bearer Header 1009ms
Required Headers.Has Content Type Json 1009ms
Required Headers.Has Posthog Sdk Info Format 1009ms
Required Headers.Has Posthog Attempt Header 1009ms
Required Headers.Has Posthog Request Id 1009ms
Required Headers.Has Posthog Request Timestamp 1009ms
Required Headers.Has User Agent 1009ms
Body Format.Body Has Created At And Batch 1009ms
Body Format.No Api Key In Body 1009ms
Body Format.No Sent At In Body 1008ms
Event Format.Event Has Required Root Fields 1010ms
Event Format.Event Uuid Is Valid 1009ms
Event Format.Event Timestamp Is Rfc3339 1008ms
Event Format.Distinct Id Is String 1009ms
Event Format.Distinct Id At Root Not Properties 1009ms
Event Format.Custom Properties Preserved 1009ms
Event Format.Set Properties Preserved 1008ms
Event Format.Set Once Properties Preserved 1009ms
Event Format.Groups Properties Preserved 1009ms
Event Format.Sdk Generates Uuid If Not Provided 1008ms
Event Format.Event Has Required Root Fields Batch 1012ms
Event Format.Event Uuid Is Valid Batch 1012ms
Event Format.Event Timestamp Is Rfc3339 Batch 1013ms
Event Format.Distinct Id Is String Batch 1013ms
Event Format.Distinct Id At Root Not Properties Batch 1013ms
Event Format.Custom Properties Preserved Batch 1012ms
Event Format.Set Properties Preserved Batch 1012ms
Event Format.Set Once Properties Preserved Batch 1012ms
Event Format.Groups Properties Preserved Batch 1013ms
Event Format.Sdk Generates Uuid If Not Provided Batch 1014ms
Batch Behavior.Multiple Events In Single Batch 1506ms
Batch Behavior.Batch Envelope Smoke 1015ms
Batch Behavior.Flush With No Events Sends Nothing 1004ms
Batch Behavior.Flush At Triggers Batch 1509ms
Batch Behavior.Created At Reflects Batch Creation Time 1011ms
Deduplication.Generates Unique Uuids 1506ms
Deduplication.Different Events Same Content Different Uuids 1507ms
Deduplication.Preserves Uuid On Retry 7513ms
Deduplication.Preserves Timestamp On Retry 7514ms
Deduplication.Preserves Uuid And Timestamp On Batch Retry 7513ms
Deduplication.No Duplicate Events In Batch 1504ms
Header Behavior On Retry.Attempt Header Starts At One 1009ms
Header Behavior On Retry.Attempt Header Increments On Retry 14517ms
Header Behavior On Retry.Request Id Preserved On Retry 7516ms
Header Behavior On Retry.Different Requests Have Different Request Ids 3515ms
Header Behavior On Retry.Request Timestamp Changes On Retry 7514ms
Response Format Validation.Success Response Has Uuid Keyed Results 1005ms
Response Format Validation.Success Response Has Ok For Each Event 1507ms
Response Format Validation.Success No Retry After When All Ok 1507ms
Response Format Validation.Success Retry After Present When Retry Events 2513ms
Response Format Validation.Success No Retry After When Drop Only 1508ms
Response Format Validation.Response Echoes Request Id 1009ms
Retry Behavior.Retries On 408 7514ms
Retry Behavior.Retries On 500 7509ms
Retry Behavior.Retries On 503 9519ms
Retry Behavior.Retries On 504 7508ms
Retry Behavior.Retryable Errors Have Retry After 4513ms
Retry Behavior.Respects Retry After On Retryable Error 12511ms
Retry Behavior.Does Not Retry On 400 3510ms
Retry Behavior.Does Not Retry On 401 3508ms
Retry Behavior.Does Not Retry On 402 3507ms
Retry Behavior.Does Not Retry On 413 3507ms
Retry Behavior.Does Not Retry On 415 3508ms
Retry Behavior.Non Retryable Errors Have No Retry After 3508ms
Retry Behavior.Implements Backoff 23530ms
Retry Behavior.Max Retries Respected 23521ms
Partial Batch Handling.Handles 200 Full Success 3001ms
Partial Batch Handling.Handles 200 With All Ok 4508ms
Partial Batch Handling.Does Not Retry Dropped Events 4505ms
Partial Batch Handling.Does Not Retry Limited Events 4510ms
Partial Batch Handling.Prunes Ok Events On Partial Retry 7509ms
Partial Batch Handling.Prunes Dropped Events On Partial Retry 7515ms
Partial Batch Handling.Retries Only Retry Events From Partial 7513ms
Partial Batch Handling.Partial Retry Preserves Uuids 7510ms
Partial Batch Handling.Partial Retry Attempt Header Increments 7512ms
Partial Batch Handling.Partial Retry Request Id Preserved 7513ms
Partial Batch Handling.Respects Retry After On Partial 9508ms
Partial Batch Handling.Unknown Result Treated As Terminal 4507ms
Partial Batch Handling.Mixed Ok Drop Limited No Retry 4511ms
Compression.Sends Gzip Content Encoding 1007ms
Compression.No Content Encoding When Disabled 1009ms
Compression.Compressed Body Is Decompressible 1009ms
Error Handling.Does Not Retry On Unknown 4Xx 3508ms
Event Options.Cookieless Mode Override 1008ms
Event Options.Disable Skew Correction Override 1008ms
Event Options.Process Person Profile Override 1009ms
Event Options.Product Tour Id Override 1008ms
Event Options.Unset Options Omitted 1008ms
Event Options.Options Override In Batch 1012ms
Geoip And Historical Migration.Geoip Disable Injected Into Properties 1008ms
Geoip And Historical Migration.Historical Migration Set In Body 1008ms
Geoip And Historical Migration.Historical Migration Absent By Default 1008ms

Feature_Flags Tests

17/17 tests passed

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

@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
@marandaneto marandaneto mentioned this pull request Jul 6, 2026
5 tasks
@github-actions

Copy link
Copy Markdown
Contributor

This PR hasn't seen activity in a week! Should it be merged, closed, or further worked on? If you want to keep it open, post a comment or remove the stale label – otherwise this will be closed in another week.

@github-actions github-actions Bot added the stale label Jul 10, 2026
@github-actions

Copy link
Copy Markdown
Contributor

This PR was closed due to lack of activity. Feel free to reopen if it's still relevant.

@github-actions github-actions Bot closed this Jul 20, 2026
@marandaneto marandaneto reopened this Jul 22, 2026
@marandaneto marandaneto removed the stale label Jul 22, 2026
@dustinbyrne
dustinbyrne self-requested a review July 22, 2026 04:52
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