> For the complete documentation index, see [llms.txt](https://developers-apps-in-toss.toss.im/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developers-apps-in-toss.toss.im/documentation/sdk/domains-api/analytics/analytics.log.md).

# Analytics.log

> 함수형 API `eventLog`로도 같은 기능을 쓸 수 있어요.

### 기능 설명

앱에서 발생하는 이벤트를 기록해요. 디버깅·정보·경고·오류·화면·노출·클릭 등 다양한 유형을 남길 수 있어요. 샌드박스 환경에서는 콘솔에 출력되고, 실환경에서는 로그 시스템에 기록돼요.

`params`에는 사용자 식별용 `anonymous_key`가 기본 파라미터로 자동 포함돼요. 같은 키를 직접 전달하면 전달한 값이 우선해요. `undefined` 값은 전송 전에 제거되고, 나머지 값은 모두 string으로 정규화돼요.

토스앱 Android/iOS `5.208.0` 이상에서 사용할 수 있어요. 미지원 버전에서는 에러 없이 로그가 조용히 무시돼요.

### 타입

```ts
Analytics.log(params: EventLogParams): Promise<void>;
```

**Params**

```ts
type EventLogParams = {
  log_name: string;
  log_type:
    | "debug"
    | "info"
    | "warn"
    | "error"
    | "event"
    | "screen"
    | "impression"
    | "click"
    | "popup";
  params: Record<string, string | number | boolean | null | undefined>;
};
```

**Response**

없음.

### 예시 코드

#### JavaScript

```js
import { Analytics } from "@apps-in-toss/web-framework";

try {
  await Analytics.log({
    log_name: "user_action",
    log_type: "event",
    params: {
      action: "button_click",
      screen: "main",
      userId: 12345,
    },
  });
} catch (error) {
  console.error(error);
}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://developers-apps-in-toss.toss.im/documentation/sdk/domains-api/analytics/analytics.log.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
