웹앱 연동
React Native SDK 3.28.0 버전 이상, Javascript SDK 11.51.0 버전 이상에서 지원하는 기능입니다.
웹앱에 대해서는 문서를 참고해주세요.
이미 웹앱 연동중이셨나요?React Native와 Javascript 코드를 모두 수정하는 웹앱 연동방식을 사용중이셨으면 마이그레이션 가이드를 참고해서 새로운 웹앱 연동 방식으로 연동해주세요.
WebView를 통해 자사 웹사이트를 랜더링하는 경우, 아래 설정을 통해 웹사이트에 포함된 핵클 JavaScript SDK를 웹사이트 코드 변경없이 핵클 React Native SDK 기능과 동일하게 사용할 수 있습니다.
웹앱 연동을 한 경우 웹뷰 내에서 발생하는 모든 이벤트는 React Native SDK를 통해 수집됩니다.
React Native 웹앱 연동을 위해서 아래의 작업이 필요합니다.
- React Native SDK 연동을 완료합니다.
@hackler/react-native-webview-plugin을 프로젝트에 추가합니다.- React Native에서 WebView를 렌더링하는 시점에 브릿지를 추가합니다.
1. 플러그인 추가
npm install --save @hackler/react-native-webview-plugin
react-native link
cd ios
pod installyarn add @hackler/react-native-webview-plugin
react-native link
cd ios
pod install2. WebView 브릿지 주입
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_SDK_KEY");
function MyWebView() {
const config = createHackleWebViewConfig();
return (
<HackleProvider hackleClient={hackleClient}>
<WebView
nativeConfig={hackleConfig}
source={{ uri: currentUrl }}
/>
</HackleProvider>
);
}웹뷰에서 발생하는 자동 수집 이벤트 연동
웹뷰 내 웹사이트에서 발생하는 $page_view와 $engagement는 비활성화 상태입니다.
웹뷰 브릿지를 설정할 때 HackleWebViewConfig를 설정하여 자동 수집 이벤트를 각각 활성화할 수 있습니다.
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_SDK_KEY");
function MyWebView() {
const config = createHackleWebViewConfig({
automaticScreenTracking: true,
automaticEngagementTracking: true,
});
return (
<HackleProvider hackleClient={hackleClient}>
<WebView
nativeConfig={hackleConfig}
source={{ uri: currentUrl }}
/>
</HackleProvider>
);
}설정 옵션
| 설정 | 기능 | 기본값 | 지원 브릿지 버전 |
|---|---|---|---|
| automaticScreenTracking | $page_view 수집 여부 | false | 1.0.0 + |
| automaticEngagementTracking | $engagement 수집 여부 | false | 1.0.0 + |
Updated 1 day ago
