Links

JavaScript

Please make sure to change your API token to `Public Access`in the LogSnag API settings when using the script on a public website.

Usage

Import Library

<script src="https://cdn.logsnag.com/js/0.1.6/ls.js"></script>

Initialize Client

const logsnag = new window.LogSnag({
token: '7f568d735724351757637b1dbf108e5',
project: 'my-saas'
});

Publish Event

logsnag.publish({
channel: "waitlist",
event: "User Joined",
description: "Email: [email protected]",
icon: "🎉",
tags: {
name: "john doe",
},
notify: true
})
.then(result => console.log(result))
.catch(error => console.log(error));

Publish Insight

logsnag.insight({
title: "User Count",
value: "100",
icon: "👨"
})
.then(result => console.log(result))
.catch(error => console.log(error));