Skip to content

fix: send alias through the configured Consumer's transport - #208

Draft
rahul-mixpanel wants to merge 2 commits into
masterfrom
rahulraveendran-sdk-370-python-101-mixpanelalias-ignores
Draft

rahul-mixpanel wants to merge 2 commits into
masterfrom
rahulraveendran-sdk-370-python-101-mixpanelalias-ignores

Conversation

@rahul-mixpanel

@rahul-mixpanel rahul-mixpanel commented Nov 27, 2026 •

Copy link
Copy Markdown

Related to #101 · Linear SDK-370

Problem

Mixpanel.alias() always created a new Consumer(). Settings on the consumer you passed to Mixpanel(...) were ignored, including api_host, request_timeout, retry_limit and verify_cert. So a project using api_host="api-eu.mixpanel.com" (EU data residency) still sent $create_alias to the US host.

Change

alias() still sends synchronously, as the docstring promises. It now reuses the transport you configured:

  • Consumer (exact type): used directly.
  • BufferedConsumer (including subclasses): its inner Consumer is used, so the alias skips the buffer and is sent right away. If there is no inner consumer, alias falls back to a default Consumer(), as before. That covers a subclass that skips super().__init__() and a Mock(spec=BufferedConsumer).
  • Everything else: no change. Alias still uses a default Consumer(), because these consumers may not send synchronously. This includes custom consumers and Consumer subclasses.

Known limitation (open design question): a Consumer subclass configured with, say, the EU host still sends alias to the default US host. This PR checks the type exactly (type(...) is Consumer), so a subclass that overrides send() to queue or defer delivery can't make alias asynchronous. Using isinstance(..., Consumer) instead would cover those subclasses' hosts too, at that small risk. The current behaviour is deliberately left as is, pending a decision.

The payload is unchanged, and so is the public API.

Cross-SDK parity

  • Node (alias): calls track("$create_alias"), so it uses the configured host. This change matches it.
  • Go (Alias): uses the client's configured host. This change matches it.
  • PHP (createAlias): turns off fork/async, then sends through the configured consumer strategy, including user-registered strategies. So PHP does send alias through a custom consumer. It just forces the built-in strategies to be synchronous.
  • Ruby (alias): always builds a fresh Consumer, regardless of the configured consumer. It accepts an optional events_endpoint.

Routing alias through fully custom consumers, which #101 and #114 ask for, is out of scope here. That is flagged on the Linear ticket for a decision.

Tests

  • test_alias_uses_configured_api_host, parametrised over Consumer and BufferedConsumer, checks that alias goes to https://api-eu.mixpanel.com/track with the expected payload, and that a BufferedConsumer sends it immediately.
  • test_alias_with_mocked_buffered_consumer checks that a Mock(spec=BufferedConsumer) falls back to the default Consumer() instead of raising AttributeError.
  • Full suite: 396 passed. ruff check and ruff format --check are clean.

🤖 Generated with Claude Code

Mixpanel.alias() always built a bare Consumer(), so it ignored the
api_host (EU/IN data residency), timeouts, retries and verify_cert of
the Consumer or BufferedConsumer passed to Mixpanel(). Alias is still
sent synchronously: a Consumer is used directly, and a BufferedConsumer's
inner Consumer is used so the buffer is bypassed. Custom consumers keep
the previous default Consumer() behaviour.

Related to #101

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@linear-code

linear-code Bot commented Nov 27, 2026

Copy link
Copy Markdown

SDK-370

@codecov

codecov Bot commented Nov 27, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.54%. Comparing base (c44c420) to head (08f51ff).

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #208      +/-   ##
==========================================
+ Coverage   96.51%   96.54%   +0.02%     
==========================================
  Files          15       15              
  Lines        2955     2977      +22     
  Branches      180      182       +2     
==========================================
+ Hits         2852     2874      +22     
  Misses         66       66              
  Partials       37       37              
Flag Coverage Δ
openfeature-provider 51.52% <0.00%> (-0.15%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@greptile-apps

greptile-apps Bot commented Nov 27, 2026 •

Copy link
Copy Markdown

Confidence Score: 5/5 · The PR appears safe to merge.RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge.

Reviews (2) · Last reviewed commit: "fix: fall back to default Consumer when ..." · Reviewed by Greptile

… consumer

Avoids AttributeError for BufferedConsumer subclasses that skip
super().__init__() and for Mock(spec=BufferedConsumer) in user tests.
Also assert the alias URL and payload in the api_host test.

Related to #101

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
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.

1 participant