rack-ga-track 0.5.0 → 0.6.0
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.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/lib/rack-ga-track.rb +9 -7
- data/rack-ga-track.gemspec +3 -3
- data/spec/rack_ga_track_spec.rb +20 -6
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2488735974ca3424b3539254fec3b519e24a0d08
|
4
|
+
data.tar.gz: 4477f298dacc26bc2473f4576cc930f35a7f8191
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 073a66941beec9d8339481b0a208f69636249a38af0b106cb532a4a2d536b5fd0a6d0b918afd04ab320fcf4482eaf139d78d56bb2c8576ee5e1e3428413c3a70
|
7
|
+
data.tar.gz: f8ee3d175f2864b957f7efeaadedb0190a7d16d2a74fe3f2b2134f8cb40cf32fa3e3d5bdbd0b115df5ac6144f8176b8b7abde507903fbcbb0313df2653795ff6
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.6.0
|
data/lib/rack-ga-track.rb
CHANGED
@@ -26,20 +26,22 @@ module Rack
|
|
26
26
|
|
27
27
|
def set_params(req)
|
28
28
|
if req.params['utm_source']
|
29
|
-
return params_hash(req
|
29
|
+
return params_hash(req)
|
30
30
|
elsif req.cookies['ga_track'] && !req.cookies['ga_track'].empty?
|
31
31
|
return JSON.parse(req.cookies['ga_track'])
|
32
32
|
end
|
33
33
|
false
|
34
34
|
end
|
35
35
|
|
36
|
-
def params_hash(
|
36
|
+
def params_hash(req)
|
37
37
|
{
|
38
|
-
source: params['utm_source'],
|
39
|
-
medium: params['utm_medium'],
|
40
|
-
term: params['utm_term'],
|
41
|
-
content: params['utm_content'],
|
42
|
-
campaign: params['utm_campaign'],
|
38
|
+
source: req.params['utm_source'],
|
39
|
+
medium: req.params['utm_medium'],
|
40
|
+
term: req.params['utm_term'],
|
41
|
+
content: req.params['utm_content'],
|
42
|
+
campaign: req.params['utm_campaign'],
|
43
|
+
referer: req.referer,
|
44
|
+
landing_page: req.path,
|
43
45
|
time: Time.now.to_i
|
44
46
|
}
|
45
47
|
end
|
data/rack-ga-track.gemspec
CHANGED
@@ -2,16 +2,16 @@
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
3
|
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
|
-
# stub: rack-ga-track 0.
|
5
|
+
# stub: rack-ga-track 0.6.0 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "rack-ga-track"
|
9
|
-
s.version = "0.
|
9
|
+
s.version = "0.6.0"
|
10
10
|
|
11
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
12
12
|
s.require_paths = ["lib"]
|
13
13
|
s.authors = ["Daniel Nolan"]
|
14
|
-
s.date = "2014-
|
14
|
+
s.date = "2014-08-21"
|
15
15
|
s.description = "If the user visits via a Google Analytics Campaign link,\n this middleware will track utm_source, utm_content, utm_term, utm_medium, utm_campaign, and time."
|
16
16
|
s.email = "dnolan@t1dexchange.org"
|
17
17
|
s.extra_rdoc_files = [
|
data/spec/rack_ga_track_spec.rb
CHANGED
@@ -15,6 +15,8 @@ describe "RackGaTrack" do
|
|
15
15
|
last_request.env['ga_track.content'].must_equal nil
|
16
16
|
last_request.env['ga_track.medium'].must_equal nil
|
17
17
|
last_request.env['ga_track.time'].must_equal nil
|
18
|
+
last_request.env['ga_track.referer'].must_equal nil
|
19
|
+
last_request.env['ga_track.landing_page'].must_equal nil
|
18
20
|
end
|
19
21
|
|
20
22
|
it "should set ga_track env vars from params" do
|
@@ -24,13 +26,15 @@ describe "RackGaTrack" do
|
|
24
26
|
utm_campaign: 'email',
|
25
27
|
utm_medium: 'test_medium' }
|
26
28
|
|
27
|
-
get '/', params
|
29
|
+
get '/testing', params, 'HTTP_REFERER' => "http://www.foo.com"
|
28
30
|
end
|
29
31
|
|
30
32
|
last_request.env['ga_track.source'].must_equal "testing"
|
31
33
|
last_request.env['ga_track.campaign'].must_equal "email"
|
32
34
|
last_request.env['ga_track.medium'].must_equal "test_medium"
|
33
35
|
last_request.env['ga_track.time'].must_equal @time.to_i
|
36
|
+
last_request.env['ga_track.referer'].must_equal 'http://www.foo.com'
|
37
|
+
last_request.env['ga_track.landing_page'].must_equal '/testing'
|
34
38
|
end
|
35
39
|
|
36
40
|
it "should save GA Campaign params in a cookie" do
|
@@ -40,7 +44,7 @@ describe "RackGaTrack" do
|
|
40
44
|
utm_campaign: 'email',
|
41
45
|
utm_medium: 'test_medium' }
|
42
46
|
|
43
|
-
get '/', params
|
47
|
+
get '/testing', params, 'HTTP_REFERER' => "http://www.foo.com"
|
44
48
|
end
|
45
49
|
|
46
50
|
cookie_params = JSON.parse(rack_mock_session.cookie_jar["ga_track"])
|
@@ -49,16 +53,22 @@ describe "RackGaTrack" do
|
|
49
53
|
cookie_params["campaign"].must_equal "email"
|
50
54
|
cookie_params["medium"].must_equal "test_medium"
|
51
55
|
cookie_params["time"].must_equal @time.to_i
|
56
|
+
cookie_params["referer"].must_equal 'http://www.foo.com'
|
57
|
+
cookie_params["landing_page"].must_equal '/testing'
|
52
58
|
end
|
53
59
|
|
54
60
|
describe "when cookie exists" do
|
55
61
|
before :each do
|
56
62
|
@time = Time.now
|
57
63
|
clear_cookies
|
58
|
-
@params = {
|
59
|
-
|
60
|
-
|
61
|
-
|
64
|
+
@params = {
|
65
|
+
source: 'testing',
|
66
|
+
campaign: 'email',
|
67
|
+
medium: 'test_medium',
|
68
|
+
time: @time.to_i,
|
69
|
+
referer: 'http://www.foo.com',
|
70
|
+
landing_page: '/testing'
|
71
|
+
}
|
62
72
|
rack_mock_session.cookie_jar["ga_track"] = @params.to_json
|
63
73
|
end
|
64
74
|
|
@@ -71,6 +81,8 @@ describe "RackGaTrack" do
|
|
71
81
|
last_request.env['ga_track.campaign'].must_equal "email"
|
72
82
|
last_request.env['ga_track.medium'].must_equal "test_medium"
|
73
83
|
last_request.env['ga_track.time'].must_equal @time.to_i
|
84
|
+
last_request.env['ga_track.referer'].must_equal 'http://www.foo.com'
|
85
|
+
last_request.env['ga_track.landing_page'].must_equal '/testing'
|
74
86
|
end
|
75
87
|
|
76
88
|
it 'should not update existing cookie' do
|
@@ -82,6 +94,8 @@ describe "RackGaTrack" do
|
|
82
94
|
last_request.env['ga_track.campaign'].must_equal "email"
|
83
95
|
last_request.env['ga_track.medium'].must_equal "test_medium"
|
84
96
|
last_request.env['ga_track.time'].must_equal @time.to_i
|
97
|
+
last_request.env['ga_track.referer'].must_equal 'http://www.foo.com'
|
98
|
+
last_request.env['ga_track.landing_page'].must_equal '/testing'
|
85
99
|
|
86
100
|
rack_mock_session.cookie_jar["ga_track"].must_equal JSON.generate(@params)
|
87
101
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rack-ga-track
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel Nolan
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-08-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rack
|