SDK Integration

This document provides steps for integrating your browser or app with Hackle via the Hackle SDK for web browsers created with Java/Kotlin. SDK Integration is a must in order to use the functions we provide.

Step 1: Add Dependencies

Think of this step as importing our SDK into your codebase. To use our Hackle services add the following dependency code and import our SDK.

repositories {

dependencies {
  implementation 'io.hackle:hackle-server-sdk:2.6.1'

Step 2: Initialize the SDK

Once you have imported the dependencies, in order to start using the Hackle SDK you must initialize the SDK. During this step, we get the information needed for SDK integration from the Hackle Server and store it in the SDK.
HackleClient is a class that provides methods for using SDK functions.


// Enter the SDK Key in the YOUR_SERVER_SDK_KEY.
HackleClient hackleClient = HackleClients.create("YOUR_SERVER_SDK_KEY");
// Enter the SDK Key in the YOUR_SERVER_SDK_KEY.
val hackleClient = Hackle.client("YOUR_SERVER_SDK_KEY")

Instantiate HackleClient by passing the SDK key.
HackleClient periodically synchronizes with the Hackle server as a background task to get the necessary information.


HackleClient must be a singleton pattern.

HackleClient manages the status internally to distribute test groups right away without blocking the calling thread. It uses additional resources for this. Instead of instantiating a new client for every request, it should be managed as a single instance throughout the application lifecycle.



The close() method should be called when the application is closed. This process returns the resources in use and sends the remaining events. If the application is terminated without this process, tracked events may be lost.


What if you are using a spring framework?

Registering HackleClient as a bean is the best option.
It is managed as a single instance during the lifecycle of the application and is automatically called until close() when the application is closed.

Did this page help you?