Links

Quick Start

Track your first event with LogSnag

Create a project.

LogSnag uses projects to give you a workspace for each of your applications. You may create as many projects as you want and organize them however you want.
To get started, create a project by clicking on the "+" button in the sidebar and entering a name for your project. For example, you could name your project "my-saas."

Create a channel.

Channels are like buckets for your events. They are used to organize your events into different categories. For example, you could create a channel for payment events, another for authentication events, etc.
To create a channel, click on the "+" button in the sidebar and enter a name for your channel. For example, you could name your channel "payments."
The project and channel values should be lowercase! Alphabet characters, digits, and dashes "-" are accepted. Validation Regex: ^[a-z0-9]+(?:-[a-z0-9]+)*$

Create an API token.

API tokens are used to authenticate your requests to LogSnag. You can create as many API keys as you want, and each API key can be configured with different permissions.
To create an API token, head to the API page under Settings, then create and copy a new API token.
If you're using LogSnag within a public-facing website or client application. Please ensure to set your Token's access level to "Public" and limit its roles to a specific project and channel.

Track your first event.

With our example project, channel, and API token, we can now track an event by making a POST request to the LogSnag API like the following.
cURL
Python
JavaScript
NodeJS
Deno
curl --location --request POST 'https://api.logsnag.com/v1/log' \
--header 'Authorization: Bearer <TOKEN>' \
--header 'Content-Type: application/json' \
--data-raw '{
"project": "my-saas",
"channel": "payments",
"event": "New Subscription",
"user_id": "user-123",
"icon": "💰",
"notify": true,
"tags": {
"plan": "premium",
"cycle": "monthly",
"trial": false
}
}'
pip3 install logsnag
from logsnag import LogSnag
logsnag = LogSnag(token='<TOKEN>', project='my-saas')
logsnag.track(
channel="payments",
event="New Subscription",
user_id="user-123",
icon="💰",
notify=True,
tags={
"plan": "premium",
"cycle": "monthly",
"trial": False
}
)
<script src="https://cdn.logsnag.com/js/1.0.0/ls.js"></script>
const logsnag = new window.LogSnag({
token: '<TOKEN>',
project: 'my-saas',
})
await logsnag.track({
channel: "payments",
event: "New Subscription",
user_id: "user-123",
icon: "💰",
notify: true,
tags: {
plan: "premium",
cycle: "monthly",
trial: false
}
})
npm install logsnag
import { LogSnag } from 'logsnag';
const logsnag = new LogSnag({
token: '<TOKEN>',
project: 'my-saas',
})
await logsnag.track({
channel: "payments",
event: "New Subscription",
user_id: "user-123",
icon: "💰",
notify: true,
tags: {
plan: "premium",
cycle: "monthly",
trial: false
}
})
import { LogSnag } from 'https://cdn.logsnag.com/deno/1.0.0/index.ts';
const logsnag = new LogSnag({
token: '<TOKEN>',
project: 'my-saas',
})
await logsnag.track({
channel: "payments",
event: "New Subscription",
user_id: "user-123",
icon: "💰",
notify: true,
tags: {
plan: "premium",
cycle: "monthly",
trial: false
}
})
Once you've made the request, you should get a push notification on your device and see the event appear in the LogSnag dashboard under the "payments" channel in the "my-saas" project, all in real-time!
To learn more about logs, check out the /log endpoint section and our other endpoints listed under the API references page.