Compare commits

..
4 Commits
Author SHA1 Message Date
Neil KakkarandGitHub dfefd0a1b6 Fix analytics package dependencies (#95) 2023-03-30 10:34:59 -04:00
Neil KakkarandGitHub 477a688016 Add CI to ensure no prints (#94) 2023-03-17 15:22:59 +00:00
Neil KakkarandGitHub fa474a0fe6 Release for print fix (#93) 2023-03-17 12:41:16 +00:00
Jann KleenandGitHub f8bc3f17eb Remove print() call (#92) 2023-03-17 12:37:01 +00:00
11 changed files with 33 additions and 21 deletions
+4
View File
@@ -33,6 +33,10 @@ jobs:
- name: Check formatting with black
run: |
black --check .
- name: Lint with flake8
run: |
flake8 posthog --ignore E501
- name: Check import order with isort
run: |
+8
View File
@@ -1,3 +1,11 @@
## 2.4.2 - 2023-03-30
1. Update backoff dependency for posthoganalytics package to be the same as posthog package
## 2.4.1 - 2023-03-17
1. Removes accidental print call left in for decide response
## 2.4.0 - 2023-03-14
1. Support evaluating all cohorts in feature flags for local evaluation
+2 -1
View File
@@ -1,4 +1,5 @@
from typing import Callable, Dict, Optional
import datetime # noqa: F401
from typing import Callable, Dict, Optional # noqa: F401
from posthog.client import Client
from posthog.version import VERSION
+5 -6
View File
@@ -157,7 +157,6 @@ class Client(object):
}
resp_data = decide(self.api_key, self.host, timeout=10, **request_data)
print(resp_data)
return resp_data
def capture(
@@ -392,7 +391,7 @@ class Client(object):
except APIError as e:
if e.status == 401:
self.log.error(
f"[FEATURE FLAGS] Error loading feature flags: To use feature flags, please set a valid personal_api_key. More information: https://posthog.com/docs/api/overview"
"[FEATURE FLAGS] Error loading feature flags: To use feature flags, please set a valid personal_api_key. More information: https://posthog.com/docs/api/overview"
)
if self.debug:
raise APIError(
@@ -495,7 +494,7 @@ class Client(object):
require("distinct_id", distinct_id, ID_TYPES)
require("groups", groups, dict)
if self.feature_flags == None and self.personal_api_key:
if self.feature_flags is None and self.personal_api_key:
self.load_feature_flags()
response = None
@@ -535,7 +534,7 @@ class Client(object):
feature_flag_reported_key = f"{key}_{str(response)}"
if (
feature_flag_reported_key not in self.distinct_ids_feature_flags_reported[distinct_id]
and send_feature_flag_events
and send_feature_flag_events # noqa: W503
):
self.capture(
distinct_id,
@@ -631,7 +630,7 @@ class Client(object):
require("distinct_id", distinct_id, ID_TYPES)
require("groups", groups, dict)
if self.feature_flags == None and self.personal_api_key:
if self.feature_flags is None and self.personal_api_key:
self.load_feature_flags()
flags = {}
@@ -651,7 +650,7 @@ class Client(object):
matched_payload = self._compute_payload_locally(flag["key"], flags[flag["key"]])
if matched_payload:
payloads[flag["key"]] = matched_payload
except InconclusiveMatchError as e:
except InconclusiveMatchError:
# No need to log this, since it's just telling us to fall back to `/decide`
fallback_to_decide = True
except Exception as e:
+1 -1
View File
@@ -11,7 +11,7 @@ def get_distinct_id(request):
return None
try:
return GET_DISTINCT_ID(request)
except:
except: # noqa: E722
return None
+2 -3
View File
@@ -1,5 +1,4 @@
from sentry_sdk._types import MYPY
from sentry_sdk.client import Client
from sentry_sdk.hub import Hub
from sentry_sdk.integrations import Integration
from sentry_sdk.scope import add_global_event_processor
@@ -10,9 +9,9 @@ from posthog.request import DEFAULT_HOST
from posthog.sentry import POSTHOG_ID_TAG
if MYPY:
from typing import Any, Dict, Optional
from typing import Optional # noqa: F401
from sentry_sdk._types import Event, Hint
from sentry_sdk._types import Event, Hint # noqa: F401
class PostHogIntegration(Integration):
+2 -3
View File
@@ -1,7 +1,6 @@
import time
import unittest
from datetime import date, datetime
from unittest.mock import MagicMock
from datetime import datetime
from uuid import uuid4
import mock
@@ -28,7 +27,7 @@ class TestClient(unittest.TestCase):
def set_fail(self, e, batch):
"""Mark the failure handler"""
print("FAIL", e, batch)
print("FAIL", e, batch) # noqa: T201
self.failed = True
def setUp(self):
+4 -4
View File
@@ -24,7 +24,7 @@ class TestLocalEvaluation(unittest.TestCase):
def set_fail(self, e, batch):
"""Mark the failure handler"""
print("FAIL", e, batch)
print("FAIL", e, batch) # noqa: T201
self.failed = True
def setUp(self):
@@ -1739,7 +1739,7 @@ class TestMatchProperties(unittest.TestCase):
self.assertFalse(match_property(property_b, {"key": "three"}))
def test_match_properties_regex(self):
property_a = self.property(key="key", value="\.com$", operator="regex")
property_a = self.property(key="key", value="\.com$", operator="regex") # noqa: W605
self.assertTrue(match_property(property_a, {"key": "value.com"}))
self.assertTrue(match_property(property_a, {"key": "value2.com"}))
@@ -1747,7 +1747,7 @@ class TestMatchProperties(unittest.TestCase):
self.assertFalse(match_property(property_a, {"key": "Alakazam"}))
self.assertFalse(match_property(property_a, {"key": 123}))
self.assertFalse(match_property(property_a, {"key": "valuecom"}))
self.assertFalse(match_property(property_a, {"key": "value\com"}))
self.assertFalse(match_property(property_a, {"key": "value\com"})) # noqa: W605
property_b = self.property(key="key", value="3", operator="regex")
self.assertTrue(match_property(property_b, {"key": "3"}))
@@ -1997,7 +1997,7 @@ class TestConsistency(unittest.TestCase):
def set_fail(self, e, batch):
"""Mark the failure handler"""
print("FAIL", e, batch)
print("FAIL", e, batch) # noqa: T201
self.failed = True
def setUp(self):
+2 -2
View File
@@ -1,4 +1,4 @@
VERSION = "2.4.0"
VERSION = "2.4.2"
if __name__ == "__main__":
print(VERSION, end="")
print(VERSION, end="") # noqa: T201
+2
View File
@@ -20,6 +20,8 @@ extras_require = {
"dev": [
"black",
"isort",
"flake8",
"flake8-print",
"pre-commit",
],
"test": ["mock>=2.0.0", "freezegun==0.3.15", "pylint", "flake8", "coverage", "pytest"],
+1 -1
View File
@@ -14,7 +14,7 @@ long_description = """
PostHog is developer-friendly, self-hosted product analytics. posthog-python is the python package.
"""
install_requires = ["requests>=2.7,<3.0", "six>=1.5", "monotonic>=1.5", "backoff==1.6.0", "python-dateutil>2.1"]
install_requires = ["requests>=2.7,<3.0", "six>=1.5", "monotonic>=1.5", "backoff>=1.10.0", "python-dateutil>2.1"]
tests_require = ["mock>=2.0.0"]