Kotlin SDK
The DeployRamp Kotlin SDK lets you evaluate feature flags, report errors, and manage traits from any JVM application. It shares the same artifact as the Java SDK, so you can use either language in the same project.
Installation
Add the dependency to your Gradle build file:
implementation("com.deployramp:deployramp-sdk:0.1.0")Initialization
Initialize the SDK with your public token before evaluating any flags. You can optionally pass initial traits:
import com.deployramp.sdk.Config
import com.deployramp.sdk.DeployRamp
DeployRamp.init(Config(
publicToken = "pk_live_abc123",
traits = mapOf("plan" to "pro"),
))Evaluating Flags
Call DeployRamp.flag() with the flag name to check whether a feature is enabled. You can optionally pass trait overrides:
if (DeployRamp.flag("new-checkout")) {
// new checkout flow
}
// With trait overrides
if (DeployRamp.flag("new-checkout", traitOverrides = mapOf("plan" to "enterprise"))) {
// enterprise-only checkout flow
}Setting Traits
Traits are key-value pairs that describe the current user or environment. They influence flag evaluation on the server:
DeployRamp.setTraits(mapOf(
"plan" to "pro",
"region" to "us-east-1",
))Error Reporting
Report caught exceptions so DeployRamp can correlate errors with flag rollouts and trigger automatic rollbacks when needed:
try {
processPayment()
} catch (e: Exception) {
DeployRamp.report(e, flagName = "new-checkout")
}Shutdown
Call close() when your application is shutting down to flush any pending events and release resources:
DeployRamp.close()API Reference
| Function | Parameters | Returns | Description |
|---|---|---|---|
DeployRamp.init | config: Config | Unit | Initialize the SDK. Pass Config(publicToken = "...") with optional traits. |
DeployRamp.flag | name: String, traitOverrides: Map<String, String>? = null | Boolean | Evaluate a feature flag, optionally with trait overrides. |
DeployRamp.setTraits | traits: Map<String, String> | Unit | Set traits for flag evaluation. |
DeployRamp.report | error: Throwable, flagName: String? = null, traitOverrides: Map<String, String>? = null | Unit | Report an error, optionally associated with a specific flag. |
DeployRamp.close | none | Unit | Flush pending events and release resources. |