Skip to content

Commit 294e538

Browse files
authored
Merge branch 'main' into codex/posthog-typing-return-annotations
2 parents 3dbb599 + 62d09a6 commit 294e538

58 files changed

Lines changed: 25547 additions & 225 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: Setup Python dev environment
2+
description: Set up Python, uv, and dev dependencies for CI checks.
3+
4+
inputs:
5+
python-version:
6+
description: Python version to install.
7+
required: false
8+
default: 3.11.11
9+
10+
runs:
11+
using: composite
12+
steps:
13+
- name: Set up Python ${{ inputs.python-version }}
14+
uses: actions/setup-python@8d9ed9ac5c53483de85588cdf95a591a75ab9f55
15+
with:
16+
python-version: ${{ inputs.python-version }}
17+
18+
- name: Install uv
19+
uses: astral-sh/setup-uv@cec208311dfd045dd5311c1add060b2062131d57 # v8.0.0
20+
with:
21+
enable-cache: true
22+
23+
- name: Install dev dependencies
24+
shell: bash
25+
run: |
26+
UV_PROJECT_ENVIRONMENT=$pythonLocation uv sync --extra dev

.github/workflows/call-flags-project-board.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ on:
99

1010
jobs:
1111
call-flags-project:
12-
uses: PostHog/.github/.github/workflows/flags-project-board.yml@d8b55d05dc5150f05c24542a6397ff3ecfbfb56d
12+
uses: PostHog/.github/.github/workflows/flags-project-board.yml@69336b569d22687f8982eea6ff7d450a885cda05
1313
with:
1414
pr_number: ${{ github.event.pull_request.number }}
1515
pr_node_id: ${{ github.event.pull_request.node_id }}

.github/workflows/ci.yml

Lines changed: 56 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,43 +9,83 @@ on:
99
permissions:
1010
contents: read
1111

12+
concurrency:
13+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
14+
cancel-in-progress: true
15+
1216
jobs:
13-
code-quality:
14-
name: Code quality checks
17+
ruff-format:
18+
name: Ruff format
1519
runs-on: ubuntu-latest
1620

1721
steps:
1822
- uses: actions/checkout@85e6279cec87321a52edac9c87bce653a07cf6c2
1923
with:
2024
fetch-depth: 1
2125

22-
- name: Set up Python 3.11
23-
uses: actions/setup-python@8d9ed9ac5c53483de85588cdf95a591a75ab9f55
24-
with:
25-
python-version: 3.11.11
26-
27-
- name: Install uv
28-
uses: astral-sh/setup-uv@cec208311dfd045dd5311c1add060b2062131d57 # v8.0.0
29-
with:
30-
enable-cache: true
31-
32-
- name: Install dev dependencies
33-
shell: bash
34-
run: |
35-
UV_PROJECT_ENVIRONMENT=$pythonLocation uv sync --extra dev
26+
- name: Set up Python dev environment
27+
uses: ./.github/actions/setup-python-dev
3628

3729
- name: Check formatting with ruff
3830
run: |
3931
ruff format --check .
4032
33+
ruff-lint:
34+
name: Ruff lint
35+
runs-on: ubuntu-latest
36+
37+
steps:
38+
- uses: actions/checkout@85e6279cec87321a52edac9c87bce653a07cf6c2
39+
with:
40+
fetch-depth: 1
41+
42+
- name: Set up Python dev environment
43+
uses: ./.github/actions/setup-python-dev
44+
4145
- name: Lint with ruff
4246
run: |
4347
ruff check .
4448
49+
mypy:
50+
name: Mypy
51+
runs-on: ubuntu-latest
52+
53+
steps:
54+
- uses: actions/checkout@85e6279cec87321a52edac9c87bce653a07cf6c2
55+
with:
56+
fetch-depth: 1
57+
58+
- name: Set up Python dev environment
59+
uses: ./.github/actions/setup-python-dev
60+
4561
- name: Check types with mypy
4662
run: |
4763
mypy --no-site-packages --config-file mypy.ini . | mypy-baseline filter
4864
65+
package-build:
66+
name: Package build
67+
runs-on: ubuntu-latest
68+
69+
steps:
70+
- uses: actions/checkout@85e6279cec87321a52edac9c87bce653a07cf6c2
71+
with:
72+
fetch-depth: 1
73+
74+
- name: Set up Python 3.11
75+
uses: actions/setup-python@8d9ed9ac5c53483de85588cdf95a591a75ab9f55
76+
with:
77+
python-version: 3.11.11
78+
79+
- name: Install uv
80+
uses: astral-sh/setup-uv@cec208311dfd045dd5311c1add060b2062131d57 # v8.0.0
81+
with:
82+
enable-cache: true
83+
84+
- name: Build and verify distributions
85+
run: |
86+
uv build
87+
uv run --with twine twine check dist/*
88+
4989
tests:
5090
name: Python ${{ matrix.python-version }} tests
5191
runs-on: ubuntu-latest

CHANGELOG.md

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,53 @@
11
# posthog
22

3+
## 7.19.0 — 2026-06-15
4+
5+
### Minor changes
6+
7+
- [b9f3208](https://github.com/posthog/posthog-python/commit/b9f320808f44832fc3b4cdd6bcf0e0aad194b76d) Add opt-in client-side rate limiting for exception autocapture, using the same token bucket algorithm as the posthog-js and posthog-node SDKs: a bucket per exception type allows a burst of captures, then refills over time. Rate-limited exceptions are skipped before they reach the ingestion queue. Disabled by default; enable with the new `enable_exception_autocapture_rate_limiting` client option and tune via `exception_autocapture_bucket_size` (default 50), `exception_autocapture_refill_rate` (default 10), and `exception_autocapture_refill_interval_seconds` (default 10). — Thanks @hpouillot!
8+
9+
## 7.18.3 — 2026-06-12
10+
11+
### Patch changes
12+
13+
- [ee6a3c8](https://github.com/posthog/posthog-python/commit/ee6a3c8c030cfaacc065765d95991a448d59ad08) Warn when an AI wrapper's `base_url` points at the PostHog AI Gateway. The gateway emits its own `$ai_generation`, so each call would be captured (and billed) twice. The wrapper only warns and never drops the event. Detection covers the wrapper funnels (OpenAI, Anthropic, LangChain) and the OTel span path. — Thanks @richardsolomou!
14+
15+
## 7.18.2 — 2026-06-12
16+
17+
### Patch changes
18+
19+
- [fe76fc9](https://github.com/posthog/posthog-python/commit/fe76fc9a874a3f2f8538ee0d1c4f8a6c66f11c03) Improve mypy coverage for core SDK modules without changing runtime behavior. — Thanks @Kshitijmishradev for your first contribution 🎉!
20+
21+
## 7.18.1 — 2026-06-10
22+
23+
### Patch changes
24+
25+
- [00b2091](https://github.com/posthog/posthog-python/commit/00b2091ea661d3b4e87ccf11f4752f73a1e0d162) Add internal-only routing of `$ai_*` events to a dedicated capture endpoint in their own batch, gated behind the unstable `_dedicated_ai_endpoint` client option (off by default, not for general use). — Thanks @carlos-marchal-ph!
26+
27+
## 7.18.0 — 2026-06-05
28+
29+
### Minor changes
30+
31+
- [a2ce51e](https://github.com/posthog/posthog-python/commit/a2ce51e8a4aad82bb91f152ee8b4236ba5898472) feat(feature-flags): support the `early_exit` condition option in local evaluation. When a flag enables early exit, evaluation now stops and returns `False` as soon as a condition group's property filters match but the rollout percentage excludes the user, instead of falling through to later groups — matching the server-side evaluation behavior. — Thanks @gustavohstrassburger!
32+
33+
## 7.17.0 — 2026-06-03
34+
35+
### Minor changes
36+
37+
- [3aed638](https://github.com/posthog/posthog-python/commit/3aed638ce1a256545f86cf05aa6338a1f2b62a89) Add a configurable `$is_server` event property (default `true`) so PostHog can identify server-side events. Set `is_server=False` when using posthog-python as a client/CLI so the device OS is attributed normally. — Thanks @turnipdabeets for your first contribution 🎉!
38+
39+
## 7.16.4 — 2026-06-03
40+
41+
### Patch changes
42+
43+
- [44e6b14](https://github.com/posthog/posthog-python/commit/44e6b14affd235f523d5a719690cddcb98f0fdde) Fix async streaming responses from the AI wrappers (OpenAI, Anthropic, Gemini) so they support `async with` as well as `async for`. Previously, consuming a stream via `async with` (e.g. with pydantic-ai) raised `TypeError: 'async_generator' object does not support the asynchronous context manager protocol`. — Thanks @turnipdabeets for your first contribution 🎉!
44+
45+
## 7.16.3 — 2026-06-01
46+
47+
### Patch changes
48+
49+
- [643a810](https://github.com/posthog/posthog-python/commit/643a810851719cfdbbdee7d76d1fb87e6ade45aa) Return empty flag defaults from Client flag helpers when the flags API fails. — Thanks @marandaneto!
50+
351
## 7.16.2 — 2026-05-28
452

553
### Patch changes

LICENSE

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,19 +22,19 @@ SOFTWARE.
2222

2323
---
2424

25-
Some files in this codebase contain code from getsentry/sentry-javascript by Software, Inc. dba Sentry.
25+
Some files in this codebase contain code from getsentry/sentry-python.
2626
In such cases it is explicitly stated in the file header. This license only applies to the relevant code in such cases.
2727

2828
MIT License
2929

30-
Copyright (c) 2012 Functional Software, Inc. dba Sentry
30+
Copyright (c) 2018 Functional Software, Inc. dba Sentry
3131

32-
Permission is hereby granted, free of charge, to any person obtaining a copy of
33-
this software and associated documentation files (the "Software"), to deal in
34-
the Software without restriction, including without limitation the rights to
35-
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
36-
of the Software, and to permit persons to whom the Software is furnished to do
37-
so, subject to the following conditions:
32+
Permission is hereby granted, free of charge, to any person obtaining a copy
33+
of this software and associated documentation files (the "Software"), to deal
34+
in the Software without restriction, including without limitation the rights
35+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
36+
copies of the Software, and to permit persons to whom the Software is
37+
furnished to do so, subject to the following conditions:
3838

3939
The above copyright notice and this permission notice shall be included in all
4040
copies or substantial portions of the Software.
@@ -45,4 +45,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
4545
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
4646
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
4747
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
48-
SOFTWARE.
48+
SOFTWARE.

examples/example-ai-openai-agents/uv.lock

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/example-ai-pydantic-ai/uv.lock

Lines changed: 6 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/example-ai-semantic-kernel/uv.lock

Lines changed: 6 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

mypy-baseline.txt

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +0,0 @@
1-
posthog/request.py:0: error: Library stubs not installed for "requests" [import-untyped]
2-
posthog/request.py:0: note: Hint: "python3 -m pip install types-requests"
3-
posthog/request.py:0: note: (or run "mypy --install-types" to install all missing stub packages)
4-
posthog/request.py:0: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports
5-
posthog/request.py:0: error: Incompatible types in assignment (expression has type "bytes", variable has type "str") [assignment]
6-
posthog/consumer.py:0: error: Name "Empty" already defined (possibly by an import) [no-redef]
7-
posthog/consumer.py:0: error: Need type annotation for "items" (hint: "items: list[<type>] = ...") [var-annotated]
8-
posthog/consumer.py:0: error: Unsupported operand types for <= ("int" and "str") [operator]
9-
posthog/consumer.py:0: note: Right operand is of type "int | str"
10-
posthog/consumer.py:0: error: Unsupported operand types for < ("str" and "int") [operator]
11-
posthog/consumer.py:0: note: Left operand is of type "int | str"
12-
posthog/feature_flags.py:0: error: Unused "type: ignore" comment [unused-ignore]
13-
posthog/client.py:0: error: Name "queue" already defined (by an import) [no-redef]
14-
posthog/client.py:0: error: Need type annotation for "queue" [var-annotated]
15-
posthog/client.py:0: error: Incompatible types in assignment (expression has type "Any | list[Any]", variable has type "None") [assignment]
16-
posthog/client.py:0: error: Incompatible types in assignment (expression has type "dict[Any, Any]", variable has type "None") [assignment]
17-
posthog/client.py:0: error: "None" has no attribute "__iter__" (not iterable) [attr-defined]
18-
posthog/client.py:0: error: Statement is unreachable [unreachable]
19-
posthog/client.py:0: error: Statement is unreachable [unreachable]
20-
posthog/client.py:0: error: Name "parse_qs" already defined (possibly by an import) [no-redef]
21-
posthog/client.py:0: error: Name "urlparse" already defined (possibly by an import) [no-redef]

mypy.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
python_version = 3.11
33
plugins =
44
pydantic.mypy
5+
mypy_path = typings
56
strict_optional = True
67
no_implicit_optional = True
78
warn_unused_ignores = True

0 commit comments

Comments
 (0)