# 웹앱 연동

{% hint style="info" %}
Android SDK 2.29.0 이상, JavaScript SDK 11.24.1 이상 버전에서 지원하는 기능입니다.

웹앱에 대해서는 [문서](/development-guide/faq/web-app-intergration.md)를 참고해주세요.
{% endhint %}

`WebView` 를 통해 자사 웹사이트를 랜더링하는 경우, 다음 같은 설정을 통해 웹사이트에 포함된 핵클 JavaScript SDK를 웹사이트 코드 변경없이 핵클 Android SDK 기능과 동일하게 사용할 수 있습니다.

브릿지 설정을 하면 웹뷰에서 발생하는 핵클 이벤트는 Android SDK를 통해 수집됩니다.

{% hint style="info" %}
웹뷰 브릿지는 Hackle JavaScript SDK에서 브릿지로 전달한 데이터만 Hackle Android SDK의 JavascriptInterface로 처리합니다.
{% endhint %}

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

```kotlin
...
Hackle.app.setWebViewBridge(webView)
...
```

{% endtab %}

{% tab title="Java" %}

```java
...
HackleApp.getInstance().setWebViewBridge(webView, HackleWebViewConfig.DEFAULT)
...
```

{% endtab %}
{% endtabs %}

{% hint style="warning" %}
해당 기능을 사용하기 위해서는 **JavaScript 웹페이지에서 동일한 App SDK 키를 사용**해야 합니다.

핵클 안드로이드 웹뷰 설정은 안드로이드 `Javascript Interface`를 통해 핵클 JavaScript SDK와 상호작용하게 됩니다. 반드시 `WebView::loadUrl` 함수 호출 이전에 해당 설정이 완료될 수 있도록 코드를 위치시켜 주세요.
{% endhint %}

### 웹뷰에서 발생하는 자동 수집 이벤트 연동

{% hint style="info" %}
Android SDK 2.62.0 이상, JavaScript SDK 11.51.0 이상 버전에서 지원하는 기능입니다.
{% endhint %}

웹뷰 내 웹사이트에서 발생하는 `$page_view`와 `$engagement`는 비활성화 상태입니다. 웹뷰 브릿지를 설정할 때 `HackleWebViewConfig`를 설정하여 자동 수집 이벤트를 각각 활성화할 수 있습니다.

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

```kotlin
val webViewConfig = HackleWebViewConfig
	.builder()
	.automaticScreenTracking(true)
	.automaticEngagementTracking(true)
	.build()
Hackle.app.setWebViewBridge(webView, webViewConfig)
```

{% endtab %}

{% tab title="Java" %}

```java
HackleWebViewConfig webViewConfig = HackleWebViewConfig
	.builder()
	.automaticScreenTracking(true)
	.automaticEngagementTracking(true)
	.build();

HackleApp.getInstance().setWebViewBridge(webView, webViewConfig);
```

{% endtab %}
{% endtabs %}

#### 설정 옵션

<table><thead><tr><th width="260.20703125">Option</th><th width="110">Default</th><th>Description</th></tr></thead><tbody><tr><td><code>automaticScreenTracking</code></td><td><code>false</code></td><td>웹사이트에서 발생해는 <code>$page_view</code> 수집 여부</td></tr><tr><td><code>automaticEngagementTracking</code></td><td><code>false</code></td><td>웹사이트에서 발생하는 <code>engagement</code> 수집 여부</td></tr><tr><td><code>automaticRouteTracking</code></td><td><code>true</code></td><td>웹사이트에서 발생하는 페이지 정보 자동 수집 여부</td></tr></tbody></table>

{% hint style="info" %}
웹페이지 이동 시 `$page_view`와 `$engagement` 를 자동 수집하려면 `automaticScreenTracking`, `automaticEngagementTracking`, `automaticRouteTracking` 를 모두 `true`로 설정하세요.

웹페이지 이동 시 `$page_view`와 `$engagement` 를 [수동 수집](/development-guide/javascript/event-tracking/js-track-page.md)하는 경우 `automaticScreenTracking`, `automaticEngagementTracking`는 `true`로 설정하고, `automaticRouteTracking` 를 `false`로 설정하세요.
{% endhint %}


---

# 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/android/android-webapp-integration.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.
