Skip to main content
Flashduty Android RUM SDK supports Android 6.0 (API level 23) and above. By integrating the SDK, you can monitor your Android app’s performance, errors, and user behavior in real-time.
About Dependencies and Package NamesFlashduty Android SDK is fully compatible with the Datadog open-source protocol. In build.gradle, use cloud.flashcat group for dependencies, but in Kotlin/Java code, import classes from the com.datadog.android package. You can seamlessly leverage Datadog ecosystem documentation, examples, and best practices while enjoying Flashduty platform services.

Integration Steps

1

Add SDK Dependencies

Add SDK dependencies in your app module’s build.gradle file:
build.gradle
dependencies {
    implementation "cloud.flashcat:dd-sdk-android-core:<latest-version>"
    implementation "cloud.flashcat:dd-sdk-android-rum:<latest-version>"
}
Check the SDK Release Page for the latest version. Replace <latest-version> with the actual version number (e.g., 0.3.0).
2

Get Application Credentials

In the Flashduty console’s RUM Application Management page:
  1. Create or select an Android application
  2. Get the following credentials:
    • Application ID - Application unique identifier
    • Client Token - Client access token
3

Initialize SDK

Initialize Flashcat SDK in your Application class’s onCreate() method:
Application.kt
import com.datadog.android.Datadog
import com.datadog.android.core.configuration.Configuration
import com.datadog.android.privacy.TrackingConsent

class SampleApplication : Application() {
    override fun onCreate() {
        super.onCreate()

        val clientToken = "<CLIENT_TOKEN>"
        val environmentName = "<ENV_NAME>"
        val appVariantName = "<APP_VARIANT_NAME>"

        val configuration = Configuration.Builder(
            clientToken = clientToken,
            env = environmentName,
            variant = appVariantName
        ).build()

        Datadog.initialize(this, configuration, TrackingConsent.GRANTED)
    }
}
Parameter Description:
  • environmentName - Environment name (e.g., production, staging)
  • appVariantName - App variant name, used to distinguish data from different build versions
  • For more configuration options, see Advanced Configuration
4

Enable RUM Features

Configure and enable Android SDK’s RUM features:
Application.kt
import com.datadog.android.rum.Rum
import com.datadog.android.rum.RumConfiguration
import com.datadog.android.rum.tracking.ActivityViewTrackingStrategy

val rumConfig = RumConfiguration.Builder(applicationId)
    .trackUserInteractions()
    .trackLongTasks(durationThreshold)
    .useViewTrackingStrategy(ActivityViewTrackingStrategy(true))
    .build()

Rum.enable(rumConfig)
The SDK will automatically start collecting the following data:
  • User interaction events
  • Long task monitoring
  • Activity view tracking
5

Configure Network Tracking (Optional)

Configure network interceptors to track HTTP requests and responses:Add OkHttp dependency:
build.gradle
dependencies {
    implementation "cloud.flashcat:dd-sdk-android-okhttp:<latest-version>"
}
Check the SDK Release Page for the latest version.
Configure interceptor:
import com.datadog.android.okhttp.DatadogInterceptor
import com.datadog.android.trace.TracingHeaderType

val tracedHostsWithHeaderType = mapOf(
    "example.com" to setOf(
        TracingHeaderType.DATADOG, // datadog protocol
        TracingHeaderType.TRACECONTEXT // w3c standard protocol
    ),
    "api.example.com" to setOf(
        TracingHeaderType.DATADOG,
        TracingHeaderType.TRACECONTEXT
    )
)

val okHttpClient = OkHttpClient.Builder()
    .addInterceptor(DatadogInterceptor.Builder(tracedHostsWithHeaderType).build())
    .build()
With DatadogInterceptor, every request handled by OkHttpClient is automatically recorded as a resource, with relevant information (URL, method, status code, error) automatically populated.
  • Only network requests initiated while a view is active are tracked - To track requests when app is in background, see Track Background Events - If using multiple interceptors, add DatadogInterceptor as the first interceptor
Track Network Redirects or Retries:To monitor network redirects or retries, use DatadogInterceptor as a network interceptor:
val okHttpClient = OkHttpClient.Builder()
    .addNetworkInterceptor(DatadogInterceptor.Builder(tracedHostsWithHeaderType).build())
    .build()
You can also add an EventListener to OkHttpClient to automatically track resource timing for third-party providers and network requests.
Filter Specific Errors:To filter specific errors reported by DatadogInterceptor, configure a custom EventMapper in RumConfiguration:
val rumConfig = RumConfiguration.Builder(applicationId)
    .setErrorEventMapper { errorEvent ->
        if (errorEvent.shouldBeDiscarded()) {
            null
        } else {
            errorEvent
        }
    }
    .build()

Advanced Configuration

Track Background Events

You can track events when the app is running in the background (e.g., crashes and network requests):
val rumConfig = RumConfiguration.Builder(applicationId)
    .trackBackgroundEvents(true)
    .build()
Tracking background events may generate additional sessions, affecting billing. If you have questions, please contact Flashcat support team.

Offline Data Handling

The Android SDK ensures data availability when the user’s device is offline:
Data Persistence Mechanism: - Events are stored locally in batches when network signal is weak or device battery is low - Automatically uploaded when network recovers, ensuring no data loss - Old data is automatically cleaned up to avoid excessive disk usage
Even if users use the app while offline, data is retained and uploaded when network recovers, ensuring no monitoring data is lost.

Track Local Resource Access

You can track access to assets and raw resources:
val inputStream = context.getAssetAsRumResource(fileName)

WebView Integration

If your Android app contains WebViews, you can enable WebView tracking to monitor web content performance and errors.
1

Add WebView Dependency

build.gradle
dependencies {
    implementation "cloud.flashcat:dd-sdk-android-webview:<latest-version>"
}
Check the SDK Release Page for the latest version.
2

Enable WebView Tracking

Enable WebView tracking in your Activity or Fragment:
import com.datadog.android.webview.WebViewTracking

// Enable tracking for specified WebView
WebViewTracking.enable(webView, listOf("example.com", "*.example.com"))
Parameter Description:
  • webView - WebView instance to track
  • allowedHosts - List of domains to track, supports wildcards (e.g., *.example.com)
Web pages in WebView can now be correlated with native app RUM data.

Verify Integration

After integration, verify that the integration is successful:
1

Access Console

Log in to Flashduty console, go to the corresponding RUM application, and check if data is being reported.
2

Trigger Test Events

Perform the following actions in the app to verify data collection: - Open different pages in the app to verify page view events - Perform user actions (clicks, swipes, etc.) to verify interaction events - Trigger network requests to verify resource loading events
3

Check Logs

Check Logcat for network requests to the data reporting endpoint.
If you see data reporting requests and data appears in the console, the integration is successful!

ProGuard Configuration

If your app has code obfuscation enabled (ProGuard/R8), add the following rules to your proguard-rules.pro file:
proguard-rules.pro
# Flashduty SDK (Datadog compatible)
-keep class com.datadog.android.** { *; }
-dontwarn com.datadog.android.**

Next Steps