LogHive
Search
K
Comment on page

Dart

LogHive provides a simple REST API that you can use to push events and errors. Here is an example code for Dart:

Push Event

import 'dart:convert';
import 'package:http/http.dart' as http;
Future<void> sendRequest() async {
final url = Uri.parse('https://api.loghive.app/v1/event/add');
final headers = <String, String>{
'Content-Type': 'application/json',
'Authorization': 'ApiKey: your-api-key'
};
final data = {
'project': 'yourprojectname',
'group': 'yourgroupname',
'event': 'your-event-name',
'description': 'your-description',
'notify': false};
final response = await http.post(url, headers: headers, body: json.encode(data));
// Handle response
}

Push Insight

import 'dart:convert';
import 'package:http/http.dart' as http;
Future<void> sendRequest() async {
final url = Uri.parse('https://api.loghive.app/v1/insight/add');
final headers = <String, String>{
'Content-Type': 'application/json',
'Authorization': 'ApiKey: your-api-key'
};
final data = {
'project': 'MySaas',
'insight': 'system1-online',
'value': 1};
final response = await http.post(url, headers: headers, body: json.encode(data));
// Handle response
}
Last modified 8mo ago