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

FunctionParametersReturnsDescription
DeployRamp.initconfig: ConfigUnitInitialize the SDK. Pass Config(publicToken = "...") with optional traits.
DeployRamp.flagname: String, traitOverrides: Map<String, String>? = nullBooleanEvaluate a feature flag, optionally with trait overrides.
DeployRamp.setTraitstraits: Map<String, String>UnitSet traits for flag evaluation.
DeployRamp.reporterror: Throwable, flagName: String? = null, traitOverrides: Map<String, String>? = nullUnitReport an error, optionally associated with a specific flag.
DeployRamp.closenoneUnitFlush pending events and release resources.

We use cookies to analyze site usage and improve your experience.