About Dependencies and Package NamesFlashduty iOS SDK is fully compatible with the Datadog open-source protocol. When adding dependencies via Swift Package Manager or CocoaPods, use names like FlashcatCore and FlashcatRUM, but in code, import modules like DatadogCore and DatadogRUM. You can seamlessly leverage Datadog ecosystem documentation, examples, and best practices while enjoying Flashduty platform services.
Flashduty iOS RUM SDK provides rich advanced configuration options to help you customize data collection and context information based on business needs.
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
In addition to auto-tracked views, you can manually track custom views:
import DatadogRUM
// Start tracking view
RUMMonitor.shared().startView(
key: "view-key",
name: "View Name",
attributes: [:]
)
// Stop tracking view
RUMMonitor.shared().stopView(
key: "view-key",
attributes: [:]
)
@import DatadogRUM;
// Start tracking view
[[RUMMonitor shared] startViewWithKey:@"view-key"
name:@"View Name"
attributes:@{}];
// Stop tracking view
[[RUMMonitor shared] stopViewWithKey:@"view-key"
attributes:@{}];
Parameter Description:
key (String) - Unique identifier for the view, same key used for startView and stopView
name (String) - Name of the view
attributes (Dictionary) - Attributes attached to the view (optional)
Custom Actions
Track specific custom user actions:
import DatadogRUM
RUMMonitor.shared().addAction(
type: .tap,
name: "Button Tapped",
attributes: ["button_id": "submit"]
)
@import DatadogRUM;
[[RUMMonitor shared] addActionWithType:RUMActionTypeTap
name:@"Button Tapped"
attributes:@{@"button_id": @"submit"}];
Custom Resources
Manually track specific custom resources:
import DatadogRUM
// Start resource tracking
RUMMonitor.shared().startResource(
resourceKey: "resource-key",
httpMethod: .get,
urlString: "https://api.example.com/data",
attributes: [:]
)
// Stop resource tracking (success)
RUMMonitor.shared().stopResource(
resourceKey: "resource-key",
statusCode: 200,
kind: .native,
size: 1024,
attributes: [:]
)
// Stop resource tracking (error)
RUMMonitor.shared().stopResourceWithError(
resourceKey: "resource-key",
message: "Network error",
type: "NetworkError",
response: nil,
attributes: [:]
)
Custom Errors
Record specific errors:
import DatadogRUM
RUMMonitor.shared().addError(
message: "Network request failed",
type: "NetworkError",
source: .network,
attributes: [
"url": "https://api.example.com",
"status_code": 500
]
)
@import DatadogRUM;
[[RUMMonitor shared] addErrorWithMessage:@"Network request failed"
type:@"NetworkError"
source:RUMErrorSourceNetwork
attributes:@{
@"url": @"https://api.example.com",
@"status_code": @500
}];
Add User Attributes
Set user information for the current session:
import DatadogCore
Datadog.setUserInfo(
id: "user-123",
name: "John Doe",
email: "john.doe@example.com",
extraInfo: [
"plan": "premium",
"signup_date": "2024-01-15"
]
)
@import DatadogCore;
[DDDatadog setUserInfoWithId:@"user-123"
name:@"John Doe"
email:@"john.doe@example.com"
extraInfo:@{
@"plan": @"premium",
@"signup_date": @"2024-01-15"
}];
Custom user attributes can be used to group and filter data in the Insights dashboard.
Event and Data Management
Clear All Data
Clear all unsent data currently stored in the SDK:
import DatadogCore
Datadog.clearAllData()
@import DatadogCore;
[DDDatadog clearAllData];
Sampling
Control the percentage of sessions that collect RUM data:
RUM.enable(
with: RUM.Configuration(
applicationID: "<RUM_APPLICATION_ID>",
sessionSampleRate: 80 // Collect 80% of sessions
)
)
Sampled-out sessions will not collect any page views or related telemetry data.
User Tracking Consent
To comply with privacy regulations like GDPR and CCPA, you can set user tracking consent state:
// Set consent state during initialization
Datadog.initialize(
with: configuration,
trackingConsent: .pending
)
// Update consent state when user grants permission
Datadog.set(trackingConsent: .granted)
// Update consent state when user revokes permission
Datadog.set(trackingConsent: .notGranted)
| State | Behavior |
|---|
.granted | Start collecting data and send to Flashduty |
.notGranted | Do not collect any data |
.pending | Collect but do not send, wait for user decision |
Global Context
Add global context attributes that will be attached to all RUM events:
import DatadogRUM
// Add attribute
RUMMonitor.shared().addAttribute(forKey: "user_type", value: "premium")
// Remove attribute
RUMMonitor.shared().removeAttribute(forKey: "user_type")
@import DatadogRUM;
// Add attribute
[[RUMMonitor shared] addAttributeForKey:@"user_type" value:@"premium"];
// Remove attribute
[[RUMMonitor shared] removeAttributeForKey:@"user_type"];
Event Mappers
Use Event Mappers to modify or filter events before they are sent:
RUM.enable(
with: RUM.Configuration(
applicationID: "<RUM_APPLICATION_ID>",
viewEventMapper: { viewEvent in
// Modify view event
var modifiedEvent = viewEvent
modifiedEvent.view.url = viewEvent.view.url?.replacingOccurrences(of: "sensitive", with: "redacted")
return modifiedEvent
},
actionEventMapper: { actionEvent in
// Filter specific actions
if actionEvent.action.target?.name?.contains("password") == true {
return nil // Discard this event
}
return actionEvent
},
errorEventMapper: { errorEvent in
// Modify error event
return errorEvent
},
resourceEventMapper: { resourceEvent in
// Modify resource event
return resourceEvent
}
)
)
View events cannot be discarded (returning nil has no effect).