seinetime-universal-sdk
v0.1.12
Published
Universal analytics SDK for React Native applications from Seinetime
Readme
Seinetime React Native SDK
Universal analytics SDK for React Native, iOS, and Android applications.
Installation
⚠️ Important: This SDK requires React Native's New Architecture (0.70+). It will not work with the old architecture.
npm install seinetime-universal-sdk
# or
yarn add seinetime-universal-sdkiOS Setup
After installing the package, install the iOS dependencies:
cd ios && pod install && cd ..Android Setup
The package uses autolinking for Android. No additional setup required.
Rebuild Your App
After installation, rebuild your app to link the native modules:
# For iOS
npx react-native run-ios
# For Android
npx react-native run-androidQuick Start
import Seinetime from 'seinetime-universal-sdk';
// Initialize SDK (call this once when your app starts)
async function initAnalytics() {
await Seinetime.setup({
secretKey: 'your-secret-key-here',
environment: 'production'
});
}
// Track custom events
Seinetime.track('button_clicked', {
button_name: 'signup',
screen: 'home'
});
// Track screen views
Seinetime.screen('home_screen', {
category: 'onboarding'
});
// Identify users
Seinetime.identify('user-123', {
email: '[email protected]',
plan: 'premium'
});Important Notes:
- Call
setup()before using any other SDK methods setup()is asynchronous - useawaitor.then()to ensure initialization completes- Initialize the SDK as early as possible in your app lifecycle (e.g., in
App.tsx)
Configuration
Configuration Options
| Option | Type | Required | Default | Description |
|--------|------|----------|---------|-------------|
| secretKey | string | Yes | - | Your Seinetime API secret key |
| identifySecretKey | string | No | - | Optional key for user identification |
| environment | string | No | 'production' | Environment: 'production', 'staging', or 'test' |
Example Configuration
await Seinetime.setup({
secretKey: 'your-secret-key-here',
identifySecretKey: 'your-identify-key', // Optional
environment: 'production' // Optional: 'production', 'staging', or 'test'
});Getting API Keys
To obtain your secretKey and optional identifySecretKey:
- Sign up at seinetime.ai
- Create a new project in your dashboard
- Copy your API keys from the project settings
Requirements
- React Native: 0.70 or higher with New Architecture enabled
- iOS: 11.0 or higher
- Android: API level 21 (Android 5.0) or higher
- Note: This SDK is built as a TurboModule and requires the New Architecture. It will not work with the old architecture or Expo managed workflow.
API Reference
setup(config: SeinetimeConfig): Promise<void>
Initialize the SDK with your configuration. Must be called before using other methods.
Parameters:
config.secretKey(required): Your Seinetime API keyconfig.identifySecretKey(optional): Key for user identificationconfig.environment(optional): Target environment
Throws:
- Error if
secretKeyis missing - Error if SDK is already initialized
track(eventName: string, properties?: EventProperties): void
Track a custom analytics event.
Parameters:
eventName(required): Name of the eventproperties(optional): Event properties as key-value pairs (string values only)
Example:
Seinetime.track('purchase_completed', {
product_id: '12345',
amount: '99.99',
currency: 'USD'
});screen(screenName: string, properties?: EventProperties): void
Track a screen view.
Parameters:
screenName(required): Name of the screenproperties(optional): Screen properties as key-value pairs (string values only)
Example:
Seinetime.screen('product_details', {
product_id: '12345',
category: 'electronics'
});identify(userId: string, traits?: EventProperties): void
Identify a user with their unique ID and optional traits.
Parameters:
userId(required): Unique identifier for the usertraits(optional): User traits as key-value pairs (string values only)
Example:
Seinetime.identify('user-123', {
email: '[email protected]',
name: 'John Doe',
plan: 'premium'
});Example App
A complete example application is available in the example directory.
Running the Example
cd example
# Install dependencies
npm install
# iOS: Install pods
cd ios && pod install && cd ..
# Run on iOS
npx react-native run-ios
# Run on Android
npx react-native run-androidThe example demonstrates:
- SDK initialization
- Event tracking
- Screen tracking
- User identification
- Error handling
Troubleshooting
Module not found
Problem: Error: Unable to resolve module "seinetime-universal-sdk"
Solutions:
- Ensure the package is installed:
npm install seinetime-universal-sdk - Clear Metro bundler cache:
npx react-native start --reset-cache - Reinstall dependencies:
rm -rf node_modules && npm install - For iOS:
cd ios && pod install && cd ..
Setup Promise never resolves
Problem: setup() call hangs and never completes
Solutions:
- Verify your
secretKeyis correct - Check your network connection
- Try a different
environmentsetting ('test' or 'staging') - Check native logs for errors:
- iOS: Open Xcode console
- Android: Run
npx react-native log-android
Events not appearing in dashboard
Problem: Tracked events don't show up in your Seinetime dashboard
Solutions:
- Ensure
setup()was called and completed before tracking events - Verify you're using the correct
secretKeyfor your environment - Check the
environmentsetting matches your dashboard - Allow a few minutes for events to appear (they may be batched)
- Check your network connection and firewall settings
Need more help?
- 📧 Email: [email protected]
- 🐛 Report issues: GitLab Issues
License
MIT License - see the LICENSE file for details.
Contact
Seinetime
- Website: https://seinetime.ai
- Email: [email protected]
- Technical Support: [email protected]
Made with ❤️ by Seinetime
