The backend Java SDK to send event to Filum Business Data Platform
Please visit the Developer Center for instructions on using the SDK.
- Download the latest JAR file Filum Java SDK Releases
- Add the JAR file to your project dependencies. Example: I put the JAR inside the
libsfolder:
dependencies {
implementation 'org.json:json:20201115'
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation files('libs/filum-java-sdk-0.0.2.jar')
}- Import and use in code:
- Update
WRITEKEYto your Filum source's writekey. You can get the writekey of your source in the source's Overview tab.
importcom.filum.Filum;
importcom.filum.exception.FilumException;
importcom.filum.EventBuilder;
...
Filumfilum = Filum.getInstance("EXAMPLE_INSTANCE");
filum.init("WRITEKEY");
EventBuilderidentifyBuilder = newEventBuilder("identify");
JSONObjecteventParams = newJSONObject();
eventParams.put("name", "Harry Potter");
eventParams.put("age", 10);
eventParams.put("float_value", 1111.11);
eventParams.put("date", getCurrentTimeISO());
identifyBuilder.setEventParams(eventParams);
identifyBuilder.setUserID("+84946113111");
EventexampleEvent = identifyBuilder.getEvent();
filum.identify(exampleEvent);
EventBuildertrackBuilder = newEventBuilder("track", "Home Page Visited");
trackBuilder.setUserID("+84946113111");
trackBuilder.setEventParams(eventParams);
EventtrackEvent = trackBuilder.getEvent();
filum.track(trackEvent);You can refer to the Demo Project for more details.
- Develop using Docker:
docker run --rm -v ${PWD}:/home/gradle -p 8080:8080 -it --entrypoint=/bin/bash gradle:jdk11 -i
- Navigate to
demofolder and update the build.gradle to point to the code instead of the .jar library file:
cd src/demo
Update the dependencies like this:
dependencies {
implementation 'org.json:json:20201115'
implementation 'org.springframework.boot:spring-boot-starter-web'
// implementation files('libs/filum-java-sdk-0.0.2.jar')
implementation project(':main')
}
Update
WRITEKEYto your Filum source's WRITEKEY inDemoController.javafileBuild the demo project then run:
gradle build
java -jar build/libs/demo.jar
In your browser go to
localhost:8080and you will see Identify and Track event appear in your source Debugging view.Update your code and rebuild and refresh browser to check for updates from your code modification.
You can run the test within Dockerized environment as follow:
- Start the Docker container:
docker run --rm -v ${PWD}:/home/gradle -p 8080:8080 -it --entrypoint=/bin/bash gradle:jdk11 -i
- Navigate to
testfolder:
cd src/test
- Run test:
gradle test
- You can view the test result in the command like or in the test report at this location in your host machine:
./src/test/build/reports/tests/test/index.html