Skip to content

Commit

Permalink
move the code under tracker module to avoid crashes
Browse files Browse the repository at this point in the history
  • Loading branch information
zevarito committed Jun 20, 2011
1 parent ee3e40a commit 9631c51
Show file tree
Hide file tree
Showing 14 changed files with 397 additions and 364 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
June 2011
---------

* Refactor Gem to live in Mixpanel::Tracker and avoid conflicts with other gems.

January 2011
------------

Expand Down
16 changes: 11 additions & 5 deletions README.rdoc
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Mixpanel is a real-time analytics service that helps companies understand how users interact with web applications.
http://mixpanel.com

== What does this Gem do?
== What does this Gem does?

* Track events with properties directly from your backend.
* Track events with properties through javascript using a rack middleware.
Expand All @@ -20,20 +20,20 @@ In your environment config file add this.

Rails::Initializer.run do |config|

config.middleware.use "MixpanelMiddleware", "YOUR_MIXPANEL_API_TOKEN"
config.middleware.use "Mixpanel::Tracker::Middleware", "YOUR_MIXPANEL_API_TOKEN"

If you want to use the asynchronous version of Mixpanel's javascript API

Rails::Initializer.run do |config|

config.middleware.use "MixpanelMiddleware", "YOUR_MIXPANEL_API_TOKEN", :async => true
config.middleware.use "Mixpanel::Tracker::Middleware", "YOUR_MIXPANEL_API_TOKEN", :async => true

In your application_controller class add a method to instance mixpanel.

before_filter :initialize_mixpanel

def initialize_mixpanel
@mixpanel = Mixpanel.new("YOUR_MIXPANEL_API_TOKEN", request.env, true)
@mixpanel = Mixpanel::Tracker.new("YOUR_MIXPANEL_API_TOKEN", request.env, true)
end

Then in each request you want to track some event you can use:
Expand All @@ -54,10 +54,16 @@ To execute any javascript API call

== Notes

There are two forms of async operation:
There are two forms of async operation:
* Using MixpanelMiddleware, events are queued via Mixpanel#append_event and inserted into a JavaScript block within the HTML response.
* Using Mixpanel.new(…, …, true), events are sent to a subprocess via a pipe and the sub process which asynchronously send events to Mixpanel. This process uses a single thread to upload events, and may start dropping events if your application generates them at a very high rate.

== Deprecation Notes

For a short term this method will be accepted but it will be deprecated soon.

Mixpanel.new

== Collaborators and Maintainers

* {Alvaro Gil}[https://github.com/zevarito] (Author)
Expand Down
10 changes: 8 additions & 2 deletions lib/mixpanel.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1,8 @@
require 'mixpanel/mixpanel'
require 'mixpanel/mixpanel_middleware'
require 'mixpanel/tracker'

module Mixpanel
def self.new(token, env, async = false)
Kernel.warn("DEPRECATED: Use Mixpanel::Tracker.new instead")
Mixpanel::Tracker.new(token, env, async)
end
end
95 changes: 0 additions & 95 deletions lib/mixpanel/mixpanel.rb

This file was deleted.

119 changes: 0 additions & 119 deletions lib/mixpanel/mixpanel_middleware.rb

This file was deleted.

30 changes: 0 additions & 30 deletions lib/mixpanel/mixpanel_subprocess.rb

This file was deleted.

Loading

0 comments on commit 9631c51

Please sign in to comment.