# 원격 구성 적용

원격 구성은 애플리케이션에서 관리되고 있는 값, 또는 속성들을 핵클 대시보드에서 정의한 파라미터 값들로 대체하여 실시간으로 애플리케이션의 동작 및 설정 값들을 제어할 수 있는 기능입니다.

핵클의 대시보드의 원격 구성 화면으로 이동하여 파라미터 정보들을 설정하고, 사용자 식별 규칙에 따른 값들을 설정할 수 있습니다.

## remoteConfig

`remoteConfig()` 메소드를 호출하면 사용자에 대한 원격 구성 정보(설정한 파라미터 및 규칙 정보)를 담고 있는 `HackleRemoteConfig` 인스턴스를 얻을 수 있습니다.\
`remoteConfig()` 는 사용자 속성을 원격 구성의 규칙 정보와 매칭 시키기 위해 사용자 식별자 정보를 전달 받을 수 있습니다.\
`HackleRemoteConfig` 에서 제공하는 메소드들을 통해 원하는 파라미터에 접근하여 값을 제공받을 수 있습니다.

```javascript
hackleClient.onReady(function() {
  const user = { id: "ae2182e0" };
	// 원격 구성 정보를 담은 인스턴스를 반환합니다.  
	const remoteConfig = hackleClient.remoteConfig(user)
});
```

## 원격 구성 파라미터 조회

* `remoteConfig()` 메소드를 사용하여 반환받은 `HackleRemoteConfig`에는 파라미터 값 조회를 위한 `get()`메소드를 제공합니다.
* 핵클의 원격 구성 화면에서 설정한 파라미터 값이 key, value 형태로 존재하기 때문에, 설정한 파라미터 유형에 따라 아래 메소드를 사용하여 설정한 파라미터 값을 반환받을 수 있습니다.

{% hint style="warning" %}
보관 후 원격 구성과 관련된 코드를 제거하세요.

원격 구성 파라미터를 보관한 경우 더이상 파라미터 정보에 접근 할 수 없습니다. 따라서 원격 구성 파라미터 보관 후에는 반드시 관련된 코드를 정리해주시기 바랍니다.
{% endhint %}

```javascript
hackleClient.onReady(function() {
  const user = { id: "ae2182e0" };
  // 원격 구성 정보를 담은 인스턴스를 반환합니다. 
  const remoteConfig = hackleClient.remoteConfig(user)
  
  //remoteConfig 에서 get() 메소드를 통해 parameter 값 가져오기
  const parameterValue = remoteConfig.get(parameterKey, defaultValue)

  // string 유형의 parameter값 예제
  const strValue = remoteConfig.get("parmeterKey", "defaultValue")
});
```

* get() 메소드의 parameterKey는 원격 구성의 파라미터 설정에서 설정한 키 정보입니다.
* defaultValue는 원격 구성 값을 결정할 수 없을 때 반환되는 값입니다. 입력한 defaultValue는 다음과 같은 상황에서 반환될 수 있습니다.
  * A. 원격 구성화면에서 설정한 타입 유형과 다른 유형의 값을 입력
  * B. 설정되지 않은 parameter key 호출
  * C. Hackle SDK 초기화 실패
  * D. 잘못된 식별자 정보가 입력되거나 존재하지 않을 때
  * E. ETC
* 설정한 정보를 제대로 받기 위해서는 defaultValue에 설정하신 파라미터 유형에 맞는 type의 값을 입력해야 합나다.
* SDK에서 제공되는 원격 구성 파라미터 유형은 string, number, boolean 이며 원격 구성 파라미터 화면에서 설정한 JSON 타입은 문자열(String)형태로 받을 수 있습니다. JSON 타입의 default 값은 문자열 타입으로 입력해야 합니다.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.hackle.io/development-guide/nodejs/node-remote-config.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
