session_logger 1.0.1 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -30,21 +30,44 @@ And/or add it to your Gemfile
30
30
  Then create the initializer:
31
31
  rails generate session_logger:initializer
32
32
 
33
- As a performance optimization you can add the list of models to observe in the initializer:
34
- config.session_logger.logged_models = [MODEL_CONSTANTS,...]
35
-
36
33
  Finally add 'enable_session_logger' to Application controller (or any controller you want logging to occur)
37
34
  ApplicationController < ActionController::Base
38
- enable_session_logger
35
+ enable_session_logging
39
36
  end
40
37
 
41
38
 
42
39
  == Usage
43
40
 
44
- 1. Create metadata columns on the models you want metadata recorded on
45
- 2. Be sure to prefix metadata columns with the model prefix ("sl_" by default)
46
- 3. Simply set that same prefixed name in the session and that metadata will be stored anytime a observed record is created during that session.
47
-
41
+ 1 Create metadata columns on the models you want metadata recorded on
42
+
43
+ add_column :users :sl_campaign
44
+ add_column :users :sl_source
45
+ add_column :users :sl_medium
46
+ add_column :users :sl_landing_page
47
+ add_column :users :sl_session_id
48
+
49
+ 2 Be sure to prefix metadata columns with the model prefix ("sl_" by default)
50
+
51
+ SessionLogger.configure do |config|
52
+ config.model_prefix = "sl_" # means columns are like: sl_XXXX
53
+ end
54
+ 3 Simply set that same prefixed name in the session and that metadata will be stored anytime a observed record is created during that session.
55
+
56
+ ApplicationController < ActionController::Base
57
+ enable_session_logging
58
+ before_filter :pull_campaign_data
59
+
60
+ def pull_campaign_data
61
+ session[:sl_campaign] = params[:sl_campaign]
62
+ ...
63
+ end
64
+
65
+ end
66
+
67
+ 4 Later segment your data naturally using the columns you defined
68
+
69
+ User.where(:sl_campaign => "facebook_ads_1").count
70
+ ...
48
71
 
49
72
  == How it works
50
73
 
@@ -58,6 +81,7 @@ appending the metadata for that users session.
58
81
 
59
82
  == Gotchas
60
83
 
84
+
61
85
  If you start monitoring a ton of metadata around the user you have to switch
62
86
  to db sessions instead of cookie store.
63
87
 
@@ -92,5 +116,11 @@ this will give you a bad taste in your mouth but it seems like a better
92
116
  solution overall.
93
117
 
94
118
 
119
+ == Optimizations
120
+
121
+ As a performance optimization you can reduce the list of models to observe in the initializer:
122
+ config.session_logger.logged_models = [MODEL_CONSTANTS,...]
123
+
124
+
95
125
  == License
96
126
  This project rocks and uses MIT-LICENSE.
@@ -60,9 +60,6 @@ module SessionLogger
60
60
 
61
61
  private
62
62
  def set_if_present(obj, key, val)
63
- pp obj
64
- pp key
65
- pp val
66
63
  obj.send("#{key}=", val) if val.present?
67
64
  end
68
65
  end
@@ -1,3 +1,3 @@
1
1
  module SessionLogger
2
- VERSION = "1.0.1"
2
+ VERSION = "1.0.2"
3
3
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: session_logger
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 1.0.1
5
+ version: 1.0.2
6
6
  platform: ruby
7
7
  authors:
8
8
  - Timothy Cardenas
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-11-05 00:00:00 Z
13
+ date: 2011-11-08 00:00:00 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rails