Low commit activity in last 3 years
No release in over a year
Simple ruby client interface to the Mixpanel Data API.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 2.4
~> 0.14
~> 3.10
~> 6.5
~> 13.0
~> 3.12
~> 1.41
~> 3.18
 Project Readme

Mixpanel Data API Client

Gem Version Code Climate

Ruby access to the Mixpanel web analytics tool.

Mixpanel Data API Reference

Installation

gem install mixpanel_client

or if you use a Gemfile

gem 'mixpanel_client'

Usage

require 'rubygems'
require 'mixpanel_client'

client = Mixpanel::Client.new(
  api_secret: 'changeme'
  timeout: 240, # Default is 60 seconds, increase to reduce timeout errors.

  # Optional URI overrides (e.g. https://developer.mixpanel.com/reference/overview)
  base_uri: 'api-eu.mixpanel.com',
  data_uri: 'example-data.com',
  import_uri: 'example-import.com'
)

data = client.request(
  'events/properties',
  event:     'Product Clicked',
  name:      'product-clicked',
  values:    '["value1", "value2"]',
  type:      'unique',
  unit:      'day',
  limit:      5,
  from_date: '2013-12-1', #<- Date range
  to_date:   '2014-3-1'   #<-
)

The API also supports passing a time interval rather than an explicit date range.

data = client.request(
  'events/properties',
  event:    'Product Clicked',
  name:     'product-clicked',
  values:   '["value1", "value2"]',
  type:     'unique',
  unit:     'day',
  limit:     5,
  interval: 7 #<- Interval
)

Use the Import API to specify a time in the past. You'll need to include your API token in the data (docs).

To import, encode the data as JSON and use Base64. Encode the data like this:

data_to_import = {
    'event' => 'firstLogin', 
    'properties' => {
        'distinct_id' => guid, 
        'time' => time_as_integer_seconds_since_epoch, 
        'token' => api_token
    }
}
encoded_data = Base64.encode64(data_to_import.to_json)

Then make a request to the API with the given API key, passing in the encoded data:

data = client.request('import', {:data => encoded_data, :api_key => api_key})

You can only import one event at a time.

Parallel

The option to make parallel requests has been removed (in v5) so that there are no runtime dependencies.

Development

List of rake tasks.

rake -T

Run specs.

rake spec

Run external specs.

cp config/mixpanel.template.yml config/mixpanel.yml
vi config/mixpanel.yml
rake spec:externals

Run rubocop and fix offences.

rubocop

Changelog

Changelog

Collaborators and Maintainers

Contributors

Copyright

Copyright (c) 2009+ Keolo Keagy. See license for details.