View Source LogSnag (LogSnag v1.0.0)

LogSnag is a simple client for the LogSnag API.

This is an unofficial library, and isn't supported by LogSnag. It will try to follow the functionality of the official Node.js client for the most part, with some slight differences in naming conventions.

Full documentation of the API and fields that are used can be found on the official LogSnag docs page.

Link to this section Summary

Types

A string containing a single emoji character.

Functions

Publish an event to LogSnag.

Publish an insight to LogSnag.

Link to this section Types

@type emoji() :: String.t()

A string containing a single emoji character.

Link to this section Functions

@spec publish_event(params) :: {:ok, LogSnag.Event.t()} | {:error, LogSnag.Error.t()}
when params: %{
       channel: String.t(),
       event: String.t(),
       description: String.t() | nil,
       icon: emoji() | nil,
       notify: boolean() | nil,
       tags: map() | nil
     }

Publish an event to LogSnag.

An event can be anything you want to track within your application, service, or system. It will be published under your project and organized within your specified channels.

For further documentation see LogSnag's official docs: https://docs.logsnag.com/endpoints/log

examples

Examples

iex> publish_event(%{
...>   channel: "waitlist",
...>   event: "User Joined",
...>   description: "Email: john@example.com",
...>   icon: "🎉",
...>   tags: %{
...>     name: "john doe",
...>     email: "john@example.com",
...>   },
...>   notify: true
...> })
{:ok,
  %Event{
    channel: "waitlist",
    event: "User Joined",
    description: "Email: john@example.com",
    icon: "🎉",
    notify: true,
    tags: %{
      name: "john doe",
      email: "john@example.com"
    }
  }}
@spec publish_insight(params) ::
  {:ok, LogSnag.Insight.t()} | {:error, LogSnag.Error.t()}
when params: %{
       title: String.t(),
       value: String.t() | integer(),
       icon: emoji() | nil
     }

Publish an insight to LogSnag.

Insights are real-time widgets that you can add to each of your projects. They are use-case agnostic and can be used to display any information that you want in real-time.

For further documentation see LogSnag's official docs: https://docs.logsnag.com/endpoints/insight

examples

Examples

iex> publish_insight(%{
...>   title: "User Count",
...>   value: 100,
...>   icon: "👨"
...> })
{:ok,
  %Insight{
    title: "User Count",
    value: 100,
    icon: "👨"
  }}