> For the complete documentation index, see [llms.txt](https://docs.dfinery.ai/developer-guide/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.dfinery.ai/developer-guide/platform/web/user_profile.md).

# 유저 프로필 설정

DFINERY 서버에서 관리하고 있는 유저에 대한 프로필 정보입니다. 해당 정보들은 모두 선택사항이며 단말기에 저장되지 않습니다. [SDK 연동](/developer-guide/platform/web/integration.md)이 선행되어야 합니다

## 시작하기 전에

유저 프로필을 설정하기 전에 [DFINERY 콘솔](https://console.dfinery.ai/)에서 유저 프로필 속성을 생성 후 연동해 주세요. 유저 프로필 속성은 부가 설정 / 데이터 연동 / 속성 관리 / 유저 프로필 속성 목록에서 생성할 수 있습니다.

## 유의사항

* 등록되지 않은 유저 프로필, 잘못된 타입의 유저 프로필 속성이 기록될 경우, 유저 프로필은 설정되지 않습니다.
* `Array of String` 타입의 유저 프로필 속성은 최대 10개까지 생성할 수 있습니다.
* `Array of Long`, `Array of Double` 타입은 최대 5개까지 생성할 수 있습니다.
* value의 입력 개수 제한은 없으나 전체 크기는 8KB를 초과할 수 없습니다.

## 설정하기

`Dfinery.setUserProfile()` 메소드 혹은 `Dfinery.setUserProfiles()` 사용하여 유저 프로필을 설정할 수 있습니다.

### 유저 프로필 속성

| 상수                         | 유저 프로필 속성명     | 내용      |
| -------------------------- | -------------- | ------- |
| `DFUserProfile.BIRTH`      | df\_birth      | 유저 생일   |
| `DFUserProfile.GENDER`     | df\_gender     | 유저 성별   |
| `DFUserProfile.NAME`       | df\_name       | 유저 이름   |
| `DFUserProfile.MEMBERSHIP` | df\_membership | 유저의 멤버쉽 |

### 항목별로 설정하기

```javascript
Dfinery.setUserProfile(key, value);
```

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

* `key` : 설정할 유저 프로필 속성의 이름. `String` 타입의 값이 입력이 가능합니다.
* `value` : 설정할 유저 프로필의 값. `null`도 입력 가능합니다.

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

```javascript
Dfinery.setUserProfiles(profiles);
```

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

* `profiles` : 유저 프로필 속성 정보의 키와 값을 갖는 Dictionary

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

```javascript
const profiles = {};
profiles[DFUserProfile.NAME] =  "TestName";
profiles[DFUserProfile.GENDER] = DFGender.MALE;
profiles[DFUserProfile.BIRTH] = "2014-05-14";
profiles[DFUserProfile.MEMBERSHIP] = "VIP";
Dfinery.setUserProfiles(profiles);
```

{% endtab %}

{% tab title="TypeScript" %}

```typescript
import Dfinery, { DFGender, DFUserProfile } from "@igaworks/dfinery-web-sdk";

const profiles: Record<string, unknown> = {
  [DFUserProfile.NAME]: "TestName",
  [DFUserProfile.GENDER]: DFGender.MALE,
  [DFUserProfile.BIRTH]: "2014-05-14",
  [DFUserProfile.MEMBERSHIP]: "VIP",
};

void Dfinery.setUserProfiles(profiles);
```

{% endtab %}
{% endtabs %}

## 사용 예시

### 이름 설정하기

* 지원 유형
  * value : `String`

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

```javascript
Dfinery.setUserProfile(DFUserProfile.NAME, "John");
```

{% endtab %}

{% tab title="TypeScript" %}

```typescript
import Dfinery, { DFUserProfile } from "@igaworks/dfinery-web-sdk";

void Dfinery.setUserProfile(DFUserProfile.NAME, "John");
```

{% endtab %}
{% endtabs %}

### 성별 설정하기

* 매개변수 지원 유형
  * value : `DFGender.MALE`, `DFGender.FEMALE`, `DFGender.NON_BINARY`, `DFGender.OTHER`

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

```javascript
Dfinery.setUserProfile(DFUserProfile.GENDER, DFGender.MALE);
```

{% endtab %}

{% tab title="TypeScript" %}

```typescript
import Dfinery, { DFGender, DFUserProfile } from "@igaworks/dfinery-web-sdk";

void Dfinery.setUserProfile(DFUserProfile.GENDER, DFGender.MALE);
```

{% endtab %}
{% endtabs %}

### 멤버십 설정하기

* 지원 유형
  * value : `String`

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

```javascript
Dfinery.setUserProfile(DFUserProfile.MEMBERSHIP, "VIP");
```

{% endtab %}

{% tab title="TypeScript" %}

```typescript
import Dfinery, { DFUserProfile } from "@igaworks/dfinery-web-sdk";

void Dfinery.setUserProfile(DFUserProfile.MEMBERSHIP, "VIP");
```

{% endtab %}
{% endtabs %}

### 생년월일 설정하기

* 지원 유형
  * value : `String(yyyy-MM-dd)`

{% hint style="warning" %}
df\_birth(생년월일)의 경우 입력 값 타입을 yyyy-MM-dd의 String 타입으로 입력해 주세요. 예시: "1999-01-01"
{% endhint %}

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

```javascript
Dfinery.setUserProfile(DFUserProfile.BIRTH, "1999-01-01");
```

{% endtab %}

{% tab title="TypeScript" %}

```typescript
import Dfinery, { DFUserProfile } from "@igaworks/dfinery-web-sdk";

void Dfinery.setUserProfile(DFUserProfile.BIRTH, "1999-01-01");
```

{% endtab %}
{% endtabs %}

### 알림 수신 동의 정보 설정하기 <a href="#consent" id="consent"></a>

알림 수신 동의 정보는 유저 프로필에 속해있으며 다양한 채널에 대한 수신 동의 정보 값을 설정할 수 있습니다.

{% hint style="danger" %}
알림 수신 동의 정보를 설정해주지 않는 경우 해당 값은 null이며, null과 true일 때 발송이 가능하고, false 일 때 발송되지 않습니다. 자세한 사항은 [이용 가이드](https://docs.dfinery.ai/user-guide/action/off-site-campaign/opt-state) 참고해주시기 바랍니다.
{% endhint %}

{% hint style="info" %}
알림 수신 동의 정보에 대한 유저 프로필은 예외적으로 DFINERY에서 서비스 생성 시 이미 자동으로 등록되어 있어 DFINERY 콘솔에서 설정하지 않아도 설정이 가능합니다.
{% endhint %}

{% hint style="warning" %}
`DFUserProfile.PUSH_OPTIN`은 이전 푸시 수신 동의 키이며 사용하지 않습니다. 푸시 수신 동의는 `DFUserProfile.PUSH_ADS_OPTIN`, `DFUserProfile.PUSH_NIGHT_ADS_OPTIN`으로 구분하여 설정해 주세요. `PUSH_OPTIN` 사용 시 SDK 로그에 deprecated 경고가 출력됩니다.
{% endhint %}

* 지원 유형
  * key : 알림 수신 동의 유형(DFUserProfile)
  * value : `Boolean`

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

```javascript
// 푸시 채널에 대한 광고성 알림 동의 설정하기
Dfinery.setUserProfile(DFUserProfile.PUSH_ADS_OPTIN, true);
```

{% endtab %}

{% tab title="TypeScript" %}

```typescript
import Dfinery, { DFUserProfile } from "@igaworks/dfinery-web-sdk";

// 푸시 채널에 대한 광고성 알림 동의 설정하기
void Dfinery.setUserProfile(DFUserProfile.PUSH_ADS_OPTIN, true);
```

{% endtab %}
{% endtabs %}

#### 알림 수신 동의 유형 <a href="#consent-type" id="consent-type"></a>

{% hint style="warning" %}
오후 9시 부터 오전 8시 사이에는 별도의 야간 광고성 알림 동의를 받아야 광고성 알림을 전송할 수 있으므로 해당 시간에 메시지를 발송하고 싶으실 경우 `PUSH_NIGHT_ADS_OPTIN` 값을 사용하여 동의를 받아 주시기 바랍니다. (불법 스팸 방지를 위한 정보통신망법 안내서, 한국인터넷진흥원, 2020.07)
{% endhint %}

| 명칭                                   | 채널           | 설명                                |
| ------------------------------------ | ------------ | --------------------------------- |
| `DFUserProfile.PUSH_ADS_OPTIN`       | 푸시           | 푸시 채널에 대한 광고성 알림 동의               |
| `DFUserProfile.PUSH_NIGHT_ADS_OPTIN` | 푸시           | 푸시 채널에 대한 야간 광고성 알림 동의            |
| `DFUserProfile.SMS_ADS_OPTIN`        | 문자           | 문자 채널에 대한 광고성 알림 동의               |
| `DFUserProfile.KAKAO_ADS_OPTIN`      | 친구톡, 브랜드 메시지 | 카카오 친구톡과 브랜드 메시지 채널에 대한 광고성 알림 동의 |

### 커스텀 유저 프로필 설정하기

커스텀 유저 프로필을 설정하고 싶을 경우 [DFINERY 콘솔](https://console.dfinery.ai/)에 해당하는 컴스텀 유저 프로필의 속성을 생성하고 키 값으로 입력하여 설정하면 됩니다.

* 지원 유형
  * key : `String`
  * value : `String`, `Boolean`, `Number`, `Date`, `Array of String`, `Array of Number`

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

```javascript
Dfinery.setUserProfile("{CUSTOM_PROFILE_KEY}", "{CUSTOM_PROFILE_VALUE}");
```

{% endtab %}

{% tab title="TypeScript" %}

```typescript
import Dfinery from "@igaworks/dfinery-web-sdk";

void Dfinery.setUserProfile("{CUSTOM_PROFILE_KEY}", "{CUSTOM_PROFILE_VALUE}");
```

{% endtab %}
{% endtabs %}
