Skip to content

Commit ec79b8f

Browse files
committed
update latest
2 parents be51643 + 2855977 commit ec79b8f

File tree

67 files changed

+42104
-2372
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+42104
-2372
lines changed

.github/dependabot.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "pip"
4+
directory: "/"
5+
schedule:
6+
interval: "daily"
7+
time: "10:00"
8+
timezone: "UTC"
9+
groups:
10+
ai-providers:
11+
patterns:
12+
- "openai"
13+
- "anthropic"
14+
- "google-genai"
15+
- "langchain-core"
16+
- "langchain-community"
17+
- "langchain-openai"
18+
- "langchain-anthropic"
19+
- "langgraph"
20+
allow:
21+
- dependency-name: "openai"
22+
- dependency-name: "anthropic"
23+
- dependency-name: "google-genai"
24+
- dependency-name: "langchain-core"
25+
- dependency-name: "langchain-community"
26+
- dependency-name: "langchain-openai"
27+
- dependency-name: "langchain-anthropic"
28+
- dependency-name: "langgraph"
29+
open-pull-requests-limit: 1
30+
reviewers:
31+
- "PostHog/team-llm-analytics"
32+
# Uncomment below to enable auto-merge for minor updates when CI passes
33+
# pull-request-branch-name:
34+
# separator: "/"
35+
# assignees:
36+
# - "PostHog/ai-team"

.github/workflows/ci.yml

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ name: CI
33
on:
44
- pull_request
55

6+
permissions:
7+
contents: read
8+
69
jobs:
710
code-quality:
811
name: Code quality checks
@@ -33,6 +36,10 @@ jobs:
3336
run: |
3437
ruff format --check .
3538
39+
- name: Lint with ruff
40+
run: |
41+
ruff check .
42+
3643
- name: Check types with mypy
3744
run: |
3845
mypy --no-site-packages --config-file mypy.ini . | mypy-baseline filter
@@ -42,7 +49,7 @@ jobs:
4249
runs-on: ubuntu-latest
4350
strategy:
4451
matrix:
45-
python-version: ['3.9', '3.10', '3.11', '3.12', '3.13']
52+
python-version: ['3.10', '3.11', '3.12', '3.13', '3.14']
4653

4754
steps:
4855
- uses: actions/checkout@85e6279cec87321a52edac9c87bce653a07cf6c2
@@ -68,3 +75,34 @@ jobs:
6875
- name: Run posthog tests
6976
run: |
7077
pytest --verbose --timeout=30
78+
79+
django5-integration:
80+
name: Django 5 integration tests
81+
runs-on: ubuntu-latest
82+
83+
steps:
84+
- uses: actions/checkout@85e6279cec87321a52edac9c87bce653a07cf6c2
85+
with:
86+
fetch-depth: 1
87+
88+
- name: Set up Python 3.12
89+
uses: actions/setup-python@8d9ed9ac5c53483de85588cdf95a591a75ab9f55
90+
with:
91+
python-version: 3.12
92+
93+
- name: Install uv
94+
uses: astral-sh/setup-uv@0c5e2b8115b80b4c7c5ddf6ffdd634974642d182 # v5.4.1
95+
with:
96+
enable-cache: true
97+
pyproject-file: 'integration_tests/django5/pyproject.toml'
98+
99+
- name: Install Django 5 test project dependencies
100+
shell: bash
101+
working-directory: integration_tests/django5
102+
run: |
103+
UV_PROJECT_ENVIRONMENT=$pythonLocation uv sync
104+
105+
- name: Run Django 5 middleware integration tests
106+
working-directory: integration_tests/django5
107+
run: |
108+
uv run pytest test_middleware.py test_exception_capture.py --verbose
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: "Generate References"
2+
3+
on:
4+
workflow_dispatch:
5+
6+
jobs:
7+
docs-generation:
8+
name: Generate references
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: Checkout the repository
12+
uses: actions/checkout@85e6279cec87321a52edac9c87bce653a07cf6c2
13+
with:
14+
fetch-depth: 0
15+
token: ${{ secrets.POSTHOG_BOT_PAT }}
16+
17+
- name: Set up Python
18+
uses: actions/setup-python@8d9ed9ac5c53483de85588cdf95a591a75ab9f55
19+
with:
20+
python-version: 3.11.11
21+
22+
- name: Install uv
23+
uses: astral-sh/setup-uv@0c5e2b8115b80b4c7c5ddf6ffdd634974642d182 # v5.4.1
24+
with:
25+
enable-cache: true
26+
pyproject-file: 'pyproject.toml'
27+
28+
- name: Generate references
29+
run: |
30+
uv run bin/docs generate-references
31+
32+
- name: Check for changes in references
33+
id: changes
34+
run: |
35+
if [ -n "$(git status --porcelain references/)" ]; then
36+
echo "changed=true" >> $GITHUB_OUTPUT
37+
echo "New references generated in references directory:"
38+
git status --porcelain references/
39+
else
40+
echo "changed=false" >> $GITHUB_OUTPUT
41+
echo "No new references generated in references directory"
42+
fi
43+
44+
- uses: stefanzweifel/git-auto-commit-action@778341af668090896ca464160c2def5d1d1a3eb0
45+
if: steps.changes.outputs.changed == 'true'
46+
with:
47+
commit_message: "Update generated references"
48+
file_pattern: references/
Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
uses: actions/checkout@85e6279cec87321a52edac9c87bce653a07cf6c2
2121
with:
2222
fetch-depth: 0
23-
token: ${{ secrets.POSTHOG_BOT_GITHUB_TOKEN }}
23+
token: ${{ secrets.POSTHOG_BOT_PAT }}
2424

2525
- name: Set up Python
2626
uses: actions/setup-python@8d9ed9ac5c53483de85588cdf95a591a75ab9f55
@@ -45,7 +45,13 @@ jobs:
4545
- name: Create GitHub release
4646
uses: actions/create-release@0cb9c9b65d5d1901c1f53e5e66eaf4afd303e70e # v1
4747
env:
48-
GITHUB_TOKEN: ${{ secrets.POSTHOG_BOT_GITHUB_TOKEN }}
48+
GITHUB_TOKEN: ${{ secrets.POSTHOG_BOT_PAT }}
4949
with:
5050
tag_name: v${{ env.REPO_VERSION }}
5151
release_name: ${{ env.REPO_VERSION }}
52+
53+
- name: Dispatch generate-references for posthog-python
54+
env:
55+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
56+
run: |
57+
gh workflow run generate-references.yml --ref master

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,4 @@ pyrightconfig.json
1919
.env
2020
.DS_Store
2121
posthog-python-references.json
22+
.claude/settings.local.json

CHANGELOG.md

Lines changed: 89 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,93 @@
1-
# 6.8.0 - 2025-12-01
1+
# 7.2.0 - 2025-12-01
22

3-
- feat: add `$feature_flag_evaluated_at` properties to `$feature_flag_called` events
3+
feat: add $feature_flag_evaluated_at properties to $feature_flag_called events
4+
5+
6+
# 7.1.0 - 2025-11-26
7+
8+
Add support for the async version of Gemini.
9+
10+
# 7.0.2 - 2025-11-18
11+
12+
Add support for Python 3.14.
13+
Projects upgrading to Python 3.14 should ensure any Pydantic models passed into the SDK use Pydantic v2, as Pydantic v1 is not compatible with Python 3.14.
14+
15+
# 7.0.1 - 2025-11-15
16+
17+
Try to use repr() when formatting code variables
18+
19+
# 7.0.0 - 2025-11-11
20+
21+
NB Python 3.9 is no longer supported
22+
23+
- chore(llma): update LLM provider SDKs to latest major versions
24+
- openai: 1.102.0 → 2.7.1
25+
- anthropic: 0.64.0 → 0.72.0
26+
- google-genai: 1.32.0 → 1.49.0
27+
- langchain-core: 0.3.75 → 1.0.3
28+
- langchain-openai: 0.3.32 → 1.0.2
29+
- langchain-anthropic: 0.3.19 → 1.0.1
30+
- langchain-community: 0.3.29 → 0.4.1
31+
- langgraph: 0.6.6 → 1.0.2
32+
33+
# 6.9.3 - 2025-11-10
34+
35+
- feat(ph-ai): PostHog properties dict in GenerationMetadata
36+
37+
# 6.9.2 - 2025-11-10
38+
39+
- fix(llma): fix cache token double subtraction in Langchain for non-Anthropic providers causing negative costs
40+
41+
# 6.9.1 - 2025-11-07
42+
43+
- fix(error-tracking): pass code variables config from init to client
44+
45+
# 6.9.0 - 2025-11-06
46+
47+
- feat(error-tracking): add local variables capture
48+
49+
# 6.8.0 - 2025-11-03
50+
51+
- feat(llma): send web search calls to be used for LLM cost calculations
52+
53+
# 6.7.14 - 2025-11-03
54+
55+
- fix(django): Handle request.user access in async middleware context to prevent SynchronousOnlyOperation errors in Django 5+ (fixes #355)
56+
- test(django): Add Django 5 integration test suite with real ASGI application testing async middleware behavior
57+
58+
# 6.7.13 - 2025-11-02
59+
60+
- fix(llma): cache cost calculation in the LangChain callback
61+
62+
# 6.7.12 - 2025-11-02
63+
64+
- fix(django): Restore process_exception method to capture view and downstream middleware exceptions (fixes #329)
65+
- fix(ai/langchain): Add LangChain 1.0+ compatibility for CallbackHandler imports (fixes #362)
66+
67+
# 6.7.11 - 2025-10-28
68+
69+
- feat(ai): Add `$ai_framework` property for framework integrations (e.g. LangChain)
70+
71+
# 6.7.10 - 2025-10-24
72+
73+
- fix(django): Make middleware truly hybrid - compatible with both sync (WSGI) and async (ASGI) Django stacks without breaking sync-only deployments
74+
75+
# 6.7.9 - 2025-10-22
76+
77+
- fix(flags): multi-condition flags with static cohorts returning wrong variants
78+
79+
# 6.7.8 - 2025-10-16
80+
81+
- fix(llma): missing async for OpenAI's streaming implementation
82+
83+
# 6.7.7 - 2025-10-14
84+
85+
- fix: remove deprecated attribute $exception_personURL from exception events
86+
87+
# 6.7.6 - 2025-09-16
88+
89+
- fix: don't sort condition sets with variant overrides to the top
90+
- fix: Prevent core Client methods from raising exceptions
491

592
# 6.7.5 - 2025-09-16
693

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ We recommend using [uv](https://docs.astral.sh/uv/). It's super fast.
3030
## PostHog recommends `uv` so...
3131

3232
```bash
33-
uv python install 3.9.19
34-
uv python pin 3.9.19
33+
uv python install 3.12
34+
uv python pin 3.12
3535
uv venv
3636
source env/bin/activate
3737
uv sync --extra dev --extra test

bin/docs_scripts/doc_constant.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"""
44

55
from typing import Dict, Union
6+
from posthog.version import VERSION
67

78
# Documentation generation metadata
89
DOCUMENTATION_METADATA = {
@@ -27,8 +28,9 @@
2728

2829
# Output file configuration
2930
OUTPUT_CONFIG: Dict[str, Union[str, int]] = {
30-
"output_dir": ".",
31-
"filename": "posthog-python-references.json",
31+
"output_dir": "./references",
32+
"filename": f"posthog-python-references-{VERSION}.json",
33+
"filename_latest": "posthog-python-references-latest.json",
3234
"indent": 2,
3335
}
3436

bin/docs_scripts/generate_json_schemas.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -460,12 +460,23 @@ def generate_sdk_documentation():
460460
try:
461461
documentation = generate_sdk_documentation()
462462

463-
# Write to file
463+
# Ensure output directory exists
464+
output_dir = str(OUTPUT_CONFIG["output_dir"])
465+
os.makedirs(output_dir, exist_ok=True)
466+
464467
output_file = os.path.join(
465468
str(OUTPUT_CONFIG["output_dir"]), str(OUTPUT_CONFIG["filename"])
466469
)
470+
output_file_latest = os.path.join(
471+
str(OUTPUT_CONFIG["output_dir"]), str(OUTPUT_CONFIG["filename_latest"])
472+
)
473+
474+
# Write to current version
467475
with open(output_file, "w") as f:
468476
json.dump(documentation, f, indent=int(OUTPUT_CONFIG["indent"]))
477+
# Write to latest
478+
with open(output_file_latest, "w") as f:
479+
json.dump(documentation, f, indent=int(OUTPUT_CONFIG["indent"]))
469480

470481
print(f"✓ Generated {output_file}")
471482

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
db.sqlite3
2+
*.pyc
3+
__pycache__/
4+
.pytest_cache/

0 commit comments

Comments
 (0)