Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions flagsmith/analytics.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

from requests_futures.sessions import FuturesSession # type: ignore

from flagsmith.version import __version__
from flagsmith.version import DEFAULT_USER_AGENT, __version__

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -218,7 +218,7 @@ def flush(self) -> None:
headers={
"Content-Type": "application/json; charset=utf-8",
"X-Environment-Key": self._environment_key,
"Flagsmith-SDK-User-Agent": f"flagsmith-python-client/{__version__}",
"Flagsmith-SDK-User-Agent": DEFAULT_USER_AGENT,
},
)
except RuntimeError:
Expand Down
3 changes: 1 addition & 2 deletions flagsmith/flagsmith.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,12 @@
TraitMapping,
)
from flagsmith.utils.identities import generate_identity_data
from flagsmith.version import __version__
from flagsmith.version import DEFAULT_USER_AGENT

logger = logging.getLogger(__name__)

DEFAULT_API_URL = "https://edge.api.flagsmith.com/api/v1/"
DEFAULT_REALTIME_API_URL = "https://realtime.flagsmith.com/"
DEFAULT_USER_AGENT = f"flagsmith-python-sdk/{__version__}"


class Flagsmith:
Expand Down
2 changes: 2 additions & 0 deletions flagsmith/version.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from importlib.metadata import version

__version__ = version("flagsmith")

DEFAULT_USER_AGENT = f"flagsmith-python-sdk/{__version__}"
2 changes: 1 addition & 1 deletion tests/test_event_processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ def test_flush_sends_correct_http_request(event_processor: EventProcessor) -> No
headers = call_kwargs[1]["headers"]
assert headers["X-Environment-Key"] == "test_key"
assert headers["Content-Type"] == "application/json; charset=utf-8"
assert "flagsmith-python-client/" in headers["Flagsmith-SDK-User-Agent"]
assert "flagsmith-python-sdk/" in headers["Flagsmith-SDK-User-Agent"]

body = json.loads(call_kwargs[1]["data"])
assert "environment_key" not in body
Expand Down
Loading