For the complete documentation index, see llms.txt. This page is also available as Markdown.

웹앱 연동

React Native SDK 3.28.0 버전 이상, JavaScript SDK 11.51.0 버전 이상에서 지원하는 기능입니다.

웹앱에 대해서는 문서를 참고해주세요.

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

웹앱 연동을 한 경우 웹뷰 내에서 발생하는 모든 이벤트는 React Native SDK를 통해 수집됩니다.

React Native SDK 연동을 완료한 뒤, 다음 단계를 진행하세요.

1

플러그인 추가

플러그인 버전 별 요구사항
플러그인 버전
React Native SDK
react-native-webview
React Native

2.0.0 이상

4.0.0 이상 5.0.0 미만

13.13.0 이상

0.74.0 이상

1.2.0

3.30.0 이상 4.0.0 미만

13.13.0 이상

제한 없음

1.1.0 이상, 1.2.0 미만

3.30.0 이상 4.0.0 미만

11.0.0 이상

제한 없음

1.0.0 이상, 1.1.0 미만

3.28.0 이상 4.0.0 미만

11.0.0 이상

제한 없음

플러그인 2.0.0 이상 버전은 Android API 24 이상, iOS 13 이상을 요구합니다.

React Native 0.81 이상 버전을 사용하면서 플러그인 1.x를 유지해야 하는 경우 플러그인 1.1.1 이상 버전을 사용하세요.

# React Native SDK 4.x
npm install --save @hackler/react-native-webview-plugin@^2.0.0

# React Native SDK 3.x
npm install --save @hackler/react-native-webview-plugin@^1.2.0
# React Native SDK 4.x
yarn add @hackler/react-native-webview-plugin@^2.0.0

# React Native SDK 3.x
yarn add @hackler/react-native-webview-plugin@^1.2.0

iOS

cd ios
pod install
2

WebView 브릿지 주입

WebView를 HackleWebViewBridge로 감싸주세요. HackleWebViewBridge가 웹뷰에 브릿지를 설치하고, 웹사이트의 핵클 JavaScript SDK가 보낸 요청을 React Native SDK로 전달합니다.

import { WebView } from 'react-native-webview';
import { createInstance, HackleProvider } from "@hackler/react-native-sdk";
import { HackleWebViewBridge } from '@hackler/react-native-webview-plugin';

// 웹앱 브릿지 주입 전 반드시 핵클 SDK 초기화가 완료되어야 합니다.
const hackleClient = createInstance("YOUR_APP_SDK_KEY");

function MyWebView() {
  return (
    <HackleProvider hackleClient={hackleClient}>
      <HackleWebViewBridge>
        // 하위요소는 react-native-webview 객체 하나만 사용해주세요.
        <WebView source={{ uri: currentUrl }} />
      </HackleWebViewBridge>
    </HackleProvider>
  );
}

react native webview의 nativeConfig props에 HackleWebViewConfig를 추가해주세요.

createHackleWebViewConfig() 함수를 이용하여 config 를 생성할 수 있습니다.

import { WebView } from 'react-native-webview';
import { createInstance, HackleProvider } from "@hackler/react-native-sdk";
import { createHackleWebViewConfig } from '@hackler/react-native-webview-plugin';

// 웹앱 브릿지 주입 전 반드시 핵클 SDK 초기화가 완료되어야 합니다.
const hackleClient = createInstance("YOUR_APP_SDK_KEY");

function MyWebView() {
  const hackleConfig = createHackleWebViewConfig();

  return (
    <HackleProvider hackleClient={hackleClient}>
      <WebView
        nativeConfig={hackleConfig}
        source={{ uri: currentUrl }}
      />
    </HackleProvider>
  );
}

React Native SDK를 4.x로 올릴 때는 플러그인도 2.x로 함께 올려야 합니다. 마이그레이션 가이드를 참고해주세요.

해당 기능을 사용하기 위해서는 JavaScript 웹페이지에서 동일한 App SDK 키를 사용해야 합니다.

3

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

웹뷰 내 웹사이트에서 발생하는 $page_view와 $engagement는 비활성화 상태입니다.

웹뷰 브릿지를 설정할 때 자동 수집 이벤트를 각각 활성화할 수 있습니다.

HackleWebViewBridge에 prop을 전달하여 설정합니다.

import { WebView } from 'react-native-webview';
import { createInstance, HackleProvider } from "@hackler/react-native-sdk";
import { HackleWebViewBridge } from '@hackler/react-native-webview-plugin';

// 웹앱 브릿지 주입 전 반드시 핵클 SDK 초기화가 완료되어야 합니다.
const hackleClient = createInstance("YOUR_APP_SDK_KEY");

function MyWebView() {
  return (
    <HackleProvider hackleClient={hackleClient}>
      <HackleWebViewBridge
        automaticScreenTracking
        automaticEngagementTracking
        automaticRouteTracking
      >
        <WebView source={{ uri: currentUrl }} />
      </HackleWebViewBridge>
    </HackleProvider>
  );
}

값을 false로 설정할 때는 automaticRouteTracking={false} 와 같이 값을 명시해주세요.

createHackleWebViewConfig()에 HackleWebViewConfig를 전달하여 설정합니다.

설정 옵션

설정 옵션의 이름과 기본값은 플러그인 1.x와 2.x가 동일합니다.

설정
기능
기본값
지원 버전

automaticScreenTracking

$page_view 수집 여부

false

1.0.0 +

automaticEngagementTracking

$engagement 수집 여부

false

1.0.0 +

automaticRouteTracking

페이지 정보 자동 수집 여부

true

1.1.0 +

웹페이지 이동 시 수집 방식을 선택하세요.

  • 자동 수집: automaticScreenTracking, automaticEngagementTracking, automaticRouteTracking를 모두 true로 설정하세요.

  • 수동 수집: automaticScreenTracking과 automaticEngagementTracking는 true로 설정하세요. automaticRouteTracking는 false로 설정하세요.

마지막 업데이트