SDK Structure
The Grain Analytics SDK provides: Core Methods: Event tracking, user identification, flushing Config Methods: Remote configuration access and management Template Methods: Pre-built events for common scenarios React Hooks: React-specific integrationImport Paths
Core API
Client Creation
Event Tracking
User Management
Remote Configuration
Template Events
Pre-built methods for common scenarios:React Hooks
Provider
Hooks
Method Categories
Core Methods
Event tracking and user management
Config Methods
Remote configuration access
Template Methods
Pre-built event methods
React Hooks
React integration hooks
Types
TypeScript type definitions
Quick Reference
Most Common Methods
Return Values
Most methods return:- Synchronous methods: Direct values or
undefined - Async methods:
Promise<T>that resolves to the result - Hooks: Objects with data, loading states, and errors
Error Handling
Methods handle errors gracefully:- track(): Fire-and-forget, errors logged if debug enabled
- Config methods: Return cached/default on failure
- Async methods: Throw errors, catch with try/catch
- Hooks: Provide
errorproperty