LogSnag

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.

Installation

Install the package by adding log_snag to your list of dependencies in mix.exs:

def deps do
  [
    {:log_snag, "~> 1.0"}
  ]
end

Configuration

The following application configuration must be in place or else errors will be thrown at runtime:

config :log_snag,
  api_key: YOUR_API_KEY,
  project: YOUR_PROJECT_NAME

Make sure to replace YOUR_API_KEY with a key from your LogSnag dashboard and YOUR_PROJECT_NAME with the name of the project to which you wish to publish events and insights.

Usage

With the package installed and configured, you can use it in your application like this:

# Publish an event
event_params = %{
  channel: "waitlist",
  event: "User Joined",
  description: "Email: john@example.com",
  icon: "🎉",
  tags: %{
    name: "john doe",
    email: "john@example.com",
  },
  notify: true
}

LogSnag.publish_event(event_params)

# Publish a new insight or update an existing one
insight_params = %{
  title: "User Count",
  value: 100,
  icon: "👨"
}

LogSnag.publish_insight(insight_params)

Contributing

Feedback, feature requests, and fixes are welcomed and encouraged. Please make appropriate use of Issues and Pull Requests.