-
-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(analytics): add Analytics events API support
Implements analytics events tracking capabilities to complement existing rules functionality. Adds ability to create custom analytics events with type, name and data fields. Changes include: - New AnalyticsEvents class for event operations - Integration with Analytics class - Test coverage with sample search event creation - Helper updates for events in analytics rules - Documentation updates on how to use new feature feat(analytics): add AnalyticsEvents class test(analytics): add AnalyticsEventsTest feat(analytics): integrate events into Analytics class refactor(helper): update createTestAnalyticsRule for events docs(analytics): add documenation on proper analytics rules usage
- Loading branch information
1 parent
d7ebd83
commit 64d5f42
Showing
5 changed files
with
91 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package org.typesense.api; | ||
|
||
import org.typesense.model.AnalyticsEventCreateResponse; | ||
import org.typesense.model.AnalyticsEventCreateSchema; | ||
|
||
|
||
public class AnalyticsEvents { | ||
private final ApiCall apiCall; | ||
public final static String RESOURCE_PATH = "/analytics/events"; | ||
|
||
public AnalyticsEvents(ApiCall apiCall) { | ||
this.apiCall = apiCall; | ||
} | ||
|
||
public AnalyticsEventCreateResponse create(AnalyticsEventCreateSchema event) throws Exception { | ||
return this.apiCall.post(RESOURCE_PATH, event, null, AnalyticsEventCreateResponse.class); | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package org.typesense.api; | ||
|
||
import java.util.Map; | ||
|
||
import org.junit.jupiter.api.AfterEach; | ||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.assertNotNull; | ||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
import org.typesense.model.AnalyticsEventCreateResponse; | ||
import org.typesense.model.AnalyticsEventCreateSchema; | ||
|
||
public class AnalyticsEventsTest { | ||
|
||
private Client client; | ||
private Helper helper; | ||
|
||
@BeforeEach | ||
void setUp() throws Exception { | ||
helper = new Helper(); | ||
client = helper.getClient(); | ||
helper.teardown(); | ||
helper.createTestCollection(); | ||
helper.createTestQueryCollection(); | ||
helper.createTestAnalyticsRule(); | ||
} | ||
|
||
@AfterEach | ||
void tearDown() throws Exception { | ||
helper.teardown(); | ||
} | ||
|
||
@Test | ||
void testCreate() throws Exception { | ||
AnalyticsEventCreateSchema analyticsEvent = new AnalyticsEventCreateSchema() | ||
.type("search") | ||
.name("products_search_event") | ||
.data(Map.of( | ||
"q", "running shoes", | ||
"user_id", "1234")); | ||
|
||
AnalyticsEventCreateResponse result = this.client.analytics().events().create(analyticsEvent); | ||
assertNotNull(result); | ||
assertEquals(true, result.isOk()); | ||
|
||
} | ||
} |
This file contains 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