Example
CodeskopAndroid.init( this, CodeskopConfig( apiKey = BuildConfig.CODESKOP_KEY, sampleRates = mapOf("api_timing" to 0.2), // keep 20% of request timings redactHeaders = setOf("authorization", "cookie", "set-cookie", "x-api-key"), maxQueueMb = 10, ),)Options
| Option | Type | Default | Description |
|---|---|---|---|
| apiKey | String | required | Your public ingest key (cs_live_pk_… or cs_test_pk_…). Any other key keeps the SDK switched off. |
| endpoint | String | https://api.codeskop.com | Where events are sent. Change this only for a staging environment Codeskop has given you. |
| sampleRates | Map<String, Double> | emptyMap() | The share of each event type to keep, from 0.0 to 1.0. Any type not listed is kept in full. See Sampling. |
| redactHeaders | Set<String> | "authorization", "cookie", "set-cookie" | Header names whose values are replaced with [REDACTED] before an event is stored. Matched case-insensitively. |
| maxQueueMb | Int | 10 | The most disk space the on-device queue may use. When it's full, the oldest low-priority events are dropped first. Crashes and ANRs are always kept. See Offline & sync. |
| flushBatchSize | Int | 50 | How many queued events are read per upload during a sync. |
| captureExceptionMessages | Boolean | false | Send exception and crash messages as they are. Off by default: messages are replaced with [REDACTED] because they often contain user input. Added in 0.2.0. See Exception messages. |
| environment | String | "production" | A label sent with every event as context.app.environment (0.3.1+). Test and production data are still separated by the key. |
| captureNetwork | Boolean | true | false turns off API capture, from the OkHttp adapter and from captureApiError / captureApiTiming (0.3.1+). |
| captureHeaders | Boolean | true | false sends no request or response headers with API events (0.3.1+). |
| heartbeatEnabled | Boolean | true | false stops the foreground presence heartbeats (0.3.1+). The live active-user count then misses this app. |
| captureScreens | Boolean | true | Product analytics (Growth and Scale): record each Activity shown as a screen (0.3.0+), and each Fragment with a view when your app uses androidx.fragment (0.4.0+). On iOS, each view controller (0.4.0+). See Screens and lifecycle events. |
Screens and lifecycle events
With captureScreens on, Activities and Fragments are recorded as screens, named after their class. Navigation hosts and other androidx containers are skipped. Jetpack Compose apps record each destination with one call (0.4.0+), named by route. It needs androidx.navigation, which the SDK doesn't add:
import com.codeskop.sdk.android.trackNavigation @Composablefun AppNavHost() { val navController = rememberNavController() LaunchedEffect(navController) { Codeskop.trackNavigation(navController) } NavHost(navController, startDestination = "home") { /* ... */ }}From 0.4.0 the SDK also sends lifecycle events on every plan: $app_opened (cold on the first foreground of the process, warm on every return to the foreground), $app_foregrounded, $app_backgrounded, $session_started, $session_ended and $app_updated. There is no option to set: they never count toward the analytics meter. The session is saved on the device, so a restart within 30 minutes continues it. See the event model.
Track with a category
Codeskop.track takes an optional category (0.4.0+). Taps aren't recorded automatically, so track the ones that matter as interaction:
Codeskop.track("delivery_method_selected", mapOf("method" to "pickup"), category = "interaction")Exception messages
By default only the exception class and stack trace are sent, and the message is replaced with [REDACTED]. The message is often the most useful clue (“cart is empty”, “database is locked”), so if your messages don't contain personal data you can opt in:
CodeskopConfig( apiKey = BuildConfig.CODESKOP_KEY, captureExceptionMessages = true, // send messages instead of [REDACTED])With zero-code init, add <meta-data android:name="codeskop.capture_exception_messages" android:value="true" /> to your manifest instead. For iOS, Flutter and web, and how to check it works, see Exception messages in Crash reporting.
Sampling
High-volume signals such as request timings can add up. Use sampleRates to keep a share of them. The keys are event types:
api_timing: latency for every completed request (the most common one to sample)api_error: failed requestsexception: handled exceptions you report withrecordExceptionheartbeat: foreground presence pings
Crashes and ANRs are never sampled
crash, crash_native and anr are always kept, whatever rate you set.Remote overrides
When the SDK starts, it fetches your project's settings from Codeskop, which you change in the dashboard under Settings → SDK settings. Those settings replace your sampleRates and maxQueueMb, can switch network capture and ANR detection off, and can turn capture off entirely. Treat the values you set in code as defaults. See Remote config.
Test and production builds
Each project has a test and a production environment, and the key decides where events go: a cs_test_pk_… key reports to Test, a cs_live_pk_… key to Production. Use the test key in debug builds so your own testing never mixes with real users:
CodeskopConfig( apiKey = if (BuildConfig.DEBUG) "cs_test_pk_YOUR_TEST_KEY" else "cs_live_pk_YOUR_LIVE_KEY",)On the dashboard, the Environment filter on the Issues page switches between the two. Test events aren't billed.
Options reserved for later releases
CodeskopConfig also accepts captureBodies and redactQueryKeys. In version 0.4.0 they don't change behavior, so you can leave them out. Request and response bodies are never captured, and query strings are always removed from URLs, whatever these options are set to.
Before 0.3.1, environment, captureNetwork, captureHeaders and heartbeatEnabled were also accepted without effect. On those versions, turn off network capture by not adding the OkHttp adapter to your client.