Skip to content

feat: add analytics_url to send flag analytics to a different host#215

Open
adamvialpando wants to merge 3 commits into
mainfrom
feat/analytics-url-213
Open

feat: add analytics_url to send flag analytics to a different host#215
adamvialpando wants to merge 3 commits into
mainfrom
feat/analytics-url-213

Conversation

@adamvialpando

Copy link
Copy Markdown

Adds an analytics_url parameter to the Flagsmith client so flag analytics can be posted to a different host from where evaluations happen.

The Edge Proxy doesn't handle the analytics endpoint, so customers running the Python SDK in local eval mode behind the proxy with enable_analytics=True were silently dropping every analytics POST. Setting analytics_url overrides only the analytics endpoint and leaves evaluations going through api_url as before. When analytics_url is unset the SDK keeps deriving the endpoint from api_url + /analytics/flags/, so nothing changes for existing setups. This mirrors the pattern the Node SDK already exposes via analyticsUrl.

Closes #213

@adamvialpando adamvialpando requested a review from a team as a code owner May 18, 2026 18:21
@adamvialpando adamvialpando requested review from khvn26 and removed request for a team May 18, 2026 18:21
adamvialpando and others added 2 commits June 11, 2026 10:33
When the SDK evaluates flags through an Edge Proxy, the analytics POST built
from api_url hits a path the proxy does not handle and events are silently
dropped. Setting analytics_url overrides just the analytics endpoint, so
analytics can be sent to the core Flagsmith API while evaluations keep going
through the proxy. When analytics_url is unset, the SDK still derives the
endpoint from api_url + /analytics/flags/, so existing setups are unaffected.

Closes #213
@adamvialpando adamvialpando force-pushed the feat/analytics-url-213 branch from 90c2f21 to 77e99d4 Compare June 11, 2026 17:38
  Extract _ensure_trailing_slash to bring Flagsmith.__init__ back under the
  flake8 C901 limit that pre-commit.ci flagged. Add an integration test for
  the default analytics endpoint, and filter both analytics tests by exact
  URL so they no longer depend on the global session's cross-test traffic.
@adamvialpando adamvialpando force-pushed the feat/analytics-url-213 branch from 92af2a0 to 5c6d316 Compare June 16, 2026 21:30

@khvn26 khvn26 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just one comment. Otherwise, a great (and cheap!) addition; IMO, all server-side SDKs should have them.

Comment thread README.md
For full documentation visit
[https://docs.flagsmith.com/clients/server-side?language=python](https://docs.flagsmith.com/clients/server-side?language=python).

### Sending flag analytics to a different host than evaluations

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wouldn't document this here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support separate analytics URL configuration (parity with Node SDK)

2 participants