Skip to content

Conversation

@ppatibandla
Copy link
Contributor

Summary

Add chainable helper methods to Event class that accept Map<String, Object> instead of requiring JSONObject, making the API more user-friendly and enabling fluent method chaining. This will give workaround to customers who don't want to add org.json dependency to their Gradle.

New methods added:

  • setEventProperties/addEventProperty: Set event properties without JSONObject
  • setUserProperties/addUserProperty: Set user properties without JSONObject
  • setGroups/addGroup: Set groups without JSONObject
  • setGroupProperties/addGroupProperty: Set group properties without JSONObject

All methods support method chaining and proper null handling. Updated demo with usage examples and added comprehensive unit tests.

Checklist

  • Build succeeds: ./gradlew build
    • All existing tests pass
    • All new unit tests pass (14 tests added)
    • Code compiles without errors
    • Demo examples updated and compile successfully
    • Backwards compatibility maintained - existing JSONObject usage still works
  • [Yes ] Does your PR title have the correct title format?
  • Does your PR have a breaking change?: No

Add chainable helper methods to Event class that accept Map<String, Object> instead of requiring JSONObject, making the API more user-friendly and enabling fluent method chaining.

New methods added:
- setEventProperties/addEventProperty: Set event properties without JSONObject
- setUserProperties/addUserProperty: Set user properties without JSONObject
- setGroups/addGroup: Set groups without JSONObject
- setGroupProperties/addGroupProperty: Set group properties without JSONObject

All methods support method chaining and proper null handling. Updated demo with usage examples and added comprehensive unit tests.
The project targets Java 8 (sourceCompatibility = 1.8) but Map.of() was introduced in Java 9. Replaced all Map.of() usages with HashMap instantiation to ensure Java 8 compatibility.

Changes:
- EventTest.java: Use HashMap instead of Map.of() in testMethodChaining
- LocalUploadDemo.java: Replace all Map.of() calls with HashMap initialization
@ppatibandla ppatibandla requested a review from AmpGabor November 11, 2025 00:48
Copy link

@igor-amp igor-amp left a comment

Choose a reason for hiding this comment

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

lgtm

@ppatibandla ppatibandla merged commit cb5c1d9 into main Dec 9, 2025
5 checks passed
@ppatibandla ppatibandla deleted the feat/event-property-helper-methods branch December 9, 2025 22:38
justin-fiedler pushed a commit that referenced this pull request Dec 9, 2025
# [1.13.0](v1.12.5...v1.13.0) (2025-12-09)

### Features

* add Map-based helper methods for Event properties ([#112](#112)) ([cb5c1d9](cb5c1d9))
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.

4 participants