addObsly method
Adds Obsly HTTP monitoring to this Dio instance
Implementation
void addObsly({bool silent = false}) {
try {
// Validate this is a Dio-like object
if (!_isDioLike(this)) {
if (!silent) {
ObslyLogger.error('addObsly() can only be called on Dio instances');
}
return;
}
// Check if already added to avoid duplicates
if (_hasObslyInterceptor(this)) {
if (!silent) {
ObslyLogger.warn(
'Obsly interceptor already exists in this Dio instance');
}
return;
}
// Get the DioIntegration instance
final integration = DioIntegration.instance;
if (!integration.isActive) {
if (!silent) {
ObslyLogger.warn(
'DioIntegration not initialized. Ensure ObslySDK.init() was called first.');
}
return;
}
// Add the interceptor
integration.addInterceptorTo(this);
if (!silent) {
ObslyLogger.debug(
'Obsly monitoring added to Dio instance successfully');
}
} catch (e) {
// Defensive: Never crash the app due to monitoring setup
if (!silent) {
ObslyLogger.error('Failed to add Obsly monitoring to Dio: $e');
}
}
}