# 사용자 식별자와 속성

{% hint style="info" %}
사용자 식별자 관리

사용자 식별자는 사용자를 고유하게 식별하는 목적으로 사용합니다. 사용자 식별자의 의미와 중요성, 선택하는 기준 등에 대해서는 [사용자 식별자 관리하기](/getting-started/user-identifier.md) 문서를 참고하시기 바랍니다.
{% endhint %}

### 직접 관리하는 사용자 식별자 사용

서버 측 SDK는 사용자를 특정할 수 없기 때문에 **항상 사용자 식별자를 파라미터로 직접 전달**해야 합니다. 전달하는 식별자는 직접 관리하는 Primary Key, 디바이스 식별자, 회원 아이디, 이메일, 해시값 등이 될 수 있습니다.

### 예시

테스트 그룹 분배 후 사용자 이벤트 전송을 하는 상황을 예로 들면 다음과 같습니다.

```php
<?php

require 'vendor/autoload.php';

$client = \Hackle\HackleClients::create("YOUR_SDK_KEY");

$user = \Hackle\Common\HackleUser::builder()
    ->deviceId("ae2182e0")
    ->build();

$event = \Hackle\Common\HackleEvent::builder("purchase")
    ->property("pay_method", "CARD")
    ->property("discount_amount", 800)
    ->property("is_discount", true)
    ->build();

//테스트 그룹 분배
$variation = $client->variation(42 , $user);

//사용자 이벤트 전송
$client->track($event, $user);

?>
```

## 추가 식별자

```php
<?php
require 'vendor/autoload.php';

$user = \Hackle\Common\HackleUser::builder()
    ->userId("123")
    ->deviceId("ae2182e0")
    ->identifier("myCustomId","customId")
    ->build();
?>
```

## 속성(Property)

핵클 SDK는 사용자(HackleUser) 객체에 속성을 추가할 수 있도록 지원합니다.

* 속성은 속성명(key)과 속성값(value)을 한 쌍으로 보내야 합니다.
* 사용자 객체에 추가 가능한 속성 개수는 최대 64개입니다.

<table><thead><tr><th width="133.04296875">구분</th><th width="127.60546875">타입</th><th>제약사항</th></tr></thead><tbody><tr><td>속성 명(key)</td><td><code>string</code></td><td><ul><li>글자수 제한은 128자입니다. (128 characters)</li><li>대소문자를 구분하지 않습니다.</li><li>예를 들어 AGE와 age는 동일한 속성명으로 인식합니다.</li></ul></td></tr><tr><td>속성 값(value)</td><td><code>boolean</code>, <code>string</code>, <code>number</code>, <code>array</code></td><td><ul><li>string 타입인 경우 글자수 제한은 1024자입니다.<br>(1024 characters)</li><li>string 타입은 대소문자를 구분합니다.</li><li>예를 들어 APPLE과 apple은 서로 다른 속성값으로 인식합니다.</li><li>number 타입인 경우 정수 최대 15자리, 소수점 최대 6자리를<br>지원합니다.</li></ul></td></tr></tbody></table>

### 예시

사용자(User) 객체는 테스트 그룹 분배, 기능 플래그 결정, 사용자 이벤트 전송에서 파라미터로 사용됩니다. 아래 예시에서는 세 가지 속성(`age`, `grade`, `is_paying_user`)을 추가한 것을 확인할 수 있습니다.

```php
<?php
  
require 'vendor/autoload.php';

$client = \Hackle\HackleClients::create("YOUR_SDK_KEY");

$user = \Hackle\Common\HackleUser::builder()
    ->deviceId("ae2182e0")
    ->property("age", 30)
    ->property("grade", "GOLD")
    ->property("is_paying_user", false)
    ->build();

//테스트 그룹 분배
$variation = $client->variation(42 , $user);

//기능 플래그 결정
$isFeatureOn = $client->isFeatureOn(42, $user);

//사용자 이벤트 전송
$client->track($event, $user);

?>
```


---

# 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/php/php-user-info.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.
