Mobile SDKs

Native and cross-platform mobile SDKs for analytics tracking

Mobile SDKs

Mobile SDKs provide native analytics tracking for iOS, Android, and cross-platform applications. Track user interactions, screen views, crashes, and custom events with minimal battery impact.

Cross-Platform SDKs

Native SDKs

Features

All mobile SDKs provide:

Core Analytics

  • Screen View Tracking: Automatic screen view tracking
  • Event Tracking: Custom event tracking with properties
  • User Identification: User identification and traits
  • Session Tracking: Automatic session management
  • Crash Reporting: Automatic crash detection and reporting

Performance Features

  • Battery Optimization: Minimal battery impact
  • Network Efficiency: Batched requests and offline support
  • Storage Efficiency: Local caching and compression
  • Background Sync: Background data synchronization

Privacy & Security

  • GDPR Compliance: Built-in privacy controls
  • Data Minimization: Only collect necessary data
  • Secure Transmission: HTTPS encryption
  • Local Storage: Secure local data storage

Quick Setup

React Native

npm install @entrolytics/react-native-sdk

# or
yarn add @entrolytics/react-native-sdk
import { Entrolytics } from '@entrolytics/react-native-sdk'

Entrolytics.initialize({
  websiteId: 'your-website-id',
  apiKey: 'your-api-key'
})

// Track events
Entrolytics.track('button_click', { button_name: 'Sign Up' })

// Track screens
Entrolytics.screen('HomeScreen')

Android

// build.gradle
implementation 'com.entrolytics:android-sdk:1.0.0'

// Application.kt
Entrolytics.initialize(this, Config.Builder()
    .websiteId("your-website-id")
    .apiKey("your-api-key")
    .build())

// Track events
Entrolytics.track("button_click", mapOf(
    "button_name" to "Sign Up"
))

// Track screens
Entrolytics.screen("HomeActivity")

iOS

// Podfile
pod 'Entrolytics/iOS'

// AppDelegate.swift
Entrolytics.initialize(
    websiteId: "your-website-id",
    apiKey: "your-api-key"
)

// Track events
Entrolytics.track("button_click", properties: [
    "button_name": "Sign Up"
])

// Track screens
Entrolytics.screen("HomeViewController")

API Reference

Common Methods

All SDKs implement these common methods:

Initialization

// React Native
Entrolytics.initialize(config)

// Android
Entrolytics.initialize(context, config)

// iOS
Entrolytics.initialize(config)

Event Tracking

// Track custom event
Entrolytics.track('event_name', { property: 'value' })

// Track screen view
Entrolytics.screen('ScreenName', { title: 'Screen Title' })

// Identify user
Entrolytics.identify('user-123', { email: 'user@example.com' })

// Set user properties
Entrolytics.setUserProperties({ plan: 'pro' })

// Reset user
Entrolytics.reset()

Configuration

// Update configuration
Entrolytics.updateConfig({
  debug: true,
  batchSize: 50,
  flushInterval: 30000
})

// Get current configuration
const config = Entrolytics.getConfig()

Advanced Features

Offline Support

All SDKs support offline tracking with automatic synchronization:

// Enable offline mode
Entrolytics.setOfflineMode(true)

// Events are stored locally and synced when online
Entrolytics.track('offline_event', { cached: true })

// Manually flush cached events
Entrolytics.flush()

Background Sync

// Configure background sync
Entrolytics.configure({
  backgroundSync: true,
  syncInterval: 60000, // 1 minute
  maxBatchSize: 100
})
// Check consent status
const hasConsent = Entrolytics.hasConsent()

// Grant consent
Entrolytics.grantConsent()

// Revoke consent
Entrolytics.revokeConsent()

// Set specific consent preferences
Entrolytics.setConsent({
  analytics: true,
  crashReporting: false,
  performance: true
})

Custom Properties

// Set global properties
Entrolytics.setGlobalProperties({
  app_version: '1.0.0',
  device_type: 'mobile'
})

// Remove global properties
Entrolytics.removeGlobalProperties(['app_version'])

// Clear all global properties
Entrolytics.clearGlobalProperties()

Performance Optimization

Batching

// Configure batch settings
Entrolytics.configure({
  batchSize: 50, // Send events in batches of 50
  flushInterval: 30000, // Flush every 30 seconds
  maxQueueSize: 1000 // Maximum events to queue
})

Network Optimization

// Configure network settings
Entrolytics.configure({
  timeout: 10000, // 10 second timeout
  retryAttempts: 3, // Retry failed requests 3 times
  retryDelay: 1000, // 1 second between retries
  compressionEnabled: true // Enable gzip compression
})

Battery Optimization

// Enable battery-saving mode
Entrolytics.configure({
  batteryOptimization: true,
  adaptiveBatching: true, // Adjust batch size based on battery level
  lowPowerMode: true // Reduce tracking when battery is low
})

Testing

Unit Tests

// React Native testing
import { Entrolytics } from '@entrolytics/react-native-sdk'

jest.mock('@entrolytics/react-native-sdk')

describe('Mobile Analytics', () => {
  it('should track events', () => {
    Entrolytics.track('test_event', { property: 'value' })

    expect(Entrolytics.track).toHaveBeenCalledWith('test_event', {
      property: 'value'
    })
  })
})

Integration Tests

// React Native integration test
describe('Analytics Integration', () => {
  it('should initialize correctly', async () => {
    await Entrolytics.initialize({
      websiteId: 'test-website-id',
      apiKey: 'test-api-key'
    })

    const config = Entrolytics.getConfig()
    expect(config.websiteId).toBe('test-website-id')
  })
})

Best Practices

Troubleshooting

Platform-Specific Considerations

iOS

App Store Guidelines

  • Ensure privacy policy compliance
  • Provide opt-out mechanism
  • Disclose analytics usage
  • Follow App Tracking Transparency (ATT)

Memory Management

  • Use weak references for delegates
  • Implement proper cleanup
  • Monitor memory usage
  • Handle memory warnings

Background Modes

  • Configure background tasks
  • Handle app lifecycle events
  • Manage background sync
  • Optimize for battery life

Android

Google Play Requirements

  • Follow privacy policy requirements
  • Implement user consent
  • Handle data deletion requests
  • Comply with Google Play policies

Performance Optimization

  • Use WorkManager for background tasks
  • Optimize for Doze mode
  • Handle network changes
  • Manage battery optimization

Permissions

  • Request necessary permissions
  • Handle permission denials
  • Provide fallback behavior
  • Explain permission usage

Migration Guides

From Other Analytics SDKs

// Google Analytics (React Native)
import analytics from '@react-native-firebase/analytics'

analytics().logEvent('button_click', { button_name: 'Sign Up' })

// Entrolytics (React Native)
import { Entrolytics } from '@entrolytics/react-native-sdk'

Entrolytics.track('button_click', { button_name: 'Sign Up' })

From Web SDKs

// Web SDK
import { EntrolyticsProvider } from '@entrolytics/react-sdk'
;<EntrolyticsProvider websiteId='your-website-id'>
  <App />
</EntrolyticsProvider>

// Mobile SDK (React Native)
import { Entrolytics } from '@entrolytics/react-native-sdk'

Entrolytics.initialize({ websiteId: 'your-website-id' })

Next Steps

  1. Choose the right SDK for your platform
  2. Follow platform-specific setup instructions
  3. Configure tracking for your use case
  4. Test integration thoroughly
  5. Monitor performance and optimize
  6. Set up alerts for tracking issues

Mobile SDKs for Entrolytics - First-party growth analytics for the edge