universal-track-manager 0.7.1 → 0.7.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/generators/templates/create_universal_track_manager_tables.rb +1 -0
- data/lib/generators/universal_track_manager/install_generator.rb +41 -5
- data/lib/universal_track_manager/controllers/concerns/universal_track_manager_concern.rb +6 -2
- data/lib/universal_track_manager/models/visit.rb +6 -1
- data/lib/version.rb +1 -1
- metadata +10 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 42bec7b0ea6f8012f06c632b17da95e5a0b065ef3cfb445988a7c8305f8d1dff
|
4
|
+
data.tar.gz: 0bfbb9d1a6e43d8704c845784649d3b7dbd84c691d897d56b433237d3fb3317c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a435166404567f0986456d80460753dadd340ba26598d2ecbc46bd15e4668824c82b522a5ea00b883b15c228d8394704b74273e6680b010308d08d5b0798caea
|
7
|
+
data.tar.gz: 1c17f30402ab644ef841e90dfca4b6f38bea5420b22093e3cd907c59da27c08f4e59491d24606cfcfe38efd5bc3b278189791ceb0c8384372d59a06132f1146a
|
@@ -1,8 +1,6 @@
|
|
1
1
|
|
2
2
|
require 'rails/generators'
|
3
3
|
|
4
|
-
require 'byebug'
|
5
|
-
|
6
4
|
module UniversalTrackManager
|
7
5
|
class InstallGenerator < Rails::Generators::Base
|
8
6
|
include Rails::Generators::Migration
|
@@ -12,7 +10,13 @@ module UniversalTrackManager
|
|
12
10
|
source_root File.expand_path('../templates', __dir__)
|
13
11
|
|
14
12
|
class_option :orm, type: 'boolean'
|
15
|
-
|
13
|
+
|
14
|
+
class_option :param_list, type: :string, default: nil # DEPRECATED --- DO NOT USE
|
15
|
+
|
16
|
+
|
17
|
+
|
18
|
+
class_option :add, type: :string, default: nil
|
19
|
+
class_option :only, type: :string, default: nil
|
16
20
|
|
17
21
|
|
18
22
|
def self.next_migration_number(path)
|
@@ -21,14 +25,45 @@ module UniversalTrackManager
|
|
21
25
|
|
22
26
|
desc "Creates an initializer for Universal Track Manager and copy files to your application."
|
23
27
|
def create_universal_track_manager_migration
|
24
|
-
|
28
|
+
# guard against pre-0.7.3 sytnax
|
29
|
+
if options['param_list']
|
30
|
+
puts "Oops (FATAL): param_list is removed; use 'add' to augment the default list of fields or use 'only' to replace it"
|
31
|
+
exit
|
32
|
+
end
|
33
|
+
|
34
|
+
# guard against using both 'add' and 'only'
|
35
|
+
if options['add'] && options['only']
|
36
|
+
puts "Oops (FATAL): You specified both 'add' and 'only'; use 'add' to augment the default list of fields OR use 'only' to replace it"
|
37
|
+
exit
|
38
|
+
end
|
39
|
+
|
40
|
+
@default_params = %w{utm_source utm_medium utm_campaign utm_content utm_term}
|
41
|
+
|
42
|
+
if options['add']
|
43
|
+
options['add'].split(",").each do |p|
|
44
|
+
if !@default_params.include?(p)
|
45
|
+
@default_params << p
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
|
51
|
+
if options['only']
|
52
|
+
@default_params = []
|
53
|
+
options['only'].split(",").each do |p|
|
54
|
+
@default_params << p
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
25
58
|
column_defs = ""
|
26
|
-
@
|
59
|
+
@default_params.each do |p|
|
27
60
|
column_defs += " t.string :#{p}, limit:256\n"
|
28
61
|
end
|
29
62
|
copy_file "create_universal_track_manager_tables.rb", "#{self.class.source_root}/create_universal_track_manager_tables.rb-staged"
|
30
63
|
gsub_file "#{self.class.source_root}/create_universal_track_manager_tables.rb-staged", "#GENERATOR INSERTS CAMPAIGN COLUMNS HERE", column_defs
|
31
64
|
migration_template "create_universal_track_manager_tables.rb-staged", "db/migrate/create_universal_track_manager_tables.rb"
|
65
|
+
|
66
|
+
remove_file "#{self.class.source_root}/create_universal_track_manager_tables.rb-staged"
|
32
67
|
end
|
33
68
|
|
34
69
|
def create_universal_track_manager_initializer
|
@@ -36,6 +71,7 @@ module UniversalTrackManager
|
|
36
71
|
copy_file "universal_track_manager.rb", "#{self.class.source_root}/universal_track_manager.rb-staged"
|
37
72
|
gsub_file "#{self.class.source_root}/universal_track_manager.rb-staged", "#GENERATOR INSERTS CAMPAIGN COLUMN CONFIG HERE", column_config
|
38
73
|
copy_file 'universal_track_manager.rb-staged', 'config/initializers/universal_track_manager.rb'
|
74
|
+
remove_file "#{self.class.source_root}/universal_track_manager.rb-staged"
|
39
75
|
end
|
40
76
|
|
41
77
|
def migration_version
|
@@ -27,7 +27,7 @@ module UniversalTrackManagerConcern
|
|
27
27
|
|
28
28
|
def user_agent
|
29
29
|
return nil if ! UniversalTrackManager.track_user_agent?
|
30
|
-
request.user_agent[0..
|
30
|
+
request.user_agent && request.user_agent[0..254]
|
31
31
|
end
|
32
32
|
|
33
33
|
def now
|
@@ -101,12 +101,16 @@ module UniversalTrackManagerConcern
|
|
101
101
|
first_pageload: now,
|
102
102
|
last_pageload: now,
|
103
103
|
original_visit_id: old_visit.original_visit_id.nil? ? old_visit.id : old_visit.original_visit_id,
|
104
|
+
count: old_visit.original_visit_id.nil? ? old_visit.count + 1 : 1,
|
104
105
|
ip_v4_address: ip_address,
|
105
106
|
campaign: find_or_create_campaign_by_current
|
106
107
|
}
|
107
108
|
|
108
109
|
# fail silently if there is no user agent
|
109
|
-
|
110
|
+
if request.user_agent
|
111
|
+
params[:browser] = find_or_create_browser_by_current
|
112
|
+
end
|
113
|
+
|
110
114
|
visit = UniversalTrackManager::Visit.create!(params)
|
111
115
|
|
112
116
|
session[:visit_id] = visit.id
|
@@ -3,8 +3,9 @@ class UniversalTrackManager::Visit < ActiveRecord::Base
|
|
3
3
|
|
4
4
|
belongs_to :campaign, class_name: "UniversalTrackManager::Campaign"
|
5
5
|
belongs_to :browser, class_name: "UniversalTrackManager::Browser"
|
6
|
+
belongs_to :original_visit, optional: true, class_name: "UniversalTrackManager::Visit"
|
6
7
|
|
7
|
-
|
8
|
+
# class_name: "UniveralTrackManager::Visit",
|
8
9
|
def matches_all_utms?(params)
|
9
10
|
if !campaign
|
10
11
|
# this visit has no campaign, which means all UTMs = null
|
@@ -22,4 +23,8 @@ class UniversalTrackManager::Visit < ActiveRecord::Base
|
|
22
23
|
end
|
23
24
|
return true
|
24
25
|
end
|
26
|
+
|
27
|
+
def name
|
28
|
+
"#{ip_v4_address} #{browser.name}"
|
29
|
+
end
|
25
30
|
end
|
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.7.
|
4
|
+
version: 0.7.6
|
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: 2022-02-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '5.1'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - ">"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '5.1'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: simplecov
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -68,7 +68,7 @@ dependencies:
|
|
68
68
|
version: '2.2'
|
69
69
|
description: Simple, plug & play visitor tracking by user agent (browser), IP address,
|
70
70
|
referrer, and UTM parameters.
|
71
|
-
email:
|
71
|
+
email: support@heliosdev.shop
|
72
72
|
executables: []
|
73
73
|
extensions: []
|
74
74
|
extra_rdoc_files: []
|
@@ -84,19 +84,19 @@ files:
|
|
84
84
|
- lib/universal_track_manager/models/campaign.rb
|
85
85
|
- lib/universal_track_manager/models/visit.rb
|
86
86
|
- lib/version.rb
|
87
|
-
homepage: https://
|
87
|
+
homepage: https://heliosdev.shop/p/universal-track-manager
|
88
88
|
licenses:
|
89
89
|
- MIT
|
90
90
|
metadata:
|
91
91
|
source_code_uri: https://github.com/jasonfb/universal_track_manager
|
92
|
-
|
93
|
-
homepage_uri: https://blog.jasonfleetwoodboldt.com/my-open-source-projects/universal-track-manager/
|
92
|
+
homepage_uri: https://heliosdev.shop/p/universal-track-manager
|
94
93
|
post_install_message: |
|
95
94
|
---------------------------------------------
|
96
95
|
Welcome to Universal Track Manager
|
97
96
|
to set up, please run
|
98
97
|
|
99
98
|
rails generate universal_track_manager:install
|
99
|
+
For support see https://heliosdev.shop/p/universal-track-manager
|
100
100
|
---------------------------------------------
|
101
101
|
rdoc_options: []
|
102
102
|
require_paths:
|
@@ -112,8 +112,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
112
112
|
- !ruby/object:Gem::Version
|
113
113
|
version: '0'
|
114
114
|
requirements: []
|
115
|
-
rubygems_version: 3.
|
115
|
+
rubygems_version: 3.1.6
|
116
116
|
signing_key:
|
117
117
|
specification_version: 4
|
118
|
-
summary: A gem to track visitors to your website.
|
118
|
+
summary: A gem to track visitors and their UTMs to your website.
|
119
119
|
test_files: []
|