Code Monkey home page Code Monkey logo

rubango's Introduction

UNMAINTAINED PROJECT WARNING

This project is currently unmaintained

Anyone who wishes to take it over, please let me know.

rubango

A ruby API wrapper for integrating your rails application with Totango.

Installation

gem install rubango # use 'totango' when require-ing

Usage

First, build your client with your API id:

Totango.srv_id "YOUR_ID_GOES_HERE"

By default, Totango will not make remote calls. It will print a debug message about the URL that would be getting hit. This message can be annoying when testing. To turn the message off, use Totango::Config:

Totango::Config[:suppress_output] = true

To make the remote call to totango.com you must turn the tracker on:

Totango.on! # you will probably only want to do this in production mode.

You now interact with Totango.client to do your bidding:

Totango.client.track({
  :organization => "Current organization",
  :user => "Current user",
  :activity => "Current activity",
  :module => "Current module"
})

You can optionally pass a 'Foreign ID' to Activity Events to indicate the Organization’s identifier on foreign systems:

Totango.client.track({
  :organization => "Current organization",
  :user => "Current user",
  :activity => "Current activity",
  :module => "Current module",
  :ofid => "1234"
})

By default, Totango will create a new thread to make the remote calls. If you already track the events using a background job, you should use synchronous calls. To turn synchronous calls on, use Totango::Config:

Totango::Config[:synchronous] = true

There is also the option for integration with different ruby frameworks.

Rails

class ApplicationController < ActionController::Base
  include Totango::Adapters::Rails

  #...
end

That will build your tracking code based around a couple of sane defaults. By default it will set the current module to params[:controller] and activity to params[:action]. If you wish to override the defaults you can do so in your controllers:

class MyController < ApplictationController
  sp_default :activity, "Whatever you want here"
  # You may also send a Proc object as the value so that it is
  # evaluated in the context of the current controller. For example:
  sp_default :user, proc { method_to_determine_current_user }
end

To track different actions, you must now tell Totango which actions you would like to track:

class MyController < ApplictationController
  track :index
  track :show, "Override default activity text here"
  track :edit, :user => "override other defaults in a hash"
  track :destroy, :if => proc { params[:my_boolean] } # Use conditionals to only run tracking based on the eval'd code in the Proc object
end

Rolling your own adapter

There are currently adapters for rails and merb, but it is simple to write your own adapter

module MySPAdapter
  extend Totango::Adapters::Base

  register_adapter :my_adapter
  hook_method :before_hook      # Hook method name that will be called before or after each action
  action_finder :action_name    # Method that determines the current action being hit

  # You can set defaults from here that will be set on the controller class
  # that includes your adapter and all of its subclasses
  sp_default :activity, proc {action_name}
  sp_default :module, proc {controller_name}
end

TODO

  • Adapter tests
  • JS client integration

rubango's People

Contributors

anibalcucco avatar jonuts avatar nightfox avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

rubango's Issues

Name change to Totango

Hi Jonah,

As you might've heard, we recently changed our name to Totango (we're big on dancing metaphors :-).

it makes sense to change the library to reflect that. specifically, point to sdr.totango.com and possibly changing the appropriate object names in the code.

what do you think?

How to send extra data?

Hi,

Is it possible to send extra data like an email address to Totango?

Thank you in advance.

Bad file permissions in 0.1.6 gem in rubygems

Hey,

Apparently https://rubygems.org/gems/rubango/versions/0.1.6 got pushed with '700' file permissions, we think it was probably built with a weird umask:

$ tar tvf data.tar.gz
-rw-------  0 wheel  wheel    1059 Jul 30  2014 LICENSE
-rw-------  0 wheel  wheel    3615 Jul 30  2014 README.md
-rw-------  0 wheel  wheel     379 Jul 30  2014 lib/totango.rb
-rw-------  0 wheel  wheel     135 Jul 30  2014 lib/totango/adapter.rb
-rw-------  0 wheel  wheel     807 Jul 30  2014 lib/totango/adapters/base.rb
-rw-------  0 wheel  wheel     296 Jul 30  2014 lib/totango/adapters/merb.rb
-rw-------  0 wheel  wheel     305 Jul 30  2014 lib/totango/adapters/rails.rb
-rw-------  0 wheel  wheel    1646 Jul 30  2014 lib/totango/arg_parser.rb
-rw-------  0 wheel  wheel    1259 Jul 30  2014 lib/totango/client.rb
-rw-------  0 wheel  wheel     404 Jul 30  2014 lib/totango/config.rb
-rw-------  0 wheel  wheel    2070 Jul 30  2014 lib/totango/resource.rb
-rw-------  0 wheel  wheel     443 Jul 30  2014 lib/totango/tracker.rb
-rw-------  0 wheel  wheel      75 Jul 30  2014 lib/totango/version.rb

We're still using this gem in our company and as part of a general update, we updated to 0.1.6 and is causing read permissions in our servers (``require': cannot load such file -- totango (LoadError)`). For now we went back to the previous version but would be good to solve the problem.

I have owner permissions for this gem in rubygems. Can i bump to 0.1.7, rebuild with the correct file permissions (755) and push the new gem to rubygems?

Thanks,
Anibal

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.