React Native SDK
Wraps @codeserk/forge-stats with a pure-JS HMAC-SHA256 implementation (js-sha256). The full SDK API is re-exported with init and Client defaulting to the React Native compatible hash function. deviceOS and deviceOSVersion are automatically detected from Platform - no extra setup needed.
Installation
Section titled “Installation”npm install @codeserk/forge-stats-react-nativeNo native modules, no pod install required.
Import from this package instead of @codeserk/forge-stats:
import { init, trackView, updateMeta } from '@codeserk/forge-stats-react-native'
init({ sdk: 'YOUR_SDK_KEY' })// deviceOS and deviceOSVersion are already set automatically
// add app metadataupdateMeta({ appName: 'MyApp', appVersionName: '2.3.1' })
// update later (e.g. after login)updateMeta({ userId: 'user_123' })
trackView('HomeScreen')Default metadata
Section titled “Default metadata”deviceOS and deviceOSVersion are set automatically from Platform. Use updateMeta to merge additional metadata or setMeta to replace all defaults. Per-call metadata takes precedence.
// add app info at startupupdateMeta({ appName: 'MyApp', appVersionName: '2.3.1' })
// merge user info after loginupdateMeta({ userId: user.id, userType: user.plan })Error tracking
Section titled “Error tracking”import { trackError, captureGlobalErrors } from '@codeserk/forge-stats-react-native'
// capture all uncaught errors (uses React Native's ErrorUtils)captureGlobalErrors()
// or track manuallytrackError(new Error('Something went wrong'))
// with optionstrackError(new Error('Oops'), { handled: true, data: { screen: 'Checkout' } })Using Client directly
Section titled “Using Client directly”import { Client } from '@codeserk/forge-stats-react-native'
const client = new Client({ sdk: 'YOUR_SDK_KEY' })
client.setMeta({ appName: 'MyApp' })client.trackView('HomeScreen')client.trackError(new Error('Oops'))All functions and types from @codeserk/forge-stats are available - see the TypeScript SDK for the full API reference.