Skip to content

Android SDK - Configuration

import com.funnelmob.sdk.FunnelMobConfiguration
import com.funnelmob.sdk.FunnelMobConfiguration.Environment
import 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)
val config = FunnelMobConfiguration(
appId = "com.example.myapp",
apiKey = "fm_live_abc123",
environment = Environment.PRODUCTION,
logLevel = LogLevel.NONE,
flushIntervalMs = 30_000L,
maxBatchSize = 100
)
EnvironmentBase URL
Environment.PRODUCTIONhttps://api.funnelmob.com/v1
Environment.SANDBOXhttps://sandbox.funnelmob.com/v1
import com.funnelmob.sdk.FunnelMob
import 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)
}
}
// Disable tracking (e.g., for GDPR compliance)
FunnelMob.setEnabled(false)
// Re-enable tracking
FunnelMob.setEnabled(true)
// Force send queued events immediately
FunnelMob.flush()

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()