The Typesense server provides analytics capabilities through its /analytics endpoints, but these features were not accessible through the Java client. Users needed to track search analytics and user interactions but had to implement their own HTTP calls or workarounds.
This PR adds complete support for Analytics Rules and Events.
Changes
Added Features:
New Analytics Management (Analytics.java):
Central class for managing analytics operations
Provides access to rules and events APIs
Analytics Rules Support (AnalyticsRules.java, AnalyticsRule.java):
create(): Create new analytics collection rules
upsert(): Create or update existing rules
retrieve(): Get single or all analytics rules
delete(): Remove analytics rules
Complete parameter support for rule configuration
Analytics Events Tracking (AnalyticsEvents.java):
create(): Track custom analytics events
Code Changes:
In Client.java:
Added analytics field and getter
Integrated analytics support in client initialization
In Helper.java:
Added test support methods for analytics
Enhanced teardown to clean analytics rules
Added test collection creation for analytics data
Documentation Updates:
In README.md:
Added comprehensive examples for analytics rules
Added examples for tracking custom events
Added code samples with use cases
Tests:
New Test Classes:
AnalyticsRulesTest.java: Complete test coverage for rules API
AnalyticsEventsTest.java: Event creation and validation tests
Integration tests with existing collections
Context
This implementation addresses and closes the feature request in #71 by @danipenaperez for analytics support in the Java client. It provides a complete solution for both analytics rules and events tracking, giving users the full power of Typesense analytics.
The changes follow the existing client architecture patterns and include comprehensive tests and documentation to ensure reliable usage.
Change Summary
Rationale
The Typesense server provides analytics capabilities through its
/analytics
endpoints, but these features were not accessible through the Java client. Users needed to track search analytics and user interactions but had to implement their own HTTP calls or workarounds.This PR adds complete support for Analytics Rules and Events.
Changes
Added Features:
New Analytics Management (
Analytics.java
):Analytics Rules Support (
AnalyticsRules.java
,AnalyticsRule.java
):create()
: Create new analytics collection rulesupsert()
: Create or update existing rulesretrieve()
: Get single or all analytics rulesdelete()
: Remove analytics rulesAnalytics Events Tracking (
AnalyticsEvents.java
):create()
: Track custom analytics eventsCode Changes:
In
Client.java
:In
Helper.java
:Documentation Updates:
README.md
:Tests:
AnalyticsRulesTest.java
: Complete test coverage for rules APIAnalyticsEventsTest.java
: Event creation and validation testsContext
This implementation addresses and closes the feature request in #71 by @danipenaperez for analytics support in the Java client. It provides a complete solution for both analytics rules and events tracking, giving users the full power of Typesense analytics.
The changes follow the existing client architecture patterns and include comprehensive tests and documentation to ensure reliable usage.
PR Checklist