smart_grow_logs_plugin 1.0.3
smart_grow_logs_plugin: ^1.0.3 copied to clipboard
Flutter plugin for Smart Grow Logs SDK. Secure logging with end-to-end encryption. Supports Android and iOS.
Smart Grow Logs Plugin for Flutter #
A Flutter plugin for secure logging with end-to-end encryption.
Features #
- 🔒 End-to-end encrypted logging
- 📱 Native implementations for iOS and Android
- 🚀 Simple, intuitive API
- 📊 Multiple log levels (debug, info, warn, error, fatal)
- 🔄 Automatic device info detection
Prerequisites #
Before using this plugin, you need to:
- Sign up for a free account at logs.smart-grow.app
- Create a new project in the dashboard
- Get your API key from the project settings
The plugin requires an active Smart Grow Logs account to function. All logs are securely transmitted to your Smart Grow Logs dashboard.
Installation #
Add this to your package's pubspec.yaml file:
dependencies:
smart_grow_logs_plugin: ^1.0.0
Then run:
flutter pub get
Usage #
Initialize the SDK #
Call this once at app startup:
import 'package:smart_grow_logs_plugin/smart_grow_logs_plugin.dart';
void main() async {
WidgetsFlutterBinding.ensureInitialized();
await SmartGrowLogs.initialize(
apiKey: 'sgl_your_api_key',
baseUrl: 'https://logs-api.smart-grow.app/',
);
runApp(MyApp());
}
Send Logs #
Use the convenience methods:
final logs = SmartGrowLogs.instance;
// Debug log
await logs.logDebug('Application started');
// Info log with metadata
await logs.info(
'User logged in',
metadata: '{"userId": "123", "method": "google"}',
userIdentifier: 'user@example.com',
);
// Warning log
await logs.warn('Deprecated API usage detected');
// Error log with stack trace
try {
// some code that might throw
} catch (e, stackTrace) {
await logs.errorWithException(
'Failed to process data',
e,
stackTrace: stackTrace,
metadata: '{"operation": "data_processing"}',
);
}
// Fatal log
await logs.fatal(
'Critical system failure',
stackTrace: StackTrace.current.toString(),
);
Log Levels #
| Level | Use Case |
|---|---|
debug |
Development and debugging information |
info |
General information about app operation |
warn |
Potentially harmful situations |
error |
Error events that might still allow the app to run |
fatal |
Severe errors that cause premature termination |
Full LogOptions #
For more control, use sendLog directly:
final response = await SmartGrowLogs.instance.sendLog(LogOptions(
level: LogLevel.error,
message: 'Payment failed',
stackTrace: stackTrace.toString(),
metadata: '{"orderId": "ORD-123", "amount": 99.99}',
userIdentifier: 'user@example.com',
sessionId: 'session-abc-123',
));
if (response.success) {
print('Log sent successfully: ${response.logId}');
} else {
print('Failed to send log: ${response.error}');
}
API Reference #
SmartGrowLogs #
| Method | Description |
|---|---|
initialize(apiKey, baseUrl, [debug]) |
Initialize the SDK (required before use) |
instance |
Get the singleton instance |
isInitialized |
Check if SDK is initialized |
sendLog(LogOptions) |
Send a log with full options |
logDebug(message, ...) |
Send a DEBUG level log |
info(message, ...) |
Send an INFO level log |
warn(message, ...) |
Send a WARN level log |
error(message, ...) |
Send an ERROR level log |
errorWithException(message, exception, ...) |
Send an ERROR with exception details |
fatal(message, ...) |
Send a FATAL level log |
LogOptions #
| Property | Type | Required | Description |
|---|---|---|---|
level |
LogLevel |
Yes | Log level |
message |
String |
Yes | Log message |
stackTrace |
String? |
No | Stack trace for errors |
metadata |
String? |
No | Additional JSON metadata |
userIdentifier |
String? |
No | User identifier for tracking |
sessionId |
String? |
No | Session identifier |
LogResponse #
| Property | Type | Description |
|---|---|---|
success |
bool |
Whether the log was sent successfully |
logId |
String? |
Server-assigned log ID (on success) |
error |
String? |
Error message (on failure) |
Minimum Requirements #
- Flutter: 3.3.0+
- Dart: 3.0.0+
- iOS: 15.0+
- Android: API 26+ (Android 8.0)
License #
Proprietary - Smart Dev Agency