# 유저 식별 정보 설정

## 시작하기 전에

DFINERY SDK를 사용하여 유저 식별 정보를 설정하는 방법입니다. [SDK 연동](/developer-guide/platform/web/integration.md)이 선행되어야 합니다

## 설정 하기

유저 식별 정보는`Dfinery.setIdentity` 와 `Dfinery.setIdentities` 메소드를 사용하여 설정이 가능합니다. 유저 식별 정보는 `DFIdentity`에 정의되어 있으며, 정의된 값만 사용 할 수 있습니다.

{% hint style="warning" %}
`EXTERNAL_ID`의 경우 유저 식별 정보 중 유저를 구분하는 중요한 값으로 사용되므로 고정 값을 사용하는것이 권장됩니다. 개인정보가 포함되지 않도록 주의해주세요. 만약 `EXTERNAL_ID`에 이메일, 전화번호 등의 개인정보가 포함되는 경우에는 암호화처리를 하시는 것을 권장합니다.
{% endhint %}

### 유저 식별 정보

| 유형                         | 내용            |
| -------------------------- | ------------- |
| `DFIdentity.EXTERNAL_ID`   | 유저 ID         |
| `DFIdentity.EMAIL`         | 유저 이메일        |
| `DFIdentity.PHONE_NO`      | 유저 전화번호       |
| `DFIdentity.KAKAO_USER_ID` | 유저 카카오 계정 아이디 |
| `DFIdentity.LINE_USER_ID`  | 유저 라인 계정 아이디  |

### 항목별로 설정하기

```javascript
setIdentity(identity, "IDENTITY_VALUE");
```

각각의 매개변수는 다음을 의미합니다.

* `identity` : 유저 식별 정보 키 ( DFIdentity 상수 사용)
* `IDENTITY_VALUE` : 유저 식별 정보 값

{% tabs %}
{% tab title="Javascript" %}

```javascript
Dfinery.setIdentity(DFIdentity.EXTERNAL_ID, "TESTID");
```

{% endtab %}
{% endtabs %}

### 한번에 여러건 설정하기

```javascript
setIdentities(identities);
```

각각의 매개변수는 다음을 의미합니다.

* `identities` : 유저 식별 정보의 키와 값을 갖는 Dictionary

{% tabs %}
{% tab title="Javascript" %}

```javascript
let identities = {};
identities[DFIdentity.EXTERNAL_ID] = "TESTID";
identities[DFIdentity.EMAIL] = "test1234@gmail.com";
identities[DFIdentity.PHONE_NO] = "821012345678";
identities[DFIdentity.KAKAO_USER_ID] = "12d1s21";
Dfinery.setIdentities(identities);
```

{% endtab %}
{% endtabs %}

{% hint style="warning" %}
전화번호의 경우 다음과 같은 형식으로 입력해주시기 바랍니다. ex) 821012345678, 82212345678
{% endhint %}

## 유저 식별 정보 초기화하기

`resetIdentity` 메소드를 호출하면 기존 저장하고 있던 유저 식별 정보를 제거하고 초기화할 수 있습니다.

{% hint style="danger" %}
유저 식별 정보를 초기화 할 경우 기존에 이어지고 있던 이벤트 흐름이 끊기고 단말기와 통합 ID의 연결도 끊기게 되므로 호출에 주의하여 주시기 바랍니다.
{% endhint %}

{% tabs %}
{% tab title="Javascript" %}

```javascript
Dfinery.resetIdentity();
```

{% endtab %}
{% endtabs %}


---

# 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.dfinery.ai/developer-guide/platform/web/identity.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.
