Skip to content

fix: remove static on server block check#889

Merged
rahul-mixpanel merged 4 commits intofeature/server-url-in-optionsfrom
pr-884-comments
Jan 28, 2026
Merged

fix: remove static on server block check#889
rahul-mixpanel merged 4 commits intofeature/server-url-in-optionsfrom
pr-884-comments

Conversation

@tylerjroach
Copy link
Contributor

  • Remove static on server block check
  • Test improvements

Copy link
Contributor

@rahul-mixpanel rahul-mixpanel left a comment

Choose a reason for hiding this comment

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

requested one change. other than that, LGTM.

* Sets the mIsServerBlocked field on an HttpService instance using reflection.
* This allows tests to set a known initial state before testing async behavior.
*/
private void setServerBlocked(HttpService service) throws Exception {
Copy link
Contributor

Choose a reason for hiding this comment

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

the default for the field "mIsServerBlocked" is false in the current code.

Copy link
Contributor

@rahul-mixpanel rahul-mixpanel left a comment

Choose a reason for hiding this comment

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

LGTM 👍

@rahul-mixpanel rahul-mixpanel merged commit 5d59a88 into feature/server-url-in-options Jan 28, 2026
rahul-mixpanel pushed a commit that referenced this pull request Jan 28, 2026
* Remove static mIsServerBlocked and Remove Thread.sleep from tests

* Add nullability annotations to new options

* simplify

* add annotation
rahul-mixpanel added a commit that referenced this pull request Jan 28, 2026
* feat: Allow serverURL configuration at initialization

This change introduces the ability to set the `serverURL` and `proxyServerInteractor` via `MixpanelOptions` during SDK initialization.

Applying the `serverURL` from `MixpanelOptions` at initialization time ensures that the ad-blocker check correctly uses the specified host (e.g., `api-eu.mixpanel.com`) instead of the default.

The previous `setServerURL()` methods on `MixpanelAPI` have been deprecated in favor of this new approach.

* chore: Centralize default server host constant

- Move the default server host URL to `MPConstants`.
- Update `AnalyticsMessages` and `HttpService` to use the new constant.

* Log error on URL host extraction failure

* Remove placeholder test for proxy interactor

* fix: Add missing assertion for default flags endpoint in test

* feat: Improve log message for URL host extraction failure

* feat: Un-deprecate setServerURL methods

This change removes the deprecation from the `setServerURL` methods, allowing for the server URL to be configured at runtime again.

* refactor: Remove redundant HttpService constructor

* feat: Consolidate proxy server configuration API

Refactored the `MixpanelOptions.Builder` API for setting a custom server URL and proxy interactor.

The separate `proxyServerInteractor()` method has been removed and replaced with a new overloaded `serverURL(String, ProxyServerInteractor)` method. This change makes the API more intuitive by coupling the proxy interactor directly with the server URL it's intended for.

Additionally, Javadocs for server URL configuration have been enhanced with clearer explanations and code examples for routing data to regional servers or a custom proxy.

* feat: Enhance ad-blocker check to consider backup host

The ad-blocker detection logic in `checkIsMixpanelBlocked` has been updated to also check the configured backup host. The SDK will now only be considered blocked if both the primary and backup hosts are inaccessible. If the primary host is blocked but the backup is available, the SDK will continue to function.

* feat: Add tests for ad blocker detection

Add unit tests for the `checkIsMixpanelBlocked` method to verify the logic for detecting when Mixpanel hosts are blocked and correctly handling primary/backup host configurations.

* refactor: Generalize ad blocker check for any server host

Renamed `checkIsMixpanelBlocked` to `checkIsServerBlocked` and related variables to reflect that the functionality checks for any blocked server host, not just Mixpanel-specific ones. This makes the ad blocker detection logic more generic.

* fix: Update Javadoc example and add logging for server check failure

* fix: remove static on server block check (#889)

* Remove static mIsServerBlocked and Remove Thread.sleep from tests

* Add nullability annotations to new options

* simplify

* add annotation

---------

Co-authored-by: Tyler Roach <tylerjroach@gmail.com>
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.

2 participants