Mxpanel

Client for Mixpanel Ingestion API.

Hex.pm VersionCICoverage Status

It provides a sync API that makes HTTP request to the Mixpanel API. And also a async API that buffers and delivers the buffered events to Mixpanel in background.

Checkout the documentation for more information.

Installation

The package can be installed by adding mxpanel to your list of dependencies in mix.exs:

def deps do
[
{:mxpanel, "~> 0.1.0"},
{:jason, "~> 1.2"},
{:finch, "~> 0.5"}
]
end

Usage

Track event

  1. Add to your supervision tree:
{Finch, name: Mxpanel.HTTPClient}
  1. Call track/2:
client = %Mxpanel.Client{token: "mixpanel project token"}
event = Mxpanel.Event.new("signup", "123")
Mxpanel.track(client, event)

Enqueue an event

  1. Add to your supervision tree:
{Finch, name: Mxpanel.HTTPClient},
{Mxpanel.Batcher, name: MyApp.Batcher, token: "mixpanel project token"}
  1. Call track_later/2:
event = Mxpanel.Event.new("signup", "123")
Mxpanel.track_later(MyApp.MxpanelBatcher, event)
  1. The event will be buffered, and later sent in batch to the Mixpanel API.

Telemetry

Mxpanel currently exposes following Telemetry events:

Changelog

See the changelog.

Contributing

See the contributing file.

License

Copyright 2021 (c) Thiago Santos.

Mxpanel source code is released under Apache 2 License.

Check LICENSE file for more information.