react-native-clarity
A ReactNative plugin that allows integrating Clarity with your application.
Installation
npm install react-native-clarity
Usage
import {LogLevel, initialize, setCustomUserId, setCustomSessionId, setCustomTag, setCurrentScreenName, getCurrentSessionId } from 'react-native-clarity';
let clarityConfig = {
logLevel: LogLevel.Verbose,
allowMeteredNetworkUsage: true
}
initialize('<ProjectId>', clarityConfig);
setCustomUserId("<CustomUserId>");
setCustomSessionId("<CustomSessionId>");
setCustomTag("key", "value");
import { ..., useFocusEffect } from '@react-navigation/native';
const HomeScreen = ({...}) => {
useFocusEffect(
React.useCallback(() => {
setCurrentScreenName("Home");
return () => { setCurrentScreenName(undefined); }
}, [])
);
...
};
getCurrentSessionId().then((id) => {...});
Initialization arguments
function initialize(projectId: string, config?: ClarityConfig)
interface ClarityConfig {
userId?: string | null;
logLevel?: LogLevel;
allowMeteredNetworkUsage?: boolean;
enableWebViewCapture?: boolean;
allowedDomains?: string[];
disableOnLowEndDevices?: Boolean;
}
License
MIT