Skip to main content

JAVA

Percept Java SDK

Getting Started

  1. Add the following lines to your package's pom.xml file to include the dependency:
<dependency>
<groupId>com.perceptinsight.sdk</groupId>
<artifactId>percept-sdk-java</artifactId>
<version>1.1</version>
</dependency>

Create Event


// Instantiate a PerceptAPI object by initializing the token.
PerceptAPI perceptAPI = new PerceptAPI.Builder("apiToken").build();

// Instantiate a PerceptAPI object with custom values by initializing the token.
PerceptAPI perceptAPI = new PerceptAPI.Builder("apiToken")
.connectTimeout(10)
.readTimeout(20)
.maxRetries(3)
.build();

// Event Builder for building events
EventBuilder eventBuilder = new EventBuilder();

// Create an event without properties
Event event = eventBuilder.createEvent("App Open", "USR123", null);

// Capture the event
perceptAPI.capture(event);

// Create an EventCollection for batching events
EventCollection eventCollection = new EventCollection();

// Create properties for an event
JsonObject eventData = new JsonObject();
eventData.addProperty("attribute1", "value1");
eventData.addProperty("attribute2", "value2");

// Create an event with properties
Event eventWithProp = eventBuilder.createEvent("Test", "USR789", eventData);

// Add the event with properties to the collection
eventCollection.addEvent(eventWithProp);

// Capture the entire event collection
perceptAPI.capture(eventCollection);


Support

If you have any questions, issues, or need assistance with Percept, here are the available support channels:

Please feel free to reach out to us with any concerns or inquiries. We'll do our best to assist you and provide timely support.