universal-track-manager 0.5.beta1 → 0.5.beta2
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: 278087c5ade44d18ca54a5bcd8e4dd3225d7111ac85678b24e14ed4d06da269f
|
4
|
+
data.tar.gz: 36899a1a79d98f5816dd44c9596dd330cbea6244d7abe60ad8115f42c88a8e3b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b919a455ff2d743b16abb0c7abc738232e8eefe4df5d3854dab8addc9b1920620ee0ddd170f687c4cb550c1df27871252a294d01076ee48df7b9dc62d6fc5488
|
7
|
+
data.tar.gz: 84e78d05622bd14a262cc8d6fb043924f011ef3c7a46b84ff4d234019dcbf023d6c9fffceb9ba9d190cca8243405399df5c1d0d26ae05cd1e06d2a1a333aa732
|
@@ -52,31 +52,39 @@ module UniversalTrackManagerConcern
|
|
52
52
|
@now ||= Time.now
|
53
53
|
end
|
54
54
|
|
55
|
+
def new_visitor
|
56
|
+
visit = UniversalTrackManager::Visit.create!(
|
57
|
+
first_pageload: now,
|
58
|
+
last_pageload: now,
|
59
|
+
ip_v4_address: ip_address,
|
60
|
+
browser: find_or_create_browser_by_current,
|
61
|
+
campaign: find_or_create_campaign_by_current)
|
62
|
+
session[:visit_id] = visit.id
|
63
|
+
end
|
64
|
+
|
55
65
|
def track_visitor
|
56
66
|
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
|
67
|
+
new_visitor
|
64
68
|
else
|
65
|
-
# existing visit
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
69
|
+
# existing visit
|
70
|
+
begin
|
71
|
+
existing_visit = UniversalTrackManager::Visit.find(session['visit_id'])
|
72
|
+
|
73
|
+
evict_visit!(existing_visit) if any_utm_params? && !existing_visit.matches_all_utms?({utm_campaign: utm_campaign,
|
74
|
+
utm_source: utm_source,
|
75
|
+
utm_term: utm_term,
|
76
|
+
utm_content: utm_content,
|
77
|
+
utm_medium: utm_medium})
|
78
|
+
|
79
|
+
evict_visit!(existing_visit) if existing_visit.ip_v4_address != ip_address
|
80
|
+
evict_visit!(existing_visit) if existing_visit.browser && existing_visit.browser.name != user_agent
|
81
|
+
|
82
|
+
existing_visit.update_columns(:last_pageload => Time.now) if !@visit_evicted
|
83
|
+
rescue ActiveRecord::RecordNotFound
|
84
|
+
# this happens if the session table is cleared or if the record in the session
|
85
|
+
# table points to a visit that has been cleared
|
86
|
+
new_visitor
|
87
|
+
end
|
80
88
|
end
|
81
89
|
end
|
82
90
|
|
data/lib/version.rb
CHANGED
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.5.
|
4
|
+
version: 0.5.beta2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jason Fleetwood-Boldt
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-01-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|