recordUsage method
Record general usage statistics
Implementation
Future<void> recordUsage({
required String command,
required int dependencyCount,
required int issuesFound,
required bool applied,
}) async {
if (!enabled) return;
try {
final payload = {
'event': 'general_usage',
'timestamp': DateTime.now().toIso8601String(),
'data': {
'command': command,
'dependency_count': dependencyCount,
'issues_found': issuesFound,
'applied': applied,
'platform': Platform.operatingSystem,
},
'version': '1.0.1',
};
await http
.post(
Uri.parse('$apiEndpoint/events'),
headers: {
'Content-Type': 'application/json',
'User-Agent':
'SmartPub/1.0 (+https://github.com/VatsalJaganwala/smartpub)',
},
body: jsonEncode(payload),
)
.timeout(const Duration(seconds: 5));
} catch (e) {
// Silently fail - telemetry should never interfere with functionality
}
}