mountain-goat 0.1.2 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README.md CHANGED
@@ -148,6 +148,20 @@ You may want to test certain items with a lower serve rate (bold new slogans).
148
148
 
149
149
  my priority / sum(all priorities for this metric)
150
150
 
151
+ ### Meta Options
152
+
153
+ There is certain meta data that you may wish to collect for a number of different conversions. For example, you may want to track ip-address so you can later pivot this column to find new / returning users. To do this, add an initializer that calls MountainGoat.add_meta_option().
154
+
155
+ MountainGoat.add_meta_option(:stats) do |c|
156
+ { :ip => c.request.remote_ip }
157
+ end
158
+
159
+ Then, simply add ':stats => true' to your record_conversion call. This will call into your block and replace the key-pair with the map returned from the block. E.g.
160
+
161
+ record_conversion(:user_login, :login => @user.login, :stats => true)
162
+
163
+ Then, when we track the conversion, you'll get meta-data for the user's ip-address. You can add any number of "meta-options" that you would like.
164
+
151
165
  ## Technical
152
166
 
153
167
  As mountain goat is a suite that is added into your project dynamically, the following routes and tables are added during setup:
@@ -21,9 +21,9 @@ class MountainGoatRalliesController < MountainGoatController
21
21
  convert = Convert.find(params[:convert_id].to_i) unless params[:convert_id].blank?
22
22
 
23
23
  if convert
24
- @rallies = convert.rallies.find(:all, :conditions => [ 'id > ?', recent_rally ], :order => "created_at DESC" )
24
+ @rallies = convert.rallies.find(:all, :conditions => [ 'id > ?', recent_rally ], :order => "id DESC" )
25
25
  else
26
- @rallies = Rally.find(:all, :conditions => [ 'id > ?', recent_rally ], :order => "created_at DESC" )
26
+ @rallies = Rally.find(:all, :conditions => [ 'id > ?', recent_rally ], :order => "id DESC" )
27
27
  end
28
28
 
29
29
  if @rallies.count > 0
@@ -43,7 +43,7 @@ module MetricTracking
43
43
  def mv_detailed(metric_type, convert_type, default, opts = {}, opt = nil)
44
44
  return get_metric_variant(metric_type, convert_type, default, opts, opt)
45
45
  end
46
-
46
+
47
47
  #shorthand
48
48
  def rc(convert_type, options = {})
49
49
  self.record_conversion(convert_type, options)
@@ -52,27 +52,14 @@ module MetricTracking
52
52
  def record_conversion(convert_type, options = {})
53
53
 
54
54
  metrics = {} #for user-defined metrics
55
+ options = options.with_indifferent_access
55
56
 
56
- #We want some system for easy default parameter setting
57
- if options.include?(:refs) && options[:refs]
58
- options = options.merge( :ref_domain => session[:ref_domain], :ref_flyer => session[:ref_flyer], :ref_user => session[:ref_user] )
59
- options.delete(:refs)
60
- end
61
-
62
- if options.include?(:user) && options[:user]
63
- options = options.merge( :user_id => current_user.id ) if signed_in?
64
- options.delete(:user)
65
- end
66
-
67
- if options.include?(:invitees) && options[:invitees]
68
- invitee_meta = {}
69
- if session[:invitee_id]
70
- invitee = Invitee.find_by_id(session[:invitee_id])
71
- if invitee.mailer.clique == @clique
72
- options.merge!( { :mailer_id => invitee.mailer.id } )
73
- end
57
+ MountainGoat.get_meta_options.each do |k, v|
58
+ if options.include?(k) && options[k]
59
+ options.delete(k)
60
+ res = v.call(self)
61
+ options.merge!( res ) if !res.nil? && res.instance_of?(Hash)
74
62
  end
75
- options.delete(:invitees)
76
63
  end
77
64
 
78
65
  options.each do |k, v|
@@ -1,3 +1,3 @@
1
1
  class MountainGoat
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
data/lib/mountain-goat.rb CHANGED
@@ -22,6 +22,13 @@ require File.join([File.dirname(__FILE__), 'mountain-goat/models/rally'])
22
22
  #$VERBOSE = nil
23
23
  #Dir["#{Gem.searcher.find('mountain-goat').full_gem_path}/lib/tasks/*.rake"].each { |ext| load ext }
24
24
 
25
- module MountainGoat
25
+ class MountainGoat
26
+ def self.add_meta_option(option, &block)
27
+ @@meta_options ||= {}
28
+ @@meta_options.merge!({ option => block })
29
+ end
26
30
 
31
+ def self.get_meta_options
32
+ @@meta_options
33
+ end
27
34
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mountain-goat
3
3
  version: !ruby/object:Gem::Version
4
- hash: 31
4
+ hash: 29
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 2
10
- version: 0.1.2
9
+ - 3
10
+ version: 0.1.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Geoffrey Hayes
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2011-07-22 00:00:00 -05:00
19
+ date: 2011-07-25 00:00:00 -05:00
20
20
  default_executable:
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency
@@ -119,7 +119,7 @@ files:
119
119
  - lib/mountain-goat/views/mountain_goat/mountain_goat_metrics/index.html.erb
120
120
  - lib/mountain-goat/views/mountain_goat/mountain_goat_metrics/new.html.erb
121
121
  - lib/mountain-goat/views/mountain_goat/mountain_goat_metrics/show.html.erb
122
- - lib/mountain-goat/views/mountain_goat/mountain_goat_rallies/.tmp__rally.html.erb.46831~
122
+ - lib/mountain-goat/views/mountain_goat/mountain_goat_rallies/.tmp__rally.html.erb.40484~
123
123
  - lib/mountain-goat/views/mountain_goat/mountain_goat_rallies/_rallies.html.erb
124
124
  - lib/mountain-goat/views/mountain_goat/mountain_goat_rallies/_rallies_form.html.erb
125
125
  - lib/mountain-goat/views/mountain_goat/mountain_goat_rallies/_rally.html.erb