Skip to content

Set server URL during initialization using MixpanelOptions#368

Merged
ketanmixpanel merged 7 commits intomasterfrom
feature/set-server-url-during-init
Feb 17, 2026
Merged

Set server URL during initialization using MixpanelOptions#368
ketanmixpanel merged 7 commits intomasterfrom
feature/set-server-url-during-init

Conversation

@rahul-mixpanel
Copy link
Copy Markdown
Contributor

Summary

Updates the Android implementation to set the server URL during Mixpanel initialization using the new MixpanelOptions API, making it consistent with the iOS implementation and enabling proper ad-blocker detection.

Based on mixpanel-android PR #884.

Changes

Updated Dependencies

  • android/build.gradle: Updated mixpanel-android SDK from 8.2.5 to 8.3.0

Modified Initialization

  • android/src/main/java/com/mixpanel/reactnative/MixpanelReactNativeModule.java:
    • Modified initialize() method to use MixpanelOptions.Builder() pattern
    • Server URL is now configured via .serverURL() during initialization (not after)
    • Also configured .optOutTrackingDefault() and .superProperties() via builder
    • Updated getInstance() call to use the new 4-parameter signature with MixpanelOptions

Backward Compatibility

  • The setServerURL() @ReactMethod remains unchanged for runtime configuration
  • No breaking changes to the React Native API

Benefits

  1. Proper ad-blocker detection: Server URL is now set before the first network request
  2. Platform consistency: Android implementation now matches iOS behavior
  3. Early configuration: All initialization options are set via MixpanelOptions before instance creation

Testing

  • ✅ Successfully built and ran the Android example app
  • ✅ Verified compilation with mixpanel-android 8.3.0
  • ✅ Confirmed backward compatibility maintained

Updated Android implementation to set server URL during initialization
using MixpanelOptions.Builder(), making it consistent with iOS behavior.
This ensures the server URL is configured before the first network request,
enabling proper ad-blocker detection and fallback logic.

Changes:
- Updated mixpanel-android SDK to v8.3.0 in build.gradle
- Modified initialize() to use MixpanelOptions.Builder().setServerURL()
- Maintained backward compatibility of setServerURL() @ReactMethod
- Made gradlew executable

Based on mixpanel-android PR #884
Updated initialize() method to correctly use MixpanelOptions.Builder():
- Use .serverURL() instead of .setServerURL()
- Add .optOutTrackingDefault() and .superProperties() to builder
- Use correct getInstance(Context, String, boolean, MixpanelOptions) signature

This ensures proper configuration during initialization with the new
MixpanelOptions API introduced in mixpanel-android 8.3.0.
@rahul-mixpanel rahul-mixpanel self-assigned this Feb 6, 2026
@rahul-mixpanel rahul-mixpanel marked this pull request as draft February 6, 2026 16:43
@rahul-mixpanel rahul-mixpanel marked this pull request as ready for review February 6, 2026 17:48
Updated MixpanelStarter to demonstrate the new serverURL initialization
feature. Users can now configure a custom Mixpanel server URL during
initialization.

Changes:
- Added serverURL prop to MixpanelProvider component
- Updated MixpanelContext to accept and pass serverURL to init()
- Added anser dependency (required by React Native)
- Configured example to use EU server (https://api-eu.mixpanel.com)
@rahul-mixpanel rahul-mixpanel force-pushed the feature/set-server-url-during-init branch from 539ea52 to bbfce4e Compare February 6, 2026 17:52
@jaredmixpanel
Copy link
Copy Markdown
Collaborator

Looks good but we should add tests.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This pull request updates the Android native module implementation to configure the server URL during Mixpanel initialization using the new MixpanelOptions API introduced in mixpanel-android 8.3.0, achieving parity with the iOS implementation. The change enables proper ad-blocker detection by ensuring the server URL is set before the first network request.

Changes:

  • Updated Android SDK from 8.2.5 to 8.3.0 and iOS SDK from 5.1.3 to 5.2.0
  • Refactored Android initialization to use MixpanelOptions.Builder() pattern for configuration
  • Enhanced MixpanelStarter sample app to demonstrate server URL configuration during initialization

Reviewed changes

Copilot reviewed 7 out of 8 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
android/build.gradle Updated mixpanel-android dependency from 8.2.5 to 8.3.0
android/src/main/java/com/mixpanel/reactnative/MixpanelReactNativeModule.java Refactored initialize() to use MixpanelOptions.Builder() for setting serverURL, optOutTrackingDefault, and superProperties before instance creation
android/gradlew Added standard Gradle wrapper script for Android builds
MixpanelReactNative.podspec Updated Mixpanel-swift dependency from 5.1.3 to 5.2.0
Samples/MixpanelStarter/src/contexts/MixpanelContext.tsx Added serverURL parameter support to MixpanelProvider
Samples/MixpanelStarter/src/App.tsx Demonstrates server URL configuration with EU endpoint
Samples/MixpanelStarter/package.json Reordered dependencies alphabetically and added anser package
.github/workflows/node.js.yml Added Podfile.lock cleanup step to ensure clean iOS pod installation

Comment thread Samples/MixpanelStarter/package.json
Comment thread android/build.gradle
ketanmixpanel and others added 2 commits February 17, 2026 15:08
…tiveModule.java

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@ketanmixpanel ketanmixpanel merged commit a4a09a2 into master Feb 17, 2026
9 checks passed
@ketanmixpanel ketanmixpanel added the enhancement New feature or request label Feb 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants