Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/blendmedia/mexpanel
https://github.com/blendmedia/mexpanel
Last synced: 7 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/blendmedia/mexpanel
- Owner: blendmedia
- License: other
- Created: 2018-05-11T16:08:18.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2019-07-08T16:39:23.000Z (over 5 years ago)
- Last Synced: 2024-10-07T19:08:14.324Z (about 1 month ago)
- Language: Elixir
- Size: 34.2 KB
- Stars: 2
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
- freaking_awesome_elixir - Elixir - An Elixir client for the Mixpanel HTTP API. (Third Party APIs)
- fucking-awesome-elixir - mexpanel - An Elixir client for the Mixpanel HTTP API. (Third Party APIs)
- awesome-elixir - mexpanel - An Elixir client for the Mixpanel HTTP API. (Third Party APIs)
README
# Mexpanel
API wrapper for [Mixpanel](https://mixpanel.com)
## Installation
If [available in Hex](https://hex.pm/docs/publish), the package can be installed
by adding `mexpanel` to your list of dependencies in `mix.exs`:```elixir
def deps do
[
{:mexpanel, "~> 0.1.0"}
]
end
```## Usage
Mixpanel provides 2 endpoints: [track](https://mixpanel.com/help/reference/http#tracking-via-http) and [engage](https://mixpanel.com/help/reference/http#people-analytics-updates).
For both these endpoints, this library provides a struct with [builder functions](https://medium.com/kkempin/builder-design-pattern-in-elixir-c841e7cea307). The `new` function expects all mandatory parameters, additional properties can be set with functions
### Track
```elixir
alias Mexpanel.TrackRequest
track = TrackRequest.new("123", "user signed up", %{name: "Leif Gensert"})
|> TrackRequest.time(DateTime.utc_now())
|> TrackRequest.ip("144.10.58.141")
|> TrackRequest.distinct_id("user:1")Mexpanel.request(track)
```### Engage
For the engage endpoint you will need to specify an operation. See the [official documentation](https://mixpanel.com/help/reference/http#update-operations) for all available operations.
```elixir
alias Mexpanel.EngageRequest
engage = EngageRequest.new("123", "user:1")
|> EngageRequest.time(DateTime.utc_now())
|> EngageRequest.ip("144.10.58.141")
|> EngageRequest.set(%{name: "Leif Gensert"})Mexpanel.request(engage)
```