Git Product home page Git Product logo

mxpanel's Introduction

Mxpanel

Client for Mixpanel Ingestion API.

Hex.pm Version CI Coverage 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, "~> 1.0.1"},
    {:jason, "~> 1.2"},
    {:hackney, "~> 1.17"}
  ]
end

Examples

# Create a client struct with your project token
client = %Mxpanel.Client{token: "<mixpanel project token>"}

# track an event
"signup"
|> Mxpanel.track("billybob")
|> Mxpanel.deliver(client)

# track an event with optional properties
"signup"
|> Mxpanel.track("billybob", %{"Favourite Color" => "Red"})
|> Mxpanel.deliver(client)

# set an IP address to get automatic geolocation info
"signup"
|> Mxpanel.track("billybob", %{}, ip: "72.229.28.185")
|> Mxpanel.deliver(client)

# track an event with a specific timestamp
"signup"
|> Mxpanel.track("billybob", %{}, time: System.os_time(:second) - 60)
|> Mxpanel.deliver(client)

# track an event in background, the event will be buffered, and later sent in batches
Mxpanel.Batcher.start_link(name: MyApp.Batcher, token: "<mixpanel project token>")

"signup"
|> Mxpanel.track("billybob")
|> Mxpanel.deliver_later(MyApp.MxpanelBatcher)

Checkout the documentation for complete usage and available functions.

Telemetry

Mxpanel currently exposes following Telemetry events:

  • [:mxpanel, :batcher, :buffers_info] - Dispatched periodically by each running batcher exposing the size of each running buffer per endpoint in the pool.

    • Measurement: %{}
    • Metadata: %{batcher_name: atom(), buffer_sizes: %{atom() => [integer()]}}

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.