Table of Contents
In the world of pay-as-you-go services, it’s important to monitor usage and set limits for users. As a NodeJs service provider, you’ll need to track usage and notify your team when a user hits their limit. LogHive’s event tracking tool works seamlessly with NodeJs applications and offers an easy way to monitor usage. For example, if you want to limit file uploads to ten per user, LogHive can send events to your dashboard and notify you when a user hits their limit.
How it works in NodeJS
LogHive provides a simple REST API that you can use to push events and errors to the LogHive service. You can organize your events into projects and groups to keep them organized and easily searchable. Once an event is pushed to LogHive, it is processed and can be viewed in the event stream or dashboard.
With just a few lines of NodeJS-code, you can start pushing events to LogHive and receiving push notifications for your application’s events and errors.
const https = require('https');
const options = {
hostname: 'api.loghive.app',
path: '/v1/event/add',
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': 'ApiKey your-personal-api-key'
}
};
const data = JSON.stringify({
'project': 'MySaas',
'group': 'Users',
'event': 'Limit exceeded',
'description': 'descripton',
'notify': true
});
const req = https.request(options, (res) => {
console.log(`Status Code: ${res.statusCode}`);
res.on('data', (d) => {
process.stdout.write(d);
});
});
req.on('error', (error) => {
console.error(error);
});
req.write(data);
req.end();
If an error occurs while creating an event, you will receive an Error object in return.
{'StatusCode': 400, 'Message': 'missing group name'}
You can receive your API-Key here: API-Key.
Receive Push Notifications
To receive push notifications, you simply need to install the LogHive Android app (Playstore) or use LogHive through the web application and allow notifications.
Add an element to your project dashboard
In addition to push notifications, LogHive allows you to display captured events in a dashboard with various elements. With just a few clicks, you can display the events already pushed in the dashboard.
LogHive’s event tracking tool provides a solution for NodeJs service providers who need to monitor usage and set limits for their users. With LogHive, you can easily track important events in real-time, send them to your dashboard, and receive push notifications when something significant happens.