universal-track-manager 0.5.beta1 → 0.6.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.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b7e8f1a36f7a12f90ea440dfdd54d7797c820ccfdfc47c014832794bdf083426
|
4
|
+
data.tar.gz: cc7cd314a64fa5a6cd3a0fc92bf37014608069f5012cbf2621534ff853c1eb4e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 90dd0a3aef33513c517df1bf035fc1cdc56664be4ff47d234be8293bf719bed752faa4e24aa0e1501fbf39b8716c051d67132d2b69bd273b29aa9fb0ee0597b4
|
7
|
+
data.tar.gz: f29a7e6975a08d4e8efebe83047f6c01e56e9fe130a3ce9dbc54172e0d7f8a7d39b521d3f0af43619cc8a1ef9625dc3c7c2be56cf23bda65cf04ed3661d9b20e
|
@@ -1,6 +1,5 @@
|
|
1
1
|
module UniversalTrackManagerConcern
|
2
2
|
extend ActiveSupport::Concern
|
3
|
-
|
4
3
|
attr_accessor :visit_evicted
|
5
4
|
|
6
5
|
included do
|
@@ -52,31 +51,41 @@ module UniversalTrackManagerConcern
|
|
52
51
|
@now ||= Time.now
|
53
52
|
end
|
54
53
|
|
54
|
+
def new_visitor
|
55
|
+
params = {
|
56
|
+
first_pageload: now,
|
57
|
+
last_pageload: now,
|
58
|
+
ip_v4_address: ip_address,
|
59
|
+
campaign: find_or_create_campaign_by_current
|
60
|
+
}
|
61
|
+
params[:browser] = find_or_create_browser_by_current if request.user_agent
|
62
|
+
visit = UniversalTrackManager::Visit.create!(params)
|
63
|
+
session[:visit_id] = visit.id
|
64
|
+
end
|
65
|
+
|
55
66
|
def track_visitor
|
56
67
|
if !session['visit_id']
|
57
|
-
|
58
|
-
first_pageload: now,
|
59
|
-
last_pageload: now,
|
60
|
-
ip_v4_address: ip_address,
|
61
|
-
browser: find_or_create_browser_by_current,
|
62
|
-
campaign: find_or_create_campaign_by_current)
|
63
|
-
session[:visit_id] = visit.id
|
68
|
+
new_visitor
|
64
69
|
else
|
65
|
-
# existing visit
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
70
|
+
# existing visit
|
71
|
+
begin
|
72
|
+
existing_visit = UniversalTrackManager::Visit.find(session['visit_id'])
|
73
|
+
|
74
|
+
evict_visit!(existing_visit) if any_utm_params? && !existing_visit.matches_all_utms?({utm_campaign: utm_campaign,
|
75
|
+
utm_source: utm_source,
|
76
|
+
utm_term: utm_term,
|
77
|
+
utm_content: utm_content,
|
78
|
+
utm_medium: utm_medium})
|
79
|
+
|
80
|
+
evict_visit!(existing_visit) if existing_visit.ip_v4_address != ip_address
|
81
|
+
evict_visit!(existing_visit) if existing_visit.browser && existing_visit.browser.name != user_agent
|
82
|
+
|
83
|
+
existing_visit.update_columns(:last_pageload => Time.now) if !@visit_evicted
|
84
|
+
rescue ActiveRecord::RecordNotFound
|
85
|
+
# this happens if the session table is cleared or if the record in the session
|
86
|
+
# table points to a visit that has been cleared
|
87
|
+
new_visitor
|
88
|
+
end
|
80
89
|
end
|
81
90
|
end
|
82
91
|
|
@@ -106,14 +115,18 @@ module UniversalTrackManagerConcern
|
|
106
115
|
|
107
116
|
def evict_visit!(old_visit)
|
108
117
|
@visit_evicted = true
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
118
|
+
params = {
|
119
|
+
first_pageload: now,
|
120
|
+
last_pageload: now,
|
121
|
+
original_visit_id: old_visit.original_visit_id.nil? ? old_visit.id : old_visit.original_visit_id,
|
122
|
+
ip_v4_address: ip_address,
|
123
|
+
campaign: find_or_create_campaign_by_current
|
124
|
+
}
|
125
|
+
|
126
|
+
# fail silently if there is no user agent
|
127
|
+
params[:browser] = find_or_create_browser_by_current if request.user_agent
|
128
|
+
visit = UniversalTrackManager::Visit.create!(params)
|
116
129
|
|
117
130
|
session[:visit_id] = visit.id
|
118
131
|
end
|
119
|
-
end
|
132
|
+
end
|
data/lib/version.rb
CHANGED
@@ -1,3 +1,3 @@
|
|
1
1
|
module UniversalTrackManager
|
2
|
-
VERSION = "0.
|
3
|
-
end
|
2
|
+
VERSION = "0.6.3"
|
3
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: universal-track-manager
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jason Fleetwood-Boldt
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-10-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -70,7 +70,7 @@ files:
|
|
70
70
|
- lib/universal_track_manager/models/campaign.rb
|
71
71
|
- lib/universal_track_manager/models/visit.rb
|
72
72
|
- lib/version.rb
|
73
|
-
homepage:
|
73
|
+
homepage: https://blog.jasonfleetwoodboldt.com/universal-track-manager/
|
74
74
|
licenses:
|
75
75
|
- MIT
|
76
76
|
metadata:
|
@@ -92,12 +92,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
92
92
|
version: '0'
|
93
93
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
94
94
|
requirements:
|
95
|
-
- - "
|
95
|
+
- - ">="
|
96
96
|
- !ruby/object:Gem::Version
|
97
|
-
version:
|
97
|
+
version: '0'
|
98
98
|
requirements: []
|
99
|
-
rubygems_version: 3.0.
|
100
|
-
signing_key:
|
99
|
+
rubygems_version: 3.0.8
|
100
|
+
signing_key:
|
101
101
|
specification_version: 4
|
102
102
|
summary: A gem to track visitors to your website.
|
103
103
|
test_files: []
|