feat: Introduce MixpanelApi Builder pattern and expose JsonSerializer option#51
Merged
tylerjroach merged 10 commits intomasterfrom Dec 3, 2025
Merged
feat: Introduce MixpanelApi Builder pattern and expose JsonSerializer option#51tylerjroach merged 10 commits intomasterfrom
tylerjroach merged 10 commits intomasterfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR introduces a flexible Builder pattern for MixpanelAPI configuration and moves Jackson serialization support to a separate optional extension module. The changes maintain full backward compatibility while providing improved performance options for high-volume use cases.
Key Changes
- Builder Pattern: New fluent API for MixpanelAPI configuration with support for all constructor parameters (custom endpoints, gzip compression, feature flags, custom serializers)
- JSON Serializer Abstraction: Introduced
JsonSerializerinterface withOrgJsonSerializeras the default implementation, allowing custom serialization strategies - Jackson Extension Module: New
mixpanel-java-extension-jacksonartifact providing 2-5x performance improvement for large batches (50+ messages), eliminating automatic classpath detection in favor of explicit opt-in
Reviewed changes
Copilot reviewed 14 out of 14 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
src/main/java/com/mixpanel/mixpanelapi/MixpanelAPI.java |
Added Builder pattern and refactored constructors to use unified private constructor with JsonSerializer support |
src/main/java/com/mixpanel/mixpanelapi/internal/JsonSerializer.java |
Removed getImplementationName() method to simplify interface |
src/main/java/com/mixpanel/mixpanelapi/internal/OrgJsonSerializer.java |
Removed getImplementationName() implementation |
src/main/java/com/mixpanel/mixpanelapi/internal/SerializerFactory.java |
Deleted automatic Jackson detection factory in favor of explicit configuration |
src/test/java/com/mixpanel/mixpanelapi/internal/SerializerBenchmark.java |
Removed benchmark utility (not part of production code) |
src/test/java/com/mixpanel/mixpanelapi/internal/JsonSerializerTest.java |
Updated tests to remove Jackson-specific tests and SerializerFactory tests |
src/test/java/com/mixpanel/mixpanelapi/MixpanelAPITest.java |
Added comprehensive tests for Builder pattern and all 8 public constructors |
pom.xml |
Removed optional Jackson dependency, updated version to 1.6.0 |
mixpanel-java-extension-jackson/pom.xml |
New extension module POM with jackson-core dependency |
mixpanel-java-extension-jackson/src/main/java/com/mixpanel/mixpanelapi/internal/JacksonSerializer.java |
High-performance Jackson streaming API implementation |
mixpanel-java-extension-jackson/src/test/java/com/mixpanel/mixpanelapi/internal/JacksonSerializerTest.java |
Tests verifying Jackson output matches OrgJson output exactly using JSONAssert |
mixpanel-java-extension-jackson/README.md |
Documentation for Jackson extension module with installation and usage instructions |
README.md |
Updated all examples to use Builder pattern, documented Jackson extension usage |
.github/workflows/release.yml |
Enhanced to build, test, and deploy both main SDK and Jackson extension artifacts |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
...extension-jackson/src/test/java/com/mixpanel/mixpanelapi/internal/JacksonSerializerTest.java
Outdated
Show resolved
Hide resolved
src/test/java/com/mixpanel/mixpanelapi/internal/JsonSerializerTest.java
Outdated
Show resolved
Hide resolved
Contributor
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 14 out of 14 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Builder Pattern and Jackson Extension for Mixpanel Java SDK
Overview
This PR introduces a flexible Builder pattern for MixpanelAPI configuration and adds an optional high-performance Jackson serialization extension as a separate module.
Key Changes
1. Builder Pattern Implementation
MixpanelAPI.Builderclass providing fluent API for configurationExample:
2. JSON Serializer Abstraction
JsonSerializerinterface incom.mixpanel.mixpanelapi.internalpackageOrgJsonSerializer- default implementation using org.json library (maintains backward compatibility)3. Jackson Extension Module (mixpanel-java-extension-jackson)
JacksonSerializerimplementation using Jackson streaming APIjackson-coredependency (lightweight)Performance Benefits:
/importendpoint (up to 2000 events)Usage:
4. Testing
JacksonSerializerTestuses JSONAssert to verify Jackson output matches OrgJson output exactly5. Release Infrastructure
6. Documentation Updates
Breaking Changes
None. All existing constructors and APIs remain unchanged. This is a purely additive release.
Migration Guide
Users can optionally adopt the builder pattern:
Before:
After: