GithubHelp home page GithubHelp logo

kissmetrics-ruby's Introduction

KISSmetrics Ruby Library

This gem is a fluent ruby wrapper for the KISSmetrics API. It strives to adhere to the UNIX philosophy Rule of Least Surprise by following ActiveRecord syntax, so that you can spend less time reading docs and more time getting on with your life.

Installation

Add this line to your application's Gemfile:

gem 'kissmetrics-ruby'

And then execute:

$ bundle

Or install it yourself as:

$ gem install kissmetrics-ruby

Configuration

If you're using Rails, you'll create an initializer to set your API key:

# /config/initializers/kissmetrics.rb

KISSmetrics.configure do |km|
  km.api_key = ENV['MY_KISSMETRICS_API_KEY']
end

Usage

The following table organizes all endpoints and methods that this gem supports. For more details on the KISSmetrics API, see their official documentation.

As in ActiveRecord, methods are chainable and order-independent, i.e. the following calls are equivalent:

  • KISSmetrics::Account.last(10).offset(5)
  • KISSmetrics::Account.offset(5).last(10)

All results need to be 'kicked' to make an actual API call. You can kick any API call by inspecting the response (automatically done in a REPL), calling #to_hash on the response, or using any of the slice methods like response['meta'].

Supported Methods

Accounts

Description Implementation
Fetch all accounts KISSmetrics::Account.all
Fetch single account KISSmetrics::Account.find('8d637290-a04f-0132-83a0-22000ab4dcd7')
Fetch account products KISSmetrics::Account.find('8d637290-a04f-0132-83a0-22000ab4dcd7').products

Events

Description Implementation
Fetch all events KISSmetrics::Event.all
Fetch single event KISSmetrics::Event.find('9941ed8e-7733-4e59-8c06-1e98a35c8b85')

Metrics

Description Implementation
Fetch all metrics KISSmetrics::Metric.all
Fetch single metric KISSmetrics::Metric.find('6b95437d-46e1-438e-8976-a4c5b0132399')

Products

Description Implementation
Fetch all products KISSmetrics::Product.all
Fetch single product KISSmetrics::Product.find('24e087bd-d318-4304-8ec8-ecdaec8817a1')
Fetch product events KISSmetrics::Product.find('24e087bd-d318-4304-8ec8-ecdaec8817a1').events
Fetch product metrics KISSmetrics::Product.find('24e087bd-d318-4304-8ec8-ecdaec8817a1').metrics
Fetch product properties KISSmetrics::Product.find('24e087bd-d318-4304-8ec8-ecdaec8817a1').properties
Fetch product reports KISSmetrics::Product.find('24e087bd-d318-4304-8ec8-ecdaec8817a1').reports

Properties

Description Implementation
Fetch all properties KISSmetrics::Property.all
Fetch single property KISSmetrics::Property.find('24e087bd-d318-4304-8ec8-ecdaec8817a1')

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

kissmetrics-ruby's People

Contributors

nathanielwroblewski avatar

Watchers

James Cloos avatar  avatar

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.