For the complete documentation index, see llms.txt. This page is also available as Markdown.

JavaScript

The JavaScript SDK supports IE11+ and all major browsers.

To use the JavaScript SDK, Promise and Map APIs must be supported. If polyfills are needed, we recommend using core-js.

Add Dependency

npm install --save @hackler/javascript-sdk
yarn add @hackler/javascript-sdk
<!-- HTML의 경우 의존성 추가 작업이 필요하지 않습니다 -->

SDK Initialization

You must initialize HackleClient before using the SDK.

  • HackleClient is the class that provides methods for using SDK features.

  • You can find the SDK Key in SDK Integration Info on the Hackle Dashboard.

Initialization Complete

Initialization runs asynchronously and fetches necessary data from the Hackle server and stores it in the SDK. You can use await to wait until initialization is complete.

If you await onInitialized(), you can use the SDK after initialization is complete. Even if initialization fails due to a network error or similar issue, subsequent SDK calls safely return the default values.

SDK Initialization Config

You can initialize the SDK with configuration options.

Configuration Options

Option
Description
Default
Supported Version

debug

Prints logs for all features to the console.

false

1.0.0+

pollingIntervalMillis

Periodically updates the configuration set in the Dashboard.

  • Minimum: 60000 (60 seconds)

-1 (no periodic update)

11.1.0+

exposureEventDedupIntervalMillis

Removes duplicate exposure events for the same A/B Test or Feature Flag distribution result triggered by the same user consecutively.

  • Minimum: 1000 (1 second)

  • Maximum: 3600000 (1 hour)

60000 (1 min / 11.23.0+) -1 (no dedup / below 11.23.0)

11.1.0+

devTool

Enables User Explorer.

undefined

11.13.0+

autoOpenDevTool

Option to automatically show the User Explorer button.

false

11.13.0+

sameSiteCookie

Sets the sameSite flag on Hackle cookies and determines cookie privacy policy.

Lax

11.20.0+

secureCookie

When set to true, sets the Secure flag on Hackle cookies.

false

11.20.0+

user

Injects a user at initialization time.

undefined

11.22.3+

sessionPolicy

Configures session persistence and expiration conditions.

ALWAYS_NEW_SESSION ,

1800000

11.54.0+

optOutTracking

Whether opt-out is enabled.

false

11.54.0+

evaluationMode

Configures the evaluation mode.

local

12.0.0+

sessionTimeoutMillis (deprecated)

Sets the session expiration time. Please use sessionPolicy instead.

1800000 (30 min)

11.8.0+

Evaluation Mode Configuration

You can choose whether the SDK performs evaluation itself or fetches results that the Hackle server has already evaluated. If not configured, the default value "local" (local evaluation) is used.

Session Policy Configuration

You can configure session persistence and expiration conditions using the session policy.

Injecting User at Initialization

When user is set in config, you can initialize the SDK with user information included.

  • If no user information is provided, the user information stored in cookies is used.

  • If user information is provided, the user information stored in cookies is not used.

  • If there is no user information in cookies, a user with the Hackle Device ID as the device id is used.

You can freely update user information after SDK initialization using the user information setter functions.

Refreshing Dashboard Configuration

You can explicitly refresh the Dashboard configuration.

Last updated