Alerts
Learn how to react on events.
LiveSession event stream was designed to be a powerful tool helpful for example in monitoring and alerting purposes. It allows you to react on events in real-time and take actions based on them.
Quickstart
Alerts delivery can be configured in two ways. First, you can use third party delivery provider like Slack
.
Second, you can set up a custom workflow using webhooks. All methods receive events in real-time.
1 import livesession from "livesession"2 3 const ls = new livesession(4 livesession.optionApiKey(process.env.LIVESESSION_PAT)5 )6 7 await ls.webhooks.create({8 website_id: "YOUR_WEBSITE_ID",9 url: "YOUR_WEBHOOK_URL",10 version: "v1.0",11 })
Once you have a webhook set up, you can create an alert to receive events in real-time.
The main duty of alerts is to filter events and send them to the configured delivery provider. You can for example create a custom event and based on that event send a message to your server.
Creating an alert
Alerts gives you a robust control which events you want to receive.
You can use built-in events like Error Click
, Network Error
or based on custom event which gives you a full control of
what and when you want to monitor.
1 import livesession from "livesession"2 3 const ls = new livesession(4 livesession.optionApiKey(process.env.LIVESESSION_PAT)5 )6 7 await ls.alerts.create({8 name: "YOUR_ALERT_NAME",9 provider: "webhooks",10 webhook_id: "YOUR_WEBHOOK_ID",11 events: [12 {13 kind: 26,14 value: "YOUR_CUSTOM_EVENT_NAME"15 }16 ]17 })
Based on above example, please make sure you used custom event tracking like
ls.track("YOUR_CUSTOM_EVENT_NAME")