Android SDK - Configuration
Using Builder (Recommended)
Section titled “Using Builder (Recommended)”import com.funnelmob.sdk.FunnelMobConfigurationimport com.funnelmob.sdk.FunnelMobConfiguration.Environmentimport com.funnelmob.sdk.FunnelMobConfiguration.LogLevel
val config = FunnelMobConfiguration.Builder( appId = "com.example.myapp", // Required: Your app identifier apiKey = "fm_live_abc123" // Required: Your API key) .environment(Environment.PRODUCTION) // PRODUCTION (default) or SANDBOX .logLevel(LogLevel.NONE) // NONE, ERROR, WARNING, INFO, DEBUG, VERBOSE .flushInterval(30_000L) // Auto-flush interval in ms (min: 1000, default: 30000) .maxBatchSize(100) // Events per batch (1-100, default: 100) .build()
FunnelMob.initialize(this, config)Using Data Class (Kotlin)
Section titled “Using Data Class (Kotlin)”val config = FunnelMobConfiguration( appId = "com.example.myapp", apiKey = "fm_live_abc123", environment = Environment.PRODUCTION, logLevel = LogLevel.NONE, flushIntervalMs = 30_000L, maxBatchSize = 100)Environments
Section titled “Environments”| Environment | Base URL |
|---|---|
Environment.PRODUCTION | https://api.funnelmob.com/v1 |
Environment.SANDBOX | https://sandbox.funnelmob.com/v1 |
Application Class Setup
Section titled “Application Class Setup”import com.funnelmob.sdk.FunnelMobimport com.funnelmob.sdk.FunnelMobConfiguration
class MyApplication : Application() { override fun onCreate() { super.onCreate()
val config = FunnelMobConfiguration.Builder( appId = "com.example.myapp", apiKey = "fm_live_abc123" ).build()
FunnelMob.initialize(this, config) }}SDK Control
Section titled “SDK Control”// Disable tracking (e.g., for GDPR compliance)FunnelMob.setEnabled(false)
// Re-enable trackingFunnelMob.setEnabled(true)
// Force send queued events immediatelyFunnelMob.flush()Error Handling
Section titled “Error Handling”The SDK throws IllegalStateException if used before initialization:
try { FunnelMob.trackEvent("test")} catch (e: IllegalStateException) { Log.e("FunnelMob", "SDK not initialized: ${e.message}")}Validation errors are logged. Set logLevel to see them:
val config = FunnelMobConfiguration.Builder(appId, apiKey) .logLevel(LogLevel.DEBUG) .build()