session_logger 1.0.2 → 1.0.3
Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc
CHANGED
@@ -40,11 +40,13 @@ Finally add 'enable_session_logger' to Application controller (or any controller
|
|
40
40
|
|
41
41
|
1 Create metadata columns on the models you want metadata recorded on
|
42
42
|
|
43
|
-
add_column :users :sl_campaign
|
44
|
-
add_column :users :sl_source
|
45
|
-
add_column :users :sl_medium
|
46
|
-
add_column :users :
|
47
|
-
add_column :users :
|
43
|
+
add_column :users, :sl_campaign, :string
|
44
|
+
add_column :users, :sl_source, :string
|
45
|
+
add_column :users, :sl_medium, :string
|
46
|
+
add_column :users, :sl_term, :string
|
47
|
+
add_column :users, :sl_content, :string
|
48
|
+
add_column :users, :sl_landing_page, :string
|
49
|
+
add_column :users, :sl_session_id, :string
|
48
50
|
|
49
51
|
2 Be sure to prefix metadata columns with the model prefix ("sl_" by default)
|
50
52
|
|
@@ -58,8 +60,29 @@ Finally add 'enable_session_logger' to Application controller (or any controller
|
|
58
60
|
before_filter :pull_campaign_data
|
59
61
|
|
60
62
|
def pull_campaign_data
|
61
|
-
|
62
|
-
|
63
|
+
first_time = session['meta_stored'].blank?
|
64
|
+
mapping = {"utm_source" => "sl_source", "utm_medium" => "sl_medium",
|
65
|
+
"utm_term" => "sl_term", "utm_content" => "sl_content",
|
66
|
+
"utm_campaign" =>"sl_campaign"}
|
67
|
+
|
68
|
+
new_values = {}
|
69
|
+
mapping.each do |param_key, session_key|
|
70
|
+
value = params[param_key]
|
71
|
+
if value.present? && session[session_key] != value
|
72
|
+
new_values[session_key] = value
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
#Override all the campaign values when new ones come in
|
77
|
+
#new values will be empty when link doesn't have utm params
|
78
|
+
if (new_values.present? || first_time)
|
79
|
+
#Store the landingpage with the utm params, and session id
|
80
|
+
new_values["sl_landing_uri"] = request.env["REQUEST_URI"]
|
81
|
+
new_values["sl_session_id"] = request.session_options[:id]
|
82
|
+
session.merge!(new_values)
|
83
|
+
end
|
84
|
+
|
85
|
+
session['meta_stored'] = true
|
63
86
|
end
|
64
87
|
|
65
88
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# The configure step must be run after the rails app has finished initializing
|
2
2
|
# for the models to respond to observer registration requests
|
3
|
-
Rails.application.config.
|
3
|
+
Rails.application.config.to_prepare do
|
4
4
|
SessionLogger.configure do |config|
|
5
5
|
|
6
6
|
# Default is to observe all models in the models dir
|
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.
|
5
|
+
version: 1.0.3
|
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:
|
13
|
+
date: 2012-01-25 00:00:00 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rails
|
@@ -235,7 +235,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
235
235
|
requirements: []
|
236
236
|
|
237
237
|
rubyforge_project:
|
238
|
-
rubygems_version: 1.8.
|
238
|
+
rubygems_version: 1.8.15
|
239
239
|
signing_key:
|
240
240
|
specification_version: 3
|
241
241
|
summary: Logs rails model updates with session info
|