Skip to content

Commit b99f9b2

Browse files
authored
Merge branch 'master' into no-context
2 parents 5297b33 + 8f43bbc commit b99f9b2

Some content is hidden

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

51 files changed

+12289
-272
lines changed

.github/workflows/ci.yml

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
with:
1919
python-version: 3.8
2020

21-
- uses: actions/cache@v1
21+
- uses: actions/cache@v3
2222
with:
2323
path: ~/.cache/pip
2424
key: ${{ runner.os }}-pip-${{ hashFiles('setup.py') }}
@@ -34,6 +34,10 @@ jobs:
3434
run: |
3535
black --check .
3636
37+
- name: Lint with flake8
38+
run: |
39+
flake8 posthog --ignore E501,W503
40+
3741
- name: Check import order with isort
3842
run: |
3943
isort --check-only .
@@ -43,19 +47,19 @@ jobs:
4347
runs-on: ubuntu-latest
4448

4549
steps:
46-
- uses: actions/checkout@v1
50+
- uses: actions/checkout@v2
4751
with:
4852
fetch-depth: 1
4953

50-
- name: Set up Python 3.7
51-
uses: actions/setup-python@v1
54+
- name: Set up Python 3.9
55+
uses: actions/setup-python@v2
5256
with:
53-
python-version: 3.7
57+
python-version: 3.9
5458

5559
- name: Install requirements.txt dependencies with pip
5660
run: |
5761
python -m pip install -e .[test]
5862
5963
- name: Run posthog tests
6064
run: |
61-
python setup.py test
65+
pytest --verbose --timeout=30

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,6 @@ pylint.out
1414
posthog-analytics
1515
.idea
1616
.python-version
17-
.coverage
17+
.coverage
18+
pyrightconfig.json
19+
.env

CHANGELOG.md

Lines changed: 260 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,264 @@
1+
## 3.11.0 - 2025-01-28
2+
3+
1. Add the `$ai_span` event to the LangChain callback handler to capture the input and output of intermediary chains.
4+
> LLM observability naming change: event property `$ai_trace_name` is now `$ai_span_name`.
5+
6+
2. Fix serialiazation of Pydantic models in methods.
7+
8+
## 3.10.0 - 2025-01-24
9+
10+
1. Add `$ai_error` and `$ai_is_error` properties to LangChain callback handler, OpenAI, and Anthropic.
11+
12+
## 3.9.3 - 2025-01-23
13+
14+
1. Fix capturing of multiple traces in the LangChain callback handler.
15+
16+
## 3.9.2 - 2025-01-22
17+
18+
1. Fix importing of LangChain callback handler under certain circumstances.
19+
20+
## 3.9.0 - 2025-01-22
21+
22+
1. Add `$ai_trace` event emission to LangChain callback handler.
23+
24+
## 3.8.4 - 2025-01-17
25+
26+
1. Add Anthropic support for LLM Observability.
27+
2. Update LLM Observability to use output_choices.
28+
29+
## 3.8.3 - 2025-01-14
30+
31+
1. Fix setuptools to include the `posthog.ai.openai` and `posthog.ai.langchain` packages for the `posthoganalytics` package.
32+
33+
## 3.8.2 - 2025-01-14
34+
35+
1. Fix setuptools to include the `posthog.ai.openai` and `posthog.ai.langchain` packages.
36+
37+
## 3.8.1 - 2025-01-14
38+
39+
1. Add LLM Observability with support for OpenAI and Langchain callbacks.
40+
41+
## 3.7.5 - 2025-01-03
42+
43+
1. Add `distinct_id` to group_identify
44+
45+
## 3.7.4 - 2024-11-25
46+
47+
1. Fix bug where this SDK incorrectly sent feature flag events with null values when calling `get_feature_flag_payload`.
48+
49+
## 3.7.3 - 2024-11-25
50+
51+
1. Use personless mode when sending an exception without a provided `distinct_id`.
52+
53+
## 3.7.2 - 2024-11-19
54+
55+
1. Add `type` property to exception stacks.
56+
57+
## 3.7.1 - 2024-10-24
58+
59+
1. Add `platform` property to each frame of exception stacks.
60+
61+
## 3.7.0 - 2024-10-03
62+
63+
1. Adds a new `super_properties` parameter on the client that are appended to every /capture call.
64+
65+
## 3.6.7 - 2024-09-24
66+
67+
1. Remove deprecated datetime.utcnow() in favour of datetime.now(tz=tzutc())
68+
69+
## 3.6.6 - 2024-09-16
70+
71+
1. Fix manual capture support for in app frames
72+
73+
## 3.6.5 - 2024-09-10
74+
75+
1. Fix django integration support for manual exception capture.
76+
77+
## 3.6.4 - 2024-09-05
78+
79+
1. Add manual exception capture.
80+
81+
## 3.6.3 - 2024-09-03
82+
83+
1. Make sure setup.py for posthoganalytics package also discovers the new exception integration package.
84+
85+
## 3.6.2 - 2024-09-03
86+
87+
1. Make sure setup.py discovers the new exception integration package.
88+
89+
## 3.6.1 - 2024-09-03
90+
91+
1. Adds django integration to exception autocapture in alpha state. This feature is not yet stable and may change in future versions.
92+
93+
## 3.6.0 - 2024-08-28
94+
95+
1. Adds exception autocapture in alpha state. This feature is not yet stable and may change in future versions.
96+
97+
## 3.5.2 - 2024-08-21
98+
99+
1. Guard for None values in local evaluation
100+
101+
## 3.5.1 - 2024-08-13
102+
103+
1. Remove "-api" suffix from ingestion hostnames
104+
105+
## 3.5.0 - 2024-02-29
106+
107+
1. - Adds a new `feature_flags_request_timeout_seconds` timeout parameter for feature flags which defaults to 3 seconds, updated from the default 10s for all other API calls.
108+
109+
## 3.4.2 - 2024-02-20
110+
111+
1. Add `historical_migration` option for bulk migration to PostHog Cloud.
112+
113+
## 3.4.1 - 2024-02-09
114+
115+
1. Use new hosts for event capture as well
116+
117+
## 3.4.0 - 2024-02-05
118+
119+
1. Point given hosts to new ingestion hosts
120+
121+
## 3.3.4 - 2024-01-30
122+
123+
1. Update type hints for module variables to work with newer versions of mypy
124+
125+
## 3.3.3 - 2024-01-26
126+
127+
1. Remove new relative date operators, combine into regular date operators
128+
129+
## 3.3.2 - 2024-01-19
130+
131+
1. Return success/failure with all capture calls from module functions
132+
133+
## 3.3.1 - 2024-01-10
134+
135+
1. Make sure we don't override any existing feature flag properties when adding locally evaluated feature flag properties.
136+
137+
## 3.3.0 - 2024-01-09
138+
139+
1. When local evaluation is enabled, we automatically add flag information to all events sent to PostHog, whenever possible. This makes it easier to use these events in experiments.
140+
141+
## 3.2.0 - 2024-01-09
142+
143+
1. Numeric property handling for feature flags now does the expected: When passed in a number, we do a numeric comparison. When passed in a string, we do a string comparison. Previously, we always did a string comparison.
144+
2. Add support for relative date operators for local evaluation.
145+
146+
## 3.1.0 - 2023-12-04
147+
148+
1. Increase maximum event size and batch size
149+
150+
## 3.0.2 - 2023-08-17
151+
152+
1. Returns the current flag property with $feature_flag_called events, to make it easier to use in experiments
153+
154+
## 3.0.1 - 2023-04-21
155+
156+
1. Restore how feature flags work when the client library is disabled: All requests return `None` and no events are sent when the client is disabled.
157+
2. Add a `feature_flag_definitions()` debug option, which returns currently loaded feature flag definitions. You can use this to more cleverly decide when to request local evaluation of feature flags.
158+
159+
## 3.0.0 - 2023-04-14
160+
161+
Breaking change:
162+
163+
All events by default now send the `$geoip_disable` property to disable geoip lookup in app. This is because usually we don't
164+
want to update person properties to take the server's location.
165+
166+
The same now happens for feature flag requests, where we discard the IP address of the server for matching on geoip properties like city, country, continent.
167+
168+
To restore previous behaviour, you can set the default to False like so:
169+
170+
```python
171+
posthog.disable_geoip = False
172+
173+
# // and if using client instantiation:
174+
posthog = Posthog('api_key', disable_geoip=False)
175+
176+
```
177+
178+
## 2.5.0 - 2023-04-10
179+
180+
1. Add option for instantiating separate client object
181+
182+
## 2.4.2 - 2023-03-30
183+
184+
1. Update backoff dependency for posthoganalytics package to be the same as posthog package
185+
186+
## 2.4.1 - 2023-03-17
187+
188+
1. Removes accidental print call left in for decide response
189+
190+
## 2.4.0 - 2023-03-14
191+
192+
1. Support evaluating all cohorts in feature flags for local evaluation
193+
194+
## 2.3.1 - 2023-02-07
195+
196+
1. Log instead of raise error on posthog personal api key errors
197+
2. Remove upper bound on backoff dependency
198+
199+
## 2.3.0 - 2023-01-31
200+
201+
1. Add support for returning payloads of matched feature flags
202+
203+
## 2.2.0 - 2022-11-14
204+
205+
Changes:
206+
207+
1. Add support for feature flag variant overrides with local evaluation
208+
209+
## 2.1.2 - 2022-09-15
210+
211+
Changes:
212+
213+
1. Fixes issues with date comparison.
214+
215+
## 2.1.1 - 2022-09-14
216+
217+
Changes:
218+
219+
1. Feature flags local evaluation now supports date property filters as well. Accepts both strings and datetime objects.
220+
221+
## 2.1.0 - 2022-08-11
222+
223+
Changes:
224+
225+
1. Feature flag defaults have been removed
226+
2. Setup logging only when debug mode is enabled.
227+
228+
## 2.0.1 - 2022-08-04
229+
230+
- Make poll_interval configurable
231+
- Add `send_feature_flag_events` parameter to feature flag calls, which determine whether the `$feature_flag_called` event should be sent or not.
232+
- Add `only_evaluate_locally` parameter to feature flag calls, which determines whether the feature flag should only be evaluated locally or not.
233+
234+
## 2.0.0 - 2022-08-02
235+
236+
Breaking changes:
237+
238+
1. The minimum version requirement for PostHog servers is now 1.38. If you're using PostHog Cloud, you satisfy this requirement automatically.
239+
2. Feature flag defaults apply only when there's an error fetching feature flag results. Earlier, if the default was set to `True`, even if a flag resolved to `False`, the default would override this.
240+
**Note: These are removed in 2.0.2**
241+
3. Feature flag remote evaluation doesn't require a personal API key.
242+
243+
New Changes:
244+
245+
1. You can now evaluate feature flags locally (i.e. without sending a request to your PostHog servers) by setting a personal API key, and passing in groups and person properties to `is_feature_enabled` and `get_feature_flag` calls.
246+
2. Introduces a `get_all_flags` method that returns all feature flags. This is useful for when you want to seed your frontend with some initial flags, given a user ID.
247+
248+
## 1.4.9 - 2022-06-13
249+
250+
- Support for sending feature flags with capture calls
251+
252+
## 1.4.8 - 2022-05-12
253+
254+
- Support multi variate feature flags
255+
256+
## 1.4.7 - 2022-04-25
257+
258+
- Allow feature flags usage without project_api_key
259+
1260
## 1.4.1 - 2021-05-28
261+
2262
- Fix packaging issues with Sentry integrations
3263

4264
## 1.4.0 - 2021-05-18

CODEOWNERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
@PostHog/team-feature-flags

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Copyright (c) 2020 PostHog (part of Hiberly Inc)
1+
Copyright (c) 2023 PostHog (part of Hiberly Inc)
22

33
Copyright (c) 2013 Segment Inc. [email protected]
44

Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,13 @@ release_analytics:
1717
rm -rf posthoganalytics
1818
mkdir posthoganalytics
1919
cp -r posthog/* posthoganalytics/
20+
find ./posthoganalytics -type f -exec sed -i '' -e 's/from posthog /from posthoganalytics /g' {} \;
2021
find ./posthoganalytics -type f -exec sed -i '' -e 's/from posthog\./from posthoganalytics\./g' {} \;
2122
rm -rf posthog
2223
python setup_analytics.py sdist bdist_wheel
2324
twine upload dist/*
2425
mkdir posthog
26+
find ./posthoganalytics -type f -exec sed -i '' -e 's/from posthoganalytics /from posthog /g' {} \;
2527
find ./posthoganalytics -type f -exec sed -i '' -e 's/from posthoganalytics\./from posthog\./g' {} \;
2628
cp -r posthoganalytics/* posthog/
2729
rm -rf posthoganalytics

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@
22

33
[![PyPI](https://img.shields.io/pypi/v/posthog)](https://pypi.org/project/posthog/)
44

5-
Please see the main [PostHog docs](https://posthog.com/docs).
65

7-
Specifically, the [Python integration](https://posthog.com/docs/integrations/python-integration) details.
6+
Please see the [Python integration docs](https://posthog.com/docs/integrations/python-integration) for details.
87

98
## Development
109

@@ -14,6 +13,7 @@ Specifically, the [Python integration](https://posthog.com/docs/integrations/pyt
1413
2. Run `source env/bin/activate` (activates the virtual environment)
1514
3. Run `python3 -m pip install -e ".[test]"` (installs the package in develop mode, along with test dependencies)
1615
4. Run `make test`
16+
1. To run a specific test do `pytest -k test_no_api_key`
1717

1818
### Running Locally
1919

@@ -39,7 +39,7 @@ Then navigate to `http://127.0.0.1:8080/sentry-debug/` and you should get an eve
3939

4040
### Releasing Versions
4141

42-
Updated are released using GitHub Actions: after bumping `version.py` in `master`, go to [our release workflow's page](https://github.com/PostHog/posthog-python/actions/workflows/release.yaml) and dispatch it manually, using workflow from `master`.
42+
Updated are released using GitHub Actions: after bumping `version.py` in `master` and adding to `CHANGELOG.md`, go to [our release workflow's page](https://github.com/PostHog/posthog-python/actions/workflows/release.yaml) and dispatch it manually, using workflow from `master`.
4343

4444
## Questions?
4545

0 commit comments

Comments
 (0)