@artim-industries/dash-sdk-react-native
v1.0.3
Published
Lightweight event tracking SDK for React Native
Downloads
475
Maintainers
Readme
dash-sdk-react-native
Lightweight event tracking SDK for React Native.
Installation
npm i @artim-industries/dash-sdk-react-nativeBasic usage
Import the SDK singleton and initialize it once before tracking:
import { dashSdkReactNative } from "@artim-industries/dash-sdk-react-native"
dashSdkReactNative.init({
apiKey: "YOUR_API_KEY",
})
// track a button click
await dashSdkReactNative.track()
// timing events
dashSdkReactNative.startTimer("button")
await dashSdkReactNative.endTimer("button")Optional track payload
await dashSdkReactNative.track("button_click", {
label: "Sign up",
screen: "Home",
})Screen tracking hook
If your app uses React hooks, use the provided screen tracking hook:
import { useScreenTracking } from "@artim-industries/dash-sdk-react-native"
export default function HomeScreen() {
useScreenTracking("HomeScreen")
return <View>{/* ... */}</View>
}This will send a screen_view event automatically.
Notes
init()must be called before any track/startTimer/endTimer calls.- The SDK persists events using
AsyncStorageand flushes them.
