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.Supported Configuration Scenarios:
- Enrich user sessions - Add custom views, actions, resources, and error information
- Protect sensitive data - Mask personally identifiable information and sensitive data
- Associate user sessions - Link user sessions with internal user identifiers
- Control data volume - Optimize data collection through sampling and event filtering
- Enhance context - Add custom attributes to data
Enrich User Sessions
Custom Views
When usingActivityViewTrackingStrategy or FragmentViewTrackingStrategy, the RUM SDK automatically tracks views. You can also manually send custom RUM views when a view becomes visible or interactive.
- Kotlin
- Java
Parameter Description:
viewKey(String) - Unique identifier for the view, sameviewKeyused forstartView()andstopView()viewName(String) - Name of the viewattributes(Map<String, Any?>) - Attributes attached to the view (optional)
Custom Actions
In addition to auto-tracked user interactions, you can track specific custom user actions (like clicks, swipes, likes).- Kotlin
- Java
RumActionType Enum Values
RumActionType Enum Values
Custom Resources
In addition to auto-tracked resources, you can manually track specific custom resources (like network requests, third-party library loading).- Kotlin
- Java
RumResourceKind Resource Types
RumResourceKind Resource Types
Custom Errors
To record specific errors, notify the RUM SDK when an exception occurs:- Kotlin
- Java
For more error reporting details, see Android Error Reporting.
Custom Timing
In addition to RUM SDK’s default performance metrics, you can use theaddTiming API to measure the duration of key operations. Timing is an offset relative to the current RUM view start time.
- Kotlin
- Java
Set User Information
The RUM SDK supports standard user information.- Kotlin
- Java
Event and Data Management
Clear All Data
UseclearAllData to clear all unsent data currently stored in the SDK:
- Kotlin
- Java
Stop Data Collection
UsestopInstance to stop collecting data and clear all local data:
- Kotlin
- Java
Control Event Batch Upload
The RUM SDK uploads events in batches automatically. You can control that behavior with configuration parameters:- Kotlin
- Java
UploadFrequency
UploadFrequency
Set Remote Log Threshold
You can define a minimum log level for remotely recorded messages. Logs below that level are not sent to Flashduty:- Kotlin
- Java
With a
Log.WARN threshold, only WARN and ERROR logs are uploaded. DEBUG and INFO logs are filtered out.Track Custom Global Attributes
Beyond the default attributes the RUM SDK captures automatically, you can attach extra context to RUM events, such as custom attributes.What custom attributes are for:
- Filter and group user behavior by business information, such as cart state, user tier, or marketing campaign
- Follow the browsing path of a specific user
- Understand which users are hit hardest by an error
- Monitor performance for your most important users
Track User Sessions
To identify user sessions, call thesetUserInfo API after initializing the SDK:
- Kotlin
- Java
Parameters:
id(String) - Unique user identifiername(String) - Friendly user name, shown in the RUM UI by defaultemail(String) - User email, shown when no name is available- All of these are optional, but you should provide at least one
Track Attributes
Global attributes are attached to every RUM event and are useful for adding shared context. Add a global attribute:- Kotlin
- Java
- Kotlin
- Java
Track Widgets
Widgets are not tracked automatically. To monitor widget interactions, call the API yourself.
- Kotlin
- Java
Initialization Parameters
When you initialize the Flashduty Android SDK,Configuration.Builder gives you several options.
Automatically Track Views
To track views (activities and fragments) automatically, calluseViewTrackingStrategy during initialization:
- Kotlin
- Java
Available tracking strategies
Available tracking strategies
Automatically Track Network Requests
To track HTTP requests automatically, see the OkHttp interceptor setup in the SDK integration guide.Automatically Track Apollo GraphQL Requests
If you use the Apollo GraphQL client for network calls, you can enable automatic tracking.1
Add the Apollo dependency
Add the dependency to your app’s
build.gradle file:build.gradle
2
Configure the Apollo client
- Kotlin
- Java
Flashduty tracing headers are added to your GraphQL requests automatically, which makes them traceable.
- Kotlin
- Java
Automatically Track Long Tasks
Long-running work on the main thread can hurt your app’s visual performance and responsiveness. The SDK can detect and track long tasks automatically.- Kotlin
- Java
The default threshold is 100ms. Adjust it to match your app’s performance requirements.
Modify or Discard RUM Events
To modify some attributes of a RUM event before it is batched, or to discard events entirely, provide an implementation ofEventMapper<T> at initialization.
- Kotlin
- Java
Modifiable Event Attributes
When you implement theEventMapper<T> interface, only some attributes can be modified for each event type:
ViewEvent modifiable attributes
ViewEvent modifiable attributes
ActionEvent modifiable attributes
ActionEvent modifiable attributes
ErrorEvent modifiable attributes
ErrorEvent modifiable attributes
ResourceEvent modifiable attributes
ResourceEvent modifiable attributes
LongTaskEvent modifiable attributes
LongTaskEvent modifiable attributes
Example: Discard Sensitive Errors
- Kotlin
- Java
Get the RUM Session ID
Retrieving the RUM session ID is useful for troubleshooting. You can attach it to support requests, emails or error reports so the support team can find the user’s session in Flashduty.- Kotlin
- Java
Sampling Control
By default, RUM collects data for every session. You can reduce the number of collected sessions by setting a sample rate through thesessionSampleRate parameter.
- Kotlin
- Java
Sample rate range: 0.0 - 100.0
100.0- Collect every session (default)50.0- Collect 50% of sessions0.0- Collect no sessions
Remote configuration: adjust the sample rate from the console
Since 0.7.0, the session sample rate can be changed on the Remote configuration page of the Flashcat console without shipping a new release of your app. The feature is off by default; turn it on at initialization:- Kotlin
- Java
- The SDK asks the console for the configuration once at startup and once whenever a new session starts. What it receives is used to draw the next session; a session already under way is never redrawn.
- The exception is a rate that crosses zero (from 0 to non-zero, or from non-zero to 0): the running session ends immediately and the next one is drawn under the new rate, so an emergency stop or a restart does not wait for sessions to rotate.
- When the request fails, times out or returns an unreadable response, the SDK keeps the values already in use; before the first configuration ever arrives, the value passed to
setSessionSampleRateapplies. The configuration is cached on the device, so the first session of the next cold start already uses it. - The request carries only the client token, the environment, the app version and the SDK version, never user data, so it is not gated by the tracking consent state.
- In a private deployment the configuration endpoint sits beside the RUM intake under
/config(for an intake ofhttps://host/api/v2/rum, it ishttps://host/api/v2/rum/config). When you useuseCustomEndpoint, make sure your gateway lets that path through.
Override the draw from your app
To guarantee that certain users are always collected (internal testers, a user whose issue you are investigating),setBeforeSampling lets the app have the last word before each draw. Return null to keep the incoming rate. A value outside 0..100, or a callback that throws, also leaves the incoming rate in place and never disrupts collection.
- Kotlin
- Java
setForcedSession() at any time to collect every session of this user from now until the process ends:
Read the console’s custom configuration
The values published under “Custom configuration” on the Remote configuration page are delivered to the SDK verbatim and can be read withgetRemoteConfig(). The SDK never interprets them; what they mean is entirely up to your app. It returns null when nothing is published or remote configuration is off.
User Tracking Consent
To comply with privacy regulations such as GDPR and CCPA, RUM lets you set the user tracking consent state at initialization.Consent States
If you initialize with
TrackingConsent.PENDING, the SDK starts collecting data but sends nothing until the consent state changes to GRANTED.Change Consent State
You can change the consent state after initialization through thesetTrackingConsent API:
- Kotlin
- Java
Best Practices
View tracking
View tracking
- Call
startViewandstopViewin the right lifecycle methods so views are not tracked twice - Use a unique
viewKeyfor each view
Resource tracking
Resource tracking
- When tracking resources manually, pair every
startResourcewith a matchingstopResourceorstopResourceWithError - Avoid tracking internal resources or requests that fire very frequently
Event modification
Event modification
- Only the attributes listed in the tables above can be modified; changes to any other attribute are ignored
- Return
nullto discard the whole event
Performance
Performance
- Tune the sample rate and batch upload frequency together to balance data volume against overhead
- Avoid slow work inside event callbacks
Related Documentation
SDK Integration
Learn how to quickly integrate the RUM SDK
Data Collection
Learn about data types and attributes collected by the SDK
Compatibility
Learn about SDK compatibility requirements