posthog 3.19.1__tar.gz → 6.8.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (89) hide show
  1. posthog-6.8.0/LICENSE +48 -0
  2. posthog-6.8.0/PKG-INFO +141 -0
  3. posthog-6.8.0/README.md +66 -0
  4. posthog-6.8.0/posthog/__init__.py +765 -0
  5. posthog-6.8.0/posthog/ai/anthropic/__init__.py +27 -0
  6. posthog-6.8.0/posthog/ai/anthropic/anthropic.py +248 -0
  7. posthog-6.8.0/posthog/ai/anthropic/anthropic_async.py +248 -0
  8. posthog-6.8.0/posthog/ai/anthropic/anthropic_converter.py +443 -0
  9. {posthog-3.19.1 → posthog-6.8.0}/posthog/ai/anthropic/anthropic_providers.py +14 -9
  10. posthog-6.8.0/posthog/ai/gemini/__init__.py +22 -0
  11. posthog-6.8.0/posthog/ai/gemini/gemini.py +420 -0
  12. posthog-6.8.0/posthog/ai/gemini/gemini_converter.py +586 -0
  13. {posthog-3.19.1 → posthog-6.8.0}/posthog/ai/langchain/callbacks.py +209 -56
  14. posthog-6.8.0/posthog/ai/openai/__init__.py +20 -0
  15. posthog-6.8.0/posthog/ai/openai/openai.py +575 -0
  16. posthog-6.8.0/posthog/ai/openai/openai_async.py +633 -0
  17. posthog-6.8.0/posthog/ai/openai/openai_converter.py +735 -0
  18. posthog-6.8.0/posthog/ai/openai/openai_providers.py +98 -0
  19. posthog-6.8.0/posthog/ai/sanitization.py +226 -0
  20. posthog-6.8.0/posthog/ai/types.py +125 -0
  21. posthog-6.8.0/posthog/ai/utils.py +589 -0
  22. posthog-6.8.0/posthog/args.py +71 -0
  23. posthog-6.8.0/posthog/client.py +2066 -0
  24. {posthog-3.19.1 → posthog-6.8.0}/posthog/consumer.py +9 -5
  25. posthog-6.8.0/posthog/contexts.py +284 -0
  26. {posthog-3.19.1 → posthog-6.8.0}/posthog/exception_capture.py +8 -23
  27. {posthog-3.19.1 → posthog-6.8.0}/posthog/exception_utils.py +191 -178
  28. posthog-6.8.0/posthog/feature_flags.py +620 -0
  29. posthog-6.8.0/posthog/integrations/django.py +319 -0
  30. posthog-6.8.0/posthog/py.typed +0 -0
  31. {posthog-3.19.1 → posthog-6.8.0}/posthog/request.py +68 -11
  32. posthog-6.8.0/posthog/test/test_before_send.py +218 -0
  33. posthog-6.8.0/posthog/test/test_client.py +2468 -0
  34. {posthog-3.19.1 → posthog-6.8.0}/posthog/test/test_consumer.py +36 -9
  35. posthog-6.8.0/posthog/test/test_contexts.py +207 -0
  36. posthog-6.8.0/posthog/test/test_exception_capture.py +34 -0
  37. posthog-6.8.0/posthog/test/test_feature_flag.py +189 -0
  38. posthog-6.8.0/posthog/test/test_feature_flag_result.py +444 -0
  39. {posthog-3.19.1 → posthog-6.8.0}/posthog/test/test_feature_flags.py +2263 -455
  40. posthog-6.8.0/posthog/test/test_module.py +32 -0
  41. {posthog-3.19.1 → posthog-6.8.0}/posthog/test/test_request.py +38 -7
  42. posthog-6.8.0/posthog/test/test_size_limited_dict.py +24 -0
  43. posthog-6.8.0/posthog/test/test_types.py +208 -0
  44. posthog-6.8.0/posthog/test/test_utils.py +298 -0
  45. posthog-6.8.0/posthog/types.py +308 -0
  46. posthog-6.8.0/posthog/utils.py +519 -0
  47. {posthog-3.19.1 → posthog-6.8.0}/posthog/version.py +1 -1
  48. posthog-6.8.0/posthog.egg-info/PKG-INFO +141 -0
  49. {posthog-3.19.1 → posthog-6.8.0}/posthog.egg-info/SOURCES.txt +18 -6
  50. {posthog-3.19.1 → posthog-6.8.0}/posthog.egg-info/requires.txt +15 -16
  51. posthog-6.8.0/pyproject.toml +100 -0
  52. posthog-6.8.0/setup.cfg +4 -0
  53. posthog-6.8.0/setup.py +35 -0
  54. posthog-3.19.1/LICENSE +0 -22
  55. posthog-3.19.1/PKG-INFO +0 -80
  56. posthog-3.19.1/README.md +0 -48
  57. posthog-3.19.1/posthog/__init__.py +0 -604
  58. posthog-3.19.1/posthog/ai/anthropic/__init__.py +0 -12
  59. posthog-3.19.1/posthog/ai/anthropic/anthropic.py +0 -206
  60. posthog-3.19.1/posthog/ai/anthropic/anthropic_async.py +0 -206
  61. posthog-3.19.1/posthog/ai/openai/__init__.py +0 -5
  62. posthog-3.19.1/posthog/ai/openai/openai.py +0 -327
  63. posthog-3.19.1/posthog/ai/openai/openai_async.py +0 -327
  64. posthog-3.19.1/posthog/ai/openai/openai_providers.py +0 -41
  65. posthog-3.19.1/posthog/ai/utils.py +0 -302
  66. posthog-3.19.1/posthog/client.py +0 -1085
  67. posthog-3.19.1/posthog/exception_integrations/__init__.py +0 -5
  68. posthog-3.19.1/posthog/exception_integrations/django.py +0 -88
  69. posthog-3.19.1/posthog/feature_flags.py +0 -338
  70. posthog-3.19.1/posthog/sentry/__init__.py +0 -1
  71. posthog-3.19.1/posthog/sentry/django.py +0 -28
  72. posthog-3.19.1/posthog/sentry/posthog_integration.py +0 -52
  73. posthog-3.19.1/posthog/test/test_client.py +0 -1214
  74. posthog-3.19.1/posthog/test/test_exception_capture.py +0 -63
  75. posthog-3.19.1/posthog/test/test_module.py +0 -48
  76. posthog-3.19.1/posthog/test/test_utils.py +0 -130
  77. posthog-3.19.1/posthog/utils.py +0 -167
  78. posthog-3.19.1/posthog.egg-info/PKG-INFO +0 -80
  79. posthog-3.19.1/pyproject.toml +0 -10
  80. posthog-3.19.1/setup.cfg +0 -10
  81. posthog-3.19.1/setup.py +0 -103
  82. {posthog-3.19.1 → posthog-6.8.0}/MANIFEST.in +0 -0
  83. {posthog-3.19.1 → posthog-6.8.0}/posthog/ai/__init__.py +0 -0
  84. {posthog-3.19.1 → posthog-6.8.0}/posthog/ai/langchain/__init__.py +0 -0
  85. /posthog-3.19.1/posthog/py.typed → /posthog-6.8.0/posthog/integrations/__init__.py +0 -0
  86. {posthog-3.19.1 → posthog-6.8.0}/posthog/poller.py +0 -0
  87. {posthog-3.19.1 → posthog-6.8.0}/posthog/test/__init__.py +0 -0
  88. {posthog-3.19.1 → posthog-6.8.0}/posthog.egg-info/dependency_links.txt +0 -0
  89. {posthog-3.19.1 → posthog-6.8.0}/posthog.egg-info/top_level.txt +0 -0
posthog-6.8.0/LICENSE ADDED
@@ -0,0 +1,48 @@
1
+ Copyright (c) 2023 PostHog (part of Hiberly Inc)
2
+
3
+ Copyright (c) 2013 Segment Inc. friends@segment.com
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
22
+
23
+ ---
24
+
25
+ Some files in this codebase contain code from getsentry/sentry-javascript by Software, Inc. dba Sentry.
26
+ In such cases it is explicitly stated in the file header. This license only applies to the relevant code in such cases.
27
+
28
+ MIT License
29
+
30
+ Copyright (c) 2012 Functional Software, Inc. dba Sentry
31
+
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:
38
+
39
+ The above copyright notice and this permission notice shall be included in all
40
+ copies or substantial portions of the Software.
41
+
42
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
43
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
44
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
45
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
46
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
47
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
48
+ SOFTWARE.
posthog-6.8.0/PKG-INFO ADDED
@@ -0,0 +1,141 @@
1
+ Metadata-Version: 2.4
2
+ Name: posthog
3
+ Version: 6.8.0
4
+ Summary: Integrate PostHog into any python application.
5
+ Home-page: https://github.com/posthog/posthog-python
6
+ Author: Posthog
7
+ Author-email: PostHog <hey@posthog.com>
8
+ Maintainer: PostHog
9
+ Maintainer-email: PostHog <hey@posthog.com>
10
+ License: MIT
11
+ Project-URL: Homepage, https://github.com/posthog/posthog-python
12
+ Project-URL: Repository, https://github.com/posthog/posthog-python
13
+ Classifier: Development Status :: 5 - Production/Stable
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: Operating System :: OS Independent
16
+ Classifier: License :: OSI Approved :: MIT License
17
+ Classifier: Programming Language :: Python
18
+ Classifier: Programming Language :: Python :: 3.9
19
+ Classifier: Programming Language :: Python :: 3.10
20
+ Classifier: Programming Language :: Python :: 3.11
21
+ Classifier: Programming Language :: Python :: 3.12
22
+ Classifier: Programming Language :: Python :: 3.13
23
+ Requires-Python: >=3.9
24
+ Description-Content-Type: text/markdown
25
+ License-File: LICENSE
26
+ Requires-Dist: requests<3.0,>=2.7
27
+ Requires-Dist: six>=1.5
28
+ Requires-Dist: python-dateutil>=2.2
29
+ Requires-Dist: backoff>=1.10.0
30
+ Requires-Dist: distro>=1.5.0
31
+ Requires-Dist: typing-extensions>=4.2.0
32
+ Provides-Extra: langchain
33
+ Requires-Dist: langchain>=0.2.0; extra == "langchain"
34
+ Provides-Extra: dev
35
+ Requires-Dist: django-stubs; extra == "dev"
36
+ Requires-Dist: lxml; extra == "dev"
37
+ Requires-Dist: mypy; extra == "dev"
38
+ Requires-Dist: mypy-baseline; extra == "dev"
39
+ Requires-Dist: types-mock; extra == "dev"
40
+ Requires-Dist: types-python-dateutil; extra == "dev"
41
+ Requires-Dist: types-requests; extra == "dev"
42
+ Requires-Dist: types-setuptools; extra == "dev"
43
+ Requires-Dist: types-six; extra == "dev"
44
+ Requires-Dist: pre-commit; extra == "dev"
45
+ Requires-Dist: pydantic; extra == "dev"
46
+ Requires-Dist: ruff; extra == "dev"
47
+ Requires-Dist: setuptools; extra == "dev"
48
+ Requires-Dist: packaging; extra == "dev"
49
+ Requires-Dist: wheel; extra == "dev"
50
+ Requires-Dist: twine; extra == "dev"
51
+ Requires-Dist: tomli; extra == "dev"
52
+ Requires-Dist: tomli_w; extra == "dev"
53
+ Provides-Extra: test
54
+ Requires-Dist: mock>=2.0.0; extra == "test"
55
+ Requires-Dist: freezegun==1.5.1; extra == "test"
56
+ Requires-Dist: coverage; extra == "test"
57
+ Requires-Dist: pytest; extra == "test"
58
+ Requires-Dist: pytest-timeout; extra == "test"
59
+ Requires-Dist: pytest-asyncio; extra == "test"
60
+ Requires-Dist: django; extra == "test"
61
+ Requires-Dist: openai; extra == "test"
62
+ Requires-Dist: anthropic; extra == "test"
63
+ Requires-Dist: langgraph>=0.4.8; extra == "test"
64
+ Requires-Dist: langchain-core>=0.3.65; extra == "test"
65
+ Requires-Dist: langchain-community>=0.3.25; extra == "test"
66
+ Requires-Dist: langchain-openai>=0.3.22; extra == "test"
67
+ Requires-Dist: langchain-anthropic>=0.3.15; extra == "test"
68
+ Requires-Dist: google-genai; extra == "test"
69
+ Requires-Dist: pydantic; extra == "test"
70
+ Requires-Dist: parameterized>=0.8.1; extra == "test"
71
+ Dynamic: author
72
+ Dynamic: home-page
73
+ Dynamic: license-file
74
+ Dynamic: maintainer
75
+
76
+ # PostHog Python
77
+
78
+ <p align="center">
79
+ <img alt="posthoglogo" src="https://user-images.githubusercontent.com/65415371/205059737-c8a4f836-4889-4654-902e-f302b187b6a0.png">
80
+ </p>
81
+ <p align="center">
82
+ <a href="https://pypi.org/project/posthog/"><img alt="pypi installs" src="https://img.shields.io/pypi/v/posthog"/></a>
83
+ <img alt="GitHub contributors" src="https://img.shields.io/github/contributors/posthog/posthog-python">
84
+ <img alt="GitHub commit activity" src="https://img.shields.io/github/commit-activity/m/posthog/posthog-python"/>
85
+ <img alt="GitHub closed issues" src="https://img.shields.io/github/issues-closed/posthog/posthog-python"/>
86
+ </p>
87
+
88
+ Please see the [Python integration docs](https://posthog.com/docs/integrations/python-integration) for details.
89
+
90
+ ## Development
91
+
92
+ ### Testing Locally
93
+
94
+ We recommend using [uv](https://docs.astral.sh/uv/). It's super fast.
95
+
96
+ 1. Run `uv venv env` (creates virtual environment called "env")
97
+ * or `python3 -m venv env`
98
+ 2. Run `source env/bin/activate` (activates the virtual environment)
99
+ 3. Run `uv sync --extra dev --extra test` (installs the package in develop mode, along with test dependencies)
100
+ * or `pip install -e ".[dev,test]"`
101
+ 4. you have to run `pre-commit install` to have auto linting pre commit
102
+ 5. Run `make test`
103
+ 1. To run a specific test do `pytest -k test_no_api_key`
104
+
105
+ ## PostHog recommends `uv` so...
106
+
107
+ ```bash
108
+ uv python install 3.9.19
109
+ uv python pin 3.9.19
110
+ uv venv
111
+ source env/bin/activate
112
+ uv sync --extra dev --extra test
113
+ pre-commit install
114
+ make test
115
+ ```
116
+
117
+ ### Running Locally
118
+
119
+ Assuming you have a [local version of PostHog](https://posthog.com/docs/developing-locally) running, you can run `python3 example.py` to see the library in action.
120
+
121
+ ### Releasing Versions
122
+
123
+ Updates are released automatically using GitHub Actions when `version.py` is updated on `master`. After bumping `version.py` in `master` and adding to `CHANGELOG.md`, the [release workflow](https://github.com/PostHog/posthog-python/blob/master/.github/workflows/release.yaml) will automatically trigger and deploy the new version.
124
+
125
+ If you need to check the latest runs or manually trigger a release, you can 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`.
126
+
127
+
128
+ ### Testing changes locally with the PostHog app
129
+
130
+ You can run `make prep_local`, and it'll create a new folder alongside the SDK repo one called `posthog-python-local`, which you can then import into the posthog project by changing pyproject.toml to look like this:
131
+ ```toml
132
+ dependencies = [
133
+ ...
134
+ "posthoganalytics" #NOTE: no version number
135
+ ...
136
+ ]
137
+ ...
138
+ [tools.uv.sources]
139
+ posthoganalytics = { path = "../posthog-python-local" }
140
+ ```
141
+ This'll let you build and test SDK changes fully locally, incorporating them into your local posthog app stack. It mainly takes care of the `posthog -> posthoganalytics` module renaming. You'll need to re-run `make prep_local` each time you make a change, and re-run `uv sync --active` in the posthog app project.
@@ -0,0 +1,66 @@
1
+ # PostHog Python
2
+
3
+ <p align="center">
4
+ <img alt="posthoglogo" src="https://user-images.githubusercontent.com/65415371/205059737-c8a4f836-4889-4654-902e-f302b187b6a0.png">
5
+ </p>
6
+ <p align="center">
7
+ <a href="https://pypi.org/project/posthog/"><img alt="pypi installs" src="https://img.shields.io/pypi/v/posthog"/></a>
8
+ <img alt="GitHub contributors" src="https://img.shields.io/github/contributors/posthog/posthog-python">
9
+ <img alt="GitHub commit activity" src="https://img.shields.io/github/commit-activity/m/posthog/posthog-python"/>
10
+ <img alt="GitHub closed issues" src="https://img.shields.io/github/issues-closed/posthog/posthog-python"/>
11
+ </p>
12
+
13
+ Please see the [Python integration docs](https://posthog.com/docs/integrations/python-integration) for details.
14
+
15
+ ## Development
16
+
17
+ ### Testing Locally
18
+
19
+ We recommend using [uv](https://docs.astral.sh/uv/). It's super fast.
20
+
21
+ 1. Run `uv venv env` (creates virtual environment called "env")
22
+ * or `python3 -m venv env`
23
+ 2. Run `source env/bin/activate` (activates the virtual environment)
24
+ 3. Run `uv sync --extra dev --extra test` (installs the package in develop mode, along with test dependencies)
25
+ * or `pip install -e ".[dev,test]"`
26
+ 4. you have to run `pre-commit install` to have auto linting pre commit
27
+ 5. Run `make test`
28
+ 1. To run a specific test do `pytest -k test_no_api_key`
29
+
30
+ ## PostHog recommends `uv` so...
31
+
32
+ ```bash
33
+ uv python install 3.9.19
34
+ uv python pin 3.9.19
35
+ uv venv
36
+ source env/bin/activate
37
+ uv sync --extra dev --extra test
38
+ pre-commit install
39
+ make test
40
+ ```
41
+
42
+ ### Running Locally
43
+
44
+ Assuming you have a [local version of PostHog](https://posthog.com/docs/developing-locally) running, you can run `python3 example.py` to see the library in action.
45
+
46
+ ### Releasing Versions
47
+
48
+ Updates are released automatically using GitHub Actions when `version.py` is updated on `master`. After bumping `version.py` in `master` and adding to `CHANGELOG.md`, the [release workflow](https://github.com/PostHog/posthog-python/blob/master/.github/workflows/release.yaml) will automatically trigger and deploy the new version.
49
+
50
+ If you need to check the latest runs or manually trigger a release, you can 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`.
51
+
52
+
53
+ ### Testing changes locally with the PostHog app
54
+
55
+ You can run `make prep_local`, and it'll create a new folder alongside the SDK repo one called `posthog-python-local`, which you can then import into the posthog project by changing pyproject.toml to look like this:
56
+ ```toml
57
+ dependencies = [
58
+ ...
59
+ "posthoganalytics" #NOTE: no version number
60
+ ...
61
+ ]
62
+ ...
63
+ [tools.uv.sources]
64
+ posthoganalytics = { path = "../posthog-python-local" }
65
+ ```
66
+ This'll let you build and test SDK changes fully locally, incorporating them into your local posthog app stack. It mainly takes care of the `posthog -> posthoganalytics` module renaming. You'll need to re-run `make prep_local` each time you make a change, and re-run `uv sync --active` in the posthog app project.