You're lucky! There is already a package available for JavaScript that you can easily download via npm.
npm install --save loghive
import { LogHive } from 'loghive';
const logging = new LogHive({
key: 'your-personal-api-key',
project: 'yourprojectname'
});
logging.addEvent({
group: "yourgroupname",
event: "your-event-name",
description: "descripton",
notify: true
});
logging.addInsight({
insight: "your-insight-name",
value: 100
});
Set Online / Offline State
logging.setSystemOnline({
system: "your-system-name"
});
logging.setSystemOffline({
system: "your-system-name"
});
import fetch from "node-fetch";
var options = {
method: "POST",
headers: {
"ApiKey": "your-personal-api-key",
"Content-Type": "application/json"
},
body: JSON.stringify({
"project": "MySaas",
"group": "yourgroupname",
"event": "your-event-name",
"description": "descripton",
"notify": true
})
};
fetch("https://api.loghive.app/v1/event/add", options).then(response => response.text());
import fetch from "node-fetch";
var options = {
method: "POST",
headers: {
"ApiKey": "your-personal-api-key",
"Content-Type": "application/json"
},
body: JSON.stringify({
"project": "MySaas",
"insight": "insightname",
"value": 100
})
};
fetch("https://api.loghive.app/v1/insight/add", options).then(response => response.text());
Set Online / Offline State
import fetch from "node-fetch";
// set online
var options = {
method: "POST",
headers: {
"ApiKey": "your-personal-api-key",
"Content-Type": "application/json"
},
body: JSON.stringify({
"project": "MySaas",
"insight": "system1",
"value": 1
})
};
fetch("https://api.loghive.app/v1/insight/add", options).then(response => response.text());
// set offline
var options = {
method: "POST",
headers: {
"ApiKey": "your-personal-api-key",
"Content-Type": "application/json"
},
body: JSON.stringify({
"project": "MySaas",
"insight": "system1",
"value": 0
})
};
fetch("https://api.loghive.app/v1/insight/add", options).then(response => response.text());