React Native SDK - SDK の初期化
インストール
Section titled インストール次のコマンドを実行すると、トラッカーと、すべてのトラッカー機能を利用するための SDK がインストールされます。
npm i @openreplay/react-native
OpenReplay のトラッカーをインスタンス化する際に、録画や録画体験のさまざまな側面をカスタマイズするための設定オプションを多数指定できます。コンストラクターでは projectKey オプションを必ず設定する必要があります。この値は、OpenReplay ダッシュボードの ‘Preferences > Projects’ から取得できます。
トラッキングコードの追加
Section titled トラッキングコードの追加次のコードをルートファイルに追加します:
import Openreplay from '@openreplay/react-native';
// ...
useEffect(() => {
Openreplay.tracker.startSession(
'yourProjectKey',
options, // explained below, set {} if empty
'https://local.openreplay.instance/ingest' // if you're using our Serverless/SaaS plan then 'https://api.openreplay.com/ingest'
);
}, [])
拡張コンポーネントの追加
Section titled 拡張コンポーネントの追加アプリ内でのユーザーインタラクションをトラッキングするには、次のコンポーネントをアプリケーションに追加する必要があります:
ORTouchTrackingView- タッチインタラクションをトラッキングするために、ルートレベルに追加しますORTrackedInput- React-Native の Input のラッパーで、ユーザーが入力を終えるたびにシグナルを送信しますORSanitizedView- 内部のコンテンツをぼかし処理します
// App.tsx
import Openreplay from '@openreplay/react-native';
function App() {
const start = () => {
Openreplay.tracker.startSession(
process.env.REACT_APP_KEY!,
{},
process.env.REACT_APP_INGEST
);
Openreplay.tracker.setMetadata('key', 'value');
Openreplay.tracker.setUserID('user-id');
Openreplay.patchNetwork(global, () => false, {});
};
React.useEffect(() => start(), []);
return (
// this top-level view is required to track touch interactions
<Openreplay.ORTouchTrackingView style={styles.container}>
<View style={styles.container}>
<Openreplay.ORTrackedInput
style={styles.input}
onChangeText={onChangeNumber}
value={number}
placeholder="Trackable input"
numberOfLines={1}
/>
<Openreplay.ORSanitizedView style={styles.sanitizedView}>
<Text>Contents of this view are sanitized and invisible on the recording</Text>
</Openreplay.ORSanitizedView>
</View>
</Openreplay.ORTouchTrackingView>
)
}
データのサニタイズ
Section titled データのサニタイズ詳細については、React Native リプレイでのデータのサニタイズ方法を参照してください。
初期化オプション
Section titled 初期化オプションデフォルトでは、すべてのオプションが true に設定されています:
crashes: Boolクラッシュレポート機能(crashlytics)を有効にします。analytics: Boolマークされたビューのアナリティクストラッキングを有効にします。performances: Boolパフォーマンスリスナーを有効にします。logs: Boolログリスナーを有効にします。screen: Bool画面レコーダーを有効にします。
React Native SDK のモジュールについて知る
ご質問はありますか?
Section titled ご質問はありますか?このプロセスについてご不明な点がございましたら、お気軽に Slack までお問い合わせください。